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_Reactor_hpp |
| 16 | #define rr_Reactor_hpp |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 17 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 18 | #include "Nucleus.hpp" |
| 19 | #include "Routine.hpp" |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 20 | #include "Traits.hpp" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 21 | |
Nicolas Capens | 4dd1eff | 2017-08-04 09:33:04 -0400 | [diff] [blame] | 22 | #include <cassert> |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 23 | #include <cstddef> |
Chris Forbes | 878d4b0 | 2019-01-21 10:48:35 -0800 | [diff] [blame] | 24 | #include <cstdio> |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 25 | |
| 26 | #include <string> |
Ben Clayton | 169872e | 2019-02-27 23:58:35 +0000 | [diff] [blame] | 27 | #include <tuple> |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 28 | #include <unordered_set> |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 29 | |
Chris Forbes | c296806 | 2019-03-19 16:48:03 -0700 | [diff] [blame] | 30 | #undef Bool // b/127920555 |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 31 | |
Ben Clayton | 5875be5 | 2019-04-11 14:57:40 -0400 | [diff] [blame] | 32 | #if !defined(NDEBUG) |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 33 | #define ENABLE_RR_PRINT 1 // Enables RR_PRINT(), RR_WATCH() |
Ben Clayton | 5875be5 | 2019-04-11 14:57:40 -0400 | [diff] [blame] | 34 | #endif // !defined(NDEBUG) |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 35 | |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 36 | #ifdef ENABLE_RR_DEBUG_INFO |
| 37 | // Functions used for generating JIT debug info. |
| 38 | // See docs/ReactorDebugInfo.md for more information. |
| 39 | namespace rr |
| 40 | { |
| 41 | // Update the current source location for debug. |
| 42 | void EmitDebugLocation(); |
| 43 | // Bind value to its symbolic name taken from the backtrace. |
| 44 | void EmitDebugVariable(class Value* value); |
| 45 | // Flush any pending variable bindings before the line ends. |
| 46 | void FlushDebug(); |
| 47 | } |
| 48 | #define RR_DEBUG_INFO_UPDATE_LOC() rr::EmitDebugLocation() |
| 49 | #define RR_DEBUG_INFO_EMIT_VAR(value) rr::EmitDebugVariable(value) |
| 50 | #define RR_DEBUG_INFO_FLUSH() rr::FlushDebug() |
| 51 | #else |
| 52 | #define RR_DEBUG_INFO_UPDATE_LOC() |
| 53 | #define RR_DEBUG_INFO_EMIT_VAR(value) |
| 54 | #define RR_DEBUG_INFO_FLUSH() |
| 55 | #endif // ENABLE_RR_DEBUG_INFO |
| 56 | |
Nicolas Capens | 4846150 | 2018-08-06 14:20:45 -0400 | [diff] [blame] | 57 | namespace rr |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 58 | { |
Ben Clayton | c790416 | 2019-04-17 17:35:48 -0400 | [diff] [blame] | 59 | struct Capabilities |
| 60 | { |
Ben Clayton | 1c82c7b | 2019-04-30 12:49:27 +0100 | [diff] [blame] | 61 | bool CallSupported; // Support for rr::Call() |
| 62 | bool CoroutinesSupported; // Support for rr::Coroutine<F> |
Ben Clayton | c790416 | 2019-04-17 17:35:48 -0400 | [diff] [blame] | 63 | }; |
| 64 | extern const Capabilities Caps; |
| 65 | |
Nicolas Capens | eb253d0 | 2016-11-18 14:40:40 -0500 | [diff] [blame] | 66 | class Bool; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 67 | class Byte; |
| 68 | class SByte; |
| 69 | class Byte4; |
| 70 | class SByte4; |
| 71 | class Byte8; |
| 72 | class SByte8; |
| 73 | class Byte16; |
| 74 | class SByte16; |
| 75 | class Short; |
| 76 | class UShort; |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 77 | class Short2; |
| 78 | class UShort2; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 79 | class Short4; |
| 80 | class UShort4; |
| 81 | class Short8; |
| 82 | class UShort8; |
| 83 | class Int; |
| 84 | class UInt; |
| 85 | class Int2; |
| 86 | class UInt2; |
| 87 | class Int4; |
| 88 | class UInt4; |
| 89 | class Long; |
Alexis Hetu | 734e257 | 2018-12-20 14:00:49 -0500 | [diff] [blame] | 90 | class Half; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 91 | class Float; |
| 92 | class Float2; |
| 93 | class Float4; |
| 94 | |
| 95 | class Void |
| 96 | { |
| 97 | public: |
| 98 | static Type *getType(); |
| 99 | |
| 100 | static bool isVoid() |
| 101 | { |
| 102 | return true; |
| 103 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | template<class T> |
| 107 | class RValue; |
| 108 | |
| 109 | template<class T> |
| 110 | class Pointer; |
| 111 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 112 | class Variable |
| 113 | { |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 114 | friend class Nucleus; |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 115 | friend class PrintValue; |
Nicolas Capens | 5da8d8d | 2019-03-27 14:45:34 -0400 | [diff] [blame] | 116 | |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 117 | Variable() = delete; |
Nicolas Capens | 5da8d8d | 2019-03-27 14:45:34 -0400 | [diff] [blame] | 118 | Variable &operator=(const Variable&) = delete; |
| 119 | |
| 120 | public: |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 121 | void materialize() const; |
| 122 | |
| 123 | Value *loadValue() const; |
| 124 | Value *storeValue(Value *value) const; |
| 125 | |
| 126 | Value *getBaseAddress() const; |
| 127 | Value *getElementPointer(Value *index, bool unsignedIndex) const; |
Nicolas Capens | 5da8d8d | 2019-03-27 14:45:34 -0400 | [diff] [blame] | 128 | |
| 129 | protected: |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 130 | Variable(Type *type, int arraySize); |
| 131 | Variable(const Variable&) = default; |
| 132 | |
| 133 | ~Variable(); |
| 134 | |
Ben Clayton | 83dd452 | 2019-06-27 10:37:00 +0100 | [diff] [blame] | 135 | const int arraySize; |
| 136 | |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 137 | private: |
| 138 | static void materializeAll(); |
| 139 | static void killUnmaterialized(); |
| 140 | |
| 141 | static std::unordered_set<Variable*> unmaterializedVariables; |
| 142 | |
| 143 | Type *const type; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 144 | mutable Value *rvalue = nullptr; |
| 145 | mutable Value *address = nullptr; |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 146 | }; |
| 147 | |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 148 | template<class T> |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 149 | class LValue : public Variable |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 150 | { |
| 151 | public: |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 152 | LValue(int arraySize = 0); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 153 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 154 | RValue<Pointer<T>> operator&(); |
| 155 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 156 | static bool isVoid() |
| 157 | { |
| 158 | return false; |
| 159 | } |
Ben Clayton | 0953d9b | 2019-06-25 20:57:06 +0100 | [diff] [blame] | 160 | |
| 161 | // self() returns the this pointer to this LValue<T> object. |
| 162 | // This function exists because operator&() is overloaded. |
| 163 | inline LValue<T>* self() { return this; } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 164 | }; |
| 165 | |
| 166 | template<class T> |
| 167 | class Reference |
| 168 | { |
| 169 | public: |
Ben Clayton | 208ed40 | 2019-05-03 22:30:03 +0100 | [diff] [blame] | 170 | using reference_underlying_type = T; |
| 171 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 172 | explicit Reference(Value *pointer, int alignment = 1); |
| 173 | |
| 174 | RValue<T> operator=(RValue<T> rhs) const; |
| 175 | RValue<T> operator=(const Reference<T> &ref) const; |
| 176 | |
| 177 | RValue<T> operator+=(RValue<T> rhs) const; |
| 178 | |
Ben Clayton | ec25573 | 2019-02-27 13:51:22 +0000 | [diff] [blame] | 179 | RValue<Pointer<T>> operator&() const { return RValue<Pointer<T>>(address); } |
| 180 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 181 | Value *loadValue() const; |
| 182 | int getAlignment() const; |
| 183 | |
| 184 | private: |
| 185 | Value *address; |
| 186 | |
| 187 | const int alignment; |
| 188 | }; |
| 189 | |
| 190 | template<class T> |
Ben Clayton | 35e90e2 | 2019-03-15 10:06:06 +0000 | [diff] [blame] | 191 | struct BoolLiteral |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 192 | { |
| 193 | struct type; |
| 194 | }; |
| 195 | |
Nicolas Capens | eb253d0 | 2016-11-18 14:40:40 -0500 | [diff] [blame] | 196 | template<> |
Ben Clayton | 35e90e2 | 2019-03-15 10:06:06 +0000 | [diff] [blame] | 197 | struct BoolLiteral<Bool> |
Nicolas Capens | eb253d0 | 2016-11-18 14:40:40 -0500 | [diff] [blame] | 198 | { |
| 199 | typedef bool type; |
| 200 | }; |
| 201 | |
Ben Clayton | 35e90e2 | 2019-03-15 10:06:06 +0000 | [diff] [blame] | 202 | template<class T> |
| 203 | struct IntLiteral |
| 204 | { |
| 205 | struct type; |
| 206 | }; |
| 207 | |
Nicolas Capens | eb253d0 | 2016-11-18 14:40:40 -0500 | [diff] [blame] | 208 | template<> |
| 209 | struct IntLiteral<Int> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 210 | { |
| 211 | typedef int type; |
| 212 | }; |
| 213 | |
Nicolas Capens | eb253d0 | 2016-11-18 14:40:40 -0500 | [diff] [blame] | 214 | template<> |
| 215 | struct IntLiteral<UInt> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 216 | { |
| 217 | typedef unsigned int type; |
| 218 | }; |
| 219 | |
Nicolas Capens | eb253d0 | 2016-11-18 14:40:40 -0500 | [diff] [blame] | 220 | template<> |
| 221 | struct IntLiteral<Long> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 222 | { |
| 223 | typedef int64_t type; |
| 224 | }; |
| 225 | |
| 226 | template<class T> |
| 227 | struct FloatLiteral |
| 228 | { |
| 229 | struct type; |
| 230 | }; |
| 231 | |
Nicolas Capens | eb253d0 | 2016-11-18 14:40:40 -0500 | [diff] [blame] | 232 | template<> |
| 233 | struct FloatLiteral<Float> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 234 | { |
| 235 | typedef float type; |
| 236 | }; |
| 237 | |
| 238 | template<class T> |
| 239 | class RValue |
| 240 | { |
| 241 | public: |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 242 | using rvalue_underlying_type = T; |
| 243 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 244 | explicit RValue(Value *rvalue); |
| 245 | |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 246 | #ifdef ENABLE_RR_DEBUG_INFO |
| 247 | RValue(const RValue<T> &rvalue); |
| 248 | #endif // ENABLE_RR_DEBUG_INFO |
| 249 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 250 | RValue(const T &lvalue); |
Ben Clayton | 35e90e2 | 2019-03-15 10:06:06 +0000 | [diff] [blame] | 251 | RValue(typename BoolLiteral<T>::type i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 252 | RValue(typename IntLiteral<T>::type i); |
| 253 | RValue(typename FloatLiteral<T>::type f); |
| 254 | RValue(const Reference<T> &rhs); |
| 255 | |
| 256 | RValue<T> &operator=(const RValue<T>&) = delete; |
| 257 | |
| 258 | Value *value; // FIXME: Make private |
| 259 | }; |
| 260 | |
| 261 | template<typename T> |
| 262 | struct Argument |
| 263 | { |
| 264 | explicit Argument(Value *value) : value(value) {} |
| 265 | |
| 266 | Value *value; |
| 267 | }; |
| 268 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 269 | class Bool : public LValue<Bool> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 270 | { |
| 271 | public: |
| 272 | Bool(Argument<Bool> argument); |
| 273 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 274 | Bool() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 275 | Bool(bool x); |
| 276 | Bool(RValue<Bool> rhs); |
| 277 | Bool(const Bool &rhs); |
| 278 | Bool(const Reference<Bool> &rhs); |
| 279 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 280 | // RValue<Bool> operator=(bool rhs); // FIXME: Implement |
| 281 | RValue<Bool> operator=(RValue<Bool> rhs); |
| 282 | RValue<Bool> operator=(const Bool &rhs); |
| 283 | RValue<Bool> operator=(const Reference<Bool> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 284 | |
| 285 | static Type *getType(); |
| 286 | }; |
| 287 | |
| 288 | RValue<Bool> operator!(RValue<Bool> val); |
| 289 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs); |
| 290 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs); |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 291 | RValue<Bool> operator!=(RValue<Bool> lhs, RValue<Bool> rhs); |
| 292 | RValue<Bool> operator==(RValue<Bool> lhs, RValue<Bool> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 293 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 294 | class Byte : public LValue<Byte> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 295 | { |
| 296 | public: |
| 297 | Byte(Argument<Byte> argument); |
| 298 | |
| 299 | explicit Byte(RValue<Int> cast); |
| 300 | explicit Byte(RValue<UInt> cast); |
| 301 | explicit Byte(RValue<UShort> cast); |
| 302 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 303 | Byte() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 304 | Byte(int x); |
| 305 | Byte(unsigned char x); |
| 306 | Byte(RValue<Byte> rhs); |
| 307 | Byte(const Byte &rhs); |
| 308 | Byte(const Reference<Byte> &rhs); |
| 309 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 310 | // RValue<Byte> operator=(unsigned char rhs); // FIXME: Implement |
| 311 | RValue<Byte> operator=(RValue<Byte> rhs); |
| 312 | RValue<Byte> operator=(const Byte &rhs); |
| 313 | RValue<Byte> operator=(const Reference<Byte> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 314 | |
| 315 | static Type *getType(); |
| 316 | }; |
| 317 | |
| 318 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs); |
| 319 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs); |
| 320 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs); |
| 321 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs); |
| 322 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs); |
| 323 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs); |
| 324 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs); |
| 325 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs); |
| 326 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs); |
| 327 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 328 | RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs); |
| 329 | RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs); |
| 330 | RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs); |
| 331 | RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs); |
| 332 | RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs); |
| 333 | RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs); |
| 334 | RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs); |
| 335 | RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs); |
| 336 | RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs); |
| 337 | RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 338 | RValue<Byte> operator+(RValue<Byte> val); |
| 339 | RValue<Byte> operator-(RValue<Byte> val); |
| 340 | RValue<Byte> operator~(RValue<Byte> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 341 | RValue<Byte> operator++(Byte &val, int); // Post-increment |
| 342 | const Byte &operator++(Byte &val); // Pre-increment |
| 343 | RValue<Byte> operator--(Byte &val, int); // Post-decrement |
| 344 | const Byte &operator--(Byte &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 345 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs); |
| 346 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs); |
| 347 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs); |
| 348 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs); |
| 349 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs); |
| 350 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs); |
| 351 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 352 | class SByte : public LValue<SByte> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 353 | { |
| 354 | public: |
| 355 | SByte(Argument<SByte> argument); |
| 356 | |
| 357 | explicit SByte(RValue<Int> cast); |
| 358 | explicit SByte(RValue<Short> cast); |
| 359 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 360 | SByte() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 361 | SByte(signed char x); |
| 362 | SByte(RValue<SByte> rhs); |
| 363 | SByte(const SByte &rhs); |
| 364 | SByte(const Reference<SByte> &rhs); |
| 365 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 366 | // RValue<SByte> operator=(signed char rhs); // FIXME: Implement |
| 367 | RValue<SByte> operator=(RValue<SByte> rhs); |
| 368 | RValue<SByte> operator=(const SByte &rhs); |
| 369 | RValue<SByte> operator=(const Reference<SByte> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 370 | |
| 371 | static Type *getType(); |
| 372 | }; |
| 373 | |
| 374 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs); |
| 375 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs); |
| 376 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs); |
| 377 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs); |
| 378 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs); |
| 379 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs); |
| 380 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs); |
| 381 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs); |
| 382 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs); |
| 383 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 384 | RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs); |
| 385 | RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs); |
| 386 | RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs); |
| 387 | RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs); |
| 388 | RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs); |
| 389 | RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs); |
| 390 | RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs); |
| 391 | RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs); |
| 392 | RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs); |
| 393 | RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 394 | RValue<SByte> operator+(RValue<SByte> val); |
| 395 | RValue<SByte> operator-(RValue<SByte> val); |
| 396 | RValue<SByte> operator~(RValue<SByte> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 397 | RValue<SByte> operator++(SByte &val, int); // Post-increment |
| 398 | const SByte &operator++(SByte &val); // Pre-increment |
| 399 | RValue<SByte> operator--(SByte &val, int); // Post-decrement |
| 400 | const SByte &operator--(SByte &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 401 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs); |
| 402 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs); |
| 403 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs); |
| 404 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs); |
| 405 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs); |
| 406 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs); |
| 407 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 408 | class Short : public LValue<Short> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 409 | { |
| 410 | public: |
| 411 | Short(Argument<Short> argument); |
| 412 | |
| 413 | explicit Short(RValue<Int> cast); |
| 414 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 415 | Short() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 416 | Short(short x); |
| 417 | Short(RValue<Short> rhs); |
| 418 | Short(const Short &rhs); |
| 419 | Short(const Reference<Short> &rhs); |
| 420 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 421 | // RValue<Short> operator=(short rhs); // FIXME: Implement |
| 422 | RValue<Short> operator=(RValue<Short> rhs); |
| 423 | RValue<Short> operator=(const Short &rhs); |
| 424 | RValue<Short> operator=(const Reference<Short> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 425 | |
| 426 | static Type *getType(); |
| 427 | }; |
| 428 | |
| 429 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs); |
| 430 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs); |
| 431 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs); |
| 432 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs); |
| 433 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs); |
| 434 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs); |
| 435 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs); |
| 436 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs); |
| 437 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs); |
| 438 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 439 | RValue<Short> operator+=(Short &lhs, RValue<Short> rhs); |
| 440 | RValue<Short> operator-=(Short &lhs, RValue<Short> rhs); |
| 441 | RValue<Short> operator*=(Short &lhs, RValue<Short> rhs); |
| 442 | RValue<Short> operator/=(Short &lhs, RValue<Short> rhs); |
| 443 | RValue<Short> operator%=(Short &lhs, RValue<Short> rhs); |
| 444 | RValue<Short> operator&=(Short &lhs, RValue<Short> rhs); |
| 445 | RValue<Short> operator|=(Short &lhs, RValue<Short> rhs); |
| 446 | RValue<Short> operator^=(Short &lhs, RValue<Short> rhs); |
| 447 | RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs); |
| 448 | RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 449 | RValue<Short> operator+(RValue<Short> val); |
| 450 | RValue<Short> operator-(RValue<Short> val); |
| 451 | RValue<Short> operator~(RValue<Short> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 452 | RValue<Short> operator++(Short &val, int); // Post-increment |
| 453 | const Short &operator++(Short &val); // Pre-increment |
| 454 | RValue<Short> operator--(Short &val, int); // Post-decrement |
| 455 | const Short &operator--(Short &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 456 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs); |
| 457 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs); |
| 458 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs); |
| 459 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs); |
| 460 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs); |
| 461 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs); |
| 462 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 463 | class UShort : public LValue<UShort> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 464 | { |
| 465 | public: |
| 466 | UShort(Argument<UShort> argument); |
| 467 | |
| 468 | explicit UShort(RValue<UInt> cast); |
| 469 | explicit UShort(RValue<Int> cast); |
| 470 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 471 | UShort() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 472 | UShort(unsigned short x); |
| 473 | UShort(RValue<UShort> rhs); |
| 474 | UShort(const UShort &rhs); |
| 475 | UShort(const Reference<UShort> &rhs); |
| 476 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 477 | // RValue<UShort> operator=(unsigned short rhs); // FIXME: Implement |
| 478 | RValue<UShort> operator=(RValue<UShort> rhs); |
| 479 | RValue<UShort> operator=(const UShort &rhs); |
| 480 | RValue<UShort> operator=(const Reference<UShort> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 481 | |
| 482 | static Type *getType(); |
| 483 | }; |
| 484 | |
| 485 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs); |
| 486 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs); |
| 487 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs); |
| 488 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs); |
| 489 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs); |
| 490 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs); |
| 491 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs); |
| 492 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs); |
| 493 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs); |
| 494 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 495 | RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs); |
| 496 | RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs); |
| 497 | RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs); |
| 498 | RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs); |
| 499 | RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs); |
| 500 | RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs); |
| 501 | RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs); |
| 502 | RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs); |
| 503 | RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs); |
| 504 | RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 505 | RValue<UShort> operator+(RValue<UShort> val); |
| 506 | RValue<UShort> operator-(RValue<UShort> val); |
| 507 | RValue<UShort> operator~(RValue<UShort> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 508 | RValue<UShort> operator++(UShort &val, int); // Post-increment |
| 509 | const UShort &operator++(UShort &val); // Pre-increment |
| 510 | RValue<UShort> operator--(UShort &val, int); // Post-decrement |
| 511 | const UShort &operator--(UShort &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 512 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs); |
| 513 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs); |
| 514 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs); |
| 515 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs); |
| 516 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs); |
| 517 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs); |
| 518 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 519 | class Byte4 : public LValue<Byte4> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 520 | { |
| 521 | public: |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 522 | explicit Byte4(RValue<Byte8> cast); |
| 523 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 524 | Byte4() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 525 | // Byte4(int x, int y, int z, int w); |
| 526 | // Byte4(RValue<Byte4> rhs); |
| 527 | // Byte4(const Byte4 &rhs); |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 528 | Byte4(const Reference<Byte4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 529 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 530 | // RValue<Byte4> operator=(RValue<Byte4> rhs); |
| 531 | // RValue<Byte4> operator=(const Byte4 &rhs); |
| 532 | // RValue<Byte4> operator=(const Reference<Byte4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 533 | |
| 534 | static Type *getType(); |
| 535 | }; |
| 536 | |
| 537 | // RValue<Byte4> operator+(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 538 | // RValue<Byte4> operator-(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 539 | // RValue<Byte4> operator*(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 540 | // RValue<Byte4> operator/(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 541 | // RValue<Byte4> operator%(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 542 | // RValue<Byte4> operator&(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 543 | // RValue<Byte4> operator|(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 544 | // RValue<Byte4> operator^(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 545 | // RValue<Byte4> operator<<(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 546 | // RValue<Byte4> operator>>(RValue<Byte4> lhs, RValue<Byte4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 547 | // RValue<Byte4> operator+=(Byte4 &lhs, RValue<Byte4> rhs); |
| 548 | // RValue<Byte4> operator-=(Byte4 &lhs, RValue<Byte4> rhs); |
| 549 | // RValue<Byte4> operator*=(Byte4 &lhs, RValue<Byte4> rhs); |
| 550 | // RValue<Byte4> operator/=(Byte4 &lhs, RValue<Byte4> rhs); |
| 551 | // RValue<Byte4> operator%=(Byte4 &lhs, RValue<Byte4> rhs); |
| 552 | // RValue<Byte4> operator&=(Byte4 &lhs, RValue<Byte4> rhs); |
| 553 | // RValue<Byte4> operator|=(Byte4 &lhs, RValue<Byte4> rhs); |
| 554 | // RValue<Byte4> operator^=(Byte4 &lhs, RValue<Byte4> rhs); |
| 555 | // RValue<Byte4> operator<<=(Byte4 &lhs, RValue<Byte4> rhs); |
| 556 | // RValue<Byte4> operator>>=(Byte4 &lhs, RValue<Byte4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 557 | // RValue<Byte4> operator+(RValue<Byte4> val); |
| 558 | // RValue<Byte4> operator-(RValue<Byte4> val); |
| 559 | // RValue<Byte4> operator~(RValue<Byte4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 560 | // RValue<Byte4> operator++(Byte4 &val, int); // Post-increment |
| 561 | // const Byte4 &operator++(Byte4 &val); // Pre-increment |
| 562 | // RValue<Byte4> operator--(Byte4 &val, int); // Post-decrement |
| 563 | // const Byte4 &operator--(Byte4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 564 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 565 | class SByte4 : public LValue<SByte4> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 566 | { |
| 567 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 568 | SByte4() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 569 | // SByte4(int x, int y, int z, int w); |
| 570 | // SByte4(RValue<SByte4> rhs); |
| 571 | // SByte4(const SByte4 &rhs); |
| 572 | // SByte4(const Reference<SByte4> &rhs); |
| 573 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 574 | // RValue<SByte4> operator=(RValue<SByte4> rhs); |
| 575 | // RValue<SByte4> operator=(const SByte4 &rhs); |
| 576 | // RValue<SByte4> operator=(const Reference<SByte4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 577 | |
| 578 | static Type *getType(); |
| 579 | }; |
| 580 | |
| 581 | // RValue<SByte4> operator+(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 582 | // RValue<SByte4> operator-(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 583 | // RValue<SByte4> operator*(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 584 | // RValue<SByte4> operator/(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 585 | // RValue<SByte4> operator%(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 586 | // RValue<SByte4> operator&(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 587 | // RValue<SByte4> operator|(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 588 | // RValue<SByte4> operator^(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 589 | // RValue<SByte4> operator<<(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 590 | // RValue<SByte4> operator>>(RValue<SByte4> lhs, RValue<SByte4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 591 | // RValue<SByte4> operator+=(SByte4 &lhs, RValue<SByte4> rhs); |
| 592 | // RValue<SByte4> operator-=(SByte4 &lhs, RValue<SByte4> rhs); |
| 593 | // RValue<SByte4> operator*=(SByte4 &lhs, RValue<SByte4> rhs); |
| 594 | // RValue<SByte4> operator/=(SByte4 &lhs, RValue<SByte4> rhs); |
| 595 | // RValue<SByte4> operator%=(SByte4 &lhs, RValue<SByte4> rhs); |
| 596 | // RValue<SByte4> operator&=(SByte4 &lhs, RValue<SByte4> rhs); |
| 597 | // RValue<SByte4> operator|=(SByte4 &lhs, RValue<SByte4> rhs); |
| 598 | // RValue<SByte4> operator^=(SByte4 &lhs, RValue<SByte4> rhs); |
| 599 | // RValue<SByte4> operator<<=(SByte4 &lhs, RValue<SByte4> rhs); |
| 600 | // RValue<SByte4> operator>>=(SByte4 &lhs, RValue<SByte4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 601 | // RValue<SByte4> operator+(RValue<SByte4> val); |
| 602 | // RValue<SByte4> operator-(RValue<SByte4> val); |
| 603 | // RValue<SByte4> operator~(RValue<SByte4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 604 | // RValue<SByte4> operator++(SByte4 &val, int); // Post-increment |
| 605 | // const SByte4 &operator++(SByte4 &val); // Pre-increment |
| 606 | // RValue<SByte4> operator--(SByte4 &val, int); // Post-decrement |
| 607 | // const SByte4 &operator--(SByte4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 608 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 609 | class Byte8 : public LValue<Byte8> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 610 | { |
| 611 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 612 | Byte8() = default; |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 613 | Byte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 614 | Byte8(RValue<Byte8> rhs); |
| 615 | Byte8(const Byte8 &rhs); |
| 616 | Byte8(const Reference<Byte8> &rhs); |
| 617 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 618 | RValue<Byte8> operator=(RValue<Byte8> rhs); |
| 619 | RValue<Byte8> operator=(const Byte8 &rhs); |
| 620 | RValue<Byte8> operator=(const Reference<Byte8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 621 | |
| 622 | static Type *getType(); |
| 623 | }; |
| 624 | |
| 625 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 626 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 627 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 628 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 629 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 630 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 631 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 632 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 633 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 634 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, RValue<Byte8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 635 | RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs); |
| 636 | RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs); |
| 637 | // RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs); |
| 638 | // RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs); |
| 639 | // RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs); |
| 640 | RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs); |
| 641 | RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs); |
| 642 | RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs); |
| 643 | // RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs); |
| 644 | // RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 645 | // RValue<Byte8> operator+(RValue<Byte8> val); |
| 646 | // RValue<Byte8> operator-(RValue<Byte8> val); |
| 647 | RValue<Byte8> operator~(RValue<Byte8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 648 | // RValue<Byte8> operator++(Byte8 &val, int); // Post-increment |
| 649 | // const Byte8 &operator++(Byte8 &val); // Pre-increment |
| 650 | // RValue<Byte8> operator--(Byte8 &val, int); // Post-decrement |
| 651 | // const Byte8 &operator--(Byte8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 652 | |
| 653 | RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y); |
| 654 | RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y); |
| 655 | RValue<Short4> Unpack(RValue<Byte4> x); |
Nicolas Capens | 411273e | 2017-01-26 15:13:36 -0800 | [diff] [blame] | 656 | RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 657 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y); |
| 658 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y); |
| 659 | RValue<Int> SignMask(RValue<Byte8> x); |
| 660 | // RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y); |
| 661 | RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y); |
| 662 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 663 | class SByte8 : public LValue<SByte8> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 664 | { |
| 665 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 666 | SByte8() = default; |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 667 | SByte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 668 | SByte8(RValue<SByte8> rhs); |
| 669 | SByte8(const SByte8 &rhs); |
| 670 | SByte8(const Reference<SByte8> &rhs); |
| 671 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 672 | RValue<SByte8> operator=(RValue<SByte8> rhs); |
| 673 | RValue<SByte8> operator=(const SByte8 &rhs); |
| 674 | RValue<SByte8> operator=(const Reference<SByte8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 675 | |
| 676 | static Type *getType(); |
| 677 | }; |
| 678 | |
| 679 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 680 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 681 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 682 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 683 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 684 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 685 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 686 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 687 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 688 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, RValue<SByte8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 689 | RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs); |
| 690 | RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs); |
| 691 | // RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs); |
| 692 | // RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs); |
| 693 | // RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs); |
| 694 | RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs); |
| 695 | RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs); |
| 696 | RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs); |
| 697 | // RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs); |
| 698 | // RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 699 | // RValue<SByte8> operator+(RValue<SByte8> val); |
| 700 | // RValue<SByte8> operator-(RValue<SByte8> val); |
| 701 | RValue<SByte8> operator~(RValue<SByte8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 702 | // RValue<SByte8> operator++(SByte8 &val, int); // Post-increment |
| 703 | // const SByte8 &operator++(SByte8 &val); // Pre-increment |
| 704 | // RValue<SByte8> operator--(SByte8 &val, int); // Post-decrement |
| 705 | // const SByte8 &operator--(SByte8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 706 | |
| 707 | RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y); |
| 708 | RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y); |
| 709 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y); |
| 710 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y); |
| 711 | RValue<Int> SignMask(RValue<SByte8> x); |
| 712 | RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y); |
| 713 | RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y); |
| 714 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 715 | class Byte16 : public LValue<Byte16> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 716 | { |
| 717 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 718 | Byte16() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 719 | // Byte16(int x, int y, int z, int w); |
| 720 | Byte16(RValue<Byte16> rhs); |
| 721 | Byte16(const Byte16 &rhs); |
| 722 | Byte16(const Reference<Byte16> &rhs); |
| 723 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 724 | RValue<Byte16> operator=(RValue<Byte16> rhs); |
| 725 | RValue<Byte16> operator=(const Byte16 &rhs); |
| 726 | RValue<Byte16> operator=(const Reference<Byte16> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 727 | |
| 728 | static Type *getType(); |
| 729 | }; |
| 730 | |
| 731 | // RValue<Byte16> operator+(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 732 | // RValue<Byte16> operator-(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 733 | // RValue<Byte16> operator*(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 734 | // RValue<Byte16> operator/(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 735 | // RValue<Byte16> operator%(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 736 | // RValue<Byte16> operator&(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 737 | // RValue<Byte16> operator|(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 738 | // RValue<Byte16> operator^(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 739 | // RValue<Byte16> operator<<(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 740 | // RValue<Byte16> operator>>(RValue<Byte16> lhs, RValue<Byte16> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 741 | // RValue<Byte16> operator+=(Byte16 &lhs, RValue<Byte16> rhs); |
| 742 | // RValue<Byte16> operator-=(Byte16 &lhs, RValue<Byte16> rhs); |
| 743 | // RValue<Byte16> operator*=(Byte16 &lhs, RValue<Byte16> rhs); |
| 744 | // RValue<Byte16> operator/=(Byte16 &lhs, RValue<Byte16> rhs); |
| 745 | // RValue<Byte16> operator%=(Byte16 &lhs, RValue<Byte16> rhs); |
| 746 | // RValue<Byte16> operator&=(Byte16 &lhs, RValue<Byte16> rhs); |
| 747 | // RValue<Byte16> operator|=(Byte16 &lhs, RValue<Byte16> rhs); |
| 748 | // RValue<Byte16> operator^=(Byte16 &lhs, RValue<Byte16> rhs); |
| 749 | // RValue<Byte16> operator<<=(Byte16 &lhs, RValue<Byte16> rhs); |
| 750 | // RValue<Byte16> operator>>=(Byte16 &lhs, RValue<Byte16> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 751 | // RValue<Byte16> operator+(RValue<Byte16> val); |
| 752 | // RValue<Byte16> operator-(RValue<Byte16> val); |
| 753 | // RValue<Byte16> operator~(RValue<Byte16> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 754 | // RValue<Byte16> operator++(Byte16 &val, int); // Post-increment |
| 755 | // const Byte16 &operator++(Byte16 &val); // Pre-increment |
| 756 | // RValue<Byte16> operator--(Byte16 &val, int); // Post-decrement |
| 757 | // const Byte16 &operator--(Byte16 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 758 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 759 | class SByte16 : public LValue<SByte16> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 760 | { |
| 761 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 762 | SByte16() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 763 | // SByte16(int x, int y, int z, int w); |
| 764 | // SByte16(RValue<SByte16> rhs); |
| 765 | // SByte16(const SByte16 &rhs); |
| 766 | // SByte16(const Reference<SByte16> &rhs); |
| 767 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 768 | // RValue<SByte16> operator=(RValue<SByte16> rhs); |
| 769 | // RValue<SByte16> operator=(const SByte16 &rhs); |
| 770 | // RValue<SByte16> operator=(const Reference<SByte16> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 771 | |
| 772 | static Type *getType(); |
| 773 | }; |
| 774 | |
| 775 | // RValue<SByte16> operator+(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 776 | // RValue<SByte16> operator-(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 777 | // RValue<SByte16> operator*(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 778 | // RValue<SByte16> operator/(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 779 | // RValue<SByte16> operator%(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 780 | // RValue<SByte16> operator&(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 781 | // RValue<SByte16> operator|(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 782 | // RValue<SByte16> operator^(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 783 | // RValue<SByte16> operator<<(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 784 | // RValue<SByte16> operator>>(RValue<SByte16> lhs, RValue<SByte16> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 785 | // RValue<SByte16> operator+=(SByte16 &lhs, RValue<SByte16> rhs); |
| 786 | // RValue<SByte16> operator-=(SByte16 &lhs, RValue<SByte16> rhs); |
| 787 | // RValue<SByte16> operator*=(SByte16 &lhs, RValue<SByte16> rhs); |
| 788 | // RValue<SByte16> operator/=(SByte16 &lhs, RValue<SByte16> rhs); |
| 789 | // RValue<SByte16> operator%=(SByte16 &lhs, RValue<SByte16> rhs); |
| 790 | // RValue<SByte16> operator&=(SByte16 &lhs, RValue<SByte16> rhs); |
| 791 | // RValue<SByte16> operator|=(SByte16 &lhs, RValue<SByte16> rhs); |
| 792 | // RValue<SByte16> operator^=(SByte16 &lhs, RValue<SByte16> rhs); |
| 793 | // RValue<SByte16> operator<<=(SByte16 &lhs, RValue<SByte16> rhs); |
| 794 | // RValue<SByte16> operator>>=(SByte16 &lhs, RValue<SByte16> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 795 | // RValue<SByte16> operator+(RValue<SByte16> val); |
| 796 | // RValue<SByte16> operator-(RValue<SByte16> val); |
| 797 | // RValue<SByte16> operator~(RValue<SByte16> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 798 | // RValue<SByte16> operator++(SByte16 &val, int); // Post-increment |
| 799 | // const SByte16 &operator++(SByte16 &val); // Pre-increment |
| 800 | // RValue<SByte16> operator--(SByte16 &val, int); // Post-decrement |
| 801 | // const SByte16 &operator--(SByte16 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 802 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 803 | class Short2 : public LValue<Short2> |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 804 | { |
| 805 | public: |
| 806 | explicit Short2(RValue<Short4> cast); |
| 807 | |
| 808 | static Type *getType(); |
| 809 | }; |
| 810 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 811 | class UShort2 : public LValue<UShort2> |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 812 | { |
| 813 | public: |
| 814 | explicit UShort2(RValue<UShort4> cast); |
| 815 | |
| 816 | static Type *getType(); |
| 817 | }; |
| 818 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 819 | class Short4 : public LValue<Short4> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 820 | { |
| 821 | public: |
| 822 | explicit Short4(RValue<Int> cast); |
| 823 | explicit Short4(RValue<Int4> cast); |
| 824 | // explicit Short4(RValue<Float> cast); |
| 825 | explicit Short4(RValue<Float4> cast); |
| 826 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 827 | Short4() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 828 | Short4(short xyzw); |
| 829 | Short4(short x, short y, short z, short w); |
| 830 | Short4(RValue<Short4> rhs); |
| 831 | Short4(const Short4 &rhs); |
| 832 | Short4(const Reference<Short4> &rhs); |
| 833 | Short4(RValue<UShort4> rhs); |
| 834 | Short4(const UShort4 &rhs); |
| 835 | Short4(const Reference<UShort4> &rhs); |
| 836 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 837 | RValue<Short4> operator=(RValue<Short4> rhs); |
| 838 | RValue<Short4> operator=(const Short4 &rhs); |
| 839 | RValue<Short4> operator=(const Reference<Short4> &rhs); |
| 840 | RValue<Short4> operator=(RValue<UShort4> rhs); |
| 841 | RValue<Short4> operator=(const UShort4 &rhs); |
| 842 | RValue<Short4> operator=(const Reference<UShort4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 843 | |
| 844 | static Type *getType(); |
| 845 | }; |
| 846 | |
| 847 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs); |
| 848 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs); |
| 849 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs); |
| 850 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs); |
| 851 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs); |
| 852 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs); |
| 853 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs); |
| 854 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs); |
| 855 | RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs); |
| 856 | RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 857 | RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs); |
| 858 | RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs); |
| 859 | RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs); |
| 860 | // RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs); |
| 861 | // RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs); |
| 862 | RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs); |
| 863 | RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs); |
| 864 | RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs); |
| 865 | RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs); |
| 866 | RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 867 | // RValue<Short4> operator+(RValue<Short4> val); |
| 868 | RValue<Short4> operator-(RValue<Short4> val); |
| 869 | RValue<Short4> operator~(RValue<Short4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 870 | // RValue<Short4> operator++(Short4 &val, int); // Post-increment |
| 871 | // const Short4 &operator++(Short4 &val); // Pre-increment |
| 872 | // RValue<Short4> operator--(Short4 &val, int); // Post-decrement |
| 873 | // const Short4 &operator--(Short4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 874 | // RValue<Bool> operator<(RValue<Short4> lhs, RValue<Short4> rhs); |
| 875 | // RValue<Bool> operator<=(RValue<Short4> lhs, RValue<Short4> rhs); |
| 876 | // RValue<Bool> operator>(RValue<Short4> lhs, RValue<Short4> rhs); |
| 877 | // RValue<Bool> operator>=(RValue<Short4> lhs, RValue<Short4> rhs); |
| 878 | // RValue<Bool> operator!=(RValue<Short4> lhs, RValue<Short4> rhs); |
| 879 | // RValue<Bool> operator==(RValue<Short4> lhs, RValue<Short4> rhs); |
| 880 | |
| 881 | RValue<Short4> RoundShort4(RValue<Float4> cast); |
| 882 | RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y); |
| 883 | RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y); |
| 884 | RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y); |
| 885 | RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y); |
| 886 | RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y); |
| 887 | RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y); |
Nicolas Capens | 33438a6 | 2017-09-27 11:47:35 -0400 | [diff] [blame] | 888 | RValue<SByte8> PackSigned(RValue<Short4> x, RValue<Short4> y); |
| 889 | RValue<Byte8> PackUnsigned(RValue<Short4> x, RValue<Short4> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 890 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y); |
| 891 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y); |
| 892 | RValue<Short4> Swizzle(RValue<Short4> x, unsigned char select); |
| 893 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i); |
| 894 | RValue<Short> Extract(RValue<Short4> val, int i); |
| 895 | RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y); |
| 896 | RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y); |
| 897 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 898 | class UShort4 : public LValue<UShort4> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 899 | { |
| 900 | public: |
| 901 | explicit UShort4(RValue<Int4> cast); |
| 902 | explicit UShort4(RValue<Float4> cast, bool saturate = false); |
| 903 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 904 | UShort4() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 905 | UShort4(unsigned short xyzw); |
| 906 | UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w); |
| 907 | UShort4(RValue<UShort4> rhs); |
| 908 | UShort4(const UShort4 &rhs); |
| 909 | UShort4(const Reference<UShort4> &rhs); |
| 910 | UShort4(RValue<Short4> rhs); |
| 911 | UShort4(const Short4 &rhs); |
| 912 | UShort4(const Reference<Short4> &rhs); |
| 913 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 914 | RValue<UShort4> operator=(RValue<UShort4> rhs); |
| 915 | RValue<UShort4> operator=(const UShort4 &rhs); |
| 916 | RValue<UShort4> operator=(const Reference<UShort4> &rhs); |
| 917 | RValue<UShort4> operator=(RValue<Short4> rhs); |
| 918 | RValue<UShort4> operator=(const Short4 &rhs); |
| 919 | RValue<UShort4> operator=(const Reference<Short4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 920 | |
| 921 | static Type *getType(); |
| 922 | }; |
| 923 | |
| 924 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 925 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 926 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 927 | // RValue<UShort4> operator/(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 928 | // RValue<UShort4> operator%(RValue<UShort4> lhs, RValue<UShort4> rhs); |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 929 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 930 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 931 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 932 | RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs); |
| 933 | RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 934 | // RValue<UShort4> operator+=(UShort4 &lhs, RValue<UShort4> rhs); |
| 935 | // RValue<UShort4> operator-=(UShort4 &lhs, RValue<UShort4> rhs); |
| 936 | // RValue<UShort4> operator*=(UShort4 &lhs, RValue<UShort4> rhs); |
| 937 | // RValue<UShort4> operator/=(UShort4 &lhs, RValue<UShort4> rhs); |
| 938 | // RValue<UShort4> operator%=(UShort4 &lhs, RValue<UShort4> rhs); |
| 939 | // RValue<UShort4> operator&=(UShort4 &lhs, RValue<UShort4> rhs); |
| 940 | // RValue<UShort4> operator|=(UShort4 &lhs, RValue<UShort4> rhs); |
| 941 | // RValue<UShort4> operator^=(UShort4 &lhs, RValue<UShort4> rhs); |
| 942 | RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs); |
| 943 | RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 944 | // RValue<UShort4> operator+(RValue<UShort4> val); |
| 945 | // RValue<UShort4> operator-(RValue<UShort4> val); |
| 946 | RValue<UShort4> operator~(RValue<UShort4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 947 | // RValue<UShort4> operator++(UShort4 &val, int); // Post-increment |
| 948 | // const UShort4 &operator++(UShort4 &val); // Pre-increment |
| 949 | // RValue<UShort4> operator--(UShort4 &val, int); // Post-decrement |
| 950 | // const UShort4 &operator--(UShort4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 951 | |
| 952 | RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y); |
| 953 | RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y); |
| 954 | RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y); |
| 955 | RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y); |
| 956 | RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y); |
| 957 | RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 958 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 959 | class Short8 : public LValue<Short8> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 960 | { |
| 961 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 962 | Short8() = default; |
Nicolas Capens | 3e7062b | 2017-01-17 14:01:33 -0500 | [diff] [blame] | 963 | Short8(short c); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 964 | Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7); |
| 965 | Short8(RValue<Short8> rhs); |
| 966 | // Short8(const Short8 &rhs); |
| 967 | Short8(const Reference<Short8> &rhs); |
| 968 | Short8(RValue<Short4> lo, RValue<Short4> hi); |
| 969 | |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 970 | RValue<Short8> operator=(RValue<Short8> rhs); |
| 971 | RValue<Short8> operator=(const Short8 &rhs); |
| 972 | RValue<Short8> operator=(const Reference<Short8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 973 | |
| 974 | static Type *getType(); |
| 975 | }; |
| 976 | |
| 977 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs); |
| 978 | // RValue<Short8> operator-(RValue<Short8> lhs, RValue<Short8> rhs); |
| 979 | // RValue<Short8> operator*(RValue<Short8> lhs, RValue<Short8> rhs); |
| 980 | // RValue<Short8> operator/(RValue<Short8> lhs, RValue<Short8> rhs); |
| 981 | // RValue<Short8> operator%(RValue<Short8> lhs, RValue<Short8> rhs); |
| 982 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs); |
| 983 | // RValue<Short8> operator|(RValue<Short8> lhs, RValue<Short8> rhs); |
| 984 | // RValue<Short8> operator^(RValue<Short8> lhs, RValue<Short8> rhs); |
| 985 | RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs); |
| 986 | RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs); |
| 987 | // RValue<Short8> operator<<(RValue<Short8> lhs, RValue<Short8> rhs); |
| 988 | // RValue<Short8> operator>>(RValue<Short8> lhs, RValue<Short8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 989 | // RValue<Short8> operator+=(Short8 &lhs, RValue<Short8> rhs); |
| 990 | // RValue<Short8> operator-=(Short8 &lhs, RValue<Short8> rhs); |
| 991 | // RValue<Short8> operator*=(Short8 &lhs, RValue<Short8> rhs); |
| 992 | // RValue<Short8> operator/=(Short8 &lhs, RValue<Short8> rhs); |
| 993 | // RValue<Short8> operator%=(Short8 &lhs, RValue<Short8> rhs); |
| 994 | // RValue<Short8> operator&=(Short8 &lhs, RValue<Short8> rhs); |
| 995 | // RValue<Short8> operator|=(Short8 &lhs, RValue<Short8> rhs); |
| 996 | // RValue<Short8> operator^=(Short8 &lhs, RValue<Short8> rhs); |
| 997 | // RValue<Short8> operator<<=(Short8 &lhs, RValue<Short8> rhs); |
| 998 | // RValue<Short8> operator>>=(Short8 &lhs, RValue<Short8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 999 | // RValue<Short8> operator+(RValue<Short8> val); |
| 1000 | // RValue<Short8> operator-(RValue<Short8> val); |
| 1001 | // RValue<Short8> operator~(RValue<Short8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1002 | // RValue<Short8> operator++(Short8 &val, int); // Post-increment |
| 1003 | // const Short8 &operator++(Short8 &val); // Pre-increment |
| 1004 | // RValue<Short8> operator--(Short8 &val, int); // Post-decrement |
| 1005 | // const Short8 &operator--(Short8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1006 | // RValue<Bool> operator<(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1007 | // RValue<Bool> operator<=(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1008 | // RValue<Bool> operator>(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1009 | // RValue<Bool> operator>=(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1010 | // RValue<Bool> operator!=(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1011 | // RValue<Bool> operator==(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1012 | |
| 1013 | RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y); |
| 1014 | RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y); |
| 1015 | RValue<Int4> Abs(RValue<Int4> x); |
| 1016 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 1017 | class UShort8 : public LValue<UShort8> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1018 | { |
| 1019 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 1020 | UShort8() = default; |
Nicolas Capens | 3e7062b | 2017-01-17 14:01:33 -0500 | [diff] [blame] | 1021 | UShort8(unsigned short c); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1022 | UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7); |
| 1023 | UShort8(RValue<UShort8> rhs); |
| 1024 | // UShort8(const UShort8 &rhs); |
| 1025 | UShort8(const Reference<UShort8> &rhs); |
| 1026 | UShort8(RValue<UShort4> lo, RValue<UShort4> hi); |
| 1027 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1028 | RValue<UShort8> operator=(RValue<UShort8> rhs); |
| 1029 | RValue<UShort8> operator=(const UShort8 &rhs); |
| 1030 | RValue<UShort8> operator=(const Reference<UShort8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1031 | |
| 1032 | static Type *getType(); |
| 1033 | }; |
| 1034 | |
| 1035 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1036 | // RValue<UShort8> operator-(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1037 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1038 | // RValue<UShort8> operator/(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1039 | // RValue<UShort8> operator%(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1040 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1041 | // RValue<UShort8> operator|(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1042 | // RValue<UShort8> operator^(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1043 | RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs); |
| 1044 | RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs); |
| 1045 | // RValue<UShort8> operator<<(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1046 | // RValue<UShort8> operator>>(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1047 | RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1048 | // RValue<UShort8> operator-=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1049 | // RValue<UShort8> operator*=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1050 | // RValue<UShort8> operator/=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1051 | // RValue<UShort8> operator%=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1052 | // RValue<UShort8> operator&=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1053 | // RValue<UShort8> operator|=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1054 | // RValue<UShort8> operator^=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1055 | // RValue<UShort8> operator<<=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1056 | // RValue<UShort8> operator>>=(UShort8 &lhs, RValue<UShort8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1057 | // RValue<UShort8> operator+(RValue<UShort8> val); |
| 1058 | // RValue<UShort8> operator-(RValue<UShort8> val); |
| 1059 | RValue<UShort8> operator~(RValue<UShort8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1060 | // RValue<UShort8> operator++(UShort8 &val, int); // Post-increment |
| 1061 | // const UShort8 &operator++(UShort8 &val); // Pre-increment |
| 1062 | // RValue<UShort8> operator--(UShort8 &val, int); // Post-decrement |
| 1063 | // const UShort8 &operator--(UShort8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1064 | // RValue<Bool> operator<(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1065 | // RValue<Bool> operator<=(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1066 | // RValue<Bool> operator>(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1067 | // RValue<Bool> operator>=(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1068 | // RValue<Bool> operator!=(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1069 | // RValue<Bool> operator==(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1070 | |
| 1071 | RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7); |
| 1072 | RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y); |
| 1073 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 1074 | class Int : public LValue<Int> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1075 | { |
| 1076 | public: |
| 1077 | Int(Argument<Int> argument); |
| 1078 | |
| 1079 | explicit Int(RValue<Byte> cast); |
| 1080 | explicit Int(RValue<SByte> cast); |
| 1081 | explicit Int(RValue<Short> cast); |
| 1082 | explicit Int(RValue<UShort> cast); |
| 1083 | explicit Int(RValue<Int2> cast); |
| 1084 | explicit Int(RValue<Long> cast); |
| 1085 | explicit Int(RValue<Float> cast); |
| 1086 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 1087 | Int() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1088 | Int(int x); |
| 1089 | Int(RValue<Int> rhs); |
| 1090 | Int(RValue<UInt> rhs); |
| 1091 | Int(const Int &rhs); |
| 1092 | Int(const UInt &rhs); |
| 1093 | Int(const Reference<Int> &rhs); |
| 1094 | Int(const Reference<UInt> &rhs); |
| 1095 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1096 | RValue<Int> operator=(int rhs); |
| 1097 | RValue<Int> operator=(RValue<Int> rhs); |
| 1098 | RValue<Int> operator=(RValue<UInt> rhs); |
| 1099 | RValue<Int> operator=(const Int &rhs); |
| 1100 | RValue<Int> operator=(const UInt &rhs); |
| 1101 | RValue<Int> operator=(const Reference<Int> &rhs); |
| 1102 | RValue<Int> operator=(const Reference<UInt> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1103 | |
| 1104 | static Type *getType(); |
| 1105 | }; |
| 1106 | |
| 1107 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs); |
| 1108 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs); |
| 1109 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs); |
| 1110 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs); |
| 1111 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs); |
| 1112 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs); |
| 1113 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs); |
| 1114 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs); |
| 1115 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs); |
| 1116 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1117 | RValue<Int> operator+=(Int &lhs, RValue<Int> rhs); |
| 1118 | RValue<Int> operator-=(Int &lhs, RValue<Int> rhs); |
| 1119 | RValue<Int> operator*=(Int &lhs, RValue<Int> rhs); |
| 1120 | RValue<Int> operator/=(Int &lhs, RValue<Int> rhs); |
| 1121 | RValue<Int> operator%=(Int &lhs, RValue<Int> rhs); |
| 1122 | RValue<Int> operator&=(Int &lhs, RValue<Int> rhs); |
| 1123 | RValue<Int> operator|=(Int &lhs, RValue<Int> rhs); |
| 1124 | RValue<Int> operator^=(Int &lhs, RValue<Int> rhs); |
| 1125 | RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs); |
| 1126 | RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1127 | RValue<Int> operator+(RValue<Int> val); |
| 1128 | RValue<Int> operator-(RValue<Int> val); |
| 1129 | RValue<Int> operator~(RValue<Int> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1130 | RValue<Int> operator++(Int &val, int); // Post-increment |
| 1131 | const Int &operator++(Int &val); // Pre-increment |
| 1132 | RValue<Int> operator--(Int &val, int); // Post-decrement |
| 1133 | const Int &operator--(Int &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1134 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs); |
| 1135 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs); |
| 1136 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs); |
| 1137 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs); |
| 1138 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs); |
| 1139 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs); |
| 1140 | |
| 1141 | RValue<Int> Max(RValue<Int> x, RValue<Int> y); |
| 1142 | RValue<Int> Min(RValue<Int> x, RValue<Int> y); |
| 1143 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max); |
| 1144 | RValue<Int> RoundInt(RValue<Float> cast); |
| 1145 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 1146 | class Long : public LValue<Long> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1147 | { |
| 1148 | public: |
| 1149 | // Long(Argument<Long> argument); |
| 1150 | |
| 1151 | // explicit Long(RValue<Short> cast); |
| 1152 | // explicit Long(RValue<UShort> cast); |
| 1153 | explicit Long(RValue<Int> cast); |
| 1154 | explicit Long(RValue<UInt> cast); |
| 1155 | // explicit Long(RValue<Float> cast); |
| 1156 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 1157 | Long() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1158 | // Long(qword x); |
| 1159 | Long(RValue<Long> rhs); |
| 1160 | // Long(RValue<ULong> rhs); |
| 1161 | // Long(const Long &rhs); |
| 1162 | // Long(const Reference<Long> &rhs); |
| 1163 | // Long(const ULong &rhs); |
| 1164 | // Long(const Reference<ULong> &rhs); |
| 1165 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1166 | RValue<Long> operator=(int64_t rhs); |
| 1167 | RValue<Long> operator=(RValue<Long> rhs); |
| 1168 | // RValue<Long> operator=(RValue<ULong> rhs); |
| 1169 | RValue<Long> operator=(const Long &rhs); |
| 1170 | RValue<Long> operator=(const Reference<Long> &rhs); |
| 1171 | // RValue<Long> operator=(const ULong &rhs); |
| 1172 | // RValue<Long> operator=(const Reference<ULong> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1173 | |
| 1174 | static Type *getType(); |
| 1175 | }; |
| 1176 | |
| 1177 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs); |
| 1178 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs); |
Chris Forbes | aa8f699 | 2019-03-01 14:18:30 -0800 | [diff] [blame] | 1179 | RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1180 | // RValue<Long> operator/(RValue<Long> lhs, RValue<Long> rhs); |
| 1181 | // RValue<Long> operator%(RValue<Long> lhs, RValue<Long> rhs); |
| 1182 | // RValue<Long> operator&(RValue<Long> lhs, RValue<Long> rhs); |
| 1183 | // RValue<Long> operator|(RValue<Long> lhs, RValue<Long> rhs); |
| 1184 | // RValue<Long> operator^(RValue<Long> lhs, RValue<Long> rhs); |
| 1185 | // RValue<Long> operator<<(RValue<Long> lhs, RValue<Long> rhs); |
Chris Forbes | aa8f699 | 2019-03-01 14:18:30 -0800 | [diff] [blame] | 1186 | RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1187 | RValue<Long> operator+=(Long &lhs, RValue<Long> rhs); |
| 1188 | RValue<Long> operator-=(Long &lhs, RValue<Long> rhs); |
| 1189 | // RValue<Long> operator*=(Long &lhs, RValue<Long> rhs); |
| 1190 | // RValue<Long> operator/=(Long &lhs, RValue<Long> rhs); |
| 1191 | // RValue<Long> operator%=(Long &lhs, RValue<Long> rhs); |
| 1192 | // RValue<Long> operator&=(Long &lhs, RValue<Long> rhs); |
| 1193 | // RValue<Long> operator|=(Long &lhs, RValue<Long> rhs); |
| 1194 | // RValue<Long> operator^=(Long &lhs, RValue<Long> rhs); |
| 1195 | // RValue<Long> operator<<=(Long &lhs, RValue<Long> rhs); |
| 1196 | // RValue<Long> operator>>=(Long &lhs, RValue<Long> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1197 | // RValue<Long> operator+(RValue<Long> val); |
| 1198 | // RValue<Long> operator-(RValue<Long> val); |
| 1199 | // RValue<Long> operator~(RValue<Long> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1200 | // RValue<Long> operator++(Long &val, int); // Post-increment |
| 1201 | // const Long &operator++(Long &val); // Pre-increment |
| 1202 | // RValue<Long> operator--(Long &val, int); // Post-decrement |
| 1203 | // const Long &operator--(Long &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1204 | // RValue<Bool> operator<(RValue<Long> lhs, RValue<Long> rhs); |
| 1205 | // RValue<Bool> operator<=(RValue<Long> lhs, RValue<Long> rhs); |
| 1206 | // RValue<Bool> operator>(RValue<Long> lhs, RValue<Long> rhs); |
| 1207 | // RValue<Bool> operator>=(RValue<Long> lhs, RValue<Long> rhs); |
| 1208 | // RValue<Bool> operator!=(RValue<Long> lhs, RValue<Long> rhs); |
| 1209 | // RValue<Bool> operator==(RValue<Long> lhs, RValue<Long> rhs); |
| 1210 | |
| 1211 | // RValue<Long> RoundLong(RValue<Float> cast); |
| 1212 | RValue<Long> AddAtomic( RValue<Pointer<Long>> x, RValue<Long> y); |
| 1213 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 1214 | class UInt : public LValue<UInt> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1215 | { |
| 1216 | public: |
| 1217 | UInt(Argument<UInt> argument); |
| 1218 | |
| 1219 | explicit UInt(RValue<UShort> cast); |
| 1220 | explicit UInt(RValue<Long> cast); |
| 1221 | explicit UInt(RValue<Float> cast); |
| 1222 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 1223 | UInt() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1224 | UInt(int x); |
| 1225 | UInt(unsigned int x); |
| 1226 | UInt(RValue<UInt> rhs); |
| 1227 | UInt(RValue<Int> rhs); |
| 1228 | UInt(const UInt &rhs); |
| 1229 | UInt(const Int &rhs); |
| 1230 | UInt(const Reference<UInt> &rhs); |
| 1231 | UInt(const Reference<Int> &rhs); |
| 1232 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1233 | RValue<UInt> operator=(unsigned int rhs); |
| 1234 | RValue<UInt> operator=(RValue<UInt> rhs); |
| 1235 | RValue<UInt> operator=(RValue<Int> rhs); |
| 1236 | RValue<UInt> operator=(const UInt &rhs); |
| 1237 | RValue<UInt> operator=(const Int &rhs); |
| 1238 | RValue<UInt> operator=(const Reference<UInt> &rhs); |
| 1239 | RValue<UInt> operator=(const Reference<Int> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1240 | |
| 1241 | static Type *getType(); |
| 1242 | }; |
| 1243 | |
| 1244 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1245 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1246 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1247 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1248 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1249 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1250 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1251 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1252 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1253 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1254 | RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs); |
| 1255 | RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs); |
| 1256 | RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs); |
| 1257 | RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs); |
| 1258 | RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs); |
| 1259 | RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs); |
| 1260 | RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs); |
| 1261 | RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs); |
| 1262 | RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs); |
| 1263 | RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1264 | RValue<UInt> operator+(RValue<UInt> val); |
| 1265 | RValue<UInt> operator-(RValue<UInt> val); |
| 1266 | RValue<UInt> operator~(RValue<UInt> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1267 | RValue<UInt> operator++(UInt &val, int); // Post-increment |
| 1268 | const UInt &operator++(UInt &val); // Pre-increment |
| 1269 | RValue<UInt> operator--(UInt &val, int); // Post-decrement |
| 1270 | const UInt &operator--(UInt &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1271 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1272 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1273 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1274 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1275 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1276 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1277 | |
| 1278 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y); |
| 1279 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y); |
| 1280 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max); |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 1281 | |
| 1282 | RValue<UInt> AddAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
Chris Forbes | 707ed99 | 2019-04-18 18:17:35 -0700 | [diff] [blame] | 1283 | RValue<UInt> SubAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 1284 | RValue<UInt> AndAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1285 | RValue<UInt> OrAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1286 | RValue<UInt> XorAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1287 | RValue<Int> MinAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder); |
| 1288 | RValue<Int> MaxAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder); |
| 1289 | RValue<UInt> MinAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1290 | RValue<UInt> MaxAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1291 | RValue<UInt> ExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
Chris Forbes | a16238d | 2019-04-18 16:31:54 -0700 | [diff] [blame] | 1292 | RValue<UInt> CompareExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, RValue<UInt> compare, std::memory_order memoryOrderEqual, std::memory_order memoryOrderUnequal); |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 1293 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1294 | // RValue<UInt> RoundUInt(RValue<Float> cast); |
| 1295 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 1296 | class Int2 : public LValue<Int2> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1297 | { |
| 1298 | public: |
| 1299 | // explicit Int2(RValue<Int> cast); |
| 1300 | explicit Int2(RValue<Int4> cast); |
| 1301 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 1302 | Int2() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1303 | Int2(int x, int y); |
| 1304 | Int2(RValue<Int2> rhs); |
| 1305 | Int2(const Int2 &rhs); |
| 1306 | Int2(const Reference<Int2> &rhs); |
| 1307 | Int2(RValue<Int> lo, RValue<Int> hi); |
| 1308 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1309 | RValue<Int2> operator=(RValue<Int2> rhs); |
| 1310 | RValue<Int2> operator=(const Int2 &rhs); |
| 1311 | RValue<Int2> operator=(const Reference<Int2> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1312 | |
| 1313 | static Type *getType(); |
| 1314 | }; |
| 1315 | |
| 1316 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1317 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1318 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1319 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1320 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1321 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1322 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1323 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1324 | RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs); |
| 1325 | RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1326 | RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs); |
| 1327 | RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs); |
| 1328 | // RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs); |
| 1329 | // RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs); |
| 1330 | // RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs); |
| 1331 | RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs); |
| 1332 | RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs); |
| 1333 | RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs); |
| 1334 | RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs); |
| 1335 | RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1336 | // RValue<Int2> operator+(RValue<Int2> val); |
| 1337 | // RValue<Int2> operator-(RValue<Int2> val); |
| 1338 | RValue<Int2> operator~(RValue<Int2> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1339 | // RValue<Int2> operator++(Int2 &val, int); // Post-increment |
| 1340 | // const Int2 &operator++(Int2 &val); // Pre-increment |
| 1341 | // RValue<Int2> operator--(Int2 &val, int); // Post-decrement |
| 1342 | // const Int2 &operator--(Int2 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1343 | // RValue<Bool> operator<(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1344 | // RValue<Bool> operator<=(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1345 | // RValue<Bool> operator>(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1346 | // RValue<Bool> operator>=(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1347 | // RValue<Bool> operator!=(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1348 | // RValue<Bool> operator==(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1349 | |
| 1350 | // RValue<Int2> RoundInt(RValue<Float4> cast); |
Nicolas Capens | 45f187a | 2016-12-02 15:30:56 -0500 | [diff] [blame] | 1351 | RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y); |
| 1352 | RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1353 | RValue<Int> Extract(RValue<Int2> val, int i); |
| 1354 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i); |
| 1355 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 1356 | class UInt2 : public LValue<UInt2> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1357 | { |
| 1358 | public: |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 1359 | UInt2() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1360 | UInt2(unsigned int x, unsigned int y); |
| 1361 | UInt2(RValue<UInt2> rhs); |
| 1362 | UInt2(const UInt2 &rhs); |
| 1363 | UInt2(const Reference<UInt2> &rhs); |
| 1364 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1365 | RValue<UInt2> operator=(RValue<UInt2> rhs); |
| 1366 | RValue<UInt2> operator=(const UInt2 &rhs); |
| 1367 | RValue<UInt2> operator=(const Reference<UInt2> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1368 | |
| 1369 | static Type *getType(); |
| 1370 | }; |
| 1371 | |
| 1372 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1373 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1374 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1375 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1376 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1377 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1378 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1379 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1380 | RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs); |
| 1381 | RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1382 | RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1383 | RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1384 | // RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1385 | // RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1386 | // RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1387 | RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1388 | RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1389 | RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1390 | RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs); |
| 1391 | RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1392 | // RValue<UInt2> operator+(RValue<UInt2> val); |
| 1393 | // RValue<UInt2> operator-(RValue<UInt2> val); |
| 1394 | RValue<UInt2> operator~(RValue<UInt2> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1395 | // RValue<UInt2> operator++(UInt2 &val, int); // Post-increment |
| 1396 | // const UInt2 &operator++(UInt2 &val); // Pre-increment |
| 1397 | // RValue<UInt2> operator--(UInt2 &val, int); // Post-decrement |
| 1398 | // const UInt2 &operator--(UInt2 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1399 | // RValue<Bool> operator<(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1400 | // RValue<Bool> operator<=(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1401 | // RValue<Bool> operator>(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1402 | // RValue<Bool> operator>=(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1403 | // RValue<Bool> operator!=(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1404 | // RValue<Bool> operator==(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1405 | |
| 1406 | // RValue<UInt2> RoundInt(RValue<Float4> cast); |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 1407 | RValue<UInt> Extract(RValue<UInt2> val, int i); |
| 1408 | RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1409 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1410 | template<class T> |
| 1411 | struct Scalar; |
| 1412 | |
| 1413 | template<class Vector4> |
| 1414 | struct XYZW; |
| 1415 | |
| 1416 | template<class Vector4, int T> |
| 1417 | class Swizzle2 |
| 1418 | { |
| 1419 | friend Vector4; |
| 1420 | |
| 1421 | public: |
| 1422 | operator RValue<Vector4>() const; |
| 1423 | |
| 1424 | private: |
| 1425 | Vector4 *parent; |
| 1426 | }; |
| 1427 | |
| 1428 | template<class Vector4, int T> |
| 1429 | class Swizzle4 |
| 1430 | { |
| 1431 | public: |
| 1432 | operator RValue<Vector4>() const; |
| 1433 | |
| 1434 | private: |
| 1435 | Vector4 *parent; |
| 1436 | }; |
| 1437 | |
| 1438 | template<class Vector4, int T> |
| 1439 | class SwizzleMask4 |
| 1440 | { |
| 1441 | friend XYZW<Vector4>; |
| 1442 | |
| 1443 | public: |
| 1444 | operator RValue<Vector4>() const; |
| 1445 | |
| 1446 | RValue<Vector4> operator=(RValue<Vector4> rhs); |
| 1447 | RValue<Vector4> operator=(RValue<typename Scalar<Vector4>::Type> rhs); |
| 1448 | |
| 1449 | private: |
| 1450 | Vector4 *parent; |
| 1451 | }; |
| 1452 | |
| 1453 | template<> |
| 1454 | struct Scalar<Float4> |
| 1455 | { |
| 1456 | using Type = Float; |
| 1457 | }; |
| 1458 | |
| 1459 | template<> |
| 1460 | struct Scalar<Int4> |
| 1461 | { |
| 1462 | using Type = Int; |
| 1463 | }; |
| 1464 | |
| 1465 | template<> |
| 1466 | struct Scalar<UInt4> |
| 1467 | { |
| 1468 | using Type = UInt; |
| 1469 | }; |
| 1470 | |
| 1471 | template<class Vector4, int T> |
| 1472 | class SwizzleMask1 |
| 1473 | { |
| 1474 | public: |
| 1475 | operator RValue<typename Scalar<Vector4>::Type>() const; |
| 1476 | operator RValue<Vector4>() const; |
| 1477 | |
| 1478 | RValue<Vector4> operator=(float x); |
| 1479 | RValue<Vector4> operator=(RValue<Vector4> rhs); |
| 1480 | RValue<Vector4> operator=(RValue<typename Scalar<Vector4>::Type> rhs); |
| 1481 | |
| 1482 | private: |
Nicolas Capens | bb575d4 | 2019-05-31 15:36:59 -0400 | [diff] [blame] | 1483 | Vector4 *parent; |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1484 | }; |
| 1485 | |
| 1486 | template<class Vector4, int T> |
| 1487 | class SwizzleMask2 |
| 1488 | { |
| 1489 | friend class Float4; |
| 1490 | |
| 1491 | public: |
| 1492 | operator RValue<Vector4>() const; |
| 1493 | |
| 1494 | RValue<Vector4> operator=(RValue<Vector4> rhs); |
| 1495 | |
| 1496 | private: |
| 1497 | Float4 *parent; |
| 1498 | }; |
| 1499 | |
| 1500 | template<class Vector4> |
| 1501 | struct XYZW |
| 1502 | { |
| 1503 | friend Vector4; |
| 1504 | |
| 1505 | private: |
| 1506 | XYZW(Vector4 *parent) |
| 1507 | { |
| 1508 | xyzw.parent = parent; |
| 1509 | } |
| 1510 | |
| 1511 | public: |
| 1512 | union |
| 1513 | { |
| 1514 | SwizzleMask1<Vector4, 0x00> x; |
| 1515 | SwizzleMask1<Vector4, 0x55> y; |
| 1516 | SwizzleMask1<Vector4, 0xAA> z; |
| 1517 | SwizzleMask1<Vector4, 0xFF> w; |
| 1518 | Swizzle2<Vector4, 0x00> xx; |
| 1519 | Swizzle2<Vector4, 0x01> yx; |
| 1520 | Swizzle2<Vector4, 0x02> zx; |
| 1521 | Swizzle2<Vector4, 0x03> wx; |
| 1522 | SwizzleMask2<Vector4, 0x54> xy; |
| 1523 | Swizzle2<Vector4, 0x55> yy; |
| 1524 | Swizzle2<Vector4, 0x56> zy; |
| 1525 | Swizzle2<Vector4, 0x57> wy; |
| 1526 | SwizzleMask2<Vector4, 0xA8> xz; |
| 1527 | SwizzleMask2<Vector4, 0xA9> yz; |
| 1528 | Swizzle2<Vector4, 0xAA> zz; |
| 1529 | Swizzle2<Vector4, 0xAB> wz; |
| 1530 | SwizzleMask2<Vector4, 0xFC> xw; |
| 1531 | SwizzleMask2<Vector4, 0xFD> yw; |
| 1532 | SwizzleMask2<Vector4, 0xFE> zw; |
| 1533 | Swizzle2<Vector4, 0xFF> ww; |
| 1534 | Swizzle4<Vector4, 0x00> xxx; |
| 1535 | Swizzle4<Vector4, 0x01> yxx; |
| 1536 | Swizzle4<Vector4, 0x02> zxx; |
| 1537 | Swizzle4<Vector4, 0x03> wxx; |
| 1538 | Swizzle4<Vector4, 0x04> xyx; |
| 1539 | Swizzle4<Vector4, 0x05> yyx; |
| 1540 | Swizzle4<Vector4, 0x06> zyx; |
| 1541 | Swizzle4<Vector4, 0x07> wyx; |
| 1542 | Swizzle4<Vector4, 0x08> xzx; |
| 1543 | Swizzle4<Vector4, 0x09> yzx; |
| 1544 | Swizzle4<Vector4, 0x0A> zzx; |
| 1545 | Swizzle4<Vector4, 0x0B> wzx; |
| 1546 | Swizzle4<Vector4, 0x0C> xwx; |
| 1547 | Swizzle4<Vector4, 0x0D> ywx; |
| 1548 | Swizzle4<Vector4, 0x0E> zwx; |
| 1549 | Swizzle4<Vector4, 0x0F> wwx; |
| 1550 | Swizzle4<Vector4, 0x50> xxy; |
| 1551 | Swizzle4<Vector4, 0x51> yxy; |
| 1552 | Swizzle4<Vector4, 0x52> zxy; |
| 1553 | Swizzle4<Vector4, 0x53> wxy; |
| 1554 | Swizzle4<Vector4, 0x54> xyy; |
| 1555 | Swizzle4<Vector4, 0x55> yyy; |
| 1556 | Swizzle4<Vector4, 0x56> zyy; |
| 1557 | Swizzle4<Vector4, 0x57> wyy; |
| 1558 | Swizzle4<Vector4, 0x58> xzy; |
| 1559 | Swizzle4<Vector4, 0x59> yzy; |
| 1560 | Swizzle4<Vector4, 0x5A> zzy; |
| 1561 | Swizzle4<Vector4, 0x5B> wzy; |
| 1562 | Swizzle4<Vector4, 0x5C> xwy; |
| 1563 | Swizzle4<Vector4, 0x5D> ywy; |
| 1564 | Swizzle4<Vector4, 0x5E> zwy; |
| 1565 | Swizzle4<Vector4, 0x5F> wwy; |
| 1566 | Swizzle4<Vector4, 0xA0> xxz; |
| 1567 | Swizzle4<Vector4, 0xA1> yxz; |
| 1568 | Swizzle4<Vector4, 0xA2> zxz; |
| 1569 | Swizzle4<Vector4, 0xA3> wxz; |
| 1570 | SwizzleMask4<Vector4, 0xA4> xyz; |
| 1571 | Swizzle4<Vector4, 0xA5> yyz; |
| 1572 | Swizzle4<Vector4, 0xA6> zyz; |
| 1573 | Swizzle4<Vector4, 0xA7> wyz; |
| 1574 | Swizzle4<Vector4, 0xA8> xzz; |
| 1575 | Swizzle4<Vector4, 0xA9> yzz; |
| 1576 | Swizzle4<Vector4, 0xAA> zzz; |
| 1577 | Swizzle4<Vector4, 0xAB> wzz; |
| 1578 | Swizzle4<Vector4, 0xAC> xwz; |
| 1579 | Swizzle4<Vector4, 0xAD> ywz; |
| 1580 | Swizzle4<Vector4, 0xAE> zwz; |
| 1581 | Swizzle4<Vector4, 0xAF> wwz; |
| 1582 | Swizzle4<Vector4, 0xF0> xxw; |
| 1583 | Swizzle4<Vector4, 0xF1> yxw; |
| 1584 | Swizzle4<Vector4, 0xF2> zxw; |
| 1585 | Swizzle4<Vector4, 0xF3> wxw; |
| 1586 | SwizzleMask4<Vector4, 0xF4> xyw; |
| 1587 | Swizzle4<Vector4, 0xF5> yyw; |
| 1588 | Swizzle4<Vector4, 0xF6> zyw; |
| 1589 | Swizzle4<Vector4, 0xF7> wyw; |
| 1590 | SwizzleMask4<Vector4, 0xF8> xzw; |
| 1591 | SwizzleMask4<Vector4, 0xF9> yzw; |
| 1592 | Swizzle4<Vector4, 0xFA> zzw; |
| 1593 | Swizzle4<Vector4, 0xFB> wzw; |
| 1594 | Swizzle4<Vector4, 0xFC> xww; |
| 1595 | Swizzle4<Vector4, 0xFD> yww; |
| 1596 | Swizzle4<Vector4, 0xFE> zww; |
| 1597 | Swizzle4<Vector4, 0xFF> www; |
| 1598 | Swizzle4<Vector4, 0x00> xxxx; |
| 1599 | Swizzle4<Vector4, 0x01> yxxx; |
| 1600 | Swizzle4<Vector4, 0x02> zxxx; |
| 1601 | Swizzle4<Vector4, 0x03> wxxx; |
| 1602 | Swizzle4<Vector4, 0x04> xyxx; |
| 1603 | Swizzle4<Vector4, 0x05> yyxx; |
| 1604 | Swizzle4<Vector4, 0x06> zyxx; |
| 1605 | Swizzle4<Vector4, 0x07> wyxx; |
| 1606 | Swizzle4<Vector4, 0x08> xzxx; |
| 1607 | Swizzle4<Vector4, 0x09> yzxx; |
| 1608 | Swizzle4<Vector4, 0x0A> zzxx; |
| 1609 | Swizzle4<Vector4, 0x0B> wzxx; |
| 1610 | Swizzle4<Vector4, 0x0C> xwxx; |
| 1611 | Swizzle4<Vector4, 0x0D> ywxx; |
| 1612 | Swizzle4<Vector4, 0x0E> zwxx; |
| 1613 | Swizzle4<Vector4, 0x0F> wwxx; |
| 1614 | Swizzle4<Vector4, 0x10> xxyx; |
| 1615 | Swizzle4<Vector4, 0x11> yxyx; |
| 1616 | Swizzle4<Vector4, 0x12> zxyx; |
| 1617 | Swizzle4<Vector4, 0x13> wxyx; |
| 1618 | Swizzle4<Vector4, 0x14> xyyx; |
| 1619 | Swizzle4<Vector4, 0x15> yyyx; |
| 1620 | Swizzle4<Vector4, 0x16> zyyx; |
| 1621 | Swizzle4<Vector4, 0x17> wyyx; |
| 1622 | Swizzle4<Vector4, 0x18> xzyx; |
| 1623 | Swizzle4<Vector4, 0x19> yzyx; |
| 1624 | Swizzle4<Vector4, 0x1A> zzyx; |
| 1625 | Swizzle4<Vector4, 0x1B> wzyx; |
| 1626 | Swizzle4<Vector4, 0x1C> xwyx; |
| 1627 | Swizzle4<Vector4, 0x1D> ywyx; |
| 1628 | Swizzle4<Vector4, 0x1E> zwyx; |
| 1629 | Swizzle4<Vector4, 0x1F> wwyx; |
| 1630 | Swizzle4<Vector4, 0x20> xxzx; |
| 1631 | Swizzle4<Vector4, 0x21> yxzx; |
| 1632 | Swizzle4<Vector4, 0x22> zxzx; |
| 1633 | Swizzle4<Vector4, 0x23> wxzx; |
| 1634 | Swizzle4<Vector4, 0x24> xyzx; |
| 1635 | Swizzle4<Vector4, 0x25> yyzx; |
| 1636 | Swizzle4<Vector4, 0x26> zyzx; |
| 1637 | Swizzle4<Vector4, 0x27> wyzx; |
| 1638 | Swizzle4<Vector4, 0x28> xzzx; |
| 1639 | Swizzle4<Vector4, 0x29> yzzx; |
| 1640 | Swizzle4<Vector4, 0x2A> zzzx; |
| 1641 | Swizzle4<Vector4, 0x2B> wzzx; |
| 1642 | Swizzle4<Vector4, 0x2C> xwzx; |
| 1643 | Swizzle4<Vector4, 0x2D> ywzx; |
| 1644 | Swizzle4<Vector4, 0x2E> zwzx; |
| 1645 | Swizzle4<Vector4, 0x2F> wwzx; |
| 1646 | Swizzle4<Vector4, 0x30> xxwx; |
| 1647 | Swizzle4<Vector4, 0x31> yxwx; |
| 1648 | Swizzle4<Vector4, 0x32> zxwx; |
| 1649 | Swizzle4<Vector4, 0x33> wxwx; |
| 1650 | Swizzle4<Vector4, 0x34> xywx; |
| 1651 | Swizzle4<Vector4, 0x35> yywx; |
| 1652 | Swizzle4<Vector4, 0x36> zywx; |
| 1653 | Swizzle4<Vector4, 0x37> wywx; |
| 1654 | Swizzle4<Vector4, 0x38> xzwx; |
| 1655 | Swizzle4<Vector4, 0x39> yzwx; |
| 1656 | Swizzle4<Vector4, 0x3A> zzwx; |
| 1657 | Swizzle4<Vector4, 0x3B> wzwx; |
| 1658 | Swizzle4<Vector4, 0x3C> xwwx; |
| 1659 | Swizzle4<Vector4, 0x3D> ywwx; |
| 1660 | Swizzle4<Vector4, 0x3E> zwwx; |
| 1661 | Swizzle4<Vector4, 0x3F> wwwx; |
| 1662 | Swizzle4<Vector4, 0x40> xxxy; |
| 1663 | Swizzle4<Vector4, 0x41> yxxy; |
| 1664 | Swizzle4<Vector4, 0x42> zxxy; |
| 1665 | Swizzle4<Vector4, 0x43> wxxy; |
| 1666 | Swizzle4<Vector4, 0x44> xyxy; |
| 1667 | Swizzle4<Vector4, 0x45> yyxy; |
| 1668 | Swizzle4<Vector4, 0x46> zyxy; |
| 1669 | Swizzle4<Vector4, 0x47> wyxy; |
| 1670 | Swizzle4<Vector4, 0x48> xzxy; |
| 1671 | Swizzle4<Vector4, 0x49> yzxy; |
| 1672 | Swizzle4<Vector4, 0x4A> zzxy; |
| 1673 | Swizzle4<Vector4, 0x4B> wzxy; |
| 1674 | Swizzle4<Vector4, 0x4C> xwxy; |
| 1675 | Swizzle4<Vector4, 0x4D> ywxy; |
| 1676 | Swizzle4<Vector4, 0x4E> zwxy; |
| 1677 | Swizzle4<Vector4, 0x4F> wwxy; |
| 1678 | Swizzle4<Vector4, 0x50> xxyy; |
| 1679 | Swizzle4<Vector4, 0x51> yxyy; |
| 1680 | Swizzle4<Vector4, 0x52> zxyy; |
| 1681 | Swizzle4<Vector4, 0x53> wxyy; |
| 1682 | Swizzle4<Vector4, 0x54> xyyy; |
| 1683 | Swizzle4<Vector4, 0x55> yyyy; |
| 1684 | Swizzle4<Vector4, 0x56> zyyy; |
| 1685 | Swizzle4<Vector4, 0x57> wyyy; |
| 1686 | Swizzle4<Vector4, 0x58> xzyy; |
| 1687 | Swizzle4<Vector4, 0x59> yzyy; |
| 1688 | Swizzle4<Vector4, 0x5A> zzyy; |
| 1689 | Swizzle4<Vector4, 0x5B> wzyy; |
| 1690 | Swizzle4<Vector4, 0x5C> xwyy; |
| 1691 | Swizzle4<Vector4, 0x5D> ywyy; |
| 1692 | Swizzle4<Vector4, 0x5E> zwyy; |
| 1693 | Swizzle4<Vector4, 0x5F> wwyy; |
| 1694 | Swizzle4<Vector4, 0x60> xxzy; |
| 1695 | Swizzle4<Vector4, 0x61> yxzy; |
| 1696 | Swizzle4<Vector4, 0x62> zxzy; |
| 1697 | Swizzle4<Vector4, 0x63> wxzy; |
| 1698 | Swizzle4<Vector4, 0x64> xyzy; |
| 1699 | Swizzle4<Vector4, 0x65> yyzy; |
| 1700 | Swizzle4<Vector4, 0x66> zyzy; |
| 1701 | Swizzle4<Vector4, 0x67> wyzy; |
| 1702 | Swizzle4<Vector4, 0x68> xzzy; |
| 1703 | Swizzle4<Vector4, 0x69> yzzy; |
| 1704 | Swizzle4<Vector4, 0x6A> zzzy; |
| 1705 | Swizzle4<Vector4, 0x6B> wzzy; |
| 1706 | Swizzle4<Vector4, 0x6C> xwzy; |
| 1707 | Swizzle4<Vector4, 0x6D> ywzy; |
| 1708 | Swizzle4<Vector4, 0x6E> zwzy; |
| 1709 | Swizzle4<Vector4, 0x6F> wwzy; |
| 1710 | Swizzle4<Vector4, 0x70> xxwy; |
| 1711 | Swizzle4<Vector4, 0x71> yxwy; |
| 1712 | Swizzle4<Vector4, 0x72> zxwy; |
| 1713 | Swizzle4<Vector4, 0x73> wxwy; |
| 1714 | Swizzle4<Vector4, 0x74> xywy; |
| 1715 | Swizzle4<Vector4, 0x75> yywy; |
| 1716 | Swizzle4<Vector4, 0x76> zywy; |
| 1717 | Swizzle4<Vector4, 0x77> wywy; |
| 1718 | Swizzle4<Vector4, 0x78> xzwy; |
| 1719 | Swizzle4<Vector4, 0x79> yzwy; |
| 1720 | Swizzle4<Vector4, 0x7A> zzwy; |
| 1721 | Swizzle4<Vector4, 0x7B> wzwy; |
| 1722 | Swizzle4<Vector4, 0x7C> xwwy; |
| 1723 | Swizzle4<Vector4, 0x7D> ywwy; |
| 1724 | Swizzle4<Vector4, 0x7E> zwwy; |
| 1725 | Swizzle4<Vector4, 0x7F> wwwy; |
| 1726 | Swizzle4<Vector4, 0x80> xxxz; |
| 1727 | Swizzle4<Vector4, 0x81> yxxz; |
| 1728 | Swizzle4<Vector4, 0x82> zxxz; |
| 1729 | Swizzle4<Vector4, 0x83> wxxz; |
| 1730 | Swizzle4<Vector4, 0x84> xyxz; |
| 1731 | Swizzle4<Vector4, 0x85> yyxz; |
| 1732 | Swizzle4<Vector4, 0x86> zyxz; |
| 1733 | Swizzle4<Vector4, 0x87> wyxz; |
| 1734 | Swizzle4<Vector4, 0x88> xzxz; |
| 1735 | Swizzle4<Vector4, 0x89> yzxz; |
| 1736 | Swizzle4<Vector4, 0x8A> zzxz; |
| 1737 | Swizzle4<Vector4, 0x8B> wzxz; |
| 1738 | Swizzle4<Vector4, 0x8C> xwxz; |
| 1739 | Swizzle4<Vector4, 0x8D> ywxz; |
| 1740 | Swizzle4<Vector4, 0x8E> zwxz; |
| 1741 | Swizzle4<Vector4, 0x8F> wwxz; |
| 1742 | Swizzle4<Vector4, 0x90> xxyz; |
| 1743 | Swizzle4<Vector4, 0x91> yxyz; |
| 1744 | Swizzle4<Vector4, 0x92> zxyz; |
| 1745 | Swizzle4<Vector4, 0x93> wxyz; |
| 1746 | Swizzle4<Vector4, 0x94> xyyz; |
| 1747 | Swizzle4<Vector4, 0x95> yyyz; |
| 1748 | Swizzle4<Vector4, 0x96> zyyz; |
| 1749 | Swizzle4<Vector4, 0x97> wyyz; |
| 1750 | Swizzle4<Vector4, 0x98> xzyz; |
| 1751 | Swizzle4<Vector4, 0x99> yzyz; |
| 1752 | Swizzle4<Vector4, 0x9A> zzyz; |
| 1753 | Swizzle4<Vector4, 0x9B> wzyz; |
| 1754 | Swizzle4<Vector4, 0x9C> xwyz; |
| 1755 | Swizzle4<Vector4, 0x9D> ywyz; |
| 1756 | Swizzle4<Vector4, 0x9E> zwyz; |
| 1757 | Swizzle4<Vector4, 0x9F> wwyz; |
| 1758 | Swizzle4<Vector4, 0xA0> xxzz; |
| 1759 | Swizzle4<Vector4, 0xA1> yxzz; |
| 1760 | Swizzle4<Vector4, 0xA2> zxzz; |
| 1761 | Swizzle4<Vector4, 0xA3> wxzz; |
| 1762 | Swizzle4<Vector4, 0xA4> xyzz; |
| 1763 | Swizzle4<Vector4, 0xA5> yyzz; |
| 1764 | Swizzle4<Vector4, 0xA6> zyzz; |
| 1765 | Swizzle4<Vector4, 0xA7> wyzz; |
| 1766 | Swizzle4<Vector4, 0xA8> xzzz; |
| 1767 | Swizzle4<Vector4, 0xA9> yzzz; |
| 1768 | Swizzle4<Vector4, 0xAA> zzzz; |
| 1769 | Swizzle4<Vector4, 0xAB> wzzz; |
| 1770 | Swizzle4<Vector4, 0xAC> xwzz; |
| 1771 | Swizzle4<Vector4, 0xAD> ywzz; |
| 1772 | Swizzle4<Vector4, 0xAE> zwzz; |
| 1773 | Swizzle4<Vector4, 0xAF> wwzz; |
| 1774 | Swizzle4<Vector4, 0xB0> xxwz; |
| 1775 | Swizzle4<Vector4, 0xB1> yxwz; |
| 1776 | Swizzle4<Vector4, 0xB2> zxwz; |
| 1777 | Swizzle4<Vector4, 0xB3> wxwz; |
| 1778 | Swizzle4<Vector4, 0xB4> xywz; |
| 1779 | Swizzle4<Vector4, 0xB5> yywz; |
| 1780 | Swizzle4<Vector4, 0xB6> zywz; |
| 1781 | Swizzle4<Vector4, 0xB7> wywz; |
| 1782 | Swizzle4<Vector4, 0xB8> xzwz; |
| 1783 | Swizzle4<Vector4, 0xB9> yzwz; |
| 1784 | Swizzle4<Vector4, 0xBA> zzwz; |
| 1785 | Swizzle4<Vector4, 0xBB> wzwz; |
| 1786 | Swizzle4<Vector4, 0xBC> xwwz; |
| 1787 | Swizzle4<Vector4, 0xBD> ywwz; |
| 1788 | Swizzle4<Vector4, 0xBE> zwwz; |
| 1789 | Swizzle4<Vector4, 0xBF> wwwz; |
| 1790 | Swizzle4<Vector4, 0xC0> xxxw; |
| 1791 | Swizzle4<Vector4, 0xC1> yxxw; |
| 1792 | Swizzle4<Vector4, 0xC2> zxxw; |
| 1793 | Swizzle4<Vector4, 0xC3> wxxw; |
| 1794 | Swizzle4<Vector4, 0xC4> xyxw; |
| 1795 | Swizzle4<Vector4, 0xC5> yyxw; |
| 1796 | Swizzle4<Vector4, 0xC6> zyxw; |
| 1797 | Swizzle4<Vector4, 0xC7> wyxw; |
| 1798 | Swizzle4<Vector4, 0xC8> xzxw; |
| 1799 | Swizzle4<Vector4, 0xC9> yzxw; |
| 1800 | Swizzle4<Vector4, 0xCA> zzxw; |
| 1801 | Swizzle4<Vector4, 0xCB> wzxw; |
| 1802 | Swizzle4<Vector4, 0xCC> xwxw; |
| 1803 | Swizzle4<Vector4, 0xCD> ywxw; |
| 1804 | Swizzle4<Vector4, 0xCE> zwxw; |
| 1805 | Swizzle4<Vector4, 0xCF> wwxw; |
| 1806 | Swizzle4<Vector4, 0xD0> xxyw; |
| 1807 | Swizzle4<Vector4, 0xD1> yxyw; |
| 1808 | Swizzle4<Vector4, 0xD2> zxyw; |
| 1809 | Swizzle4<Vector4, 0xD3> wxyw; |
| 1810 | Swizzle4<Vector4, 0xD4> xyyw; |
| 1811 | Swizzle4<Vector4, 0xD5> yyyw; |
| 1812 | Swizzle4<Vector4, 0xD6> zyyw; |
| 1813 | Swizzle4<Vector4, 0xD7> wyyw; |
| 1814 | Swizzle4<Vector4, 0xD8> xzyw; |
| 1815 | Swizzle4<Vector4, 0xD9> yzyw; |
| 1816 | Swizzle4<Vector4, 0xDA> zzyw; |
| 1817 | Swizzle4<Vector4, 0xDB> wzyw; |
| 1818 | Swizzle4<Vector4, 0xDC> xwyw; |
| 1819 | Swizzle4<Vector4, 0xDD> ywyw; |
| 1820 | Swizzle4<Vector4, 0xDE> zwyw; |
| 1821 | Swizzle4<Vector4, 0xDF> wwyw; |
| 1822 | Swizzle4<Vector4, 0xE0> xxzw; |
| 1823 | Swizzle4<Vector4, 0xE1> yxzw; |
| 1824 | Swizzle4<Vector4, 0xE2> zxzw; |
| 1825 | Swizzle4<Vector4, 0xE3> wxzw; |
| 1826 | SwizzleMask4<Vector4, 0xE4> xyzw; |
| 1827 | Swizzle4<Vector4, 0xE5> yyzw; |
| 1828 | Swizzle4<Vector4, 0xE6> zyzw; |
| 1829 | Swizzle4<Vector4, 0xE7> wyzw; |
| 1830 | Swizzle4<Vector4, 0xE8> xzzw; |
| 1831 | Swizzle4<Vector4, 0xE9> yzzw; |
| 1832 | Swizzle4<Vector4, 0xEA> zzzw; |
| 1833 | Swizzle4<Vector4, 0xEB> wzzw; |
| 1834 | Swizzle4<Vector4, 0xEC> xwzw; |
| 1835 | Swizzle4<Vector4, 0xED> ywzw; |
| 1836 | Swizzle4<Vector4, 0xEE> zwzw; |
| 1837 | Swizzle4<Vector4, 0xEF> wwzw; |
| 1838 | Swizzle4<Vector4, 0xF0> xxww; |
| 1839 | Swizzle4<Vector4, 0xF1> yxww; |
| 1840 | Swizzle4<Vector4, 0xF2> zxww; |
| 1841 | Swizzle4<Vector4, 0xF3> wxww; |
| 1842 | Swizzle4<Vector4, 0xF4> xyww; |
| 1843 | Swizzle4<Vector4, 0xF5> yyww; |
| 1844 | Swizzle4<Vector4, 0xF6> zyww; |
| 1845 | Swizzle4<Vector4, 0xF7> wyww; |
| 1846 | Swizzle4<Vector4, 0xF8> xzww; |
| 1847 | Swizzle4<Vector4, 0xF9> yzww; |
| 1848 | Swizzle4<Vector4, 0xFA> zzww; |
| 1849 | Swizzle4<Vector4, 0xFB> wzww; |
| 1850 | Swizzle4<Vector4, 0xFC> xwww; |
| 1851 | Swizzle4<Vector4, 0xFD> ywww; |
| 1852 | Swizzle4<Vector4, 0xFE> zwww; |
| 1853 | Swizzle4<Vector4, 0xFF> wwww; |
| 1854 | }; |
| 1855 | }; |
| 1856 | |
| 1857 | class Int4 : public LValue<Int4>, public XYZW<Int4> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1858 | { |
| 1859 | public: |
| 1860 | explicit Int4(RValue<Byte4> cast); |
| 1861 | explicit Int4(RValue<SByte4> cast); |
| 1862 | explicit Int4(RValue<Float4> cast); |
| 1863 | explicit Int4(RValue<Short4> cast); |
| 1864 | explicit Int4(RValue<UShort4> cast); |
| 1865 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1866 | Int4(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1867 | Int4(int xyzw); |
| 1868 | Int4(int x, int yzw); |
| 1869 | Int4(int x, int y, int zw); |
| 1870 | Int4(int x, int y, int z, int w); |
| 1871 | Int4(RValue<Int4> rhs); |
| 1872 | Int4(const Int4 &rhs); |
| 1873 | Int4(const Reference<Int4> &rhs); |
| 1874 | Int4(RValue<UInt4> rhs); |
| 1875 | Int4(const UInt4 &rhs); |
| 1876 | Int4(const Reference<UInt4> &rhs); |
| 1877 | Int4(RValue<Int2> lo, RValue<Int2> hi); |
| 1878 | Int4(RValue<Int> rhs); |
| 1879 | Int4(const Int &rhs); |
| 1880 | Int4(const Reference<Int> &rhs); |
| 1881 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1882 | RValue<Int4> operator=(RValue<Int4> rhs); |
| 1883 | RValue<Int4> operator=(const Int4 &rhs); |
| 1884 | RValue<Int4> operator=(const Reference<Int4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1885 | |
| 1886 | static Type *getType(); |
| 1887 | |
| 1888 | private: |
| 1889 | void constant(int x, int y, int z, int w); |
| 1890 | }; |
| 1891 | |
| 1892 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1893 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1894 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1895 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1896 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1897 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1898 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1899 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1900 | RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs); |
| 1901 | RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs); |
| 1902 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1903 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1904 | RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs); |
| 1905 | RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs); |
| 1906 | RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs); |
| 1907 | // RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs); |
| 1908 | // RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs); |
| 1909 | RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs); |
| 1910 | RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs); |
| 1911 | RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs); |
| 1912 | RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs); |
| 1913 | RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1914 | RValue<Int4> operator+(RValue<Int4> val); |
| 1915 | RValue<Int4> operator-(RValue<Int4> val); |
| 1916 | RValue<Int4> operator~(RValue<Int4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1917 | // RValue<Int4> operator++(Int4 &val, int); // Post-increment |
| 1918 | // const Int4 &operator++(Int4 &val); // Pre-increment |
| 1919 | // RValue<Int4> operator--(Int4 &val, int); // Post-decrement |
| 1920 | // const Int4 &operator--(Int4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1921 | // RValue<Bool> operator<(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1922 | // RValue<Bool> operator<=(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1923 | // RValue<Bool> operator>(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1924 | // RValue<Bool> operator>=(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1925 | // RValue<Bool> operator!=(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1926 | // RValue<Bool> operator==(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1927 | |
Nicolas Capens | 4b74373 | 2018-05-28 13:22:07 -0400 | [diff] [blame] | 1928 | inline RValue<Int4> operator+(RValue<Int> lhs, RValue<Int4> rhs) |
| 1929 | { |
| 1930 | return Int4(lhs) + rhs; |
| 1931 | } |
| 1932 | |
| 1933 | inline RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int> rhs) |
| 1934 | { |
| 1935 | return lhs + Int4(rhs); |
| 1936 | } |
| 1937 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1938 | RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y); |
| 1939 | RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y); |
| 1940 | RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y); |
| 1941 | RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y); |
| 1942 | RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y); |
| 1943 | RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y); |
Ben Clayton | e95eeb1 | 2019-03-04 16:32:09 +0000 | [diff] [blame] | 1944 | inline RValue<Int4> CmpGT(RValue<Int4> x, RValue<Int4> y) { return CmpNLE(x, y); } |
| 1945 | inline RValue<Int4> CmpGE(RValue<Int4> x, RValue<Int4> y) { return CmpNLT(x, y); } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1946 | RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y); |
| 1947 | RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y); |
| 1948 | RValue<Int4> RoundInt(RValue<Float4> cast); |
Nicolas Capens | 33438a6 | 2017-09-27 11:47:35 -0400 | [diff] [blame] | 1949 | RValue<Short8> PackSigned(RValue<Int4> x, RValue<Int4> y); |
| 1950 | RValue<UShort8> PackUnsigned(RValue<Int4> x, RValue<Int4> y); |
Nicolas Capens | c94ab74 | 2016-11-08 15:15:31 -0500 | [diff] [blame] | 1951 | RValue<Int> Extract(RValue<Int4> val, int i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1952 | RValue<Int4> Insert(RValue<Int4> val, RValue<Int> element, int i); |
| 1953 | RValue<Int> SignMask(RValue<Int4> x); |
| 1954 | RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select); |
Chris Forbes | e86b6dc | 2019-03-01 09:08:47 -0800 | [diff] [blame] | 1955 | RValue<Int4> MulHigh(RValue<Int4> x, RValue<Int4> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1956 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1957 | class UInt4 : public LValue<UInt4>, public XYZW<UInt4> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1958 | { |
| 1959 | public: |
| 1960 | explicit UInt4(RValue<Float4> cast); |
| 1961 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1962 | UInt4(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1963 | UInt4(int xyzw); |
| 1964 | UInt4(int x, int yzw); |
| 1965 | UInt4(int x, int y, int zw); |
| 1966 | UInt4(int x, int y, int z, int w); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1967 | UInt4(RValue<UInt4> rhs); |
| 1968 | UInt4(const UInt4 &rhs); |
| 1969 | UInt4(const Reference<UInt4> &rhs); |
| 1970 | UInt4(RValue<Int4> rhs); |
| 1971 | UInt4(const Int4 &rhs); |
| 1972 | UInt4(const Reference<Int4> &rhs); |
| 1973 | UInt4(RValue<UInt2> lo, RValue<UInt2> hi); |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 1974 | UInt4(RValue<UInt> rhs); |
| 1975 | UInt4(const UInt &rhs); |
| 1976 | UInt4(const Reference<UInt> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1977 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1978 | RValue<UInt4> operator=(RValue<UInt4> rhs); |
| 1979 | RValue<UInt4> operator=(const UInt4 &rhs); |
| 1980 | RValue<UInt4> operator=(const Reference<UInt4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1981 | |
| 1982 | static Type *getType(); |
| 1983 | |
| 1984 | private: |
| 1985 | void constant(int x, int y, int z, int w); |
| 1986 | }; |
| 1987 | |
| 1988 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1989 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1990 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1991 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1992 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1993 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1994 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1995 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1996 | RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs); |
| 1997 | RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs); |
| 1998 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1999 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2000 | RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2001 | RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2002 | RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2003 | // RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2004 | // RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2005 | RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2006 | RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2007 | RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs); |
| 2008 | RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs); |
| 2009 | RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2010 | RValue<UInt4> operator+(RValue<UInt4> val); |
| 2011 | RValue<UInt4> operator-(RValue<UInt4> val); |
| 2012 | RValue<UInt4> operator~(RValue<UInt4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2013 | // RValue<UInt4> operator++(UInt4 &val, int); // Post-increment |
| 2014 | // const UInt4 &operator++(UInt4 &val); // Pre-increment |
| 2015 | // RValue<UInt4> operator--(UInt4 &val, int); // Post-decrement |
| 2016 | // const UInt4 &operator--(UInt4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2017 | // RValue<Bool> operator<(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 2018 | // RValue<Bool> operator<=(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 2019 | // RValue<Bool> operator>(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 2020 | // RValue<Bool> operator>=(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 2021 | // RValue<Bool> operator!=(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 2022 | // RValue<Bool> operator==(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 2023 | |
| 2024 | RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y); |
| 2025 | RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y); |
| 2026 | RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y); |
| 2027 | RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y); |
| 2028 | RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y); |
| 2029 | RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y); |
Ben Clayton | e95eeb1 | 2019-03-04 16:32:09 +0000 | [diff] [blame] | 2030 | inline RValue<UInt4> CmpGT(RValue<UInt4> x, RValue<UInt4> y) { return CmpNLE(x, y); } |
| 2031 | inline RValue<UInt4> CmpGE(RValue<UInt4> x, RValue<UInt4> y) { return CmpNLT(x, y); } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2032 | RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y); |
| 2033 | RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y); |
Chris Forbes | e86b6dc | 2019-03-01 09:08:47 -0800 | [diff] [blame] | 2034 | RValue<UInt4> MulHigh(RValue<UInt4> x, RValue<UInt4> y); |
Ben Clayton | fc77af1 | 2019-04-09 10:48:00 -0400 | [diff] [blame] | 2035 | RValue<UInt> Extract(RValue<UInt4> val, int i); |
| 2036 | RValue<UInt4> Insert(RValue<UInt4> val, RValue<UInt> element, int i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2037 | // RValue<UInt4> RoundInt(RValue<Float4> cast); |
Ben Clayton | 7459172 | 2019-05-14 16:51:52 +0100 | [diff] [blame] | 2038 | RValue<UInt4> Swizzle(RValue<UInt4> x, unsigned char select); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2039 | |
Alexis Hetu | 734e257 | 2018-12-20 14:00:49 -0500 | [diff] [blame] | 2040 | class Half : public LValue<Half> |
| 2041 | { |
| 2042 | public: |
| 2043 | explicit Half(RValue<Float> cast); |
| 2044 | |
| 2045 | static Type *getType(); |
| 2046 | }; |
| 2047 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 2048 | class Float : public LValue<Float> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2049 | { |
| 2050 | public: |
| 2051 | explicit Float(RValue<Int> cast); |
Alexis Hetu | cfd9632 | 2017-07-24 14:44:33 -0400 | [diff] [blame] | 2052 | explicit Float(RValue<UInt> cast); |
Alexis Hetu | 734e257 | 2018-12-20 14:00:49 -0500 | [diff] [blame] | 2053 | explicit Float(RValue<Half> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2054 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2055 | Float() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2056 | Float(float x); |
| 2057 | Float(RValue<Float> rhs); |
| 2058 | Float(const Float &rhs); |
| 2059 | Float(const Reference<Float> &rhs); |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 2060 | Float(Argument<Float> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2061 | |
| 2062 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2063 | Float(const SwizzleMask1<Float4, T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2064 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2065 | // RValue<Float> operator=(float rhs); // FIXME: Implement |
| 2066 | RValue<Float> operator=(RValue<Float> rhs); |
| 2067 | RValue<Float> operator=(const Float &rhs); |
| 2068 | RValue<Float> operator=(const Reference<Float> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2069 | |
| 2070 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2071 | RValue<Float> operator=(const SwizzleMask1<Float4, T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2072 | |
| 2073 | static Type *getType(); |
| 2074 | }; |
| 2075 | |
| 2076 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs); |
| 2077 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs); |
| 2078 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs); |
| 2079 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2080 | RValue<Float> operator+=(Float &lhs, RValue<Float> rhs); |
| 2081 | RValue<Float> operator-=(Float &lhs, RValue<Float> rhs); |
| 2082 | RValue<Float> operator*=(Float &lhs, RValue<Float> rhs); |
| 2083 | RValue<Float> operator/=(Float &lhs, RValue<Float> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2084 | RValue<Float> operator+(RValue<Float> val); |
| 2085 | RValue<Float> operator-(RValue<Float> val); |
| 2086 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs); |
| 2087 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs); |
| 2088 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs); |
| 2089 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs); |
| 2090 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs); |
| 2091 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs); |
| 2092 | |
| 2093 | RValue<Float> Abs(RValue<Float> x); |
| 2094 | RValue<Float> Max(RValue<Float> x, RValue<Float> y); |
| 2095 | RValue<Float> Min(RValue<Float> x, RValue<Float> y); |
| 2096 | RValue<Float> Rcp_pp(RValue<Float> val, bool exactAtPow2 = false); |
| 2097 | RValue<Float> RcpSqrt_pp(RValue<Float> val); |
| 2098 | RValue<Float> Sqrt(RValue<Float> x); |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 2099 | |
| 2100 | // RValue<Int4> IsInf(RValue<Float> x); |
| 2101 | // RValue<Int4> IsNan(RValue<Float> x); |
| 2102 | RValue<Float> Round(RValue<Float> x); |
| 2103 | RValue<Float> Trunc(RValue<Float> x); |
| 2104 | RValue<Float> Frac(RValue<Float> x); |
| 2105 | RValue<Float> Floor(RValue<Float> x); |
| 2106 | RValue<Float> Ceil(RValue<Float> x); |
| 2107 | |
| 2108 | // Trigonometric functions |
| 2109 | // TODO: Currently unimplemented for Subzero. |
| 2110 | // RValue<Float> Sin(RValue<Float> x); |
| 2111 | // RValue<Float> Cos(RValue<Float> x); |
| 2112 | // RValue<Float> Tan(RValue<Float> x); |
| 2113 | // RValue<Float> Asin(RValue<Float> x); |
| 2114 | // RValue<Float> Acos(RValue<Float> x); |
| 2115 | // RValue<Float> Atan(RValue<Float> x); |
| 2116 | // RValue<Float> Sinh(RValue<Float> x); |
| 2117 | // RValue<Float> Cosh(RValue<Float> x); |
| 2118 | // RValue<Float> Tanh(RValue<Float> x); |
| 2119 | // RValue<Float> Asinh(RValue<Float> x); |
| 2120 | // RValue<Float> Acosh(RValue<Float> x); |
| 2121 | // RValue<Float> Atanh(RValue<Float> x); |
| 2122 | // RValue<Float> Atan2(RValue<Float> x, RValue<Float> y); |
| 2123 | |
| 2124 | // Exponential functions |
| 2125 | // TODO: Currently unimplemented for Subzero. |
| 2126 | // RValue<Float> Pow(RValue<Float> x, RValue<Float> y); |
| 2127 | // RValue<Float> Exp(RValue<Float> x); |
| 2128 | // RValue<Float> Log(RValue<Float> x); |
| 2129 | RValue<Float> Exp2(RValue<Float> x); |
| 2130 | RValue<Float> Log2(RValue<Float> x); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2131 | |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 2132 | class Float2 : public LValue<Float2> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2133 | { |
| 2134 | public: |
| 2135 | // explicit Float2(RValue<Byte2> cast); |
| 2136 | // explicit Float2(RValue<Short2> cast); |
| 2137 | // explicit Float2(RValue<UShort2> cast); |
| 2138 | // explicit Float2(RValue<Int2> cast); |
| 2139 | // explicit Float2(RValue<UInt2> cast); |
| 2140 | explicit Float2(RValue<Float4> cast); |
| 2141 | |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2142 | Float2() = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2143 | // Float2(float x, float y); |
| 2144 | // Float2(RValue<Float2> rhs); |
| 2145 | // Float2(const Float2 &rhs); |
| 2146 | // Float2(const Reference<Float2> &rhs); |
| 2147 | // Float2(RValue<Float> rhs); |
| 2148 | // Float2(const Float &rhs); |
| 2149 | // Float2(const Reference<Float> &rhs); |
| 2150 | |
| 2151 | // template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2152 | // Float2(const SwizzleMask1<T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2153 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2154 | // RValue<Float2> operator=(float replicate); |
| 2155 | // RValue<Float2> operator=(RValue<Float2> rhs); |
| 2156 | // RValue<Float2> operator=(const Float2 &rhs); |
| 2157 | // RValue<Float2> operator=(const Reference<Float2> &rhs); |
| 2158 | // RValue<Float2> operator=(RValue<Float> rhs); |
| 2159 | // RValue<Float2> operator=(const Float &rhs); |
| 2160 | // RValue<Float2> operator=(const Reference<Float> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2161 | |
| 2162 | // template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2163 | // RValue<Float2> operator=(const SwizzleMask1<T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2164 | |
| 2165 | static Type *getType(); |
| 2166 | }; |
| 2167 | |
| 2168 | // RValue<Float2> operator+(RValue<Float2> lhs, RValue<Float2> rhs); |
| 2169 | // RValue<Float2> operator-(RValue<Float2> lhs, RValue<Float2> rhs); |
| 2170 | // RValue<Float2> operator*(RValue<Float2> lhs, RValue<Float2> rhs); |
| 2171 | // RValue<Float2> operator/(RValue<Float2> lhs, RValue<Float2> rhs); |
| 2172 | // RValue<Float2> operator%(RValue<Float2> lhs, RValue<Float2> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2173 | // RValue<Float2> operator+=(Float2 &lhs, RValue<Float2> rhs); |
| 2174 | // RValue<Float2> operator-=(Float2 &lhs, RValue<Float2> rhs); |
| 2175 | // RValue<Float2> operator*=(Float2 &lhs, RValue<Float2> rhs); |
| 2176 | // RValue<Float2> operator/=(Float2 &lhs, RValue<Float2> rhs); |
| 2177 | // RValue<Float2> operator%=(Float2 &lhs, RValue<Float2> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2178 | // RValue<Float2> operator+(RValue<Float2> val); |
| 2179 | // RValue<Float2> operator-(RValue<Float2> val); |
| 2180 | |
| 2181 | // RValue<Float2> Abs(RValue<Float2> x); |
| 2182 | // RValue<Float2> Max(RValue<Float2> x, RValue<Float2> y); |
| 2183 | // RValue<Float2> Min(RValue<Float2> x, RValue<Float2> y); |
| 2184 | // RValue<Float2> Swizzle(RValue<Float2> x, unsigned char select); |
| 2185 | // RValue<Float2> Mask(Float2 &lhs, RValue<Float2> rhs, unsigned char select); |
| 2186 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2187 | class Float4 : public LValue<Float4>, public XYZW<Float4> |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2188 | { |
| 2189 | public: |
| 2190 | explicit Float4(RValue<Byte4> cast); |
| 2191 | explicit Float4(RValue<SByte4> cast); |
| 2192 | explicit Float4(RValue<Short4> cast); |
| 2193 | explicit Float4(RValue<UShort4> cast); |
| 2194 | explicit Float4(RValue<Int4> cast); |
| 2195 | explicit Float4(RValue<UInt4> cast); |
| 2196 | |
| 2197 | Float4(); |
| 2198 | Float4(float xyzw); |
| 2199 | Float4(float x, float yzw); |
| 2200 | Float4(float x, float y, float zw); |
| 2201 | Float4(float x, float y, float z, float w); |
| 2202 | Float4(RValue<Float4> rhs); |
| 2203 | Float4(const Float4 &rhs); |
| 2204 | Float4(const Reference<Float4> &rhs); |
| 2205 | Float4(RValue<Float> rhs); |
| 2206 | Float4(const Float &rhs); |
| 2207 | Float4(const Reference<Float> &rhs); |
| 2208 | |
| 2209 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2210 | Float4(const SwizzleMask1<Float4, T> &rhs); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2211 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2212 | Float4(const Swizzle4<Float4, T> &rhs); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2213 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2214 | Float4(const Swizzle2<Float4, X> &x, const Swizzle2<Float4, Y> &y); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2215 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2216 | Float4(const SwizzleMask2<Float4, X> &x, const Swizzle2<Float4, Y> &y); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2217 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2218 | Float4(const Swizzle2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2219 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2220 | Float4(const SwizzleMask2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2221 | |
| 2222 | RValue<Float4> operator=(float replicate); |
| 2223 | RValue<Float4> operator=(RValue<Float4> rhs); |
| 2224 | RValue<Float4> operator=(const Float4 &rhs); |
| 2225 | RValue<Float4> operator=(const Reference<Float4> &rhs); |
| 2226 | RValue<Float4> operator=(RValue<Float> rhs); |
| 2227 | RValue<Float4> operator=(const Float &rhs); |
| 2228 | RValue<Float4> operator=(const Reference<Float> &rhs); |
| 2229 | |
| 2230 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2231 | RValue<Float4> operator=(const SwizzleMask1<Float4, T> &rhs); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2232 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2233 | RValue<Float4> operator=(const Swizzle4<Float4, T> &rhs); |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2234 | |
| 2235 | static Type *getType(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2236 | |
| 2237 | private: |
| 2238 | void constant(float x, float y, float z, float w); |
| 2239 | }; |
| 2240 | |
| 2241 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs); |
| 2242 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs); |
| 2243 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs); |
| 2244 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs); |
| 2245 | RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2246 | RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs); |
| 2247 | RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs); |
| 2248 | RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs); |
| 2249 | RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs); |
| 2250 | RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2251 | RValue<Float4> operator+(RValue<Float4> val); |
| 2252 | RValue<Float4> operator-(RValue<Float4> val); |
| 2253 | |
| 2254 | RValue<Float4> Abs(RValue<Float4> x); |
| 2255 | RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y); |
| 2256 | RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y); |
| 2257 | RValue<Float4> Rcp_pp(RValue<Float4> val, bool exactAtPow2 = false); |
| 2258 | RValue<Float4> RcpSqrt_pp(RValue<Float4> val); |
| 2259 | RValue<Float4> Sqrt(RValue<Float4> x); |
Nicolas Capens | c94ab74 | 2016-11-08 15:15:31 -0500 | [diff] [blame] | 2260 | RValue<Float4> Insert(RValue<Float4> val, RValue<Float> element, int i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2261 | RValue<Float> Extract(RValue<Float4> x, int i); |
| 2262 | RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select); |
| 2263 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm); |
| 2264 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y); |
| 2265 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y); |
| 2266 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, unsigned char select); |
| 2267 | RValue<Int> SignMask(RValue<Float4> x); |
Ben Clayton | ec1aeb8 | 2019-03-04 19:33:27 +0000 | [diff] [blame] | 2268 | |
| 2269 | // Ordered comparison functions |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2270 | RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y); |
| 2271 | RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y); |
| 2272 | RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y); |
| 2273 | RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y); |
| 2274 | RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y); |
| 2275 | RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y); |
Ben Clayton | ec1aeb8 | 2019-03-04 19:33:27 +0000 | [diff] [blame] | 2276 | inline RValue<Int4> CmpGT(RValue<Float4> x, RValue<Float4> y) { return CmpNLE(x, y); } |
| 2277 | inline RValue<Int4> CmpGE(RValue<Float4> x, RValue<Float4> y) { return CmpNLT(x, y); } |
| 2278 | |
| 2279 | // Unordered comparison functions |
| 2280 | RValue<Int4> CmpUEQ(RValue<Float4> x, RValue<Float4> y); |
| 2281 | RValue<Int4> CmpULT(RValue<Float4> x, RValue<Float4> y); |
| 2282 | RValue<Int4> CmpULE(RValue<Float4> x, RValue<Float4> y); |
| 2283 | RValue<Int4> CmpUNEQ(RValue<Float4> x, RValue<Float4> y); |
| 2284 | RValue<Int4> CmpUNLT(RValue<Float4> x, RValue<Float4> y); |
| 2285 | RValue<Int4> CmpUNLE(RValue<Float4> x, RValue<Float4> y); |
| 2286 | inline RValue<Int4> CmpUGT(RValue<Float4> x, RValue<Float4> y) { return CmpUNLE(x, y); } |
| 2287 | inline RValue<Int4> CmpUGE(RValue<Float4> x, RValue<Float4> y) { return CmpUNLT(x, y); } |
| 2288 | |
Alexis Hetu | 8ef6d10 | 2017-11-09 15:49:09 -0500 | [diff] [blame] | 2289 | RValue<Int4> IsInf(RValue<Float4> x); |
| 2290 | RValue<Int4> IsNan(RValue<Float4> x); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2291 | RValue<Float4> Round(RValue<Float4> x); |
| 2292 | RValue<Float4> Trunc(RValue<Float4> x); |
| 2293 | RValue<Float4> Frac(RValue<Float4> x); |
| 2294 | RValue<Float4> Floor(RValue<Float4> x); |
| 2295 | RValue<Float4> Ceil(RValue<Float4> x); |
| 2296 | |
Ben Clayton | a2c8b77 | 2019-04-09 13:42:36 -0400 | [diff] [blame] | 2297 | // Trigonometric functions |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 2298 | // TODO: Currently unimplemented for Subzero. |
Ben Clayton | a2c8b77 | 2019-04-09 13:42:36 -0400 | [diff] [blame] | 2299 | RValue<Float4> Sin(RValue<Float4> x); |
Ben Clayton | 1b6f8c7 | 2019-04-09 13:47:43 -0400 | [diff] [blame] | 2300 | RValue<Float4> Cos(RValue<Float4> x); |
Ben Clayton | 1474006 | 2019-04-09 13:48:41 -0400 | [diff] [blame] | 2301 | RValue<Float4> Tan(RValue<Float4> x); |
Ben Clayton | f9350d7 | 2019-04-09 14:19:02 -0400 | [diff] [blame] | 2302 | RValue<Float4> Asin(RValue<Float4> x); |
Ben Clayton | eafae47 | 2019-04-09 14:22:38 -0400 | [diff] [blame] | 2303 | RValue<Float4> Acos(RValue<Float4> x); |
Ben Clayton | 749b4e0 | 2019-04-09 14:27:43 -0400 | [diff] [blame] | 2304 | RValue<Float4> Atan(RValue<Float4> x); |
Ben Clayton | d963697 | 2019-04-09 15:09:54 -0400 | [diff] [blame] | 2305 | RValue<Float4> Sinh(RValue<Float4> x); |
Ben Clayton | 900ea2c | 2019-04-09 15:25:36 -0400 | [diff] [blame] | 2306 | RValue<Float4> Cosh(RValue<Float4> x); |
Ben Clayton | 3928bd9 | 2019-04-09 15:27:41 -0400 | [diff] [blame] | 2307 | RValue<Float4> Tanh(RValue<Float4> x); |
Ben Clayton | f6d77ab | 2019-04-09 15:30:04 -0400 | [diff] [blame] | 2308 | RValue<Float4> Asinh(RValue<Float4> x); |
Ben Clayton | 28ebcb0 | 2019-04-09 15:33:38 -0400 | [diff] [blame] | 2309 | RValue<Float4> Acosh(RValue<Float4> x); |
Ben Clayton | fa6a539 | 2019-04-09 15:35:24 -0400 | [diff] [blame] | 2310 | RValue<Float4> Atanh(RValue<Float4> x); |
Ben Clayton | a520c3e | 2019-04-09 15:43:45 -0400 | [diff] [blame] | 2311 | RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y); |
Ben Clayton | a2c8b77 | 2019-04-09 13:42:36 -0400 | [diff] [blame] | 2312 | |
Ben Clayton | bfe94f0 | 2019-04-09 15:52:12 -0400 | [diff] [blame] | 2313 | // Exponential functions |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 2314 | // TODO: Currently unimplemented for Subzero. |
Ben Clayton | bfe94f0 | 2019-04-09 15:52:12 -0400 | [diff] [blame] | 2315 | RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y); |
Ben Clayton | 242f002 | 2019-04-09 16:00:53 -0400 | [diff] [blame] | 2316 | RValue<Float4> Exp(RValue<Float4> x); |
Ben Clayton | 2c1da72 | 2019-04-09 16:03:03 -0400 | [diff] [blame] | 2317 | RValue<Float4> Log(RValue<Float4> x); |
Ben Clayton | f40b56c | 2019-04-09 16:06:55 -0400 | [diff] [blame] | 2318 | RValue<Float4> Exp2(RValue<Float4> x); |
Ben Clayton | e17acfe | 2019-04-09 16:09:13 -0400 | [diff] [blame] | 2319 | RValue<Float4> Log2(RValue<Float4> x); |
Ben Clayton | bfe94f0 | 2019-04-09 15:52:12 -0400 | [diff] [blame] | 2320 | |
Ben Clayton | 6095826 | 2019-04-10 14:53:30 -0400 | [diff] [blame] | 2321 | // Bit Manipulation functions. |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 2322 | // TODO: Currently unimplemented for Subzero. |
Ben Clayton | 6095826 | 2019-04-10 14:53:30 -0400 | [diff] [blame] | 2323 | |
| 2324 | // Count leading zeros. |
| 2325 | // Returns 32 when: isZeroUndef && x == 0. |
| 2326 | // Returns an undefined value when: !isZeroUndef && x == 0. |
Ben Clayton | ff6e8c0 | 2019-08-06 21:23:44 +0100 | [diff] [blame] | 2327 | RValue<UInt> Ctlz(RValue<UInt> x, bool isZeroUndef); |
Ben Clayton | 6095826 | 2019-04-10 14:53:30 -0400 | [diff] [blame] | 2328 | RValue<UInt4> Ctlz(RValue<UInt4> x, bool isZeroUndef); |
| 2329 | |
Ben Clayton | 3f007c4 | 2019-04-10 14:54:23 -0400 | [diff] [blame] | 2330 | // Count trailing zeros. |
| 2331 | // Returns 32 when: isZeroUndef && x == 0. |
| 2332 | // Returns an undefined value when: !isZeroUndef && x == 0. |
Ben Clayton | ff6e8c0 | 2019-08-06 21:23:44 +0100 | [diff] [blame] | 2333 | RValue<UInt> Cttz(RValue<UInt> x, bool isZeroUndef); |
Ben Clayton | 3f007c4 | 2019-04-10 14:54:23 -0400 | [diff] [blame] | 2334 | RValue<UInt4> Cttz(RValue<UInt4> x, bool isZeroUndef); |
| 2335 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2336 | template<class T> |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 2337 | class Pointer : public LValue<Pointer<T>> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2338 | { |
| 2339 | public: |
| 2340 | template<class S> |
| 2341 | Pointer(RValue<Pointer<S>> pointerS, int alignment = 1) : alignment(alignment) |
| 2342 | { |
| 2343 | Value *pointerT = Nucleus::createBitCast(pointerS.value, Nucleus::getPointerType(T::getType())); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2344 | LValue<Pointer<T>>::storeValue(pointerT); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | template<class S> |
| 2348 | Pointer(const Pointer<S> &pointer, int alignment = 1) : alignment(alignment) |
| 2349 | { |
Nicolas Capens | 4126b8e | 2017-07-26 13:34:36 -0400 | [diff] [blame] | 2350 | Value *pointerS = pointer.loadValue(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2351 | Value *pointerT = Nucleus::createBitCast(pointerS, Nucleus::getPointerType(T::getType())); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2352 | LValue<Pointer<T>>::storeValue(pointerT); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2353 | } |
| 2354 | |
| 2355 | Pointer(Argument<Pointer<T>> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2356 | |
| 2357 | Pointer(); |
| 2358 | Pointer(RValue<Pointer<T>> rhs); |
| 2359 | Pointer(const Pointer<T> &rhs); |
| 2360 | Pointer(const Reference<Pointer<T>> &rhs); |
Ben Clayton | 0697da0 | 2019-08-01 13:35:48 +0100 | [diff] [blame] | 2361 | Pointer(std::nullptr_t); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2362 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2363 | RValue<Pointer<T>> operator=(RValue<Pointer<T>> rhs); |
| 2364 | RValue<Pointer<T>> operator=(const Pointer<T> &rhs); |
| 2365 | RValue<Pointer<T>> operator=(const Reference<Pointer<T>> &rhs); |
Ben Clayton | 0697da0 | 2019-08-01 13:35:48 +0100 | [diff] [blame] | 2366 | RValue<Pointer<T>> operator=(std::nullptr_t); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2367 | |
| 2368 | Reference<T> operator*(); |
| 2369 | Reference<T> operator[](int index); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2370 | Reference<T> operator[](unsigned int index); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2371 | Reference<T> operator[](RValue<Int> index); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2372 | Reference<T> operator[](RValue<UInt> index); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2373 | |
| 2374 | static Type *getType(); |
| 2375 | |
| 2376 | private: |
| 2377 | const int alignment; |
| 2378 | }; |
| 2379 | |
| 2380 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset); |
| 2381 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset); |
| 2382 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2383 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset); |
| 2384 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset); |
| 2385 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2386 | |
| 2387 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset); |
| 2388 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset); |
| 2389 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2390 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset); |
| 2391 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset); |
| 2392 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2393 | |
Ben Clayton | 204a410 | 2019-07-31 13:17:47 +0100 | [diff] [blame] | 2394 | template <typename T> |
| 2395 | RValue<Bool> operator==(const Pointer<T> &lhs, const Pointer<T> &rhs) |
| 2396 | { |
| 2397 | return RValue<Bool>(Nucleus::createPtrEQ(lhs.loadValue(), rhs.loadValue())); |
| 2398 | } |
| 2399 | |
Nicolas Capens | 86509d9 | 2019-03-21 13:23:50 -0400 | [diff] [blame] | 2400 | template<typename T> |
| 2401 | RValue<T> Load(RValue<Pointer<T>> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2402 | { |
| 2403 | return RValue<T>(Nucleus::createLoad(pointer.value, T::getType(), false, alignment, atomic, memoryOrder)); |
| 2404 | } |
| 2405 | |
| 2406 | template<typename T> |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2407 | RValue<T> Load(Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2408 | { |
| 2409 | return Load(RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder); |
| 2410 | } |
| 2411 | |
Ben Clayton | 0fc611f | 2019-04-18 11:23:27 -0400 | [diff] [blame] | 2412 | // TODO: Use SIMD to template these. |
Ben Clayton | 0b00b95 | 2019-07-03 15:51:19 +0100 | [diff] [blame] | 2413 | RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); |
| 2414 | RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); |
Ben Clayton | cb2ebc9 | 2019-06-20 00:18:03 +0100 | [diff] [blame] | 2415 | void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment); |
| 2416 | void MaskedStore(RValue<Pointer<Int4>> base, RValue<Int4> val, RValue<Int4> mask, unsigned int alignment); |
| 2417 | |
Ben Clayton | 0b00b95 | 2019-07-03 15:51:19 +0100 | [diff] [blame] | 2418 | RValue<Float4> Gather(RValue<Pointer<Float>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); |
| 2419 | RValue<Int4> Gather(RValue<Pointer<Int>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); |
Ben Clayton | 0fc611f | 2019-04-18 11:23:27 -0400 | [diff] [blame] | 2420 | void Scatter(RValue<Pointer<Float>> base, RValue<Float4> val, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment); |
| 2421 | void Scatter(RValue<Pointer<Int>> base, RValue<Int4> val, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment); |
| 2422 | |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2423 | template<typename T> |
Nicolas Capens | 86509d9 | 2019-03-21 13:23:50 -0400 | [diff] [blame] | 2424 | void Store(RValue<T> value, RValue<Pointer<T>> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2425 | { |
| 2426 | Nucleus::createStore(value.value, pointer.value, T::getType(), false, alignment, atomic, memoryOrder); |
| 2427 | } |
| 2428 | |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2429 | template<typename T> |
| 2430 | void Store(RValue<T> value, Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2431 | { |
| 2432 | Store(value, RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder); |
| 2433 | } |
| 2434 | |
| 2435 | template<typename T> |
| 2436 | void Store(T value, Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2437 | { |
| 2438 | Store(RValue<T>(value), RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder); |
| 2439 | } |
| 2440 | |
Ben Clayton | b16c586 | 2019-05-08 14:01:38 +0100 | [diff] [blame] | 2441 | // Fence adds a memory barrier that enforces ordering constraints on memory |
| 2442 | // operations. memoryOrder can only be one of: |
| 2443 | // std::memory_order_acquire, std::memory_order_release, |
| 2444 | // std::memory_order_acq_rel, or std::memory_order_seq_cst. |
| 2445 | void Fence(std::memory_order memoryOrder); |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2446 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2447 | template<class T, int S = 1> |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 2448 | class Array : public LValue<T> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2449 | { |
| 2450 | public: |
| 2451 | Array(int size = S); |
| 2452 | |
| 2453 | Reference<T> operator[](int index); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2454 | Reference<T> operator[](unsigned int index); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2455 | Reference<T> operator[](RValue<Int> index); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2456 | Reference<T> operator[](RValue<UInt> index); |
Ben Clayton | 0953d9b | 2019-06-25 20:57:06 +0100 | [diff] [blame] | 2457 | |
| 2458 | // self() returns the this pointer to this Array object. |
| 2459 | // This function exists because operator&() is overloaded by LValue<T>. |
| 2460 | inline Array* self() { return this; } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2461 | }; |
| 2462 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2463 | // RValue<Array<T>> operator++(Array<T> &val, int); // Post-increment |
| 2464 | // const Array<T> &operator++(Array<T> &val); // Pre-increment |
| 2465 | // RValue<Array<T>> operator--(Array<T> &val, int); // Post-decrement |
| 2466 | // const Array<T> &operator--(Array<T> &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2467 | |
Nicolas Capens | f4eec2f | 2017-05-24 15:46:48 -0400 | [diff] [blame] | 2468 | void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2469 | |
Ben Clayton | 208ed40 | 2019-05-03 22:30:03 +0100 | [diff] [blame] | 2470 | // ValueOf returns a rr::Value* for the given C-type, RValue<T>, LValue<T> |
| 2471 | // or Reference<T>. |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 2472 | template <typename T> |
| 2473 | inline Value* ValueOf(const T &v) |
| 2474 | { |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 2475 | return ReactorType<T>::cast(v).loadValue(); |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 2476 | } |
| 2477 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2478 | void Return(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2479 | |
| 2480 | template<class T> |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 2481 | void Return(const T &ret) |
| 2482 | { |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 2483 | static_assert(CanBeUsedAsReturn< ReactorTypeT<T> >::value, "Unsupported type for Return()"); |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 2484 | Nucleus::createRet(ValueOf<T>(ret)); |
| 2485 | // Place any unreachable instructions in an unreferenced block. |
| 2486 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 2487 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2488 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2489 | // Generic template, leave undefined! |
| 2490 | template<typename FunctionType> |
| 2491 | class Function; |
| 2492 | |
| 2493 | // Specialized for function types |
| 2494 | template<typename Return, typename... Arguments> |
| 2495 | class Function<Return(Arguments...)> |
| 2496 | { |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 2497 | // Static assert that the function signature is valid. |
| 2498 | static_assert(sizeof(AssertFunctionSignatureIsValid<Return(Arguments...)>) >= 0, "Invalid function signature"); |
| 2499 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2500 | public: |
| 2501 | Function(); |
| 2502 | |
| 2503 | virtual ~Function(); |
| 2504 | |
| 2505 | template<int index> |
Ben Clayton | 169872e | 2019-02-27 23:58:35 +0000 | [diff] [blame] | 2506 | Argument<typename std::tuple_element<index, std::tuple<Arguments...>>::type> Arg() const |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2507 | { |
| 2508 | Value *arg = Nucleus::getArgument(index); |
Ben Clayton | 169872e | 2019-02-27 23:58:35 +0000 | [diff] [blame] | 2509 | return Argument<typename std::tuple_element<index, std::tuple<Arguments...>>::type>(arg); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2510 | } |
| 2511 | |
Ben Clayton | 6897e9b | 2019-07-16 17:27:27 +0100 | [diff] [blame] | 2512 | std::shared_ptr<Routine> operator()(const char *name, ...); |
| 2513 | std::shared_ptr<Routine> operator()(const Config::Edit &cfg, const char *name, ...); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2514 | |
| 2515 | protected: |
| 2516 | Nucleus *core; |
| 2517 | std::vector<Type*> arguments; |
| 2518 | }; |
| 2519 | |
| 2520 | template<typename Return> |
| 2521 | class Function<Return()> : public Function<Return(Void)> |
| 2522 | { |
| 2523 | }; |
| 2524 | |
Antonio Maiorano | 62f49b2 | 2019-10-29 09:27:58 -0400 | [diff] [blame] | 2525 | // FunctionT accepts a C-style function type template argument, allowing it to return a type-safe RoutineT wrapper |
| 2526 | template<typename FunctionType> |
| 2527 | class FunctionT; |
| 2528 | |
| 2529 | template<typename Return, typename... Arguments> |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 2530 | class FunctionT<Return(Arguments...)> : public Function<CToReactorT<Return>(CToReactorT<Arguments>...)> |
Antonio Maiorano | 62f49b2 | 2019-10-29 09:27:58 -0400 | [diff] [blame] | 2531 | { |
| 2532 | public: |
| 2533 | // Type of base class |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 2534 | using BaseType = Function<CToReactorT<Return>(CToReactorT<Arguments>...)>; |
Antonio Maiorano | 62f49b2 | 2019-10-29 09:27:58 -0400 | [diff] [blame] | 2535 | |
| 2536 | // Function type, e.g. void(int,float) |
| 2537 | using CFunctionType = Return(Arguments...); |
| 2538 | |
| 2539 | // Reactor function type, e.g. Void(Int, Float) |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 2540 | using ReactorFunctionType = CToReactorT<Return>(CToReactorT<Arguments>...); |
Antonio Maiorano | 62f49b2 | 2019-10-29 09:27:58 -0400 | [diff] [blame] | 2541 | |
| 2542 | // Returned RoutineT type |
| 2543 | using RoutineType = RoutineT<CFunctionType>; |
| 2544 | |
| 2545 | // Hide base implementations of operator() |
| 2546 | |
| 2547 | RoutineType operator()(const char* name, ...) |
| 2548 | { |
| 2549 | return RoutineType(BaseType::operator()(name)); |
| 2550 | } |
| 2551 | |
| 2552 | RoutineType operator()(const Config::Edit& cfg, const char* name, ...) |
| 2553 | { |
| 2554 | return RoutineType(BaseType::operator()(cfg, name)); |
| 2555 | } |
| 2556 | }; |
| 2557 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2558 | RValue<Long> Ticks(); |
| 2559 | } |
| 2560 | |
Nicolas Capens | 4846150 | 2018-08-06 14:20:45 -0400 | [diff] [blame] | 2561 | namespace rr |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2562 | { |
| 2563 | template<class T> |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2564 | LValue<T>::LValue(int arraySize) : Variable(T::getType(), arraySize) |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2565 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2566 | #ifdef ENABLE_RR_DEBUG_INFO |
| 2567 | materialize(); |
| 2568 | #endif // ENABLE_RR_DEBUG_INFO |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2569 | } |
| 2570 | |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2571 | inline void Variable::materialize() const |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2572 | { |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2573 | if(!address) |
| 2574 | { |
| 2575 | address = Nucleus::allocateStackVariable(type, arraySize); |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2576 | RR_DEBUG_INFO_EMIT_VAR(address); |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2577 | |
| 2578 | if(rvalue) |
| 2579 | { |
| 2580 | storeValue(rvalue); |
| 2581 | rvalue = nullptr; |
| 2582 | } |
| 2583 | } |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2584 | } |
| 2585 | |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2586 | inline Value *Variable::loadValue() const |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2587 | { |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2588 | if(rvalue) |
| 2589 | { |
| 2590 | return rvalue; |
| 2591 | } |
| 2592 | |
| 2593 | if(!address) |
| 2594 | { |
| 2595 | // TODO: Return undef instead. |
| 2596 | materialize(); |
| 2597 | } |
| 2598 | |
| 2599 | return Nucleus::createLoad(address, type, false, 0); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2600 | } |
| 2601 | |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2602 | inline Value *Variable::storeValue(Value *value) const |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2603 | { |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2604 | if(address) |
| 2605 | { |
| 2606 | return Nucleus::createStore(value, address, type, false, 0); |
| 2607 | } |
| 2608 | |
| 2609 | rvalue = value; |
| 2610 | |
| 2611 | return value; |
| 2612 | } |
| 2613 | |
| 2614 | inline Value *Variable::getBaseAddress() const |
| 2615 | { |
| 2616 | materialize(); |
| 2617 | |
| 2618 | return address; |
| 2619 | } |
| 2620 | |
| 2621 | inline Value *Variable::getElementPointer(Value *index, bool unsignedIndex) const |
| 2622 | { |
| 2623 | return Nucleus::createGEP(getBaseAddress(), type, index, unsignedIndex); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2624 | } |
| 2625 | |
| 2626 | template<class T> |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 2627 | RValue<Pointer<T>> LValue<T>::operator&() |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2628 | { |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 2629 | return RValue<Pointer<T>>(getBaseAddress()); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2630 | } |
| 2631 | |
| 2632 | template<class T> |
| 2633 | Reference<T>::Reference(Value *pointer, int alignment) : alignment(alignment) |
| 2634 | { |
| 2635 | address = pointer; |
| 2636 | } |
| 2637 | |
| 2638 | template<class T> |
| 2639 | RValue<T> Reference<T>::operator=(RValue<T> rhs) const |
| 2640 | { |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 2641 | Nucleus::createStore(rhs.value, address, T::getType(), false, alignment); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2642 | |
| 2643 | return rhs; |
| 2644 | } |
| 2645 | |
| 2646 | template<class T> |
| 2647 | RValue<T> Reference<T>::operator=(const Reference<T> &ref) const |
| 2648 | { |
Nicolas Capens | e12780d | 2016-09-27 14:18:07 -0400 | [diff] [blame] | 2649 | Value *tmp = Nucleus::createLoad(ref.address, T::getType(), false, ref.alignment); |
Nicolas Capens | 6d73871 | 2016-09-30 04:15:22 -0400 | [diff] [blame] | 2650 | Nucleus::createStore(tmp, address, T::getType(), false, alignment); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2651 | |
| 2652 | return RValue<T>(tmp); |
| 2653 | } |
| 2654 | |
| 2655 | template<class T> |
| 2656 | RValue<T> Reference<T>::operator+=(RValue<T> rhs) const |
| 2657 | { |
| 2658 | return *this = *this + rhs; |
| 2659 | } |
| 2660 | |
| 2661 | template<class T> |
| 2662 | Value *Reference<T>::loadValue() const |
| 2663 | { |
Nicolas Capens | e12780d | 2016-09-27 14:18:07 -0400 | [diff] [blame] | 2664 | return Nucleus::createLoad(address, T::getType(), false, alignment); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2665 | } |
| 2666 | |
| 2667 | template<class T> |
| 2668 | int Reference<T>::getAlignment() const |
| 2669 | { |
| 2670 | return alignment; |
| 2671 | } |
| 2672 | |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2673 | #ifdef ENABLE_RR_DEBUG_INFO |
| 2674 | template<class T> |
| 2675 | RValue<T>::RValue(const RValue<T> &rvalue) : value(rvalue.value) |
| 2676 | { |
| 2677 | RR_DEBUG_INFO_EMIT_VAR(value); |
| 2678 | } |
| 2679 | #endif // ENABLE_RR_DEBUG_INFO |
| 2680 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2681 | template<class T> |
| 2682 | RValue<T>::RValue(Value *rvalue) |
| 2683 | { |
Nicolas Capens | bea4dce | 2017-07-24 16:54:44 -0400 | [diff] [blame] | 2684 | assert(Nucleus::createBitCast(rvalue, T::getType()) == rvalue); // Run-time type should match T, so bitcast is no-op. |
| 2685 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2686 | value = rvalue; |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2687 | RR_DEBUG_INFO_EMIT_VAR(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2688 | } |
| 2689 | |
| 2690 | template<class T> |
| 2691 | RValue<T>::RValue(const T &lvalue) |
| 2692 | { |
| 2693 | value = lvalue.loadValue(); |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2694 | RR_DEBUG_INFO_EMIT_VAR(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2695 | } |
| 2696 | |
| 2697 | template<class T> |
Ben Clayton | 35e90e2 | 2019-03-15 10:06:06 +0000 | [diff] [blame] | 2698 | RValue<T>::RValue(typename BoolLiteral<T>::type i) |
| 2699 | { |
| 2700 | value = Nucleus::createConstantBool(i); |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2701 | RR_DEBUG_INFO_EMIT_VAR(value); |
Ben Clayton | 35e90e2 | 2019-03-15 10:06:06 +0000 | [diff] [blame] | 2702 | } |
| 2703 | |
| 2704 | template<class T> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2705 | RValue<T>::RValue(typename IntLiteral<T>::type i) |
| 2706 | { |
Nicolas Capens | a16473e | 2016-11-07 15:32:52 -0500 | [diff] [blame] | 2707 | value = Nucleus::createConstantInt(i); |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2708 | RR_DEBUG_INFO_EMIT_VAR(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | template<class T> |
| 2712 | RValue<T>::RValue(typename FloatLiteral<T>::type f) |
| 2713 | { |
Nicolas Capens | a16473e | 2016-11-07 15:32:52 -0500 | [diff] [blame] | 2714 | value = Nucleus::createConstantFloat(f); |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2715 | RR_DEBUG_INFO_EMIT_VAR(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2716 | } |
| 2717 | |
| 2718 | template<class T> |
| 2719 | RValue<T>::RValue(const Reference<T> &ref) |
| 2720 | { |
| 2721 | value = ref.loadValue(); |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2722 | RR_DEBUG_INFO_EMIT_VAR(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2723 | } |
| 2724 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2725 | template<class Vector4, int T> |
| 2726 | Swizzle2<Vector4, T>::operator RValue<Vector4>() const |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2727 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2728 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2729 | Value *vector = parent->loadValue(); |
| 2730 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2731 | return Swizzle(RValue<Vector4>(vector), T); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2732 | } |
| 2733 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2734 | template<class Vector4, int T> |
| 2735 | Swizzle4<Vector4, T>::operator RValue<Vector4>() const |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2736 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2737 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2738 | Value *vector = parent->loadValue(); |
| 2739 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2740 | return Swizzle(RValue<Vector4>(vector), T); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2741 | } |
| 2742 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2743 | template<class Vector4, int T> |
| 2744 | SwizzleMask4<Vector4, T>::operator RValue<Vector4>() const |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2745 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2746 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2747 | Value *vector = parent->loadValue(); |
| 2748 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2749 | return Swizzle(RValue<Vector4>(vector), T); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2750 | } |
| 2751 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2752 | template<class Vector4, int T> |
| 2753 | RValue<Vector4> SwizzleMask4<Vector4, T>::operator=(RValue<Vector4> rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2754 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2755 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2756 | return Mask(*parent, rhs, T); |
| 2757 | } |
| 2758 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2759 | template<class Vector4, int T> |
| 2760 | RValue<Vector4> SwizzleMask4<Vector4, T>::operator=(RValue<typename Scalar<Vector4>::Type> rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2761 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2762 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2763 | return Mask(*parent, Vector4(rhs), T); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2764 | } |
| 2765 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2766 | template<class Vector4, int T> |
| 2767 | SwizzleMask1<Vector4, T>::operator RValue<typename Scalar<Vector4>::Type>() const // FIXME: Call a non-template function |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2768 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2769 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2770 | return Extract(*parent, T & 0x3); |
| 2771 | } |
| 2772 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2773 | template<class Vector4, int T> |
| 2774 | SwizzleMask1<Vector4, T>::operator RValue<Vector4>() const |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2775 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2776 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2777 | Value *vector = parent->loadValue(); |
| 2778 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2779 | return Swizzle(RValue<Vector4>(vector), T); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2780 | } |
| 2781 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2782 | template<class Vector4, int T> |
| 2783 | RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(float x) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2784 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2785 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | c94ab74 | 2016-11-08 15:15:31 -0500 | [diff] [blame] | 2786 | return *parent = Insert(*parent, Float(x), T & 0x3); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2787 | } |
| 2788 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2789 | template<class Vector4, int T> |
| 2790 | RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(RValue<Vector4> rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2791 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2792 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2793 | return Mask(*parent, Float4(rhs), T); |
| 2794 | } |
| 2795 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2796 | template<class Vector4, int T> |
| 2797 | RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(RValue<typename Scalar<Vector4>::Type> rhs) // FIXME: Call a non-template function |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2798 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2799 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | c94ab74 | 2016-11-08 15:15:31 -0500 | [diff] [blame] | 2800 | return *parent = Insert(*parent, rhs, T & 0x3); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2801 | } |
| 2802 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2803 | template<class Vector4, int T> |
| 2804 | SwizzleMask2<Vector4, T>::operator RValue<Vector4>() const |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2805 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2806 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2807 | Value *vector = parent->loadValue(); |
| 2808 | |
Nicolas Capens | e95d534 | 2016-09-30 11:37:28 -0400 | [diff] [blame] | 2809 | return Swizzle(RValue<Float4>(vector), T); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2810 | } |
| 2811 | |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2812 | template<class Vector4, int T> |
| 2813 | RValue<Vector4> SwizzleMask2<Vector4, T>::operator=(RValue<Vector4> rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2814 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2815 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2816 | return Mask(*parent, Float4(rhs), T); |
| 2817 | } |
| 2818 | |
| 2819 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2820 | Float::Float(const SwizzleMask1<Float4, T> &rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2821 | { |
| 2822 | *this = rhs.operator RValue<Float>(); |
| 2823 | } |
| 2824 | |
| 2825 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2826 | RValue<Float> Float::operator=(const SwizzleMask1<Float4, T> &rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2827 | { |
| 2828 | return *this = rhs.operator RValue<Float>(); |
| 2829 | } |
| 2830 | |
| 2831 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2832 | Float4::Float4(const SwizzleMask1<Float4, T> &rhs) : XYZW(this) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2833 | { |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2834 | *this = rhs.operator RValue<Float4>(); |
| 2835 | } |
| 2836 | |
| 2837 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2838 | Float4::Float4(const Swizzle4<Float4, T> &rhs) : XYZW(this) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2839 | { |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2840 | *this = rhs.operator RValue<Float4>(); |
| 2841 | } |
| 2842 | |
| 2843 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2844 | Float4::Float4(const Swizzle2<Float4, X> &x, const Swizzle2<Float4, Y> &y) : XYZW(this) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2845 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2846 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2847 | *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4); |
| 2848 | } |
| 2849 | |
| 2850 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2851 | Float4::Float4(const SwizzleMask2<Float4, X> &x, const Swizzle2<Float4, Y> &y) : XYZW(this) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2852 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2853 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2854 | *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4); |
| 2855 | } |
| 2856 | |
| 2857 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2858 | Float4::Float4(const Swizzle2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y) : XYZW(this) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2859 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2860 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2861 | *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4); |
| 2862 | } |
| 2863 | |
| 2864 | template<int X, int Y> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2865 | Float4::Float4(const SwizzleMask2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y) : XYZW(this) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2866 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2867 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2868 | *this = ShuffleLowHigh(*x.parent, *y.parent, (X & 0xF) | (Y & 0xF) << 4); |
| 2869 | } |
| 2870 | |
| 2871 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2872 | RValue<Float4> Float4::operator=(const SwizzleMask1<Float4, T> &rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2873 | { |
| 2874 | return *this = rhs.operator RValue<Float4>(); |
| 2875 | } |
| 2876 | |
| 2877 | template<int T> |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 2878 | RValue<Float4> Float4::operator=(const Swizzle4<Float4, T> &rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2879 | { |
| 2880 | return *this = rhs.operator RValue<Float4>(); |
| 2881 | } |
| 2882 | |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame^] | 2883 | // Returns a reactor pointer to the fixed-address ptr. |
| 2884 | RValue<Pointer<Byte>> ConstantPointer(void const * ptr); |
| 2885 | |
| 2886 | // Returns a reactor pointer to an immutable copy of the data of size bytes. |
| 2887 | RValue<Pointer<Byte>> ConstantData(void const * data, size_t size); |
| 2888 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2889 | template<class T> |
| 2890 | Pointer<T>::Pointer(Argument<Pointer<T>> argument) : alignment(1) |
| 2891 | { |
Nicolas Capens | 51d9867 | 2019-04-02 12:05:40 -0400 | [diff] [blame] | 2892 | LValue<Pointer<T>>::materialize(); // FIXME(b/129757459) |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2893 | LValue<Pointer<T>>::storeValue(argument.value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2894 | } |
| 2895 | |
| 2896 | template<class T> |
Ben Clayton | f63c4e5 | 2019-08-01 13:40:43 +0100 | [diff] [blame] | 2897 | Pointer<T>::Pointer() : alignment(1) {} |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2898 | |
| 2899 | template<class T> |
| 2900 | Pointer<T>::Pointer(RValue<Pointer<T>> rhs) : alignment(1) |
| 2901 | { |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2902 | LValue<Pointer<T>>::storeValue(rhs.value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2903 | } |
| 2904 | |
| 2905 | template<class T> |
| 2906 | Pointer<T>::Pointer(const Pointer<T> &rhs) : alignment(rhs.alignment) |
| 2907 | { |
| 2908 | Value *value = rhs.loadValue(); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2909 | LValue<Pointer<T>>::storeValue(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2910 | } |
| 2911 | |
| 2912 | template<class T> |
| 2913 | Pointer<T>::Pointer(const Reference<Pointer<T>> &rhs) : alignment(rhs.getAlignment()) |
| 2914 | { |
| 2915 | Value *value = rhs.loadValue(); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2916 | LValue<Pointer<T>>::storeValue(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2917 | } |
| 2918 | |
| 2919 | template<class T> |
Ben Clayton | 0697da0 | 2019-08-01 13:35:48 +0100 | [diff] [blame] | 2920 | Pointer<T>::Pointer(std::nullptr_t) : alignment(1) |
| 2921 | { |
| 2922 | Value *value = Nucleus::createNullPointer(T::getType()); |
| 2923 | LValue<Pointer<T>>::storeValue(value); |
| 2924 | } |
| 2925 | |
| 2926 | template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2927 | RValue<Pointer<T>> Pointer<T>::operator=(RValue<Pointer<T>> rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2928 | { |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2929 | LValue<Pointer<T>>::storeValue(rhs.value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2930 | |
| 2931 | return rhs; |
| 2932 | } |
| 2933 | |
| 2934 | template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2935 | RValue<Pointer<T>> Pointer<T>::operator=(const Pointer<T> &rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2936 | { |
| 2937 | Value *value = rhs.loadValue(); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2938 | LValue<Pointer<T>>::storeValue(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2939 | |
| 2940 | return RValue<Pointer<T>>(value); |
| 2941 | } |
| 2942 | |
| 2943 | template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2944 | RValue<Pointer<T>> Pointer<T>::operator=(const Reference<Pointer<T>> &rhs) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2945 | { |
| 2946 | Value *value = rhs.loadValue(); |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2947 | LValue<Pointer<T>>::storeValue(value); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2948 | |
| 2949 | return RValue<Pointer<T>>(value); |
| 2950 | } |
| 2951 | |
| 2952 | template<class T> |
Ben Clayton | 0697da0 | 2019-08-01 13:35:48 +0100 | [diff] [blame] | 2953 | RValue<Pointer<T>> Pointer<T>::operator=(std::nullptr_t) |
| 2954 | { |
| 2955 | Value *value = Nucleus::createNullPointer(T::getType()); |
| 2956 | LValue<Pointer<T>>::storeValue(value); |
| 2957 | |
| 2958 | return RValue<Pointer<T>>(this); |
| 2959 | } |
| 2960 | |
| 2961 | template<class T> |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2962 | Reference<T> Pointer<T>::operator*() |
| 2963 | { |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2964 | return Reference<T>(LValue<Pointer<T>>::loadValue(), alignment); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2965 | } |
| 2966 | |
| 2967 | template<class T> |
| 2968 | Reference<T> Pointer<T>::operator[](int index) |
| 2969 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2970 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2971 | Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), Nucleus::createConstantInt(index), false); |
| 2972 | |
| 2973 | return Reference<T>(element, alignment); |
| 2974 | } |
| 2975 | |
| 2976 | template<class T> |
| 2977 | Reference<T> Pointer<T>::operator[](unsigned int index) |
| 2978 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2979 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2980 | Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), Nucleus::createConstantInt(index), true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2981 | |
| 2982 | return Reference<T>(element, alignment); |
| 2983 | } |
| 2984 | |
| 2985 | template<class T> |
| 2986 | Reference<T> Pointer<T>::operator[](RValue<Int> index) |
| 2987 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2988 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2989 | Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), index.value, false); |
| 2990 | |
| 2991 | return Reference<T>(element, alignment); |
| 2992 | } |
| 2993 | |
| 2994 | template<class T> |
| 2995 | Reference<T> Pointer<T>::operator[](RValue<UInt> index) |
| 2996 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2997 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2998 | Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), index.value, true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2999 | |
| 3000 | return Reference<T>(element, alignment); |
| 3001 | } |
| 3002 | |
| 3003 | template<class T> |
| 3004 | Type *Pointer<T>::getType() |
| 3005 | { |
| 3006 | return Nucleus::getPointerType(T::getType()); |
| 3007 | } |
| 3008 | |
| 3009 | template<class T, int S> |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 3010 | Array<T, S>::Array(int size) : LValue<T>(size) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3011 | { |
| 3012 | } |
| 3013 | |
| 3014 | template<class T, int S> |
| 3015 | Reference<T> Array<T, S>::operator[](int index) |
| 3016 | { |
Ben Clayton | 83dd452 | 2019-06-27 10:37:00 +0100 | [diff] [blame] | 3017 | assert(index < this->arraySize); |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 3018 | Value *element = LValue<T>::getElementPointer(Nucleus::createConstantInt(index), false); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 3019 | |
| 3020 | return Reference<T>(element); |
| 3021 | } |
| 3022 | |
| 3023 | template<class T, int S> |
| 3024 | Reference<T> Array<T, S>::operator[](unsigned int index) |
| 3025 | { |
Ben Clayton | 83dd452 | 2019-06-27 10:37:00 +0100 | [diff] [blame] | 3026 | assert(index < static_cast<unsigned int>(this->arraySize)); |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 3027 | Value *element = LValue<T>::getElementPointer(Nucleus::createConstantInt(index), true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3028 | |
| 3029 | return Reference<T>(element); |
| 3030 | } |
| 3031 | |
| 3032 | template<class T, int S> |
| 3033 | Reference<T> Array<T, S>::operator[](RValue<Int> index) |
| 3034 | { |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 3035 | Value *element = LValue<T>::getElementPointer(index.value, false); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 3036 | |
| 3037 | return Reference<T>(element); |
| 3038 | } |
| 3039 | |
| 3040 | template<class T, int S> |
| 3041 | Reference<T> Array<T, S>::operator[](RValue<UInt> index) |
| 3042 | { |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 3043 | Value *element = LValue<T>::getElementPointer(index.value, true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3044 | |
| 3045 | return Reference<T>(element); |
| 3046 | } |
| 3047 | |
| 3048 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 3049 | // RValue<Array<T>> operator++(Array<T> &val, int) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3050 | // { |
| 3051 | // // FIXME: Requires storing the address of the array |
| 3052 | // } |
| 3053 | |
| 3054 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 3055 | // const Array<T> &operator++(Array<T> &val) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3056 | // { |
| 3057 | // // FIXME: Requires storing the address of the array |
| 3058 | // } |
| 3059 | |
| 3060 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 3061 | // RValue<Array<T>> operator--(Array<T> &val, int) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3062 | // { |
| 3063 | // // FIXME: Requires storing the address of the array |
| 3064 | // } |
| 3065 | |
| 3066 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 3067 | // const Array<T> &operator--(Array<T> &val) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3068 | // { |
| 3069 | // // FIXME: Requires storing the address of the array |
| 3070 | // } |
| 3071 | |
| 3072 | template<class T> |
| 3073 | RValue<T> IfThenElse(RValue<Bool> condition, RValue<T> ifTrue, RValue<T> ifFalse) |
| 3074 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3075 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3076 | return RValue<T>(Nucleus::createSelect(condition.value, ifTrue.value, ifFalse.value)); |
| 3077 | } |
| 3078 | |
| 3079 | template<class T> |
| 3080 | RValue<T> IfThenElse(RValue<Bool> condition, const T &ifTrue, RValue<T> ifFalse) |
| 3081 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3082 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3083 | Value *trueValue = ifTrue.loadValue(); |
| 3084 | |
| 3085 | return RValue<T>(Nucleus::createSelect(condition.value, trueValue, ifFalse.value)); |
| 3086 | } |
| 3087 | |
| 3088 | template<class T> |
| 3089 | RValue<T> IfThenElse(RValue<Bool> condition, RValue<T> ifTrue, const T &ifFalse) |
| 3090 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3091 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3092 | Value *falseValue = ifFalse.loadValue(); |
| 3093 | |
| 3094 | return RValue<T>(Nucleus::createSelect(condition.value, ifTrue.value, falseValue)); |
| 3095 | } |
| 3096 | |
| 3097 | template<class T> |
| 3098 | RValue<T> IfThenElse(RValue<Bool> condition, const T &ifTrue, const T &ifFalse) |
| 3099 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3100 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3101 | Value *trueValue = ifTrue.loadValue(); |
| 3102 | Value *falseValue = ifFalse.loadValue(); |
| 3103 | |
| 3104 | return RValue<T>(Nucleus::createSelect(condition.value, trueValue, falseValue)); |
| 3105 | } |
| 3106 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3107 | template<typename Return, typename... Arguments> |
| 3108 | Function<Return(Arguments...)>::Function() |
| 3109 | { |
| 3110 | core = new Nucleus(); |
| 3111 | |
| 3112 | Type *types[] = {Arguments::getType()...}; |
| 3113 | for(Type *type : types) |
| 3114 | { |
| 3115 | if(type != Void::getType()) |
| 3116 | { |
| 3117 | arguments.push_back(type); |
| 3118 | } |
| 3119 | } |
| 3120 | |
| 3121 | Nucleus::createFunction(Return::getType(), arguments); |
| 3122 | } |
| 3123 | |
| 3124 | template<typename Return, typename... Arguments> |
| 3125 | Function<Return(Arguments...)>::~Function() |
| 3126 | { |
| 3127 | delete core; |
| 3128 | } |
| 3129 | |
| 3130 | template<typename Return, typename... Arguments> |
Ben Clayton | 6897e9b | 2019-07-16 17:27:27 +0100 | [diff] [blame] | 3131 | std::shared_ptr<Routine> Function<Return(Arguments...)>::operator()(const char *name, ...) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3132 | { |
Chris Forbes | 878d4b0 | 2019-01-21 10:48:35 -0800 | [diff] [blame] | 3133 | char fullName[1024 + 1]; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3134 | |
| 3135 | va_list vararg; |
| 3136 | va_start(vararg, name); |
Chris Forbes | 878d4b0 | 2019-01-21 10:48:35 -0800 | [diff] [blame] | 3137 | vsnprintf(fullName, 1024, name, vararg); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3138 | va_end(vararg); |
| 3139 | |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 3140 | return core->acquireRoutine(fullName, Config::Edit::None); |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 3141 | } |
| 3142 | |
| 3143 | template<typename Return, typename... Arguments> |
Ben Clayton | 6897e9b | 2019-07-16 17:27:27 +0100 | [diff] [blame] | 3144 | std::shared_ptr<Routine> Function<Return(Arguments...)>::operator()(const Config::Edit &cfg, const char *name, ...) |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 3145 | { |
| 3146 | char fullName[1024 + 1]; |
| 3147 | |
| 3148 | va_list vararg; |
| 3149 | va_start(vararg, name); |
| 3150 | vsnprintf(fullName, 1024, name, vararg); |
| 3151 | va_end(vararg); |
| 3152 | |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 3153 | return core->acquireRoutine(fullName, cfg); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3154 | } |
| 3155 | |
| 3156 | template<class T, class S> |
| 3157 | RValue<T> ReinterpretCast(RValue<S> val) |
| 3158 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3159 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3160 | return RValue<T>(Nucleus::createBitCast(val.value, T::getType())); |
| 3161 | } |
| 3162 | |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 3163 | template<class T, class S> |
| 3164 | RValue<T> ReinterpretCast(const LValue<S> &var) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3165 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3166 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3167 | Value *val = var.loadValue(); |
| 3168 | |
| 3169 | return RValue<T>(Nucleus::createBitCast(val, T::getType())); |
| 3170 | } |
| 3171 | |
| 3172 | template<class T, class S> |
| 3173 | RValue<T> ReinterpretCast(const Reference<S> &var) |
| 3174 | { |
| 3175 | return ReinterpretCast<T>(RValue<S>(var)); |
| 3176 | } |
| 3177 | |
Nicolas Capens | 70dfff4 | 2016-10-27 10:20:28 -0400 | [diff] [blame] | 3178 | template<class T> |
| 3179 | RValue<T> As(Value *val) |
| 3180 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3181 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | 70dfff4 | 2016-10-27 10:20:28 -0400 | [diff] [blame] | 3182 | return RValue<T>(Nucleus::createBitCast(val, T::getType())); |
| 3183 | } |
| 3184 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3185 | template<class T, class S> |
| 3186 | RValue<T> As(RValue<S> val) |
| 3187 | { |
| 3188 | return ReinterpretCast<T>(val); |
| 3189 | } |
| 3190 | |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 3191 | template<class T, class S> |
| 3192 | RValue<T> As(const LValue<S> &var) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3193 | { |
| 3194 | return ReinterpretCast<T>(var); |
| 3195 | } |
| 3196 | |
| 3197 | template<class T, class S> |
| 3198 | RValue<T> As(const Reference<S> &val) |
| 3199 | { |
| 3200 | return ReinterpretCast<T>(val); |
| 3201 | } |
| 3202 | |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3203 | // Calls the function pointer fptr with the given arguments, return type |
| 3204 | // and parameter types. Returns the call's return value if the function has |
| 3205 | // a non-void return type. |
| 3206 | Value* Call(RValue<Pointer<Byte>> fptr, Type* retTy, std::initializer_list<Value*> args, std::initializer_list<Type*> paramTys); |
| 3207 | |
| 3208 | template <typename F> |
| 3209 | class CallHelper {}; |
| 3210 | |
| 3211 | template<typename Return, typename ... Arguments> |
| 3212 | class CallHelper<Return(Arguments...)> |
| 3213 | { |
| 3214 | public: |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3215 | using RReturn = CToReactorT<Return>; |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3216 | |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3217 | static inline RReturn Call(Return(fptr)(Arguments...), CToReactorT<Arguments>... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3218 | { |
| 3219 | return RValue<RReturn>(rr::Call( |
| 3220 | ConstantPointer(reinterpret_cast<void*>(fptr)), |
| 3221 | RReturn::getType(), |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 3222 | { ValueOf(args) ... }, |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3223 | { CToReactorT<Arguments>::getType() ... })); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3224 | } |
| 3225 | |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3226 | static inline RReturn Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3227 | { |
| 3228 | return RValue<RReturn>(rr::Call( |
| 3229 | fptr, |
| 3230 | RReturn::getType(), |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 3231 | { ValueOf(args) ... }, |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3232 | { CToReactorT<Arguments>::getType() ... })); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3233 | } |
| 3234 | }; |
| 3235 | |
| 3236 | template<typename ... Arguments> |
| 3237 | class CallHelper<void(Arguments...)> |
| 3238 | { |
| 3239 | public: |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3240 | static inline void Call(void(fptr)(Arguments...), CToReactorT<Arguments>... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3241 | { |
| 3242 | rr::Call(ConstantPointer(reinterpret_cast<void*>(fptr)), |
| 3243 | Void::getType(), |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 3244 | { ValueOf(args) ... }, |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3245 | { CToReactorT<Arguments>::getType() ... }); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3246 | } |
| 3247 | |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3248 | static inline void Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3249 | { |
| 3250 | rr::Call(fptr, |
| 3251 | Void::getType(), |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 3252 | { ValueOf(args) ... }, |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3253 | { CToReactorT<Arguments>::getType() ... }); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3254 | } |
| 3255 | }; |
| 3256 | |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3257 | template <typename T> |
| 3258 | inline ReactorTypeT<T> CastToReactor(const T& v) { return ReactorType<T>::cast(v); } |
| 3259 | |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame^] | 3260 | // Calls the static function pointer fptr with the given arguments args. |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3261 | template<typename Return, typename ... CArgs, typename ... RArgs> |
| 3262 | inline CToReactorT<Return> Call(Return(fptr)(CArgs...), RArgs&&... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3263 | { |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3264 | return CallHelper<Return(CArgs...)>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3265 | } |
| 3266 | |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame^] | 3267 | // Calls the static function pointer fptr with the given arguments args. |
Antonio Maiorano | 7363cd2 | 2019-10-11 15:23:22 -0400 | [diff] [blame] | 3268 | // Overload for calling functions with void return type. |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3269 | template<typename ... CArgs, typename ... RArgs> |
| 3270 | inline void Call(void(fptr)(CArgs...), RArgs&&... args) |
Antonio Maiorano | 7363cd2 | 2019-10-11 15:23:22 -0400 | [diff] [blame] | 3271 | { |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3272 | CallHelper<void(CArgs...)>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...); |
Antonio Maiorano | 7363cd2 | 2019-10-11 15:23:22 -0400 | [diff] [blame] | 3273 | } |
| 3274 | |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame^] | 3275 | // Calls the member function pointer fptr with the given arguments args. |
| 3276 | // object can be a Class*, or a Pointer<Byte>. |
| 3277 | template<typename Return, typename Class, typename C, typename ... CArgs, typename ... RArgs> |
| 3278 | inline CToReactorT<Return> Call(Return(Class::* fptr)(CArgs...), C&& object, RArgs&&... args) |
| 3279 | { |
| 3280 | using Helper = CallHelper<Return(Class*, void*, CArgs...)>; |
| 3281 | using fptrTy = decltype(fptr); |
| 3282 | struct Static { |
| 3283 | static inline Return Call(Class* object, void* fptrptr, CArgs... args) |
| 3284 | { |
| 3285 | auto fptr = *reinterpret_cast<fptrTy*>(fptrptr); |
| 3286 | return (object->*fptr)(std::forward<CArgs>(args)...); |
| 3287 | } |
| 3288 | }; |
| 3289 | return Helper::Call(&Static::Call, |
| 3290 | CastToReactor(object), |
| 3291 | ConstantData(&fptr, sizeof(fptr)), |
| 3292 | CastToReactor(std::forward<RArgs>(args))...); |
| 3293 | } |
| 3294 | |
| 3295 | // Calls the member function pointer fptr with the given arguments args. |
| 3296 | // Overload for calling functions with void return type. |
| 3297 | // object can be a Class*, or a Pointer<Byte>. |
| 3298 | template<typename Class, typename C, typename ... CArgs, typename ... RArgs> |
| 3299 | inline void Call(void(Class::* fptr)(CArgs...), C&& object, RArgs&&... args) |
| 3300 | { |
| 3301 | using Helper = CallHelper<void(Class*, void*, CArgs...)>; |
| 3302 | using fptrTy = decltype(fptr); |
| 3303 | struct Static { |
| 3304 | static inline void Call(Class* object, void* fptrptr, CArgs... args) |
| 3305 | { |
| 3306 | auto fptr = *reinterpret_cast<fptrTy*>(fptrptr); |
| 3307 | (object->*fptr)(std::forward<CArgs>(args)...); |
| 3308 | } |
| 3309 | }; |
| 3310 | Helper::Call(&Static::Call, |
| 3311 | CastToReactor(object), |
| 3312 | ConstantData(&fptr, sizeof(fptr)), |
| 3313 | CastToReactor(std::forward<RArgs>(args))...); |
| 3314 | } |
| 3315 | |
| 3316 | // Calls the Reactor function pointer fptr with the signature |
| 3317 | // FUNCTION_SIGNATURE and arguments. |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3318 | template<typename FUNCTION_SIGNATURE, typename ... RArgs> |
| 3319 | inline void Call(Pointer<Byte> fptr, RArgs&& ... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3320 | { |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3321 | CallHelper<FUNCTION_SIGNATURE>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3322 | } |
| 3323 | |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3324 | // Breakpoint emits an instruction that will cause the application to trap. |
| 3325 | // This can be used to stop an attached debugger at the given call. |
| 3326 | void Breakpoint(); |
| 3327 | |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3328 | #ifdef ENABLE_RR_PRINT |
| 3329 | // PrintValue holds the printf format and value(s) for a single argument |
| 3330 | // to Print(). A single argument can be expanded into multiple printf |
| 3331 | // values - for example a Float4 will expand to "%f %f %f %f" and four |
| 3332 | // scalar values. |
| 3333 | // The PrintValue constructor accepts the following: |
| 3334 | // * Reactor LValues, RValues, Pointers. |
| 3335 | // * Standard Plain-Old-Value types (int, float, bool, etc) |
| 3336 | // * Custom types that specialize the PrintValue::Ty template struct. |
| 3337 | // * Static arrays in the form T[N] where T can be any of the above. |
| 3338 | class PrintValue |
| 3339 | { |
| 3340 | // Ty is a template that can be specialized for printing type T. |
| 3341 | // Each specialization must expose: |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3342 | // * A 'static std::string fmt(const T& v)' method that provides the |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3343 | // printf format specifier. |
| 3344 | // * A 'static std::vector<rr::Value*> val(const T& v)' method that |
| 3345 | // returns all the printf format values. |
| 3346 | template <typename T> struct Ty |
| 3347 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3348 | // static std::string fmt(const T& v); |
| 3349 | // static std::vector<rr::Value*> val(const T& v); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3350 | }; |
| 3351 | |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3352 | // returns the printf values for all the values in the given array. |
| 3353 | template <typename T> |
| 3354 | static std::vector<Value*> val(const T* list, int count) { |
| 3355 | std::vector<Value*> values; |
| 3356 | values.reserve(count); |
| 3357 | for (int i = 0; i < count; i++) |
| 3358 | { |
| 3359 | auto v = val(list[i]); |
| 3360 | values.insert(values.end(), v.begin(), v.end()); |
| 3361 | } |
| 3362 | return values; |
Ben Clayton | bcc71a3 | 2019-04-21 07:35:37 -0400 | [diff] [blame] | 3363 | } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3364 | |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3365 | // fmt returns the comma-delimited list of printf format strings for |
| 3366 | // every element in the provided list, all enclosed in square brackets. |
| 3367 | template <typename T> |
| 3368 | static std::string fmt(const T* list, int count) |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3369 | { |
| 3370 | std::string out = "["; |
| 3371 | for (int i = 0; i < count; i++) |
| 3372 | { |
| 3373 | if (i > 0) { out += ", "; } |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3374 | out += fmt(list[i]); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3375 | } |
| 3376 | return out + "]"; |
| 3377 | } |
| 3378 | |
Ben Clayton | 3ed8ba0 | 2019-04-04 22:01:51 +0100 | [diff] [blame] | 3379 | static std::string addr(const void* ptr) |
| 3380 | { |
| 3381 | char buf[32]; |
| 3382 | snprintf(buf, sizeof(buf), "%p", ptr); |
| 3383 | return buf; |
| 3384 | } |
| 3385 | |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3386 | public: |
| 3387 | const std::string format; |
| 3388 | const std::vector<Value*> values; |
| 3389 | |
| 3390 | // Constructs a PrintValue for the given value. |
| 3391 | template <typename T> |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3392 | PrintValue(const T& v) : format(fmt(v)), values(val(v)) {} |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3393 | |
| 3394 | // Constructs a PrintValue for the given static array. |
| 3395 | template <typename T, int N> |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3396 | PrintValue(const T (&v)[N]) : format(fmt(&v[0], N)), values(val(&v[0], N)) {} |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3397 | |
| 3398 | // Constructs a PrintValue for the given array starting at arr of length |
| 3399 | // len. |
| 3400 | template <typename T> |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3401 | PrintValue(const T* arr, int len) : format(fmt(arr, len)), values(val(arr, len)) {} |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3402 | |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3403 | // PrintValue constructors for plain-old-data values. |
| 3404 | PrintValue(bool v) : format(v ? "true" : "false") {} |
| 3405 | PrintValue(int8_t v) : format(std::to_string(v)) {} |
| 3406 | PrintValue(uint8_t v) : format(std::to_string(v)) {} |
| 3407 | PrintValue(int16_t v) : format(std::to_string(v)) {} |
| 3408 | PrintValue(uint16_t v) : format(std::to_string(v)) {} |
| 3409 | PrintValue(int32_t v) : format(std::to_string(v)) {} |
| 3410 | PrintValue(uint32_t v) : format(std::to_string(v)) {} |
| 3411 | PrintValue(int64_t v) : format(std::to_string(v)) {} |
| 3412 | PrintValue(uint64_t v) : format(std::to_string(v)) {} |
| 3413 | PrintValue(float v) : format(std::to_string(v)) {} |
| 3414 | PrintValue(double v) : format(std::to_string(v)) {} |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3415 | |
Ben Clayton | 3ed8ba0 | 2019-04-04 22:01:51 +0100 | [diff] [blame] | 3416 | template <typename T> |
| 3417 | PrintValue(const T* v) : format(addr(v)) {} |
| 3418 | |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3419 | // vals is a helper to build composite value lists. |
| 3420 | // vals returns the full, sequential list of printf argument values used |
| 3421 | // to print all the provided variadic values. |
| 3422 | // vals() is intended to be used by implementations of |
| 3423 | // PrintValue::Ty<>::vals() to help declare aggregate types. |
| 3424 | // For example, if you were declaring a PrintValue::Ty<> specialization |
| 3425 | // for a custom Mat4x4 matrix formed from four Vector4 values, you'd |
| 3426 | // write: |
| 3427 | // |
| 3428 | // namespace rr |
| 3429 | // { |
| 3430 | // template <> struct PrintValue::Ty<Mat4x4> |
| 3431 | // { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3432 | // static std::string fmt(const Mat4x4& v) |
| 3433 | // { |
| 3434 | // return "[a: <%f, %f, %f, %f>," |
| 3435 | // " b: <%f, %f, %f, %f>," |
| 3436 | // " c: <%f, %f, %f, %f>," |
| 3437 | // " d: <%f, %f, %f, %f>]"; |
| 3438 | // } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3439 | // static std::vector<rr::Value*> val(const Mat4x4& v) |
| 3440 | // { |
| 3441 | // return PrintValue::vals(v.a, v.b, v.c, v.d); |
| 3442 | // } |
| 3443 | // }; |
| 3444 | // } |
| 3445 | template<typename ... ARGS> |
| 3446 | static std::vector<Value*> vals(ARGS... v) |
| 3447 | { |
| 3448 | std::vector< std::vector<Value*> > lists = {val(v)...}; |
| 3449 | std::vector<Value*> joined; |
| 3450 | for (const auto& list : lists) |
| 3451 | { |
| 3452 | joined.insert(joined.end(), list.begin(), list.end()); |
| 3453 | } |
| 3454 | return joined; |
| 3455 | } |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3456 | |
| 3457 | // returns the printf format specifier for the given type via the |
| 3458 | // PrintValue::Ty<T> specialization. |
| 3459 | template <typename T> |
| 3460 | static std::string fmt(const T& v) { return Ty<T>::fmt(v); } |
| 3461 | |
| 3462 | // returns the printf value for the given type with a |
| 3463 | // PrintValue::Ty<T> specialization. |
| 3464 | template <typename T> |
| 3465 | static std::vector<Value*> val(const T& v) { return Ty<T>::val(v); } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3466 | }; |
| 3467 | |
Ben Clayton | bc0cbb9 | 2019-05-15 17:12:57 +0100 | [diff] [blame] | 3468 | // PrintValue::Ty<T> specializations for basic types. |
| 3469 | template <> struct PrintValue::Ty<const char*> |
| 3470 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3471 | static std::string fmt(const char* v) { return "%s"; } |
Ben Clayton | bc0cbb9 | 2019-05-15 17:12:57 +0100 | [diff] [blame] | 3472 | static std::vector<Value*> val(const char* v); |
| 3473 | }; |
| 3474 | template <> struct PrintValue::Ty<std::string> |
| 3475 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3476 | static std::string fmt(const std::string& v) { return PrintValue::Ty<const char*>::fmt(v.c_str()); } |
Ben Clayton | bc0cbb9 | 2019-05-15 17:12:57 +0100 | [diff] [blame] | 3477 | static std::vector<Value*> val(const std::string& v) { return PrintValue::Ty<const char*>::val(v.c_str()); } |
| 3478 | }; |
| 3479 | |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3480 | // PrintValue::Ty<T> specializations for standard Reactor types. |
Ben Clayton | ca56e8b | 2019-03-12 20:05:43 +0000 | [diff] [blame] | 3481 | template <> struct PrintValue::Ty<Bool> |
| 3482 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3483 | static std::string fmt(const RValue<Bool>& v) { return "%d"; } |
Ben Clayton | ca56e8b | 2019-03-12 20:05:43 +0000 | [diff] [blame] | 3484 | static std::vector<Value*> val(const RValue<Bool>& v) { return {v.value}; } |
| 3485 | }; |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3486 | template <> struct PrintValue::Ty<Byte> |
| 3487 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3488 | static std::string fmt(const RValue<Byte>& v) { return "%d"; } |
| 3489 | static std::vector<Value*> val(const RValue<Byte>& v); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3490 | }; |
| 3491 | template <> struct PrintValue::Ty<Byte4> |
| 3492 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3493 | static std::string fmt(const RValue<Byte4>& v) { return "[%d, %d, %d, %d]"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3494 | static std::vector<Value*> val(const RValue<Byte4>& v); |
| 3495 | }; |
| 3496 | template <> struct PrintValue::Ty<Int> |
| 3497 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3498 | static std::string fmt(const RValue<Int>& v) { return "%d"; } |
Ben Clayton | ca8e3d7 | 2019-05-14 16:51:05 +0100 | [diff] [blame] | 3499 | static std::vector<Value*> val(const RValue<Int>& v); |
| 3500 | }; |
| 3501 | template <> struct PrintValue::Ty<Int2> |
| 3502 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3503 | static std::string fmt(const RValue<Int>& v) { return "[%d, %d]"; } |
Ben Clayton | ca8e3d7 | 2019-05-14 16:51:05 +0100 | [diff] [blame] | 3504 | static std::vector<Value*> val(const RValue<Int2>& v); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3505 | }; |
| 3506 | template <> struct PrintValue::Ty<Int4> |
| 3507 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3508 | static std::string fmt(const RValue<Int4>& v) { return "[%d, %d, %d, %d]"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3509 | static std::vector<Value*> val(const RValue<Int4>& v); |
| 3510 | }; |
| 3511 | template <> struct PrintValue::Ty<UInt> |
| 3512 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3513 | static std::string fmt(const RValue<UInt>& v) { return "%u"; } |
Ben Clayton | ca8e3d7 | 2019-05-14 16:51:05 +0100 | [diff] [blame] | 3514 | static std::vector<Value*> val(const RValue<UInt>& v); |
| 3515 | }; |
| 3516 | template <> struct PrintValue::Ty<UInt2> |
| 3517 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3518 | static std::string fmt(const RValue<UInt>& v) { return "[%u, %u]"; } |
Ben Clayton | ca8e3d7 | 2019-05-14 16:51:05 +0100 | [diff] [blame] | 3519 | static std::vector<Value*> val(const RValue<UInt2>& v); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3520 | }; |
| 3521 | template <> struct PrintValue::Ty<UInt4> |
| 3522 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3523 | static std::string fmt(const RValue<UInt4>& v) { return "[%u, %u, %u, %u]"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3524 | static std::vector<Value*> val(const RValue<UInt4>& v); |
| 3525 | }; |
| 3526 | template <> struct PrintValue::Ty<Short> |
| 3527 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3528 | static std::string fmt(const RValue<Short>& v) { return "%d"; } |
| 3529 | static std::vector<Value*> val(const RValue<Short>& v); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3530 | }; |
| 3531 | template <> struct PrintValue::Ty<Short4> |
| 3532 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3533 | static std::string fmt(const RValue<Short4>& v) { return "[%d, %d, %d, %d]"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3534 | static std::vector<Value*> val(const RValue<Short4>& v); |
| 3535 | }; |
| 3536 | template <> struct PrintValue::Ty<UShort> |
| 3537 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3538 | static std::string fmt(const RValue<UShort>& v) { return "%u"; } |
| 3539 | static std::vector<Value*> val(const RValue<UShort>& v); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3540 | }; |
| 3541 | template <> struct PrintValue::Ty<UShort4> |
| 3542 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3543 | static std::string fmt(const RValue<UShort4>& v) { return "[%u, %u, %u, %u]"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3544 | static std::vector<Value*> val(const RValue<UShort4>& v); |
| 3545 | }; |
| 3546 | template <> struct PrintValue::Ty<Float> |
| 3547 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3548 | static std::string fmt(const RValue<Float>& v) { return "[%f]"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3549 | static std::vector<Value*> val(const RValue<Float>& v); |
| 3550 | }; |
| 3551 | template <> struct PrintValue::Ty<Float4> |
| 3552 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3553 | static std::string fmt(const RValue<Float4>& v) { return "[%f, %f, %f, %f]"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3554 | static std::vector<Value*> val(const RValue<Float4>& v); |
| 3555 | }; |
Ben Clayton | 7945a51 | 2019-04-15 23:00:43 -0400 | [diff] [blame] | 3556 | template <> struct PrintValue::Ty<Long> |
| 3557 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3558 | static std::string fmt(const RValue<Long>& v) { return "%lld"; } |
Ben Clayton | 7945a51 | 2019-04-15 23:00:43 -0400 | [diff] [blame] | 3559 | static std::vector<Value*> val(const RValue<Long>& v) { return {v.value}; } |
| 3560 | }; |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3561 | template <typename T> struct PrintValue::Ty< Pointer<T> > |
| 3562 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3563 | static std::string fmt(const RValue<Pointer<T>>& v) { return "%p"; } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3564 | static std::vector<Value*> val(const RValue<Pointer<T>>& v) { return {v.value}; } |
| 3565 | }; |
| 3566 | template <typename T> struct PrintValue::Ty< Reference<T> > |
| 3567 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3568 | static std::string fmt(const Reference<T>& v) { return PrintValue::Ty<T>::fmt(v); } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3569 | static std::vector<Value*> val(const Reference<T>& v) { return PrintValue::Ty<T>::val(v); } |
| 3570 | }; |
| 3571 | template <typename T> struct PrintValue::Ty< RValue<T> > |
| 3572 | { |
Ben Clayton | a683328 | 2019-05-28 17:15:02 +0100 | [diff] [blame] | 3573 | static std::string fmt(const RValue<T>& v) { return PrintValue::Ty<T>::fmt(v); } |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3574 | static std::vector<Value*> val(const RValue<T>& v) { return PrintValue::Ty<T>::val(v); } |
| 3575 | }; |
| 3576 | |
| 3577 | // Printv emits a call to printf() using the function, file and line, |
| 3578 | // message and optional values. |
| 3579 | // See Printv below. |
| 3580 | void Printv(const char* function, const char* file, int line, const char* msg, std::initializer_list<PrintValue> vals); |
| 3581 | |
| 3582 | // Printv emits a call to printf() using the provided message and optional |
| 3583 | // values. |
| 3584 | // Printf replaces any bracketed indices in the message with string |
| 3585 | // representations of the corresponding value in vals. |
| 3586 | // For example: |
| 3587 | // Printv("{0} and {1}", "red", "green"); |
| 3588 | // Would print the string: |
| 3589 | // "red and green" |
| 3590 | // Arguments can be indexed in any order. |
| 3591 | // Invalid indices are not substituted. |
| 3592 | inline void Printv(const char* msg, std::initializer_list<PrintValue> vals) |
| 3593 | { |
| 3594 | Printv(nullptr, nullptr, 0, msg, vals); |
| 3595 | } |
| 3596 | |
| 3597 | // Print is a wrapper over Printv that wraps the variadic arguments into an |
| 3598 | // initializer_list before calling Printv. |
| 3599 | template <typename ... ARGS> |
| 3600 | void Print(const char* msg, const ARGS& ... vals) { Printv(msg, {vals...}); } |
| 3601 | |
| 3602 | // Print is a wrapper over Printv that wraps the variadic arguments into an |
| 3603 | // initializer_list before calling Printv. |
| 3604 | template <typename ... ARGS> |
| 3605 | void Print(const char* function, const char* file, int line, const char* msg, const ARGS& ... vals) |
| 3606 | { |
| 3607 | Printv(function, file, line, msg, {vals...}); |
| 3608 | } |
| 3609 | |
| 3610 | // RR_LOG is a macro that calls Print(), automatically populating the |
| 3611 | // function, file and line parameters and appending a newline to the string. |
| 3612 | // |
| 3613 | // RR_LOG() is intended to be used for debugging JIT compiled code, and is |
| 3614 | // not intended for production use. |
Antonio Maiorano | f448d8e | 2019-04-26 16:19:16 -0400 | [diff] [blame] | 3615 | #if defined(_WIN32) |
Ben Clayton | 68a2901 | 2019-06-23 19:15:45 +0100 | [diff] [blame] | 3616 | #define RR_LOG(msg, ...) Print(__FUNCSIG__, __FILE__, static_cast<int>(__LINE__), msg "\n", ##__VA_ARGS__) |
Antonio Maiorano | f448d8e | 2019-04-26 16:19:16 -0400 | [diff] [blame] | 3617 | #else |
Ben Clayton | 68a2901 | 2019-06-23 19:15:45 +0100 | [diff] [blame] | 3618 | #define RR_LOG(msg, ...) Print(__PRETTY_FUNCTION__, __FILE__, static_cast<int>(__LINE__), msg "\n", ##__VA_ARGS__) |
Antonio Maiorano | f448d8e | 2019-04-26 16:19:16 -0400 | [diff] [blame] | 3619 | #endif |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3620 | |
| 3621 | // Macro magic to perform variadic dispatch. |
| 3622 | // See: https://renenyffenegger.ch/notes/development/languages/C-C-plus-plus/preprocessor/macros/__VA_ARGS__/count-arguments |
| 3623 | // Note, this doesn't attempt to use the ##__VA_ARGS__ trick to handle 0 |
Ben Clayton | 68a2901 | 2019-06-23 19:15:45 +0100 | [diff] [blame] | 3624 | #define RR_MSVC_EXPAND_BUG(X) X // Helper macro to force expanding __VA_ARGS__ to satisfy MSVC compiler. |
| 3625 | #define RR_GET_NTH_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N |
| 3626 | #define RR_COUNT_ARGUMENTS(...) RR_MSVC_EXPAND_BUG(RR_GET_NTH_ARG(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) |
Ben Clayton | 60a3d6f | 2019-02-26 17:24:46 +0000 | [diff] [blame] | 3627 | static_assert(1 == RR_COUNT_ARGUMENTS(a), "RR_COUNT_ARGUMENTS broken"); // Sanity checks. |
| 3628 | static_assert(2 == RR_COUNT_ARGUMENTS(a, b), "RR_COUNT_ARGUMENTS broken"); |
| 3629 | static_assert(3 == RR_COUNT_ARGUMENTS(a, b, c), "RR_COUNT_ARGUMENTS broken"); |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3630 | |
| 3631 | // RR_WATCH_FMT(...) resolves to a string literal that lists all the |
| 3632 | // arguments by name. This string can be passed to LOG() to print each of |
| 3633 | // the arguments with their name and value. |
| 3634 | // |
| 3635 | // RR_WATCH_FMT(...) uses the RR_COUNT_ARGUMENTS helper macro to delegate to a |
| 3636 | // corresponding RR_WATCH_FMT_n specialization macro below. |
| 3637 | #define RR_WATCH_CONCAT(a, b) a ## b |
| 3638 | #define RR_WATCH_CONCAT2(a, b) RR_WATCH_CONCAT(a, b) |
Ben Clayton | 68a2901 | 2019-06-23 19:15:45 +0100 | [diff] [blame] | 3639 | #define RR_WATCH_FMT(...) RR_MSVC_EXPAND_BUG(RR_WATCH_CONCAT2(RR_WATCH_FMT_, RR_COUNT_ARGUMENTS(__VA_ARGS__))(__VA_ARGS__)) |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3640 | #define RR_WATCH_FMT_1(_1) "\n " #_1 ": {0}" |
Ben Clayton | 644a350 | 2019-03-13 11:24:46 +0000 | [diff] [blame] | 3641 | #define RR_WATCH_FMT_2(_1, _2) RR_WATCH_FMT_1(_1) "\n " #_2 ": {1}" |
| 3642 | #define RR_WATCH_FMT_3(_1, _2, _3) RR_WATCH_FMT_2(_1, _2) "\n " #_3 ": {2}" |
| 3643 | #define RR_WATCH_FMT_4(_1, _2, _3, _4) RR_WATCH_FMT_3(_1, _2, _3) "\n " #_4 ": {3}" |
| 3644 | #define RR_WATCH_FMT_5(_1, _2, _3, _4, _5) RR_WATCH_FMT_4(_1, _2, _3, _4) "\n " #_5 ": {4}" |
| 3645 | #define RR_WATCH_FMT_6(_1, _2, _3, _4, _5, _6) RR_WATCH_FMT_5(_1, _2, _3, _4, _5) "\n " #_6 ": {5}" |
| 3646 | #define RR_WATCH_FMT_7(_1, _2, _3, _4, _5, _6, _7) RR_WATCH_FMT_6(_1, _2, _3, _4, _5, _6) "\n " #_7 ": {6}" |
| 3647 | #define RR_WATCH_FMT_8(_1, _2, _3, _4, _5, _6, _7, _8) RR_WATCH_FMT_7(_1, _2, _3, _4, _5, _6, _7) "\n " #_8 ": {7}" |
| 3648 | #define RR_WATCH_FMT_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) RR_WATCH_FMT_8(_1, _2, _3, _4, _5, _6, _7, _8) "\n " #_9 ": {8}" |
| 3649 | #define RR_WATCH_FMT_10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) RR_WATCH_FMT_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) "\n " #_10 ": {9}" |
| 3650 | #define RR_WATCH_FMT_11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) RR_WATCH_FMT_10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) "\n " #_11 ": {10}" |
| 3651 | #define RR_WATCH_FMT_12(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) RR_WATCH_FMT_11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) "\n " #_12 ": {11}" |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 3652 | |
| 3653 | // RR_WATCH() is a helper that prints the name and value of all the supplied |
| 3654 | // arguments. |
| 3655 | // For example, if you had the Int and bool variables 'foo' and 'bar' that |
| 3656 | // you want to print, you can simply write: |
| 3657 | // RR_WATCH(foo, bar) |
| 3658 | // When this JIT compiled code is executed, it will print the string |
| 3659 | // "foo: 1, bar: true" to stdout. |
| 3660 | // |
| 3661 | // RR_WATCH() is intended to be used for debugging JIT compiled code, and |
| 3662 | // is not intended for production use. |
| 3663 | #define RR_WATCH(...) RR_LOG(RR_WATCH_FMT(__VA_ARGS__), __VA_ARGS__) |
| 3664 | #endif // ENABLE_RR_PRINT |
| 3665 | |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3666 | class ForData |
| 3667 | { |
| 3668 | public: |
| 3669 | ForData(bool init) : loopOnce(init) |
| 3670 | { |
| 3671 | } |
| 3672 | |
| 3673 | operator bool() |
| 3674 | { |
| 3675 | return loopOnce; |
| 3676 | } |
| 3677 | |
| 3678 | bool operator=(bool value) |
| 3679 | { |
| 3680 | return loopOnce = value; |
| 3681 | } |
| 3682 | |
| 3683 | bool setup() |
| 3684 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 3685 | RR_DEBUG_INFO_FLUSH(); |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3686 | if(Nucleus::getInsertBlock() != endBB) |
| 3687 | { |
| 3688 | testBB = Nucleus::createBasicBlock(); |
| 3689 | |
| 3690 | Nucleus::createBr(testBB); |
| 3691 | Nucleus::setInsertBlock(testBB); |
| 3692 | |
| 3693 | return true; |
| 3694 | } |
| 3695 | |
| 3696 | return false; |
| 3697 | } |
| 3698 | |
| 3699 | bool test(RValue<Bool> cmp) |
| 3700 | { |
| 3701 | BasicBlock *bodyBB = Nucleus::createBasicBlock(); |
| 3702 | endBB = Nucleus::createBasicBlock(); |
| 3703 | |
| 3704 | Nucleus::createCondBr(cmp.value, bodyBB, endBB); |
| 3705 | Nucleus::setInsertBlock(bodyBB); |
| 3706 | |
| 3707 | return true; |
| 3708 | } |
| 3709 | |
| 3710 | void end() |
| 3711 | { |
| 3712 | Nucleus::createBr(testBB); |
| 3713 | Nucleus::setInsertBlock(endBB); |
| 3714 | } |
| 3715 | |
| 3716 | private: |
| 3717 | BasicBlock *testBB = nullptr; |
| 3718 | BasicBlock *endBB = nullptr; |
| 3719 | bool loopOnce = true; |
| 3720 | }; |
| 3721 | |
| 3722 | class IfElseData |
| 3723 | { |
| 3724 | public: |
| 3725 | IfElseData(RValue<Bool> cmp) : iteration(0) |
| 3726 | { |
| 3727 | condition = cmp.value; |
| 3728 | |
| 3729 | beginBB = Nucleus::getInsertBlock(); |
| 3730 | trueBB = Nucleus::createBasicBlock(); |
| 3731 | falseBB = nullptr; |
| 3732 | endBB = Nucleus::createBasicBlock(); |
| 3733 | |
| 3734 | Nucleus::setInsertBlock(trueBB); |
| 3735 | } |
| 3736 | |
| 3737 | ~IfElseData() |
| 3738 | { |
| 3739 | Nucleus::createBr(endBB); |
| 3740 | |
| 3741 | Nucleus::setInsertBlock(beginBB); |
| 3742 | Nucleus::createCondBr(condition, trueBB, falseBB ? falseBB : endBB); |
| 3743 | |
| 3744 | Nucleus::setInsertBlock(endBB); |
| 3745 | } |
| 3746 | |
| 3747 | operator int() |
| 3748 | { |
| 3749 | return iteration; |
| 3750 | } |
| 3751 | |
| 3752 | IfElseData &operator++() |
| 3753 | { |
| 3754 | ++iteration; |
| 3755 | |
| 3756 | return *this; |
| 3757 | } |
| 3758 | |
| 3759 | void elseClause() |
| 3760 | { |
| 3761 | Nucleus::createBr(endBB); |
| 3762 | |
| 3763 | falseBB = Nucleus::createBasicBlock(); |
| 3764 | Nucleus::setInsertBlock(falseBB); |
| 3765 | } |
| 3766 | |
| 3767 | private: |
| 3768 | Value *condition; |
| 3769 | BasicBlock *beginBB; |
| 3770 | BasicBlock *trueBB; |
| 3771 | BasicBlock *falseBB; |
| 3772 | BasicBlock *endBB; |
| 3773 | int iteration; |
| 3774 | }; |
| 3775 | |
Nicolas Capens | b0eb377 | 2016-10-24 17:49:13 -0400 | [diff] [blame] | 3776 | #define For(init, cond, inc) \ |
Nicolas Capens | 8884a23 | 2016-11-16 15:03:18 -0500 | [diff] [blame] | 3777 | for(ForData for__ = true; for__; for__ = false) \ |
| 3778 | for(init; for__.setup() && for__.test(cond); inc, for__.end()) |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3779 | |
Nicolas Capens | b0eb377 | 2016-10-24 17:49:13 -0400 | [diff] [blame] | 3780 | #define While(cond) For((void)0, cond, (void)0) |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3781 | |
Nicolas Capens | b0eb377 | 2016-10-24 17:49:13 -0400 | [diff] [blame] | 3782 | #define Do \ |
| 3783 | { \ |
| 3784 | BasicBlock *body__ = Nucleus::createBasicBlock(); \ |
| 3785 | Nucleus::createBr(body__); \ |
| 3786 | Nucleus::setInsertBlock(body__); |
| 3787 | |
| 3788 | #define Until(cond) \ |
| 3789 | BasicBlock *end__ = Nucleus::createBasicBlock(); \ |
| 3790 | Nucleus::createCondBr((cond).value, end__, body__); \ |
| 3791 | Nucleus::setInsertBlock(end__); \ |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3792 | } |
| 3793 | |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3794 | enum {IF_BLOCK__, ELSE_CLAUSE__, ELSE_BLOCK__, IFELSE_NUM__}; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3795 | |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3796 | #define If(cond) \ |
| 3797 | for(IfElseData ifElse__(cond); ifElse__ < IFELSE_NUM__; ++ifElse__) \ |
| 3798 | if(ifElse__ == IF_BLOCK__) |
| 3799 | |
| 3800 | #define Else \ |
| 3801 | else if(ifElse__ == ELSE_CLAUSE__) \ |
| 3802 | { \ |
| 3803 | ifElse__.elseClause(); \ |
| 3804 | } \ |
| 3805 | else // ELSE_BLOCK__ |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3806 | } |
| 3807 | |
Ben Clayton | 7e11f46 | 2019-11-18 16:00:31 +0000 | [diff] [blame] | 3808 | #include "Traits.inl" |
| 3809 | |
Nicolas Capens | 4846150 | 2018-08-06 14:20:45 -0400 | [diff] [blame] | 3810 | #endif // rr_Reactor_hpp |