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 | |
Michael J. Spencer | ab425d8 | 2010-11-29 18:47:54 +0000 | [diff] [blame] | 18 | #include "llvm/Support/DataTypes.h" |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 19 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 20 | #ifdef __cplusplus |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 21 | |
| 22 | /* Need these includes to support the LLVM 'cast' template for the C++ 'wrap' |
| 23 | and 'unwrap' conversion functions. */ |
| 24 | #include "llvm/Module.h" |
Owen Anderson | 4698c5d | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 25 | #include "llvm/PassRegistry.h" |
Duncan Sands | a07136e | 2008-04-13 06:22:09 +0000 | [diff] [blame] | 26 | #include "llvm/Support/IRBuilder.h" |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 27 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 28 | extern "C" { |
| 29 | #endif |
| 30 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 31 | /** |
| 32 | * @defgroup LLVMC LLVM-C: C interface to LLVM |
| 33 | * |
| 34 | * This module exposes parts of the LLVM library as a C API. |
| 35 | * |
| 36 | * @{ |
| 37 | */ |
| 38 | |
| 39 | /** |
| 40 | * @defgroup LLVMCTransforms Transforms |
| 41 | */ |
| 42 | |
| 43 | /** |
| 44 | * @defgroup LLVMCCore Core |
| 45 | * |
| 46 | * This modules provide an interface to libLLVMCore, which implements |
| 47 | * the LLVM intermediate representation as well as other related types |
| 48 | * and utilities. |
| 49 | * |
| 50 | * LLVM uses a polymorphic type hierarchy which C cannot represent, therefore |
| 51 | * parameters must be passed as base types. Despite the declared types, most |
| 52 | * of the functions provided operate only on branches of the type hierarchy. |
| 53 | * The declared parameter names are descriptive and specify which type is |
| 54 | * required. Additionally, each type hierarchy is documented along with the |
| 55 | * functions that operate upon it. For more detail, refer to LLVM's C++ code. |
| 56 | * If in doubt, refer to Core.cpp, which performs paramter downcasts in the |
| 57 | * form unwrap<RequiredType>(Param). |
| 58 | * |
| 59 | * Many exotic languages can interoperate with C code but have a harder time |
| 60 | * with C++ due to name mangling. So in addition to C, this interface enables |
| 61 | * tools written in such languages. |
| 62 | * |
| 63 | * When included into a C++ source file, also declares 'wrap' and 'unwrap' |
| 64 | * helpers to perform opaque reference<-->pointer conversions. These helpers |
| 65 | * are shorter and more tightly typed than writing the casts by hand when |
| 66 | * authoring bindings. In assert builds, they will do runtime type checking. |
| 67 | * |
| 68 | * @{ |
| 69 | */ |
| 70 | |
| 71 | /** |
| 72 | * @defgroup LLVMCCoreTypes Types and Enumerations |
| 73 | * |
| 74 | * @{ |
| 75 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 76 | |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 77 | typedef int LLVMBool; |
| 78 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 79 | /* Opaque types. */ |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 80 | |
| 81 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 82 | * 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] | 83 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 84 | typedef struct LLVMOpaqueContext *LLVMContextRef; |
Owen Anderson | 6773d38 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 85 | |
| 86 | /** |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 87 | * The top-level container for all other LLVM Intermediate Representation (IR) |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 88 | * objects. |
| 89 | * |
| 90 | * @see llvm::Module |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 91 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 92 | typedef struct LLVMOpaqueModule *LLVMModuleRef; |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 93 | |
| 94 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 95 | * Each value in the LLVM IR has a type, an LLVMTypeRef. |
| 96 | * |
| 97 | * @see llvm::Type |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 98 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 99 | typedef struct LLVMOpaqueType *LLVMTypeRef; |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 100 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 101 | /** |
| 102 | * Represents an individual value in LLVM IR. |
| 103 | * |
| 104 | * This models llvm::Value. |
| 105 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 106 | typedef struct LLVMOpaqueValue *LLVMValueRef; |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Represents a basic block of instruction in LLVM IR. |
| 110 | * |
| 111 | * This models llvm::BasicBlock. |
| 112 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 113 | typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Represents an LLVM basic block builder. |
| 117 | * |
| 118 | * This models llvm::IRBuilder. |
| 119 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 120 | typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 121 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 122 | /** |
| 123 | * Interface used to provide a module to JIT or interpreter. |
| 124 | * This is now just a synonym for llvm::Module, but we have to keep using the |
| 125 | * different type to keep binary compatibility. |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 126 | */ |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 127 | typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 128 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 129 | /** |
| 130 | * Used to provide a module to JIT or interpreter. |
| 131 | * |
| 132 | * @see llvm::MemoryBuffer |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 133 | */ |
| 134 | typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef; |
| 135 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 136 | /** @see llvm::PassManagerBase */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 137 | typedef struct LLVMOpaquePassManager *LLVMPassManagerRef; |
| 138 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 139 | /** @see llvm::PassRegistry */ |
Owen Anderson | 4698c5d | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 140 | typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef; |
| 141 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 142 | /** |
| 143 | * Used to get the users and usees of a Value. |
| 144 | * |
| 145 | * @see llvm::Use */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 146 | typedef struct LLVMOpaqueUse *LLVMUseRef; |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 147 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 148 | typedef enum { |
Devang Patel | 4c758ea | 2008-09-25 21:00:45 +0000 | [diff] [blame] | 149 | LLVMZExtAttribute = 1<<0, |
| 150 | LLVMSExtAttribute = 1<<1, |
| 151 | LLVMNoReturnAttribute = 1<<2, |
| 152 | LLVMInRegAttribute = 1<<3, |
| 153 | LLVMStructRetAttribute = 1<<4, |
| 154 | LLVMNoUnwindAttribute = 1<<5, |
| 155 | LLVMNoAliasAttribute = 1<<6, |
| 156 | LLVMByValAttribute = 1<<7, |
| 157 | LLVMNestAttribute = 1<<8, |
| 158 | LLVMReadNoneAttribute = 1<<9, |
Anton Korobeynikov | c8ce7b08 | 2009-07-17 18:07:26 +0000 | [diff] [blame] | 159 | LLVMReadOnlyAttribute = 1<<10, |
Anton Korobeynikov | 9750be9 | 2009-07-17 18:57:16 +0000 | [diff] [blame] | 160 | LLVMNoInlineAttribute = 1<<11, |
| 161 | LLVMAlwaysInlineAttribute = 1<<12, |
| 162 | LLVMOptimizeForSizeAttribute = 1<<13, |
| 163 | LLVMStackProtectAttribute = 1<<14, |
| 164 | LLVMStackProtectReqAttribute = 1<<15, |
Erick Tryzelaar | 8f69fea | 2010-03-03 23:51:25 +0000 | [diff] [blame] | 165 | LLVMAlignment = 31<<16, |
Anton Korobeynikov | 9750be9 | 2009-07-17 18:57:16 +0000 | [diff] [blame] | 166 | LLVMNoCaptureAttribute = 1<<21, |
| 167 | LLVMNoRedZoneAttribute = 1<<22, |
| 168 | LLVMNoImplicitFloatAttribute = 1<<23, |
Jakob Stoklund Olesen | 74bb06c | 2010-02-06 01:16:28 +0000 | [diff] [blame] | 169 | LLVMNakedAttribute = 1<<24, |
Erick Tryzelaar | 8f69fea | 2010-03-03 23:51:25 +0000 | [diff] [blame] | 170 | LLVMInlineHintAttribute = 1<<25, |
Torok Edwin | 1db48c0 | 2011-10-06 12:13:32 +0000 | [diff] [blame] | 171 | LLVMStackAlignment = 7<<26, |
| 172 | LLVMReturnsTwice = 1 << 29, |
| 173 | LLVMUWTable = 1 << 30, |
Chandler Carruth | 44d69d9 | 2012-01-25 07:40:15 +0000 | [diff] [blame] | 174 | LLVMNonLazyBind = 1 << 31 |
| 175 | |
| 176 | // FIXME: This attribute is currently not included in the C API as |
| 177 | // a temporary measure until the API/ABI impact to the C API is understood |
| 178 | // and the path forward agreed upon. |
| 179 | //LLVMAddressSafety = 1ULL << 32 |
Devang Patel | 4c758ea | 2008-09-25 21:00:45 +0000 | [diff] [blame] | 180 | } LLVMAttribute; |
Gordon Henriksen | 2d9cc21 | 2008-04-28 17:37:06 +0000 | [diff] [blame] | 181 | |
| 182 | typedef enum { |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 183 | /* Terminator Instructions */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 184 | LLVMRet = 1, |
| 185 | LLVMBr = 2, |
| 186 | LLVMSwitch = 3, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 187 | LLVMIndirectBr = 4, |
| 188 | LLVMInvoke = 5, |
Bill Wendling | 46ffaa9 | 2011-08-02 06:20:17 +0000 | [diff] [blame] | 189 | /* removed 6 due to API changes */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 190 | LLVMUnreachable = 7, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 191 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 192 | /* Standard Binary Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 193 | LLVMAdd = 8, |
| 194 | LLVMFAdd = 9, |
| 195 | LLVMSub = 10, |
| 196 | LLVMFSub = 11, |
| 197 | LLVMMul = 12, |
| 198 | LLVMFMul = 13, |
| 199 | LLVMUDiv = 14, |
| 200 | LLVMSDiv = 15, |
| 201 | LLVMFDiv = 16, |
| 202 | LLVMURem = 17, |
| 203 | LLVMSRem = 18, |
| 204 | LLVMFRem = 19, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 205 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 206 | /* Logical Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 207 | LLVMShl = 20, |
| 208 | LLVMLShr = 21, |
| 209 | LLVMAShr = 22, |
| 210 | LLVMAnd = 23, |
| 211 | LLVMOr = 24, |
| 212 | LLVMXor = 25, |
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 | /* Memory Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 215 | LLVMAlloca = 26, |
| 216 | LLVMLoad = 27, |
| 217 | LLVMStore = 28, |
| 218 | LLVMGetElementPtr = 29, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 219 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 220 | /* Cast Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 221 | LLVMTrunc = 30, |
| 222 | LLVMZExt = 31, |
| 223 | LLVMSExt = 32, |
| 224 | LLVMFPToUI = 33, |
| 225 | LLVMFPToSI = 34, |
| 226 | LLVMUIToFP = 35, |
| 227 | LLVMSIToFP = 36, |
| 228 | LLVMFPTrunc = 37, |
| 229 | LLVMFPExt = 38, |
| 230 | LLVMPtrToInt = 39, |
| 231 | LLVMIntToPtr = 40, |
| 232 | LLVMBitCast = 41, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 233 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 234 | /* Other Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 235 | LLVMICmp = 42, |
| 236 | LLVMFCmp = 43, |
| 237 | LLVMPHI = 44, |
| 238 | LLVMCall = 45, |
| 239 | LLVMSelect = 46, |
Torok Edwin | 05dc9d6 | 2011-10-06 12:39:34 +0000 | [diff] [blame] | 240 | LLVMUserOp1 = 47, |
| 241 | LLVMUserOp2 = 48, |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 242 | LLVMVAArg = 49, |
| 243 | LLVMExtractElement = 50, |
| 244 | LLVMInsertElement = 51, |
| 245 | LLVMShuffleVector = 52, |
| 246 | LLVMExtractValue = 53, |
| 247 | LLVMInsertValue = 54, |
Eli Friedman | 4fc946c | 2011-07-27 18:59:19 +0000 | [diff] [blame] | 248 | |
| 249 | /* Atomic operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 250 | LLVMFence = 55, |
Eli Friedman | c9a551e | 2011-07-28 21:48:00 +0000 | [diff] [blame] | 251 | LLVMAtomicCmpXchg = 56, |
Bill Wendling | f891bf8 | 2011-07-31 06:30:59 +0000 | [diff] [blame] | 252 | LLVMAtomicRMW = 57, |
| 253 | |
| 254 | /* Exception Handling Operators */ |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 255 | LLVMResume = 58, |
Bill Wendling | 0aef16a | 2012-02-06 21:44:22 +0000 | [diff] [blame] | 256 | LLVMLandingPad = 59 |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 257 | |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 258 | } LLVMOpcode; |
| 259 | |
| 260 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 261 | LLVMVoidTypeKind, /**< type with no size */ |
Dan Gohman | 518cda4 | 2011-12-17 00:04:22 +0000 | [diff] [blame] | 262 | LLVMHalfTypeKind, /**< 16 bit floating point type */ |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 263 | LLVMFloatTypeKind, /**< 32 bit floating point type */ |
| 264 | LLVMDoubleTypeKind, /**< 64 bit floating point type */ |
| 265 | LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ |
| 266 | LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ |
| 267 | LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ |
| 268 | LLVMLabelTypeKind, /**< Labels */ |
| 269 | LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ |
| 270 | LLVMFunctionTypeKind, /**< Functions */ |
| 271 | LLVMStructTypeKind, /**< Structures */ |
| 272 | LLVMArrayTypeKind, /**< Arrays */ |
| 273 | LLVMPointerTypeKind, /**< Pointers */ |
Chris Lattner | dac44ec | 2009-07-15 22:00:31 +0000 | [diff] [blame] | 274 | LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */ |
Dale Johannesen | baa5d04 | 2010-09-10 20:55:01 +0000 | [diff] [blame] | 275 | LLVMMetadataTypeKind, /**< Metadata */ |
| 276 | LLVMX86_MMXTypeKind /**< X86 MMX */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 277 | } LLVMTypeKind; |
| 278 | |
| 279 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 280 | LLVMExternalLinkage, /**< Externally visible function */ |
Chris Lattner | 2dba0f0 | 2009-04-13 06:25:37 +0000 | [diff] [blame] | 281 | LLVMAvailableExternallyLinkage, |
Duncan Sands | 12da8ce | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 282 | LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/ |
| 283 | LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something |
| 284 | equivalent. */ |
| 285 | LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */ |
| 286 | LLVMWeakODRLinkage, /**< Same, but only replaced by something |
| 287 | equivalent. */ |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 288 | LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ |
| 289 | LLVMInternalLinkage, /**< Rename collisions when linking (static |
| 290 | functions) */ |
Duncan Sands | 12da8ce | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 291 | LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */ |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 292 | LLVMDLLImportLinkage, /**< Function to be imported from DLL */ |
| 293 | LLVMDLLExportLinkage, /**< Function to be accessible from DLL */ |
Duncan Sands | e288105 | 2009-03-11 08:08:06 +0000 | [diff] [blame] | 294 | LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 295 | LLVMGhostLinkage, /**< Obsolete */ |
Bill Wendling | 002b167 | 2009-07-20 18:22:52 +0000 | [diff] [blame] | 296 | LLVMCommonLinkage, /**< Tentative definitions */ |
Bill Wendling | 03bcd6e | 2010-07-01 21:55:59 +0000 | [diff] [blame] | 297 | LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */ |
Bill Wendling | 578ee40 | 2010-08-20 22:05:50 +0000 | [diff] [blame] | 298 | LLVMLinkerPrivateWeakLinkage, /**< Like LinkerPrivate, but is weak. */ |
| 299 | LLVMLinkerPrivateWeakDefAutoLinkage /**< Like LinkerPrivateWeak, but possibly |
| 300 | hidden. */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 301 | } LLVMLinkage; |
| 302 | |
| 303 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 304 | LLVMDefaultVisibility, /**< The GV is visible */ |
| 305 | LLVMHiddenVisibility, /**< The GV is hidden */ |
| 306 | LLVMProtectedVisibility /**< The GV is protected */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 307 | } LLVMVisibility; |
| 308 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 309 | typedef enum { |
| 310 | LLVMCCallConv = 0, |
| 311 | LLVMFastCallConv = 8, |
| 312 | LLVMColdCallConv = 9, |
| 313 | LLVMX86StdcallCallConv = 64, |
| 314 | LLVMX86FastcallCallConv = 65 |
| 315 | } LLVMCallConv; |
| 316 | |
| 317 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 318 | LLVMIntEQ = 32, /**< equal */ |
| 319 | LLVMIntNE, /**< not equal */ |
| 320 | LLVMIntUGT, /**< unsigned greater than */ |
| 321 | LLVMIntUGE, /**< unsigned greater or equal */ |
| 322 | LLVMIntULT, /**< unsigned less than */ |
| 323 | LLVMIntULE, /**< unsigned less or equal */ |
| 324 | LLVMIntSGT, /**< signed greater than */ |
| 325 | LLVMIntSGE, /**< signed greater or equal */ |
| 326 | LLVMIntSLT, /**< signed less than */ |
| 327 | LLVMIntSLE /**< signed less or equal */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 328 | } LLVMIntPredicate; |
| 329 | |
| 330 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 331 | LLVMRealPredicateFalse, /**< Always false (always folded) */ |
| 332 | LLVMRealOEQ, /**< True if ordered and equal */ |
| 333 | LLVMRealOGT, /**< True if ordered and greater than */ |
| 334 | LLVMRealOGE, /**< True if ordered and greater than or equal */ |
| 335 | LLVMRealOLT, /**< True if ordered and less than */ |
| 336 | LLVMRealOLE, /**< True if ordered and less than or equal */ |
| 337 | LLVMRealONE, /**< True if ordered and operands are unequal */ |
| 338 | LLVMRealORD, /**< True if ordered (no nans) */ |
| 339 | LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */ |
| 340 | LLVMRealUEQ, /**< True if unordered or equal */ |
| 341 | LLVMRealUGT, /**< True if unordered or greater than */ |
| 342 | LLVMRealUGE, /**< True if unordered, greater than, or equal */ |
| 343 | LLVMRealULT, /**< True if unordered or less than */ |
| 344 | LLVMRealULE, /**< True if unordered, less than, or equal */ |
| 345 | LLVMRealUNE, /**< True if unordered or not equal */ |
| 346 | LLVMRealPredicateTrue /**< Always true (always folded) */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 347 | } LLVMRealPredicate; |
| 348 | |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 349 | typedef enum { |
| 350 | LLVMLandingPadCatch, /**< A catch clause */ |
| 351 | LLVMLandingPadFilter /**< A filter clause */ |
| 352 | } LLVMLandingPadClauseTy; |
| 353 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 354 | /** |
| 355 | * @} |
| 356 | */ |
| 357 | |
Nick Lewycky | 0db2654 | 2011-05-15 07:20:34 +0000 | [diff] [blame] | 358 | void LLVMInitializeCore(LLVMPassRegistryRef R); |
| 359 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 360 | |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 361 | /*===-- Error handling ----------------------------------------------------===*/ |
| 362 | |
| 363 | void LLVMDisposeMessage(char *Message); |
| 364 | |
| 365 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 366 | /** |
| 367 | * @defgroup LLVMCCoreContext Contexts |
| 368 | * |
| 369 | * Contexts are execution states for the core LLVM IR system. |
| 370 | * |
| 371 | * Most types are tied to a context instance. Multiple contexts can |
| 372 | * exist simultaneously. A single context is not thread safe. However, |
| 373 | * different contexts can execute on different threads simultaneously. |
| 374 | * |
| 375 | * @{ |
| 376 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 377 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 378 | /** |
| 379 | * Create a new context. |
| 380 | * |
| 381 | * Every call to this function should be paired with a call to |
| 382 | * LLVMContextDispose() or the context will leak memory. |
| 383 | */ |
Erick Tryzelaar | f34cb0c | 2009-08-30 23:38:06 +0000 | [diff] [blame] | 384 | LLVMContextRef LLVMContextCreate(void); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 385 | |
| 386 | /** |
| 387 | * Obtain the global context instance. |
| 388 | */ |
Erick Tryzelaar | f34cb0c | 2009-08-30 23:38:06 +0000 | [diff] [blame] | 389 | LLVMContextRef LLVMGetGlobalContext(void); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 390 | |
| 391 | /** |
| 392 | * Destroy a context instance. |
| 393 | * |
| 394 | * This should be called for every call to LLVMContextCreate() or memory |
| 395 | * will be leaked. |
| 396 | */ |
Owen Anderson | 6773d38 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 397 | void LLVMContextDispose(LLVMContextRef C); |
| 398 | |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 399 | unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, |
| 400 | unsigned SLen); |
| 401 | unsigned LLVMGetMDKindID(const char* Name, unsigned SLen); |
| 402 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 403 | /** |
| 404 | * @} |
| 405 | */ |
| 406 | |
| 407 | /** @defgroup LLVMCCoreModule Modules |
| 408 | * |
| 409 | * Modules represent the top-level structure in a LLVM program. An LLVM |
| 410 | * module is effectively a translation unit or a collection of |
| 411 | * translation units merged together. |
| 412 | * |
| 413 | * @{ |
| 414 | */ |
| 415 | |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 416 | /*===-- Modules -----------------------------------------------------------===*/ |
| 417 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 418 | /* Create and destroy modules. */ |
| 419 | /** @see llvm::Module::Module */ |
| 420 | |
| 421 | /** |
| 422 | * Create a new, empty module in the global context. |
| 423 | * |
| 424 | * This is equivalent to calling LLVMModuleCreateWithNameInContext with |
| 425 | * LLVMGetGlobalContext() as the context parameter. |
| 426 | * |
| 427 | * Every invocation should be paired with LLVMDisposeModule() or memory |
| 428 | * will be leaked. |
| 429 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 430 | LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 431 | |
| 432 | /** |
| 433 | * Create a new, empty module in a specific context. |
| 434 | * |
| 435 | * Every invocation should be paired with LLVMDisposeModule() or memory |
| 436 | * will be leaked. |
| 437 | */ |
Owen Anderson | 31d44e4 | 2009-07-02 07:17:57 +0000 | [diff] [blame] | 438 | LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, |
| 439 | LLVMContextRef C); |
Gordon Henriksen | a49d435 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 440 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 441 | /** |
| 442 | * Destroy a module instance. |
| 443 | * |
| 444 | * This must be called for every created module or memory will be |
| 445 | * leaked. |
| 446 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 447 | void LLVMDisposeModule(LLVMModuleRef M); |
| 448 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 449 | /** |
| 450 | * Obtain the data layout for a module. |
| 451 | * |
| 452 | * @see Module::getDataLayout() |
| 453 | */ |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 454 | const char *LLVMGetDataLayout(LLVMModuleRef M); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 455 | |
| 456 | /** |
| 457 | * Set the data layout for a module. |
| 458 | * |
| 459 | * @see Module::setDataLayout() |
| 460 | */ |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 461 | void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple); |
| 462 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 463 | /** |
| 464 | * Obtain the target triple for a module. |
| 465 | * |
| 466 | * @see Module::getTargetTriple() |
| 467 | */ |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 468 | const char *LLVMGetTarget(LLVMModuleRef M); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 469 | |
| 470 | /** |
| 471 | * Set the target triple for a module. |
| 472 | * |
| 473 | * @see Module::setTargetTriple() |
| 474 | */ |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 475 | void LLVMSetTarget(LLVMModuleRef M, const char *Triple); |
| 476 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 477 | /** |
| 478 | * Dump a representation of a module to stderr. |
| 479 | * |
| 480 | * @see Module::dump() |
| 481 | */ |
Gordon Henriksen | 6c6075e | 2008-03-14 23:58:56 +0000 | [diff] [blame] | 482 | void LLVMDumpModule(LLVMModuleRef M); |
| 483 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 484 | /** |
| 485 | * Set inline assembly for a module. |
| 486 | * |
| 487 | * @see Module::setModuleInlineAsm() |
| 488 | */ |
Chris Lattner | 2694145 | 2010-04-10 17:52:58 +0000 | [diff] [blame] | 489 | void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 490 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 491 | /** |
| 492 | * Obtain the context to which this module is associated. |
| 493 | * |
| 494 | * @see Module::getContext() |
| 495 | */ |
Chris Lattner | a7e04b0 | 2010-11-28 20:03:44 +0000 | [diff] [blame] | 496 | LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M); |
| 497 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 498 | /** |
| 499 | * Obtain a Type from a module by its registered name. |
| 500 | */ |
| 501 | LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 502 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 503 | /** |
| 504 | * Obtain the number of operands for named metadata in a module. |
| 505 | * |
| 506 | * @see llvm::Module::getNamedMetadata() |
| 507 | */ |
| 508 | unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name); |
| 509 | |
| 510 | /** |
| 511 | * Obtain the named metadata operands for a module. |
| 512 | * |
| 513 | * The passed LLVMValueRef pointer should refer to an array of |
| 514 | * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This |
| 515 | * array will be populated with the LLVMValueRef instances. Each |
| 516 | * instance corresponds to a llvm::MDNode. |
| 517 | * |
| 518 | * @see llvm::Module::getNamedMetadata() |
| 519 | * @see llvm::MDNode::getOperand() |
| 520 | */ |
| 521 | void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest); |
| 522 | |
| 523 | /** |
| 524 | * Add an operand to named metadata. |
| 525 | * |
| 526 | * @see llvm::Module::getNamedMetadata() |
| 527 | * @see llvm::MDNode::addOperand() |
| 528 | */ |
| 529 | void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name, |
| 530 | LLVMValueRef Val); |
| 531 | |
| 532 | |
| 533 | /** |
| 534 | * @} |
| 535 | */ |
| 536 | |
| 537 | /** |
| 538 | * @defgroup LLVMCCoreType Types |
| 539 | * |
| 540 | * Types represent the type of a value. |
| 541 | * |
| 542 | * Types are associated with a context instance. The context internally |
| 543 | * deduplicates types so there is only 1 instance of a specific type |
| 544 | * alive at a time. In other words, a unique type is shared among all |
| 545 | * consumers within a context. |
| 546 | * |
| 547 | * A Type in the C API corresponds to llvm::Type. |
| 548 | * |
| 549 | * Types have the following hierarchy: |
| 550 | * |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 551 | * types: |
| 552 | * integer type |
| 553 | * real type |
| 554 | * function type |
| 555 | * sequence types: |
| 556 | * array type |
| 557 | * pointer type |
| 558 | * vector type |
| 559 | * void type |
| 560 | * label type |
| 561 | * opaque type |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 562 | * |
| 563 | * @{ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 564 | */ |
| 565 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 566 | /** |
| 567 | * Obtain the enumerated type of a Type instance. |
| 568 | * |
| 569 | * @see llvm::Type:getTypeID() |
| 570 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 571 | LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 572 | |
| 573 | /** |
| 574 | * Whether the type has a known size. |
| 575 | * |
| 576 | * Things that don't have a size are abstract types, labels, and void.a |
| 577 | * |
| 578 | * @see llvm::Type::isSized() |
| 579 | */ |
Torok Edwin | 1cd9ade | 2011-10-06 12:13:28 +0000 | [diff] [blame] | 580 | LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty); |
Gordon Henriksen | a49d435 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 581 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 582 | /** |
| 583 | * Obtain the context to which this type instance is associated. |
| 584 | * |
| 585 | * @see llvm::Type::getContext() |
| 586 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 587 | LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); |
| 588 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 589 | /** |
| 590 | * @defgroup LLVMCCoreTypeInt Integer Types |
| 591 | * |
| 592 | * Functions in this section operate on integer types. |
| 593 | * |
| 594 | * @{ |
| 595 | */ |
| 596 | |
| 597 | /** |
| 598 | * Obtain an integer type from a context with specified bit width. |
| 599 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 600 | LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C); |
| 601 | LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C); |
| 602 | LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C); |
| 603 | LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C); |
| 604 | LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C); |
| 605 | LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits); |
| 606 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 607 | /** |
| 608 | * Obtain an integer type from the global context with a specified bit |
| 609 | * width. |
| 610 | */ |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 611 | LLVMTypeRef LLVMInt1Type(void); |
| 612 | LLVMTypeRef LLVMInt8Type(void); |
| 613 | LLVMTypeRef LLVMInt16Type(void); |
| 614 | LLVMTypeRef LLVMInt32Type(void); |
| 615 | LLVMTypeRef LLVMInt64Type(void); |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 616 | LLVMTypeRef LLVMIntType(unsigned NumBits); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 617 | unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 618 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 619 | /** |
| 620 | * @} |
| 621 | */ |
| 622 | |
| 623 | /** |
| 624 | * @defgroup LLVMCCoreTypeFloat Floating Point Types |
| 625 | * |
| 626 | * @{ |
| 627 | */ |
| 628 | |
| 629 | /** |
| 630 | * Obtain a 16-bit floating point type from a context. |
| 631 | */ |
Dan Gohman | 518cda4 | 2011-12-17 00:04:22 +0000 | [diff] [blame] | 632 | LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 633 | |
| 634 | /** |
| 635 | * Obtain a 32-bit floating point type from a context. |
| 636 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 637 | LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 638 | |
| 639 | /** |
| 640 | * Obtain a 64-bit floating point type from a context. |
| 641 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 642 | LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 643 | |
| 644 | /** |
| 645 | * Obtain a 80-bit floating point type (X87) from a context. |
| 646 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 647 | LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 648 | |
| 649 | /** |
| 650 | * Obtain a 128-bit floating point type (112-bit mantissa) from a |
| 651 | * context. |
| 652 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 653 | LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 654 | |
| 655 | /** |
| 656 | * Obtain a 128-bit floating point type (two 64-bits) from a context. |
| 657 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 658 | LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C); |
| 659 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 660 | /** |
| 661 | * Obtain a floating point type from the global context. |
| 662 | * |
| 663 | * These map to the functions in this group of the same name. |
| 664 | */ |
Dan Gohman | 518cda4 | 2011-12-17 00:04:22 +0000 | [diff] [blame] | 665 | LLVMTypeRef LLVMHalfType(void); |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 666 | LLVMTypeRef LLVMFloatType(void); |
| 667 | LLVMTypeRef LLVMDoubleType(void); |
| 668 | LLVMTypeRef LLVMX86FP80Type(void); |
| 669 | LLVMTypeRef LLVMFP128Type(void); |
| 670 | LLVMTypeRef LLVMPPCFP128Type(void); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 671 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 672 | /** |
| 673 | * @} |
| 674 | */ |
| 675 | |
| 676 | /** |
| 677 | * @defgroup LLVMCCoreTypeFunction Function Types |
| 678 | * |
| 679 | * @{ |
| 680 | */ |
| 681 | |
| 682 | /** |
| 683 | * Obtain a function type consisting of a specified signature. |
| 684 | * |
| 685 | * The function is defined as a tuple of a return Type, a list of |
| 686 | * parameter types, and whether the function is variadic. |
| 687 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 688 | LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, |
| 689 | LLVMTypeRef *ParamTypes, unsigned ParamCount, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 690 | LLVMBool IsVarArg); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 691 | |
| 692 | /** |
| 693 | * Returns whether a function type is variadic. |
| 694 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 695 | LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 696 | |
| 697 | /** |
| 698 | * Obtain the Type this function Type returns. |
| 699 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 700 | LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 701 | |
| 702 | /** |
| 703 | * Obtain the number of parameters this function accepts. |
| 704 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 705 | unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 706 | |
| 707 | /** |
| 708 | * Obtain the types of a function's parameters. |
| 709 | * |
| 710 | * The Dest parameter should point to a pre-allocated array of |
| 711 | * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the |
| 712 | * first LLVMCountParamTypes() entries in the array will be populated |
| 713 | * with LLVMTypeRef instances. |
| 714 | * |
| 715 | * @param FunctionTy The function type to operate on. |
| 716 | * @param Dest Memory address of an array to be filled with result. |
| 717 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 718 | void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 719 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 720 | /** |
| 721 | * @} |
| 722 | */ |
| 723 | |
| 724 | /** |
| 725 | * @defgroup LLVMCCoreTypeStruct Structure Types |
| 726 | * |
| 727 | * These functions relate to LLVMTypeRef instances. |
| 728 | * |
| 729 | * @see llvm::StructType |
| 730 | * |
| 731 | * @{ |
| 732 | */ |
| 733 | |
| 734 | /** |
| 735 | * Create a new structure type in a context. |
| 736 | * |
| 737 | * A structure is specified by a list of inner elements/types and |
| 738 | * whether these can be packed together. |
| 739 | * |
| 740 | * @see llvm::StructType::create() |
| 741 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 742 | LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 743 | unsigned ElementCount, LLVMBool Packed); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 744 | |
| 745 | /** |
| 746 | * Create a new structure type in the global context. |
| 747 | * |
| 748 | * @see llvm::StructType::create() |
| 749 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 750 | LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 751 | LLVMBool Packed); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 752 | |
| 753 | /** |
| 754 | * Create an empty structure in a context having a specified name. |
| 755 | * |
| 756 | * @see llvm::StructType::create() |
| 757 | */ |
Chris Lattner | e71ccde | 2011-07-14 05:53:17 +0000 | [diff] [blame] | 758 | LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 759 | |
| 760 | /** |
| 761 | * Obtain the name of a structure. |
| 762 | * |
| 763 | * @see llvm::StructType::getName() |
| 764 | */ |
Torok Edwin | 0d5f6ae | 2011-10-06 12:12:50 +0000 | [diff] [blame] | 765 | const char *LLVMGetStructName(LLVMTypeRef Ty); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 766 | |
| 767 | /** |
| 768 | * Set the contents of a structure type. |
| 769 | * |
| 770 | * @see llvm::StructType::setBody() |
| 771 | */ |
Chris Lattner | e71ccde | 2011-07-14 05:53:17 +0000 | [diff] [blame] | 772 | void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, |
| 773 | unsigned ElementCount, LLVMBool Packed); |
| 774 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 775 | /** |
| 776 | * Get the number of elements defined inside the structure. |
| 777 | * |
| 778 | * @see llvm::StructType::getNumElements() |
| 779 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 780 | unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 781 | |
| 782 | /** |
| 783 | * Get the elements within a structure. |
| 784 | * |
| 785 | * The function is passed the address of a pre-allocated array of |
| 786 | * LLVMTypeRef at least LLVMCountStructElementTypes() long. After |
| 787 | * invocation, this array will be populated with the structure's |
| 788 | * elements. The objects in the destination array will have a lifetime |
| 789 | * of the structure type itself, which is the lifetime of the context it |
| 790 | * is contained in. |
| 791 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 792 | void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 793 | |
| 794 | /** |
| 795 | * Determine whether a structure is packed. |
| 796 | * |
| 797 | * @see llvm::StructType::isPacked() |
| 798 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 799 | LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 800 | |
| 801 | /** |
| 802 | * Determine whether a structure is opaque. |
| 803 | * |
| 804 | * @see llvm::StructType::isOpaque() |
| 805 | */ |
Chris Lattner | 17cf05b | 2011-07-14 16:20:28 +0000 | [diff] [blame] | 806 | LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy); |
| 807 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 808 | /** |
| 809 | * @} |
| 810 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 811 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 812 | |
| 813 | /** |
| 814 | * @defgroup LLVMCCoreTypeSequential Sequential Types |
| 815 | * |
| 816 | * Sequential types represents "arrays" of types. This is a super class |
| 817 | * for array, vector, and pointer types. |
| 818 | * |
| 819 | * @{ |
| 820 | */ |
| 821 | |
| 822 | /** |
| 823 | * Obtain the type of elements within a sequential type. |
| 824 | * |
| 825 | * This works on array, vector, and pointer types. |
| 826 | * |
| 827 | * @see llvm::SequentialType::getElementType() |
| 828 | */ |
| 829 | LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); |
| 830 | |
| 831 | /** |
| 832 | * Create a fixed size array type that refers to a specific type. |
| 833 | * |
| 834 | * The created type will exist in the context that its element type |
| 835 | * exists in. |
| 836 | * |
| 837 | * @see llvm::ArrayType::get() |
| 838 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 839 | LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 840 | |
| 841 | /** |
| 842 | * Obtain the length of an array type. |
| 843 | * |
| 844 | * This only works on types that represent arrays. |
| 845 | * |
| 846 | * @see llvm::ArrayType::getNumElements() |
| 847 | */ |
| 848 | unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); |
| 849 | |
| 850 | /** |
| 851 | * Create a pointer type that points to a defined type. |
| 852 | * |
| 853 | * The created type will exist in the context that its pointee type |
| 854 | * exists in. |
| 855 | * |
| 856 | * @see llvm::PointerType::get() |
| 857 | */ |
Gordon Henriksen | 5a3fe03 | 2007-12-17 16:08:32 +0000 | [diff] [blame] | 858 | LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 859 | |
| 860 | /** |
| 861 | * Obtain the address space of a pointer type. |
| 862 | * |
| 863 | * This only works on types that represent pointers. |
| 864 | * |
| 865 | * @see llvm::PointerType::getAddressSpace() |
| 866 | */ |
| 867 | unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); |
| 868 | |
| 869 | /** |
| 870 | * Create a vector type that contains a defined type and has a specific |
| 871 | * number of elements. |
| 872 | * |
| 873 | * The created type will exist in the context thats its element type |
| 874 | * exists in. |
| 875 | * |
| 876 | * @see llvm::VectorType::get() |
| 877 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 878 | LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 879 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 880 | /** |
| 881 | * Obtain the number of elements in a vector type. |
| 882 | * |
| 883 | * This only works on types that represent vectors. |
| 884 | * |
| 885 | * @see llvm::VectorType::getNumElements() |
| 886 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 887 | unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); |
| 888 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 889 | /** |
| 890 | * @} |
| 891 | */ |
| 892 | |
| 893 | /** |
| 894 | * @defgroup LLVMCCoreTypeOther Other Types |
| 895 | * |
| 896 | * @{ |
| 897 | */ |
| 898 | |
| 899 | /** |
| 900 | * Create a void type in a context. |
| 901 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 902 | LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 903 | |
| 904 | /** |
| 905 | * Create a label type in a context. |
| 906 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 907 | LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 908 | |
| 909 | /** |
| 910 | * Create a X86 MMX type in a context. |
| 911 | */ |
Dale Johannesen | 95b67af | 2010-09-10 21:58:02 +0000 | [diff] [blame] | 912 | LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 913 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 914 | /** |
| 915 | * These are similar to the above functions except they operate on the |
| 916 | * global context. |
| 917 | */ |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 918 | LLVMTypeRef LLVMVoidType(void); |
| 919 | LLVMTypeRef LLVMLabelType(void); |
Dale Johannesen | 95b67af | 2010-09-10 21:58:02 +0000 | [diff] [blame] | 920 | LLVMTypeRef LLVMX86MMXType(void); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 921 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 922 | /** |
| 923 | * @} |
| 924 | */ |
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 LLVMCCoreValues Values |
| 932 | * |
| 933 | * 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] | 934 | * rich type hierarchy. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 935 | * |
| 936 | * LLVMValueRef essentially represents llvm::Value. There is a rich |
| 937 | * hierarchy of classes within this type. Depending on the instance |
| 938 | * obtain, not all APIs are available. |
| 939 | * |
| 940 | * Callers can determine the type of a LLVMValueRef by calling the |
| 941 | * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These |
| 942 | * functions are defined by a macro, so it isn't obvious which are |
| 943 | * available by looking at the Doxygen source code. Instead, look at the |
| 944 | * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list |
| 945 | * of value names given. These value names also correspond to classes in |
| 946 | * the llvm::Value hierarchy. |
| 947 | * |
| 948 | * @{ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 949 | */ |
| 950 | |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 951 | #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \ |
| 952 | macro(Argument) \ |
| 953 | macro(BasicBlock) \ |
| 954 | macro(InlineAsm) \ |
Torok Edwin | d09b757 | 2011-10-14 20:37:56 +0000 | [diff] [blame] | 955 | macro(MDNode) \ |
| 956 | macro(MDString) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 957 | macro(User) \ |
| 958 | macro(Constant) \ |
Torok Edwin | d09b757 | 2011-10-14 20:37:56 +0000 | [diff] [blame] | 959 | macro(BlockAddress) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 960 | macro(ConstantAggregateZero) \ |
| 961 | macro(ConstantArray) \ |
| 962 | macro(ConstantExpr) \ |
| 963 | macro(ConstantFP) \ |
| 964 | macro(ConstantInt) \ |
| 965 | macro(ConstantPointerNull) \ |
| 966 | macro(ConstantStruct) \ |
| 967 | macro(ConstantVector) \ |
| 968 | macro(GlobalValue) \ |
| 969 | macro(Function) \ |
| 970 | macro(GlobalAlias) \ |
| 971 | macro(GlobalVariable) \ |
| 972 | macro(UndefValue) \ |
| 973 | macro(Instruction) \ |
| 974 | macro(BinaryOperator) \ |
| 975 | macro(CallInst) \ |
| 976 | macro(IntrinsicInst) \ |
| 977 | macro(DbgInfoIntrinsic) \ |
| 978 | macro(DbgDeclareInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 979 | macro(MemIntrinsic) \ |
| 980 | macro(MemCpyInst) \ |
| 981 | macro(MemMoveInst) \ |
| 982 | macro(MemSetInst) \ |
| 983 | macro(CmpInst) \ |
Torok Edwin | d09b757 | 2011-10-14 20:37:56 +0000 | [diff] [blame] | 984 | macro(FCmpInst) \ |
| 985 | macro(ICmpInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 986 | macro(ExtractElementInst) \ |
| 987 | macro(GetElementPtrInst) \ |
| 988 | macro(InsertElementInst) \ |
| 989 | macro(InsertValueInst) \ |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 990 | macro(LandingPadInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 991 | macro(PHINode) \ |
| 992 | macro(SelectInst) \ |
| 993 | macro(ShuffleVectorInst) \ |
| 994 | macro(StoreInst) \ |
| 995 | macro(TerminatorInst) \ |
| 996 | macro(BranchInst) \ |
Torok Edwin | d09b757 | 2011-10-14 20:37:56 +0000 | [diff] [blame] | 997 | macro(IndirectBrInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 998 | macro(InvokeInst) \ |
| 999 | macro(ReturnInst) \ |
| 1000 | macro(SwitchInst) \ |
| 1001 | macro(UnreachableInst) \ |
Bill Wendling | f891bf8 | 2011-07-31 06:30:59 +0000 | [diff] [blame] | 1002 | macro(ResumeInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1003 | macro(UnaryInstruction) \ |
Victor Hernandez | 8acf295 | 2009-10-23 21:09:37 +0000 | [diff] [blame] | 1004 | macro(AllocaInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1005 | macro(CastInst) \ |
Gordon Henriksen | 05a868f | 2008-12-19 18:51:17 +0000 | [diff] [blame] | 1006 | macro(BitCastInst) \ |
| 1007 | macro(FPExtInst) \ |
| 1008 | macro(FPToSIInst) \ |
| 1009 | macro(FPToUIInst) \ |
| 1010 | macro(FPTruncInst) \ |
| 1011 | macro(IntToPtrInst) \ |
| 1012 | macro(PtrToIntInst) \ |
| 1013 | macro(SExtInst) \ |
| 1014 | macro(SIToFPInst) \ |
| 1015 | macro(TruncInst) \ |
| 1016 | macro(UIToFPInst) \ |
| 1017 | macro(ZExtInst) \ |
| 1018 | macro(ExtractValueInst) \ |
Gordon Henriksen | 05a868f | 2008-12-19 18:51:17 +0000 | [diff] [blame] | 1019 | macro(LoadInst) \ |
| 1020 | macro(VAArgInst) |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1021 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1022 | /** |
| 1023 | * @defgroup LLVMCCoreValueGeneral General APIs |
| 1024 | * |
| 1025 | * Functions in this section work on all LLVMValueRef instances, |
| 1026 | * regardless of their sub-type. They correspond to functions available |
| 1027 | * on llvm::Value. |
| 1028 | * |
| 1029 | * @{ |
| 1030 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1031 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1032 | /** |
| 1033 | * Obtain the type of a value. |
| 1034 | * |
| 1035 | * @see llvm::Value::getType() |
| 1036 | */ |
| 1037 | LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); |
| 1038 | |
| 1039 | /** |
| 1040 | * Obtain the string name of a value. |
| 1041 | * |
| 1042 | * @see llvm::Value::getName() |
| 1043 | */ |
| 1044 | const char *LLVMGetValueName(LLVMValueRef Val); |
| 1045 | |
| 1046 | /** |
| 1047 | * Set the string name of a value. |
| 1048 | * |
| 1049 | * @see llvm::Value::setName() |
| 1050 | */ |
| 1051 | void LLVMSetValueName(LLVMValueRef Val, const char *Name); |
| 1052 | |
| 1053 | /** |
| 1054 | * Dump a representation of a value to stderr. |
| 1055 | * |
| 1056 | * @see llvm::Value::dump() |
| 1057 | */ |
| 1058 | void LLVMDumpValue(LLVMValueRef Val); |
| 1059 | |
| 1060 | /** |
| 1061 | * Replace all uses of a value with another one. |
| 1062 | * |
| 1063 | * @see llvm::Value::replaceAllUsesWith() |
| 1064 | */ |
| 1065 | void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); |
| 1066 | |
| 1067 | /** |
| 1068 | * Determine whether the specified constant instance is constant. |
| 1069 | */ |
| 1070 | LLVMBool LLVMIsConstant(LLVMValueRef Val); |
| 1071 | |
| 1072 | /** |
| 1073 | * Determine whether a value instance is undefined. |
| 1074 | */ |
| 1075 | LLVMBool LLVMIsUndef(LLVMValueRef Val); |
| 1076 | |
| 1077 | /** |
| 1078 | * Convert value instances between types. |
| 1079 | * |
| 1080 | * Internally, a LLVMValueRef is "pinned" to a specific type. This |
| 1081 | * series of functions allows you to cast an instance to a specific |
| 1082 | * type. |
| 1083 | * |
| 1084 | * If the cast is not valid for the specified type, NULL is returned. |
| 1085 | * |
| 1086 | * @see llvm::dyn_cast_or_null<> |
| 1087 | */ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1088 | #define LLVM_DECLARE_VALUE_CAST(name) \ |
| 1089 | LLVMValueRef LLVMIsA##name(LLVMValueRef Val); |
| 1090 | LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) |
| 1091 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1092 | /** |
| 1093 | * @} |
| 1094 | */ |
| 1095 | |
| 1096 | /** |
| 1097 | * @defgroup LLVMCCoreValueUses Usage |
| 1098 | * |
| 1099 | * This module defines functions that allow you to inspect the uses of a |
| 1100 | * LLVMValueRef. |
| 1101 | * |
| 1102 | * It is possible to obtain a LLVMUseRef for any LLVMValueRef instance. |
| 1103 | * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a |
| 1104 | * llvm::User and llvm::Value. |
| 1105 | * |
| 1106 | * @{ |
| 1107 | */ |
| 1108 | |
| 1109 | /** |
| 1110 | * Obtain the first use of a value. |
| 1111 | * |
| 1112 | * Uses are obtained in an iterator fashion. First, call this function |
| 1113 | * to obtain a reference to the first use. Then, call LLVMGetNextUse() |
| 1114 | * on that instance and all subsequently obtained instances untl |
| 1115 | * LLVMGetNextUse() returns NULL. |
| 1116 | * |
| 1117 | * @see llvm::Value::use_begin() |
| 1118 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1119 | LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1120 | |
| 1121 | /** |
| 1122 | * Obtain the next use of a value. |
| 1123 | * |
| 1124 | * This effectively advances the iterator. It returns NULL if you are on |
| 1125 | * the final use and no more are available. |
| 1126 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1127 | LLVMUseRef LLVMGetNextUse(LLVMUseRef U); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1128 | |
| 1129 | /** |
| 1130 | * Obtain the user value for a user. |
| 1131 | * |
| 1132 | * The returned value corresponds to a llvm::User type. |
| 1133 | * |
| 1134 | * @see llvm::Use::getUser() |
| 1135 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1136 | LLVMValueRef LLVMGetUser(LLVMUseRef U); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1137 | |
| 1138 | /** |
| 1139 | * Obtain the value this use corresponds to. |
| 1140 | * |
| 1141 | * @see llvm::Use::get(). |
| 1142 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1143 | LLVMValueRef LLVMGetUsedValue(LLVMUseRef U); |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1144 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1145 | /** |
| 1146 | * @} |
| 1147 | */ |
| 1148 | |
| 1149 | /** |
| 1150 | * @defgroup LLVMCValueUser User value |
| 1151 | * |
| 1152 | * Function in this group pertain to LLVMValueRef instances that descent |
| 1153 | * from llvm::User. This includes constants, instructions, and |
| 1154 | * operators. |
| 1155 | * |
| 1156 | * @{ |
| 1157 | */ |
| 1158 | |
| 1159 | /** |
| 1160 | * Obtain an operand at a specific index in a llvm::User value. |
| 1161 | * |
| 1162 | * @see llvm::User::getOperand() |
| 1163 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1164 | LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1165 | |
| 1166 | /** |
| 1167 | * Set an operand at a specific index in a llvm::User value. |
| 1168 | * |
| 1169 | * @see llvm::User::setOperand() |
| 1170 | */ |
Erick Tryzelaar | b4d4870 | 2010-08-20 14:51:22 +0000 | [diff] [blame] | 1171 | void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1172 | |
| 1173 | /** |
| 1174 | * Obtain the number of operands in a llvm::User value. |
| 1175 | * |
| 1176 | * @see llvm::User::getNumOperands() |
| 1177 | */ |
Erick Tryzelaar | b4d4870 | 2010-08-20 14:51:22 +0000 | [diff] [blame] | 1178 | int LLVMGetNumOperands(LLVMValueRef Val); |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1179 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1180 | /** |
| 1181 | * @} |
| 1182 | */ |
| 1183 | |
| 1184 | /** |
| 1185 | * @defgroup LLVMCoreValueConstant Constant values |
| 1186 | * |
| 1187 | * This section contains APIs for interacting with LLVMValueRef that |
| 1188 | * correspond to llvm::Constant instances. |
| 1189 | * |
| 1190 | * These functions will work for any LLVMValueRef in the llvm::Constant |
| 1191 | * class hierarchy. |
| 1192 | * |
| 1193 | * @{ |
| 1194 | */ |
| 1195 | |
| 1196 | /** |
| 1197 | * Obtain a constant value referring to the null instance of a type. |
| 1198 | * |
| 1199 | * @see llvm::Constant::getNullValue() |
| 1200 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1201 | LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1202 | |
| 1203 | /** |
| 1204 | * Obtain a constant value referring to the instance of a type |
| 1205 | * consisting of all ones. |
| 1206 | * |
| 1207 | * This is only valid for integer types. |
| 1208 | * |
| 1209 | * @see llvm::Constant::getAllOnesValue() |
| 1210 | */ |
| 1211 | LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); |
| 1212 | |
| 1213 | /** |
| 1214 | * Obtain a constant value referring to an undefined value of a type. |
| 1215 | * |
| 1216 | * @see llvm::UndefValue::get() |
| 1217 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1218 | LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1219 | |
| 1220 | /** |
| 1221 | * Determine whether a value instance is null. |
| 1222 | * |
| 1223 | * @see llvm::Constant::isNullValue() |
| 1224 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1225 | LLVMBool LLVMIsNull(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1226 | |
| 1227 | /** |
| 1228 | * Obtain a constant that is a constant pointer pointing to NULL for a |
| 1229 | * specified type. |
| 1230 | */ |
Chris Lattner | 7f31824 | 2009-07-06 17:29:59 +0000 | [diff] [blame] | 1231 | LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1232 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1233 | /** |
| 1234 | * @defgroup LLVMCCoreValueConstantScalar Scalar constants |
| 1235 | * |
| 1236 | * Functions in this group model LLVMValueRef instances that correspond |
| 1237 | * to constants referring to scalar types. |
| 1238 | * |
| 1239 | * For integer types, the LLVMTypeRef parameter should correspond to a |
| 1240 | * llvm::IntegerType instance and the returned LLVMValueRef will |
| 1241 | * correspond to a llvm::ConstantInt. |
| 1242 | * |
| 1243 | * For floating point types, the LLVMTypeRef returned corresponds to a |
| 1244 | * llvm::ConstantFP. |
| 1245 | * |
| 1246 | * @{ |
| 1247 | */ |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 1248 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1249 | /** |
| 1250 | * Obtain a constant value for an integer type. |
| 1251 | * |
| 1252 | * The returned value corresponds to a llvm::ConstantInt. |
| 1253 | * |
| 1254 | * @see llvm::ConstantInt::get() |
| 1255 | * |
| 1256 | * @param IntTy Integer type to obtain value of. |
| 1257 | * @param N The value the returned instance should refer to. |
| 1258 | * @param SignExtend Whether to sign extend the produced value. |
| 1259 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1260 | LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1261 | LLVMBool SignExtend); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1262 | |
| 1263 | /** |
| 1264 | * Obtain a constant value for an integer of arbitrary precision. |
| 1265 | * |
| 1266 | * @see llvm::ConstantInt::get() |
| 1267 | */ |
Chris Lattner | 4329e07 | 2010-11-23 02:47:22 +0000 | [diff] [blame] | 1268 | LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, |
| 1269 | unsigned NumWords, |
| 1270 | const uint64_t Words[]); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1271 | |
| 1272 | /** |
| 1273 | * Obtain a constant value for an integer parsed from a string. |
| 1274 | * |
| 1275 | * A similar API, LLVMConstIntOfStringAndSize is also available. If the |
| 1276 | * string's length is available, it is preferred to call that function |
| 1277 | * instead. |
| 1278 | * |
| 1279 | * @see llvm::ConstantInt::get() |
| 1280 | */ |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1281 | LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text, |
| 1282 | uint8_t Radix); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1283 | |
| 1284 | /** |
| 1285 | * Obtain a constant value for an integer parsed from a string with |
| 1286 | * specified length. |
| 1287 | * |
| 1288 | * @see llvm::ConstantInt::get() |
| 1289 | */ |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1290 | LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text, |
| 1291 | unsigned SLen, uint8_t Radix); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1292 | |
| 1293 | /** |
| 1294 | * Obtain a constant value referring to a double floating point value. |
| 1295 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1296 | LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1297 | |
| 1298 | /** |
| 1299 | * Obtain a constant for a floating point value parsed from a string. |
| 1300 | * |
| 1301 | * A similar API, LLVMConstRealOfStringAndSize is also available. It |
| 1302 | * should be used if the input string's length is known. |
| 1303 | */ |
Gordon Henriksen | 931e121 | 2008-02-02 01:07:50 +0000 | [diff] [blame] | 1304 | LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1305 | |
| 1306 | /** |
| 1307 | * Obtain a constant for a floating point value parsed from a string. |
| 1308 | */ |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1309 | LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text, |
| 1310 | unsigned SLen); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1311 | |
| 1312 | /** |
| 1313 | * Obtain the zero extended value for an integer constant value. |
| 1314 | * |
| 1315 | * @see llvm::ConstantInt::getZExtValue() |
| 1316 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1317 | unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1318 | |
| 1319 | /** |
| 1320 | * Obtain the sign extended value for an integer constant value. |
| 1321 | * |
| 1322 | * @see llvm::ConstantInt::getSExtValue() |
| 1323 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1324 | long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1325 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1326 | /** |
| 1327 | * @} |
| 1328 | */ |
| 1329 | |
| 1330 | /** |
| 1331 | * @} |
| 1332 | */ |
| 1333 | |
| 1334 | /** |
| 1335 | * @defgroup LLVMCCoreValueMetadata Metadata |
| 1336 | * |
| 1337 | * @{ |
| 1338 | */ |
| 1339 | |
| 1340 | /** |
| 1341 | * Obtain a MDString value from a context. |
| 1342 | * |
| 1343 | * The returned instance corresponds to the llvm::MDString class. |
| 1344 | * |
| 1345 | * The instance is specified by string data of a specified length. The |
| 1346 | * string content is copied, so the backing memory can be freed after |
| 1347 | * this function returns. |
| 1348 | */ |
| 1349 | LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, |
| 1350 | unsigned SLen); |
| 1351 | |
| 1352 | /** |
| 1353 | * Obtain a MDString value from the global context. |
| 1354 | */ |
| 1355 | LLVMValueRef LLVMMDString(const char *Str, unsigned SLen); |
| 1356 | |
| 1357 | /** |
| 1358 | * Obtain a MDNode value from a context. |
| 1359 | * |
| 1360 | * The returned value corresponds to the llvm::MDNode class. |
| 1361 | */ |
| 1362 | LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, |
| 1363 | unsigned Count); |
| 1364 | |
| 1365 | /** |
| 1366 | * Obtain a MDNode value from the global context. |
| 1367 | */ |
| 1368 | LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); |
| 1369 | |
| 1370 | /** |
| 1371 | * Obtain the underlying string from a MDString value. |
| 1372 | * |
| 1373 | * @param V Instance to obtain string from. |
| 1374 | * @param Len Memory address which will hold length of returned string. |
| 1375 | * @return String data in MDString. |
| 1376 | */ |
| 1377 | const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len); |
| 1378 | |
| 1379 | /** |
| 1380 | * @} |
| 1381 | */ |
| 1382 | |
| 1383 | /** |
| 1384 | * @defgroup LLVMCCoreValueUNCATEGORIZED UNCATEGORIZED |
| 1385 | * |
| 1386 | * Functions in this group are not yet categorized. They belong |
| 1387 | * somewhere else and will be organized there in the future. Perhaps you |
| 1388 | * can help by submitting a patch to the documentation. |
| 1389 | * |
| 1390 | * @{ |
| 1391 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1392 | |
| 1393 | /* Operations on composite constants */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1394 | LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1395 | unsigned Length, LLVMBool DontNullTerminate); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1396 | LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, |
| 1397 | LLVMValueRef *ConstantVals, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1398 | unsigned Count, LLVMBool Packed); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1399 | |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1400 | LLVMValueRef LLVMConstString(const char *Str, unsigned Length, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1401 | LLVMBool DontNullTerminate); |
Gordon Henriksen | 2ad5aef | 2008-04-25 03:21:19 +0000 | [diff] [blame] | 1402 | LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1403 | LLVMValueRef *ConstantVals, unsigned Length); |
| 1404 | LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1405 | LLVMBool Packed); |
Rafael Espindola | 784ad24 | 2011-07-14 19:09:08 +0000 | [diff] [blame] | 1406 | LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, |
| 1407 | LLVMValueRef *ConstantVals, |
| 1408 | unsigned Count); |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1409 | LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1410 | |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1411 | /* Constant expressions */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1412 | LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); |
Erick Tryzelaar | fd529d7 | 2009-08-19 08:36:49 +0000 | [diff] [blame] | 1413 | LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1414 | LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); |
| 1415 | LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 1416 | LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); |
| 1417 | LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 1418 | LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1419 | LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); |
| 1420 | LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Dan Gohman | e4ca02d | 2009-09-03 23:34:49 +0000 | [diff] [blame] | 1421 | LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 1422 | LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 1423 | LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1424 | LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 1425 | LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1426 | LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 1427 | LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1428 | LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 1429 | LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1430 | LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 1431 | LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1432 | LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1433 | LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Dan Gohman | e4ca02d | 2009-09-03 23:34:49 +0000 | [diff] [blame] | 1434 | LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1435 | LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1436 | LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1437 | LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1438 | LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1439 | LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1440 | LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1441 | LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1442 | LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, |
| 1443 | LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1444 | LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, |
| 1445 | LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1446 | LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1447 | LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1448 | LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 1449 | LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, |
| 1450 | LLVMValueRef *ConstantIndices, unsigned NumIndices); |
Dan Gohman | e4ca02d | 2009-09-03 23:34:49 +0000 | [diff] [blame] | 1451 | LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, |
| 1452 | LLVMValueRef *ConstantIndices, |
| 1453 | unsigned NumIndices); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1454 | LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1455 | LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1456 | LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1457 | LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1458 | LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1459 | LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1460 | LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1461 | LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1462 | LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1463 | LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1464 | LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 1465 | LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 1466 | LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, |
| 1467 | LLVMTypeRef ToType); |
| 1468 | LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, |
| 1469 | LLVMTypeRef ToType); |
| 1470 | LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, |
| 1471 | LLVMTypeRef ToType); |
| 1472 | LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, |
| 1473 | LLVMTypeRef ToType); |
| 1474 | LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1475 | LLVMBool isSigned); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 1476 | LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1477 | LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, |
| 1478 | LLVMValueRef ConstantIfTrue, |
| 1479 | LLVMValueRef ConstantIfFalse); |
| 1480 | LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, |
| 1481 | LLVMValueRef IndexConstant); |
| 1482 | LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, |
| 1483 | LLVMValueRef ElementValueConstant, |
| 1484 | LLVMValueRef IndexConstant); |
| 1485 | LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, |
| 1486 | LLVMValueRef VectorBConstant, |
| 1487 | LLVMValueRef MaskConstant); |
Dan Gohman | d5104a5 | 2008-11-03 22:55:43 +0000 | [diff] [blame] | 1488 | LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, |
| 1489 | unsigned NumIdx); |
| 1490 | LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, |
| 1491 | LLVMValueRef ElementValueConstant, |
| 1492 | unsigned *IdxList, unsigned NumIdx); |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1493 | LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, |
Chris Lattner | 3d1f552 | 2008-12-17 21:39:50 +0000 | [diff] [blame] | 1494 | const char *AsmString, const char *Constraints, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1495 | LLVMBool HasSideEffects, LLVMBool IsAlignStack); |
Erick Tryzelaar | 0fb26ef | 2010-02-28 09:46:06 +0000 | [diff] [blame] | 1496 | LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 1497 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1498 | /* Operations on global variables, functions, and aliases (globals) */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 1499 | LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1500 | LLVMBool LLVMIsDeclaration(LLVMValueRef Global); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1501 | LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); |
| 1502 | void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); |
| 1503 | const char *LLVMGetSection(LLVMValueRef Global); |
| 1504 | void LLVMSetSection(LLVMValueRef Global, const char *Section); |
| 1505 | LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); |
| 1506 | void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); |
| 1507 | unsigned LLVMGetAlignment(LLVMValueRef Global); |
| 1508 | void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); |
| 1509 | |
| 1510 | /* Operations on global variables */ |
| 1511 | LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); |
Erick Tryzelaar | 06894b3 | 2010-02-28 09:46:13 +0000 | [diff] [blame] | 1512 | LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, |
| 1513 | const char *Name, |
| 1514 | unsigned AddressSpace); |
Gordon Henriksen | 783f7bb | 2007-10-08 03:45:09 +0000 | [diff] [blame] | 1515 | LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 1516 | LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); |
| 1517 | LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); |
| 1518 | LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); |
| 1519 | LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1520 | void LLVMDeleteGlobal(LLVMValueRef GlobalVar); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1521 | LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); |
| 1522 | void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1523 | LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar); |
| 1524 | void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal); |
| 1525 | LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar); |
| 1526 | void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1527 | |
Chris Lattner | 3d1f552 | 2008-12-17 21:39:50 +0000 | [diff] [blame] | 1528 | /* Operations on aliases */ |
| 1529 | LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, |
| 1530 | const char *Name); |
| 1531 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1532 | /* Operations on functions */ |
| 1533 | LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, |
| 1534 | LLVMTypeRef FunctionTy); |
Gordon Henriksen | 783f7bb | 2007-10-08 03:45:09 +0000 | [diff] [blame] | 1535 | LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1536 | LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); |
| 1537 | LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); |
| 1538 | LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); |
| 1539 | LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1540 | |
| 1541 | /** |
| 1542 | * @} |
| 1543 | */ |
| 1544 | |
| 1545 | /** |
| 1546 | * @defgroup LLVMCCoreValueFunction Function values |
| 1547 | * |
| 1548 | * Functions in this group operate on LLVMValueRef instances that |
| 1549 | * correspond to llvm::Function instances. |
| 1550 | * |
| 1551 | * @see llvm::Function |
| 1552 | * |
| 1553 | * @{ |
| 1554 | */ |
| 1555 | |
| 1556 | /** |
| 1557 | * Remove a function from its containing module and deletes it. |
| 1558 | * |
| 1559 | * @see llvm::Function::eraseFromParent() |
| 1560 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1561 | void LLVMDeleteFunction(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1562 | |
| 1563 | /** |
| 1564 | * Obtain the ID number from a function instance. |
| 1565 | * |
| 1566 | * @see llvm::Function::getIntrinsicID() |
| 1567 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1568 | unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1569 | |
| 1570 | /** |
| 1571 | * Obtain the calling function of a function. |
| 1572 | * |
| 1573 | * The returned value corresponds to the LLVMCallConv enumeration. |
| 1574 | * |
| 1575 | * @see llvm::Function::getCallingConv() |
| 1576 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1577 | unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1578 | |
| 1579 | /** |
| 1580 | * Set the calling convention of a function. |
| 1581 | * |
| 1582 | * @see llvm::Function::setCallingConv() |
| 1583 | * |
| 1584 | * @param Fn Function to operate on |
| 1585 | * @param CC LLVMCallConv to set calling convention to |
| 1586 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1587 | void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1588 | |
| 1589 | /** |
| 1590 | * Obtain the name of the garbage collector to use during code |
| 1591 | * generation. |
| 1592 | * |
| 1593 | * @see llvm::Function::getGC() |
| 1594 | */ |
Gordon Henriksen | d930f91 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 1595 | const char *LLVMGetGC(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1596 | |
| 1597 | /** |
| 1598 | * Define the garbage collector to use during code generation. |
| 1599 | * |
| 1600 | * @see llvm::Function::setGC() |
| 1601 | */ |
Gordon Henriksen | d930f91 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 1602 | void LLVMSetGC(LLVMValueRef Fn, const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1603 | |
| 1604 | /** |
| 1605 | * Add an attribute to a function. |
| 1606 | * |
| 1607 | * @see llvm::Function::addAttribute() |
| 1608 | */ |
Duncan Sands | 7374a01 | 2009-05-06 12:21:17 +0000 | [diff] [blame] | 1609 | void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1610 | |
| 1611 | /** |
| 1612 | * Obtain an attribute from a function. |
| 1613 | * |
| 1614 | * @see llvm::Function::getAttributes() |
| 1615 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1616 | LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1617 | |
| 1618 | /** |
| 1619 | * Remove an attribute from a function. |
| 1620 | */ |
Duncan Sands | 7374a01 | 2009-05-06 12:21:17 +0000 | [diff] [blame] | 1621 | void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1622 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1623 | /** |
| 1624 | * @defgroup LLVMCCoreValueFunctionParameters Function Parameters |
| 1625 | * |
| 1626 | * Functions in this group relate to arguments/parameters on functions. |
| 1627 | * |
| 1628 | * Functions in this group expect LLVMValueRef instances that correspond |
| 1629 | * to llvm::Function instances. |
| 1630 | * |
| 1631 | * @{ |
| 1632 | */ |
| 1633 | |
| 1634 | /** |
| 1635 | * Obtain the number of parameters in a function. |
| 1636 | * |
| 1637 | * @see llvm::Function::arg_size() |
| 1638 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 1639 | unsigned LLVMCountParams(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1640 | |
| 1641 | /** |
| 1642 | * Obtain the parameters in a function. |
| 1643 | * |
| 1644 | * The takes a pointer to a pre-allocated array of LLVMValueRef that is |
| 1645 | * at least LLVMCountParams() long. This array will be filled with |
| 1646 | * LLVMValueRef instances which correspond to the parameters the |
| 1647 | * function receives. Each LLVMValueRef corresponds to a llvm::Argument |
| 1648 | * instance. |
| 1649 | * |
| 1650 | * @see llvm::Function::arg_begin() |
| 1651 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 1652 | void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1653 | |
| 1654 | /** |
| 1655 | * Obtain the parameter at the specified index. |
| 1656 | * |
| 1657 | * Parameters are indexed from 0. |
| 1658 | * |
| 1659 | * @see llvm::Function::arg_begin() |
| 1660 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 1661 | LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1662 | |
| 1663 | /** |
| 1664 | * Obtain the function to which this argument belongs. |
| 1665 | * |
| 1666 | * Unlike other functions in this group, this one takes a LLVMValueRef |
| 1667 | * that corresponds to a llvm::Attribute. |
| 1668 | * |
| 1669 | * The returned LLVMValueRef is the llvm::Function to which this |
| 1670 | * argument belongs. |
| 1671 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 1672 | LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1673 | |
| 1674 | /** |
| 1675 | * Obtain the first parameter to a function. |
| 1676 | * |
| 1677 | * @see llvm::Function::arg_begin() |
| 1678 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 1679 | LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1680 | |
| 1681 | /** |
| 1682 | * Obtain the last parameter to a function. |
| 1683 | * |
| 1684 | * @see llvm::Function::arg_end() |
| 1685 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 1686 | LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1687 | |
| 1688 | /** |
| 1689 | * Obtain the next parameter to a function. |
| 1690 | * |
| 1691 | * This takes a LLVMValueRef obtained from LLVMGetFirstParam() (which is |
| 1692 | * actually a wrapped iterator) and obtains the next parameter from the |
| 1693 | * underlying iterator. |
| 1694 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 1695 | LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1696 | |
| 1697 | /** |
| 1698 | * Obtain the previous parameter to a function. |
| 1699 | * |
| 1700 | * This is the opposite of LLVMGetNextParam(). |
| 1701 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 1702 | LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1703 | |
| 1704 | /** |
| 1705 | * Add an attribute to a function argument. |
| 1706 | * |
| 1707 | * @see llvm::Argument::addAttr() |
| 1708 | */ |
Devang Patel | 4c758ea | 2008-09-25 21:00:45 +0000 | [diff] [blame] | 1709 | void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1710 | |
| 1711 | /** |
| 1712 | * Remove an attribute from a function argument. |
| 1713 | * |
| 1714 | * @see llvm::Argument::removeAttr() |
| 1715 | */ |
Devang Patel | 4c758ea | 2008-09-25 21:00:45 +0000 | [diff] [blame] | 1716 | void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1717 | |
| 1718 | /** |
| 1719 | * Get an attribute from a function argument. |
| 1720 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1721 | LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1722 | |
| 1723 | /** |
| 1724 | * Set the alignment for a function parameter. |
| 1725 | * |
| 1726 | * @see llvm::Argument::addAttr() |
| 1727 | * @see llvm::Attribute::constructAlignmentFromInt() |
| 1728 | */ |
Gordon Henriksen | 2d9cc21 | 2008-04-28 17:37:06 +0000 | [diff] [blame] | 1729 | void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align); |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 1730 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1731 | /** |
| 1732 | * @} |
| 1733 | */ |
| 1734 | |
| 1735 | /** |
| 1736 | * @} |
| 1737 | */ |
| 1738 | |
| 1739 | /** |
| 1740 | * @defgroup LLVMCCoreValueBasicBlock Basic Block |
| 1741 | * |
| 1742 | * A basic block represents a single entry single exit section of code. |
| 1743 | * Basic blocks contain a list of instructions which form the body of |
| 1744 | * the block. |
| 1745 | * |
| 1746 | * Basic blocks belong to functions. They have the type of label. |
| 1747 | * |
| 1748 | * Basic blocks are themselves values. However, the C API models them as |
| 1749 | * LLVMBasicBlockRef. |
| 1750 | * |
| 1751 | * @see llvm::BasicBlock |
| 1752 | * |
| 1753 | * @{ |
| 1754 | */ |
| 1755 | |
| 1756 | /** |
| 1757 | * Convert a basic block instance to a value type. |
| 1758 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 1759 | LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1760 | |
| 1761 | /** |
| 1762 | * Determine whether a LLVMValueRef is itself a basic block. |
| 1763 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1764 | LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1765 | |
| 1766 | /** |
| 1767 | * Convert a LLVMValueRef to a LLVMBasicBlockRef instance. |
| 1768 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1769 | LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1770 | |
| 1771 | /** |
| 1772 | * Obtain the function to which a basic block belongs. |
| 1773 | * |
| 1774 | * @see llvm::BasicBlock::getParent() |
| 1775 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 1776 | LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1777 | |
| 1778 | /** |
| 1779 | * Obtain the terminator instruction for a basic block. |
| 1780 | * |
| 1781 | * If the basic block does not have a terminator (it is not well-formed |
| 1782 | * if it doesn't), then NULL is returned. |
| 1783 | * |
| 1784 | * The returned LLVMValueRef corresponds to a llvm::TerminatorInst. |
| 1785 | * |
| 1786 | * @see llvm::BasicBlock::getTerminator() |
| 1787 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 1788 | LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1789 | |
| 1790 | /** |
| 1791 | * Obtain the number of basic blocks in a function. |
| 1792 | * |
| 1793 | * @param Fn Function value to operate on. |
| 1794 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1795 | unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1796 | |
| 1797 | /** |
| 1798 | * Obtain all of the basic blocks in a function. |
| 1799 | * |
| 1800 | * This operates on a function value. The BasicBlocks parameter is a |
| 1801 | * pointer to a pre-allocated array of LLVMBasicBlockRef of at least |
| 1802 | * LLVMCountBasicBlocks() in length. This array is populated with |
| 1803 | * LLVMBasicBlockRef instances. |
| 1804 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1805 | void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1806 | |
| 1807 | /** |
| 1808 | * Obtain the first basic block in a function. |
| 1809 | * |
| 1810 | * The returned basic block can be used as an iterator. You will likely |
| 1811 | * eventually call into LLVMGetNextBasicBlock() with it. |
| 1812 | * |
| 1813 | * @see llvm::Function::begin() |
| 1814 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1815 | LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1816 | |
| 1817 | /** |
| 1818 | * Obtain the last basic block in a function. |
| 1819 | * |
| 1820 | * @see llvm::Function::end() |
| 1821 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1822 | LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1823 | |
| 1824 | /** |
| 1825 | * Advance a basic block iterator. |
| 1826 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1827 | LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1828 | |
| 1829 | /** |
| 1830 | * Go backwards in a basic block iterator. |
| 1831 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1832 | LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1833 | |
| 1834 | /** |
| 1835 | * Obtain the basic block that corresponds to the entry point of a |
| 1836 | * function. |
| 1837 | * |
| 1838 | * @see llvm::Function::getEntryBlock() |
| 1839 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1840 | LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1841 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1842 | /** |
| 1843 | * Append a basic block to the end of a function. |
| 1844 | * |
| 1845 | * @see llvm::BasicBlock::Create() |
| 1846 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1847 | LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, |
| 1848 | LLVMValueRef Fn, |
| 1849 | const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1850 | |
| 1851 | /** |
| 1852 | * Append a basic block to the end of a function using the global |
| 1853 | * context. |
| 1854 | * |
| 1855 | * @see llvm::BasicBlock::Create() |
| 1856 | */ |
| 1857 | LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); |
| 1858 | |
| 1859 | /** |
| 1860 | * Insert a basic block in a function before another basic block. |
| 1861 | * |
| 1862 | * The function to add to is determined by the function of the |
| 1863 | * passed basic block. |
| 1864 | * |
| 1865 | * @see llvm::BasicBlock::Create() |
| 1866 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1867 | LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, |
| 1868 | LLVMBasicBlockRef BB, |
| 1869 | const char *Name); |
| 1870 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1871 | /** |
| 1872 | * Insert a basic block in a function using the global context. |
| 1873 | * |
| 1874 | * @see llvm::BasicBlock::Create() |
| 1875 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1876 | LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, |
| 1877 | const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1878 | |
| 1879 | /** |
| 1880 | * Remove a basic block from a function and delete it. |
| 1881 | * |
| 1882 | * This deletes the basic block from its containing function and deletes |
| 1883 | * the basic block itself. |
| 1884 | * |
| 1885 | * @see llvm::BasicBlock::eraseFromParent() |
| 1886 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1887 | void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1888 | |
| 1889 | /** |
| 1890 | * Remove a basic block from a function. |
| 1891 | * |
| 1892 | * This deletes the basic block from its containing function but keep |
| 1893 | * the basic block alive. |
| 1894 | * |
| 1895 | * @see llvm::BasicBlock::removeFromParent() |
| 1896 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 1897 | void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1898 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1899 | /** |
| 1900 | * Move a basic block to before another one. |
| 1901 | * |
| 1902 | * @see llvm::BasicBlock::moveBefore() |
| 1903 | */ |
Duncan Sands | b1d61aa | 2010-07-19 15:31:07 +0000 | [diff] [blame] | 1904 | void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1905 | |
| 1906 | /** |
| 1907 | * Move a basic block to after another one. |
| 1908 | * |
| 1909 | * @see llvm::BasicBlock::moveAfter() |
| 1910 | */ |
Duncan Sands | b1d61aa | 2010-07-19 15:31:07 +0000 | [diff] [blame] | 1911 | void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); |
| 1912 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1913 | /** |
| 1914 | * Obtain the first instruction in a basic block. |
| 1915 | * |
| 1916 | * The returned LLVMValueRef corresponds to a llvm::Instruction |
| 1917 | * instance. |
| 1918 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1919 | LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1920 | |
| 1921 | /** |
| 1922 | * Obtain the last instruction in a basic block. |
| 1923 | * |
| 1924 | * The returned LLVMValueRef corresponds to a LLVM:Instruction. |
| 1925 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1926 | LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 1927 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1928 | /** |
| 1929 | * @} |
| 1930 | */ |
| 1931 | |
| 1932 | /** |
| 1933 | * @defgroup LLVMCCoreValueInstruction Instructions |
| 1934 | * |
| 1935 | * Functions in this group relate to the inspection and manipulation of |
| 1936 | * individual instructions. |
| 1937 | * |
| 1938 | * In the C++ API, an instruction is modeled by llvm::Instruction. This |
| 1939 | * class has a large number of descendents. llvm::Instruction is a |
| 1940 | * llvm::Value and in the C API, instructions are modeled by |
| 1941 | * LLVMValueRef. |
| 1942 | * |
| 1943 | * This group also contains sub-groups which operate on specific |
| 1944 | * llvm::Instruction types, e.g. llvm::CallInst. |
| 1945 | * |
| 1946 | * @{ |
| 1947 | */ |
| 1948 | |
| 1949 | /** |
| 1950 | * Determine whether an instruction has any metadata attached. |
| 1951 | */ |
| 1952 | int LLVMHasMetadata(LLVMValueRef Val); |
| 1953 | |
| 1954 | /** |
| 1955 | * Return metadata associated with an instruction value. |
| 1956 | */ |
| 1957 | LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); |
| 1958 | |
| 1959 | /** |
| 1960 | * Set metadata associated with an instruction value. |
| 1961 | */ |
| 1962 | void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node); |
| 1963 | |
| 1964 | /** |
| 1965 | * Obtain the basic block to which an instruction belongs. |
| 1966 | * |
| 1967 | * @see llvm::Instruction::getParent() |
| 1968 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 1969 | LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1970 | |
| 1971 | /** |
| 1972 | * Obtain the instruction that occurs after the one specified. |
| 1973 | * |
| 1974 | * The next instruction will be from the same basic block. |
| 1975 | * |
| 1976 | * If this is the last instruction in a basic block, NULL will be |
| 1977 | * returned. |
| 1978 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1979 | LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1980 | |
| 1981 | /** |
| 1982 | * Obtain the instruction that occured before this one. |
| 1983 | * |
| 1984 | * If the instruction is the first instruction in a basic block, NULL |
| 1985 | * will be returned. |
| 1986 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 1987 | LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1988 | |
| 1989 | /** |
| 1990 | * Remove and delete an instruction. |
| 1991 | * |
| 1992 | * The instruction specified is removed from its containing building |
| 1993 | * block and then deleted. |
| 1994 | * |
| 1995 | * @see llvm::Instruction::eraseFromParent() |
| 1996 | */ |
Devang Patel | dbebc6f | 2011-10-03 20:59:18 +0000 | [diff] [blame] | 1997 | void LLVMInstructionEraseFromParent(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1998 | |
| 1999 | /** |
| 2000 | * Obtain the code opcode for an individual instruction. |
| 2001 | * |
| 2002 | * @see llvm::Instruction::getOpCode() |
| 2003 | */ |
Torok Edwin | ab6158e | 2011-10-14 20:37:49 +0000 | [diff] [blame] | 2004 | LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2005 | |
| 2006 | /** |
| 2007 | * Obtain the predicate of an instruction. |
| 2008 | * |
| 2009 | * This is only valid for instructions that correspond to llvm::ICmpInst |
| 2010 | * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp. |
| 2011 | * |
| 2012 | * @see llvm::ICmpInst::getPredicate() |
| 2013 | */ |
Torok Edwin | 60c40de | 2011-10-06 12:13:20 +0000 | [diff] [blame] | 2014 | LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst); |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2015 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2016 | /** |
| 2017 | * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations |
| 2018 | * |
| 2019 | * Functions in this group apply to instructions that refer to call |
| 2020 | * sites and invocations. These correspond to C++ types in the |
| 2021 | * llvm::CallInst class tree. |
| 2022 | * |
| 2023 | * @{ |
| 2024 | */ |
| 2025 | |
| 2026 | /** |
| 2027 | * Set the calling convention for a call instruction. |
| 2028 | * |
| 2029 | * This expects an LLVMValueRef that corresponds to a llvm::CallInst or |
| 2030 | * llvm::InvokeInst. |
| 2031 | * |
| 2032 | * @see llvm::CallInst::setCallingConv() |
| 2033 | * @see llvm::InvokeInst::setCallingConv() |
| 2034 | */ |
Gordon Henriksen | 1158c53 | 2007-12-29 20:45:00 +0000 | [diff] [blame] | 2035 | void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2036 | |
| 2037 | /** |
| 2038 | * Obtain the calling convention for a call instruction. |
| 2039 | * |
| 2040 | * This is the opposite of LLVMSetInstructionCallConv(). Reads its |
| 2041 | * usage. |
| 2042 | * |
| 2043 | * @see LLVMSetInstructionCallConv() |
| 2044 | */ |
Gordon Henriksen | 1158c53 | 2007-12-29 20:45:00 +0000 | [diff] [blame] | 2045 | unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2046 | |
| 2047 | |
Devang Patel | 4c758ea | 2008-09-25 21:00:45 +0000 | [diff] [blame] | 2048 | void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2049 | void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, |
Devang Patel | 4c758ea | 2008-09-25 21:00:45 +0000 | [diff] [blame] | 2050 | LLVMAttribute); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2051 | void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, |
Gordon Henriksen | 2d9cc21 | 2008-04-28 17:37:06 +0000 | [diff] [blame] | 2052 | unsigned align); |
Gordon Henriksen | 1158c53 | 2007-12-29 20:45:00 +0000 | [diff] [blame] | 2053 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2054 | /** |
| 2055 | * Obtain whether a call instruction is a tail call. |
| 2056 | * |
| 2057 | * This only works on llvm::CallInst instructions. |
| 2058 | * |
| 2059 | * @see llvm::CallInst::isTailCall() |
| 2060 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2061 | LLVMBool LLVMIsTailCall(LLVMValueRef CallInst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2062 | |
| 2063 | /** |
| 2064 | * Set whether a call instruction is a tail call. |
| 2065 | * |
| 2066 | * This only works on llvm::CallInst instructions. |
| 2067 | * |
| 2068 | * @see llvm::CallInst::setTailCall() |
| 2069 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2070 | void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); |
Gordon Henriksen | eeb6537 | 2008-08-30 16:34:54 +0000 | [diff] [blame] | 2071 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2072 | /** |
| 2073 | * @} |
| 2074 | */ |
| 2075 | |
| 2076 | /** |
| 2077 | * Obtain the default destination basic block of a switch instruction. |
| 2078 | * |
| 2079 | * This only works on llvm::SwitchInst instructions. |
| 2080 | * |
| 2081 | * @see llvm::SwitchInst::getDefaultDest() |
| 2082 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 2083 | LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr); |
| 2084 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2085 | /** |
| 2086 | * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes |
| 2087 | * |
| 2088 | * Functions in this group only apply to instructions that map to |
| 2089 | * llvm::PHINode instances. |
| 2090 | * |
| 2091 | * @{ |
| 2092 | */ |
| 2093 | |
| 2094 | /** |
| 2095 | * Add an incoming value to the end of a PHI list. |
| 2096 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 2097 | void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, |
| 2098 | LLVMBasicBlockRef *IncomingBlocks, unsigned Count); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2099 | |
| 2100 | /** |
| 2101 | * Obtain the number of incoming basic blocks to a PHI node. |
| 2102 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 2103 | unsigned LLVMCountIncoming(LLVMValueRef PhiNode); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2104 | |
| 2105 | /** |
| 2106 | * Obtain an incoming value to a PHI node as a LLVMValueRef. |
| 2107 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 2108 | LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2109 | |
| 2110 | /** |
| 2111 | * Obtain an incoming value to a PHI node as a LLVMBasicBlockRef. |
| 2112 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 2113 | LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2114 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2115 | /** |
| 2116 | * @} |
| 2117 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2118 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2119 | /** |
| 2120 | * @} |
| 2121 | */ |
| 2122 | |
| 2123 | /** |
| 2124 | * @} |
| 2125 | */ |
| 2126 | |
| 2127 | /** |
| 2128 | * @defgroup LLVMCCoreInstructionBuilder Instruction Builders |
| 2129 | * |
| 2130 | * An instruction builder represents a point within a basic block and is |
| 2131 | * the exclusive means of building instructions using the C interface. |
| 2132 | * |
| 2133 | * @{ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2134 | */ |
| 2135 | |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 2136 | LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C); |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 2137 | LLVMBuilderRef LLVMCreateBuilder(void); |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 2138 | void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, |
| 2139 | LLVMValueRef Instr); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2140 | void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); |
| 2141 | void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2142 | LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); |
Chris Lattner | 3d1f552 | 2008-12-17 21:39:50 +0000 | [diff] [blame] | 2143 | void LLVMClearInsertionPosition(LLVMBuilderRef Builder); |
| 2144 | void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); |
Erick Tryzelaar | 9813bea | 2009-08-16 02:20:57 +0000 | [diff] [blame] | 2145 | void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, |
| 2146 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2147 | void LLVMDisposeBuilder(LLVMBuilderRef Builder); |
| 2148 | |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 2149 | /* Metadata */ |
| 2150 | void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L); |
| 2151 | LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); |
| 2152 | void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); |
| 2153 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2154 | /* Terminators */ |
| 2155 | LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); |
| 2156 | LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); |
Erick Tryzelaar | fd529d7 | 2009-08-19 08:36:49 +0000 | [diff] [blame] | 2157 | LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals, |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2158 | unsigned N); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2159 | LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); |
| 2160 | LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, |
| 2161 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); |
| 2162 | LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, |
| 2163 | LLVMBasicBlockRef Else, unsigned NumCases); |
Erick Tryzelaar | 0fb26ef | 2010-02-28 09:46:06 +0000 | [diff] [blame] | 2164 | LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, |
| 2165 | unsigned NumDests); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2166 | LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, |
| 2167 | LLVMValueRef *Args, unsigned NumArgs, |
| 2168 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, |
| 2169 | const char *Name); |
Benjamin Kramer | 5a656883 | 2011-08-19 01:36:54 +0000 | [diff] [blame] | 2170 | LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 2171 | LLVMValueRef PersFn, unsigned NumClauses, |
| 2172 | const char *Name); |
Bill Wendling | f891bf8 | 2011-07-31 06:30:59 +0000 | [diff] [blame] | 2173 | LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2174 | LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); |
| 2175 | |
Gordon Henriksen | 097102c | 2008-01-01 05:50:53 +0000 | [diff] [blame] | 2176 | /* Add a case to the switch instruction */ |
| 2177 | void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, |
| 2178 | LLVMBasicBlockRef Dest); |
| 2179 | |
Erick Tryzelaar | 0fb26ef | 2010-02-28 09:46:06 +0000 | [diff] [blame] | 2180 | /* Add a destination to the indirectbr instruction */ |
| 2181 | void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); |
| 2182 | |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 2183 | /* Add a catch or filter clause to the landingpad instruction */ |
| 2184 | void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal); |
| 2185 | |
| 2186 | /* Set the 'cleanup' flag in the landingpad instruction */ |
| 2187 | void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val); |
| 2188 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2189 | /* Arithmetic */ |
| 2190 | LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2191 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2192 | LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2193 | const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2194 | LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2195 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2196 | LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2197 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2198 | LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2199 | const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2200 | LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2201 | const char *Name); |
| 2202 | LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2203 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2204 | LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2205 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2206 | LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2207 | const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2208 | LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2209 | const char *Name); |
| 2210 | LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2211 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2212 | LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2213 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2214 | LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2215 | const char *Name); |
| 2216 | LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2217 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2218 | LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2219 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2220 | LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2221 | const char *Name); |
| 2222 | LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2223 | const char *Name); |
| 2224 | LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2225 | const char *Name); |
| 2226 | LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2227 | const char *Name); |
| 2228 | LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2229 | const char *Name); |
| 2230 | LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2231 | const char *Name); |
| 2232 | LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2233 | const char *Name); |
| 2234 | LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2235 | const char *Name); |
| 2236 | LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2237 | const char *Name); |
| 2238 | LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 2239 | const char *Name); |
Erick Tryzelaar | 3183179 | 2010-02-28 05:51:27 +0000 | [diff] [blame] | 2240 | LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, |
| 2241 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 2242 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2243 | LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2244 | LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, |
| 2245 | const char *Name); |
| 2246 | LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, |
| 2247 | const char *Name); |
Dan Gohman | f919bd6 | 2009-09-28 21:51:41 +0000 | [diff] [blame] | 2248 | LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2249 | LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
| 2250 | |
| 2251 | /* Memory */ |
| 2252 | LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 2253 | LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, |
| 2254 | LLVMValueRef Val, const char *Name); |
| 2255 | LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 2256 | LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, |
| 2257 | LLVMValueRef Val, const char *Name); |
| 2258 | LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); |
| 2259 | LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, |
| 2260 | const char *Name); |
| 2261 | LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); |
| 2262 | LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 2263 | LLVMValueRef *Indices, unsigned NumIndices, |
| 2264 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2265 | LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 2266 | LLVMValueRef *Indices, unsigned NumIndices, |
| 2267 | const char *Name); |
| 2268 | LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 2269 | unsigned Idx, const char *Name); |
| 2270 | LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, |
| 2271 | const char *Name); |
| 2272 | LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, |
| 2273 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2274 | |
| 2275 | /* Casts */ |
| 2276 | LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 2277 | LLVMTypeRef DestTy, const char *Name); |
| 2278 | LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, |
| 2279 | LLVMTypeRef DestTy, const char *Name); |
| 2280 | LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, |
| 2281 | LLVMTypeRef DestTy, const char *Name); |
| 2282 | LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, |
| 2283 | LLVMTypeRef DestTy, const char *Name); |
| 2284 | LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, |
| 2285 | LLVMTypeRef DestTy, const char *Name); |
| 2286 | LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 2287 | LLVMTypeRef DestTy, const char *Name); |
| 2288 | LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 2289 | LLVMTypeRef DestTy, const char *Name); |
| 2290 | LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 2291 | LLVMTypeRef DestTy, const char *Name); |
| 2292 | LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, |
| 2293 | LLVMTypeRef DestTy, const char *Name); |
| 2294 | LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, |
| 2295 | LLVMTypeRef DestTy, const char *Name); |
| 2296 | LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, |
| 2297 | LLVMTypeRef DestTy, const char *Name); |
| 2298 | LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 2299 | LLVMTypeRef DestTy, const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2300 | LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 2301 | LLVMTypeRef DestTy, const char *Name); |
| 2302 | LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 2303 | LLVMTypeRef DestTy, const char *Name); |
| 2304 | LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 2305 | LLVMTypeRef DestTy, const char *Name); |
Erick Tryzelaar | 3183179 | 2010-02-28 05:51:27 +0000 | [diff] [blame] | 2306 | LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, |
| 2307 | LLVMTypeRef DestTy, const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2308 | LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, |
| 2309 | LLVMTypeRef DestTy, const char *Name); |
Duncan Sands | 9d786d7 | 2009-11-23 10:49:03 +0000 | [diff] [blame] | 2310 | LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/ |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2311 | LLVMTypeRef DestTy, const char *Name); |
| 2312 | LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, |
| 2313 | LLVMTypeRef DestTy, const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2314 | |
| 2315 | /* Comparisons */ |
| 2316 | LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, |
| 2317 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 2318 | const char *Name); |
| 2319 | LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, |
| 2320 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 2321 | const char *Name); |
| 2322 | |
| 2323 | /* Miscellaneous instructions */ |
| 2324 | LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 2325 | LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, |
| 2326 | LLVMValueRef *Args, unsigned NumArgs, |
| 2327 | const char *Name); |
| 2328 | LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, |
| 2329 | LLVMValueRef Then, LLVMValueRef Else, |
| 2330 | const char *Name); |
| 2331 | LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, |
| 2332 | const char *Name); |
| 2333 | LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 2334 | LLVMValueRef Index, const char *Name); |
| 2335 | LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 2336 | LLVMValueRef EltVal, LLVMValueRef Index, |
| 2337 | const char *Name); |
| 2338 | LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, |
| 2339 | LLVMValueRef V2, LLVMValueRef Mask, |
| 2340 | const char *Name); |
Dan Gohman | d5104a5 | 2008-11-03 22:55:43 +0000 | [diff] [blame] | 2341 | LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, |
| 2342 | unsigned Index, const char *Name); |
| 2343 | LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, |
| 2344 | LLVMValueRef EltVal, unsigned Index, |
| 2345 | const char *Name); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2346 | |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 2347 | LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, |
| 2348 | const char *Name); |
| 2349 | LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, |
| 2350 | const char *Name); |
| 2351 | LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, |
| 2352 | LLVMValueRef RHS, const char *Name); |
| 2353 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2354 | /** |
| 2355 | * @} |
| 2356 | */ |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2357 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2358 | /** |
| 2359 | * @defgroup LLVMCCoreModuleProvider Module Providers |
| 2360 | * |
| 2361 | * @{ |
| 2362 | */ |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 2363 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2364 | /** |
| 2365 | * 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] | 2366 | * JIT. They take ModuleProviders for historical reasons. |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 2367 | */ |
| 2368 | LLVMModuleProviderRef |
| 2369 | LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); |
| 2370 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2371 | /** |
| 2372 | * Destroys the module M. |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 2373 | */ |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 2374 | void LLVMDisposeModuleProvider(LLVMModuleProviderRef M); |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 2375 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2376 | /** |
| 2377 | * @} |
| 2378 | */ |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2379 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2380 | /** |
| 2381 | * @defgroup LLVMCCoreMemoryBuffers Memory Buffers |
| 2382 | * |
| 2383 | * @{ |
| 2384 | */ |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2385 | |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2386 | LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, |
| 2387 | LLVMMemoryBufferRef *OutMemBuf, |
| 2388 | char **OutMessage); |
| 2389 | LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, |
| 2390 | char **OutMessage); |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2391 | void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); |
| 2392 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2393 | /** |
| 2394 | * @} |
| 2395 | */ |
| 2396 | |
| 2397 | /** |
| 2398 | * @defgroup LLVMCCorePassRegistry Pass Registry |
| 2399 | * |
| 2400 | * @{ |
| 2401 | */ |
Owen Anderson | 4698c5d | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 2402 | |
| 2403 | /** Return the global pass registry, for use with initialization functions. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2404 | @see llvm::PassRegistry::getPassRegistry */ |
Owen Anderson | 4698c5d | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 2405 | LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2406 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2407 | /** |
| 2408 | * @} |
| 2409 | */ |
| 2410 | |
| 2411 | /** |
| 2412 | * @defgroup LLVMCCorePassManagers Pass Managers |
| 2413 | * |
| 2414 | * @{ |
| 2415 | */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2416 | |
| 2417 | /** Constructs a new whole-module pass pipeline. This type of pipeline is |
| 2418 | suitable for link-time optimization and whole-module transformations. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2419 | @see llvm::PassManager::PassManager */ |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 2420 | LLVMPassManagerRef LLVMCreatePassManager(void); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2421 | |
| 2422 | /** Constructs a new function-by-function pass pipeline over the module |
| 2423 | provider. It does not take ownership of the module provider. This type of |
| 2424 | pipeline is suitable for code generation and JIT compilation tasks. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2425 | @see llvm::FunctionPassManager::FunctionPassManager */ |
Erick Tryzelaar | ad0e0cb | 2010-03-02 23:58:54 +0000 | [diff] [blame] | 2426 | LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); |
| 2427 | |
| 2428 | /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2429 | LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); |
| 2430 | |
| 2431 | /** Initializes, executes on the provided module, and finalizes all of the |
| 2432 | 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] | 2433 | modified the module, 0 otherwise. |
| 2434 | @see llvm::PassManager::run(Module&) */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2435 | LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2436 | |
| 2437 | /** Initializes all of the function passes scheduled in the function pass |
| 2438 | 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] | 2439 | @see llvm::FunctionPassManager::doInitialization */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2440 | LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2441 | |
| 2442 | /** Executes all of the function passes scheduled in the function pass manager |
| 2443 | on the provided function. Returns 1 if any of the passes modified the |
| 2444 | function, false otherwise. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2445 | @see llvm::FunctionPassManager::run(Function&) */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2446 | LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2447 | |
| 2448 | /** Finalizes all of the function passes scheduled in in the function pass |
| 2449 | 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] | 2450 | @see llvm::FunctionPassManager::doFinalization */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2451 | LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2452 | |
| 2453 | /** Frees the memory of a pass pipeline. For function pipelines, does not free |
| 2454 | the module provider. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2455 | @see llvm::PassManagerBase::~PassManagerBase. */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2456 | void LLVMDisposePassManager(LLVMPassManagerRef PM); |
| 2457 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2458 | /** |
| 2459 | * @} |
| 2460 | */ |
| 2461 | |
| 2462 | /** |
| 2463 | * @} |
| 2464 | */ |
| 2465 | |
| 2466 | /** |
| 2467 | * @} |
| 2468 | */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2469 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2470 | #ifdef __cplusplus |
| 2471 | } |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2472 | |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2473 | namespace llvm { |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2474 | class MemoryBuffer; |
Gordon Henriksen | 9657149 | 2008-03-16 15:55:43 +0000 | [diff] [blame] | 2475 | class PassManagerBase; |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 2476 | |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2477 | #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ |
| 2478 | inline ty *unwrap(ref P) { \ |
| 2479 | return reinterpret_cast<ty*>(P); \ |
| 2480 | } \ |
| 2481 | \ |
| 2482 | inline ref wrap(const ty *P) { \ |
| 2483 | return reinterpret_cast<ref>(const_cast<ty*>(P)); \ |
| 2484 | } |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2485 | |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2486 | #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ |
| 2487 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ |
| 2488 | \ |
| 2489 | template<typename T> \ |
| 2490 | inline T *unwrap(ref P) { \ |
| 2491 | return cast<T>(unwrap(P)); \ |
| 2492 | } |
| 2493 | |
| 2494 | #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ |
| 2495 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ |
| 2496 | \ |
| 2497 | template<typename T> \ |
| 2498 | inline T *unwrap(ref P) { \ |
Chris Lattner | 7ba0661 | 2010-01-22 06:49:46 +0000 | [diff] [blame] | 2499 | T *Q = (T*)unwrap(P); \ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2500 | assert(Q && "Invalid cast!"); \ |
| 2501 | return Q; \ |
| 2502 | } |
| 2503 | |
| 2504 | DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef ) |
| 2505 | DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) |
Gordon Henriksen | 823f973 | 2007-12-27 18:25:59 +0000 | [diff] [blame] | 2506 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) |
| 2507 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) |
Eric Christopher | 5927883 | 2008-08-08 19:39:37 +0000 | [diff] [blame] | 2508 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) |
Gordon Henriksen | 823f973 | 2007-12-27 18:25:59 +0000 | [diff] [blame] | 2509 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) |
Owen Anderson | 6773d38 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 2510 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 2511 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef ) |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2512 | DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) |
Owen Anderson | 4698c5d | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 2513 | DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef ) |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 2514 | /* LLVMModuleProviderRef exists for historical reasons, but now just holds a |
| 2515 | * Module. |
| 2516 | */ |
| 2517 | inline Module *unwrap(LLVMModuleProviderRef MP) { |
| 2518 | return reinterpret_cast<Module*>(MP); |
| 2519 | } |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2520 | |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 2521 | #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS |
| 2522 | #undef DEFINE_ISA_CONVERSION_FUNCTIONS |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2523 | #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 2524 | |
| 2525 | /* Specialized opaque context conversions. |
| 2526 | */ |
| 2527 | inline LLVMContext **unwrap(LLVMContextRef* Tys) { |
| 2528 | return reinterpret_cast<LLVMContext**>(Tys); |
| 2529 | } |
| 2530 | |
| 2531 | inline LLVMContextRef *wrap(const LLVMContext **Tys) { |
| 2532 | return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys)); |
| 2533 | } |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2534 | |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2535 | /* Specialized opaque type conversions. |
| 2536 | */ |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2537 | inline Type **unwrap(LLVMTypeRef* Tys) { |
| 2538 | return reinterpret_cast<Type**>(Tys); |
| 2539 | } |
| 2540 | |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 2541 | inline LLVMTypeRef *wrap(Type **Tys) { |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2542 | return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys)); |
| 2543 | } |
| 2544 | |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 2545 | /* Specialized opaque value conversions. |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2546 | */ |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2547 | inline Value **unwrap(LLVMValueRef *Vals) { |
| 2548 | return reinterpret_cast<Value**>(Vals); |
| 2549 | } |
| 2550 | |
| 2551 | template<typename T> |
| 2552 | inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { |
| 2553 | #if DEBUG |
Chris Lattner | b797115 | 2009-07-10 18:28:19 +0000 | [diff] [blame] | 2554 | for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2555 | cast<T>(*I); |
| 2556 | #endif |
Hans Wennborg | 8f7edbf | 2011-06-04 16:00:19 +0000 | [diff] [blame] | 2557 | (void)Length; |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2558 | return reinterpret_cast<T**>(Vals); |
| 2559 | } |
| 2560 | |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2561 | inline LLVMValueRef *wrap(const Value **Vals) { |
| 2562 | return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals)); |
| 2563 | } |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 2564 | } |
| 2565 | |
| 2566 | #endif /* !defined(__cplusplus) */ |
| 2567 | |
| 2568 | #endif /* !defined(LLVM_C_CORE_H) */ |