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