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" |
Nicolas Capens | c9991d4 | 2021-06-16 00:46:28 -0400 | [diff] [blame] | 19 | #include "Pragma.hpp" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 20 | #include "Routine.hpp" |
Nicolas Capens | 2e653e5 | 2022-02-23 13:30:13 -0500 | [diff] [blame] | 21 | #include "Swizzle.hpp" |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 22 | #include "Traits.hpp" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 23 | |
Sean Risser | 19e3080 | 2022-06-01 10:58:10 -0400 | [diff] [blame] | 24 | #include <array> |
Nicolas Capens | 4dd1eff | 2017-08-04 09:33:04 -0400 | [diff] [blame] | 25 | #include <cassert> |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 26 | #include <cmath> |
Nicolas Capens | 3bbc5e1 | 2016-09-27 10:49:52 -0400 | [diff] [blame] | 27 | #include <cstddef> |
Chris Forbes | 878d4b0 | 2019-01-21 10:48:35 -0800 | [diff] [blame] | 28 | #include <cstdio> |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 29 | #include <limits> |
Ben Clayton | 169872e | 2019-02-27 23:58:35 +0000 | [diff] [blame] | 30 | #include <tuple> |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 31 | #include <unordered_map> |
Ben Clayton | 1bc7ee9 | 2019-02-14 18:43:22 +0000 | [diff] [blame] | 32 | |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 33 | #ifdef ENABLE_RR_DEBUG_INFO |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 34 | // Functions used for generating JIT debug info. |
| 35 | // See docs/ReactorDebugInfo.md for more information. |
| 36 | namespace rr { |
| 37 | // Update the current source location for debug. |
| 38 | void EmitDebugLocation(); |
| 39 | // Bind value to its symbolic name taken from the backtrace. |
| 40 | void EmitDebugVariable(class Value *value); |
| 41 | // Flush any pending variable bindings before the line ends. |
| 42 | void FlushDebug(); |
| 43 | } // namespace rr |
| 44 | # define RR_DEBUG_INFO_UPDATE_LOC() rr::EmitDebugLocation() |
| 45 | # define RR_DEBUG_INFO_EMIT_VAR(value) rr::EmitDebugVariable(value) |
| 46 | # define RR_DEBUG_INFO_FLUSH() rr::FlushDebug() |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 47 | #else |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 48 | # define RR_DEBUG_INFO_UPDATE_LOC() |
| 49 | # define RR_DEBUG_INFO_EMIT_VAR(value) |
| 50 | # define RR_DEBUG_INFO_FLUSH() |
| 51 | #endif // ENABLE_RR_DEBUG_INFO |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 52 | |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 53 | #ifdef ENABLE_RR_PRINT |
| 54 | namespace rr { |
| 55 | int DebugPrintf(const char *format, ...); |
| 56 | } |
| 57 | #endif |
| 58 | |
Nicolas Capens | 259ce70 | 2020-11-18 11:32:05 -0500 | [diff] [blame] | 59 | // A Clang extension to determine compiler features. |
| 60 | // We use it to detect Sanitizer builds (e.g. -fsanitize=memory). |
| 61 | #ifndef __has_feature |
| 62 | # define __has_feature(x) 0 |
| 63 | #endif |
| 64 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 65 | namespace rr { |
| 66 | |
Nicolas Capens | 70505b4 | 2022-01-31 22:29:48 -0500 | [diff] [blame] | 67 | struct Caps |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 68 | { |
Nicolas Capens | 70505b4 | 2022-01-31 22:29:48 -0500 | [diff] [blame] | 69 | static std::string backendName(); |
| 70 | static bool coroutinesSupported(); // Support for rr::Coroutine<F> |
| 71 | static bool fmaIsFast(); // rr::FMA() is faster than `x * y + z` |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 72 | }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 73 | |
| 74 | class Bool; |
| 75 | class Byte; |
| 76 | class SByte; |
| 77 | class Byte4; |
| 78 | class SByte4; |
| 79 | class Byte8; |
| 80 | class SByte8; |
| 81 | class Byte16; |
| 82 | class SByte16; |
| 83 | class Short; |
| 84 | class UShort; |
| 85 | class Short2; |
| 86 | class UShort2; |
| 87 | class Short4; |
| 88 | class UShort4; |
| 89 | class Short8; |
| 90 | class UShort8; |
| 91 | class Int; |
| 92 | class UInt; |
| 93 | class Int2; |
| 94 | class UInt2; |
| 95 | class Int4; |
| 96 | class UInt4; |
| 97 | class Long; |
| 98 | class Half; |
| 99 | class Float; |
| 100 | class Float2; |
| 101 | class Float4; |
| 102 | |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 103 | namespace SIMD { |
| 104 | class Int; |
| 105 | class UInt; |
| 106 | class Float; |
| 107 | } // namespace SIMD |
| 108 | |
Nicolas Capens | 2e653e5 | 2022-02-23 13:30:13 -0500 | [diff] [blame] | 109 | template<> |
| 110 | struct Scalar<Float4> |
| 111 | { |
| 112 | using Type = Float; |
| 113 | }; |
| 114 | |
| 115 | template<> |
| 116 | struct Scalar<Int4> |
| 117 | { |
| 118 | using Type = Int; |
| 119 | }; |
| 120 | |
| 121 | template<> |
| 122 | struct Scalar<UInt4> |
| 123 | { |
| 124 | using Type = UInt; |
| 125 | }; |
| 126 | |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 127 | template<> |
| 128 | struct Scalar<SIMD::Float> |
| 129 | { |
| 130 | using Type = Float; |
| 131 | }; |
| 132 | |
| 133 | template<> |
| 134 | struct Scalar<SIMD::Int> |
| 135 | { |
| 136 | using Type = Int; |
| 137 | }; |
| 138 | |
| 139 | template<> |
| 140 | struct Scalar<SIMD::UInt> |
| 141 | { |
| 142 | using Type = UInt; |
| 143 | }; |
| 144 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 145 | class Void |
| 146 | { |
| 147 | public: |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 148 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 149 | }; |
Ben Clayton | c790416 | 2019-04-17 17:35:48 -0400 | [diff] [blame] | 150 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 151 | template<class T> |
| 152 | class RValue; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 153 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 154 | template<class T> |
| 155 | class Pointer; |
| 156 | |
| 157 | class Variable |
| 158 | { |
| 159 | friend class Nucleus; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 160 | |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 161 | Variable() = delete; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 162 | Variable &operator=(const Variable &) = delete; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 163 | |
| 164 | public: |
| 165 | void materialize() const; |
| 166 | |
| 167 | Value *loadValue() const; |
| 168 | Value *storeValue(Value *value) const; |
| 169 | |
| 170 | Value *getBaseAddress() const; |
| 171 | Value *getElementPointer(Value *index, bool unsignedIndex) const; |
| 172 | |
Antonio Maiorano | bae138d | 2020-12-02 14:25:10 -0500 | [diff] [blame] | 173 | Type *getType() const { return type; } |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 174 | int getArraySize() const { return arraySize; } |
Nicolas Capens | 67cdce9 | 2020-05-01 21:37:20 -0400 | [diff] [blame] | 175 | |
Antonio Maiorano | 6c839a6 | 2020-11-06 11:19:24 -0500 | [diff] [blame] | 176 | // This function is only public for testing purposes, as it affects performance. |
| 177 | // It is not considered part of Reactor's public API. |
| 178 | static void materializeAll(); |
| 179 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 180 | protected: |
Antonio Maiorano | bae138d | 2020-12-02 14:25:10 -0500 | [diff] [blame] | 181 | Variable(Type *type, int arraySize); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 182 | Variable(const Variable &) = default; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 183 | |
Nicolas Capens | 67cdce9 | 2020-05-01 21:37:20 -0400 | [diff] [blame] | 184 | virtual ~Variable(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 185 | |
| 186 | private: |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 187 | static void killUnmaterialized(); |
| 188 | |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 189 | // Set of variables that do not have a stack location yet. |
| 190 | class UnmaterializedVariables |
| 191 | { |
| 192 | public: |
| 193 | void add(const Variable *v); |
| 194 | void remove(const Variable *v); |
| 195 | void clear(); |
| 196 | void materializeAll(); |
| 197 | |
| 198 | private: |
| 199 | int counter = 0; |
| 200 | std::unordered_map<const Variable *, int> variables; |
| 201 | }; |
| 202 | |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 203 | // This has to be a raw pointer because glibc 2.17 doesn't support __cxa_thread_atexit_impl |
| 204 | // for destructing objects at exit. See crbug.com/1074222 |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 205 | static thread_local UnmaterializedVariables *unmaterializedVariables; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 206 | |
Antonio Maiorano | bae138d | 2020-12-02 14:25:10 -0500 | [diff] [blame] | 207 | Type *const type; |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 208 | const int arraySize; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 209 | mutable Value *rvalue = nullptr; |
| 210 | mutable Value *address = nullptr; |
| 211 | }; |
| 212 | |
| 213 | template<class T> |
| 214 | class LValue : public Variable |
| 215 | { |
| 216 | public: |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 217 | LValue(int arraySize = 0); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 218 | |
| 219 | RValue<Pointer<T>> operator&(); |
| 220 | |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 221 | RValue<T> load() const |
| 222 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 223 | return RValue<T>(this->loadValue()); |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | RValue<T> store(RValue<T> rvalue) const |
| 227 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 228 | this->storeValue(rvalue.value()); |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 229 | |
| 230 | return rvalue; |
| 231 | } |
| 232 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 233 | // self() returns the this pointer to this LValue<T> object. |
| 234 | // This function exists because operator&() is overloaded. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 235 | inline LValue<T> *self() { return this; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 236 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 237 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 238 | template<class T> |
| 239 | class Reference |
| 240 | { |
| 241 | public: |
| 242 | using reference_underlying_type = T; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 243 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 244 | explicit Reference(Value *pointer, int alignment = 1); |
Nicolas Capens | 990e4b2 | 2021-06-17 22:26:36 -0400 | [diff] [blame] | 245 | Reference(const Reference<T> &ref) = default; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 246 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 247 | RValue<T> operator=(RValue<T> rhs) const; |
| 248 | RValue<T> operator=(const Reference<T> &ref) const; |
Nicolas Capens | 5da8d8d | 2019-03-27 14:45:34 -0400 | [diff] [blame] | 249 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 250 | RValue<T> operator+=(RValue<T> rhs) const; |
Nicolas Capens | 5da8d8d | 2019-03-27 14:45:34 -0400 | [diff] [blame] | 251 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 252 | RValue<Pointer<T>> operator&() const { return RValue<Pointer<T>>(address); } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 253 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 254 | Value *loadValue() const; |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 255 | RValue<T> load() const; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 256 | int getAlignment() const; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 257 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 258 | private: |
Nicolas Capens | 990e4b2 | 2021-06-17 22:26:36 -0400 | [diff] [blame] | 259 | Value *const address; |
Nicolas Capens | 5da8d8d | 2019-03-27 14:45:34 -0400 | [diff] [blame] | 260 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 261 | const int alignment; |
| 262 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 263 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 264 | template<class T> |
| 265 | struct BoolLiteral |
| 266 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 267 | struct Type; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 268 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 269 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 270 | template<> |
| 271 | struct BoolLiteral<Bool> |
| 272 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 273 | using Type = bool; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 274 | }; |
Ben Clayton | 83dd452 | 2019-06-27 10:37:00 +0100 | [diff] [blame] | 275 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 276 | template<class T> |
| 277 | struct IntLiteral |
| 278 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 279 | struct Type; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 280 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 281 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 282 | template<> |
| 283 | struct IntLiteral<Int> |
| 284 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 285 | using Type = int; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 286 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 287 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 288 | template<> |
| 289 | struct IntLiteral<UInt> |
| 290 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 291 | using Type = unsigned int; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 292 | }; |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 293 | |
Daniele Vettorel | f908b18 | 2022-02-09 17:38:08 +0000 | [diff] [blame] | 294 | template<class T> |
| 295 | struct LongLiteral |
| 296 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 297 | struct Type; |
Daniele Vettorel | f908b18 | 2022-02-09 17:38:08 +0000 | [diff] [blame] | 298 | }; |
| 299 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 300 | template<> |
Daniele Vettorel | f908b18 | 2022-02-09 17:38:08 +0000 | [diff] [blame] | 301 | struct LongLiteral<Long> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 302 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 303 | using Type = int64_t; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 304 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 305 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 306 | template<class T> |
| 307 | struct FloatLiteral |
| 308 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 309 | struct Type; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 310 | }; |
Nicolas Capens | 297d26e | 2016-11-18 12:52:17 -0500 | [diff] [blame] | 311 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 312 | template<> |
| 313 | struct FloatLiteral<Float> |
| 314 | { |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 315 | using Type = float; |
| 316 | }; |
| 317 | |
| 318 | template<class T> |
| 319 | struct BroadcastLiteral |
| 320 | { |
| 321 | struct Type; |
| 322 | }; |
| 323 | |
| 324 | template<> |
| 325 | struct BroadcastLiteral<Int4> |
| 326 | { |
| 327 | using Type = int; |
| 328 | }; |
| 329 | |
| 330 | template<> |
| 331 | struct BroadcastLiteral<UInt4> |
| 332 | { |
| 333 | using Type = unsigned int; |
| 334 | }; |
| 335 | |
| 336 | template<> |
| 337 | struct BroadcastLiteral<Float4> |
| 338 | { |
| 339 | using Type = float; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 340 | }; |
Ben Clayton | 0953d9b | 2019-06-25 20:57:06 +0100 | [diff] [blame] | 341 | |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 342 | template<> |
| 343 | struct BroadcastLiteral<SIMD::Int> |
| 344 | { |
| 345 | using Type = int; |
| 346 | }; |
| 347 | |
| 348 | template<> |
| 349 | struct BroadcastLiteral<SIMD::UInt> |
| 350 | { |
| 351 | using Type = unsigned int; |
| 352 | }; |
| 353 | |
| 354 | template<> |
| 355 | struct BroadcastLiteral<SIMD::Float> |
| 356 | { |
| 357 | using Type = float; |
| 358 | }; |
| 359 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 360 | template<class T> |
| 361 | class RValue |
| 362 | { |
| 363 | public: |
| 364 | using rvalue_underlying_type = T; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 365 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 366 | explicit RValue(Value *rvalue); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 367 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 368 | RValue(const RValue<T> &rvalue); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 369 | RValue(const T &lvalue); |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 370 | RValue(typename BoolLiteral<T>::Type b); |
| 371 | RValue(typename IntLiteral<T>::Type i); |
| 372 | RValue(typename LongLiteral<T>::Type i); |
| 373 | RValue(typename FloatLiteral<T>::Type f); |
| 374 | RValue(typename BroadcastLiteral<T>::Type x); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 375 | RValue(const Reference<T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 376 | |
Nicolas Capens | 67cdce9 | 2020-05-01 21:37:20 -0400 | [diff] [blame] | 377 | // Rvalues cannot be assigned to: "(a + b) = c;" |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 378 | RValue<T> &operator=(const RValue<T> &) = delete; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 379 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 380 | Value *value() const { return val; } |
| 381 | |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 382 | static int element_count() { return T::element_count(); } |
| 383 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 384 | private: |
| 385 | Value *const val; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 386 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 387 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 388 | template<typename T> |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 389 | class Argument |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 390 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 391 | public: |
| 392 | explicit Argument(Value *val) |
| 393 | : val(val) |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 394 | {} |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 395 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 396 | RValue<T> rvalue() const { return RValue<T>(val); } |
| 397 | |
| 398 | private: |
| 399 | Value *const val; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 400 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 401 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 402 | class Bool : public LValue<Bool> |
| 403 | { |
| 404 | public: |
| 405 | Bool(Argument<Bool> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 406 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 407 | Bool() = default; |
| 408 | Bool(bool x); |
| 409 | Bool(RValue<Bool> rhs); |
| 410 | Bool(const Bool &rhs); |
| 411 | Bool(const Reference<Bool> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 412 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 413 | // RValue<Bool> operator=(bool rhs); // FIXME: Implement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 414 | RValue<Bool> operator=(RValue<Bool> rhs); |
| 415 | RValue<Bool> operator=(const Bool &rhs); |
| 416 | RValue<Bool> operator=(const Reference<Bool> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 417 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 418 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 419 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 420 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 421 | RValue<Bool> operator!(RValue<Bool> val); |
| 422 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs); |
| 423 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs); |
| 424 | RValue<Bool> operator!=(RValue<Bool> lhs, RValue<Bool> rhs); |
| 425 | RValue<Bool> operator==(RValue<Bool> lhs, RValue<Bool> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 426 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 427 | class Byte : public LValue<Byte> |
| 428 | { |
| 429 | public: |
| 430 | Byte(Argument<Byte> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 431 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 432 | explicit Byte(RValue<Int> cast); |
| 433 | explicit Byte(RValue<UInt> cast); |
| 434 | explicit Byte(RValue<UShort> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 435 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 436 | Byte() = default; |
| 437 | Byte(int x); |
| 438 | Byte(unsigned char x); |
| 439 | Byte(RValue<Byte> rhs); |
| 440 | Byte(const Byte &rhs); |
| 441 | Byte(const Reference<Byte> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 442 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 443 | // RValue<Byte> operator=(unsigned char rhs); // FIXME: Implement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 444 | RValue<Byte> operator=(RValue<Byte> rhs); |
| 445 | RValue<Byte> operator=(const Byte &rhs); |
| 446 | RValue<Byte> operator=(const Reference<Byte> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 447 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 448 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 449 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 450 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 451 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs); |
| 452 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs); |
| 453 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs); |
| 454 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs); |
| 455 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs); |
| 456 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs); |
| 457 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs); |
| 458 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs); |
| 459 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs); |
| 460 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs); |
| 461 | RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs); |
| 462 | RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs); |
| 463 | RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs); |
| 464 | RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs); |
| 465 | RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs); |
| 466 | RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs); |
| 467 | RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs); |
| 468 | RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs); |
| 469 | RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs); |
| 470 | RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs); |
| 471 | RValue<Byte> operator+(RValue<Byte> val); |
| 472 | RValue<Byte> operator-(RValue<Byte> val); |
| 473 | RValue<Byte> operator~(RValue<Byte> val); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 474 | RValue<Byte> operator++(Byte &val, int); // Post-increment |
| 475 | const Byte &operator++(Byte &val); // Pre-increment |
| 476 | RValue<Byte> operator--(Byte &val, int); // Post-decrement |
| 477 | const Byte &operator--(Byte &val); // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 478 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs); |
| 479 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs); |
| 480 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs); |
| 481 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs); |
| 482 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs); |
| 483 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 484 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 485 | class SByte : public LValue<SByte> |
| 486 | { |
| 487 | public: |
| 488 | SByte(Argument<SByte> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 489 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 490 | explicit SByte(RValue<Int> cast); |
| 491 | explicit SByte(RValue<Short> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 492 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 493 | SByte() = default; |
| 494 | SByte(signed char x); |
| 495 | SByte(RValue<SByte> rhs); |
| 496 | SByte(const SByte &rhs); |
| 497 | SByte(const Reference<SByte> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 498 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 499 | // RValue<SByte> operator=(signed char rhs); // FIXME: Implement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 500 | RValue<SByte> operator=(RValue<SByte> rhs); |
| 501 | RValue<SByte> operator=(const SByte &rhs); |
| 502 | RValue<SByte> operator=(const Reference<SByte> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 503 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 504 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 505 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 506 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 507 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs); |
| 508 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs); |
| 509 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs); |
| 510 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs); |
| 511 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs); |
| 512 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs); |
| 513 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs); |
| 514 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs); |
| 515 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs); |
| 516 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs); |
| 517 | RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs); |
| 518 | RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs); |
| 519 | RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs); |
| 520 | RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs); |
| 521 | RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs); |
| 522 | RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs); |
| 523 | RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs); |
| 524 | RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs); |
| 525 | RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs); |
| 526 | RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs); |
| 527 | RValue<SByte> operator+(RValue<SByte> val); |
| 528 | RValue<SByte> operator-(RValue<SByte> val); |
| 529 | RValue<SByte> operator~(RValue<SByte> val); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 530 | RValue<SByte> operator++(SByte &val, int); // Post-increment |
| 531 | const SByte &operator++(SByte &val); // Pre-increment |
| 532 | RValue<SByte> operator--(SByte &val, int); // Post-decrement |
| 533 | const SByte &operator--(SByte &val); // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 534 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs); |
| 535 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs); |
| 536 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs); |
| 537 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs); |
| 538 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs); |
| 539 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 540 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 541 | class Short : public LValue<Short> |
| 542 | { |
| 543 | public: |
| 544 | Short(Argument<Short> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 545 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 546 | explicit Short(RValue<Int> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 547 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 548 | Short() = default; |
| 549 | Short(short x); |
| 550 | Short(RValue<Short> rhs); |
| 551 | Short(const Short &rhs); |
| 552 | Short(const Reference<Short> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 553 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 554 | // RValue<Short> operator=(short rhs); // FIXME: Implement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 555 | RValue<Short> operator=(RValue<Short> rhs); |
| 556 | RValue<Short> operator=(const Short &rhs); |
| 557 | RValue<Short> operator=(const Reference<Short> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 558 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 559 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 560 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 561 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 562 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs); |
| 563 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs); |
| 564 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs); |
| 565 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs); |
| 566 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs); |
| 567 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs); |
| 568 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs); |
| 569 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs); |
| 570 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs); |
| 571 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs); |
| 572 | RValue<Short> operator+=(Short &lhs, RValue<Short> rhs); |
| 573 | RValue<Short> operator-=(Short &lhs, RValue<Short> rhs); |
| 574 | RValue<Short> operator*=(Short &lhs, RValue<Short> rhs); |
| 575 | RValue<Short> operator/=(Short &lhs, RValue<Short> rhs); |
| 576 | RValue<Short> operator%=(Short &lhs, RValue<Short> rhs); |
| 577 | RValue<Short> operator&=(Short &lhs, RValue<Short> rhs); |
| 578 | RValue<Short> operator|=(Short &lhs, RValue<Short> rhs); |
| 579 | RValue<Short> operator^=(Short &lhs, RValue<Short> rhs); |
| 580 | RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs); |
| 581 | RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs); |
| 582 | RValue<Short> operator+(RValue<Short> val); |
| 583 | RValue<Short> operator-(RValue<Short> val); |
| 584 | RValue<Short> operator~(RValue<Short> val); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 585 | RValue<Short> operator++(Short &val, int); // Post-increment |
| 586 | const Short &operator++(Short &val); // Pre-increment |
| 587 | RValue<Short> operator--(Short &val, int); // Post-decrement |
| 588 | const Short &operator--(Short &val); // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 589 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs); |
| 590 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs); |
| 591 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs); |
| 592 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs); |
| 593 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs); |
| 594 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 595 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 596 | class UShort : public LValue<UShort> |
| 597 | { |
| 598 | public: |
| 599 | UShort(Argument<UShort> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 600 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 601 | explicit UShort(RValue<UInt> cast); |
| 602 | explicit UShort(RValue<Int> cast); |
Jason Macnak | 341ad7e | 2022-03-16 18:17:57 -0700 | [diff] [blame] | 603 | explicit UShort(RValue<Byte> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 604 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 605 | UShort() = default; |
| 606 | UShort(unsigned short x); |
| 607 | UShort(RValue<UShort> rhs); |
| 608 | UShort(const UShort &rhs); |
| 609 | UShort(const Reference<UShort> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 610 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 611 | // RValue<UShort> operator=(unsigned short rhs); // FIXME: Implement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 612 | RValue<UShort> operator=(RValue<UShort> rhs); |
| 613 | RValue<UShort> operator=(const UShort &rhs); |
| 614 | RValue<UShort> operator=(const Reference<UShort> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 615 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 616 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 617 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 618 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 619 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs); |
| 620 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs); |
| 621 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs); |
| 622 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs); |
| 623 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs); |
| 624 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs); |
| 625 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs); |
| 626 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs); |
| 627 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs); |
| 628 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs); |
| 629 | RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs); |
| 630 | RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs); |
| 631 | RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs); |
| 632 | RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs); |
| 633 | RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs); |
| 634 | RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs); |
| 635 | RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs); |
| 636 | RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs); |
| 637 | RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs); |
| 638 | RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs); |
| 639 | RValue<UShort> operator+(RValue<UShort> val); |
| 640 | RValue<UShort> operator-(RValue<UShort> val); |
| 641 | RValue<UShort> operator~(RValue<UShort> val); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 642 | RValue<UShort> operator++(UShort &val, int); // Post-increment |
| 643 | const UShort &operator++(UShort &val); // Pre-increment |
| 644 | RValue<UShort> operator--(UShort &val, int); // Post-decrement |
| 645 | const UShort &operator--(UShort &val); // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 646 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs); |
| 647 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs); |
| 648 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs); |
| 649 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs); |
| 650 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs); |
| 651 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 652 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 653 | class Byte4 : public LValue<Byte4> |
| 654 | { |
| 655 | public: |
| 656 | explicit Byte4(RValue<Byte8> cast); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 657 | explicit Byte4(RValue<UShort4> cast); |
| 658 | explicit Byte4(RValue<Short4> cast); |
| 659 | explicit Byte4(RValue<UInt4> cast); |
| 660 | explicit Byte4(RValue<Int4> cast); |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 661 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 662 | Byte4() = default; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 663 | // Byte4(int x, int y, int z, int w); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 664 | Byte4(RValue<Byte4> rhs); |
| 665 | Byte4(const Byte4 &rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 666 | Byte4(const Reference<Byte4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 667 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 668 | RValue<Byte4> operator=(RValue<Byte4> rhs); |
| 669 | RValue<Byte4> operator=(const Byte4 &rhs); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 670 | // RValue<Byte4> operator=(const Reference<Byte4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 671 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 672 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 673 | static int element_count() { return 4; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 674 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 675 | |
Jason Macnak | 341ad7e | 2022-03-16 18:17:57 -0700 | [diff] [blame] | 676 | RValue<Byte4> Insert(RValue<Byte4> val, RValue<Byte> element, int i); |
| 677 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 678 | // RValue<Byte4> operator+(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 679 | // RValue<Byte4> operator-(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 680 | // RValue<Byte4> operator*(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 681 | // RValue<Byte4> operator/(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 682 | // RValue<Byte4> operator%(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 683 | // RValue<Byte4> operator&(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 684 | // RValue<Byte4> operator|(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 685 | // RValue<Byte4> operator^(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 686 | // RValue<Byte4> operator<<(RValue<Byte4> lhs, RValue<Byte4> rhs); |
| 687 | // RValue<Byte4> operator>>(RValue<Byte4> lhs, RValue<Byte4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 688 | // RValue<Byte4> operator+=(Byte4 &lhs, RValue<Byte4> rhs); |
| 689 | // RValue<Byte4> operator-=(Byte4 &lhs, RValue<Byte4> rhs); |
| 690 | // RValue<Byte4> operator*=(Byte4 &lhs, RValue<Byte4> rhs); |
| 691 | // RValue<Byte4> operator/=(Byte4 &lhs, RValue<Byte4> rhs); |
| 692 | // RValue<Byte4> operator%=(Byte4 &lhs, RValue<Byte4> rhs); |
| 693 | // RValue<Byte4> operator&=(Byte4 &lhs, RValue<Byte4> rhs); |
| 694 | // RValue<Byte4> operator|=(Byte4 &lhs, RValue<Byte4> rhs); |
| 695 | // RValue<Byte4> operator^=(Byte4 &lhs, RValue<Byte4> rhs); |
| 696 | // RValue<Byte4> operator<<=(Byte4 &lhs, RValue<Byte4> rhs); |
| 697 | // RValue<Byte4> operator>>=(Byte4 &lhs, RValue<Byte4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 698 | // RValue<Byte4> operator+(RValue<Byte4> val); |
| 699 | // RValue<Byte4> operator-(RValue<Byte4> val); |
| 700 | // RValue<Byte4> operator~(RValue<Byte4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 701 | // RValue<Byte4> operator++(Byte4 &val, int); // Post-increment |
| 702 | // const Byte4 &operator++(Byte4 &val); // Pre-increment |
| 703 | // RValue<Byte4> operator--(Byte4 &val, int); // Post-decrement |
| 704 | // const Byte4 &operator--(Byte4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 705 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 706 | class SByte4 : public LValue<SByte4> |
| 707 | { |
| 708 | public: |
| 709 | SByte4() = default; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 710 | // SByte4(int x, int y, int z, int w); |
| 711 | // SByte4(RValue<SByte4> rhs); |
| 712 | // SByte4(const SByte4 &rhs); |
| 713 | // SByte4(const Reference<SByte4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 714 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 715 | // RValue<SByte4> operator=(RValue<SByte4> rhs); |
| 716 | // RValue<SByte4> operator=(const SByte4 &rhs); |
| 717 | // RValue<SByte4> operator=(const Reference<SByte4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 718 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 719 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 720 | static int element_count() { return 4; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 721 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 722 | |
| 723 | // RValue<SByte4> operator+(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 724 | // RValue<SByte4> operator-(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 725 | // RValue<SByte4> operator*(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 726 | // RValue<SByte4> operator/(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 727 | // RValue<SByte4> operator%(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 728 | // RValue<SByte4> operator&(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 729 | // RValue<SByte4> operator|(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 730 | // RValue<SByte4> operator^(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 731 | // RValue<SByte4> operator<<(RValue<SByte4> lhs, RValue<SByte4> rhs); |
| 732 | // RValue<SByte4> operator>>(RValue<SByte4> lhs, RValue<SByte4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 733 | // RValue<SByte4> operator+=(SByte4 &lhs, RValue<SByte4> rhs); |
| 734 | // RValue<SByte4> operator-=(SByte4 &lhs, RValue<SByte4> rhs); |
| 735 | // RValue<SByte4> operator*=(SByte4 &lhs, RValue<SByte4> rhs); |
| 736 | // RValue<SByte4> operator/=(SByte4 &lhs, RValue<SByte4> rhs); |
| 737 | // RValue<SByte4> operator%=(SByte4 &lhs, RValue<SByte4> rhs); |
| 738 | // RValue<SByte4> operator&=(SByte4 &lhs, RValue<SByte4> rhs); |
| 739 | // RValue<SByte4> operator|=(SByte4 &lhs, RValue<SByte4> rhs); |
| 740 | // RValue<SByte4> operator^=(SByte4 &lhs, RValue<SByte4> rhs); |
| 741 | // RValue<SByte4> operator<<=(SByte4 &lhs, RValue<SByte4> rhs); |
| 742 | // RValue<SByte4> operator>>=(SByte4 &lhs, RValue<SByte4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 743 | // RValue<SByte4> operator+(RValue<SByte4> val); |
| 744 | // RValue<SByte4> operator-(RValue<SByte4> val); |
| 745 | // RValue<SByte4> operator~(RValue<SByte4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 746 | // RValue<SByte4> operator++(SByte4 &val, int); // Post-increment |
| 747 | // const SByte4 &operator++(SByte4 &val); // Pre-increment |
| 748 | // RValue<SByte4> operator--(SByte4 &val, int); // Post-decrement |
| 749 | // const SByte4 &operator--(SByte4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 750 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 751 | class Byte8 : public LValue<Byte8> |
| 752 | { |
| 753 | public: |
| 754 | Byte8() = default; |
| 755 | 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); |
| 756 | Byte8(RValue<Byte8> rhs); |
| 757 | Byte8(const Byte8 &rhs); |
| 758 | Byte8(const Reference<Byte8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 759 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 760 | RValue<Byte8> operator=(RValue<Byte8> rhs); |
| 761 | RValue<Byte8> operator=(const Byte8 &rhs); |
| 762 | RValue<Byte8> operator=(const Reference<Byte8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 763 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 764 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 765 | static int element_count() { return 8; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 766 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 767 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 768 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 769 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 770 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 771 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 772 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 773 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 774 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 775 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 776 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, RValue<Byte8> rhs); |
| 777 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, RValue<Byte8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 778 | RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs); |
| 779 | RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 780 | // RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs); |
| 781 | // RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs); |
| 782 | // RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 783 | RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs); |
| 784 | RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs); |
| 785 | RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 786 | // RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs); |
| 787 | // RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 788 | // RValue<Byte8> operator+(RValue<Byte8> val); |
| 789 | // RValue<Byte8> operator-(RValue<Byte8> val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 790 | RValue<Byte8> operator~(RValue<Byte8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 791 | // RValue<Byte8> operator++(Byte8 &val, int); // Post-increment |
| 792 | // const Byte8 &operator++(Byte8 &val); // Pre-increment |
| 793 | // RValue<Byte8> operator--(Byte8 &val, int); // Post-decrement |
| 794 | // const Byte8 &operator--(Byte8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 795 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 796 | RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y); |
| 797 | RValue<Byte8> SubSat(RValue<Byte8> x, RValue<Byte8> y); |
| 798 | RValue<Short4> Unpack(RValue<Byte4> x); |
| 799 | RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y); |
| 800 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y); |
| 801 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y); |
| 802 | RValue<Int> SignMask(RValue<Byte8> x); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 803 | // RValue<Byte8> CmpGT(RValue<Byte8> x, RValue<Byte8> y); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 804 | RValue<Byte8> CmpEQ(RValue<Byte8> x, RValue<Byte8> y); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 805 | RValue<Byte8> Swizzle(RValue<Byte8> x, uint32_t select); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 806 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 807 | class SByte8 : public LValue<SByte8> |
| 808 | { |
| 809 | public: |
| 810 | SByte8() = default; |
| 811 | 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); |
| 812 | SByte8(RValue<SByte8> rhs); |
| 813 | SByte8(const SByte8 &rhs); |
| 814 | SByte8(const Reference<SByte8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 815 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 816 | RValue<SByte8> operator=(RValue<SByte8> rhs); |
| 817 | RValue<SByte8> operator=(const SByte8 &rhs); |
| 818 | RValue<SByte8> operator=(const Reference<SByte8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 819 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 820 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 821 | static int element_count() { return 8; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 822 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 823 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 824 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 825 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 826 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 827 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 828 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 829 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 830 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 831 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 832 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, RValue<SByte8> rhs); |
| 833 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, RValue<SByte8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 834 | RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs); |
| 835 | RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 836 | // RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs); |
| 837 | // RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs); |
| 838 | // RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 839 | RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs); |
| 840 | RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs); |
| 841 | RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 842 | // RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs); |
| 843 | // RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 844 | // RValue<SByte8> operator+(RValue<SByte8> val); |
| 845 | // RValue<SByte8> operator-(RValue<SByte8> val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 846 | RValue<SByte8> operator~(RValue<SByte8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 847 | // RValue<SByte8> operator++(SByte8 &val, int); // Post-increment |
| 848 | // const SByte8 &operator++(SByte8 &val); // Pre-increment |
| 849 | // RValue<SByte8> operator--(SByte8 &val, int); // Post-decrement |
| 850 | // const SByte8 &operator--(SByte8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 851 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 852 | RValue<SByte8> AddSat(RValue<SByte8> x, RValue<SByte8> y); |
| 853 | RValue<SByte8> SubSat(RValue<SByte8> x, RValue<SByte8> y); |
| 854 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y); |
| 855 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y); |
| 856 | RValue<Int> SignMask(RValue<SByte8> x); |
| 857 | RValue<Byte8> CmpGT(RValue<SByte8> x, RValue<SByte8> y); |
| 858 | RValue<Byte8> CmpEQ(RValue<SByte8> x, RValue<SByte8> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 859 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 860 | class Byte16 : public LValue<Byte16> |
| 861 | { |
| 862 | public: |
| 863 | Byte16() = default; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 864 | Byte16(RValue<Byte16> rhs); |
| 865 | Byte16(const Byte16 &rhs); |
| 866 | Byte16(const Reference<Byte16> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 867 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 868 | RValue<Byte16> operator=(RValue<Byte16> rhs); |
| 869 | RValue<Byte16> operator=(const Byte16 &rhs); |
| 870 | RValue<Byte16> operator=(const Reference<Byte16> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 871 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 872 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 873 | static int element_count() { return 16; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 874 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 875 | |
| 876 | // RValue<Byte16> operator+(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 877 | // RValue<Byte16> operator-(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 878 | // RValue<Byte16> operator*(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 879 | // RValue<Byte16> operator/(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 880 | // RValue<Byte16> operator%(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 881 | // RValue<Byte16> operator&(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 882 | // RValue<Byte16> operator|(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 883 | // RValue<Byte16> operator^(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 884 | // RValue<Byte16> operator<<(RValue<Byte16> lhs, RValue<Byte16> rhs); |
| 885 | // RValue<Byte16> operator>>(RValue<Byte16> lhs, RValue<Byte16> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 886 | // RValue<Byte16> operator+=(Byte16 &lhs, RValue<Byte16> rhs); |
| 887 | // RValue<Byte16> operator-=(Byte16 &lhs, RValue<Byte16> rhs); |
| 888 | // RValue<Byte16> operator*=(Byte16 &lhs, RValue<Byte16> rhs); |
| 889 | // RValue<Byte16> operator/=(Byte16 &lhs, RValue<Byte16> rhs); |
| 890 | // RValue<Byte16> operator%=(Byte16 &lhs, RValue<Byte16> rhs); |
| 891 | // RValue<Byte16> operator&=(Byte16 &lhs, RValue<Byte16> rhs); |
| 892 | // RValue<Byte16> operator|=(Byte16 &lhs, RValue<Byte16> rhs); |
| 893 | // RValue<Byte16> operator^=(Byte16 &lhs, RValue<Byte16> rhs); |
| 894 | // RValue<Byte16> operator<<=(Byte16 &lhs, RValue<Byte16> rhs); |
| 895 | // RValue<Byte16> operator>>=(Byte16 &lhs, RValue<Byte16> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 896 | // RValue<Byte16> operator+(RValue<Byte16> val); |
| 897 | // RValue<Byte16> operator-(RValue<Byte16> val); |
| 898 | // RValue<Byte16> operator~(RValue<Byte16> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 899 | // RValue<Byte16> operator++(Byte16 &val, int); // Post-increment |
| 900 | // const Byte16 &operator++(Byte16 &val); // Pre-increment |
| 901 | // RValue<Byte16> operator--(Byte16 &val, int); // Post-decrement |
| 902 | // const Byte16 &operator--(Byte16 &val); // Pre-decrement |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 903 | RValue<Byte16> Swizzle(RValue<Byte16> x, uint64_t select); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 904 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 905 | class SByte16 : public LValue<SByte16> |
| 906 | { |
| 907 | public: |
| 908 | SByte16() = default; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 909 | // SByte16(int x, int y, int z, int w); |
| 910 | // SByte16(RValue<SByte16> rhs); |
| 911 | // SByte16(const SByte16 &rhs); |
| 912 | // SByte16(const Reference<SByte16> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 913 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 914 | // RValue<SByte16> operator=(RValue<SByte16> rhs); |
| 915 | // RValue<SByte16> operator=(const SByte16 &rhs); |
| 916 | // RValue<SByte16> operator=(const Reference<SByte16> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 917 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 918 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 919 | static int element_count() { return 16; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 920 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 921 | |
| 922 | // RValue<SByte16> operator+(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 923 | // RValue<SByte16> operator-(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 924 | // RValue<SByte16> operator*(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 925 | // RValue<SByte16> operator/(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 926 | // RValue<SByte16> operator%(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 927 | // RValue<SByte16> operator&(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 928 | // RValue<SByte16> operator|(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 929 | // RValue<SByte16> operator^(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 930 | // RValue<SByte16> operator<<(RValue<SByte16> lhs, RValue<SByte16> rhs); |
| 931 | // RValue<SByte16> operator>>(RValue<SByte16> lhs, RValue<SByte16> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 932 | // RValue<SByte16> operator+=(SByte16 &lhs, RValue<SByte16> rhs); |
| 933 | // RValue<SByte16> operator-=(SByte16 &lhs, RValue<SByte16> rhs); |
| 934 | // RValue<SByte16> operator*=(SByte16 &lhs, RValue<SByte16> rhs); |
| 935 | // RValue<SByte16> operator/=(SByte16 &lhs, RValue<SByte16> rhs); |
| 936 | // RValue<SByte16> operator%=(SByte16 &lhs, RValue<SByte16> rhs); |
| 937 | // RValue<SByte16> operator&=(SByte16 &lhs, RValue<SByte16> rhs); |
| 938 | // RValue<SByte16> operator|=(SByte16 &lhs, RValue<SByte16> rhs); |
| 939 | // RValue<SByte16> operator^=(SByte16 &lhs, RValue<SByte16> rhs); |
| 940 | // RValue<SByte16> operator<<=(SByte16 &lhs, RValue<SByte16> rhs); |
| 941 | // RValue<SByte16> operator>>=(SByte16 &lhs, RValue<SByte16> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 942 | // RValue<SByte16> operator+(RValue<SByte16> val); |
| 943 | // RValue<SByte16> operator-(RValue<SByte16> val); |
| 944 | // RValue<SByte16> operator~(RValue<SByte16> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 945 | // RValue<SByte16> operator++(SByte16 &val, int); // Post-increment |
| 946 | // const SByte16 &operator++(SByte16 &val); // Pre-increment |
| 947 | // RValue<SByte16> operator--(SByte16 &val, int); // Post-decrement |
| 948 | // const SByte16 &operator--(SByte16 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 949 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 950 | class Short2 : public LValue<Short2> |
| 951 | { |
| 952 | public: |
| 953 | explicit Short2(RValue<Short4> cast); |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 954 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 955 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 956 | static int element_count() { return 2; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 957 | }; |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 958 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 959 | class UShort2 : public LValue<UShort2> |
| 960 | { |
| 961 | public: |
| 962 | explicit UShort2(RValue<UShort4> cast); |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 963 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 964 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 965 | static int element_count() { return 2; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 966 | }; |
Nicolas Capens | 16b5f15 | 2016-10-13 13:39:01 -0400 | [diff] [blame] | 967 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 968 | class Short4 : public LValue<Short4> |
| 969 | { |
| 970 | public: |
| 971 | explicit Short4(RValue<Int> cast); |
| 972 | explicit Short4(RValue<Int4> cast); |
Nicolas Capens | 7119686 | 2022-01-06 21:31:57 -0500 | [diff] [blame] | 973 | explicit Short4(RValue<UInt4> cast); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 974 | // explicit Short4(RValue<Float> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 975 | explicit Short4(RValue<Float4> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 976 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 977 | Short4() = default; |
| 978 | Short4(short xyzw); |
| 979 | Short4(short x, short y, short z, short w); |
| 980 | Short4(RValue<Short4> rhs); |
| 981 | Short4(const Short4 &rhs); |
| 982 | Short4(const Reference<Short4> &rhs); |
| 983 | Short4(RValue<UShort4> rhs); |
| 984 | Short4(const UShort4 &rhs); |
| 985 | Short4(const Reference<UShort4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 986 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 987 | RValue<Short4> operator=(RValue<Short4> rhs); |
| 988 | RValue<Short4> operator=(const Short4 &rhs); |
| 989 | RValue<Short4> operator=(const Reference<Short4> &rhs); |
| 990 | RValue<Short4> operator=(RValue<UShort4> rhs); |
| 991 | RValue<Short4> operator=(const UShort4 &rhs); |
| 992 | RValue<Short4> operator=(const Reference<UShort4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 993 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 994 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 995 | static int element_count() { return 4; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 996 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 997 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 998 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs); |
| 999 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1000 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1001 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1002 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1003 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1004 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1005 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1006 | RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs); |
| 1007 | RValue<Short4> operator>>(RValue<Short4> lhs, unsigned char rhs); |
| 1008 | RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs); |
| 1009 | RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs); |
| 1010 | RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1011 | // RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs); |
| 1012 | // RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1013 | RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs); |
| 1014 | RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs); |
| 1015 | RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs); |
| 1016 | RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs); |
| 1017 | RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1018 | // RValue<Short4> operator+(RValue<Short4> val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1019 | RValue<Short4> operator-(RValue<Short4> val); |
| 1020 | RValue<Short4> operator~(RValue<Short4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1021 | // RValue<Short4> operator++(Short4 &val, int); // Post-increment |
| 1022 | // const Short4 &operator++(Short4 &val); // Pre-increment |
| 1023 | // RValue<Short4> operator--(Short4 &val, int); // Post-decrement |
| 1024 | // const Short4 &operator--(Short4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1025 | // RValue<Bool> operator<(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1026 | // RValue<Bool> operator<=(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1027 | // RValue<Bool> operator>(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1028 | // RValue<Bool> operator>=(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1029 | // RValue<Bool> operator!=(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1030 | // RValue<Bool> operator==(RValue<Short4> lhs, RValue<Short4> rhs); |
| 1031 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1032 | RValue<Short4> RoundShort4(RValue<Float4> cast); |
| 1033 | RValue<Short4> Max(RValue<Short4> x, RValue<Short4> y); |
| 1034 | RValue<Short4> Min(RValue<Short4> x, RValue<Short4> y); |
| 1035 | RValue<Short4> AddSat(RValue<Short4> x, RValue<Short4> y); |
| 1036 | RValue<Short4> SubSat(RValue<Short4> x, RValue<Short4> y); |
| 1037 | RValue<Short4> MulHigh(RValue<Short4> x, RValue<Short4> y); |
| 1038 | RValue<Int2> MulAdd(RValue<Short4> x, RValue<Short4> y); |
| 1039 | RValue<SByte8> PackSigned(RValue<Short4> x, RValue<Short4> y); |
| 1040 | RValue<Byte8> PackUnsigned(RValue<Short4> x, RValue<Short4> y); |
| 1041 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y); |
| 1042 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y); |
| 1043 | RValue<Short4> Swizzle(RValue<Short4> x, uint16_t select); |
| 1044 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i); |
| 1045 | RValue<Short> Extract(RValue<Short4> val, int i); |
| 1046 | RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y); |
| 1047 | RValue<Short4> CmpEQ(RValue<Short4> x, RValue<Short4> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1048 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1049 | class UShort4 : public LValue<UShort4> |
| 1050 | { |
| 1051 | public: |
Nicolas Capens | 7119686 | 2022-01-06 21:31:57 -0500 | [diff] [blame] | 1052 | explicit UShort4(RValue<UInt4> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1053 | explicit UShort4(RValue<Int4> cast); |
| 1054 | explicit UShort4(RValue<Float4> cast, bool saturate = false); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1055 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1056 | UShort4() = default; |
| 1057 | UShort4(unsigned short xyzw); |
| 1058 | UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w); |
| 1059 | UShort4(RValue<UShort4> rhs); |
| 1060 | UShort4(const UShort4 &rhs); |
| 1061 | UShort4(const Reference<UShort4> &rhs); |
| 1062 | UShort4(RValue<Short4> rhs); |
| 1063 | UShort4(const Short4 &rhs); |
| 1064 | UShort4(const Reference<Short4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1065 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1066 | RValue<UShort4> operator=(RValue<UShort4> rhs); |
| 1067 | RValue<UShort4> operator=(const UShort4 &rhs); |
| 1068 | RValue<UShort4> operator=(const Reference<UShort4> &rhs); |
| 1069 | RValue<UShort4> operator=(RValue<Short4> rhs); |
| 1070 | RValue<UShort4> operator=(const Short4 &rhs); |
| 1071 | RValue<UShort4> operator=(const Reference<Short4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1072 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1073 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1074 | static int element_count() { return 4; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1075 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1076 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1077 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 1078 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 1079 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1080 | // RValue<UShort4> operator/(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 1081 | // RValue<UShort4> operator%(RValue<UShort4> lhs, RValue<UShort4> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1082 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 1083 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 1084 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs); |
| 1085 | RValue<UShort4> operator<<(RValue<UShort4> lhs, unsigned char rhs); |
| 1086 | RValue<UShort4> operator>>(RValue<UShort4> lhs, unsigned char rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1087 | // RValue<UShort4> operator+=(UShort4 &lhs, RValue<UShort4> rhs); |
| 1088 | // RValue<UShort4> operator-=(UShort4 &lhs, RValue<UShort4> rhs); |
| 1089 | // RValue<UShort4> operator*=(UShort4 &lhs, RValue<UShort4> rhs); |
| 1090 | // RValue<UShort4> operator/=(UShort4 &lhs, RValue<UShort4> rhs); |
| 1091 | // RValue<UShort4> operator%=(UShort4 &lhs, RValue<UShort4> rhs); |
| 1092 | // RValue<UShort4> operator&=(UShort4 &lhs, RValue<UShort4> rhs); |
| 1093 | // RValue<UShort4> operator|=(UShort4 &lhs, RValue<UShort4> rhs); |
| 1094 | // RValue<UShort4> operator^=(UShort4 &lhs, RValue<UShort4> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1095 | RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs); |
| 1096 | RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1097 | // RValue<UShort4> operator+(RValue<UShort4> val); |
| 1098 | // RValue<UShort4> operator-(RValue<UShort4> val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1099 | RValue<UShort4> operator~(RValue<UShort4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1100 | // RValue<UShort4> operator++(UShort4 &val, int); // Post-increment |
| 1101 | // const UShort4 &operator++(UShort4 &val); // Pre-increment |
| 1102 | // RValue<UShort4> operator--(UShort4 &val, int); // Post-decrement |
| 1103 | // const UShort4 &operator--(UShort4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1104 | |
Jason Macnak | 0587e07 | 2022-02-11 16:49:02 -0800 | [diff] [blame] | 1105 | RValue<UShort4> Insert(RValue<UShort4> val, RValue<UShort> element, int i); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1106 | RValue<UShort4> Max(RValue<UShort4> x, RValue<UShort4> y); |
| 1107 | RValue<UShort4> Min(RValue<UShort4> x, RValue<UShort4> y); |
| 1108 | RValue<UShort4> AddSat(RValue<UShort4> x, RValue<UShort4> y); |
| 1109 | RValue<UShort4> SubSat(RValue<UShort4> x, RValue<UShort4> y); |
| 1110 | RValue<UShort4> MulHigh(RValue<UShort4> x, RValue<UShort4> y); |
| 1111 | RValue<UShort4> Average(RValue<UShort4> x, RValue<UShort4> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1112 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1113 | class Short8 : public LValue<Short8> |
| 1114 | { |
| 1115 | public: |
| 1116 | Short8() = default; |
| 1117 | Short8(short c); |
| 1118 | Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7); |
| 1119 | Short8(RValue<Short8> rhs); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1120 | // Short8(const Short8 &rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1121 | Short8(const Reference<Short8> &rhs); |
| 1122 | Short8(RValue<Short4> lo, RValue<Short4> hi); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1123 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1124 | RValue<Short8> operator=(RValue<Short8> rhs); |
| 1125 | RValue<Short8> operator=(const Short8 &rhs); |
| 1126 | RValue<Short8> operator=(const Reference<Short8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1127 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1128 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1129 | static int element_count() { return 8; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1130 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1131 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1132 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1133 | // RValue<Short8> operator-(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1134 | // RValue<Short8> operator*(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1135 | // RValue<Short8> operator/(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1136 | // RValue<Short8> operator%(RValue<Short8> lhs, RValue<Short8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1137 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1138 | // RValue<Short8> operator|(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1139 | // RValue<Short8> operator^(RValue<Short8> lhs, RValue<Short8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1140 | RValue<Short8> operator<<(RValue<Short8> lhs, unsigned char rhs); |
| 1141 | RValue<Short8> operator>>(RValue<Short8> lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1142 | // RValue<Short8> operator<<(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1143 | // RValue<Short8> operator>>(RValue<Short8> lhs, RValue<Short8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1144 | // RValue<Short8> operator+=(Short8 &lhs, RValue<Short8> rhs); |
| 1145 | // RValue<Short8> operator-=(Short8 &lhs, RValue<Short8> rhs); |
| 1146 | // RValue<Short8> operator*=(Short8 &lhs, RValue<Short8> rhs); |
| 1147 | // RValue<Short8> operator/=(Short8 &lhs, RValue<Short8> rhs); |
| 1148 | // RValue<Short8> operator%=(Short8 &lhs, RValue<Short8> rhs); |
| 1149 | // RValue<Short8> operator&=(Short8 &lhs, RValue<Short8> rhs); |
| 1150 | // RValue<Short8> operator|=(Short8 &lhs, RValue<Short8> rhs); |
| 1151 | // RValue<Short8> operator^=(Short8 &lhs, RValue<Short8> rhs); |
| 1152 | // RValue<Short8> operator<<=(Short8 &lhs, RValue<Short8> rhs); |
| 1153 | // RValue<Short8> operator>>=(Short8 &lhs, RValue<Short8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1154 | // RValue<Short8> operator+(RValue<Short8> val); |
| 1155 | // RValue<Short8> operator-(RValue<Short8> val); |
| 1156 | // RValue<Short8> operator~(RValue<Short8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1157 | // RValue<Short8> operator++(Short8 &val, int); // Post-increment |
| 1158 | // const Short8 &operator++(Short8 &val); // Pre-increment |
| 1159 | // RValue<Short8> operator--(Short8 &val, int); // Post-decrement |
| 1160 | // const Short8 &operator--(Short8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1161 | // RValue<Bool> operator<(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1162 | // RValue<Bool> operator<=(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1163 | // RValue<Bool> operator>(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1164 | // RValue<Bool> operator>=(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1165 | // RValue<Bool> operator!=(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1166 | // RValue<Bool> operator==(RValue<Short8> lhs, RValue<Short8> rhs); |
| 1167 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1168 | RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y); |
| 1169 | RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1170 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1171 | class UShort8 : public LValue<UShort8> |
| 1172 | { |
| 1173 | public: |
| 1174 | UShort8() = default; |
| 1175 | UShort8(unsigned short c); |
| 1176 | 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); |
| 1177 | UShort8(RValue<UShort8> rhs); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1178 | // UShort8(const UShort8 &rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1179 | UShort8(const Reference<UShort8> &rhs); |
| 1180 | UShort8(RValue<UShort4> lo, RValue<UShort4> hi); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1181 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1182 | RValue<UShort8> operator=(RValue<UShort8> rhs); |
| 1183 | RValue<UShort8> operator=(const UShort8 &rhs); |
| 1184 | RValue<UShort8> operator=(const Reference<UShort8> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1185 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1186 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1187 | static int element_count() { return 8; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1188 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1189 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1190 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1191 | // RValue<UShort8> operator-(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1192 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1193 | // RValue<UShort8> operator/(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1194 | // RValue<UShort8> operator%(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1195 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1196 | // RValue<UShort8> operator|(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1197 | // RValue<UShort8> operator^(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1198 | RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs); |
| 1199 | RValue<UShort8> operator>>(RValue<UShort8> lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1200 | // RValue<UShort8> operator<<(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1201 | // RValue<UShort8> operator>>(RValue<UShort8> lhs, RValue<UShort8> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1202 | RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1203 | // RValue<UShort8> operator-=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1204 | // RValue<UShort8> operator*=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1205 | // RValue<UShort8> operator/=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1206 | // RValue<UShort8> operator%=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1207 | // RValue<UShort8> operator&=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1208 | // RValue<UShort8> operator|=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1209 | // RValue<UShort8> operator^=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1210 | // RValue<UShort8> operator<<=(UShort8 &lhs, RValue<UShort8> rhs); |
| 1211 | // RValue<UShort8> operator>>=(UShort8 &lhs, RValue<UShort8> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1212 | // RValue<UShort8> operator+(RValue<UShort8> val); |
| 1213 | // RValue<UShort8> operator-(RValue<UShort8> val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1214 | RValue<UShort8> operator~(RValue<UShort8> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1215 | // RValue<UShort8> operator++(UShort8 &val, int); // Post-increment |
| 1216 | // const UShort8 &operator++(UShort8 &val); // Pre-increment |
| 1217 | // RValue<UShort8> operator--(UShort8 &val, int); // Post-decrement |
| 1218 | // const UShort8 &operator--(UShort8 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1219 | // RValue<Bool> operator<(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1220 | // RValue<Bool> operator<=(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1221 | // RValue<Bool> operator>(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1222 | // RValue<Bool> operator>=(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1223 | // RValue<Bool> operator!=(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1224 | // RValue<Bool> operator==(RValue<UShort8> lhs, RValue<UShort8> rhs); |
| 1225 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1226 | RValue<UShort8> Swizzle(RValue<UShort8> x, uint32_t select); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1227 | RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1228 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1229 | class Int : public LValue<Int> |
| 1230 | { |
| 1231 | public: |
| 1232 | Int(Argument<Int> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1233 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1234 | explicit Int(RValue<Byte> cast); |
| 1235 | explicit Int(RValue<SByte> cast); |
| 1236 | explicit Int(RValue<Short> cast); |
| 1237 | explicit Int(RValue<UShort> cast); |
| 1238 | explicit Int(RValue<Int2> cast); |
| 1239 | explicit Int(RValue<Long> cast); |
| 1240 | explicit Int(RValue<Float> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1241 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1242 | Int() = default; |
| 1243 | Int(int x); |
| 1244 | Int(RValue<Int> rhs); |
| 1245 | Int(RValue<UInt> rhs); |
| 1246 | Int(const Int &rhs); |
| 1247 | Int(const UInt &rhs); |
| 1248 | Int(const Reference<Int> &rhs); |
| 1249 | Int(const Reference<UInt> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1250 | |
Nicolas Capens | 6e9eafd | 2022-02-23 13:09:57 -0500 | [diff] [blame] | 1251 | template<int T> |
| 1252 | Int(const SwizzleMask1<Int4, T> &rhs); |
| 1253 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1254 | RValue<Int> operator=(int rhs); |
| 1255 | RValue<Int> operator=(RValue<Int> rhs); |
| 1256 | RValue<Int> operator=(RValue<UInt> rhs); |
| 1257 | RValue<Int> operator=(const Int &rhs); |
| 1258 | RValue<Int> operator=(const UInt &rhs); |
| 1259 | RValue<Int> operator=(const Reference<Int> &rhs); |
| 1260 | RValue<Int> operator=(const Reference<UInt> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1261 | |
Nicolas Capens | 6e9eafd | 2022-02-23 13:09:57 -0500 | [diff] [blame] | 1262 | template<int T> |
| 1263 | RValue<Int> operator=(const SwizzleMask1<Int4, T> &rhs); |
| 1264 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1265 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1266 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1267 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1268 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs); |
| 1269 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs); |
| 1270 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs); |
| 1271 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs); |
| 1272 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs); |
| 1273 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs); |
| 1274 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs); |
| 1275 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs); |
| 1276 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs); |
| 1277 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs); |
| 1278 | RValue<Int> operator+=(Int &lhs, RValue<Int> rhs); |
| 1279 | RValue<Int> operator-=(Int &lhs, RValue<Int> rhs); |
| 1280 | RValue<Int> operator*=(Int &lhs, RValue<Int> rhs); |
| 1281 | RValue<Int> operator/=(Int &lhs, RValue<Int> rhs); |
| 1282 | RValue<Int> operator%=(Int &lhs, RValue<Int> rhs); |
| 1283 | RValue<Int> operator&=(Int &lhs, RValue<Int> rhs); |
| 1284 | RValue<Int> operator|=(Int &lhs, RValue<Int> rhs); |
| 1285 | RValue<Int> operator^=(Int &lhs, RValue<Int> rhs); |
| 1286 | RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs); |
| 1287 | RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs); |
| 1288 | RValue<Int> operator+(RValue<Int> val); |
| 1289 | RValue<Int> operator-(RValue<Int> val); |
| 1290 | RValue<Int> operator~(RValue<Int> val); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1291 | RValue<Int> operator++(Int &val, int); // Post-increment |
| 1292 | const Int &operator++(Int &val); // Pre-increment |
| 1293 | RValue<Int> operator--(Int &val, int); // Post-decrement |
| 1294 | const Int &operator--(Int &val); // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1295 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs); |
| 1296 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs); |
| 1297 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs); |
| 1298 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs); |
| 1299 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs); |
| 1300 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1301 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1302 | RValue<Int> Max(RValue<Int> x, RValue<Int> y); |
| 1303 | RValue<Int> Min(RValue<Int> x, RValue<Int> y); |
| 1304 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max); |
| 1305 | RValue<Int> RoundInt(RValue<Float> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1306 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1307 | class Long : public LValue<Long> |
| 1308 | { |
| 1309 | public: |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1310 | // Long(Argument<Long> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1311 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1312 | // explicit Long(RValue<Short> cast); |
| 1313 | // explicit Long(RValue<UShort> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1314 | explicit Long(RValue<Int> cast); |
| 1315 | explicit Long(RValue<UInt> cast); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1316 | // explicit Long(RValue<Float> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1317 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1318 | Long() = default; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1319 | // Long(qword x); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1320 | Long(RValue<Long> rhs); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1321 | // Long(RValue<ULong> rhs); |
| 1322 | // Long(const Long &rhs); |
| 1323 | // Long(const Reference<Long> &rhs); |
| 1324 | // Long(const ULong &rhs); |
| 1325 | // Long(const Reference<ULong> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1326 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1327 | RValue<Long> operator=(int64_t rhs); |
| 1328 | RValue<Long> operator=(RValue<Long> rhs); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1329 | // RValue<Long> operator=(RValue<ULong> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1330 | RValue<Long> operator=(const Long &rhs); |
| 1331 | RValue<Long> operator=(const Reference<Long> &rhs); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1332 | // RValue<Long> operator=(const ULong &rhs); |
| 1333 | // RValue<Long> operator=(const Reference<ULong> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1334 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1335 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1336 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1337 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1338 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs); |
| 1339 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs); |
| 1340 | RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1341 | // RValue<Long> operator/(RValue<Long> lhs, RValue<Long> rhs); |
| 1342 | // RValue<Long> operator%(RValue<Long> lhs, RValue<Long> rhs); |
| 1343 | // RValue<Long> operator&(RValue<Long> lhs, RValue<Long> rhs); |
| 1344 | // RValue<Long> operator|(RValue<Long> lhs, RValue<Long> rhs); |
| 1345 | // RValue<Long> operator^(RValue<Long> lhs, RValue<Long> rhs); |
| 1346 | // RValue<Long> operator<<(RValue<Long> lhs, RValue<Long> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1347 | RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs); |
| 1348 | RValue<Long> operator+=(Long &lhs, RValue<Long> rhs); |
| 1349 | RValue<Long> operator-=(Long &lhs, RValue<Long> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1350 | // RValue<Long> operator*=(Long &lhs, RValue<Long> rhs); |
| 1351 | // RValue<Long> operator/=(Long &lhs, RValue<Long> rhs); |
| 1352 | // RValue<Long> operator%=(Long &lhs, RValue<Long> rhs); |
| 1353 | // RValue<Long> operator&=(Long &lhs, RValue<Long> rhs); |
| 1354 | // RValue<Long> operator|=(Long &lhs, RValue<Long> rhs); |
| 1355 | // RValue<Long> operator^=(Long &lhs, RValue<Long> rhs); |
| 1356 | // RValue<Long> operator<<=(Long &lhs, RValue<Long> rhs); |
| 1357 | // RValue<Long> operator>>=(Long &lhs, RValue<Long> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1358 | // RValue<Long> operator+(RValue<Long> val); |
| 1359 | // RValue<Long> operator-(RValue<Long> val); |
| 1360 | // RValue<Long> operator~(RValue<Long> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1361 | // RValue<Long> operator++(Long &val, int); // Post-increment |
| 1362 | // const Long &operator++(Long &val); // Pre-increment |
| 1363 | // RValue<Long> operator--(Long &val, int); // Post-decrement |
| 1364 | // const Long &operator--(Long &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1365 | // RValue<Bool> operator<(RValue<Long> lhs, RValue<Long> rhs); |
| 1366 | // RValue<Bool> operator<=(RValue<Long> lhs, RValue<Long> rhs); |
| 1367 | // RValue<Bool> operator>(RValue<Long> lhs, RValue<Long> rhs); |
| 1368 | // RValue<Bool> operator>=(RValue<Long> lhs, RValue<Long> rhs); |
| 1369 | // RValue<Bool> operator!=(RValue<Long> lhs, RValue<Long> rhs); |
| 1370 | // RValue<Bool> operator==(RValue<Long> lhs, RValue<Long> rhs); |
| 1371 | |
| 1372 | // RValue<Long> RoundLong(RValue<Float> cast); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1373 | RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1374 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1375 | class UInt : public LValue<UInt> |
| 1376 | { |
| 1377 | public: |
| 1378 | UInt(Argument<UInt> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1379 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1380 | explicit UInt(RValue<UShort> cast); |
| 1381 | explicit UInt(RValue<Long> cast); |
| 1382 | explicit UInt(RValue<Float> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1383 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1384 | UInt() = default; |
| 1385 | UInt(int x); |
| 1386 | UInt(unsigned int x); |
| 1387 | UInt(RValue<UInt> rhs); |
| 1388 | UInt(RValue<Int> rhs); |
| 1389 | UInt(const UInt &rhs); |
| 1390 | UInt(const Int &rhs); |
| 1391 | UInt(const Reference<UInt> &rhs); |
| 1392 | UInt(const Reference<Int> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1393 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1394 | RValue<UInt> operator=(unsigned int rhs); |
| 1395 | RValue<UInt> operator=(RValue<UInt> rhs); |
| 1396 | RValue<UInt> operator=(RValue<Int> rhs); |
| 1397 | RValue<UInt> operator=(const UInt &rhs); |
| 1398 | RValue<UInt> operator=(const Int &rhs); |
| 1399 | RValue<UInt> operator=(const Reference<UInt> &rhs); |
| 1400 | RValue<UInt> operator=(const Reference<Int> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1401 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1402 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1403 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1404 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1405 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1406 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1407 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1408 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1409 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1410 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1411 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1412 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1413 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1414 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1415 | RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs); |
| 1416 | RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs); |
| 1417 | RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs); |
| 1418 | RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs); |
| 1419 | RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs); |
| 1420 | RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs); |
| 1421 | RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs); |
| 1422 | RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs); |
| 1423 | RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs); |
| 1424 | RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs); |
| 1425 | RValue<UInt> operator+(RValue<UInt> val); |
| 1426 | RValue<UInt> operator-(RValue<UInt> val); |
| 1427 | RValue<UInt> operator~(RValue<UInt> val); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1428 | RValue<UInt> operator++(UInt &val, int); // Post-increment |
| 1429 | const UInt &operator++(UInt &val); // Pre-increment |
| 1430 | RValue<UInt> operator--(UInt &val, int); // Post-decrement |
| 1431 | const UInt &operator--(UInt &val); // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1432 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1433 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1434 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1435 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1436 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs); |
| 1437 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1438 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1439 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y); |
| 1440 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y); |
| 1441 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max); |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 1442 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1443 | RValue<UInt> AddAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1444 | RValue<UInt> SubAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1445 | RValue<UInt> AndAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1446 | RValue<UInt> OrAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1447 | RValue<UInt> XorAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1448 | RValue<Int> MinAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder); |
| 1449 | RValue<Int> MaxAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder); |
| 1450 | RValue<UInt> MinAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1451 | RValue<UInt> MaxAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1452 | RValue<UInt> ExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); |
| 1453 | 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] | 1454 | |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1455 | // RValue<UInt> RoundUInt(RValue<Float> cast); |
| 1456 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1457 | class Int2 : public LValue<Int2> |
| 1458 | { |
| 1459 | public: |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1460 | // explicit Int2(RValue<Int> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1461 | explicit Int2(RValue<Int4> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1462 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1463 | Int2() = default; |
| 1464 | Int2(int x, int y); |
| 1465 | Int2(RValue<Int2> rhs); |
| 1466 | Int2(const Int2 &rhs); |
| 1467 | Int2(const Reference<Int2> &rhs); |
| 1468 | Int2(RValue<Int> lo, RValue<Int> hi); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1469 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1470 | RValue<Int2> operator=(RValue<Int2> rhs); |
| 1471 | RValue<Int2> operator=(const Int2 &rhs); |
| 1472 | RValue<Int2> operator=(const Reference<Int2> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1473 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1474 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1475 | static int element_count() { return 2; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1476 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1477 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1478 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1479 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1480 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1481 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1482 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1483 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1484 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1485 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1486 | RValue<Int2> operator<<(RValue<Int2> lhs, unsigned char rhs); |
| 1487 | RValue<Int2> operator>>(RValue<Int2> lhs, unsigned char rhs); |
| 1488 | RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs); |
| 1489 | RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1490 | // RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs); |
| 1491 | // RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs); |
| 1492 | // RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1493 | RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs); |
| 1494 | RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs); |
| 1495 | RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs); |
| 1496 | RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs); |
| 1497 | RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1498 | // RValue<Int2> operator+(RValue<Int2> val); |
| 1499 | // RValue<Int2> operator-(RValue<Int2> val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1500 | RValue<Int2> operator~(RValue<Int2> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1501 | // RValue<Int2> operator++(Int2 &val, int); // Post-increment |
| 1502 | // const Int2 &operator++(Int2 &val); // Pre-increment |
| 1503 | // RValue<Int2> operator--(Int2 &val, int); // Post-decrement |
| 1504 | // const Int2 &operator--(Int2 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1505 | // RValue<Bool> operator<(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1506 | // RValue<Bool> operator<=(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1507 | // RValue<Bool> operator>(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1508 | // RValue<Bool> operator>=(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1509 | // RValue<Bool> operator!=(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1510 | // RValue<Bool> operator==(RValue<Int2> lhs, RValue<Int2> rhs); |
| 1511 | |
| 1512 | // RValue<Int2> RoundInt(RValue<Float4> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1513 | RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y); |
| 1514 | RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y); |
| 1515 | RValue<Int> Extract(RValue<Int2> val, int i); |
| 1516 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1517 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1518 | class UInt2 : public LValue<UInt2> |
| 1519 | { |
| 1520 | public: |
| 1521 | UInt2() = default; |
| 1522 | UInt2(unsigned int x, unsigned int y); |
| 1523 | UInt2(RValue<UInt2> rhs); |
| 1524 | UInt2(const UInt2 &rhs); |
| 1525 | UInt2(const Reference<UInt2> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1526 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1527 | RValue<UInt2> operator=(RValue<UInt2> rhs); |
| 1528 | RValue<UInt2> operator=(const UInt2 &rhs); |
| 1529 | RValue<UInt2> operator=(const Reference<UInt2> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1530 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1531 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1532 | static int element_count() { return 2; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1533 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1534 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1535 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1536 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1537 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1538 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1539 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1540 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1541 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1542 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1543 | RValue<UInt2> operator<<(RValue<UInt2> lhs, unsigned char rhs); |
| 1544 | RValue<UInt2> operator>>(RValue<UInt2> lhs, unsigned char rhs); |
| 1545 | RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1546 | RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1547 | // RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1548 | // RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1549 | // RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1550 | RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1551 | RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1552 | RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs); |
| 1553 | RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs); |
| 1554 | RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1555 | // RValue<UInt2> operator+(RValue<UInt2> val); |
| 1556 | // RValue<UInt2> operator-(RValue<UInt2> val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1557 | RValue<UInt2> operator~(RValue<UInt2> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1558 | // RValue<UInt2> operator++(UInt2 &val, int); // Post-increment |
| 1559 | // const UInt2 &operator++(UInt2 &val); // Pre-increment |
| 1560 | // RValue<UInt2> operator--(UInt2 &val, int); // Post-decrement |
| 1561 | // const UInt2 &operator--(UInt2 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1562 | // RValue<Bool> operator<(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1563 | // RValue<Bool> operator<=(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1564 | // RValue<Bool> operator>(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1565 | // RValue<Bool> operator>=(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1566 | // RValue<Bool> operator!=(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1567 | // RValue<Bool> operator==(RValue<UInt2> lhs, RValue<UInt2> rhs); |
| 1568 | |
| 1569 | // RValue<UInt2> RoundInt(RValue<Float4> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1570 | RValue<UInt> Extract(RValue<UInt2> val, int i); |
| 1571 | RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1572 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1573 | class Int4 : public LValue<Int4>, public XYZW<Int4> |
| 1574 | { |
| 1575 | public: |
| 1576 | explicit Int4(RValue<Byte4> cast); |
| 1577 | explicit Int4(RValue<SByte4> cast); |
| 1578 | explicit Int4(RValue<Float4> cast); |
| 1579 | explicit Int4(RValue<Short4> cast); |
| 1580 | explicit Int4(RValue<UShort4> cast); |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1581 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1582 | Int4(); |
| 1583 | Int4(int xyzw); |
| 1584 | Int4(int x, int yzw); |
| 1585 | Int4(int x, int y, int zw); |
| 1586 | Int4(int x, int y, int z, int w); |
| 1587 | Int4(RValue<Int4> rhs); |
| 1588 | Int4(const Int4 &rhs); |
| 1589 | Int4(const Reference<Int4> &rhs); |
| 1590 | Int4(RValue<UInt4> rhs); |
| 1591 | Int4(const UInt4 &rhs); |
| 1592 | Int4(const Reference<UInt4> &rhs); |
| 1593 | Int4(RValue<Int2> lo, RValue<Int2> hi); |
| 1594 | Int4(RValue<Int> rhs); |
| 1595 | Int4(const Int &rhs); |
| 1596 | Int4(const Reference<Int> &rhs); |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1597 | |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 1598 | template<int T> |
| 1599 | Int4(const SwizzleMask1<Int4, T> &rhs); |
| 1600 | |
Nicolas Capens | 82d425d | 2022-03-02 16:35:20 -0500 | [diff] [blame] | 1601 | RValue<Int4> operator=(int broadcast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1602 | RValue<Int4> operator=(RValue<Int4> rhs); |
| 1603 | RValue<Int4> operator=(const Int4 &rhs); |
| 1604 | RValue<Int4> operator=(const Reference<Int4> &rhs); |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1605 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1606 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1607 | static int element_count() { return 4; } |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1608 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1609 | private: |
| 1610 | void constant(int x, int y, int z, int w); |
| 1611 | }; |
Nicolas Capens | cb98676 | 2017-01-20 11:34:37 -0500 | [diff] [blame] | 1612 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1613 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1614 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1615 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1616 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1617 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1618 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1619 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1620 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1621 | RValue<Int4> operator<<(RValue<Int4> lhs, unsigned char rhs); |
| 1622 | RValue<Int4> operator>>(RValue<Int4> lhs, unsigned char rhs); |
| 1623 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1624 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1625 | RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs); |
| 1626 | RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs); |
| 1627 | RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1628 | // RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs); |
| 1629 | // RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1630 | RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs); |
| 1631 | RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs); |
| 1632 | RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs); |
| 1633 | RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs); |
| 1634 | RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs); |
| 1635 | RValue<Int4> operator+(RValue<Int4> val); |
| 1636 | RValue<Int4> operator-(RValue<Int4> val); |
| 1637 | RValue<Int4> operator~(RValue<Int4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1638 | // RValue<Int4> operator++(Int4 &val, int); // Post-increment |
| 1639 | // const Int4 &operator++(Int4 &val); // Pre-increment |
| 1640 | // RValue<Int4> operator--(Int4 &val, int); // Post-decrement |
| 1641 | // const Int4 &operator--(Int4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1642 | // RValue<Bool> operator<(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1643 | // RValue<Bool> operator<=(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1644 | // RValue<Bool> operator>(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1645 | // RValue<Bool> operator>=(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1646 | // RValue<Bool> operator!=(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1647 | // RValue<Bool> operator==(RValue<Int4> lhs, RValue<Int4> rhs); |
| 1648 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1649 | RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y); |
| 1650 | RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y); |
| 1651 | RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y); |
| 1652 | RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y); |
| 1653 | RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y); |
| 1654 | RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1655 | inline RValue<Int4> CmpGT(RValue<Int4> x, RValue<Int4> y) |
| 1656 | { |
| 1657 | return CmpNLE(x, y); |
| 1658 | } |
| 1659 | inline RValue<Int4> CmpGE(RValue<Int4> x, RValue<Int4> y) |
| 1660 | { |
| 1661 | return CmpNLT(x, y); |
| 1662 | } |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 1663 | RValue<Int4> Abs(RValue<Int4> x); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1664 | RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y); |
| 1665 | RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y); |
Nicolas Capens | eeb8184 | 2021-01-12 17:44:40 -0500 | [diff] [blame] | 1666 | // Convert to nearest integer. If a converted value is outside of the integer |
| 1667 | // range, the returned result is undefined. |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1668 | RValue<Int4> RoundInt(RValue<Float4> cast); |
Nicolas Capens | eeb8184 | 2021-01-12 17:44:40 -0500 | [diff] [blame] | 1669 | // Rounds to the nearest integer, but clamps very large values to an |
| 1670 | // implementation-dependent range. |
| 1671 | // Specifically, on x86, values larger than 2147483583.0 are converted to |
| 1672 | // 2147483583 (0x7FFFFFBF) instead of producing 0x80000000. |
| 1673 | RValue<Int4> RoundIntClamped(RValue<Float4> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1674 | RValue<Short8> PackSigned(RValue<Int4> x, RValue<Int4> y); |
| 1675 | RValue<UShort8> PackUnsigned(RValue<Int4> x, RValue<Int4> y); |
| 1676 | RValue<Int> Extract(RValue<Int4> val, int i); |
| 1677 | RValue<Int4> Insert(RValue<Int4> val, RValue<Int> element, int i); |
| 1678 | RValue<Int> SignMask(RValue<Int4> x); |
| 1679 | RValue<Int4> Swizzle(RValue<Int4> x, uint16_t select); |
| 1680 | RValue<Int4> Shuffle(RValue<Int4> x, RValue<Int4> y, uint16_t select); |
| 1681 | RValue<Int4> MulHigh(RValue<Int4> x, RValue<Int4> y); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1682 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1683 | class UInt4 : public LValue<UInt4>, public XYZW<UInt4> |
| 1684 | { |
| 1685 | public: |
| 1686 | explicit UInt4(RValue<Float4> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1687 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1688 | UInt4(); |
| 1689 | UInt4(int xyzw); |
| 1690 | UInt4(int x, int yzw); |
| 1691 | UInt4(int x, int y, int zw); |
| 1692 | UInt4(int x, int y, int z, int w); |
| 1693 | UInt4(RValue<UInt4> rhs); |
| 1694 | UInt4(const UInt4 &rhs); |
| 1695 | UInt4(const Reference<UInt4> &rhs); |
| 1696 | UInt4(RValue<Int4> rhs); |
| 1697 | UInt4(const Int4 &rhs); |
| 1698 | UInt4(const Reference<Int4> &rhs); |
| 1699 | UInt4(RValue<UInt2> lo, RValue<UInt2> hi); |
| 1700 | UInt4(RValue<UInt> rhs); |
| 1701 | UInt4(const UInt &rhs); |
| 1702 | UInt4(const Reference<UInt> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1703 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1704 | RValue<UInt4> operator=(RValue<UInt4> rhs); |
| 1705 | RValue<UInt4> operator=(const UInt4 &rhs); |
| 1706 | RValue<UInt4> operator=(const Reference<UInt4> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1707 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1708 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1709 | static int element_count() { return 4; } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1710 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1711 | private: |
| 1712 | void constant(int x, int y, int z, int w); |
| 1713 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1714 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1715 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1716 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1717 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1718 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1719 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1720 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1721 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1722 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1723 | RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs); |
| 1724 | RValue<UInt4> operator>>(RValue<UInt4> lhs, unsigned char rhs); |
| 1725 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1726 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1727 | RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs); |
| 1728 | RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs); |
| 1729 | RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1730 | // RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs); |
| 1731 | // RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1732 | RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs); |
| 1733 | RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs); |
| 1734 | RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs); |
| 1735 | RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs); |
| 1736 | RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs); |
| 1737 | RValue<UInt4> operator+(RValue<UInt4> val); |
| 1738 | RValue<UInt4> operator-(RValue<UInt4> val); |
| 1739 | RValue<UInt4> operator~(RValue<UInt4> val); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1740 | // RValue<UInt4> operator++(UInt4 &val, int); // Post-increment |
| 1741 | // const UInt4 &operator++(UInt4 &val); // Pre-increment |
| 1742 | // RValue<UInt4> operator--(UInt4 &val, int); // Post-decrement |
| 1743 | // const UInt4 &operator--(UInt4 &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1744 | // RValue<Bool> operator<(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1745 | // RValue<Bool> operator<=(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1746 | // RValue<Bool> operator>(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1747 | // RValue<Bool> operator>=(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1748 | // RValue<Bool> operator!=(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1749 | // RValue<Bool> operator==(RValue<UInt4> lhs, RValue<UInt4> rhs); |
| 1750 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1751 | RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y); |
| 1752 | RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y); |
| 1753 | RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y); |
| 1754 | RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y); |
| 1755 | RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y); |
| 1756 | RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1757 | inline RValue<UInt4> CmpGT(RValue<UInt4> x, RValue<UInt4> y) |
| 1758 | { |
| 1759 | return CmpNLE(x, y); |
| 1760 | } |
| 1761 | inline RValue<UInt4> CmpGE(RValue<UInt4> x, RValue<UInt4> y) |
| 1762 | { |
| 1763 | return CmpNLT(x, y); |
| 1764 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1765 | RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y); |
| 1766 | RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y); |
| 1767 | RValue<UInt4> MulHigh(RValue<UInt4> x, RValue<UInt4> y); |
| 1768 | RValue<UInt> Extract(RValue<UInt4> val, int i); |
| 1769 | RValue<UInt4> Insert(RValue<UInt4> val, RValue<UInt> element, int i); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1770 | // RValue<UInt4> RoundInt(RValue<Float4> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1771 | RValue<UInt4> Swizzle(RValue<UInt4> x, uint16_t select); |
| 1772 | RValue<UInt4> Shuffle(RValue<UInt4> x, RValue<UInt4> y, uint16_t select); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1773 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1774 | class Half : public LValue<Half> |
| 1775 | { |
| 1776 | public: |
| 1777 | explicit Half(RValue<Float> cast); |
Alexis Hetu | 734e257 | 2018-12-20 14:00:49 -0500 | [diff] [blame] | 1778 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1779 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1780 | }; |
Alexis Hetu | 734e257 | 2018-12-20 14:00:49 -0500 | [diff] [blame] | 1781 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1782 | class Float : public LValue<Float> |
| 1783 | { |
| 1784 | public: |
| 1785 | explicit Float(RValue<Int> cast); |
| 1786 | explicit Float(RValue<UInt> cast); |
| 1787 | explicit Float(RValue<Half> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1788 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1789 | Float() = default; |
| 1790 | Float(float x); |
| 1791 | Float(RValue<Float> rhs); |
| 1792 | Float(const Float &rhs); |
| 1793 | Float(const Reference<Float> &rhs); |
| 1794 | Float(Argument<Float> argument); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1795 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1796 | template<int T> |
| 1797 | Float(const SwizzleMask1<Float4, T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1798 | |
Nicolas Capens | 0aca3ca | 2020-09-19 23:59:08 -0400 | [diff] [blame] | 1799 | RValue<Float> operator=(float rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1800 | RValue<Float> operator=(RValue<Float> rhs); |
| 1801 | RValue<Float> operator=(const Float &rhs); |
| 1802 | RValue<Float> operator=(const Reference<Float> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1803 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1804 | template<int T> |
| 1805 | RValue<Float> operator=(const SwizzleMask1<Float4, T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1806 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 1807 | static Float infinity(); |
| 1808 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1809 | static Type *type(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1810 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1811 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1812 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs); |
| 1813 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs); |
| 1814 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs); |
| 1815 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs); |
| 1816 | RValue<Float> operator+=(Float &lhs, RValue<Float> rhs); |
| 1817 | RValue<Float> operator-=(Float &lhs, RValue<Float> rhs); |
| 1818 | RValue<Float> operator*=(Float &lhs, RValue<Float> rhs); |
| 1819 | RValue<Float> operator/=(Float &lhs, RValue<Float> rhs); |
| 1820 | RValue<Float> operator+(RValue<Float> val); |
| 1821 | RValue<Float> operator-(RValue<Float> val); |
| 1822 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs); |
| 1823 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs); |
| 1824 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs); |
| 1825 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs); |
| 1826 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs); |
| 1827 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1828 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1829 | RValue<Float> Abs(RValue<Float> x); |
| 1830 | RValue<Float> Max(RValue<Float> x, RValue<Float> y); |
| 1831 | RValue<Float> Min(RValue<Float> x, RValue<Float> y); |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 1832 | RValue<Float> Rcp(RValue<Float> x, bool relaxedPrecision, bool exactAtPow2 = false); |
| 1833 | RValue<Float> RcpSqrt(RValue<Float> x, bool relaxedPrecision); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1834 | RValue<Float> Sqrt(RValue<Float> x); |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 1835 | |
| 1836 | // RValue<Int4> IsInf(RValue<Float> x); |
| 1837 | // RValue<Int4> IsNan(RValue<Float> x); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1838 | RValue<Float> Round(RValue<Float> x); |
| 1839 | RValue<Float> Trunc(RValue<Float> x); |
| 1840 | RValue<Float> Frac(RValue<Float> x); |
| 1841 | RValue<Float> Floor(RValue<Float> x); |
| 1842 | RValue<Float> Ceil(RValue<Float> x); |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 1843 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1844 | // Trigonometric functions |
| 1845 | // TODO: Currently unimplemented for Subzero. |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 1846 | // RValue<Float> Sin(RValue<Float> x); |
| 1847 | // RValue<Float> Cos(RValue<Float> x); |
| 1848 | // RValue<Float> Tan(RValue<Float> x); |
| 1849 | // RValue<Float> Asin(RValue<Float> x); |
| 1850 | // RValue<Float> Acos(RValue<Float> x); |
| 1851 | // RValue<Float> Atan(RValue<Float> x); |
| 1852 | // RValue<Float> Sinh(RValue<Float> x); |
| 1853 | // RValue<Float> Cosh(RValue<Float> x); |
| 1854 | // RValue<Float> Tanh(RValue<Float> x); |
| 1855 | // RValue<Float> Asinh(RValue<Float> x); |
| 1856 | // RValue<Float> Acosh(RValue<Float> x); |
| 1857 | // RValue<Float> Atanh(RValue<Float> x); |
| 1858 | // RValue<Float> Atan2(RValue<Float> x, RValue<Float> y); |
| 1859 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1860 | // Exponential functions |
| 1861 | // TODO: Currently unimplemented for Subzero. |
Nicolas Capens | 88ac367 | 2019-08-01 13:22:34 -0400 | [diff] [blame] | 1862 | // RValue<Float> Pow(RValue<Float> x, RValue<Float> y); |
| 1863 | // RValue<Float> Exp(RValue<Float> x); |
| 1864 | // RValue<Float> Log(RValue<Float> x); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1865 | RValue<Float> Exp2(RValue<Float> x); |
| 1866 | RValue<Float> Log2(RValue<Float> x); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1867 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1868 | class Float2 : public LValue<Float2> |
| 1869 | { |
| 1870 | public: |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1871 | // explicit Float2(RValue<Byte2> cast); |
| 1872 | // explicit Float2(RValue<Short2> cast); |
| 1873 | // explicit Float2(RValue<UShort2> cast); |
| 1874 | // explicit Float2(RValue<Int2> cast); |
| 1875 | // explicit Float2(RValue<UInt2> cast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1876 | explicit Float2(RValue<Float4> cast); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1877 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1878 | Float2() = default; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1879 | // Float2(float x, float y); |
| 1880 | // Float2(RValue<Float2> rhs); |
| 1881 | // Float2(const Float2 &rhs); |
| 1882 | // Float2(const Reference<Float2> &rhs); |
| 1883 | // Float2(RValue<Float> rhs); |
| 1884 | // Float2(const Float &rhs); |
| 1885 | // Float2(const Reference<Float> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1886 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1887 | // template<int T> |
| 1888 | // Float2(const SwizzleMask1<T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1889 | |
Nicolas Capens | 82d425d | 2022-03-02 16:35:20 -0500 | [diff] [blame] | 1890 | // RValue<Float2> operator=(float broadcast); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1891 | // RValue<Float2> operator=(RValue<Float2> rhs); |
| 1892 | // RValue<Float2> operator=(const Float2 &rhs); |
| 1893 | // RValue<Float2> operator=(const Reference<Float2> &rhs); |
| 1894 | // RValue<Float2> operator=(RValue<Float> rhs); |
| 1895 | // RValue<Float2> operator=(const Float &rhs); |
| 1896 | // RValue<Float2> operator=(const Reference<Float> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1897 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1898 | // template<int T> |
| 1899 | // RValue<Float2> operator=(const SwizzleMask1<T> &rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1900 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1901 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1902 | static int element_count() { return 2; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1903 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1904 | |
| 1905 | // RValue<Float2> operator+(RValue<Float2> lhs, RValue<Float2> rhs); |
| 1906 | // RValue<Float2> operator-(RValue<Float2> lhs, RValue<Float2> rhs); |
| 1907 | // RValue<Float2> operator*(RValue<Float2> lhs, RValue<Float2> rhs); |
| 1908 | // RValue<Float2> operator/(RValue<Float2> lhs, RValue<Float2> rhs); |
| 1909 | // RValue<Float2> operator%(RValue<Float2> lhs, RValue<Float2> rhs); |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 1910 | // RValue<Float2> operator+=(Float2 &lhs, RValue<Float2> rhs); |
| 1911 | // RValue<Float2> operator-=(Float2 &lhs, RValue<Float2> rhs); |
| 1912 | // RValue<Float2> operator*=(Float2 &lhs, RValue<Float2> rhs); |
| 1913 | // RValue<Float2> operator/=(Float2 &lhs, RValue<Float2> rhs); |
| 1914 | // RValue<Float2> operator%=(Float2 &lhs, RValue<Float2> rhs); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1915 | // RValue<Float2> operator+(RValue<Float2> val); |
| 1916 | // RValue<Float2> operator-(RValue<Float2> val); |
| 1917 | |
| 1918 | // RValue<Float2> Abs(RValue<Float2> x); |
| 1919 | // RValue<Float2> Max(RValue<Float2> x, RValue<Float2> y); |
| 1920 | // RValue<Float2> Min(RValue<Float2> x, RValue<Float2> y); |
Ben Clayton | 8701dc4 | 2019-12-05 21:27:03 +0000 | [diff] [blame] | 1921 | // RValue<Float2> Swizzle(RValue<Float2> x, uint16_t select); |
| 1922 | // RValue<Float2> Mask(Float2 &lhs, RValue<Float2> rhs, uint16_t select); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 1923 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1924 | class Float4 : public LValue<Float4>, public XYZW<Float4> |
| 1925 | { |
| 1926 | public: |
| 1927 | explicit Float4(RValue<Byte4> cast); |
| 1928 | explicit Float4(RValue<SByte4> cast); |
| 1929 | explicit Float4(RValue<Short4> cast); |
| 1930 | explicit Float4(RValue<UShort4> cast); |
| 1931 | explicit Float4(RValue<Int4> cast); |
| 1932 | explicit Float4(RValue<UInt4> cast); |
| 1933 | |
| 1934 | Float4(); |
| 1935 | Float4(float xyzw); |
| 1936 | Float4(float x, float yzw); |
| 1937 | Float4(float x, float y, float zw); |
| 1938 | Float4(float x, float y, float z, float w); |
| 1939 | Float4(RValue<Float4> rhs); |
| 1940 | Float4(const Float4 &rhs); |
| 1941 | Float4(const Reference<Float4> &rhs); |
| 1942 | Float4(RValue<Float> rhs); |
| 1943 | Float4(const Float &rhs); |
| 1944 | Float4(const Reference<Float> &rhs); |
| 1945 | |
| 1946 | template<int T> |
| 1947 | Float4(const SwizzleMask1<Float4, T> &rhs); |
| 1948 | template<int T> |
| 1949 | Float4(const Swizzle4<Float4, T> &rhs); |
| 1950 | template<int X, int Y> |
| 1951 | Float4(const Swizzle2<Float4, X> &x, const Swizzle2<Float4, Y> &y); |
| 1952 | template<int X, int Y> |
| 1953 | Float4(const SwizzleMask2<Float4, X> &x, const Swizzle2<Float4, Y> &y); |
| 1954 | template<int X, int Y> |
| 1955 | Float4(const Swizzle2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y); |
| 1956 | template<int X, int Y> |
| 1957 | Float4(const SwizzleMask2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y); |
Nicolas Capens | 419b7d7 | 2020-10-02 16:15:34 -0400 | [diff] [blame] | 1958 | Float4(RValue<Float2> lo, RValue<Float2> hi); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1959 | |
Nicolas Capens | 82d425d | 2022-03-02 16:35:20 -0500 | [diff] [blame] | 1960 | RValue<Float4> operator=(float broadcast); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1961 | RValue<Float4> operator=(RValue<Float4> rhs); |
| 1962 | RValue<Float4> operator=(const Float4 &rhs); |
| 1963 | RValue<Float4> operator=(const Reference<Float4> &rhs); |
| 1964 | RValue<Float4> operator=(RValue<Float> rhs); |
| 1965 | RValue<Float4> operator=(const Float &rhs); |
| 1966 | RValue<Float4> operator=(const Reference<Float> &rhs); |
| 1967 | |
| 1968 | template<int T> |
| 1969 | RValue<Float4> operator=(const SwizzleMask1<Float4, T> &rhs); |
| 1970 | template<int T> |
| 1971 | RValue<Float4> operator=(const Swizzle4<Float4, T> &rhs); |
| 1972 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 1973 | static Float4 infinity(); |
| 1974 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1975 | static Type *type(); |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 1976 | static int element_count() { return 4; } |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1977 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1978 | private: |
| 1979 | void constant(float x, float y, float z, float w); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1980 | }; |
| 1981 | |
| 1982 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs); |
| 1983 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs); |
| 1984 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs); |
| 1985 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs); |
| 1986 | RValue<Float4> operator%(RValue<Float4> lhs, RValue<Float4> rhs); |
| 1987 | RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs); |
| 1988 | RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs); |
| 1989 | RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs); |
| 1990 | RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs); |
| 1991 | RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs); |
| 1992 | RValue<Float4> operator+(RValue<Float4> val); |
| 1993 | RValue<Float4> operator-(RValue<Float4> val); |
| 1994 | |
Nicolas Capens | bc74bc2 | 2022-01-26 10:47:00 -0500 | [diff] [blame] | 1995 | // Computes `x * y + z`, which may be fused into one operation to produce a higher-precision result. |
| 1996 | RValue<Float4> MulAdd(RValue<Float4> x, RValue<Float4> y, RValue<Float4> z); |
Nicolas Capens | 75d79f2 | 2022-01-31 17:46:26 -0500 | [diff] [blame] | 1997 | // Computes a fused `x * y + z` operation. Caps::fmaIsFast indicates whether it emits an FMA instruction. |
| 1998 | RValue<Float4> FMA(RValue<Float4> x, RValue<Float4> y, RValue<Float4> z); |
Nicolas Capens | bc74bc2 | 2022-01-26 10:47:00 -0500 | [diff] [blame] | 1999 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2000 | RValue<Float4> Abs(RValue<Float4> x); |
| 2001 | RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y); |
| 2002 | RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y); |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 2003 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 2004 | RValue<Float4> Rcp(RValue<Float4> x, bool relaxedPrecision, bool exactAtPow2 = false); |
| 2005 | RValue<Float4> RcpSqrt(RValue<Float4> x, bool relaxedPrecision); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2006 | RValue<Float4> Sqrt(RValue<Float4> x); |
| 2007 | RValue<Float4> Insert(RValue<Float4> val, RValue<Float> element, int i); |
| 2008 | RValue<Float> Extract(RValue<Float4> x, int i); |
| 2009 | RValue<Float4> Swizzle(RValue<Float4> x, uint16_t select); |
| 2010 | RValue<Float4> Shuffle(RValue<Float4> x, RValue<Float4> y, uint16_t select); |
| 2011 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, uint16_t imm); |
| 2012 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y); |
| 2013 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y); |
| 2014 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, uint16_t select); |
| 2015 | RValue<Int> SignMask(RValue<Float4> x); |
| 2016 | |
| 2017 | // Ordered comparison functions |
| 2018 | RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y); |
| 2019 | RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y); |
| 2020 | RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y); |
| 2021 | RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y); |
| 2022 | RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y); |
| 2023 | RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2024 | inline RValue<Int4> CmpGT(RValue<Float4> x, RValue<Float4> y) |
| 2025 | { |
| 2026 | return CmpNLE(x, y); |
| 2027 | } |
| 2028 | inline RValue<Int4> CmpGE(RValue<Float4> x, RValue<Float4> y) |
| 2029 | { |
| 2030 | return CmpNLT(x, y); |
| 2031 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2032 | |
| 2033 | // Unordered comparison functions |
| 2034 | RValue<Int4> CmpUEQ(RValue<Float4> x, RValue<Float4> y); |
| 2035 | RValue<Int4> CmpULT(RValue<Float4> x, RValue<Float4> y); |
| 2036 | RValue<Int4> CmpULE(RValue<Float4> x, RValue<Float4> y); |
| 2037 | RValue<Int4> CmpUNEQ(RValue<Float4> x, RValue<Float4> y); |
| 2038 | RValue<Int4> CmpUNLT(RValue<Float4> x, RValue<Float4> y); |
| 2039 | RValue<Int4> CmpUNLE(RValue<Float4> x, RValue<Float4> y); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2040 | inline RValue<Int4> CmpUGT(RValue<Float4> x, RValue<Float4> y) |
| 2041 | { |
| 2042 | return CmpUNLE(x, y); |
| 2043 | } |
| 2044 | inline RValue<Int4> CmpUGE(RValue<Float4> x, RValue<Float4> y) |
| 2045 | { |
| 2046 | return CmpUNLT(x, y); |
| 2047 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2048 | |
| 2049 | RValue<Int4> IsInf(RValue<Float4> x); |
| 2050 | RValue<Int4> IsNan(RValue<Float4> x); |
| 2051 | RValue<Float4> Round(RValue<Float4> x); |
| 2052 | RValue<Float4> Trunc(RValue<Float4> x); |
| 2053 | RValue<Float4> Frac(RValue<Float4> x); |
| 2054 | RValue<Float4> Floor(RValue<Float4> x); |
| 2055 | RValue<Float4> Ceil(RValue<Float4> x); |
| 2056 | |
| 2057 | // Trigonometric functions |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2058 | RValue<Float4> Sin(RValue<Float4> x); |
| 2059 | RValue<Float4> Cos(RValue<Float4> x); |
| 2060 | RValue<Float4> Tan(RValue<Float4> x); |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 2061 | RValue<Float4> Asin(RValue<Float4> x); |
| 2062 | RValue<Float4> Acos(RValue<Float4> x); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2063 | RValue<Float4> Atan(RValue<Float4> x); |
| 2064 | RValue<Float4> Sinh(RValue<Float4> x); |
| 2065 | RValue<Float4> Cosh(RValue<Float4> x); |
| 2066 | RValue<Float4> Tanh(RValue<Float4> x); |
| 2067 | RValue<Float4> Asinh(RValue<Float4> x); |
| 2068 | RValue<Float4> Acosh(RValue<Float4> x); |
| 2069 | RValue<Float4> Atanh(RValue<Float4> x); |
| 2070 | RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y); |
| 2071 | |
| 2072 | // Exponential functions |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2073 | RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y); |
| 2074 | RValue<Float4> Exp(RValue<Float4> x); |
| 2075 | RValue<Float4> Log(RValue<Float4> x); |
| 2076 | RValue<Float4> Exp2(RValue<Float4> x); |
| 2077 | RValue<Float4> Log2(RValue<Float4> x); |
| 2078 | |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 2079 | // Call a unary C function on each element of a vector type. |
| 2080 | template<typename Func, typename T> |
| 2081 | inline RValue<T> ScalarizeCall(Func func, const RValue<T> &x) |
| 2082 | { |
| 2083 | T result; |
| 2084 | for(int i = 0; i < T::element_count(); i++) |
| 2085 | { |
| 2086 | result = Insert(result, Call(func, Extract(x, i)), i); |
| 2087 | } |
| 2088 | |
| 2089 | return result; |
| 2090 | } |
| 2091 | |
| 2092 | // Call a binary C function on each element of a vector type. |
| 2093 | template<typename Func, typename T> |
| 2094 | inline RValue<T> ScalarizeCall(Func func, const RValue<T> &x, const RValue<T> &y) |
| 2095 | { |
| 2096 | T result; |
| 2097 | for(int i = 0; i < T::element_count(); i++) |
| 2098 | { |
| 2099 | result = Insert(result, Call(func, Extract(x, i), Extract(y, i)), i); |
| 2100 | } |
| 2101 | |
| 2102 | return result; |
| 2103 | } |
| 2104 | |
| 2105 | // Call a ternary C function on each element of a vector type. |
| 2106 | template<typename Func, typename T> |
| 2107 | inline RValue<T> ScalarizeCall(Func func, const RValue<T> &x, const RValue<T> &y, const RValue<T> &z) |
| 2108 | { |
| 2109 | T result; |
| 2110 | for(int i = 0; i < T::element_count(); i++) |
| 2111 | { |
| 2112 | result = Insert(result, Call(func, Extract(x, i), Extract(y, i), Extract(z, i)), i); |
| 2113 | } |
| 2114 | |
| 2115 | return result; |
| 2116 | } |
| 2117 | |
| 2118 | // Invoke a unary lambda expression on each element of a vector type. |
| 2119 | template<typename Func, typename T> |
| 2120 | inline RValue<T> Scalarize(Func func, const RValue<T> &x) |
| 2121 | { |
| 2122 | T result; |
| 2123 | for(int i = 0; i < T::element_count(); i++) |
| 2124 | { |
| 2125 | result = Insert(result, func(Extract(x, i)), i); |
| 2126 | } |
| 2127 | |
| 2128 | return result; |
| 2129 | } |
| 2130 | |
| 2131 | // Invoke a binary lambda expression on each element of a vector type. |
| 2132 | template<typename Func, typename T> |
| 2133 | inline RValue<T> Scalarize(Func func, const RValue<T> &x, const RValue<T> &y) |
| 2134 | { |
| 2135 | T result; |
| 2136 | for(int i = 0; i < T::element_count(); i++) |
| 2137 | { |
| 2138 | result = Insert(result, func(Extract(x, i), Extract(y, i)), i); |
| 2139 | } |
| 2140 | |
| 2141 | return result; |
| 2142 | } |
| 2143 | |
| 2144 | // Invoke a ternary lambda expression on each element of a vector type. |
| 2145 | template<typename Func, typename T> |
| 2146 | inline RValue<T> Scalarize(Func func, const RValue<T> &x, const RValue<T> &y, const RValue<T> &z) |
| 2147 | { |
| 2148 | T result; |
| 2149 | for(int i = 0; i < T::element_count(); i++) |
| 2150 | { |
| 2151 | result = Insert(result, func(Extract(x, i), Extract(y, i), Extract(z, i)), i); |
| 2152 | } |
| 2153 | |
| 2154 | return result; |
| 2155 | } |
| 2156 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2157 | // Bit Manipulation functions. |
| 2158 | // TODO: Currently unimplemented for Subzero. |
| 2159 | |
| 2160 | // Count leading zeros. |
| 2161 | // Returns 32 when: !isZeroUndef && x == 0. |
| 2162 | // Returns an undefined value when: isZeroUndef && x == 0. |
| 2163 | RValue<UInt> Ctlz(RValue<UInt> x, bool isZeroUndef); |
| 2164 | RValue<UInt4> Ctlz(RValue<UInt4> x, bool isZeroUndef); |
| 2165 | |
| 2166 | // Count trailing zeros. |
| 2167 | // Returns 32 when: !isZeroUndef && x == 0. |
| 2168 | // Returns an undefined value when: isZeroUndef && x == 0. |
| 2169 | RValue<UInt> Cttz(RValue<UInt> x, bool isZeroUndef); |
| 2170 | RValue<UInt4> Cttz(RValue<UInt4> x, bool isZeroUndef); |
| 2171 | |
| 2172 | template<class T> |
| 2173 | class Pointer : public LValue<Pointer<T>> |
| 2174 | { |
| 2175 | public: |
| 2176 | template<class S> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2177 | Pointer(RValue<Pointer<S>> pointerS, int alignment = 1) |
| 2178 | : alignment(alignment) |
Nicolas Capens | a25311a | 2017-01-16 17:19:00 -0500 | [diff] [blame] | 2179 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2180 | Value *pointerT = Nucleus::createBitCast(pointerS.value(), Nucleus::getPointerType(T::type())); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2181 | this->storeValue(pointerT); |
Ben Clayton | 204a410 | 2019-07-31 13:17:47 +0100 | [diff] [blame] | 2182 | } |
| 2183 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2184 | template<class S> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2185 | Pointer(const Pointer<S> &pointer, int alignment = 1) |
| 2186 | : alignment(alignment) |
Nicolas Capens | 86509d9 | 2019-03-21 13:23:50 -0400 | [diff] [blame] | 2187 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2188 | Value *pointerS = pointer.loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2189 | Value *pointerT = Nucleus::createBitCast(pointerS, Nucleus::getPointerType(T::type())); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2190 | this->storeValue(pointerT); |
Nicolas Capens | 86509d9 | 2019-03-21 13:23:50 -0400 | [diff] [blame] | 2191 | } |
| 2192 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2193 | Pointer(Argument<Pointer<T>> argument); |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2194 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2195 | Pointer(); |
| 2196 | Pointer(RValue<Pointer<T>> rhs); |
| 2197 | Pointer(const Pointer<T> &rhs); |
| 2198 | Pointer(const Reference<Pointer<T>> &rhs); |
| 2199 | Pointer(std::nullptr_t); |
Ben Clayton | cb2ebc9 | 2019-06-20 00:18:03 +0100 | [diff] [blame] | 2200 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2201 | RValue<Pointer<T>> operator=(RValue<Pointer<T>> rhs); |
| 2202 | RValue<Pointer<T>> operator=(const Pointer<T> &rhs); |
| 2203 | RValue<Pointer<T>> operator=(const Reference<Pointer<T>> &rhs); |
| 2204 | RValue<Pointer<T>> operator=(std::nullptr_t); |
Ben Clayton | 0fc611f | 2019-04-18 11:23:27 -0400 | [diff] [blame] | 2205 | |
Nicolas Capens | ef72cb4 | 2021-11-12 13:57:14 -0500 | [diff] [blame] | 2206 | Reference<T> operator*() const; |
| 2207 | Reference<T> operator[](int index) const; |
| 2208 | Reference<T> operator[](unsigned int index) const; |
| 2209 | Reference<T> operator[](RValue<Int> index) const; |
| 2210 | Reference<T> operator[](RValue<UInt> index) const; |
Nicolas Capens | 86509d9 | 2019-03-21 13:23:50 -0400 | [diff] [blame] | 2211 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2212 | static Type *type(); |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2213 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2214 | private: |
| 2215 | const int alignment; |
| 2216 | }; |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2217 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2218 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset); |
| 2219 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset); |
| 2220 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset); |
| 2221 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset); |
| 2222 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset); |
| 2223 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset); |
Ben Clayton | 97035bd | 2019-04-16 11:35:38 -0400 | [diff] [blame] | 2224 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2225 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset); |
| 2226 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset); |
| 2227 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset); |
| 2228 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset); |
| 2229 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset); |
| 2230 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2231 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2232 | template<typename T> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2233 | RValue<Bool> operator==(const Pointer<T> &lhs, const Pointer<T> &rhs) |
| 2234 | { |
Nicolas Capens | 8603b12 | 2021-02-12 16:14:18 -0500 | [diff] [blame] | 2235 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.loadValue(), rhs.loadValue())); |
| 2236 | } |
| 2237 | |
| 2238 | template<typename T> |
| 2239 | RValue<Bool> operator!=(const Pointer<T> &lhs, const Pointer<T> &rhs) |
| 2240 | { |
| 2241 | return RValue<Bool>(Nucleus::createICmpNE(lhs.loadValue(), rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2242 | } |
Ben Clayton | 0953d9b | 2019-06-25 20:57:06 +0100 | [diff] [blame] | 2243 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2244 | template<typename T> |
| 2245 | RValue<T> Load(RValue<Pointer<T>> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2246 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2247 | return RValue<T>(Nucleus::createLoad(pointer.value(), T::type(), false, alignment, atomic, memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2248 | } |
| 2249 | |
| 2250 | template<typename T> |
| 2251 | RValue<T> Load(Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2252 | { |
| 2253 | return Load(RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder); |
| 2254 | } |
| 2255 | |
| 2256 | // TODO: Use SIMD to template these. |
Nicolas Capens | e4b7794 | 2021-08-03 17:09:41 -0400 | [diff] [blame] | 2257 | // TODO(b/155867273): These can be undeprecated if implemented for Subzero. |
| 2258 | [[deprecated]] RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); |
| 2259 | [[deprecated]] RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); |
| 2260 | [[deprecated]] void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment); |
| 2261 | [[deprecated]] void MaskedStore(RValue<Pointer<Int4>> base, RValue<Int4> val, RValue<Int4> mask, unsigned int alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2262 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2263 | template<typename T> |
| 2264 | void Store(RValue<T> value, RValue<Pointer<T>> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2265 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2266 | Nucleus::createStore(value.value(), pointer.value(), T::type(), false, alignment, atomic, memoryOrder); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | template<typename T> |
| 2270 | void Store(RValue<T> value, Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2271 | { |
| 2272 | Store(value, RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder); |
| 2273 | } |
| 2274 | |
| 2275 | template<typename T> |
| 2276 | void Store(T value, Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder) |
| 2277 | { |
| 2278 | Store(RValue<T>(value), RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder); |
| 2279 | } |
| 2280 | |
Sean Risser | 19e3080 | 2022-06-01 10:58:10 -0400 | [diff] [blame] | 2281 | enum class OutOfBoundsBehavior |
| 2282 | { |
| 2283 | Nullify, // Loads become zero, stores are elided. |
| 2284 | RobustBufferAccess, // As defined by the Vulkan spec (in short: access anywhere within bounds, or zeroing). |
| 2285 | UndefinedValue, // Only for load operations. Not secure. No program termination. |
| 2286 | UndefinedBehavior, // Program may terminate. |
| 2287 | }; |
| 2288 | |
Sean Risser | 19e3080 | 2022-06-01 10:58:10 -0400 | [diff] [blame] | 2289 | RValue<Bool> AnyTrue(const RValue<Int4> &bools); |
| 2290 | RValue<Bool> AnyFalse(const RValue<Int4> &bools); |
| 2291 | RValue<Bool> AllTrue(const RValue<Int4> &bools); |
| 2292 | RValue<Bool> AllFalse(const RValue<Int4> &bools); |
| 2293 | |
| 2294 | RValue<Bool> Divergent(const RValue<Int4> &ints); |
| 2295 | RValue<Bool> Divergent(const RValue<Float4> &floats); |
| 2296 | RValue<Bool> Uniform(const RValue<Int4> &ints); |
| 2297 | RValue<Bool> Uniform(const RValue<Float4> &floats); |
| 2298 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2299 | // Fence adds a memory barrier that enforces ordering constraints on memory |
| 2300 | // operations. memoryOrder can only be one of: |
| 2301 | // std::memory_order_acquire, std::memory_order_release, |
| 2302 | // std::memory_order_acq_rel, or std::memory_order_seq_cst. |
| 2303 | void Fence(std::memory_order memoryOrder); |
| 2304 | |
| 2305 | template<class T, int S = 1> |
| 2306 | class Array : public LValue<T> |
| 2307 | { |
| 2308 | public: |
| 2309 | Array(int size = S); |
| 2310 | |
| 2311 | Reference<T> operator[](int index); |
| 2312 | Reference<T> operator[](unsigned int index); |
| 2313 | Reference<T> operator[](RValue<Int> index); |
| 2314 | Reference<T> operator[](RValue<UInt> index); |
| 2315 | |
| 2316 | // self() returns the this pointer to this Array object. |
| 2317 | // This function exists because operator&() is overloaded by LValue<T>. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2318 | inline Array *self() { return this; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2319 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2320 | |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2321 | // RValue<Array<T>> operator++(Array<T> &val, int); // Post-increment |
| 2322 | // const Array<T> &operator++(Array<T> &val); // Pre-increment |
| 2323 | // RValue<Array<T>> operator--(Array<T> &val, int); // Post-decrement |
| 2324 | // const Array<T> &operator--(Array<T> &val); // Pre-decrement |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2325 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2326 | void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2327 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2328 | // ValueOf returns a rr::Value* for the given C-type, RValue<T>, LValue<T> |
| 2329 | // or Reference<T>. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2330 | template<typename T> |
| 2331 | inline Value *ValueOf(const T &v) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2332 | { |
| 2333 | return ReactorType<T>::cast(v).loadValue(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2334 | } |
| 2335 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2336 | void Return(); |
| 2337 | |
| 2338 | template<class T> |
| 2339 | void Return(const T &ret) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2340 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2341 | static_assert(CanBeUsedAsReturn<ReactorTypeT<T>>::value, "Unsupported type for Return()"); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2342 | Nucleus::createRet(ValueOf<T>(ret)); |
| 2343 | // Place any unreachable instructions in an unreferenced block. |
| 2344 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 2345 | } |
| 2346 | |
| 2347 | // Generic template, leave undefined! |
| 2348 | template<typename FunctionType> |
| 2349 | class Function; |
| 2350 | |
| 2351 | // Specialized for function types |
| 2352 | template<typename Return, typename... Arguments> |
| 2353 | class Function<Return(Arguments...)> |
| 2354 | { |
| 2355 | // Static assert that the function signature is valid. |
| 2356 | static_assert(sizeof(AssertFunctionSignatureIsValid<Return(Arguments...)>) >= 0, "Invalid function signature"); |
| 2357 | |
| 2358 | public: |
| 2359 | Function(); |
| 2360 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2361 | template<int index> |
| 2362 | Argument<typename std::tuple_element<index, std::tuple<Arguments...>>::type> Arg() const |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2363 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2364 | Value *arg = Nucleus::getArgument(index); |
| 2365 | return Argument<typename std::tuple_element<index, std::tuple<Arguments...>>::type>(arg); |
| 2366 | } |
| 2367 | |
| 2368 | std::shared_ptr<Routine> operator()(const char *name, ...); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2369 | |
| 2370 | protected: |
Nicolas Capens | 3d26cfc | 2021-01-22 16:51:00 -0500 | [diff] [blame] | 2371 | std::unique_ptr<Nucleus> core; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2372 | std::vector<Type *> arguments; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2373 | }; |
| 2374 | |
| 2375 | template<typename Return> |
| 2376 | class Function<Return()> : public Function<Return(Void)> |
| 2377 | { |
| 2378 | }; |
| 2379 | |
| 2380 | // FunctionT accepts a C-style function type template argument, allowing it to return a type-safe RoutineT wrapper |
| 2381 | template<typename FunctionType> |
| 2382 | class FunctionT; |
| 2383 | |
| 2384 | template<typename Return, typename... Arguments> |
| 2385 | class FunctionT<Return(Arguments...)> : public Function<CToReactorT<Return>(CToReactorT<Arguments>...)> |
| 2386 | { |
| 2387 | public: |
| 2388 | // Type of base class |
| 2389 | using BaseType = Function<CToReactorT<Return>(CToReactorT<Arguments>...)>; |
| 2390 | |
| 2391 | // Function type, e.g. void(int,float) |
| 2392 | using CFunctionType = Return(Arguments...); |
| 2393 | |
| 2394 | // Reactor function type, e.g. Void(Int, Float) |
| 2395 | using ReactorFunctionType = CToReactorT<Return>(CToReactorT<Arguments>...); |
| 2396 | |
| 2397 | // Returned RoutineT type |
| 2398 | using RoutineType = RoutineT<CFunctionType>; |
| 2399 | |
| 2400 | // Hide base implementations of operator() |
| 2401 | |
Antonio Maiorano | 9ff8066 | 2020-11-27 13:51:35 -0500 | [diff] [blame] | 2402 | template<typename... VarArgs> |
| 2403 | RoutineType operator()(const char *name, VarArgs... varArgs) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2404 | { |
Antonio Maiorano | 9ff8066 | 2020-11-27 13:51:35 -0500 | [diff] [blame] | 2405 | return RoutineType(BaseType::operator()(name, std::forward<VarArgs>(varArgs)...)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2406 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2407 | }; |
| 2408 | |
| 2409 | RValue<Long> Ticks(); |
| 2410 | |
| 2411 | } // namespace rr |
| 2412 | |
| 2413 | /* Inline implementations */ |
| 2414 | |
| 2415 | namespace rr { |
| 2416 | |
| 2417 | template<class T> |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 2418 | LValue<T>::LValue(int arraySize) |
Antonio Maiorano | bae138d | 2020-12-02 14:25:10 -0500 | [diff] [blame] | 2419 | : Variable(T::type(), arraySize) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2420 | { |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2421 | #ifdef ENABLE_RR_DEBUG_INFO |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2422 | materialize(); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2423 | #endif // ENABLE_RR_DEBUG_INFO |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2424 | } |
Nicolas Capens | 22479eb | 2016-09-28 22:34:26 -0400 | [diff] [blame] | 2425 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2426 | template<class T> |
| 2427 | RValue<Pointer<T>> LValue<T>::operator&() |
| 2428 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2429 | return RValue<Pointer<T>>(this->getBaseAddress()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2430 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2431 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2432 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2433 | Reference<T>::Reference(Value *pointer, int alignment) |
Nicolas Capens | 990e4b2 | 2021-06-17 22:26:36 -0400 | [diff] [blame] | 2434 | : address(pointer) |
| 2435 | , alignment(alignment) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2436 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2437 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2438 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2439 | template<class T> |
| 2440 | RValue<T> Reference<T>::operator=(RValue<T> rhs) const |
| 2441 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2442 | Nucleus::createStore(rhs.value(), address, T::type(), false, alignment); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2443 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2444 | return rhs; |
| 2445 | } |
| 2446 | |
| 2447 | template<class T> |
| 2448 | RValue<T> Reference<T>::operator=(const Reference<T> &ref) const |
| 2449 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2450 | Value *tmp = Nucleus::createLoad(ref.address, T::type(), false, ref.alignment); |
| 2451 | Nucleus::createStore(tmp, address, T::type(), false, alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2452 | |
| 2453 | return RValue<T>(tmp); |
| 2454 | } |
| 2455 | |
| 2456 | template<class T> |
| 2457 | RValue<T> Reference<T>::operator+=(RValue<T> rhs) const |
| 2458 | { |
| 2459 | return *this = *this + rhs; |
| 2460 | } |
| 2461 | |
| 2462 | template<class T> |
| 2463 | Value *Reference<T>::loadValue() const |
| 2464 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2465 | return Nucleus::createLoad(address, T::type(), false, alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2466 | } |
| 2467 | |
| 2468 | template<class T> |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2469 | RValue<T> Reference<T>::load() const |
| 2470 | { |
| 2471 | return RValue<T>(loadValue()); |
| 2472 | } |
| 2473 | |
| 2474 | template<class T> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2475 | int Reference<T>::getAlignment() const |
| 2476 | { |
| 2477 | return alignment; |
| 2478 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2479 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2480 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2481 | RValue<T>::RValue(const RValue<T> &rvalue) |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2482 | : val(rvalue.val) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2483 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2484 | RR_DEBUG_INFO_EMIT_VAR(val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2485 | } |
Ben Clayton | ac07ed8 | 2019-03-26 14:17:41 +0000 | [diff] [blame] | 2486 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2487 | template<class T> |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2488 | RValue<T>::RValue(Value *value) |
| 2489 | : val(value) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2490 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2491 | assert(Nucleus::createBitCast(value, T::type()) == value); // Run-time type should match T, so bitcast is no-op. |
| 2492 | RR_DEBUG_INFO_EMIT_VAR(val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2493 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2494 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2495 | template<class T> |
| 2496 | RValue<T>::RValue(const T &lvalue) |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2497 | : val(lvalue.loadValue()) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2498 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2499 | RR_DEBUG_INFO_EMIT_VAR(val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2500 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2501 | |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2502 | template<> |
| 2503 | inline RValue<Bool>::RValue(bool b) |
| 2504 | : val(Nucleus::createConstantBool(b)) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2505 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2506 | RR_DEBUG_INFO_EMIT_VAR(val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2507 | } |
Ben Clayton | 35e90e2 | 2019-03-15 10:06:06 +0000 | [diff] [blame] | 2508 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2509 | template<class T> |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2510 | RValue<T>::RValue(typename IntLiteral<T>::Type i) |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2511 | : val(Nucleus::createConstantInt(i)) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2512 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2513 | RR_DEBUG_INFO_EMIT_VAR(val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2514 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2515 | |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2516 | template<> |
| 2517 | inline RValue<Long>::RValue(int64_t i) |
Daniele Vettorel | f908b18 | 2022-02-09 17:38:08 +0000 | [diff] [blame] | 2518 | : val(Nucleus::createConstantLong(i)) |
| 2519 | { |
| 2520 | RR_DEBUG_INFO_EMIT_VAR(val); |
| 2521 | } |
| 2522 | |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2523 | template<> |
| 2524 | inline RValue<Float>::RValue(float f) |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2525 | : val(Nucleus::createConstantFloat(f)) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2526 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2527 | RR_DEBUG_INFO_EMIT_VAR(val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2528 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2529 | |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 2530 | inline Value *broadcast(int i, Type *type) |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2531 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2532 | std::vector<int64_t> constantVector = { i }; |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 2533 | return Nucleus::createConstantVector(constantVector, type); |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2534 | } |
| 2535 | |
| 2536 | template<> |
| 2537 | inline RValue<Int4>::RValue(int i) |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 2538 | : val(broadcast(i, Int4::type())) |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2539 | { |
| 2540 | RR_DEBUG_INFO_EMIT_VAR(val); |
| 2541 | } |
| 2542 | |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2543 | template<> |
| 2544 | inline RValue<UInt4>::RValue(unsigned int i) |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 2545 | : val(broadcast(int(i), UInt4::type())) |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2546 | { |
| 2547 | RR_DEBUG_INFO_EMIT_VAR(val); |
| 2548 | } |
| 2549 | |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 2550 | inline Value *broadcast(float f, Type *type) |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2551 | { |
| 2552 | // See Float(float) constructor for the rationale behind this assert. |
| 2553 | assert(std::isfinite(f)); |
| 2554 | |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2555 | std::vector<double> constantVector = { f }; |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 2556 | return Nucleus::createConstantVector(constantVector, type); |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2557 | } |
| 2558 | |
| 2559 | template<> |
| 2560 | inline RValue<Float4>::RValue(float f) |
Nicolas Capens | 44f9469 | 2022-06-20 23:15:46 -0400 | [diff] [blame] | 2561 | : val(broadcast(f, Float4::type())) |
Nicolas Capens | 3edbc04 | 2022-03-01 16:02:18 -0500 | [diff] [blame] | 2562 | { |
| 2563 | RR_DEBUG_INFO_EMIT_VAR(val); |
| 2564 | } |
| 2565 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2566 | template<class T> |
| 2567 | RValue<T>::RValue(const Reference<T> &ref) |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2568 | : val(ref.loadValue()) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2569 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2570 | RR_DEBUG_INFO_EMIT_VAR(val); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2571 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2572 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2573 | template<class Vector4, int T> |
| 2574 | Swizzle2<Vector4, T>::operator RValue<Vector4>() const |
| 2575 | { |
| 2576 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2577 | Value *vector = parent->loadValue(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2578 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2579 | return Swizzle(RValue<Vector4>(vector), T); |
| 2580 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2581 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2582 | template<class Vector4, int T> |
| 2583 | Swizzle4<Vector4, T>::operator RValue<Vector4>() const |
| 2584 | { |
| 2585 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2586 | Value *vector = parent->loadValue(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2587 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2588 | return Swizzle(RValue<Vector4>(vector), T); |
| 2589 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2590 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2591 | template<class Vector4, int T> |
| 2592 | SwizzleMask4<Vector4, T>::operator RValue<Vector4>() const |
| 2593 | { |
| 2594 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2595 | Value *vector = parent->loadValue(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2596 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2597 | return Swizzle(RValue<Vector4>(vector), T); |
| 2598 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2599 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2600 | template<class Vector4, int T> |
| 2601 | RValue<Vector4> SwizzleMask4<Vector4, T>::operator=(RValue<Vector4> rhs) |
| 2602 | { |
| 2603 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2604 | return Mask(*parent, rhs, T); |
| 2605 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2606 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2607 | template<class Vector4, int T> |
| 2608 | RValue<Vector4> SwizzleMask4<Vector4, T>::operator=(RValue<typename Scalar<Vector4>::Type> rhs) |
| 2609 | { |
| 2610 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2611 | return Mask(*parent, Vector4(rhs), T); |
| 2612 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2613 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2614 | template<class Vector4, int T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2615 | SwizzleMask1<Vector4, T>::operator RValue<typename Scalar<Vector4>::Type>() const // FIXME: Call a non-template function |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2616 | { |
| 2617 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2618 | return Extract(*parent, T & 0x3); |
| 2619 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2620 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2621 | template<class Vector4, int T> |
| 2622 | SwizzleMask1<Vector4, T>::operator RValue<Vector4>() const |
| 2623 | { |
| 2624 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2625 | Value *vector = parent->loadValue(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2626 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2627 | return Swizzle(RValue<Vector4>(vector), T); |
| 2628 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2629 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2630 | template<class Vector4, int T> |
| 2631 | RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(float x) |
| 2632 | { |
| 2633 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2634 | return *parent = Insert(*parent, Float(x), T & 0x3); |
| 2635 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2636 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2637 | template<class Vector4, int T> |
| 2638 | RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(RValue<Vector4> rhs) |
| 2639 | { |
| 2640 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2641 | return Mask(*parent, Float4(rhs), T); |
| 2642 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2643 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2644 | template<class Vector4, int T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2645 | RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(RValue<typename Scalar<Vector4>::Type> rhs) // FIXME: Call a non-template function |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2646 | { |
| 2647 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2648 | return *parent = Insert(*parent, rhs, T & 0x3); |
| 2649 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2650 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2651 | template<class Vector4, int T> |
| 2652 | SwizzleMask2<Vector4, T>::operator RValue<Vector4>() const |
| 2653 | { |
| 2654 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2655 | Value *vector = parent->loadValue(); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2656 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2657 | return Swizzle(RValue<Float4>(vector), T); |
| 2658 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2659 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2660 | template<class Vector4, int T> |
| 2661 | RValue<Vector4> SwizzleMask2<Vector4, T>::operator=(RValue<Vector4> rhs) |
| 2662 | { |
| 2663 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2664 | return Mask(*parent, Float4(rhs), T); |
| 2665 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2666 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2667 | template<int T> |
Nicolas Capens | 6e9eafd | 2022-02-23 13:09:57 -0500 | [diff] [blame] | 2668 | Int::Int(const SwizzleMask1<Int4, T> &rhs) |
| 2669 | { |
| 2670 | *this = rhs.operator RValue<Int>(); |
| 2671 | } |
| 2672 | |
| 2673 | template<int T> |
| 2674 | RValue<Int> Int::operator=(const SwizzleMask1<Int4, T> &rhs) |
| 2675 | { |
| 2676 | return *this = rhs.operator RValue<Int>(); |
| 2677 | } |
| 2678 | |
| 2679 | template<int T> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2680 | Float::Float(const SwizzleMask1<Float4, T> &rhs) |
| 2681 | { |
| 2682 | *this = rhs.operator RValue<Float>(); |
| 2683 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2684 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2685 | template<int T> |
| 2686 | RValue<Float> Float::operator=(const SwizzleMask1<Float4, T> &rhs) |
| 2687 | { |
| 2688 | return *this = rhs.operator RValue<Float>(); |
| 2689 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2690 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2691 | template<int T> |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 2692 | Int4::Int4(const SwizzleMask1<Int4, T> &rhs) |
| 2693 | : XYZW(this) |
| 2694 | { |
| 2695 | *this = rhs.operator RValue<Int4>(); |
| 2696 | } |
| 2697 | |
| 2698 | template<int T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2699 | Float4::Float4(const SwizzleMask1<Float4, T> &rhs) |
| 2700 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2701 | { |
| 2702 | *this = rhs.operator RValue<Float4>(); |
| 2703 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2704 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2705 | template<int T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2706 | Float4::Float4(const Swizzle4<Float4, T> &rhs) |
| 2707 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2708 | { |
| 2709 | *this = rhs.operator RValue<Float4>(); |
| 2710 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2711 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2712 | template<int X, int Y> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2713 | Float4::Float4(const Swizzle2<Float4, X> &x, const Swizzle2<Float4, Y> &y) |
| 2714 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2715 | { |
| 2716 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2717 | *this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu)); |
| 2718 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2719 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2720 | template<int X, int Y> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2721 | Float4::Float4(const SwizzleMask2<Float4, X> &x, const Swizzle2<Float4, Y> &y) |
| 2722 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2723 | { |
| 2724 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2725 | *this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu)); |
| 2726 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2727 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2728 | template<int X, int Y> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2729 | Float4::Float4(const Swizzle2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y) |
| 2730 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2731 | { |
| 2732 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2733 | *this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu)); |
| 2734 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2735 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2736 | template<int X, int Y> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2737 | Float4::Float4(const SwizzleMask2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y) |
| 2738 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2739 | { |
| 2740 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2741 | *this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu)); |
| 2742 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2743 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2744 | template<int T> |
| 2745 | RValue<Float4> Float4::operator=(const SwizzleMask1<Float4, T> &rhs) |
| 2746 | { |
| 2747 | return *this = rhs.operator RValue<Float4>(); |
| 2748 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2749 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2750 | template<int T> |
| 2751 | RValue<Float4> Float4::operator=(const Swizzle4<Float4, T> &rhs) |
| 2752 | { |
| 2753 | return *this = rhs.operator RValue<Float4>(); |
| 2754 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2755 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2756 | // Returns a reactor pointer to the fixed-address ptr. |
Nicolas Capens | 3d7faaa | 2022-10-04 14:48:57 -0400 | [diff] [blame] | 2757 | RValue<Pointer<Byte>> ConstantPointer(const void *ptr); |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame] | 2758 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2759 | // Returns a reactor pointer to an immutable copy of the data of size bytes. |
Nicolas Capens | 3d7faaa | 2022-10-04 14:48:57 -0400 | [diff] [blame] | 2760 | RValue<Pointer<Byte>> ConstantData(const void *data, size_t size); |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame] | 2761 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2762 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2763 | Pointer<T>::Pointer(Argument<Pointer<T>> argument) |
| 2764 | : alignment(1) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2765 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2766 | this->store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2767 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2768 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2769 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2770 | Pointer<T>::Pointer() |
| 2771 | : alignment(1) |
| 2772 | {} |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2773 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2774 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2775 | Pointer<T>::Pointer(RValue<Pointer<T>> rhs) |
| 2776 | : alignment(1) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2777 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2778 | this->store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2779 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2780 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2781 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2782 | Pointer<T>::Pointer(const Pointer<T> &rhs) |
| 2783 | : alignment(rhs.alignment) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2784 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2785 | this->store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2786 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2787 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2788 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2789 | Pointer<T>::Pointer(const Reference<Pointer<T>> &rhs) |
| 2790 | : alignment(rhs.getAlignment()) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2791 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2792 | this->store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2793 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2794 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2795 | template<class T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2796 | Pointer<T>::Pointer(std::nullptr_t) |
| 2797 | : alignment(1) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2798 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2799 | Value *value = Nucleus::createNullPointer(T::type()); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2800 | this->storeValue(value); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2801 | } |
Ben Clayton | 0697da0 | 2019-08-01 13:35:48 +0100 | [diff] [blame] | 2802 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2803 | template<class T> |
| 2804 | RValue<Pointer<T>> Pointer<T>::operator=(RValue<Pointer<T>> rhs) |
| 2805 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2806 | return this->store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2807 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2808 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2809 | template<class T> |
| 2810 | RValue<Pointer<T>> Pointer<T>::operator=(const Pointer<T> &rhs) |
| 2811 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2812 | return this->store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2813 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2814 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2815 | template<class T> |
| 2816 | RValue<Pointer<T>> Pointer<T>::operator=(const Reference<Pointer<T>> &rhs) |
| 2817 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2818 | return this->store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2819 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2820 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2821 | template<class T> |
| 2822 | RValue<Pointer<T>> Pointer<T>::operator=(std::nullptr_t) |
| 2823 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2824 | Value *value = Nucleus::createNullPointer(T::type()); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2825 | this->storeValue(value); |
Ben Clayton | 0697da0 | 2019-08-01 13:35:48 +0100 | [diff] [blame] | 2826 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2827 | return RValue<Pointer<T>>(this); |
| 2828 | } |
Ben Clayton | 0697da0 | 2019-08-01 13:35:48 +0100 | [diff] [blame] | 2829 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2830 | template<class T> |
Nicolas Capens | ef72cb4 | 2021-11-12 13:57:14 -0500 | [diff] [blame] | 2831 | Reference<T> Pointer<T>::operator*() const |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2832 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2833 | return Reference<T>(this->loadValue(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2834 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2835 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2836 | template<class T> |
Nicolas Capens | ef72cb4 | 2021-11-12 13:57:14 -0500 | [diff] [blame] | 2837 | Reference<T> Pointer<T>::operator[](int index) const |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2838 | { |
| 2839 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2840 | Value *element = Nucleus::createGEP(this->loadValue(), T::type(), Nucleus::createConstantInt(index), false); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2841 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2842 | return Reference<T>(element, alignment); |
| 2843 | } |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2844 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2845 | template<class T> |
Nicolas Capens | ef72cb4 | 2021-11-12 13:57:14 -0500 | [diff] [blame] | 2846 | Reference<T> Pointer<T>::operator[](unsigned int index) const |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2847 | { |
| 2848 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2849 | Value *element = Nucleus::createGEP(this->loadValue(), T::type(), Nucleus::createConstantInt(index), true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2850 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2851 | return Reference<T>(element, alignment); |
| 2852 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2853 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2854 | template<class T> |
Nicolas Capens | ef72cb4 | 2021-11-12 13:57:14 -0500 | [diff] [blame] | 2855 | Reference<T> Pointer<T>::operator[](RValue<Int> index) const |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2856 | { |
| 2857 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2858 | Value *element = Nucleus::createGEP(this->loadValue(), T::type(), index.value(), false); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2859 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2860 | return Reference<T>(element, alignment); |
| 2861 | } |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2862 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2863 | template<class T> |
Nicolas Capens | ef72cb4 | 2021-11-12 13:57:14 -0500 | [diff] [blame] | 2864 | Reference<T> Pointer<T>::operator[](RValue<UInt> index) const |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2865 | { |
| 2866 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2867 | Value *element = Nucleus::createGEP(this->loadValue(), T::type(), index.value(), true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2868 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2869 | return Reference<T>(element, alignment); |
| 2870 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2871 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2872 | template<class T> |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2873 | Type *Pointer<T>::type() |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2874 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2875 | return Nucleus::getPointerType(T::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2876 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2877 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2878 | template<class T, int S> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2879 | Array<T, S>::Array(int size) |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 2880 | : LValue<T>(size) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2881 | { |
| 2882 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2883 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2884 | template<class T, int S> |
| 2885 | Reference<T> Array<T, S>::operator[](int index) |
| 2886 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 2887 | assert(index < Variable::getArraySize()); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2888 | Value *element = this->getElementPointer(Nucleus::createConstantInt(index), false); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2889 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2890 | return Reference<T>(element); |
| 2891 | } |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2892 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2893 | template<class T, int S> |
| 2894 | Reference<T> Array<T, S>::operator[](unsigned int index) |
| 2895 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 2896 | assert(index < static_cast<unsigned int>(Variable::getArraySize())); |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2897 | Value *element = this->getElementPointer(Nucleus::createConstantInt(index), true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2898 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2899 | return Reference<T>(element); |
| 2900 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2901 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2902 | template<class T, int S> |
| 2903 | Reference<T> Array<T, S>::operator[](RValue<Int> index) |
| 2904 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2905 | Value *element = this->getElementPointer(index.value(), false); |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2906 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2907 | return Reference<T>(element); |
| 2908 | } |
Nicolas Capens | d294def | 2017-01-26 17:44:37 -0800 | [diff] [blame] | 2909 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2910 | template<class T, int S> |
| 2911 | Reference<T> Array<T, S>::operator[](RValue<UInt> index) |
| 2912 | { |
Nicolas Capens | 3b655b6 | 2020-05-13 15:23:54 -0400 | [diff] [blame] | 2913 | Value *element = this->getElementPointer(index.value(), true); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2914 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2915 | return Reference<T>(element); |
| 2916 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2917 | |
| 2918 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2919 | // RValue<Array<T>> operator++(Array<T> &val, int) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2920 | // { |
| 2921 | // // FIXME: Requires storing the address of the array |
| 2922 | // } |
| 2923 | |
| 2924 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2925 | // const Array<T> &operator++(Array<T> &val) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2926 | // { |
| 2927 | // // FIXME: Requires storing the address of the array |
| 2928 | // } |
| 2929 | |
| 2930 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2931 | // RValue<Array<T>> operator--(Array<T> &val, int) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2932 | // { |
| 2933 | // // FIXME: Requires storing the address of the array |
| 2934 | // } |
| 2935 | |
| 2936 | // template<class T> |
Nicolas Capens | 96d4e09 | 2016-11-18 14:22:38 -0500 | [diff] [blame] | 2937 | // const Array<T> &operator--(Array<T> &val) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2938 | // { |
| 2939 | // // FIXME: Requires storing the address of the array |
| 2940 | // } |
| 2941 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2942 | template<class T> |
| 2943 | RValue<T> IfThenElse(RValue<Bool> condition, RValue<T> ifTrue, RValue<T> ifFalse) |
| 2944 | { |
| 2945 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2946 | return RValue<T>(Nucleus::createSelect(condition.value(), ifTrue.value(), ifFalse.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2947 | } |
| 2948 | |
| 2949 | template<class T> |
| 2950 | RValue<T> IfThenElse(RValue<Bool> condition, const T &ifTrue, RValue<T> ifFalse) |
| 2951 | { |
| 2952 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2953 | Value *trueValue = ifTrue.loadValue(); |
| 2954 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2955 | return RValue<T>(Nucleus::createSelect(condition.value(), trueValue, ifFalse.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2956 | } |
| 2957 | |
| 2958 | template<class T> |
| 2959 | RValue<T> IfThenElse(RValue<Bool> condition, RValue<T> ifTrue, const T &ifFalse) |
| 2960 | { |
| 2961 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2962 | Value *falseValue = ifFalse.loadValue(); |
| 2963 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2964 | return RValue<T>(Nucleus::createSelect(condition.value(), ifTrue.value(), falseValue)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2965 | } |
| 2966 | |
| 2967 | template<class T> |
| 2968 | RValue<T> IfThenElse(RValue<Bool> condition, const T &ifTrue, const T &ifFalse) |
| 2969 | { |
| 2970 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 2971 | Value *trueValue = ifTrue.loadValue(); |
| 2972 | Value *falseValue = ifFalse.loadValue(); |
| 2973 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2974 | return RValue<T>(Nucleus::createSelect(condition.value(), trueValue, falseValue)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2975 | } |
| 2976 | |
| 2977 | template<typename Return, typename... Arguments> |
| 2978 | Function<Return(Arguments...)>::Function() |
Nicolas Capens | 3d26cfc | 2021-01-22 16:51:00 -0500 | [diff] [blame] | 2979 | : core(new Nucleus()) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2980 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2981 | Type *types[] = { Arguments::type()... }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2982 | for(Type *type : types) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2983 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2984 | if(type != Void::type()) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2985 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2986 | arguments.push_back(type); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2987 | } |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 2988 | } |
| 2989 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2990 | Nucleus::createFunction(Return::type(), arguments); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2991 | } |
| 2992 | |
| 2993 | template<typename Return, typename... Arguments> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2994 | std::shared_ptr<Routine> Function<Return(Arguments...)>::operator()(const char *name, ...) |
| 2995 | { |
| 2996 | char fullName[1024 + 1]; |
| 2997 | |
| 2998 | va_list vararg; |
| 2999 | va_start(vararg, name); |
| 3000 | vsnprintf(fullName, 1024, name, vararg); |
| 3001 | va_end(vararg); |
| 3002 | |
Nicolas Capens | 79d4c6c | 2022-04-22 17:20:26 -0400 | [diff] [blame] | 3003 | auto routine = core->acquireRoutine(fullName); |
Nicolas Capens | 3d26cfc | 2021-01-22 16:51:00 -0500 | [diff] [blame] | 3004 | core.reset(nullptr); |
| 3005 | |
| 3006 | return routine; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3007 | } |
| 3008 | |
| 3009 | template<class T, class S> |
| 3010 | RValue<T> ReinterpretCast(RValue<S> val) |
| 3011 | { |
| 3012 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3013 | return RValue<T>(Nucleus::createBitCast(val.value(), T::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3014 | } |
| 3015 | |
| 3016 | template<class T, class S> |
| 3017 | RValue<T> ReinterpretCast(const LValue<S> &var) |
| 3018 | { |
| 3019 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 3020 | Value *val = var.loadValue(); |
| 3021 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3022 | return RValue<T>(Nucleus::createBitCast(val, T::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3023 | } |
| 3024 | |
| 3025 | template<class T, class S> |
| 3026 | RValue<T> ReinterpretCast(const Reference<S> &var) |
| 3027 | { |
| 3028 | return ReinterpretCast<T>(RValue<S>(var)); |
| 3029 | } |
| 3030 | |
| 3031 | template<class T> |
| 3032 | RValue<T> As(Value *val) |
| 3033 | { |
| 3034 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3035 | return RValue<T>(Nucleus::createBitCast(val, T::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | template<class T, class S> |
| 3039 | RValue<T> As(RValue<S> val) |
| 3040 | { |
| 3041 | return ReinterpretCast<T>(val); |
| 3042 | } |
| 3043 | |
| 3044 | template<class T, class S> |
| 3045 | RValue<T> As(const LValue<S> &var) |
| 3046 | { |
| 3047 | return ReinterpretCast<T>(var); |
| 3048 | } |
| 3049 | |
| 3050 | template<class T, class S> |
| 3051 | RValue<T> As(const Reference<S> &val) |
| 3052 | { |
| 3053 | return ReinterpretCast<T>(val); |
| 3054 | } |
| 3055 | |
| 3056 | // Calls the function pointer fptr with the given arguments, return type |
| 3057 | // and parameter types. Returns the call's return value if the function has |
| 3058 | // a non-void return type. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3059 | Value *Call(RValue<Pointer<Byte>> fptr, Type *retTy, std::initializer_list<Value *> args, std::initializer_list<Type *> paramTys); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3060 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3061 | template<typename F> |
| 3062 | class CallHelper |
| 3063 | {}; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3064 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3065 | template<typename Return, typename... Arguments> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3066 | class CallHelper<Return(Arguments...)> |
| 3067 | { |
| 3068 | public: |
| 3069 | using RReturn = CToReactorT<Return>; |
| 3070 | |
| 3071 | static inline RReturn Call(Return(fptr)(Arguments...), CToReactorT<Arguments>... args) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3072 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3073 | return RValue<RReturn>(rr::Call( |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3074 | ConstantPointer(reinterpret_cast<void *>(fptr)), |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3075 | RReturn::type(), |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3076 | { ValueOf(args)... }, |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3077 | { CToReactorT<Arguments>::type()... })); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3078 | } |
| 3079 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3080 | static inline RReturn Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args) |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3081 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3082 | return RValue<RReturn>(rr::Call( |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3083 | fptr, |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3084 | RReturn::type(), |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3085 | { ValueOf(args)... }, |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3086 | { CToReactorT<Arguments>::type()... })); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3087 | } |
| 3088 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3089 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3090 | template<typename... Arguments> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3091 | class CallHelper<void(Arguments...)> |
| 3092 | { |
| 3093 | public: |
| 3094 | static inline void Call(void(fptr)(Arguments...), CToReactorT<Arguments>... args) |
| 3095 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3096 | rr::Call(ConstantPointer(reinterpret_cast<void *>(fptr)), |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3097 | Void::type(), |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3098 | { ValueOf(args)... }, |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3099 | { CToReactorT<Arguments>::type()... }); |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 3100 | } |
| 3101 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3102 | static inline void Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args) |
Ben Clayton | 68cfc78 | 2019-06-29 12:31:08 +0100 | [diff] [blame] | 3103 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3104 | rr::Call(fptr, |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3105 | Void::type(), |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3106 | { ValueOf(args)... }, |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3107 | { CToReactorT<Arguments>::type()... }); |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3108 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3109 | }; |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3110 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3111 | template<typename T> |
| 3112 | inline ReactorTypeT<T> CastToReactor(const T &v) |
| 3113 | { |
| 3114 | return ReactorType<T>::cast(v); |
| 3115 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3116 | |
| 3117 | // Calls the static function pointer fptr with the given arguments args. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3118 | template<typename Return, typename... CArgs, typename... RArgs> |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 3119 | inline CToReactorT<Return> Call(Return(fptr)(CArgs...), RArgs &&...args) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3120 | { |
| 3121 | return CallHelper<Return(CArgs...)>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...); |
| 3122 | } |
| 3123 | |
| 3124 | // Calls the static function pointer fptr with the given arguments args. |
| 3125 | // Overload for calling functions with void return type. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3126 | template<typename... CArgs, typename... RArgs> |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 3127 | inline void Call(void(fptr)(CArgs...), RArgs &&...args) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3128 | { |
| 3129 | CallHelper<void(CArgs...)>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...); |
| 3130 | } |
| 3131 | |
| 3132 | // Calls the member function pointer fptr with the given arguments args. |
| 3133 | // object can be a Class*, or a Pointer<Byte>. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3134 | template<typename Return, typename Class, typename C, typename... CArgs, typename... RArgs> |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 3135 | inline CToReactorT<Return> Call(Return (Class::*fptr)(CArgs...), C &&object, RArgs &&...args) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3136 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3137 | using Helper = CallHelper<Return(Class *, void *, CArgs...)>; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3138 | using fptrTy = decltype(fptr); |
| 3139 | |
| 3140 | struct Static |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3141 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3142 | static inline Return Call(Class *object, void *fptrptr, CArgs... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3143 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3144 | auto fptr = *reinterpret_cast<fptrTy *>(fptrptr); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3145 | return (object->*fptr)(std::forward<CArgs>(args)...); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3146 | } |
| 3147 | }; |
| 3148 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3149 | return Helper::Call(&Static::Call, |
| 3150 | CastToReactor(object), |
| 3151 | ConstantData(&fptr, sizeof(fptr)), |
| 3152 | CastToReactor(std::forward<RArgs>(args))...); |
| 3153 | } |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3154 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3155 | // Calls the member function pointer fptr with the given arguments args. |
| 3156 | // Overload for calling functions with void return type. |
| 3157 | // object can be a Class*, or a Pointer<Byte>. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3158 | template<typename Class, typename C, typename... CArgs, typename... RArgs> |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 3159 | inline void Call(void (Class::*fptr)(CArgs...), C &&object, RArgs &&...args) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3160 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3161 | using Helper = CallHelper<void(Class *, void *, CArgs...)>; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3162 | using fptrTy = decltype(fptr); |
| 3163 | |
| 3164 | struct Static |
| 3165 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3166 | static inline void Call(Class *object, void *fptrptr, CArgs... args) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3167 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3168 | auto fptr = *reinterpret_cast<fptrTy *>(fptrptr); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3169 | (object->*fptr)(std::forward<CArgs>(args)...); |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3170 | } |
| 3171 | }; |
| 3172 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3173 | Helper::Call(&Static::Call, |
| 3174 | CastToReactor(object), |
| 3175 | ConstantData(&fptr, sizeof(fptr)), |
| 3176 | CastToReactor(std::forward<RArgs>(args))...); |
| 3177 | } |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 3178 | |
Nicolas Capens | 22f14a8 | 2020-12-16 15:41:22 -0500 | [diff] [blame] | 3179 | // NonVoidFunction<F> and VoidFunction<F> are helper classes which define ReturnType |
| 3180 | // when F matches a non-void fuction signature or void function signature, respectively, |
| 3181 | // as the function's return type. |
| 3182 | template<typename F> |
| 3183 | struct NonVoidFunction |
| 3184 | {}; |
| 3185 | |
| 3186 | template<typename Return, typename... Arguments> |
| 3187 | struct NonVoidFunction<Return(Arguments...)> |
| 3188 | { |
| 3189 | using ReturnType = Return; |
| 3190 | }; |
| 3191 | |
| 3192 | template<typename... Arguments> |
| 3193 | struct NonVoidFunction<void(Arguments...)> |
| 3194 | { |
| 3195 | }; |
| 3196 | |
| 3197 | template<typename F> |
| 3198 | using NonVoidFunctionReturnType = typename NonVoidFunction<F>::ReturnType; |
| 3199 | |
| 3200 | template<typename F> |
| 3201 | struct VoidFunction |
| 3202 | {}; |
| 3203 | |
| 3204 | template<typename... Arguments> |
| 3205 | struct VoidFunction<void(Arguments...)> |
| 3206 | { |
| 3207 | using ReturnType = void; |
| 3208 | }; |
| 3209 | |
| 3210 | template<typename F> |
| 3211 | using VoidFunctionReturnType = typename VoidFunction<F>::ReturnType; |
| 3212 | |
| 3213 | // Calls the Reactor function pointer fptr with the signature FUNCTION_SIGNATURE and arguments. |
| 3214 | // Overload for calling functions with non-void return type. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3215 | template<typename FUNCTION_SIGNATURE, typename... RArgs> |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 3216 | inline CToReactorT<NonVoidFunctionReturnType<FUNCTION_SIGNATURE>> Call(Pointer<Byte> fptr, RArgs &&...args) |
Nicolas Capens | 22f14a8 | 2020-12-16 15:41:22 -0500 | [diff] [blame] | 3217 | { |
| 3218 | return CallHelper<FUNCTION_SIGNATURE>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...); |
| 3219 | } |
| 3220 | |
| 3221 | // Calls the Reactor function pointer fptr with the signature FUNCTION_SIGNATURE and arguments. |
| 3222 | // Overload for calling functions with void return type. |
| 3223 | template<typename FUNCTION_SIGNATURE, typename... RArgs> |
Nicolas Capens | 0eb3b10 | 2022-06-15 16:49:17 -0400 | [diff] [blame] | 3224 | inline VoidFunctionReturnType<FUNCTION_SIGNATURE> Call(Pointer<Byte> fptr, RArgs &&...args) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3225 | { |
| 3226 | CallHelper<FUNCTION_SIGNATURE>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...); |
| 3227 | } |
| 3228 | |
| 3229 | // Breakpoint emits an instruction that will cause the application to trap. |
| 3230 | // This can be used to stop an attached debugger at the given call. |
| 3231 | void Breakpoint(); |
| 3232 | |
| 3233 | class ForData |
| 3234 | { |
| 3235 | public: |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3236 | ForData(bool init) |
| 3237 | : loopOnce(init) |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3238 | { |
Ben Clayton | d853c12 | 2019-04-16 17:51:49 -0400 | [diff] [blame] | 3239 | } |
| 3240 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3241 | operator bool() |
Antonio Maiorano | 7363cd2 | 2019-10-11 15:23:22 -0400 | [diff] [blame] | 3242 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3243 | return loopOnce; |
Antonio Maiorano | 7363cd2 | 2019-10-11 15:23:22 -0400 | [diff] [blame] | 3244 | } |
| 3245 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3246 | bool operator=(bool value) |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame] | 3247 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3248 | return loopOnce = value; |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame] | 3249 | } |
| 3250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3251 | bool setup() |
Ben Clayton | b7eb3a8 | 2019-11-19 00:43:50 +0000 | [diff] [blame] | 3252 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3253 | RR_DEBUG_INFO_FLUSH(); |
| 3254 | if(Nucleus::getInsertBlock() != endBB) |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3255 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3256 | testBB = Nucleus::createBasicBlock(); |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3257 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3258 | Nucleus::createBr(testBB); |
| 3259 | Nucleus::setInsertBlock(testBB); |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3260 | |
| 3261 | return true; |
| 3262 | } |
| 3263 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3264 | return false; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3265 | } |
| 3266 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3267 | bool test(RValue<Bool> cmp) |
| 3268 | { |
| 3269 | BasicBlock *bodyBB = Nucleus::createBasicBlock(); |
| 3270 | endBB = Nucleus::createBasicBlock(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3271 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3272 | Nucleus::createCondBr(cmp.value(), bodyBB, endBB); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3273 | Nucleus::setInsertBlock(bodyBB); |
Nicolas Capens | 37ed908 | 2016-11-16 17:40:48 -0500 | [diff] [blame] | 3274 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3275 | return true; |
| 3276 | } |
| 3277 | |
| 3278 | void end() |
| 3279 | { |
| 3280 | Nucleus::createBr(testBB); |
| 3281 | Nucleus::setInsertBlock(endBB); |
| 3282 | } |
| 3283 | |
| 3284 | private: |
| 3285 | BasicBlock *testBB = nullptr; |
| 3286 | BasicBlock *endBB = nullptr; |
| 3287 | bool loopOnce = true; |
| 3288 | }; |
| 3289 | |
| 3290 | class IfElseData |
| 3291 | { |
| 3292 | public: |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3293 | IfElseData(RValue<Bool> cmp) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3294 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3295 | trueBB = Nucleus::createBasicBlock(); |
Nicolas Capens | d85a7a2 | 2021-02-18 15:23:40 -0500 | [diff] [blame] | 3296 | falseBB = Nucleus::createBasicBlock(); |
| 3297 | endBB = falseBB; // Until we encounter an Else statement, these are the same. |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3298 | |
Nicolas Capens | d85a7a2 | 2021-02-18 15:23:40 -0500 | [diff] [blame] | 3299 | Nucleus::createCondBr(cmp.value(), trueBB, falseBB); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3300 | Nucleus::setInsertBlock(trueBB); |
| 3301 | } |
| 3302 | |
| 3303 | ~IfElseData() |
| 3304 | { |
| 3305 | Nucleus::createBr(endBB); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3306 | Nucleus::setInsertBlock(endBB); |
| 3307 | } |
| 3308 | |
| 3309 | operator int() |
| 3310 | { |
| 3311 | return iteration; |
| 3312 | } |
| 3313 | |
| 3314 | IfElseData &operator++() |
| 3315 | { |
| 3316 | ++iteration; |
| 3317 | |
| 3318 | return *this; |
| 3319 | } |
| 3320 | |
| 3321 | void elseClause() |
| 3322 | { |
Nicolas Capens | d85a7a2 | 2021-02-18 15:23:40 -0500 | [diff] [blame] | 3323 | endBB = Nucleus::createBasicBlock(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3324 | Nucleus::createBr(endBB); |
| 3325 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3326 | Nucleus::setInsertBlock(falseBB); |
| 3327 | } |
| 3328 | |
| 3329 | private: |
Nicolas Capens | d85a7a2 | 2021-02-18 15:23:40 -0500 | [diff] [blame] | 3330 | BasicBlock *trueBB = nullptr; |
| 3331 | BasicBlock *falseBB = nullptr; |
| 3332 | BasicBlock *endBB = nullptr; |
| 3333 | int iteration = 0; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3334 | }; |
| 3335 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3336 | #define For(init, cond, inc) \ |
| 3337 | for(ForData for__ = true; for__; for__ = false) \ |
| 3338 | for(init; for__.setup() && for__.test(cond); inc, for__.end()) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3339 | |
| 3340 | #define While(cond) For((void)0, cond, (void)0) |
| 3341 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3342 | #define Do \ |
| 3343 | { \ |
| 3344 | BasicBlock *body__ = Nucleus::createBasicBlock(); \ |
| 3345 | Nucleus::createBr(body__); \ |
| 3346 | Nucleus::setInsertBlock(body__); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3347 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3348 | #define Until(cond) \ |
| 3349 | BasicBlock *end__ = Nucleus::createBasicBlock(); \ |
| 3350 | Nucleus::createCondBr((cond).value(), end__, body__); \ |
| 3351 | Nucleus::setInsertBlock(end__); \ |
| 3352 | } \ |
| 3353 | do \ |
| 3354 | { \ |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3355 | } while(false) // Require a semi-colon at the end of the Until() |
Nicolas Capens | d022e41 | 2016-09-26 13:30:14 -0400 | [diff] [blame] | 3356 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3357 | enum |
| 3358 | { |
| 3359 | IF_BLOCK__, |
| 3360 | ELSE_CLAUSE__, |
| 3361 | ELSE_BLOCK__, |
| 3362 | IFELSE_NUM__ |
| 3363 | }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3364 | |
Nicolas Capens | 782dbeb | 2020-10-30 14:17:00 -0400 | [diff] [blame] | 3365 | #define If(cond) \ |
| 3366 | for(IfElseData ifElse__{ cond }; ifElse__ < IFELSE_NUM__; ++ifElse__) \ |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3367 | if(ifElse__ == IF_BLOCK__) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3368 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3369 | #define Else \ |
| 3370 | else if(ifElse__ == ELSE_CLAUSE__) \ |
| 3371 | { \ |
| 3372 | ifElse__.elseClause(); \ |
| 3373 | } \ |
| 3374 | else // ELSE_BLOCK__ |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3375 | |
Nicolas Capens | d085136 | 2020-04-30 15:59:30 -0400 | [diff] [blame] | 3376 | // The OFFSET macro is a generalization of the offsetof() macro defined in <cstddef>. |
| 3377 | // It allows e.g. getting the offset of array elements, even when indexed dynamically. |
| 3378 | // We cast the address '32' and subtract it again, because null-dereference is undefined behavior. |
| 3379 | #define OFFSET(s, m) ((int)(size_t) & reinterpret_cast<const volatile char &>((((s *)32)->m)) - 32) |
| 3380 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3381 | } // namespace rr |
| 3382 | |
Ben Clayton | 7e11f46 | 2019-11-18 16:00:31 +0000 | [diff] [blame] | 3383 | #include "Traits.inl" |
| 3384 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3385 | #endif // rr_Reactor_hpp |