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