Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1 | // Copyright 2019 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 | |
| 15 | #include "Reactor.hpp" |
Nicolas Capens | c7d5ec3 | 2020-04-22 01:11:37 -0400 | [diff] [blame] | 16 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 17 | #include "CPUID.hpp" |
Ben Clayton | b16c586 | 2019-05-08 14:01:38 +0100 | [diff] [blame] | 18 | #include "Debug.hpp" |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 19 | #include "Print.hpp" |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 20 | |
Ben Clayton | 983761c | 2020-04-01 19:49:44 +0100 | [diff] [blame] | 21 | #include <algorithm> |
Nicolas Capens | d94d6a3 | 2019-08-31 04:04:37 +0000 | [diff] [blame] | 22 | #include <cmath> |
| 23 | |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 24 | #if defined(_WIN32) |
| 25 | # ifndef WIN32_LEAN_AND_MEAN |
| 26 | # define WIN32_LEAN_AND_MEAN |
| 27 | # endif |
| 28 | # include <windows.h> |
| 29 | #endif |
| 30 | |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 31 | // Define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION to non-zero to ensure all |
| 32 | // variables have a stack location obtained throuch alloca(). |
| 33 | #ifndef REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
| 34 | # define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION 0 |
| 35 | #endif |
| 36 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 37 | namespace rr { |
| 38 | |
| 39 | const Config::Edit Config::Edit::None = {}; |
| 40 | |
| 41 | Config Config::Edit::apply(const Config &cfg) const |
| 42 | { |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 43 | if(this == &None) { return cfg; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 44 | |
| 45 | auto level = optLevelChanged ? optLevel : cfg.optimization.getLevel(); |
| 46 | auto passes = cfg.optimization.getPasses(); |
| 47 | apply(optPassEdits, passes); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 48 | return Config{ Optimization{ level, passes } }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 49 | } |
| 50 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 51 | template<typename T> |
| 52 | void rr::Config::Edit::apply(const std::vector<std::pair<ListEdit, T>> &edits, std::vector<T> &list) const |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 53 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 54 | for(auto &edit : edits) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 55 | { |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 56 | switch(edit.first) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 57 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 58 | case ListEdit::Add: |
| 59 | list.push_back(edit.second); |
| 60 | break; |
| 61 | case ListEdit::Remove: |
Ben Clayton | 983761c | 2020-04-01 19:49:44 +0100 | [diff] [blame] | 62 | list.erase(std::remove_if(list.begin(), list.end(), [&](T item) { |
| 63 | return item == edit.second; |
| 64 | }), |
| 65 | list.end()); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 66 | break; |
| 67 | case ListEdit::Clear: |
| 68 | list.clear(); |
| 69 | break; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 70 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 71 | } |
| 72 | } |
| 73 | |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 74 | thread_local Variable::UnmaterializedVariables *Variable::unmaterializedVariables = nullptr; |
| 75 | |
| 76 | void Variable::UnmaterializedVariables::add(const Variable *v) |
| 77 | { |
| 78 | variables.emplace(v, counter++); |
| 79 | } |
| 80 | |
| 81 | void Variable::UnmaterializedVariables::remove(const Variable *v) |
| 82 | { |
| 83 | auto iter = variables.find(v); |
| 84 | if(iter != variables.end()) |
| 85 | { |
| 86 | variables.erase(iter); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | void Variable::UnmaterializedVariables::clear() |
| 91 | { |
| 92 | variables.clear(); |
| 93 | } |
| 94 | |
| 95 | void Variable::UnmaterializedVariables::materializeAll() |
| 96 | { |
| 97 | // Flatten map of Variable* to monotonically increasing counter to a vector, |
| 98 | // then sort it by the counter, so that we materialize in variable usage order. |
| 99 | std::vector<std::pair<const Variable *, int>> sorted; |
| 100 | sorted.resize(variables.size()); |
| 101 | std::copy(variables.begin(), variables.end(), sorted.begin()); |
| 102 | std::sort(sorted.begin(), sorted.end(), [&](auto &lhs, auto &rhs) { |
| 103 | return lhs.second < rhs.second; |
| 104 | }); |
| 105 | |
| 106 | for(auto &v : sorted) |
| 107 | { |
| 108 | v.first->materialize(); |
| 109 | } |
| 110 | |
| 111 | variables.clear(); |
| 112 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 113 | |
Antonio Maiorano | bae138d | 2020-12-02 14:25:10 -0500 | [diff] [blame] | 114 | Variable::Variable(Type *type, int arraySize) |
| 115 | : type(type) |
| 116 | , arraySize(arraySize) |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 117 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 118 | #if REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
| 119 | materialize(); |
| 120 | #else |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 121 | unmaterializedVariables->add(this); |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 122 | #endif |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 123 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 124 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 125 | Variable::~Variable() |
| 126 | { |
Nicolas Capens | 3d26cfc | 2021-01-22 16:51:00 -0500 | [diff] [blame^] | 127 | // `unmaterializedVariables` can be null at this point due to the function |
| 128 | // already having been finalized, while classes derived from `Function<>` |
| 129 | // can have member `Variable` fields which are destructed afterwards. |
| 130 | if(unmaterializedVariables) |
| 131 | { |
| 132 | unmaterializedVariables->remove(this); |
| 133 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 134 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 135 | |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 136 | void Variable::materialize() const |
| 137 | { |
| 138 | if(!address) |
| 139 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 140 | address = Nucleus::allocateStackVariable(getType(), arraySize); |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 141 | RR_DEBUG_INFO_EMIT_VAR(address); |
| 142 | |
| 143 | if(rvalue) |
| 144 | { |
| 145 | storeValue(rvalue); |
| 146 | rvalue = nullptr; |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | Value *Variable::loadValue() const |
| 152 | { |
| 153 | if(rvalue) |
| 154 | { |
| 155 | return rvalue; |
| 156 | } |
| 157 | |
| 158 | if(!address) |
| 159 | { |
| 160 | // TODO: Return undef instead. |
| 161 | materialize(); |
| 162 | } |
| 163 | |
| 164 | return Nucleus::createLoad(address, getType(), false, 0); |
| 165 | } |
| 166 | |
| 167 | Value *Variable::storeValue(Value *value) const |
| 168 | { |
| 169 | if(address) |
| 170 | { |
| 171 | return Nucleus::createStore(value, address, getType(), false, 0); |
| 172 | } |
| 173 | |
| 174 | rvalue = value; |
| 175 | |
| 176 | return value; |
| 177 | } |
| 178 | |
| 179 | Value *Variable::getBaseAddress() const |
| 180 | { |
| 181 | materialize(); |
| 182 | |
| 183 | return address; |
| 184 | } |
| 185 | |
| 186 | Value *Variable::getElementPointer(Value *index, bool unsignedIndex) const |
| 187 | { |
| 188 | return Nucleus::createGEP(getBaseAddress(), getType(), index, unsignedIndex); |
| 189 | } |
| 190 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 191 | void Variable::materializeAll() |
| 192 | { |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 193 | unmaterializedVariables->materializeAll(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 194 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 195 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 196 | void Variable::killUnmaterialized() |
| 197 | { |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 198 | unmaterializedVariables->clear(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 199 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 200 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 201 | // NOTE: Only 12 bits out of 16 of the |select| value are used. |
| 202 | // More specifically, the value should look like: |
| 203 | // |
| 204 | // msb lsb |
| 205 | // v v |
| 206 | // [.xxx|.yyy|.zzz|.www] where '.' means an ignored bit |
| 207 | // |
| 208 | // This format makes it easy to write calls with hexadecimal select values, |
| 209 | // since each hex digit is a separate swizzle index. |
| 210 | // |
| 211 | // For example: |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 212 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x0123 ) -> [a,b,c,d] |
| 213 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x4567 ) -> [e,f,g,h] |
| 214 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x4012 ) -> [e,a,b,c] |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 215 | // |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 216 | static Value *createShuffle4(Value *lhs, Value *rhs, uint16_t select) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 217 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 218 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 219 | (select >> 12) & 0x07, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 220 | (select >> 8) & 0x07, |
| 221 | (select >> 4) & 0x07, |
| 222 | (select >> 0) & 0x07, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 223 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 224 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 225 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 226 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 227 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 228 | // NOTE: Only 8 bits out of 16 of the |select| value are used. |
| 229 | // More specifically, the value should look like: |
| 230 | // |
| 231 | // msb lsb |
| 232 | // v v |
| 233 | // [..xx|..yy|..zz|..ww] where '.' means an ignored bit |
| 234 | // |
| 235 | // This format makes it easy to write calls with hexadecimal select values, |
| 236 | // since each hex digit is a separate swizzle index. |
| 237 | // |
| 238 | // For example: |
| 239 | // createSwizzle4( [a,b,c,d], 0x0123 ) -> [a,b,c,d] |
| 240 | // createSwizzle4( [a,b,c,d], 0x0033 ) -> [a,a,d,d] |
| 241 | // |
| 242 | static Value *createSwizzle4(Value *val, uint16_t select) |
| 243 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 244 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 245 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 246 | (select >> 8) & 0x03, |
| 247 | (select >> 4) & 0x03, |
| 248 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 249 | }; |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 251 | return Nucleus::createShuffleVector(val, val, swizzle); |
| 252 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 253 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 254 | static Value *createMask4(Value *lhs, Value *rhs, uint16_t select) |
| 255 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 256 | bool mask[4] = { false, false, false, false }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 257 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 258 | mask[(select >> 12) & 0x03] = true; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 259 | mask[(select >> 8) & 0x03] = true; |
| 260 | mask[(select >> 4) & 0x03] = true; |
| 261 | mask[(select >> 0) & 0x03] = true; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 262 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 263 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 264 | mask[0] ? 4 : 0, |
| 265 | mask[1] ? 5 : 1, |
| 266 | mask[2] ? 6 : 2, |
| 267 | mask[3] ? 7 : 3, |
| 268 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 269 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 270 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 271 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 272 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 273 | Bool::Bool(Argument<Bool> argument) |
| 274 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 275 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 276 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 277 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 278 | Bool::Bool(bool x) |
| 279 | { |
| 280 | storeValue(Nucleus::createConstantBool(x)); |
| 281 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 282 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 283 | Bool::Bool(RValue<Bool> rhs) |
| 284 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 285 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 286 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 287 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 288 | Bool::Bool(const Bool &rhs) |
| 289 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 290 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 291 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 292 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 293 | Bool::Bool(const Reference<Bool> &rhs) |
| 294 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 295 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 296 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 297 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 298 | RValue<Bool> Bool::operator=(RValue<Bool> rhs) |
| 299 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 300 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 301 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 302 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 303 | RValue<Bool> Bool::operator=(const Bool &rhs) |
| 304 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 305 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 306 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 307 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 308 | RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) |
| 309 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 310 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 311 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 312 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 313 | RValue<Bool> operator!(RValue<Bool> val) |
| 314 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 315 | return RValue<Bool>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 316 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 317 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 318 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) |
| 319 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 320 | return RValue<Bool>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 321 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 322 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 323 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) |
| 324 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 325 | return RValue<Bool>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 326 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 327 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 328 | RValue<Bool> operator!=(RValue<Bool> lhs, RValue<Bool> rhs) |
| 329 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 330 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 331 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 332 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 333 | RValue<Bool> operator==(RValue<Bool> lhs, RValue<Bool> rhs) |
| 334 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 335 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 336 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 337 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 338 | Byte::Byte(Argument<Byte> argument) |
| 339 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 340 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 341 | } |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 342 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 343 | Byte::Byte(RValue<Int> cast) |
| 344 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 345 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 346 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 347 | storeValue(integer); |
| 348 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 349 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 350 | Byte::Byte(RValue<UInt> cast) |
| 351 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 352 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 353 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 354 | storeValue(integer); |
| 355 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 356 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 357 | Byte::Byte(RValue<UShort> cast) |
| 358 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 359 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 360 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 361 | storeValue(integer); |
| 362 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 363 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 364 | Byte::Byte(int x) |
| 365 | { |
| 366 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
| 367 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 368 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 369 | Byte::Byte(unsigned char x) |
| 370 | { |
| 371 | storeValue(Nucleus::createConstantByte(x)); |
| 372 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 373 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 374 | Byte::Byte(RValue<Byte> rhs) |
| 375 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 376 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 377 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 378 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 379 | Byte::Byte(const Byte &rhs) |
| 380 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 381 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 382 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 383 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 384 | Byte::Byte(const Reference<Byte> &rhs) |
| 385 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 386 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 387 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 388 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 389 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) |
| 390 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 391 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 392 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 393 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 394 | RValue<Byte> Byte::operator=(const Byte &rhs) |
| 395 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 396 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 397 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 398 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 399 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) |
| 400 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 401 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 402 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 403 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 404 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
| 405 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 406 | return RValue<Byte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 407 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 408 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 409 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
| 410 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 411 | return RValue<Byte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 412 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 413 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 414 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
| 415 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 416 | return RValue<Byte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 417 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 418 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 419 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
| 420 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 421 | return RValue<Byte>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 422 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 423 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 424 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
| 425 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 426 | return RValue<Byte>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 427 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 428 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 429 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
| 430 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 431 | return RValue<Byte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 432 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 433 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 434 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
| 435 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 436 | return RValue<Byte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 437 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 438 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 439 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
| 440 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 441 | return RValue<Byte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 442 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 443 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 444 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 445 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 446 | return RValue<Byte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 447 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 448 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 449 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 450 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 451 | return RValue<Byte>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 452 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 453 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 454 | RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs) |
| 455 | { |
| 456 | return lhs = lhs + rhs; |
| 457 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 458 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 459 | RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs) |
| 460 | { |
| 461 | return lhs = lhs - rhs; |
| 462 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 463 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 464 | RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs) |
| 465 | { |
| 466 | return lhs = lhs * rhs; |
| 467 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 468 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 469 | RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs) |
| 470 | { |
| 471 | return lhs = lhs / rhs; |
| 472 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 473 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 474 | RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs) |
| 475 | { |
| 476 | return lhs = lhs % rhs; |
| 477 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 478 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 479 | RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs) |
| 480 | { |
| 481 | return lhs = lhs & rhs; |
| 482 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 483 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 484 | RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs) |
| 485 | { |
| 486 | return lhs = lhs | rhs; |
| 487 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 488 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 489 | RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs) |
| 490 | { |
| 491 | return lhs = lhs ^ rhs; |
| 492 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 493 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 494 | RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs) |
| 495 | { |
| 496 | return lhs = lhs << rhs; |
| 497 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 498 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 499 | RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs) |
| 500 | { |
| 501 | return lhs = lhs >> rhs; |
| 502 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 503 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 504 | RValue<Byte> operator+(RValue<Byte> val) |
| 505 | { |
| 506 | return val; |
| 507 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 508 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 509 | RValue<Byte> operator-(RValue<Byte> val) |
| 510 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 511 | return RValue<Byte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 512 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 513 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 514 | RValue<Byte> operator~(RValue<Byte> val) |
| 515 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 516 | return RValue<Byte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 517 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 518 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 519 | RValue<Byte> operator++(Byte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 520 | { |
| 521 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 522 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 523 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 524 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 525 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 526 | return res; |
| 527 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 528 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 529 | const Byte &operator++(Byte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 530 | { |
| 531 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 532 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 533 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 534 | return val; |
| 535 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 536 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 537 | RValue<Byte> operator--(Byte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 538 | { |
| 539 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 540 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 541 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 542 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 543 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 544 | return res; |
| 545 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 546 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 547 | const Byte &operator--(Byte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 548 | { |
| 549 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 550 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 551 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 552 | return val; |
| 553 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 554 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 555 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 556 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 557 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 558 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 559 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 560 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 561 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 562 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 563 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 564 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 565 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 566 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 567 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 568 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 569 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 570 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 571 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 572 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 573 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 574 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 575 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 576 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 577 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 578 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 579 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 580 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
| 581 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 582 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 583 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 584 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 585 | SByte::SByte(Argument<SByte> argument) |
| 586 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 587 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 588 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 589 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 590 | SByte::SByte(RValue<Int> cast) |
| 591 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 592 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 593 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 594 | storeValue(integer); |
| 595 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 596 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 597 | SByte::SByte(RValue<Short> cast) |
| 598 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 599 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 600 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 601 | storeValue(integer); |
| 602 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 603 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 604 | SByte::SByte(signed char x) |
| 605 | { |
| 606 | storeValue(Nucleus::createConstantByte(x)); |
| 607 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 608 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 609 | SByte::SByte(RValue<SByte> rhs) |
| 610 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 611 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 612 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 613 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 614 | SByte::SByte(const SByte &rhs) |
| 615 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 616 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 617 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 618 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 619 | SByte::SByte(const Reference<SByte> &rhs) |
| 620 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 621 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 622 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 623 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 624 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) |
| 625 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 626 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 627 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 628 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 629 | RValue<SByte> SByte::operator=(const SByte &rhs) |
| 630 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 631 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 632 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 633 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 634 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) |
| 635 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 636 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 637 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 638 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 639 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
| 640 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 641 | return RValue<SByte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 642 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 643 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 644 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
| 645 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 646 | return RValue<SByte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 647 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 648 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 649 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
| 650 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 651 | return RValue<SByte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 652 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 653 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 654 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
| 655 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 656 | return RValue<SByte>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 657 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 658 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 659 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) |
| 660 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 661 | return RValue<SByte>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 662 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 663 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 664 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) |
| 665 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 666 | return RValue<SByte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 667 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 668 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 669 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) |
| 670 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 671 | return RValue<SByte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 672 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 673 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 674 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) |
| 675 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 676 | return RValue<SByte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 677 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 678 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 679 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 680 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 681 | return RValue<SByte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 682 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 683 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 684 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 685 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 686 | return RValue<SByte>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 687 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 688 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 689 | RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs) |
| 690 | { |
| 691 | return lhs = lhs + rhs; |
| 692 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 693 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 694 | RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs) |
| 695 | { |
| 696 | return lhs = lhs - rhs; |
| 697 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 698 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 699 | RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs) |
| 700 | { |
| 701 | return lhs = lhs * rhs; |
| 702 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 703 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 704 | RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs) |
| 705 | { |
| 706 | return lhs = lhs / rhs; |
| 707 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 708 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 709 | RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs) |
| 710 | { |
| 711 | return lhs = lhs % rhs; |
| 712 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 713 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 714 | RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs) |
| 715 | { |
| 716 | return lhs = lhs & rhs; |
| 717 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 718 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 719 | RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs) |
| 720 | { |
| 721 | return lhs = lhs | rhs; |
| 722 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 723 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 724 | RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs) |
| 725 | { |
| 726 | return lhs = lhs ^ rhs; |
| 727 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 728 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 729 | RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs) |
| 730 | { |
| 731 | return lhs = lhs << rhs; |
| 732 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 733 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 734 | RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs) |
| 735 | { |
| 736 | return lhs = lhs >> rhs; |
| 737 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 738 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 739 | RValue<SByte> operator+(RValue<SByte> val) |
| 740 | { |
| 741 | return val; |
| 742 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 743 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 744 | RValue<SByte> operator-(RValue<SByte> val) |
| 745 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 746 | return RValue<SByte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 747 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 748 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 749 | RValue<SByte> operator~(RValue<SByte> val) |
| 750 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 751 | return RValue<SByte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 752 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 753 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 754 | RValue<SByte> operator++(SByte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 755 | { |
| 756 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 757 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 758 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 759 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 760 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 761 | return res; |
| 762 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 763 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 764 | const SByte &operator++(SByte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 765 | { |
| 766 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 767 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 768 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 769 | return val; |
| 770 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 771 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 772 | RValue<SByte> operator--(SByte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 773 | { |
| 774 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 775 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 776 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 777 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 778 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 779 | return res; |
| 780 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 781 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 782 | const SByte &operator--(SByte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 783 | { |
| 784 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 785 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 786 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 787 | return val; |
| 788 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 789 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 790 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 791 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 792 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 793 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 794 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 795 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 796 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 797 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 798 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 799 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 800 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 801 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 802 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 803 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 804 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 805 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 806 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 807 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 808 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 809 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 810 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 811 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 812 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 813 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 814 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 815 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) |
| 816 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 817 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 818 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 819 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 820 | Short::Short(Argument<Short> argument) |
| 821 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 822 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 823 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 824 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 825 | Short::Short(RValue<Int> cast) |
| 826 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 827 | Value *integer = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 828 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 829 | storeValue(integer); |
| 830 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 831 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 832 | Short::Short(short x) |
| 833 | { |
| 834 | storeValue(Nucleus::createConstantShort(x)); |
| 835 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 836 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 837 | Short::Short(RValue<Short> rhs) |
| 838 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 839 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 840 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 841 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 842 | Short::Short(const Short &rhs) |
| 843 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 844 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 845 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 846 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 847 | Short::Short(const Reference<Short> &rhs) |
| 848 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 849 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 850 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 851 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 852 | RValue<Short> Short::operator=(RValue<Short> rhs) |
| 853 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 854 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 855 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 856 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 857 | RValue<Short> Short::operator=(const Short &rhs) |
| 858 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 859 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 860 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 861 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 862 | RValue<Short> Short::operator=(const Reference<Short> &rhs) |
| 863 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 864 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 865 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 866 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 867 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
| 868 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 869 | return RValue<Short>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 870 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 871 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 872 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
| 873 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 874 | return RValue<Short>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 875 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 876 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 877 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
| 878 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 879 | return RValue<Short>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 880 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 881 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 882 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
| 883 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 884 | return RValue<Short>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 885 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 886 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 887 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) |
| 888 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 889 | return RValue<Short>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 890 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 891 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 892 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) |
| 893 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 894 | return RValue<Short>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 895 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 896 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 897 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) |
| 898 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 899 | return RValue<Short>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 900 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 901 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 902 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) |
| 903 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 904 | return RValue<Short>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 905 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 906 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 907 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) |
| 908 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 909 | return RValue<Short>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 910 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 911 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 912 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) |
| 913 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 914 | return RValue<Short>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 915 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 916 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 917 | RValue<Short> operator+=(Short &lhs, RValue<Short> rhs) |
| 918 | { |
| 919 | return lhs = lhs + rhs; |
| 920 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 921 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 922 | RValue<Short> operator-=(Short &lhs, RValue<Short> rhs) |
| 923 | { |
| 924 | return lhs = lhs - rhs; |
| 925 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 926 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 927 | RValue<Short> operator*=(Short &lhs, RValue<Short> rhs) |
| 928 | { |
| 929 | return lhs = lhs * rhs; |
| 930 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 931 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 932 | RValue<Short> operator/=(Short &lhs, RValue<Short> rhs) |
| 933 | { |
| 934 | return lhs = lhs / rhs; |
| 935 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 936 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 937 | RValue<Short> operator%=(Short &lhs, RValue<Short> rhs) |
| 938 | { |
| 939 | return lhs = lhs % rhs; |
| 940 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 941 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 942 | RValue<Short> operator&=(Short &lhs, RValue<Short> rhs) |
| 943 | { |
| 944 | return lhs = lhs & rhs; |
| 945 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 946 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 947 | RValue<Short> operator|=(Short &lhs, RValue<Short> rhs) |
| 948 | { |
| 949 | return lhs = lhs | rhs; |
| 950 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 951 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 952 | RValue<Short> operator^=(Short &lhs, RValue<Short> rhs) |
| 953 | { |
| 954 | return lhs = lhs ^ rhs; |
| 955 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 956 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 957 | RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs) |
| 958 | { |
| 959 | return lhs = lhs << rhs; |
| 960 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 961 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 962 | RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs) |
| 963 | { |
| 964 | return lhs = lhs >> rhs; |
| 965 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 966 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 967 | RValue<Short> operator+(RValue<Short> val) |
| 968 | { |
| 969 | return val; |
| 970 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 971 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 972 | RValue<Short> operator-(RValue<Short> val) |
| 973 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 974 | return RValue<Short>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 975 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 976 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 977 | RValue<Short> operator~(RValue<Short> val) |
| 978 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 979 | return RValue<Short>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 980 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 981 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 982 | RValue<Short> operator++(Short &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 983 | { |
| 984 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 985 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 986 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 987 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 988 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 989 | return res; |
| 990 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 991 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 992 | const Short &operator++(Short &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 993 | { |
| 994 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 995 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 996 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 997 | return val; |
| 998 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 999 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1000 | RValue<Short> operator--(Short &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1001 | { |
| 1002 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1003 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1004 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1005 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1006 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1007 | return res; |
| 1008 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1009 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1010 | const Short &operator--(Short &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1011 | { |
| 1012 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 1013 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1014 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1015 | return val; |
| 1016 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1017 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1018 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
| 1019 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1020 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1021 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1022 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1023 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
| 1024 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1025 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1026 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1027 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1028 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
| 1029 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1030 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1031 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1032 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1033 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
| 1034 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1035 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1036 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1037 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1038 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) |
| 1039 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1040 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1041 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1042 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1043 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) |
| 1044 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1045 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1046 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1047 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1048 | UShort::UShort(Argument<UShort> argument) |
| 1049 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1050 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1051 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1052 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1053 | UShort::UShort(RValue<UInt> cast) |
| 1054 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1055 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1056 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1057 | storeValue(integer); |
| 1058 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1059 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1060 | UShort::UShort(RValue<Int> cast) |
| 1061 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1062 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1063 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1064 | storeValue(integer); |
| 1065 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1066 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1067 | UShort::UShort(unsigned short x) |
| 1068 | { |
| 1069 | storeValue(Nucleus::createConstantShort(x)); |
| 1070 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1071 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1072 | UShort::UShort(RValue<UShort> rhs) |
| 1073 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1074 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1075 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1076 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1077 | UShort::UShort(const UShort &rhs) |
| 1078 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1079 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1080 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1081 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1082 | UShort::UShort(const Reference<UShort> &rhs) |
| 1083 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1084 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1085 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1086 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1087 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) |
| 1088 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1089 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1090 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1091 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1092 | RValue<UShort> UShort::operator=(const UShort &rhs) |
| 1093 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1094 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1095 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1096 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1097 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) |
| 1098 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1099 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1100 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1101 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1102 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1103 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1104 | return RValue<UShort>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1105 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1106 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1107 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1108 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1109 | return RValue<UShort>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1110 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1111 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1112 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1113 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1114 | return RValue<UShort>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1115 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1116 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1117 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1118 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1119 | return RValue<UShort>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1120 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1121 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1122 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1123 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1124 | return RValue<UShort>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1125 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1126 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1127 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1128 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1129 | return RValue<UShort>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1130 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1131 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1132 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1133 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1134 | return RValue<UShort>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1135 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1136 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1137 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1138 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1139 | return RValue<UShort>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1140 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1141 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1142 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1143 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1144 | return RValue<UShort>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1145 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1146 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1147 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1148 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1149 | return RValue<UShort>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1150 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1151 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1152 | RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs) |
| 1153 | { |
| 1154 | return lhs = lhs + rhs; |
| 1155 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1156 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1157 | RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs) |
| 1158 | { |
| 1159 | return lhs = lhs - rhs; |
| 1160 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1161 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1162 | RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs) |
| 1163 | { |
| 1164 | return lhs = lhs * rhs; |
| 1165 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1166 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1167 | RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs) |
| 1168 | { |
| 1169 | return lhs = lhs / rhs; |
| 1170 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1171 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1172 | RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs) |
| 1173 | { |
| 1174 | return lhs = lhs % rhs; |
| 1175 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1176 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1177 | RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs) |
| 1178 | { |
| 1179 | return lhs = lhs & rhs; |
| 1180 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1181 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1182 | RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs) |
| 1183 | { |
| 1184 | return lhs = lhs | rhs; |
| 1185 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1186 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1187 | RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs) |
| 1188 | { |
| 1189 | return lhs = lhs ^ rhs; |
| 1190 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1191 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1192 | RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs) |
| 1193 | { |
| 1194 | return lhs = lhs << rhs; |
| 1195 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1196 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1197 | RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs) |
| 1198 | { |
| 1199 | return lhs = lhs >> rhs; |
| 1200 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1201 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1202 | RValue<UShort> operator+(RValue<UShort> val) |
| 1203 | { |
| 1204 | return val; |
| 1205 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1206 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1207 | RValue<UShort> operator-(RValue<UShort> val) |
| 1208 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1209 | return RValue<UShort>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1210 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1211 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1212 | RValue<UShort> operator~(RValue<UShort> val) |
| 1213 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1214 | return RValue<UShort>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1215 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1216 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1217 | RValue<UShort> operator++(UShort &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1218 | { |
| 1219 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1220 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1221 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1222 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1223 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1224 | return res; |
| 1225 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1226 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1227 | const UShort &operator++(UShort &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1228 | { |
| 1229 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1230 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1231 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1232 | return val; |
| 1233 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1234 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1235 | RValue<UShort> operator--(UShort &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1236 | { |
| 1237 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1238 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1239 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1240 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1241 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1242 | return res; |
| 1243 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1244 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1245 | const UShort &operator--(UShort &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1246 | { |
| 1247 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1248 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1249 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1250 | return val; |
| 1251 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1252 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1253 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1254 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1255 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1256 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1257 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1258 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1259 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1260 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1261 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1262 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1263 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1264 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1265 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1266 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1267 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1268 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1269 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1270 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1271 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1272 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1273 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1274 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1275 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1276 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1277 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1278 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1279 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1280 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1281 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1282 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1283 | Byte4::Byte4(RValue<Byte8> cast) |
| 1284 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1285 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1286 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1287 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1288 | Byte4::Byte4(RValue<UShort4> cast) |
| 1289 | { |
| 1290 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1291 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1292 | } |
| 1293 | |
| 1294 | Byte4::Byte4(RValue<Short4> cast) |
| 1295 | { |
| 1296 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1297 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1298 | } |
| 1299 | |
| 1300 | Byte4::Byte4(RValue<UInt4> cast) |
| 1301 | { |
| 1302 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1303 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1304 | } |
| 1305 | |
| 1306 | Byte4::Byte4(RValue<Int4> cast) |
| 1307 | { |
| 1308 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1309 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1310 | } |
| 1311 | |
| 1312 | Byte4::Byte4(RValue<Byte4> rhs) |
| 1313 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1314 | store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1315 | } |
| 1316 | |
| 1317 | Byte4::Byte4(const Byte4 &rhs) |
| 1318 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1319 | store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1320 | } |
| 1321 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1322 | Byte4::Byte4(const Reference<Byte4> &rhs) |
| 1323 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1324 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1325 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1326 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1327 | RValue<Byte4> Byte4::operator=(RValue<Byte4> rhs) |
| 1328 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1329 | return store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | RValue<Byte4> Byte4::operator=(const Byte4 &rhs) |
| 1333 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1334 | return store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1335 | } |
| 1336 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1337 | Byte8::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) |
| 1338 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1339 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1340 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1341 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1342 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1343 | Byte8::Byte8(RValue<Byte8> rhs) |
| 1344 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1345 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1346 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1347 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1348 | Byte8::Byte8(const Byte8 &rhs) |
| 1349 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1350 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1351 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1352 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1353 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 1354 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1355 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1356 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1357 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1358 | RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) |
| 1359 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1360 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1361 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1362 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1363 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) |
| 1364 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1365 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1366 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1367 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1368 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) |
| 1369 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1370 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1371 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1372 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1373 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1374 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1375 | return RValue<Byte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1376 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1377 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1378 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1379 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1380 | return RValue<Byte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1381 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1382 | |
| 1383 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1384 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1385 | // return RValue<Byte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1386 | // } |
| 1387 | |
| 1388 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1389 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1390 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1391 | // } |
| 1392 | |
| 1393 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1394 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1395 | // return RValue<Byte8>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1396 | // } |
| 1397 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1398 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1399 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1400 | return RValue<Byte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1401 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1402 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1403 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1404 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1405 | return RValue<Byte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1406 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1407 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1408 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1409 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1410 | return RValue<Byte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1411 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1412 | |
| 1413 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
| 1414 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1415 | // return RValue<Byte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1416 | // } |
| 1417 | |
| 1418 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
| 1419 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1420 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1421 | // } |
| 1422 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1423 | RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1424 | { |
| 1425 | return lhs = lhs + rhs; |
| 1426 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1427 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1428 | RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1429 | { |
| 1430 | return lhs = lhs - rhs; |
| 1431 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1432 | |
| 1433 | // RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1434 | // { |
| 1435 | // return lhs = lhs * rhs; |
| 1436 | // } |
| 1437 | |
| 1438 | // RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1439 | // { |
| 1440 | // return lhs = lhs / rhs; |
| 1441 | // } |
| 1442 | |
| 1443 | // RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1444 | // { |
| 1445 | // return lhs = lhs % rhs; |
| 1446 | // } |
| 1447 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1448 | RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1449 | { |
| 1450 | return lhs = lhs & rhs; |
| 1451 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1452 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1453 | RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1454 | { |
| 1455 | return lhs = lhs | rhs; |
| 1456 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1457 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1458 | RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1459 | { |
| 1460 | return lhs = lhs ^ rhs; |
| 1461 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1462 | |
| 1463 | // RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1464 | // { |
| 1465 | // return lhs = lhs << rhs; |
| 1466 | // } |
| 1467 | |
| 1468 | // RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1469 | // { |
| 1470 | // return lhs = lhs >> rhs; |
| 1471 | // } |
| 1472 | |
| 1473 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 1474 | // { |
| 1475 | // return val; |
| 1476 | // } |
| 1477 | |
| 1478 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 1479 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1480 | // return RValue<Byte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1481 | // } |
| 1482 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1483 | RValue<Byte8> operator~(RValue<Byte8> val) |
| 1484 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1485 | return RValue<Byte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1486 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1487 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1488 | RValue<Byte8> Swizzle(RValue<Byte8> x, uint32_t select) |
| 1489 | { |
| 1490 | // Real type is v16i8 |
| 1491 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1492 | int shuffle[16] = { |
| 1493 | static_cast<int>((select >> 28) & 0x07), |
| 1494 | static_cast<int>((select >> 24) & 0x07), |
| 1495 | static_cast<int>((select >> 20) & 0x07), |
| 1496 | static_cast<int>((select >> 16) & 0x07), |
| 1497 | static_cast<int>((select >> 12) & 0x07), |
| 1498 | static_cast<int>((select >> 8) & 0x07), |
| 1499 | static_cast<int>((select >> 4) & 0x07), |
| 1500 | static_cast<int>((select >> 0) & 0x07), |
| 1501 | static_cast<int>((select >> 28) & 0x07), |
| 1502 | static_cast<int>((select >> 24) & 0x07), |
| 1503 | static_cast<int>((select >> 20) & 0x07), |
| 1504 | static_cast<int>((select >> 16) & 0x07), |
| 1505 | static_cast<int>((select >> 12) & 0x07), |
| 1506 | static_cast<int>((select >> 8) & 0x07), |
| 1507 | static_cast<int>((select >> 4) & 0x07), |
| 1508 | static_cast<int>((select >> 0) & 0x07), |
| 1509 | }; |
| 1510 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1511 | return As<Byte8>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1512 | } |
| 1513 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1514 | RValue<Short4> Unpack(RValue<Byte4> x) |
| 1515 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1516 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1517 | int shuffle[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1518 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1519 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1520 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1521 | RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y) |
| 1522 | { |
| 1523 | return UnpackLow(As<Byte8>(x), As<Byte8>(y)); |
| 1524 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1525 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1526 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 1527 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1528 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1529 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1530 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1531 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1532 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1533 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
| 1534 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1535 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1536 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1537 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1538 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1539 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1540 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1541 | SByte8::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) |
| 1542 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1543 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1544 | Value *vector = Nucleus::createConstantVector(constantVector, type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1545 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1546 | storeValue(Nucleus::createBitCast(vector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1547 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1548 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1549 | SByte8::SByte8(RValue<SByte8> rhs) |
| 1550 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1551 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1552 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1553 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1554 | SByte8::SByte8(const SByte8 &rhs) |
| 1555 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1556 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1557 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1558 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1559 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 1560 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1561 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1562 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1563 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1564 | RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) |
| 1565 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1566 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1567 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1568 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1569 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) |
| 1570 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1571 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1572 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1573 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1574 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) |
| 1575 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1576 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1577 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1578 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1579 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1580 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1581 | return RValue<SByte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1582 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1583 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1584 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1585 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1586 | return RValue<SByte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1587 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1588 | |
| 1589 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1590 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1591 | // return RValue<SByte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1592 | // } |
| 1593 | |
| 1594 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1595 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1596 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1597 | // } |
| 1598 | |
| 1599 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1600 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1601 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1602 | // } |
| 1603 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1604 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1605 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1606 | return RValue<SByte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1607 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1608 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1609 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1610 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1611 | return RValue<SByte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1612 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1613 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1614 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1615 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1616 | return RValue<SByte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1617 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1618 | |
| 1619 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
| 1620 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1621 | // return RValue<SByte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1622 | // } |
| 1623 | |
| 1624 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
| 1625 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1626 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1627 | // } |
| 1628 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1629 | RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1630 | { |
| 1631 | return lhs = lhs + rhs; |
| 1632 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1633 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1634 | RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1635 | { |
| 1636 | return lhs = lhs - rhs; |
| 1637 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1638 | |
| 1639 | // RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1640 | // { |
| 1641 | // return lhs = lhs * rhs; |
| 1642 | // } |
| 1643 | |
| 1644 | // RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1645 | // { |
| 1646 | // return lhs = lhs / rhs; |
| 1647 | // } |
| 1648 | |
| 1649 | // RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1650 | // { |
| 1651 | // return lhs = lhs % rhs; |
| 1652 | // } |
| 1653 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1654 | RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1655 | { |
| 1656 | return lhs = lhs & rhs; |
| 1657 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1658 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1659 | RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1660 | { |
| 1661 | return lhs = lhs | rhs; |
| 1662 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1663 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1664 | RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1665 | { |
| 1666 | return lhs = lhs ^ rhs; |
| 1667 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1668 | |
| 1669 | // RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1670 | // { |
| 1671 | // return lhs = lhs << rhs; |
| 1672 | // } |
| 1673 | |
| 1674 | // RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1675 | // { |
| 1676 | // return lhs = lhs >> rhs; |
| 1677 | // } |
| 1678 | |
| 1679 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 1680 | // { |
| 1681 | // return val; |
| 1682 | // } |
| 1683 | |
| 1684 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 1685 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1686 | // return RValue<SByte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1687 | // } |
| 1688 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1689 | RValue<SByte8> operator~(RValue<SByte8> val) |
| 1690 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1691 | return RValue<SByte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1692 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1693 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1694 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
| 1695 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1696 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1697 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1698 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1699 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1700 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1701 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
| 1702 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1703 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1704 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1705 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1706 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1707 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1708 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1709 | Byte16::Byte16(RValue<Byte16> rhs) |
| 1710 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1711 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1712 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1713 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1714 | Byte16::Byte16(const Byte16 &rhs) |
| 1715 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1716 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1717 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1718 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1719 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 1720 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1721 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1722 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1723 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1724 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) |
| 1725 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1726 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1727 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1728 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1729 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) |
| 1730 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1731 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1732 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1733 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1734 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) |
| 1735 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1736 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1737 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1738 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1739 | RValue<Byte16> Swizzle(RValue<Byte16> x, uint64_t select) |
| 1740 | { |
| 1741 | int shuffle[16] = { |
| 1742 | static_cast<int>((select >> 60) & 0x0F), |
| 1743 | static_cast<int>((select >> 56) & 0x0F), |
| 1744 | static_cast<int>((select >> 52) & 0x0F), |
| 1745 | static_cast<int>((select >> 48) & 0x0F), |
| 1746 | static_cast<int>((select >> 44) & 0x0F), |
| 1747 | static_cast<int>((select >> 40) & 0x0F), |
| 1748 | static_cast<int>((select >> 36) & 0x0F), |
| 1749 | static_cast<int>((select >> 32) & 0x0F), |
| 1750 | static_cast<int>((select >> 28) & 0x0F), |
| 1751 | static_cast<int>((select >> 24) & 0x0F), |
| 1752 | static_cast<int>((select >> 20) & 0x0F), |
| 1753 | static_cast<int>((select >> 16) & 0x0F), |
| 1754 | static_cast<int>((select >> 12) & 0x0F), |
| 1755 | static_cast<int>((select >> 8) & 0x0F), |
| 1756 | static_cast<int>((select >> 4) & 0x0F), |
| 1757 | static_cast<int>((select >> 0) & 0x0F), |
| 1758 | }; |
| 1759 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1760 | return As<Byte16>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1761 | } |
| 1762 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1763 | Short2::Short2(RValue<Short4> cast) |
| 1764 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1765 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1766 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1767 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1768 | UShort2::UShort2(RValue<UShort4> cast) |
| 1769 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1770 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1771 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1772 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1773 | Short4::Short4(RValue<Int> cast) |
| 1774 | { |
| 1775 | Value *vector = loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1776 | Value *element = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1777 | Value *insert = Nucleus::createInsertElement(vector, element, 0); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1778 | Value *swizzle = Swizzle(RValue<Short4>(insert), 0x0000).value(); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1779 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1780 | storeValue(swizzle); |
| 1781 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1782 | |
| 1783 | // Short4::Short4(RValue<Float> cast) |
| 1784 | // { |
| 1785 | // } |
| 1786 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1787 | Short4::Short4(short xyzw) |
| 1788 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1789 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1790 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1791 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1792 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1793 | Short4::Short4(short x, short y, short z, short w) |
| 1794 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1795 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1796 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1797 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1798 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1799 | Short4::Short4(RValue<Short4> rhs) |
| 1800 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1801 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1802 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1803 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1804 | Short4::Short4(const Short4 &rhs) |
| 1805 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1806 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1807 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1808 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1809 | Short4::Short4(const Reference<Short4> &rhs) |
| 1810 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1811 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1812 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1813 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1814 | Short4::Short4(RValue<UShort4> rhs) |
| 1815 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1816 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1817 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1818 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1819 | Short4::Short4(const UShort4 &rhs) |
| 1820 | { |
| 1821 | storeValue(rhs.loadValue()); |
| 1822 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1823 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1824 | Short4::Short4(const Reference<UShort4> &rhs) |
| 1825 | { |
| 1826 | storeValue(rhs.loadValue()); |
| 1827 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1828 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1829 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) |
| 1830 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1831 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1832 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1833 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1834 | RValue<Short4> Short4::operator=(const Short4 &rhs) |
| 1835 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1836 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1837 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1838 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1839 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) |
| 1840 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1841 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1842 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1843 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1844 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) |
| 1845 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1846 | return RValue<Short4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1847 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1848 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1849 | RValue<Short4> Short4::operator=(const UShort4 &rhs) |
| 1850 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1851 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1852 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1853 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1854 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) |
| 1855 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1856 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1857 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1858 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1859 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1860 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1861 | return RValue<Short4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1862 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1863 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1864 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1865 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1866 | return RValue<Short4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1867 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1868 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1869 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1870 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1871 | return RValue<Short4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1872 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1873 | |
| 1874 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1875 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1876 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1877 | // } |
| 1878 | |
| 1879 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1880 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1881 | // return RValue<Short4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1882 | // } |
| 1883 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1884 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1885 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1886 | return RValue<Short4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1887 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1888 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1889 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1890 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1891 | return RValue<Short4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1892 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1893 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1894 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1895 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1896 | return RValue<Short4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1897 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1898 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1899 | RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs) |
| 1900 | { |
| 1901 | return lhs = lhs + rhs; |
| 1902 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1903 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1904 | RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs) |
| 1905 | { |
| 1906 | return lhs = lhs - rhs; |
| 1907 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1908 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1909 | RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs) |
| 1910 | { |
| 1911 | return lhs = lhs * rhs; |
| 1912 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1913 | |
| 1914 | // RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs) |
| 1915 | // { |
| 1916 | // return lhs = lhs / rhs; |
| 1917 | // } |
| 1918 | |
| 1919 | // RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs) |
| 1920 | // { |
| 1921 | // return lhs = lhs % rhs; |
| 1922 | // } |
| 1923 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1924 | RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs) |
| 1925 | { |
| 1926 | return lhs = lhs & rhs; |
| 1927 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1928 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1929 | RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs) |
| 1930 | { |
| 1931 | return lhs = lhs | rhs; |
| 1932 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1933 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1934 | RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs) |
| 1935 | { |
| 1936 | return lhs = lhs ^ rhs; |
| 1937 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1938 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1939 | RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs) |
| 1940 | { |
| 1941 | return lhs = lhs << rhs; |
| 1942 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1943 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1944 | RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs) |
| 1945 | { |
| 1946 | return lhs = lhs >> rhs; |
| 1947 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1948 | |
| 1949 | // RValue<Short4> operator+(RValue<Short4> val) |
| 1950 | // { |
| 1951 | // return val; |
| 1952 | // } |
| 1953 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1954 | RValue<Short4> operator-(RValue<Short4> val) |
| 1955 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1956 | return RValue<Short4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1957 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1958 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1959 | RValue<Short4> operator~(RValue<Short4> val) |
| 1960 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1961 | return RValue<Short4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1962 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1963 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1964 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
| 1965 | { |
| 1966 | RValue<Int4> int4 = RoundInt(cast); |
| 1967 | return As<Short4>(PackSigned(int4, int4)); |
| 1968 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1969 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1970 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
| 1971 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1972 | int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1973 | return As<Int2>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1974 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1975 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1976 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
| 1977 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1978 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1979 | int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1980 | auto lowHigh = RValue<Short8>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1981 | return As<Int2>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1982 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1983 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1984 | RValue<Short4> Swizzle(RValue<Short4> x, uint16_t select) |
| 1985 | { |
| 1986 | // Real type is v8i16 |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1987 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1988 | int shuffle[8] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1989 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1990 | (select >> 8) & 0x03, |
| 1991 | (select >> 4) & 0x03, |
| 1992 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1993 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1994 | (select >> 8) & 0x03, |
| 1995 | (select >> 4) & 0x03, |
| 1996 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1997 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1998 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1999 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2000 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2001 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2002 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
| 2003 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2004 | return RValue<Short4>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2005 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2006 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2007 | RValue<Short> Extract(RValue<Short4> val, int i) |
| 2008 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2009 | return RValue<Short>(Nucleus::createExtractElement(val.value(), Short::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2010 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2011 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2012 | UShort4::UShort4(RValue<Int4> cast) |
| 2013 | { |
| 2014 | *this = Short4(cast); |
| 2015 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2016 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2017 | UShort4::UShort4(unsigned short xyzw) |
| 2018 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2019 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2020 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2021 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2022 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2023 | UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) |
| 2024 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2025 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2026 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2027 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2028 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2029 | UShort4::UShort4(RValue<UShort4> rhs) |
| 2030 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2031 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2032 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2033 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2034 | UShort4::UShort4(const UShort4 &rhs) |
| 2035 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2036 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2037 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2038 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2039 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 2040 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2041 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2042 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2043 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2044 | UShort4::UShort4(RValue<Short4> rhs) |
| 2045 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2046 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2047 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2048 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2049 | UShort4::UShort4(const Short4 &rhs) |
| 2050 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2051 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2052 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2053 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2054 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 2055 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2056 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2057 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2058 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2059 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) |
| 2060 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2061 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2062 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2063 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2064 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) |
| 2065 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2066 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2067 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2068 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2069 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) |
| 2070 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2071 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2072 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2073 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2074 | RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) |
| 2075 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2076 | return RValue<UShort4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2077 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2078 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2079 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) |
| 2080 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2081 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2082 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2083 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2084 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) |
| 2085 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2086 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2087 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2088 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2089 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2090 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2091 | return RValue<UShort4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2092 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2093 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2094 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2095 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2096 | return RValue<UShort4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2097 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2098 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2099 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2100 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2101 | return RValue<UShort4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2102 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2103 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2104 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2105 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2106 | return RValue<UShort4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2107 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2108 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2109 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2110 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2111 | return RValue<UShort4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2112 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2113 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2114 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2115 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2116 | return RValue<UShort4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2117 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2118 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2119 | RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs) |
| 2120 | { |
| 2121 | return lhs = lhs << rhs; |
| 2122 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2123 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2124 | RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs) |
| 2125 | { |
| 2126 | return lhs = lhs >> rhs; |
| 2127 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2128 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2129 | RValue<UShort4> operator~(RValue<UShort4> val) |
| 2130 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2131 | return RValue<UShort4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2132 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2133 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2134 | Short8::Short8(short c) |
| 2135 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2136 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2137 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2138 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2139 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2140 | Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 2141 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2142 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2143 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2144 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2145 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2146 | Short8::Short8(RValue<Short8> rhs) |
| 2147 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2148 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2149 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2150 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2151 | Short8::Short8(const Reference<Short8> &rhs) |
| 2152 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2153 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2154 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2155 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2156 | Short8::Short8(RValue<Short4> lo, RValue<Short4> hi) |
| 2157 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2158 | int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2159 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2160 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2161 | storeValue(packed); |
| 2162 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2163 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2164 | RValue<Short8> Short8::operator=(RValue<Short8> rhs) |
| 2165 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2166 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2167 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2168 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2169 | RValue<Short8> Short8::operator=(const Short8 &rhs) |
| 2170 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2171 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2172 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2173 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2174 | RValue<Short8> Short8::operator=(const Reference<Short8> &rhs) |
| 2175 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2176 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2177 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2178 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2179 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2180 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2181 | return RValue<Short8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2182 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2183 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2184 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2185 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2186 | return RValue<Short8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2187 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2188 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2189 | RValue<Int4> Abs(RValue<Int4> x) |
| 2190 | { |
| 2191 | // TODO: Optimize. |
| 2192 | auto negative = x >> 31; |
| 2193 | return (x ^ negative) - negative; |
| 2194 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2195 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2196 | UShort8::UShort8(unsigned short c) |
| 2197 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2198 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2199 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2200 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2201 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2202 | UShort8::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) |
| 2203 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2204 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2205 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2206 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2207 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2208 | UShort8::UShort8(RValue<UShort8> rhs) |
| 2209 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2210 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2211 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2212 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2213 | UShort8::UShort8(const Reference<UShort8> &rhs) |
| 2214 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2215 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2216 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2217 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2218 | UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi) |
| 2219 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2220 | int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2221 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2222 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2223 | storeValue(packed); |
| 2224 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2225 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2226 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) |
| 2227 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2228 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2229 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2230 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2231 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) |
| 2232 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2233 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2234 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2235 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2236 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) |
| 2237 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2238 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2239 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2240 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2241 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2242 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2243 | return RValue<UShort8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2244 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2245 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2246 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2247 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2248 | return RValue<UShort8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2249 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2251 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2252 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2253 | return RValue<UShort8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2254 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2255 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2256 | RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs) |
| 2257 | { |
| 2258 | return lhs = lhs + rhs; |
| 2259 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2260 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2261 | RValue<UShort8> operator~(RValue<UShort8> val) |
| 2262 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2263 | return RValue<UShort8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2264 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2265 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2266 | RValue<UShort8> Swizzle(RValue<UShort8> x, uint32_t select) |
| 2267 | { |
| 2268 | int swizzle[16] = { |
| 2269 | static_cast<int>((select >> 28) & 0x07), |
| 2270 | static_cast<int>((select >> 24) & 0x07), |
| 2271 | static_cast<int>((select >> 20) & 0x07), |
| 2272 | static_cast<int>((select >> 16) & 0x07), |
| 2273 | static_cast<int>((select >> 12) & 0x07), |
| 2274 | static_cast<int>((select >> 8) & 0x07), |
| 2275 | static_cast<int>((select >> 4) & 0x07), |
| 2276 | static_cast<int>((select >> 0) & 0x07), |
| 2277 | }; |
| 2278 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2279 | return RValue<UShort8>(Nucleus::createShuffleVector(x.value(), x.value(), swizzle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2280 | } |
| 2281 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2282 | Int::Int(Argument<Int> argument) |
| 2283 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2284 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2285 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2286 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2287 | Int::Int(RValue<Byte> cast) |
| 2288 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2289 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2290 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2291 | storeValue(integer); |
| 2292 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2293 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2294 | Int::Int(RValue<SByte> cast) |
| 2295 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2296 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2297 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2298 | storeValue(integer); |
| 2299 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2300 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2301 | Int::Int(RValue<Short> cast) |
| 2302 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2303 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2304 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2305 | storeValue(integer); |
| 2306 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2307 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2308 | Int::Int(RValue<UShort> cast) |
| 2309 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2310 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2311 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2312 | storeValue(integer); |
| 2313 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2314 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2315 | Int::Int(RValue<Int2> cast) |
| 2316 | { |
| 2317 | *this = Extract(cast, 0); |
| 2318 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2319 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2320 | Int::Int(RValue<Long> cast) |
| 2321 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2322 | Value *integer = Nucleus::createTrunc(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2323 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2324 | storeValue(integer); |
| 2325 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2326 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2327 | Int::Int(RValue<Float> cast) |
| 2328 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2329 | Value *integer = Nucleus::createFPToSI(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2330 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2331 | storeValue(integer); |
| 2332 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2333 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2334 | Int::Int(int x) |
| 2335 | { |
| 2336 | storeValue(Nucleus::createConstantInt(x)); |
| 2337 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2338 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2339 | Int::Int(RValue<Int> rhs) |
| 2340 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2341 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2342 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2343 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2344 | Int::Int(RValue<UInt> rhs) |
| 2345 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2346 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2347 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2348 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2349 | Int::Int(const Int &rhs) |
| 2350 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2351 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2352 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2353 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2354 | Int::Int(const Reference<Int> &rhs) |
| 2355 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2356 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2357 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2358 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2359 | Int::Int(const UInt &rhs) |
| 2360 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2361 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2362 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2363 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2364 | Int::Int(const Reference<UInt> &rhs) |
| 2365 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2366 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2367 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2368 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2369 | RValue<Int> Int::operator=(int rhs) |
| 2370 | { |
| 2371 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2372 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2373 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2374 | RValue<Int> Int::operator=(RValue<Int> rhs) |
| 2375 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2376 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2377 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2378 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2379 | RValue<Int> Int::operator=(RValue<UInt> rhs) |
| 2380 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2381 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2382 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2383 | return RValue<Int>(rhs); |
| 2384 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2385 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2386 | RValue<Int> Int::operator=(const Int &rhs) |
| 2387 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2388 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2389 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2390 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2391 | RValue<Int> Int::operator=(const Reference<Int> &rhs) |
| 2392 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2393 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2394 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2395 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2396 | RValue<Int> Int::operator=(const UInt &rhs) |
| 2397 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2398 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2399 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2400 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2401 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) |
| 2402 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2403 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2404 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2405 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2406 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) |
| 2407 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2408 | return RValue<Int>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2409 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2410 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2411 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) |
| 2412 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2413 | return RValue<Int>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2414 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2415 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2416 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) |
| 2417 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2418 | return RValue<Int>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2419 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2420 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2421 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
| 2422 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2423 | return RValue<Int>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2424 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2425 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2426 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
| 2427 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2428 | return RValue<Int>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2429 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2430 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2431 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
| 2432 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2433 | return RValue<Int>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2434 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2435 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2436 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
| 2437 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2438 | return RValue<Int>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2439 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2440 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2441 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
| 2442 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2443 | return RValue<Int>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2444 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2445 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2446 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
| 2447 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2448 | return RValue<Int>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2449 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2450 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2451 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
| 2452 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2453 | return RValue<Int>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2454 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2455 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2456 | RValue<Int> operator+=(Int &lhs, RValue<Int> rhs) |
| 2457 | { |
| 2458 | return lhs = lhs + rhs; |
| 2459 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2460 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2461 | RValue<Int> operator-=(Int &lhs, RValue<Int> rhs) |
| 2462 | { |
| 2463 | return lhs = lhs - rhs; |
| 2464 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2465 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2466 | RValue<Int> operator*=(Int &lhs, RValue<Int> rhs) |
| 2467 | { |
| 2468 | return lhs = lhs * rhs; |
| 2469 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2470 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2471 | RValue<Int> operator/=(Int &lhs, RValue<Int> rhs) |
| 2472 | { |
| 2473 | return lhs = lhs / rhs; |
| 2474 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2475 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2476 | RValue<Int> operator%=(Int &lhs, RValue<Int> rhs) |
| 2477 | { |
| 2478 | return lhs = lhs % rhs; |
| 2479 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2480 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2481 | RValue<Int> operator&=(Int &lhs, RValue<Int> rhs) |
| 2482 | { |
| 2483 | return lhs = lhs & rhs; |
| 2484 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2485 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2486 | RValue<Int> operator|=(Int &lhs, RValue<Int> rhs) |
| 2487 | { |
| 2488 | return lhs = lhs | rhs; |
| 2489 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2490 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2491 | RValue<Int> operator^=(Int &lhs, RValue<Int> rhs) |
| 2492 | { |
| 2493 | return lhs = lhs ^ rhs; |
| 2494 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2495 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2496 | RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs) |
| 2497 | { |
| 2498 | return lhs = lhs << rhs; |
| 2499 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2500 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2501 | RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs) |
| 2502 | { |
| 2503 | return lhs = lhs >> rhs; |
| 2504 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2505 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2506 | RValue<Int> operator+(RValue<Int> val) |
| 2507 | { |
| 2508 | return val; |
| 2509 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2510 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2511 | RValue<Int> operator-(RValue<Int> val) |
| 2512 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2513 | return RValue<Int>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2514 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2515 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2516 | RValue<Int> operator~(RValue<Int> val) |
| 2517 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2518 | return RValue<Int>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2519 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2520 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2521 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
| 2522 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2523 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2524 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2525 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2526 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
| 2527 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2528 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2529 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2530 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2531 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
| 2532 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2533 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2534 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2535 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2536 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
| 2537 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2538 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2539 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2540 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2541 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
| 2542 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2543 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2544 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2545 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2546 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
| 2547 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2548 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2549 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2550 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2551 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 2552 | { |
| 2553 | return IfThenElse(x > y, x, y); |
| 2554 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2555 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2556 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 2557 | { |
| 2558 | return IfThenElse(x < y, x, y); |
| 2559 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2560 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2561 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 2562 | { |
| 2563 | return Min(Max(x, min), max); |
| 2564 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2565 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2566 | Long::Long(RValue<Int> cast) |
| 2567 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2568 | Value *integer = Nucleus::createSExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2569 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2570 | storeValue(integer); |
| 2571 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2572 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2573 | Long::Long(RValue<UInt> cast) |
| 2574 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2575 | Value *integer = Nucleus::createZExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2576 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2577 | storeValue(integer); |
| 2578 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2579 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2580 | Long::Long(RValue<Long> rhs) |
| 2581 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2582 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2583 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2584 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2585 | RValue<Long> Long::operator=(int64_t rhs) |
| 2586 | { |
| 2587 | return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs))); |
| 2588 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2589 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2590 | RValue<Long> Long::operator=(RValue<Long> rhs) |
| 2591 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2592 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2593 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2594 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2595 | RValue<Long> Long::operator=(const Long &rhs) |
| 2596 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2597 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2598 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2599 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2600 | RValue<Long> Long::operator=(const Reference<Long> &rhs) |
| 2601 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2602 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2603 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2604 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2605 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
| 2606 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2607 | return RValue<Long>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2608 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2609 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2610 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
| 2611 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2612 | return RValue<Long>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2613 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2614 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2615 | RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs) |
| 2616 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2617 | return RValue<Long>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2618 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2619 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2620 | RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs) |
| 2621 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2622 | return RValue<Long>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2623 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2624 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2625 | RValue<Long> operator+=(Long &lhs, RValue<Long> rhs) |
| 2626 | { |
| 2627 | return lhs = lhs + rhs; |
| 2628 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2629 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2630 | RValue<Long> operator-=(Long &lhs, RValue<Long> rhs) |
| 2631 | { |
| 2632 | return lhs = lhs - rhs; |
| 2633 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2634 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2635 | RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2636 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2637 | return RValue<Long>(Nucleus::createAtomicAdd(x.value(), y.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2638 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2639 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2640 | RValue<UInt> AddAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2641 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2642 | return RValue<UInt>(Nucleus::createAtomicAdd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2643 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2644 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2645 | RValue<UInt> SubAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2646 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2647 | return RValue<UInt>(Nucleus::createAtomicSub(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2648 | } |
Chris Forbes | 707ed99 | 2019-04-18 18:17:35 -0700 | [diff] [blame] | 2649 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2650 | RValue<UInt> AndAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2651 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2652 | return RValue<UInt>(Nucleus::createAtomicAnd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2653 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2654 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2655 | RValue<UInt> OrAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2656 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2657 | return RValue<UInt>(Nucleus::createAtomicOr(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2658 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2659 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2660 | RValue<UInt> XorAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2661 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2662 | return RValue<UInt>(Nucleus::createAtomicXor(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2663 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2664 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2665 | RValue<UInt> ExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2666 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2667 | return RValue<UInt>(Nucleus::createAtomicExchange(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2668 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2669 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2670 | RValue<UInt> CompareExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, RValue<UInt> compare, std::memory_order memoryOrderEqual, std::memory_order memoryOrderUnequal) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2671 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2672 | return RValue<UInt>(Nucleus::createAtomicCompareExchange(x.value(), y.value(), compare.value(), memoryOrderEqual, memoryOrderUnequal)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2673 | } |
Chris Forbes | a16238d | 2019-04-18 16:31:54 -0700 | [diff] [blame] | 2674 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2675 | UInt::UInt(Argument<UInt> argument) |
| 2676 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2677 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2678 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2679 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2680 | UInt::UInt(RValue<UShort> cast) |
| 2681 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2682 | Value *integer = Nucleus::createZExt(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2683 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2684 | storeValue(integer); |
| 2685 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2686 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2687 | UInt::UInt(RValue<Long> cast) |
| 2688 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2689 | Value *integer = Nucleus::createTrunc(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2690 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2691 | storeValue(integer); |
| 2692 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2693 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2694 | UInt::UInt(int x) |
| 2695 | { |
| 2696 | storeValue(Nucleus::createConstantInt(x)); |
| 2697 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2698 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2699 | UInt::UInt(unsigned int x) |
| 2700 | { |
| 2701 | storeValue(Nucleus::createConstantInt(x)); |
| 2702 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2703 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2704 | UInt::UInt(RValue<UInt> rhs) |
| 2705 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2706 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2707 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2708 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2709 | UInt::UInt(RValue<Int> rhs) |
| 2710 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2711 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2712 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2713 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2714 | UInt::UInt(const UInt &rhs) |
| 2715 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2716 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2717 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2718 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2719 | UInt::UInt(const Reference<UInt> &rhs) |
| 2720 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2721 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2722 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2723 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2724 | UInt::UInt(const Int &rhs) |
| 2725 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2726 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2727 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2728 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2729 | UInt::UInt(const Reference<Int> &rhs) |
| 2730 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2731 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2732 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2733 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2734 | RValue<UInt> UInt::operator=(unsigned int rhs) |
| 2735 | { |
| 2736 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2737 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2738 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2739 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) |
| 2740 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2741 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2742 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2743 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2744 | RValue<UInt> UInt::operator=(RValue<Int> rhs) |
| 2745 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2746 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2747 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2748 | return RValue<UInt>(rhs); |
| 2749 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2750 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2751 | RValue<UInt> UInt::operator=(const UInt &rhs) |
| 2752 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2753 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2754 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2755 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2756 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) |
| 2757 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2758 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2759 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2760 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2761 | RValue<UInt> UInt::operator=(const Int &rhs) |
| 2762 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2763 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2764 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2765 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2766 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) |
| 2767 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2768 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2769 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2770 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2771 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2772 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2773 | return RValue<UInt>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2774 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2775 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2776 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2777 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2778 | return RValue<UInt>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2779 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2780 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2781 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2782 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2783 | return RValue<UInt>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2784 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2785 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2786 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2787 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2788 | return RValue<UInt>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2789 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2790 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2791 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2792 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2793 | return RValue<UInt>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2794 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2795 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2796 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2797 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2798 | return RValue<UInt>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2799 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2800 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2801 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2802 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2803 | return RValue<UInt>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2804 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2805 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2806 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2807 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2808 | return RValue<UInt>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2809 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2810 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2811 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2812 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2813 | return RValue<UInt>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2814 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2815 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2816 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2817 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2818 | return RValue<UInt>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2819 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2820 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2821 | RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs) |
| 2822 | { |
| 2823 | return lhs = lhs + rhs; |
| 2824 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2825 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2826 | RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs) |
| 2827 | { |
| 2828 | return lhs = lhs - rhs; |
| 2829 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2830 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2831 | RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs) |
| 2832 | { |
| 2833 | return lhs = lhs * rhs; |
| 2834 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2835 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2836 | RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs) |
| 2837 | { |
| 2838 | return lhs = lhs / rhs; |
| 2839 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2840 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2841 | RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs) |
| 2842 | { |
| 2843 | return lhs = lhs % rhs; |
| 2844 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2845 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2846 | RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs) |
| 2847 | { |
| 2848 | return lhs = lhs & rhs; |
| 2849 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2850 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2851 | RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs) |
| 2852 | { |
| 2853 | return lhs = lhs | rhs; |
| 2854 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2855 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2856 | RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs) |
| 2857 | { |
| 2858 | return lhs = lhs ^ rhs; |
| 2859 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2860 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2861 | RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs) |
| 2862 | { |
| 2863 | return lhs = lhs << rhs; |
| 2864 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2865 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2866 | RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs) |
| 2867 | { |
| 2868 | return lhs = lhs >> rhs; |
| 2869 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2870 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2871 | RValue<UInt> operator+(RValue<UInt> val) |
| 2872 | { |
| 2873 | return val; |
| 2874 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2875 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2876 | RValue<UInt> operator-(RValue<UInt> val) |
| 2877 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2878 | return RValue<UInt>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2879 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2880 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2881 | RValue<UInt> operator~(RValue<UInt> val) |
| 2882 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2883 | return RValue<UInt>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2884 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2885 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2886 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 2887 | { |
| 2888 | return IfThenElse(x > y, x, y); |
| 2889 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2890 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2891 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 2892 | { |
| 2893 | return IfThenElse(x < y, x, y); |
| 2894 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2895 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2896 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 2897 | { |
| 2898 | return Min(Max(x, min), max); |
| 2899 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2900 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2901 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2902 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2903 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2904 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2905 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2906 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2907 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2908 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2909 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2910 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2911 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2912 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2913 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2914 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2915 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2916 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2917 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2918 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2919 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2920 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2921 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2922 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2923 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2924 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2925 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2926 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2927 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2928 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2929 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2930 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2931 | Int2::Int2(RValue<Int4> cast) |
| 2932 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2933 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2934 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2935 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2936 | Int2::Int2(int x, int y) |
| 2937 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2938 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2939 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2940 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2941 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2942 | Int2::Int2(RValue<Int2> rhs) |
| 2943 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2944 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2945 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2946 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2947 | Int2::Int2(const Int2 &rhs) |
| 2948 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2949 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2950 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2951 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2952 | Int2::Int2(const Reference<Int2> &rhs) |
| 2953 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2954 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2955 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2956 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2957 | Int2::Int2(RValue<Int> lo, RValue<Int> hi) |
| 2958 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2959 | int shuffle[4] = { 0, 4, 1, 5 }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2960 | Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2961 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2962 | storeValue(Nucleus::createBitCast(packed, Int2::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2963 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2964 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2965 | RValue<Int2> Int2::operator=(RValue<Int2> rhs) |
| 2966 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2967 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2968 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2969 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2970 | RValue<Int2> Int2::operator=(const Int2 &rhs) |
| 2971 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2972 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2973 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2974 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2975 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) |
| 2976 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2977 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2978 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2979 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2980 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2981 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2982 | return RValue<Int2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2983 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2984 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2985 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2986 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2987 | return RValue<Int2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2988 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2989 | |
| 2990 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2991 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2992 | // return RValue<Int2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2993 | // } |
| 2994 | |
| 2995 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2996 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2997 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2998 | // } |
| 2999 | |
| 3000 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3001 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3002 | // return RValue<Int2>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3003 | // } |
| 3004 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3005 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3006 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3007 | return RValue<Int2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3008 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3009 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3010 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3011 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3012 | return RValue<Int2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3013 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3014 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3015 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3016 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3017 | return RValue<Int2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3018 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3019 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3020 | RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs) |
| 3021 | { |
| 3022 | return lhs = lhs + rhs; |
| 3023 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3024 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3025 | RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs) |
| 3026 | { |
| 3027 | return lhs = lhs - rhs; |
| 3028 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3029 | |
| 3030 | // RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs) |
| 3031 | // { |
| 3032 | // return lhs = lhs * rhs; |
| 3033 | // } |
| 3034 | |
| 3035 | // RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs) |
| 3036 | // { |
| 3037 | // return lhs = lhs / rhs; |
| 3038 | // } |
| 3039 | |
| 3040 | // RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs) |
| 3041 | // { |
| 3042 | // return lhs = lhs % rhs; |
| 3043 | // } |
| 3044 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3045 | RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs) |
| 3046 | { |
| 3047 | return lhs = lhs & rhs; |
| 3048 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3049 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3050 | RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs) |
| 3051 | { |
| 3052 | return lhs = lhs | rhs; |
| 3053 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3054 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3055 | RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs) |
| 3056 | { |
| 3057 | return lhs = lhs ^ rhs; |
| 3058 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3059 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3060 | RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs) |
| 3061 | { |
| 3062 | return lhs = lhs << rhs; |
| 3063 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3064 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3065 | RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs) |
| 3066 | { |
| 3067 | return lhs = lhs >> rhs; |
| 3068 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3069 | |
| 3070 | // RValue<Int2> operator+(RValue<Int2> val) |
| 3071 | // { |
| 3072 | // return val; |
| 3073 | // } |
| 3074 | |
| 3075 | // RValue<Int2> operator-(RValue<Int2> val) |
| 3076 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3077 | // return RValue<Int2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3078 | // } |
| 3079 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3080 | RValue<Int2> operator~(RValue<Int2> val) |
| 3081 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3082 | return RValue<Int2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3083 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3084 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3085 | RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
| 3086 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3087 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3088 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3089 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3090 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3091 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3092 | RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
| 3093 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3094 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3095 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3096 | auto lowHigh = RValue<Int4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3097 | return As<Short4>(Swizzle(lowHigh, 0x2323)); |
| 3098 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3099 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3100 | RValue<Int> Extract(RValue<Int2> val, int i) |
| 3101 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3102 | return RValue<Int>(Nucleus::createExtractElement(val.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3103 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3104 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3105 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
| 3106 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3107 | return RValue<Int2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3108 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3109 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3110 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 3111 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3112 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3113 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3114 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3115 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3116 | UInt2::UInt2(RValue<UInt2> rhs) |
| 3117 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3118 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3119 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3120 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3121 | UInt2::UInt2(const UInt2 &rhs) |
| 3122 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3123 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3124 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3125 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3126 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 3127 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3128 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3129 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3130 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3131 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) |
| 3132 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3133 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3134 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3135 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3136 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) |
| 3137 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3138 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3139 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3140 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3141 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) |
| 3142 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3143 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3144 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3145 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3146 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3147 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3148 | return RValue<UInt2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3149 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3150 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3151 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3152 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3153 | return RValue<UInt2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3154 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3155 | |
| 3156 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3157 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3158 | // return RValue<UInt2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3159 | // } |
| 3160 | |
| 3161 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3162 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3163 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3164 | // } |
| 3165 | |
| 3166 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3167 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3168 | // return RValue<UInt2>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3169 | // } |
| 3170 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3171 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3172 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3173 | return RValue<UInt2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3174 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3175 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3176 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3177 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3178 | return RValue<UInt2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3179 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3180 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3181 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3182 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3183 | return RValue<UInt2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3184 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3185 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3186 | RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3187 | { |
| 3188 | return lhs = lhs + rhs; |
| 3189 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3190 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3191 | RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3192 | { |
| 3193 | return lhs = lhs - rhs; |
| 3194 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3195 | |
| 3196 | // RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3197 | // { |
| 3198 | // return lhs = lhs * rhs; |
| 3199 | // } |
| 3200 | |
| 3201 | // RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3202 | // { |
| 3203 | // return lhs = lhs / rhs; |
| 3204 | // } |
| 3205 | |
| 3206 | // RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3207 | // { |
| 3208 | // return lhs = lhs % rhs; |
| 3209 | // } |
| 3210 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3211 | RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3212 | { |
| 3213 | return lhs = lhs & rhs; |
| 3214 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3215 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3216 | RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3217 | { |
| 3218 | return lhs = lhs | rhs; |
| 3219 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3220 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3221 | RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3222 | { |
| 3223 | return lhs = lhs ^ rhs; |
| 3224 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3225 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3226 | RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs) |
| 3227 | { |
| 3228 | return lhs = lhs << rhs; |
| 3229 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3230 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3231 | RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs) |
| 3232 | { |
| 3233 | return lhs = lhs >> rhs; |
| 3234 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3235 | |
| 3236 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 3237 | // { |
| 3238 | // return val; |
| 3239 | // } |
| 3240 | |
| 3241 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 3242 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3243 | // return RValue<UInt2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3244 | // } |
| 3245 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3246 | RValue<UInt2> operator~(RValue<UInt2> val) |
| 3247 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3248 | return RValue<UInt2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3249 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3251 | RValue<UInt> Extract(RValue<UInt2> val, int i) |
| 3252 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3253 | return RValue<UInt>(Nucleus::createExtractElement(val.value(), UInt::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3254 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3255 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3256 | RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i) |
| 3257 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3258 | return RValue<UInt2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3259 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3260 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3261 | Int4::Int4() |
| 3262 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3263 | { |
| 3264 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3265 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3266 | Int4::Int4(RValue<Float4> cast) |
| 3267 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3268 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3269 | Value *xyzw = Nucleus::createFPToSI(cast.value(), Int4::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3270 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3271 | storeValue(xyzw); |
| 3272 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3273 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3274 | Int4::Int4(int xyzw) |
| 3275 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3276 | { |
| 3277 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3278 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3279 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3280 | Int4::Int4(int x, int yzw) |
| 3281 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3282 | { |
| 3283 | constant(x, yzw, yzw, yzw); |
| 3284 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3285 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3286 | Int4::Int4(int x, int y, int zw) |
| 3287 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3288 | { |
| 3289 | constant(x, y, zw, zw); |
| 3290 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3291 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3292 | Int4::Int4(int x, int y, int z, int w) |
| 3293 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3294 | { |
| 3295 | constant(x, y, z, w); |
| 3296 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3297 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3298 | void Int4::constant(int x, int y, int z, int w) |
| 3299 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3300 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3301 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3302 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3303 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3304 | Int4::Int4(RValue<Int4> rhs) |
| 3305 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3306 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3307 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3308 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3309 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3310 | Int4::Int4(const Int4 &rhs) |
| 3311 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3312 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3313 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3314 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3315 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3316 | Int4::Int4(const Reference<Int4> &rhs) |
| 3317 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3318 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3319 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3320 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3321 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3322 | Int4::Int4(RValue<UInt4> rhs) |
| 3323 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3324 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3325 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3326 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3327 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3328 | Int4::Int4(const UInt4 &rhs) |
| 3329 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3330 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3331 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3332 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3333 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3334 | Int4::Int4(const Reference<UInt4> &rhs) |
| 3335 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3336 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3337 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3338 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3339 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3340 | Int4::Int4(RValue<Int2> lo, RValue<Int2> hi) |
| 3341 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3342 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3343 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3344 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3345 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3346 | storeValue(packed); |
| 3347 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3348 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3349 | Int4::Int4(const Int &rhs) |
| 3350 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3351 | { |
| 3352 | *this = RValue<Int>(rhs.loadValue()); |
| 3353 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3354 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3355 | Int4::Int4(const Reference<Int> &rhs) |
| 3356 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3357 | { |
| 3358 | *this = RValue<Int>(rhs.loadValue()); |
| 3359 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3360 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3361 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) |
| 3362 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3363 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3364 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3365 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3366 | RValue<Int4> Int4::operator=(const Int4 &rhs) |
| 3367 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3368 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3369 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3370 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3371 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) |
| 3372 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3373 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3374 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3375 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3376 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3377 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3378 | return RValue<Int4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3379 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3380 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3381 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3382 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3383 | return RValue<Int4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3384 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3385 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3386 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3387 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3388 | return RValue<Int4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3389 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3390 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3391 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3392 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3393 | return RValue<Int4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3394 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3395 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3396 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3397 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3398 | return RValue<Int4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3399 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3400 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3401 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3402 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3403 | return RValue<Int4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3404 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3405 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3406 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3407 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3408 | return RValue<Int4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3409 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3410 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3411 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3412 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3413 | return RValue<Int4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3414 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3415 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3416 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3417 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3418 | return RValue<Int4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3419 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3420 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3421 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3422 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3423 | return RValue<Int4>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3424 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3425 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3426 | RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs) |
| 3427 | { |
| 3428 | return lhs = lhs + rhs; |
| 3429 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3430 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3431 | RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs) |
| 3432 | { |
| 3433 | return lhs = lhs - rhs; |
| 3434 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3435 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3436 | RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs) |
| 3437 | { |
| 3438 | return lhs = lhs * rhs; |
| 3439 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3440 | |
| 3441 | // RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs) |
| 3442 | // { |
| 3443 | // return lhs = lhs / rhs; |
| 3444 | // } |
| 3445 | |
| 3446 | // RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs) |
| 3447 | // { |
| 3448 | // return lhs = lhs % rhs; |
| 3449 | // } |
| 3450 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3451 | RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs) |
| 3452 | { |
| 3453 | return lhs = lhs & rhs; |
| 3454 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3455 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3456 | RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs) |
| 3457 | { |
| 3458 | return lhs = lhs | rhs; |
| 3459 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3460 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3461 | RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs) |
| 3462 | { |
| 3463 | return lhs = lhs ^ rhs; |
| 3464 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3465 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3466 | RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs) |
| 3467 | { |
| 3468 | return lhs = lhs << rhs; |
| 3469 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3470 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3471 | RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs) |
| 3472 | { |
| 3473 | return lhs = lhs >> rhs; |
| 3474 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3475 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3476 | RValue<Int4> operator+(RValue<Int4> val) |
| 3477 | { |
| 3478 | return val; |
| 3479 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3480 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3481 | RValue<Int4> operator-(RValue<Int4> val) |
| 3482 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3483 | return RValue<Int4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3484 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3485 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3486 | RValue<Int4> operator~(RValue<Int4> val) |
| 3487 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3488 | return RValue<Int4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3489 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3490 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3491 | RValue<Int> Extract(RValue<Int4> x, int i) |
| 3492 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3493 | return RValue<Int>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3494 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3495 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3496 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
| 3497 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3498 | return RValue<Int4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3499 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3500 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3501 | RValue<Int4> Swizzle(RValue<Int4> x, uint16_t select) |
| 3502 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3503 | return RValue<Int4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3504 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3505 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3506 | RValue<Int4> Shuffle(RValue<Int4> x, RValue<Int4> y, unsigned short select) |
| 3507 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3508 | return RValue<Int4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3509 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 3510 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3511 | UInt4::UInt4() |
| 3512 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3513 | { |
| 3514 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3515 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3516 | UInt4::UInt4(int xyzw) |
| 3517 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3518 | { |
| 3519 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3520 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3521 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3522 | UInt4::UInt4(int x, int yzw) |
| 3523 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3524 | { |
| 3525 | constant(x, yzw, yzw, yzw); |
| 3526 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3527 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3528 | UInt4::UInt4(int x, int y, int zw) |
| 3529 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3530 | { |
| 3531 | constant(x, y, zw, zw); |
| 3532 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3533 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3534 | UInt4::UInt4(int x, int y, int z, int w) |
| 3535 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3536 | { |
| 3537 | constant(x, y, z, w); |
| 3538 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3539 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3540 | void UInt4::constant(int x, int y, int z, int w) |
| 3541 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3542 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3543 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3544 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3545 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3546 | UInt4::UInt4(RValue<UInt4> rhs) |
| 3547 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3548 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3549 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3550 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3551 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3552 | UInt4::UInt4(const UInt4 &rhs) |
| 3553 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3554 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3555 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3556 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3557 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3558 | UInt4::UInt4(const Reference<UInt4> &rhs) |
| 3559 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3560 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3561 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3562 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3563 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3564 | UInt4::UInt4(RValue<Int4> rhs) |
| 3565 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3566 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3567 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3568 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3569 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3570 | UInt4::UInt4(const Int4 &rhs) |
| 3571 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3572 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3573 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3574 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3575 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3576 | UInt4::UInt4(const Reference<Int4> &rhs) |
| 3577 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3578 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3579 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3580 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3581 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3582 | UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi) |
| 3583 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3584 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3585 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3586 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3587 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3588 | storeValue(packed); |
| 3589 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3590 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3591 | UInt4::UInt4(const UInt &rhs) |
| 3592 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3593 | { |
| 3594 | *this = RValue<UInt>(rhs.loadValue()); |
| 3595 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3596 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3597 | UInt4::UInt4(const Reference<UInt> &rhs) |
| 3598 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3599 | { |
| 3600 | *this = RValue<UInt>(rhs.loadValue()); |
| 3601 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3602 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3603 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) |
| 3604 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3605 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3606 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3607 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3608 | RValue<UInt4> UInt4::operator=(const UInt4 &rhs) |
| 3609 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3610 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3611 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3612 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3613 | RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) |
| 3614 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3615 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3616 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3617 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3618 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3619 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3620 | return RValue<UInt4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3621 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3622 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3623 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3624 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3625 | return RValue<UInt4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3626 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3627 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3628 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3629 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3630 | return RValue<UInt4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3631 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3632 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3633 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3634 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3635 | return RValue<UInt4>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3636 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3637 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3638 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3639 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3640 | return RValue<UInt4>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3641 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3642 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3643 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3644 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3645 | return RValue<UInt4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3646 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3647 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3648 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3649 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3650 | return RValue<UInt4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3651 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3652 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3653 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3654 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3655 | return RValue<UInt4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3656 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3657 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3658 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3659 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3660 | return RValue<UInt4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3661 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3662 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3663 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3664 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3665 | return RValue<UInt4>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3666 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3667 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3668 | RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3669 | { |
| 3670 | return lhs = lhs + rhs; |
| 3671 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3672 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3673 | RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3674 | { |
| 3675 | return lhs = lhs - rhs; |
| 3676 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3677 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3678 | RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3679 | { |
| 3680 | return lhs = lhs * rhs; |
| 3681 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3682 | |
| 3683 | // RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3684 | // { |
| 3685 | // return lhs = lhs / rhs; |
| 3686 | // } |
| 3687 | |
| 3688 | // RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3689 | // { |
| 3690 | // return lhs = lhs % rhs; |
| 3691 | // } |
| 3692 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3693 | RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3694 | { |
| 3695 | return lhs = lhs & rhs; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3696 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3697 | |
| 3698 | RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3699 | { |
| 3700 | return lhs = lhs | rhs; |
| 3701 | } |
| 3702 | |
| 3703 | RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3704 | { |
| 3705 | return lhs = lhs ^ rhs; |
| 3706 | } |
| 3707 | |
| 3708 | RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs) |
| 3709 | { |
| 3710 | return lhs = lhs << rhs; |
| 3711 | } |
| 3712 | |
| 3713 | RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs) |
| 3714 | { |
| 3715 | return lhs = lhs >> rhs; |
| 3716 | } |
| 3717 | |
| 3718 | RValue<UInt4> operator+(RValue<UInt4> val) |
| 3719 | { |
| 3720 | return val; |
| 3721 | } |
| 3722 | |
| 3723 | RValue<UInt4> operator-(RValue<UInt4> val) |
| 3724 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3725 | return RValue<UInt4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3726 | } |
| 3727 | |
| 3728 | RValue<UInt4> operator~(RValue<UInt4> val) |
| 3729 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3730 | return RValue<UInt4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3731 | } |
| 3732 | |
| 3733 | RValue<UInt> Extract(RValue<UInt4> x, int i) |
| 3734 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3735 | return RValue<UInt>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3736 | } |
| 3737 | |
| 3738 | RValue<UInt4> Insert(RValue<UInt4> x, RValue<UInt> element, int i) |
| 3739 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3740 | return RValue<UInt4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3741 | } |
| 3742 | |
| 3743 | RValue<UInt4> Swizzle(RValue<UInt4> x, uint16_t select) |
| 3744 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3745 | return RValue<UInt4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | RValue<UInt4> Shuffle(RValue<UInt4> x, RValue<UInt4> y, unsigned short select) |
| 3749 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3750 | return RValue<UInt4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3751 | } |
| 3752 | |
| 3753 | Half::Half(RValue<Float> cast) |
| 3754 | { |
| 3755 | UInt fp32i = As<UInt>(cast); |
| 3756 | UInt abs = fp32i & 0x7FFFFFFF; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3757 | UShort fp16i((fp32i & 0x80000000) >> 16); // sign |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3758 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3759 | If(abs > 0x47FFEFFF) // Infinity |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3760 | { |
| 3761 | fp16i |= UShort(0x7FFF); |
| 3762 | } |
| 3763 | Else |
| 3764 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3765 | If(abs < 0x38800000) // Denormal |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3766 | { |
| 3767 | Int mantissa = (abs & 0x007FFFFF) | 0x00800000; |
| 3768 | Int e = 113 - (abs >> 23); |
Nicolas Capens | 60f8c2e | 2019-12-12 13:40:15 -0500 | [diff] [blame] | 3769 | abs = IfThenElse(e < 24, (mantissa >> e), Int(0)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3770 | fp16i |= UShort((abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3771 | } |
| 3772 | Else |
| 3773 | { |
| 3774 | fp16i |= UShort((abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3775 | } |
| 3776 | } |
| 3777 | |
| 3778 | storeValue(fp16i.loadValue()); |
| 3779 | } |
| 3780 | |
| 3781 | Float::Float(RValue<Int> cast) |
| 3782 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3783 | Value *integer = Nucleus::createSIToFP(cast.value(), Float::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3784 | |
| 3785 | storeValue(integer); |
| 3786 | } |
| 3787 | |
| 3788 | Float::Float(RValue<UInt> cast) |
| 3789 | { |
| 3790 | RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) + |
| 3791 | As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u))); |
| 3792 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3793 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3794 | } |
| 3795 | |
| 3796 | Float::Float(RValue<Half> cast) |
| 3797 | { |
| 3798 | Int fp16i(As<UShort>(cast)); |
| 3799 | |
| 3800 | Int s = (fp16i >> 15) & 0x00000001; |
| 3801 | Int e = (fp16i >> 10) & 0x0000001F; |
| 3802 | Int m = fp16i & 0x000003FF; |
| 3803 | |
| 3804 | UInt fp32i(s << 31); |
| 3805 | If(e == 0) |
| 3806 | { |
| 3807 | If(m != 0) |
| 3808 | { |
| 3809 | While((m & 0x00000400) == 0) |
| 3810 | { |
| 3811 | m <<= 1; |
| 3812 | e -= 1; |
| 3813 | } |
| 3814 | |
| 3815 | fp32i |= As<UInt>(((e + (127 - 15) + 1) << 23) | ((m & ~0x00000400) << 13)); |
| 3816 | } |
| 3817 | } |
| 3818 | Else |
| 3819 | { |
| 3820 | fp32i |= As<UInt>(((e + (127 - 15)) << 23) | (m << 13)); |
| 3821 | } |
| 3822 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3823 | storeValue(As<Float>(fp32i).value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3824 | } |
| 3825 | |
| 3826 | Float::Float(float x) |
| 3827 | { |
| 3828 | // C++ does not have a way to write an infinite or NaN literal, |
| 3829 | // nor does it allow division by zero as a constant expression. |
| 3830 | // Thus we should not accept inf or NaN as a Reactor Float constant, |
| 3831 | // as this would typically idicate a bug, and avoids undefined |
| 3832 | // behavior. |
| 3833 | // |
| 3834 | // This also prevents the issue of the LLVM JIT only taking double |
| 3835 | // values for constructing floating-point constants. During the |
| 3836 | // conversion from single-precision to double, a signaling NaN can |
| 3837 | // become a quiet NaN, thus altering its bit pattern. Hence this |
| 3838 | // assert is also helpful for detecting cases where integers are |
| 3839 | // being reinterpreted as float and then bitcast to integer again, |
| 3840 | // which does not guarantee preserving the integer value. |
| 3841 | // |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3842 | // The inifinity() method can be used to obtain positive infinity. |
| 3843 | // Should NaN constants be required, methods like quiet_NaN() and |
| 3844 | // signaling_NaN() should be added (matching std::numeric_limits). |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3845 | ASSERT(std::isfinite(x)); |
| 3846 | |
| 3847 | storeValue(Nucleus::createConstantFloat(x)); |
| 3848 | } |
| 3849 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3850 | // TODO(b/140302841): Negative infinity can be obtained by using '-infinity()'. |
| 3851 | // This comes at a minor run-time JIT cost, and the backend may or may not |
| 3852 | // perform constant folding. This can be optimized by having Reactor perform |
| 3853 | // the folding, which would still be cheaper than having a capable backend do it. |
| 3854 | Float Float::infinity() |
| 3855 | { |
| 3856 | Float result; |
| 3857 | |
| 3858 | constexpr double inf = std::numeric_limits<double>::infinity(); |
| 3859 | result.storeValue(Nucleus::createConstantFloat(inf)); |
| 3860 | |
| 3861 | return result; |
| 3862 | } |
| 3863 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3864 | Float::Float(RValue<Float> rhs) |
| 3865 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3866 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3867 | } |
| 3868 | |
| 3869 | Float::Float(const Float &rhs) |
| 3870 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3871 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3872 | } |
| 3873 | |
| 3874 | Float::Float(const Reference<Float> &rhs) |
| 3875 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3876 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3877 | } |
| 3878 | |
| 3879 | Float::Float(Argument<Float> argument) |
| 3880 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3881 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3882 | } |
| 3883 | |
Nicolas Capens | 0aca3ca | 2020-09-19 23:59:08 -0400 | [diff] [blame] | 3884 | RValue<Float> Float::operator=(float rhs) |
| 3885 | { |
| 3886 | return RValue<Float>(storeValue(Nucleus::createConstantFloat(rhs))); |
| 3887 | } |
| 3888 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3889 | RValue<Float> Float::operator=(RValue<Float> rhs) |
| 3890 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3891 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3892 | } |
| 3893 | |
| 3894 | RValue<Float> Float::operator=(const Float &rhs) |
| 3895 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3896 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3897 | } |
| 3898 | |
| 3899 | RValue<Float> Float::operator=(const Reference<Float> &rhs) |
| 3900 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3901 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3902 | } |
| 3903 | |
| 3904 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
| 3905 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3906 | return RValue<Float>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3907 | } |
| 3908 | |
| 3909 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
| 3910 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3911 | return RValue<Float>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3912 | } |
| 3913 | |
| 3914 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
| 3915 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3916 | return RValue<Float>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3917 | } |
| 3918 | |
| 3919 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
| 3920 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3921 | return RValue<Float>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3922 | } |
| 3923 | |
| 3924 | RValue<Float> operator+=(Float &lhs, RValue<Float> rhs) |
| 3925 | { |
| 3926 | return lhs = lhs + rhs; |
| 3927 | } |
| 3928 | |
| 3929 | RValue<Float> operator-=(Float &lhs, RValue<Float> rhs) |
| 3930 | { |
| 3931 | return lhs = lhs - rhs; |
| 3932 | } |
| 3933 | |
| 3934 | RValue<Float> operator*=(Float &lhs, RValue<Float> rhs) |
| 3935 | { |
| 3936 | return lhs = lhs * rhs; |
| 3937 | } |
| 3938 | |
| 3939 | RValue<Float> operator/=(Float &lhs, RValue<Float> rhs) |
| 3940 | { |
| 3941 | return lhs = lhs / rhs; |
| 3942 | } |
| 3943 | |
| 3944 | RValue<Float> operator+(RValue<Float> val) |
| 3945 | { |
| 3946 | return val; |
| 3947 | } |
| 3948 | |
| 3949 | RValue<Float> operator-(RValue<Float> val) |
| 3950 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3951 | return RValue<Float>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3952 | } |
| 3953 | |
| 3954 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
| 3955 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3956 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3957 | } |
| 3958 | |
| 3959 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
| 3960 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3961 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3962 | } |
| 3963 | |
| 3964 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
| 3965 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3966 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3967 | } |
| 3968 | |
| 3969 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
| 3970 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3971 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3972 | } |
| 3973 | |
| 3974 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
| 3975 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3976 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3977 | } |
| 3978 | |
| 3979 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
| 3980 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3981 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3982 | } |
| 3983 | |
| 3984 | RValue<Float> Abs(RValue<Float> x) |
| 3985 | { |
| 3986 | return IfThenElse(x > 0.0f, x, -x); |
| 3987 | } |
| 3988 | |
| 3989 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
| 3990 | { |
| 3991 | return IfThenElse(x > y, x, y); |
| 3992 | } |
| 3993 | |
| 3994 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
| 3995 | { |
| 3996 | return IfThenElse(x < y, x, y); |
| 3997 | } |
| 3998 | |
| 3999 | Float2::Float2(RValue<Float4> cast) |
| 4000 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4001 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4002 | } |
| 4003 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4004 | Float4::Float4(RValue<Byte4> cast) |
| 4005 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4006 | { |
| 4007 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4008 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4009 | |
| 4010 | storeValue(xyzw); |
| 4011 | } |
| 4012 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4013 | Float4::Float4(RValue<SByte4> cast) |
| 4014 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4015 | { |
| 4016 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4017 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4018 | |
| 4019 | storeValue(xyzw); |
| 4020 | } |
| 4021 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4022 | Float4::Float4(RValue<Short4> cast) |
| 4023 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4024 | { |
| 4025 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4026 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4027 | } |
| 4028 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4029 | Float4::Float4(RValue<UShort4> cast) |
| 4030 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4031 | { |
| 4032 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4033 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4034 | } |
| 4035 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4036 | Float4::Float4(RValue<Int4> cast) |
| 4037 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4038 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4039 | Value *xyzw = Nucleus::createSIToFP(cast.value(), Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4040 | |
| 4041 | storeValue(xyzw); |
| 4042 | } |
| 4043 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4044 | Float4::Float4(RValue<UInt4> cast) |
| 4045 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4046 | { |
| 4047 | RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) + |
| 4048 | As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u))); |
| 4049 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4050 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4051 | } |
| 4052 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4053 | Float4::Float4() |
| 4054 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4055 | { |
| 4056 | } |
| 4057 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4058 | Float4::Float4(float xyzw) |
| 4059 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4060 | { |
| 4061 | constant(xyzw, xyzw, xyzw, xyzw); |
| 4062 | } |
| 4063 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4064 | Float4::Float4(float x, float yzw) |
| 4065 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4066 | { |
| 4067 | constant(x, yzw, yzw, yzw); |
| 4068 | } |
| 4069 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4070 | Float4::Float4(float x, float y, float zw) |
| 4071 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4072 | { |
| 4073 | constant(x, y, zw, zw); |
| 4074 | } |
| 4075 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4076 | Float4::Float4(float x, float y, float z, float w) |
| 4077 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4078 | { |
| 4079 | constant(x, y, z, w); |
| 4080 | } |
| 4081 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4082 | Float4 Float4::infinity() |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4083 | { |
| 4084 | Float4 result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4085 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4086 | constexpr double inf = std::numeric_limits<double>::infinity(); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4087 | double constantVector[4] = { inf, inf, inf, inf }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4088 | result.storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4089 | |
| 4090 | return result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4091 | } |
| 4092 | |
| 4093 | void Float4::constant(float x, float y, float z, float w) |
| 4094 | { |
| 4095 | // See Float(float) constructor for the rationale behind this assert. |
| 4096 | ASSERT(std::isfinite(x) && std::isfinite(y) && std::isfinite(z) && std::isfinite(w)); |
| 4097 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4098 | double constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4099 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4100 | } |
| 4101 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4102 | Float4::Float4(RValue<Float4> rhs) |
| 4103 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4104 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4105 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4106 | } |
| 4107 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4108 | Float4::Float4(const Float4 &rhs) |
| 4109 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4110 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4111 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4112 | } |
| 4113 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4114 | Float4::Float4(const Reference<Float4> &rhs) |
| 4115 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4116 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4117 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4118 | } |
| 4119 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4120 | Float4::Float4(const Float &rhs) |
| 4121 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4122 | { |
| 4123 | *this = RValue<Float>(rhs.loadValue()); |
| 4124 | } |
| 4125 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4126 | Float4::Float4(const Reference<Float> &rhs) |
| 4127 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4128 | { |
| 4129 | *this = RValue<Float>(rhs.loadValue()); |
| 4130 | } |
| 4131 | |
Nicolas Capens | 419b7d7 | 2020-10-02 16:15:34 -0400 | [diff] [blame] | 4132 | Float4::Float4(RValue<Float2> lo, RValue<Float2> hi) |
| 4133 | : XYZW(this) |
| 4134 | { |
| 4135 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
| 4136 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
| 4137 | |
| 4138 | storeValue(packed); |
| 4139 | } |
| 4140 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4141 | RValue<Float4> Float4::operator=(float x) |
| 4142 | { |
| 4143 | return *this = Float4(x, x, x, x); |
| 4144 | } |
| 4145 | |
| 4146 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) |
| 4147 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4148 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4149 | } |
| 4150 | |
| 4151 | RValue<Float4> Float4::operator=(const Float4 &rhs) |
| 4152 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4153 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4154 | } |
| 4155 | |
| 4156 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) |
| 4157 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4158 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4159 | } |
| 4160 | |
| 4161 | RValue<Float4> Float4::operator=(RValue<Float> rhs) |
| 4162 | { |
| 4163 | return *this = Float4(rhs); |
| 4164 | } |
| 4165 | |
| 4166 | RValue<Float4> Float4::operator=(const Float &rhs) |
| 4167 | { |
| 4168 | return *this = Float4(rhs); |
| 4169 | } |
| 4170 | |
| 4171 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) |
| 4172 | { |
| 4173 | return *this = Float4(rhs); |
| 4174 | } |
| 4175 | |
| 4176 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4177 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4178 | return RValue<Float4>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4179 | } |
| 4180 | |
| 4181 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4182 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4183 | return RValue<Float4>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4184 | } |
| 4185 | |
| 4186 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4187 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4188 | return RValue<Float4>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4189 | } |
| 4190 | |
| 4191 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4192 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4193 | return RValue<Float4>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4194 | } |
| 4195 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4196 | RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs) |
| 4197 | { |
| 4198 | return lhs = lhs + rhs; |
| 4199 | } |
| 4200 | |
| 4201 | RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs) |
| 4202 | { |
| 4203 | return lhs = lhs - rhs; |
| 4204 | } |
| 4205 | |
| 4206 | RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs) |
| 4207 | { |
| 4208 | return lhs = lhs * rhs; |
| 4209 | } |
| 4210 | |
| 4211 | RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs) |
| 4212 | { |
| 4213 | return lhs = lhs / rhs; |
| 4214 | } |
| 4215 | |
| 4216 | RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs) |
| 4217 | { |
| 4218 | return lhs = lhs % rhs; |
| 4219 | } |
| 4220 | |
| 4221 | RValue<Float4> operator+(RValue<Float4> val) |
| 4222 | { |
| 4223 | return val; |
| 4224 | } |
| 4225 | |
| 4226 | RValue<Float4> operator-(RValue<Float4> val) |
| 4227 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4228 | return RValue<Float4>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4229 | } |
| 4230 | |
| 4231 | RValue<Float4> Abs(RValue<Float4> x) |
| 4232 | { |
| 4233 | // TODO: Optimize. |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4234 | Value *vector = Nucleus::createBitCast(x.value(), Int4::type()); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4235 | int64_t constantVector[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4236 | Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, Int4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4237 | |
| 4238 | return As<Float4>(result); |
| 4239 | } |
| 4240 | |
| 4241 | RValue<Float4> Insert(RValue<Float4> x, RValue<Float> element, int i) |
| 4242 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4243 | return RValue<Float4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4244 | } |
| 4245 | |
| 4246 | RValue<Float> Extract(RValue<Float4> x, int i) |
| 4247 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4248 | return RValue<Float>(Nucleus::createExtractElement(x.value(), Float::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4249 | } |
| 4250 | |
| 4251 | RValue<Float4> Swizzle(RValue<Float4> x, uint16_t select) |
| 4252 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4253 | return RValue<Float4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4254 | } |
| 4255 | |
| 4256 | RValue<Float4> Shuffle(RValue<Float4> x, RValue<Float4> y, uint16_t select) |
| 4257 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4258 | return RValue<Float4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4259 | } |
| 4260 | |
| 4261 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, uint16_t imm) |
| 4262 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4263 | int shuffle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4264 | ((imm >> 12) & 0x03) + 0, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4265 | ((imm >> 8) & 0x03) + 0, |
| 4266 | ((imm >> 4) & 0x03) + 4, |
| 4267 | ((imm >> 0) & 0x03) + 4, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4268 | }; |
| 4269 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4270 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4271 | } |
| 4272 | |
| 4273 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) |
| 4274 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4275 | int shuffle[4] = { 0, 4, 1, 5 }; |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4276 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4277 | } |
| 4278 | |
| 4279 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
| 4280 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4281 | int shuffle[4] = { 2, 6, 3, 7 }; |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4282 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, uint16_t select) |
| 4286 | { |
| 4287 | Value *vector = lhs.loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4288 | Value *result = createMask4(vector, rhs.value(), select); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4289 | lhs.storeValue(result); |
| 4290 | |
| 4291 | return RValue<Float4>(result); |
| 4292 | } |
| 4293 | |
| 4294 | RValue<Int4> IsInf(RValue<Float4> x) |
| 4295 | { |
| 4296 | return CmpEQ(As<Int4>(x) & Int4(0x7FFFFFFF), Int4(0x7F800000)); |
| 4297 | } |
| 4298 | |
| 4299 | RValue<Int4> IsNan(RValue<Float4> x) |
| 4300 | { |
| 4301 | return ~CmpEQ(x, x); |
| 4302 | } |
| 4303 | |
| 4304 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) |
| 4305 | { |
| 4306 | return lhs + RValue<Int>(Nucleus::createConstantInt(offset)); |
| 4307 | } |
| 4308 | |
| 4309 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4310 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4311 | return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value(), Byte::type(), offset.value(), false)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4312 | } |
| 4313 | |
| 4314 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4315 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4316 | return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value(), Byte::type(), offset.value(), true)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4317 | } |
| 4318 | |
| 4319 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset) |
| 4320 | { |
| 4321 | return lhs = lhs + offset; |
| 4322 | } |
| 4323 | |
| 4324 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4325 | { |
| 4326 | return lhs = lhs + offset; |
| 4327 | } |
| 4328 | |
| 4329 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4330 | { |
| 4331 | return lhs = lhs + offset; |
| 4332 | } |
| 4333 | |
| 4334 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset) |
| 4335 | { |
| 4336 | return lhs + -offset; |
| 4337 | } |
| 4338 | |
| 4339 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4340 | { |
| 4341 | return lhs + -offset; |
| 4342 | } |
| 4343 | |
| 4344 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4345 | { |
| 4346 | return lhs + -offset; |
| 4347 | } |
| 4348 | |
| 4349 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset) |
| 4350 | { |
| 4351 | return lhs = lhs - offset; |
| 4352 | } |
| 4353 | |
| 4354 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4355 | { |
| 4356 | return lhs = lhs - offset; |
| 4357 | } |
| 4358 | |
| 4359 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4360 | { |
| 4361 | return lhs = lhs - offset; |
| 4362 | } |
| 4363 | |
| 4364 | void Return() |
| 4365 | { |
| 4366 | Nucleus::createRetVoid(); |
| 4367 | // Place any unreachable instructions in an unreferenced block. |
| 4368 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 4369 | } |
| 4370 | |
| 4371 | void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
| 4372 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4373 | Nucleus::createCondBr(cmp.value(), bodyBB, endBB); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4374 | Nucleus::setInsertBlock(bodyBB); |
| 4375 | } |
| 4376 | |
| 4377 | RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4378 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4379 | return RValue<Float4>(Nucleus::createMaskedLoad(base.value(), Float::type(), mask.value(), alignment, zeroMaskedLanes)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4380 | } |
| 4381 | |
| 4382 | RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4383 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4384 | return RValue<Int4>(Nucleus::createMaskedLoad(base.value(), Int::type(), mask.value(), alignment, zeroMaskedLanes)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4385 | } |
| 4386 | |
| 4387 | void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment) |
| 4388 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4389 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4390 | } |
| 4391 | |
| 4392 | void MaskedStore(RValue<Pointer<Int4>> base, RValue<Int4> val, RValue<Int4> mask, unsigned int alignment) |
| 4393 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4394 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4395 | } |
| 4396 | |
| 4397 | void Fence(std::memory_order memoryOrder) |
| 4398 | { |
| 4399 | ASSERT_MSG(memoryOrder == std::memory_order_acquire || |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4400 | memoryOrder == std::memory_order_release || |
| 4401 | memoryOrder == std::memory_order_acq_rel || |
| 4402 | memoryOrder == std::memory_order_seq_cst, |
| 4403 | "Unsupported memoryOrder: %d", int(memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4404 | Nucleus::createFence(memoryOrder); |
| 4405 | } |
| 4406 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4407 | Bool CToReactor<bool>::cast(bool v) |
| 4408 | { |
| 4409 | return type(v); |
| 4410 | } |
| 4411 | Byte CToReactor<uint8_t>::cast(uint8_t v) |
| 4412 | { |
| 4413 | return type(v); |
| 4414 | } |
| 4415 | SByte CToReactor<int8_t>::cast(int8_t v) |
| 4416 | { |
| 4417 | return type(v); |
| 4418 | } |
| 4419 | Short CToReactor<int16_t>::cast(int16_t v) |
| 4420 | { |
| 4421 | return type(v); |
| 4422 | } |
| 4423 | UShort CToReactor<uint16_t>::cast(uint16_t v) |
| 4424 | { |
| 4425 | return type(v); |
| 4426 | } |
| 4427 | Int CToReactor<int32_t>::cast(int32_t v) |
| 4428 | { |
| 4429 | return type(v); |
| 4430 | } |
| 4431 | UInt CToReactor<uint32_t>::cast(uint32_t v) |
| 4432 | { |
| 4433 | return type(v); |
| 4434 | } |
| 4435 | Float CToReactor<float>::cast(float v) |
| 4436 | { |
| 4437 | return type(v); |
| 4438 | } |
| 4439 | Float4 CToReactor<float[4]>::cast(float v[4]) |
| 4440 | { |
| 4441 | return type(v[0], v[1], v[2], v[3]); |
| 4442 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4443 | |
| 4444 | // TODO: Long has no constructor that takes a uint64_t |
| 4445 | // Long CToReactor<uint64_t>::cast(uint64_t v) { return type(v); } |
| 4446 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4447 | #ifdef ENABLE_RR_PRINT |
| 4448 | static std::string replaceAll(std::string str, const std::string &substr, const std::string &replacement) |
| 4449 | { |
| 4450 | size_t pos = 0; |
| 4451 | while((pos = str.find(substr, pos)) != std::string::npos) |
| 4452 | { |
| 4453 | str.replace(pos, substr.length(), replacement); |
| 4454 | pos += replacement.length(); |
| 4455 | } |
| 4456 | return str; |
| 4457 | } |
| 4458 | |
| 4459 | // extractAll returns a vector containing the extracted n scalar value of |
| 4460 | // the vector vec. |
| 4461 | // TODO: Move to Reactor.cpp (LLVMReactor can use this too) |
| 4462 | static std::vector<Value *> extractAll(Value *vec, int n) |
| 4463 | { |
| 4464 | Type *elemTy = Nucleus::getContainedType(Nucleus::getType(vec)); |
| 4465 | std::vector<Value *> elements; |
| 4466 | elements.reserve(n); |
| 4467 | for(int i = 0; i < n; i++) |
| 4468 | { |
| 4469 | auto el = Nucleus::createExtractElement(vec, elemTy, i); |
| 4470 | elements.push_back(el); |
| 4471 | } |
| 4472 | return elements; |
| 4473 | } |
| 4474 | |
| 4475 | // toInt returns all the integer values in vals extended to a printf-required storage value |
| 4476 | static std::vector<Value *> toInt(const std::vector<Value *> &vals, bool isSigned) |
| 4477 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4478 | auto storageTy = Nucleus::getPrintfStorageType(Int::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4479 | std::vector<Value *> elements; |
| 4480 | elements.reserve(vals.size()); |
| 4481 | for(auto v : vals) |
| 4482 | { |
| 4483 | if(isSigned) |
| 4484 | { |
| 4485 | elements.push_back(Nucleus::createSExt(v, storageTy)); |
| 4486 | } |
| 4487 | else |
| 4488 | { |
| 4489 | elements.push_back(Nucleus::createZExt(v, storageTy)); |
| 4490 | } |
| 4491 | } |
| 4492 | return elements; |
| 4493 | } |
| 4494 | |
| 4495 | // toFloat returns all the float values in vals extended to extended to a printf-required storage value |
| 4496 | static std::vector<Value *> toFloat(const std::vector<Value *> &vals) |
| 4497 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4498 | auto storageTy = Nucleus::getPrintfStorageType(Float::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4499 | std::vector<Value *> elements; |
| 4500 | elements.reserve(vals.size()); |
| 4501 | for(auto v : vals) |
| 4502 | { |
| 4503 | elements.push_back(Nucleus::createFPExt(v, storageTy)); |
| 4504 | } |
| 4505 | return elements; |
| 4506 | } |
| 4507 | |
| 4508 | std::vector<Value *> PrintValue::Ty<Bool>::val(const RValue<Bool> &v) |
| 4509 | { |
| 4510 | auto t = Nucleus::createConstantString("true"); |
| 4511 | auto f = Nucleus::createConstantString("false"); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4512 | return { Nucleus::createSelect(v.value(), t, f) }; |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4513 | } |
| 4514 | |
| 4515 | std::vector<Value *> PrintValue::Ty<Byte>::val(const RValue<Byte> &v) |
| 4516 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4517 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4518 | } |
| 4519 | |
| 4520 | std::vector<Value *> PrintValue::Ty<Byte4>::val(const RValue<Byte4> &v) |
| 4521 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4522 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4523 | } |
| 4524 | |
| 4525 | std::vector<Value *> PrintValue::Ty<Int>::val(const RValue<Int> &v) |
| 4526 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4527 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4528 | } |
| 4529 | |
| 4530 | std::vector<Value *> PrintValue::Ty<Int2>::val(const RValue<Int2> &v) |
| 4531 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4532 | return toInt(extractAll(v.value(), 2), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4533 | } |
| 4534 | |
| 4535 | std::vector<Value *> PrintValue::Ty<Int4>::val(const RValue<Int4> &v) |
| 4536 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4537 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4538 | } |
| 4539 | |
| 4540 | std::vector<Value *> PrintValue::Ty<UInt>::val(const RValue<UInt> &v) |
| 4541 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4542 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4543 | } |
| 4544 | |
| 4545 | std::vector<Value *> PrintValue::Ty<UInt2>::val(const RValue<UInt2> &v) |
| 4546 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4547 | return toInt(extractAll(v.value(), 2), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4548 | } |
| 4549 | |
| 4550 | std::vector<Value *> PrintValue::Ty<UInt4>::val(const RValue<UInt4> &v) |
| 4551 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4552 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4553 | } |
| 4554 | |
| 4555 | std::vector<Value *> PrintValue::Ty<Short>::val(const RValue<Short> &v) |
| 4556 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4557 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4558 | } |
| 4559 | |
| 4560 | std::vector<Value *> PrintValue::Ty<Short4>::val(const RValue<Short4> &v) |
| 4561 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4562 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4563 | } |
| 4564 | |
| 4565 | std::vector<Value *> PrintValue::Ty<UShort>::val(const RValue<UShort> &v) |
| 4566 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4567 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4568 | } |
| 4569 | |
| 4570 | std::vector<Value *> PrintValue::Ty<UShort4>::val(const RValue<UShort4> &v) |
| 4571 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4572 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4573 | } |
| 4574 | |
| 4575 | std::vector<Value *> PrintValue::Ty<Float>::val(const RValue<Float> &v) |
| 4576 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4577 | return toFloat({ v.value() }); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | std::vector<Value *> PrintValue::Ty<Float4>::val(const RValue<Float4> &v) |
| 4581 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4582 | return toFloat(extractAll(v.value(), 4)); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4583 | } |
| 4584 | |
| 4585 | std::vector<Value *> PrintValue::Ty<const char *>::val(const char *v) |
| 4586 | { |
| 4587 | return { Nucleus::createConstantString(v) }; |
| 4588 | } |
| 4589 | |
| 4590 | void Printv(const char *function, const char *file, int line, const char *fmt, std::initializer_list<PrintValue> args) |
| 4591 | { |
| 4592 | // Build the printf format message string. |
| 4593 | std::string str; |
| 4594 | if(file != nullptr) { str += (line > 0) ? "%s:%d " : "%s "; } |
| 4595 | if(function != nullptr) { str += "%s "; } |
| 4596 | str += fmt; |
| 4597 | |
| 4598 | // Perform substitution on all '{n}' bracketed indices in the format |
| 4599 | // message. |
| 4600 | int i = 0; |
| 4601 | for(const PrintValue &arg : args) |
| 4602 | { |
| 4603 | str = replaceAll(str, "{" + std::to_string(i++) + "}", arg.format); |
| 4604 | } |
| 4605 | |
| 4606 | std::vector<Value *> vals; |
| 4607 | vals.reserve(8); |
| 4608 | |
| 4609 | // The format message is always the first argument. |
| 4610 | vals.push_back(Nucleus::createConstantString(str)); |
| 4611 | |
| 4612 | // Add optional file, line and function info if provided. |
| 4613 | if(file != nullptr) |
| 4614 | { |
| 4615 | vals.push_back(Nucleus::createConstantString(file)); |
| 4616 | if(line > 0) |
| 4617 | { |
| 4618 | vals.push_back(Nucleus::createConstantInt(line)); |
| 4619 | } |
| 4620 | } |
| 4621 | if(function != nullptr) |
| 4622 | { |
| 4623 | vals.push_back(Nucleus::createConstantString(function)); |
| 4624 | } |
| 4625 | |
| 4626 | // Add all format arguments. |
| 4627 | for(const PrintValue &arg : args) |
| 4628 | { |
| 4629 | for(auto val : arg.values) |
| 4630 | { |
| 4631 | vals.push_back(val); |
| 4632 | } |
| 4633 | } |
| 4634 | |
| 4635 | // This call is implemented by each backend |
| 4636 | VPrintf(vals); |
| 4637 | } |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 4638 | |
| 4639 | // This is the function that is called by VPrintf from the backends |
| 4640 | int DebugPrintf(const char *format, ...) |
| 4641 | { |
| 4642 | // Uncomment this to make it so that we do not print, but the call to this function is emitted. |
| 4643 | // Useful when debugging emitted code to see the Reactor source location. |
| 4644 | //# define RR_PRINT_OUTPUT_TYPE_STUB |
| 4645 | |
| 4646 | # if defined(RR_PRINT_OUTPUT_TYPE_STUB) |
| 4647 | return 0; |
| 4648 | # else |
| 4649 | |
| 4650 | int result; |
| 4651 | va_list args; |
| 4652 | |
| 4653 | va_start(args, format); |
| 4654 | char buffer[2048]; |
| 4655 | result = vsprintf(buffer, format, args); |
| 4656 | va_end(args); |
| 4657 | |
| 4658 | std::fputs(buffer, stdout); |
| 4659 | # if defined(_WIN32) |
| 4660 | OutputDebugString(buffer); |
| 4661 | # endif |
| 4662 | |
| 4663 | return result; |
| 4664 | # endif |
| 4665 | } |
| 4666 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4667 | #endif // ENABLE_RR_PRINT |
| 4668 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4669 | // Functions implemented by backends |
| 4670 | bool HasRcpApprox(); |
| 4671 | RValue<Float4> RcpApprox(RValue<Float4> x, bool exactAtPow2 = false); |
| 4672 | RValue<Float> RcpApprox(RValue<Float> x, bool exactAtPow2 = false); |
| 4673 | |
| 4674 | template<typename T> |
| 4675 | static RValue<T> DoRcp(RValue<T> x, Precision p, bool finite, bool exactAtPow2) |
| 4676 | { |
| 4677 | #if defined(__i386__) || defined(__x86_64__) // On x86, 1/x is fast enough, except for lower precision |
| 4678 | bool approx = HasRcpApprox() && (p != Precision::Full); |
| 4679 | #else |
| 4680 | bool approx = HasRcpApprox(); |
| 4681 | #endif |
| 4682 | |
| 4683 | T rcp; |
| 4684 | |
| 4685 | if(approx) |
| 4686 | { |
| 4687 | rcp = RcpApprox(x, exactAtPow2); |
| 4688 | |
| 4689 | if(p == Precision::Full) |
| 4690 | { |
| 4691 | // Perform one more iteration of Newton-Rhapson division to increase precision |
| 4692 | rcp = (rcp + rcp) - (x * rcp * rcp); |
| 4693 | } |
| 4694 | } |
| 4695 | else |
| 4696 | { |
| 4697 | rcp = T(1.0f) / x; |
| 4698 | } |
| 4699 | |
| 4700 | if(finite) |
| 4701 | { |
| 4702 | constexpr int big = 0x7F7FFFFF; |
| 4703 | rcp = Min(rcp, T((float &)big)); |
| 4704 | } |
| 4705 | |
| 4706 | return rcp; |
| 4707 | } |
| 4708 | |
| 4709 | RValue<Float4> Rcp(RValue<Float4> x, Precision p, bool finite, bool exactAtPow2) |
| 4710 | { |
| 4711 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 4712 | return DoRcp(x, p, finite, exactAtPow2); |
| 4713 | } |
| 4714 | |
| 4715 | RValue<Float> Rcp(RValue<Float> x, Precision p, bool finite, bool exactAtPow2) |
| 4716 | { |
| 4717 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 4718 | return DoRcp(x, p, finite, exactAtPow2); |
| 4719 | } |
| 4720 | |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4721 | // Functions implemented by backends |
| 4722 | bool HasRcpSqrtApprox(); |
| 4723 | RValue<Float4> RcpSqrtApprox(RValue<Float4> x); |
| 4724 | RValue<Float> RcpSqrtApprox(RValue<Float> x); |
| 4725 | |
| 4726 | template<typename T> |
| 4727 | struct CastToIntType; |
| 4728 | |
| 4729 | template<> |
| 4730 | struct CastToIntType<Float4> |
| 4731 | { |
| 4732 | using type = Int4; |
| 4733 | }; |
| 4734 | |
| 4735 | template<> |
| 4736 | struct CastToIntType<Float> |
| 4737 | { |
| 4738 | using type = Int; |
| 4739 | }; |
| 4740 | |
| 4741 | // TODO: move to Reactor.hpp? |
| 4742 | RValue<Int> CmpNEQ(RValue<Int> x, RValue<Int> y) |
| 4743 | { |
| 4744 | return IfThenElse(x != y, Int(~0), Int(0)); |
| 4745 | } |
| 4746 | |
| 4747 | template<typename T> |
| 4748 | static RValue<T> DoRcpSqrt(RValue<T> x, Precision p) |
| 4749 | { |
| 4750 | #if defined(__i386__) || defined(__x86_64__) // On x86, 1/x is fast enough, except for lower precision |
| 4751 | bool approx = HasRcpApprox() && (p != Precision::Full); |
| 4752 | #else |
| 4753 | bool approx = HasRcpApprox(); |
| 4754 | #endif |
| 4755 | |
| 4756 | if(approx) |
| 4757 | { |
| 4758 | using IntType = typename CastToIntType<T>::type; |
| 4759 | |
| 4760 | T rsq = RcpSqrtApprox(x); |
| 4761 | |
| 4762 | if(p == Precision::Full) |
| 4763 | { |
| 4764 | rsq = rsq * (T(3.0f) - rsq * rsq * x) * T(0.5f); |
| 4765 | rsq = As<T>(CmpNEQ(As<IntType>(x), IntType(0x7F800000)) & As<IntType>(rsq)); |
| 4766 | } |
| 4767 | |
| 4768 | return rsq; |
| 4769 | } |
| 4770 | else |
| 4771 | { |
| 4772 | return T(1.0f) / Sqrt(x); |
| 4773 | } |
| 4774 | } |
| 4775 | |
| 4776 | RValue<Float4> RcpSqrt(RValue<Float4> x, Precision p) |
| 4777 | { |
| 4778 | return DoRcpSqrt(x, p); |
| 4779 | } |
| 4780 | |
| 4781 | RValue<Float> RcpSqrt(RValue<Float> x, Precision p) |
| 4782 | { |
| 4783 | return DoRcpSqrt(x, p); |
| 4784 | } |
| 4785 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4786 | } // namespace rr |