Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Nicolas Capens | 4846150 | 2018-08-06 14:20:45 -0400 | [diff] [blame] | 15 | #ifndef rr_Nucleus_hpp |
| 16 | #define rr_Nucleus_hpp |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 17 | |
Ben Clayton | 6897e9b | 2019-07-16 17:27:27 +0100 | [diff] [blame] | 18 | #include <atomic> |
Nicolas Capens | 01a9796 | 2017-07-28 17:30:51 -0400 | [diff] [blame] | 19 | #include <cassert> |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 20 | #include <cstdarg> |
| 21 | #include <cstdint> |
Antonio Maiorano | 5ba2a5b | 2020-01-17 15:29:37 -0500 | [diff] [blame] | 22 | #include <functional> |
Ben Clayton | 6897e9b | 2019-07-16 17:27:27 +0100 | [diff] [blame] | 23 | #include <memory> |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 24 | #include <string> |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 25 | #include <vector> |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 26 | |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 27 | #ifdef None |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 28 | # undef None // TODO(b/127920555) |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 29 | #endif |
| 30 | |
Nicolas Capens | b3a473e | 2019-12-09 11:41:03 -0500 | [diff] [blame] | 31 | static_assert(sizeof(short) == 2, "Reactor's 'Short' type is 16-bit, and requires the C++ 'short' to match that."); |
| 32 | static_assert(sizeof(int) == 4, "Reactor's 'Int' type is 32-bit, and requires the C++ 'int' to match that."); |
| 33 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 34 | namespace rr { |
| 35 | |
| 36 | class Type; |
| 37 | class Value; |
| 38 | class SwitchCases; |
| 39 | class BasicBlock; |
| 40 | class Routine; |
| 41 | |
| 42 | // Optimization holds the optimization settings for code generation. |
| 43 | class Optimization |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 44 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 45 | public: |
| 46 | enum class Level |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 47 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 48 | None, |
| 49 | Less, |
| 50 | Default, |
| 51 | Aggressive, |
| 52 | }; |
| 53 | |
| 54 | enum class Pass |
| 55 | { |
| 56 | Disabled, |
| 57 | InstructionCombining, |
| 58 | CFGSimplification, |
| 59 | LICM, |
| 60 | AggressiveDCE, |
| 61 | GVN, |
| 62 | Reassociate, |
| 63 | DeadStoreElimination, |
| 64 | SCCP, |
| 65 | ScalarReplAggregates, |
| 66 | EarlyCSEPass, |
| 67 | |
| 68 | Count, |
| 69 | }; |
| 70 | |
| 71 | using Passes = std::vector<Pass>; |
| 72 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 73 | Optimization(Level level = Level::Default, const Passes &passes = {}) |
| 74 | : level(level) |
| 75 | , passes(passes) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 76 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 77 | #if defined(REACTOR_DEFAULT_OPT_LEVEL) |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 78 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 79 | this->level = Level::REACTOR_DEFAULT_OPT_LEVEL; |
Antonio Maiorano | 062dc18 | 2019-12-09 11:52:31 -0500 | [diff] [blame] | 80 | } |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 81 | #endif |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 82 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 83 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 84 | Level getLevel() const { return level; } |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 85 | const Passes &getPasses() const { return passes; } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 86 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 87 | private: |
| 88 | Level level = Level::Default; |
| 89 | Passes passes; |
| 90 | }; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 91 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 92 | // Config holds the Reactor configuration settings. |
| 93 | class Config |
| 94 | { |
| 95 | public: |
| 96 | // Edit holds a number of modifications to a config, that can be applied |
| 97 | // on an existing Config to produce a new Config with the specified |
| 98 | // changes. |
| 99 | class Edit |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 100 | { |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 101 | public: |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 102 | static const Edit None; |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 103 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 104 | Edit &set(Optimization::Level level) |
| 105 | { |
| 106 | optLevel = level; |
| 107 | optLevelChanged = true; |
| 108 | return *this; |
| 109 | } |
| 110 | Edit &add(Optimization::Pass pass) |
| 111 | { |
| 112 | optPassEdits.push_back({ ListEdit::Add, pass }); |
| 113 | return *this; |
| 114 | } |
| 115 | Edit &remove(Optimization::Pass pass) |
| 116 | { |
| 117 | optPassEdits.push_back({ ListEdit::Remove, pass }); |
| 118 | return *this; |
| 119 | } |
| 120 | Edit &clearOptimizationPasses() |
| 121 | { |
| 122 | optPassEdits.push_back({ ListEdit::Clear, Optimization::Pass::Disabled }); |
| 123 | return *this; |
| 124 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 125 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 126 | Config apply(const Config &cfg) const; |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 127 | |
| 128 | private: |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 129 | enum class ListEdit |
| 130 | { |
| 131 | Add, |
| 132 | Remove, |
| 133 | Clear |
| 134 | }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 135 | using OptPassesEdit = std::pair<ListEdit, Optimization::Pass>; |
| 136 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 137 | template<typename T> |
| 138 | void apply(const std::vector<std::pair<ListEdit, T>> &edits, std::vector<T> &list) const; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 139 | |
| 140 | Optimization::Level optLevel; |
| 141 | bool optLevelChanged = false; |
| 142 | std::vector<OptPassesEdit> optPassEdits; |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 143 | }; |
| 144 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 145 | Config() = default; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 146 | Config(const Optimization &optimization) |
| 147 | : optimization(optimization) |
| 148 | {} |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 149 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 150 | const Optimization &getOptimization() const { return optimization; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 151 | |
| 152 | private: |
| 153 | Optimization optimization; |
| 154 | }; |
| 155 | |
| 156 | class Nucleus |
| 157 | { |
| 158 | public: |
| 159 | Nucleus(); |
| 160 | |
| 161 | virtual ~Nucleus(); |
| 162 | |
| 163 | // Default configuration to use when no other configuration is specified. |
| 164 | // The new configuration will be applied to subsequent reactor calls. |
| 165 | static void setDefaultConfig(const Config &cfg); |
| 166 | static void adjustDefaultConfig(const Config::Edit &cfgEdit); |
| 167 | static Config getDefaultConfig(); |
| 168 | |
| 169 | std::shared_ptr<Routine> acquireRoutine(const char *name, const Config::Edit &cfgEdit = Config::Edit::None); |
| 170 | |
| 171 | static Value *allocateStackVariable(Type *type, int arraySize = 0); |
| 172 | static BasicBlock *createBasicBlock(); |
| 173 | static BasicBlock *getInsertBlock(); |
| 174 | static void setInsertBlock(BasicBlock *basicBlock); |
| 175 | |
Antonio Maiorano | 5ba2a5b | 2020-01-17 15:29:37 -0500 | [diff] [blame] | 176 | static void createFunction(Type *returnType, const std::vector<Type *> ¶mTypes); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 177 | static Value *getArgument(unsigned int index); |
| 178 | |
| 179 | // Coroutines |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 180 | using CoroutineHandle = void *; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 181 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 182 | template<typename... ARGS> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 183 | using CoroutineBegin = CoroutineHandle(ARGS...); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 184 | using CoroutineAwait = bool(CoroutineHandle, void *yieldValue); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 185 | using CoroutineDestroy = void(CoroutineHandle); |
| 186 | |
| 187 | enum CoroutineEntries |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 188 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 189 | CoroutineEntryBegin = 0, |
| 190 | CoroutineEntryAwait, |
| 191 | CoroutineEntryDestroy, |
| 192 | CoroutineEntryCount |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 193 | }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 194 | |
Antonio Maiorano | 5ba2a5b | 2020-01-17 15:29:37 -0500 | [diff] [blame] | 195 | // Begins the generation of the three coroutine functions: CoroutineBegin, CoroutineAwait, and CoroutineDestroy, |
| 196 | // which will be returned by Routine::getEntry() with arg CoroutineEntryBegin, CoroutineEntryAwait, and CoroutineEntryDestroy |
| 197 | // respectively. Called by Coroutine constructor. |
| 198 | // Params are used to generate the params to CoroutineBegin, while ReturnType is used as the YieldType for the coroutine, |
| 199 | // returned via CoroutineAwait.. |
| 200 | static void createCoroutine(Type *returnType, const std::vector<Type *> ¶ms); |
| 201 | // Generates code to store the passed in value, and to suspend execution of the coroutine, such that the next call to |
| 202 | // CoroutineAwait can set the output yieldValue and resume execution of the coroutine. |
| 203 | static void yield(Value *val); |
| 204 | // Called to finalize coroutine creation. After this call, Routine::getEntry can be called to retrieve the entry point to any |
| 205 | // of the three coroutine functions. Called by Coroutine::finalize. |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 206 | std::shared_ptr<Routine> acquireCoroutine(const char *name, const Config::Edit &cfg = Config::Edit::None); |
Antonio Maiorano | 5ba2a5b | 2020-01-17 15:29:37 -0500 | [diff] [blame] | 207 | // Called by Coroutine::operator() to execute CoroutineEntryBegin wrapped up in func. This is needed in case |
| 208 | // the call must be run on a separate thread of execution (e.g. on a fiber). |
| 209 | static CoroutineHandle invokeCoroutineBegin(Routine &routine, std::function<CoroutineHandle()> func); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 210 | |
| 211 | // Terminators |
| 212 | static void createRetVoid(); |
| 213 | static void createRet(Value *V); |
| 214 | static void createBr(BasicBlock *dest); |
| 215 | static void createCondBr(Value *cond, BasicBlock *ifTrue, BasicBlock *ifFalse); |
| 216 | |
| 217 | // Binary operators |
| 218 | static Value *createAdd(Value *lhs, Value *rhs); |
| 219 | static Value *createSub(Value *lhs, Value *rhs); |
| 220 | static Value *createMul(Value *lhs, Value *rhs); |
| 221 | static Value *createUDiv(Value *lhs, Value *rhs); |
| 222 | static Value *createSDiv(Value *lhs, Value *rhs); |
| 223 | static Value *createFAdd(Value *lhs, Value *rhs); |
| 224 | static Value *createFSub(Value *lhs, Value *rhs); |
| 225 | static Value *createFMul(Value *lhs, Value *rhs); |
| 226 | static Value *createFDiv(Value *lhs, Value *rhs); |
| 227 | static Value *createURem(Value *lhs, Value *rhs); |
| 228 | static Value *createSRem(Value *lhs, Value *rhs); |
| 229 | static Value *createFRem(Value *lhs, Value *rhs); |
| 230 | static Value *createShl(Value *lhs, Value *rhs); |
| 231 | static Value *createLShr(Value *lhs, Value *rhs); |
| 232 | static Value *createAShr(Value *lhs, Value *rhs); |
| 233 | static Value *createAnd(Value *lhs, Value *rhs); |
| 234 | static Value *createOr(Value *lhs, Value *rhs); |
| 235 | static Value *createXor(Value *lhs, Value *rhs); |
| 236 | |
| 237 | // Unary operators |
| 238 | static Value *createNeg(Value *V); |
| 239 | static Value *createFNeg(Value *V); |
| 240 | static Value *createNot(Value *V); |
| 241 | |
| 242 | // Memory instructions |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 243 | static Value *createLoad(Value *ptr, Type *type, bool isVolatile = false, unsigned int alignment = 0, bool atomic = false, std::memory_order memoryOrder = std::memory_order_relaxed); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 244 | static Value *createStore(Value *value, Value *ptr, Type *type, bool isVolatile = false, unsigned int aligment = 0, bool atomic = false, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 245 | static Value *createGEP(Value *ptr, Type *type, Value *index, bool unsignedIndex); |
| 246 | |
| 247 | // Masked Load / Store instructions |
| 248 | static Value *createMaskedLoad(Value *base, Type *elementType, Value *mask, unsigned int alignment, bool zeroMaskedLanes); |
| 249 | static void createMaskedStore(Value *base, Value *value, Value *mask, unsigned int alignment); |
| 250 | |
| 251 | // Barrier instructions |
| 252 | static void createFence(std::memory_order memoryOrder); |
| 253 | |
| 254 | // Atomic instructions |
| 255 | static Value *createAtomicAdd(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 256 | static Value *createAtomicSub(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 257 | static Value *createAtomicAnd(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 258 | static Value *createAtomicOr(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 259 | static Value *createAtomicXor(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 260 | static Value *createAtomicMin(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 261 | static Value *createAtomicMax(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 262 | static Value *createAtomicUMin(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 263 | static Value *createAtomicUMax(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 264 | static Value *createAtomicExchange(Value *ptr, Value *value, std::memory_order memoryOrder = std::memory_order_relaxed); |
| 265 | static Value *createAtomicCompareExchange(Value *ptr, Value *value, Value *compare, std::memory_order memoryOrderEqual, std::memory_order memoryOrderUnequal); |
| 266 | |
| 267 | // Cast/Conversion Operators |
| 268 | static Value *createTrunc(Value *V, Type *destType); |
| 269 | static Value *createZExt(Value *V, Type *destType); |
| 270 | static Value *createSExt(Value *V, Type *destType); |
| 271 | static Value *createFPToUI(Value *V, Type *destType); |
| 272 | static Value *createFPToSI(Value *V, Type *destType); |
| 273 | static Value *createSIToFP(Value *V, Type *destType); |
| 274 | static Value *createFPTrunc(Value *V, Type *destType); |
| 275 | static Value *createFPExt(Value *V, Type *destType); |
| 276 | static Value *createBitCast(Value *V, Type *destType); |
| 277 | |
| 278 | // Compare instructions |
| 279 | static Value *createPtrEQ(Value *lhs, Value *rhs); |
| 280 | static Value *createICmpEQ(Value *lhs, Value *rhs); |
| 281 | static Value *createICmpNE(Value *lhs, Value *rhs); |
| 282 | static Value *createICmpUGT(Value *lhs, Value *rhs); |
| 283 | static Value *createICmpUGE(Value *lhs, Value *rhs); |
| 284 | static Value *createICmpULT(Value *lhs, Value *rhs); |
| 285 | static Value *createICmpULE(Value *lhs, Value *rhs); |
| 286 | static Value *createICmpSGT(Value *lhs, Value *rhs); |
| 287 | static Value *createICmpSGE(Value *lhs, Value *rhs); |
| 288 | static Value *createICmpSLT(Value *lhs, Value *rhs); |
| 289 | static Value *createICmpSLE(Value *lhs, Value *rhs); |
| 290 | static Value *createFCmpOEQ(Value *lhs, Value *rhs); |
| 291 | static Value *createFCmpOGT(Value *lhs, Value *rhs); |
| 292 | static Value *createFCmpOGE(Value *lhs, Value *rhs); |
| 293 | static Value *createFCmpOLT(Value *lhs, Value *rhs); |
| 294 | static Value *createFCmpOLE(Value *lhs, Value *rhs); |
| 295 | static Value *createFCmpONE(Value *lhs, Value *rhs); |
| 296 | static Value *createFCmpORD(Value *lhs, Value *rhs); |
| 297 | static Value *createFCmpUNO(Value *lhs, Value *rhs); |
| 298 | static Value *createFCmpUEQ(Value *lhs, Value *rhs); |
| 299 | static Value *createFCmpUGT(Value *lhs, Value *rhs); |
| 300 | static Value *createFCmpUGE(Value *lhs, Value *rhs); |
| 301 | static Value *createFCmpULT(Value *lhs, Value *rhs); |
| 302 | static Value *createFCmpULE(Value *lhs, Value *rhs); |
| 303 | static Value *createFCmpUNE(Value *lhs, Value *rhs); |
| 304 | |
| 305 | // Vector instructions |
| 306 | static Value *createExtractElement(Value *vector, Type *type, int index); |
| 307 | static Value *createInsertElement(Value *vector, Value *element, int index); |
| 308 | static Value *createShuffleVector(Value *V1, Value *V2, const int *select); |
| 309 | |
| 310 | // Other instructions |
| 311 | static Value *createSelect(Value *C, Value *ifTrue, Value *ifFalse); |
| 312 | static SwitchCases *createSwitch(Value *control, BasicBlock *defaultBranch, unsigned numCases); |
| 313 | static void addSwitchCase(SwitchCases *switchCases, int label, BasicBlock *branch); |
| 314 | static void createUnreachable(); |
| 315 | |
| 316 | // Constant values |
| 317 | static Value *createNullValue(Type *type); |
| 318 | static Value *createConstantLong(int64_t i); |
| 319 | static Value *createConstantInt(int i); |
| 320 | static Value *createConstantInt(unsigned int i); |
| 321 | static Value *createConstantBool(bool b); |
| 322 | static Value *createConstantByte(signed char i); |
| 323 | static Value *createConstantByte(unsigned char i); |
| 324 | static Value *createConstantShort(short i); |
| 325 | static Value *createConstantShort(unsigned short i); |
| 326 | static Value *createConstantFloat(float x); |
| 327 | static Value *createNullPointer(Type *type); |
| 328 | static Value *createConstantVector(const int64_t *constants, Type *type); |
| 329 | static Value *createConstantVector(const double *constants, Type *type); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 330 | static Value *createConstantString(const char *v); |
| 331 | static Value *createConstantString(const std::string &v) { return createConstantString(v.c_str()); } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 332 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 333 | static Type *getType(Value *value); |
| 334 | static Type *getContainedType(Type *vectorType); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 335 | static Type *getPointerType(Type *elementType); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 336 | static Type *getPrintfStorageType(Type *valueType); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 337 | }; |
| 338 | |
| 339 | } // namespace rr |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 340 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 341 | #endif // rr_Nucleus_hpp |