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