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