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