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 | { |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 127 | unmaterializedVariables->remove(this); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 128 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 129 | |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 130 | void Variable::materialize() const |
| 131 | { |
| 132 | if(!address) |
| 133 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 134 | address = Nucleus::allocateStackVariable(getType(), arraySize); |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 135 | RR_DEBUG_INFO_EMIT_VAR(address); |
| 136 | |
| 137 | if(rvalue) |
| 138 | { |
| 139 | storeValue(rvalue); |
| 140 | rvalue = nullptr; |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | Value *Variable::loadValue() const |
| 146 | { |
| 147 | if(rvalue) |
| 148 | { |
| 149 | return rvalue; |
| 150 | } |
| 151 | |
| 152 | if(!address) |
| 153 | { |
| 154 | // TODO: Return undef instead. |
| 155 | materialize(); |
| 156 | } |
| 157 | |
| 158 | return Nucleus::createLoad(address, getType(), false, 0); |
| 159 | } |
| 160 | |
| 161 | Value *Variable::storeValue(Value *value) const |
| 162 | { |
| 163 | if(address) |
| 164 | { |
| 165 | return Nucleus::createStore(value, address, getType(), false, 0); |
| 166 | } |
| 167 | |
| 168 | rvalue = value; |
| 169 | |
| 170 | return value; |
| 171 | } |
| 172 | |
| 173 | Value *Variable::getBaseAddress() const |
| 174 | { |
| 175 | materialize(); |
| 176 | |
| 177 | return address; |
| 178 | } |
| 179 | |
| 180 | Value *Variable::getElementPointer(Value *index, bool unsignedIndex) const |
| 181 | { |
| 182 | return Nucleus::createGEP(getBaseAddress(), getType(), index, unsignedIndex); |
| 183 | } |
| 184 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 185 | void Variable::materializeAll() |
| 186 | { |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 187 | unmaterializedVariables->materializeAll(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 188 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 189 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 190 | void Variable::killUnmaterialized() |
| 191 | { |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 192 | unmaterializedVariables->clear(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 193 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 194 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 195 | // NOTE: Only 12 bits out of 16 of the |select| value are used. |
| 196 | // More specifically, the value should look like: |
| 197 | // |
| 198 | // msb lsb |
| 199 | // v v |
| 200 | // [.xxx|.yyy|.zzz|.www] where '.' means an ignored bit |
| 201 | // |
| 202 | // This format makes it easy to write calls with hexadecimal select values, |
| 203 | // since each hex digit is a separate swizzle index. |
| 204 | // |
| 205 | // For example: |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 206 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x0123 ) -> [a,b,c,d] |
| 207 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x4567 ) -> [e,f,g,h] |
| 208 | // 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] | 209 | // |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 210 | static Value *createShuffle4(Value *lhs, Value *rhs, uint16_t select) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 211 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 212 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 213 | (select >> 12) & 0x07, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 214 | (select >> 8) & 0x07, |
| 215 | (select >> 4) & 0x07, |
| 216 | (select >> 0) & 0x07, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 217 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 218 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 219 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 220 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 221 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 222 | // NOTE: Only 8 bits out of 16 of the |select| value are used. |
| 223 | // More specifically, the value should look like: |
| 224 | // |
| 225 | // msb lsb |
| 226 | // v v |
| 227 | // [..xx|..yy|..zz|..ww] where '.' means an ignored bit |
| 228 | // |
| 229 | // This format makes it easy to write calls with hexadecimal select values, |
| 230 | // since each hex digit is a separate swizzle index. |
| 231 | // |
| 232 | // For example: |
| 233 | // createSwizzle4( [a,b,c,d], 0x0123 ) -> [a,b,c,d] |
| 234 | // createSwizzle4( [a,b,c,d], 0x0033 ) -> [a,a,d,d] |
| 235 | // |
| 236 | static Value *createSwizzle4(Value *val, uint16_t select) |
| 237 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 238 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 239 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 240 | (select >> 8) & 0x03, |
| 241 | (select >> 4) & 0x03, |
| 242 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 243 | }; |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 244 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 245 | return Nucleus::createShuffleVector(val, val, swizzle); |
| 246 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 247 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 248 | static Value *createMask4(Value *lhs, Value *rhs, uint16_t select) |
| 249 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 250 | bool mask[4] = { false, false, false, false }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 251 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 252 | mask[(select >> 12) & 0x03] = true; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 253 | mask[(select >> 8) & 0x03] = true; |
| 254 | mask[(select >> 4) & 0x03] = true; |
| 255 | mask[(select >> 0) & 0x03] = true; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 256 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 257 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 258 | mask[0] ? 4 : 0, |
| 259 | mask[1] ? 5 : 1, |
| 260 | mask[2] ? 6 : 2, |
| 261 | mask[3] ? 7 : 3, |
| 262 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 263 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 264 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 265 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 266 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 267 | Bool::Bool(Argument<Bool> argument) |
| 268 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 269 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 270 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 271 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 272 | Bool::Bool(bool x) |
| 273 | { |
| 274 | storeValue(Nucleus::createConstantBool(x)); |
| 275 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 276 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 277 | Bool::Bool(RValue<Bool> rhs) |
| 278 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 279 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 280 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 281 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 282 | Bool::Bool(const Bool &rhs) |
| 283 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 284 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 285 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 286 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 287 | Bool::Bool(const Reference<Bool> &rhs) |
| 288 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 289 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 290 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 291 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 292 | RValue<Bool> Bool::operator=(RValue<Bool> rhs) |
| 293 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 294 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 295 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 296 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 297 | RValue<Bool> Bool::operator=(const Bool &rhs) |
| 298 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 299 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 300 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 301 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 302 | RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) |
| 303 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 304 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 305 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 306 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 307 | RValue<Bool> operator!(RValue<Bool> val) |
| 308 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 309 | return RValue<Bool>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 310 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 311 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 312 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) |
| 313 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 314 | return RValue<Bool>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 315 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 316 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 317 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) |
| 318 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 319 | return RValue<Bool>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 320 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 321 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 322 | RValue<Bool> operator!=(RValue<Bool> lhs, RValue<Bool> rhs) |
| 323 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 324 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 325 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 326 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 327 | RValue<Bool> operator==(RValue<Bool> lhs, RValue<Bool> rhs) |
| 328 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 329 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 330 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 331 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 332 | Byte::Byte(Argument<Byte> argument) |
| 333 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 334 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 335 | } |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 336 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 337 | Byte::Byte(RValue<Int> cast) |
| 338 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 339 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 340 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 341 | storeValue(integer); |
| 342 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 343 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 344 | Byte::Byte(RValue<UInt> cast) |
| 345 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 346 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 347 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 348 | storeValue(integer); |
| 349 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 350 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 351 | Byte::Byte(RValue<UShort> cast) |
| 352 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 353 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 354 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 355 | storeValue(integer); |
| 356 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 357 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 358 | Byte::Byte(int x) |
| 359 | { |
| 360 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
| 361 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 362 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 363 | Byte::Byte(unsigned char x) |
| 364 | { |
| 365 | storeValue(Nucleus::createConstantByte(x)); |
| 366 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 367 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 368 | Byte::Byte(RValue<Byte> rhs) |
| 369 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 370 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 371 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 372 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 373 | Byte::Byte(const Byte &rhs) |
| 374 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 375 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 376 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 377 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 378 | Byte::Byte(const Reference<Byte> &rhs) |
| 379 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 380 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 381 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 382 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 383 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) |
| 384 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 385 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 386 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 387 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 388 | RValue<Byte> Byte::operator=(const Byte &rhs) |
| 389 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 390 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 391 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 392 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 393 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) |
| 394 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 395 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 396 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 397 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 398 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
| 399 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 400 | return RValue<Byte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 401 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 402 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 403 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
| 404 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 405 | return RValue<Byte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 406 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 407 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 408 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
| 409 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 410 | return RValue<Byte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 411 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 412 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 413 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
| 414 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 415 | return RValue<Byte>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 416 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 417 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 418 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
| 419 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 420 | return RValue<Byte>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 421 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 422 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 423 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
| 424 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 425 | return RValue<Byte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 426 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 427 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 428 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
| 429 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 430 | return RValue<Byte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 431 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 432 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 433 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
| 434 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 435 | return RValue<Byte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 436 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 437 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 438 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 439 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 440 | return RValue<Byte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 441 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 442 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 443 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 444 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 445 | return RValue<Byte>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 446 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 447 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 448 | RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs) |
| 449 | { |
| 450 | return lhs = lhs + rhs; |
| 451 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 452 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 453 | RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs) |
| 454 | { |
| 455 | return lhs = lhs - rhs; |
| 456 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 457 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 458 | RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs) |
| 459 | { |
| 460 | return lhs = lhs * rhs; |
| 461 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 462 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 463 | RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs) |
| 464 | { |
| 465 | return lhs = lhs / rhs; |
| 466 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 467 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 468 | RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs) |
| 469 | { |
| 470 | return lhs = lhs % rhs; |
| 471 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 472 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 473 | RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs) |
| 474 | { |
| 475 | return lhs = lhs & rhs; |
| 476 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 477 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 478 | RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs) |
| 479 | { |
| 480 | return lhs = lhs | rhs; |
| 481 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 482 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 483 | RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs) |
| 484 | { |
| 485 | return lhs = lhs ^ rhs; |
| 486 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 487 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 488 | RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs) |
| 489 | { |
| 490 | return lhs = lhs << rhs; |
| 491 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 492 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 493 | RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs) |
| 494 | { |
| 495 | return lhs = lhs >> rhs; |
| 496 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 497 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 498 | RValue<Byte> operator+(RValue<Byte> val) |
| 499 | { |
| 500 | return val; |
| 501 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 502 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 503 | RValue<Byte> operator-(RValue<Byte> val) |
| 504 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 505 | return RValue<Byte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 506 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 507 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 508 | RValue<Byte> operator~(RValue<Byte> val) |
| 509 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 510 | return RValue<Byte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 511 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 512 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 513 | RValue<Byte> operator++(Byte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 514 | { |
| 515 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 516 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 517 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 518 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 519 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 520 | return res; |
| 521 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 522 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 523 | const Byte &operator++(Byte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 524 | { |
| 525 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 526 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 527 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 528 | return val; |
| 529 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 530 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 531 | RValue<Byte> operator--(Byte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 532 | { |
| 533 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 534 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 535 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 536 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 537 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 538 | return res; |
| 539 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 540 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 541 | const Byte &operator--(Byte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 542 | { |
| 543 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 544 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 545 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 546 | return val; |
| 547 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 548 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 549 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 550 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 551 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 552 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 553 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 554 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 555 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 556 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 557 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 558 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 559 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 560 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 561 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 562 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 563 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 564 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 565 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 566 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 567 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 568 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 569 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 570 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 571 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 572 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 573 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 574 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
| 575 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 576 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 577 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 578 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 579 | SByte::SByte(Argument<SByte> argument) |
| 580 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 581 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 582 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 583 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 584 | SByte::SByte(RValue<Int> cast) |
| 585 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 586 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 587 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 588 | storeValue(integer); |
| 589 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 590 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 591 | SByte::SByte(RValue<Short> cast) |
| 592 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 593 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 594 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 595 | storeValue(integer); |
| 596 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 597 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 598 | SByte::SByte(signed char x) |
| 599 | { |
| 600 | storeValue(Nucleus::createConstantByte(x)); |
| 601 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 602 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 603 | SByte::SByte(RValue<SByte> rhs) |
| 604 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 605 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 606 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 607 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 608 | SByte::SByte(const SByte &rhs) |
| 609 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 610 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 611 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 612 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 613 | SByte::SByte(const Reference<SByte> &rhs) |
| 614 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 615 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 616 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 617 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 618 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) |
| 619 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 620 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 621 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 622 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 623 | RValue<SByte> SByte::operator=(const SByte &rhs) |
| 624 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 625 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 626 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 627 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 628 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) |
| 629 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 630 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 631 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 632 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 633 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
| 634 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 635 | return RValue<SByte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 636 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 637 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 638 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
| 639 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 640 | return RValue<SByte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 641 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 642 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 643 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
| 644 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 645 | return RValue<SByte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 646 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 647 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 648 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
| 649 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 650 | return RValue<SByte>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 651 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 652 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 653 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) |
| 654 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 655 | return RValue<SByte>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 656 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 657 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 658 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) |
| 659 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 660 | return RValue<SByte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 661 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 662 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 663 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) |
| 664 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 665 | return RValue<SByte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 666 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 667 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 668 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) |
| 669 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 670 | return RValue<SByte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 671 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 672 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 673 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 674 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 675 | return RValue<SByte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 676 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 677 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 678 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 679 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 680 | return RValue<SByte>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 681 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 682 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 683 | RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs) |
| 684 | { |
| 685 | return lhs = lhs + rhs; |
| 686 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 687 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 688 | RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs) |
| 689 | { |
| 690 | return lhs = lhs - rhs; |
| 691 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 692 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 693 | RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs) |
| 694 | { |
| 695 | return lhs = lhs * rhs; |
| 696 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 697 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 698 | RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs) |
| 699 | { |
| 700 | return lhs = lhs / rhs; |
| 701 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 702 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 703 | RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs) |
| 704 | { |
| 705 | return lhs = lhs % rhs; |
| 706 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 707 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 708 | RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs) |
| 709 | { |
| 710 | return lhs = lhs & rhs; |
| 711 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 712 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 713 | RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs) |
| 714 | { |
| 715 | return lhs = lhs | rhs; |
| 716 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 717 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 718 | RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs) |
| 719 | { |
| 720 | return lhs = lhs ^ rhs; |
| 721 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 722 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 723 | RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs) |
| 724 | { |
| 725 | return lhs = lhs << rhs; |
| 726 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 727 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 728 | RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs) |
| 729 | { |
| 730 | return lhs = lhs >> rhs; |
| 731 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 732 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 733 | RValue<SByte> operator+(RValue<SByte> val) |
| 734 | { |
| 735 | return val; |
| 736 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 737 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 738 | RValue<SByte> operator-(RValue<SByte> val) |
| 739 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 740 | return RValue<SByte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 741 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 742 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 743 | RValue<SByte> operator~(RValue<SByte> val) |
| 744 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 745 | return RValue<SByte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 746 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 747 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 748 | RValue<SByte> operator++(SByte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 749 | { |
| 750 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 751 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 752 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 753 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 754 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 755 | return res; |
| 756 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 757 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 758 | const SByte &operator++(SByte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 759 | { |
| 760 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 761 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 762 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 763 | return val; |
| 764 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 765 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 766 | RValue<SByte> operator--(SByte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 767 | { |
| 768 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 769 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 770 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 771 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 772 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 773 | return res; |
| 774 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 775 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 776 | const SByte &operator--(SByte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 777 | { |
| 778 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 779 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 780 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 781 | return val; |
| 782 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 783 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 784 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 785 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 786 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 787 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 788 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 789 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 790 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 791 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 792 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 793 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 794 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 795 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 796 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 797 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 798 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 799 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 800 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 801 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 802 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 803 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 804 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 805 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 806 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 807 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 808 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 809 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) |
| 810 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 811 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 812 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 813 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 814 | Short::Short(Argument<Short> argument) |
| 815 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 816 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 817 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 818 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 819 | Short::Short(RValue<Int> cast) |
| 820 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 821 | Value *integer = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 822 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 823 | storeValue(integer); |
| 824 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 825 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 826 | Short::Short(short x) |
| 827 | { |
| 828 | storeValue(Nucleus::createConstantShort(x)); |
| 829 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 830 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 831 | Short::Short(RValue<Short> rhs) |
| 832 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 833 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 834 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 835 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 836 | Short::Short(const Short &rhs) |
| 837 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 838 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 839 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 840 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 841 | Short::Short(const Reference<Short> &rhs) |
| 842 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 843 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 844 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 845 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 846 | RValue<Short> Short::operator=(RValue<Short> rhs) |
| 847 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 848 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 849 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 850 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 851 | RValue<Short> Short::operator=(const Short &rhs) |
| 852 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 853 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 854 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 855 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 856 | RValue<Short> Short::operator=(const Reference<Short> &rhs) |
| 857 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 858 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 859 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 860 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 861 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
| 862 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 863 | return RValue<Short>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 864 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 865 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 866 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
| 867 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 868 | return RValue<Short>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 869 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 870 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 871 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
| 872 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 873 | return RValue<Short>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 874 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 875 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 876 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
| 877 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 878 | return RValue<Short>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 879 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 880 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 881 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) |
| 882 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 883 | return RValue<Short>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 884 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 885 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 886 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) |
| 887 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 888 | return RValue<Short>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 889 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 890 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 891 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) |
| 892 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 893 | return RValue<Short>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 894 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 895 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 896 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) |
| 897 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 898 | return RValue<Short>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 899 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 900 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 901 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) |
| 902 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 903 | return RValue<Short>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 904 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 905 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 906 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) |
| 907 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 908 | return RValue<Short>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 909 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 910 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 911 | RValue<Short> operator+=(Short &lhs, RValue<Short> rhs) |
| 912 | { |
| 913 | return lhs = lhs + rhs; |
| 914 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 915 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 916 | RValue<Short> operator-=(Short &lhs, RValue<Short> rhs) |
| 917 | { |
| 918 | return lhs = lhs - rhs; |
| 919 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 920 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 921 | RValue<Short> operator*=(Short &lhs, RValue<Short> rhs) |
| 922 | { |
| 923 | return lhs = lhs * rhs; |
| 924 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 925 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 926 | RValue<Short> operator/=(Short &lhs, RValue<Short> rhs) |
| 927 | { |
| 928 | return lhs = lhs / rhs; |
| 929 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 930 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 931 | RValue<Short> operator%=(Short &lhs, RValue<Short> rhs) |
| 932 | { |
| 933 | return lhs = lhs % rhs; |
| 934 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 935 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 936 | RValue<Short> operator&=(Short &lhs, RValue<Short> rhs) |
| 937 | { |
| 938 | return lhs = lhs & rhs; |
| 939 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 940 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 941 | RValue<Short> operator|=(Short &lhs, RValue<Short> rhs) |
| 942 | { |
| 943 | return lhs = lhs | rhs; |
| 944 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 945 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 946 | RValue<Short> operator^=(Short &lhs, RValue<Short> rhs) |
| 947 | { |
| 948 | return lhs = lhs ^ rhs; |
| 949 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 950 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 951 | RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs) |
| 952 | { |
| 953 | return lhs = lhs << rhs; |
| 954 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 955 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 956 | RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs) |
| 957 | { |
| 958 | return lhs = lhs >> rhs; |
| 959 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 960 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 961 | RValue<Short> operator+(RValue<Short> val) |
| 962 | { |
| 963 | return val; |
| 964 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 965 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 966 | RValue<Short> operator-(RValue<Short> val) |
| 967 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 968 | return RValue<Short>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 969 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 970 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 971 | RValue<Short> operator~(RValue<Short> val) |
| 972 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 973 | return RValue<Short>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 974 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 975 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 976 | RValue<Short> operator++(Short &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 977 | { |
| 978 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 979 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 980 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 981 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 982 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 983 | return res; |
| 984 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 985 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 986 | const Short &operator++(Short &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 987 | { |
| 988 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 989 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 990 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 991 | return val; |
| 992 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 993 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 994 | RValue<Short> operator--(Short &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 995 | { |
| 996 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 997 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 998 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 999 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1000 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1001 | return res; |
| 1002 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1003 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1004 | const Short &operator--(Short &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1005 | { |
| 1006 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 1007 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1008 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1009 | return val; |
| 1010 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1011 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1012 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
| 1013 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1014 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1015 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1016 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1017 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
| 1018 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1019 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1020 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1021 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1022 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
| 1023 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1024 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1025 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1026 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1027 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
| 1028 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1029 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1030 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1031 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1032 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) |
| 1033 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1034 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1035 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1036 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1037 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) |
| 1038 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1039 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1040 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1041 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1042 | UShort::UShort(Argument<UShort> argument) |
| 1043 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1044 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1045 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1046 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1047 | UShort::UShort(RValue<UInt> cast) |
| 1048 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1049 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1050 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1051 | storeValue(integer); |
| 1052 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1053 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1054 | UShort::UShort(RValue<Int> cast) |
| 1055 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1056 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1057 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1058 | storeValue(integer); |
| 1059 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1060 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1061 | UShort::UShort(unsigned short x) |
| 1062 | { |
| 1063 | storeValue(Nucleus::createConstantShort(x)); |
| 1064 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1065 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1066 | UShort::UShort(RValue<UShort> rhs) |
| 1067 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1068 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1069 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1070 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1071 | UShort::UShort(const UShort &rhs) |
| 1072 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1073 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1074 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1075 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1076 | UShort::UShort(const Reference<UShort> &rhs) |
| 1077 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1078 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1079 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1080 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1081 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) |
| 1082 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1083 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1084 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1085 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1086 | RValue<UShort> UShort::operator=(const UShort &rhs) |
| 1087 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1088 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1089 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1090 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1091 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) |
| 1092 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1093 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1094 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1095 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1096 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1097 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1098 | return RValue<UShort>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1099 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1100 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1101 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1102 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1103 | return RValue<UShort>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1104 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1105 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1106 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1107 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1108 | return RValue<UShort>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1109 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1110 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1111 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1112 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1113 | return RValue<UShort>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1114 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1115 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1116 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1117 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1118 | return RValue<UShort>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1119 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1120 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1121 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1122 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1123 | return RValue<UShort>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1124 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1125 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1126 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1127 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1128 | return RValue<UShort>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1129 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1130 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1131 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1132 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1133 | return RValue<UShort>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1134 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1135 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1136 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1137 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1138 | return RValue<UShort>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1139 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1140 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1141 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1142 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1143 | return RValue<UShort>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1144 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1145 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1146 | RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs) |
| 1147 | { |
| 1148 | return lhs = lhs + rhs; |
| 1149 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1150 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1151 | RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs) |
| 1152 | { |
| 1153 | return lhs = lhs - rhs; |
| 1154 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1155 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1156 | RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs) |
| 1157 | { |
| 1158 | return lhs = lhs * rhs; |
| 1159 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1160 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1161 | RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs) |
| 1162 | { |
| 1163 | return lhs = lhs / rhs; |
| 1164 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1165 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1166 | RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs) |
| 1167 | { |
| 1168 | return lhs = lhs % rhs; |
| 1169 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1170 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1171 | RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs) |
| 1172 | { |
| 1173 | return lhs = lhs & rhs; |
| 1174 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1175 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1176 | RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs) |
| 1177 | { |
| 1178 | return lhs = lhs | rhs; |
| 1179 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1180 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1181 | RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs) |
| 1182 | { |
| 1183 | return lhs = lhs ^ rhs; |
| 1184 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1185 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1186 | RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs) |
| 1187 | { |
| 1188 | return lhs = lhs << rhs; |
| 1189 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1190 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1191 | RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs) |
| 1192 | { |
| 1193 | return lhs = lhs >> rhs; |
| 1194 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1195 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1196 | RValue<UShort> operator+(RValue<UShort> val) |
| 1197 | { |
| 1198 | return val; |
| 1199 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1200 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1201 | RValue<UShort> operator-(RValue<UShort> val) |
| 1202 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1203 | return RValue<UShort>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1204 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1205 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1206 | RValue<UShort> operator~(RValue<UShort> val) |
| 1207 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1208 | return RValue<UShort>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1209 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1210 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1211 | RValue<UShort> operator++(UShort &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1212 | { |
| 1213 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1214 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1215 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1216 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1217 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1218 | return res; |
| 1219 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1220 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1221 | const UShort &operator++(UShort &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1222 | { |
| 1223 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1224 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1225 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1226 | return val; |
| 1227 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1228 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1229 | RValue<UShort> operator--(UShort &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1230 | { |
| 1231 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1232 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1233 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1234 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1235 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1236 | return res; |
| 1237 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1238 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1239 | const UShort &operator--(UShort &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1240 | { |
| 1241 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1242 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1243 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1244 | return val; |
| 1245 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1246 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1247 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1248 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1249 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1250 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1251 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1252 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1253 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1254 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1255 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1256 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1257 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1258 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1259 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1260 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1261 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1262 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1263 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1264 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1265 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1266 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1267 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1268 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1269 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1270 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1271 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1272 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1273 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1274 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1275 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1276 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1277 | Byte4::Byte4(RValue<Byte8> cast) |
| 1278 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1279 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1280 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1281 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1282 | Byte4::Byte4(RValue<UShort4> cast) |
| 1283 | { |
| 1284 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1285 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1286 | } |
| 1287 | |
| 1288 | Byte4::Byte4(RValue<Short4> 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<UInt4> cast) |
| 1295 | { |
| 1296 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1297 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1298 | } |
| 1299 | |
| 1300 | Byte4::Byte4(RValue<Int4> 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<Byte4> rhs) |
| 1307 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1308 | store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | Byte4::Byte4(const Byte4 &rhs) |
| 1312 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1313 | store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1314 | } |
| 1315 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1316 | Byte4::Byte4(const Reference<Byte4> &rhs) |
| 1317 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1318 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1319 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1320 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1321 | RValue<Byte4> Byte4::operator=(RValue<Byte4> rhs) |
| 1322 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1323 | return store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1324 | } |
| 1325 | |
| 1326 | RValue<Byte4> Byte4::operator=(const Byte4 &rhs) |
| 1327 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1328 | return store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1329 | } |
| 1330 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1331 | 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) |
| 1332 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1333 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1334 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1335 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1336 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1337 | Byte8::Byte8(RValue<Byte8> rhs) |
| 1338 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1339 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1340 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1341 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1342 | Byte8::Byte8(const Byte8 &rhs) |
| 1343 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1344 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1345 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1346 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1347 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 1348 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1349 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1350 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1351 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1352 | RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) |
| 1353 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1354 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1355 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1356 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1357 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) |
| 1358 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1359 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1360 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1361 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1362 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) |
| 1363 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1364 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1365 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1366 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1367 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1368 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1369 | return RValue<Byte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1370 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1371 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1372 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1373 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1374 | return RValue<Byte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1375 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1376 | |
| 1377 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1378 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1379 | // return RValue<Byte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1380 | // } |
| 1381 | |
| 1382 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1383 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1384 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1385 | // } |
| 1386 | |
| 1387 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1388 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1389 | // return RValue<Byte8>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1390 | // } |
| 1391 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1392 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1393 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1394 | return RValue<Byte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1395 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1396 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1397 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1398 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1399 | return RValue<Byte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1400 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1401 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1402 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1403 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1404 | return RValue<Byte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1405 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1406 | |
| 1407 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
| 1408 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1409 | // return RValue<Byte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1410 | // } |
| 1411 | |
| 1412 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
| 1413 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1414 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1415 | // } |
| 1416 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1417 | RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1418 | { |
| 1419 | return lhs = lhs + rhs; |
| 1420 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1421 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1422 | RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1423 | { |
| 1424 | return lhs = lhs - rhs; |
| 1425 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1426 | |
| 1427 | // RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1428 | // { |
| 1429 | // return lhs = lhs * rhs; |
| 1430 | // } |
| 1431 | |
| 1432 | // RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1433 | // { |
| 1434 | // return lhs = lhs / rhs; |
| 1435 | // } |
| 1436 | |
| 1437 | // RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1438 | // { |
| 1439 | // return lhs = lhs % rhs; |
| 1440 | // } |
| 1441 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1442 | RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1443 | { |
| 1444 | return lhs = lhs & rhs; |
| 1445 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1446 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1447 | RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1448 | { |
| 1449 | return lhs = lhs | rhs; |
| 1450 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1451 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1452 | RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1453 | { |
| 1454 | return lhs = lhs ^ rhs; |
| 1455 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1456 | |
| 1457 | // RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1458 | // { |
| 1459 | // return lhs = lhs << rhs; |
| 1460 | // } |
| 1461 | |
| 1462 | // RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1463 | // { |
| 1464 | // return lhs = lhs >> rhs; |
| 1465 | // } |
| 1466 | |
| 1467 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 1468 | // { |
| 1469 | // return val; |
| 1470 | // } |
| 1471 | |
| 1472 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 1473 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1474 | // return RValue<Byte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1475 | // } |
| 1476 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1477 | RValue<Byte8> operator~(RValue<Byte8> val) |
| 1478 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1479 | return RValue<Byte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1480 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1481 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1482 | RValue<Byte8> Swizzle(RValue<Byte8> x, uint32_t select) |
| 1483 | { |
| 1484 | // Real type is v16i8 |
| 1485 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1486 | int shuffle[16] = { |
| 1487 | static_cast<int>((select >> 28) & 0x07), |
| 1488 | static_cast<int>((select >> 24) & 0x07), |
| 1489 | static_cast<int>((select >> 20) & 0x07), |
| 1490 | static_cast<int>((select >> 16) & 0x07), |
| 1491 | static_cast<int>((select >> 12) & 0x07), |
| 1492 | static_cast<int>((select >> 8) & 0x07), |
| 1493 | static_cast<int>((select >> 4) & 0x07), |
| 1494 | static_cast<int>((select >> 0) & 0x07), |
| 1495 | static_cast<int>((select >> 28) & 0x07), |
| 1496 | static_cast<int>((select >> 24) & 0x07), |
| 1497 | static_cast<int>((select >> 20) & 0x07), |
| 1498 | static_cast<int>((select >> 16) & 0x07), |
| 1499 | static_cast<int>((select >> 12) & 0x07), |
| 1500 | static_cast<int>((select >> 8) & 0x07), |
| 1501 | static_cast<int>((select >> 4) & 0x07), |
| 1502 | static_cast<int>((select >> 0) & 0x07), |
| 1503 | }; |
| 1504 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1505 | return As<Byte8>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1506 | } |
| 1507 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1508 | RValue<Short4> Unpack(RValue<Byte4> x) |
| 1509 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1510 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1511 | 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] | 1512 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1513 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1514 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1515 | RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y) |
| 1516 | { |
| 1517 | return UnpackLow(As<Byte8>(x), As<Byte8>(y)); |
| 1518 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1519 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1520 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 1521 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1522 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1523 | 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] | 1524 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1525 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1526 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1527 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
| 1528 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1529 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1530 | 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] | 1531 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1532 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1533 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1534 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1535 | 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) |
| 1536 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1537 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1538 | Value *vector = Nucleus::createConstantVector(constantVector, type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1539 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1540 | storeValue(Nucleus::createBitCast(vector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1541 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1542 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1543 | SByte8::SByte8(RValue<SByte8> rhs) |
| 1544 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1545 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1546 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1547 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1548 | SByte8::SByte8(const SByte8 &rhs) |
| 1549 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1550 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1551 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1552 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1553 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 1554 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1555 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1556 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1557 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1558 | RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) |
| 1559 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1560 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1561 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1562 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1563 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) |
| 1564 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1565 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1566 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1567 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1568 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) |
| 1569 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1570 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1571 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1572 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1573 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1574 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1575 | return RValue<SByte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1576 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1577 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1578 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1579 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1580 | return RValue<SByte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1581 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1582 | |
| 1583 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1584 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1585 | // return RValue<SByte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1586 | // } |
| 1587 | |
| 1588 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1589 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1590 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1591 | // } |
| 1592 | |
| 1593 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1594 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1595 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1596 | // } |
| 1597 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1598 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1599 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1600 | return RValue<SByte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1601 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1602 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1603 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1604 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1605 | return RValue<SByte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1606 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1607 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1608 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1609 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1610 | return RValue<SByte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1611 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1612 | |
| 1613 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
| 1614 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1615 | // return RValue<SByte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1616 | // } |
| 1617 | |
| 1618 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
| 1619 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1620 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1621 | // } |
| 1622 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1623 | RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1624 | { |
| 1625 | return lhs = lhs + rhs; |
| 1626 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1627 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1628 | RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1629 | { |
| 1630 | return lhs = lhs - rhs; |
| 1631 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1632 | |
| 1633 | // RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1634 | // { |
| 1635 | // return lhs = lhs * rhs; |
| 1636 | // } |
| 1637 | |
| 1638 | // RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1639 | // { |
| 1640 | // return lhs = lhs / rhs; |
| 1641 | // } |
| 1642 | |
| 1643 | // RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1644 | // { |
| 1645 | // return lhs = lhs % rhs; |
| 1646 | // } |
| 1647 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1648 | RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1649 | { |
| 1650 | return lhs = lhs & rhs; |
| 1651 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1652 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1653 | RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1654 | { |
| 1655 | return lhs = lhs | rhs; |
| 1656 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1657 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1658 | RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1659 | { |
| 1660 | return lhs = lhs ^ rhs; |
| 1661 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1662 | |
| 1663 | // RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1664 | // { |
| 1665 | // return lhs = lhs << rhs; |
| 1666 | // } |
| 1667 | |
| 1668 | // RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1669 | // { |
| 1670 | // return lhs = lhs >> rhs; |
| 1671 | // } |
| 1672 | |
| 1673 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 1674 | // { |
| 1675 | // return val; |
| 1676 | // } |
| 1677 | |
| 1678 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 1679 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1680 | // return RValue<SByte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1681 | // } |
| 1682 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1683 | RValue<SByte8> operator~(RValue<SByte8> val) |
| 1684 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1685 | return RValue<SByte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1686 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1687 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1688 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
| 1689 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1690 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1691 | 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] | 1692 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1693 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1694 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1695 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
| 1696 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1697 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1698 | 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] | 1699 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1700 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1701 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1702 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1703 | Byte16::Byte16(RValue<Byte16> rhs) |
| 1704 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1705 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1706 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1707 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1708 | Byte16::Byte16(const Byte16 &rhs) |
| 1709 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1710 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1711 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1712 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1713 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 1714 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1715 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1716 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1717 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1718 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) |
| 1719 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1720 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1721 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1722 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1723 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) |
| 1724 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1725 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1726 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1727 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1728 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) |
| 1729 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1730 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1731 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1732 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1733 | RValue<Byte16> Swizzle(RValue<Byte16> x, uint64_t select) |
| 1734 | { |
| 1735 | int shuffle[16] = { |
| 1736 | static_cast<int>((select >> 60) & 0x0F), |
| 1737 | static_cast<int>((select >> 56) & 0x0F), |
| 1738 | static_cast<int>((select >> 52) & 0x0F), |
| 1739 | static_cast<int>((select >> 48) & 0x0F), |
| 1740 | static_cast<int>((select >> 44) & 0x0F), |
| 1741 | static_cast<int>((select >> 40) & 0x0F), |
| 1742 | static_cast<int>((select >> 36) & 0x0F), |
| 1743 | static_cast<int>((select >> 32) & 0x0F), |
| 1744 | static_cast<int>((select >> 28) & 0x0F), |
| 1745 | static_cast<int>((select >> 24) & 0x0F), |
| 1746 | static_cast<int>((select >> 20) & 0x0F), |
| 1747 | static_cast<int>((select >> 16) & 0x0F), |
| 1748 | static_cast<int>((select >> 12) & 0x0F), |
| 1749 | static_cast<int>((select >> 8) & 0x0F), |
| 1750 | static_cast<int>((select >> 4) & 0x0F), |
| 1751 | static_cast<int>((select >> 0) & 0x0F), |
| 1752 | }; |
| 1753 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1754 | return As<Byte16>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1755 | } |
| 1756 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1757 | Short2::Short2(RValue<Short4> cast) |
| 1758 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1759 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1760 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1761 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1762 | UShort2::UShort2(RValue<UShort4> cast) |
| 1763 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1764 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1765 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1766 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1767 | Short4::Short4(RValue<Int> cast) |
| 1768 | { |
| 1769 | Value *vector = loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1770 | Value *element = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1771 | Value *insert = Nucleus::createInsertElement(vector, element, 0); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1772 | Value *swizzle = Swizzle(RValue<Short4>(insert), 0x0000).value(); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1773 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1774 | storeValue(swizzle); |
| 1775 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1776 | |
| 1777 | // Short4::Short4(RValue<Float> cast) |
| 1778 | // { |
| 1779 | // } |
| 1780 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1781 | Short4::Short4(short xyzw) |
| 1782 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1783 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1784 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1785 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1786 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1787 | Short4::Short4(short x, short y, short z, short w) |
| 1788 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1789 | int64_t constantVector[4] = { x, y, z, w }; |
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(RValue<Short4> rhs) |
| 1794 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1795 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1796 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1797 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1798 | Short4::Short4(const Short4 &rhs) |
| 1799 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1800 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1801 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1802 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1803 | Short4::Short4(const Reference<Short4> &rhs) |
| 1804 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1805 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1806 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1807 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1808 | Short4::Short4(RValue<UShort4> rhs) |
| 1809 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1810 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1811 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1812 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1813 | Short4::Short4(const UShort4 &rhs) |
| 1814 | { |
| 1815 | storeValue(rhs.loadValue()); |
| 1816 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1817 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1818 | Short4::Short4(const Reference<UShort4> &rhs) |
| 1819 | { |
| 1820 | storeValue(rhs.loadValue()); |
| 1821 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1822 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1823 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) |
| 1824 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1825 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1826 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1827 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1828 | RValue<Short4> Short4::operator=(const Short4 &rhs) |
| 1829 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1830 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1831 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1832 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1833 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) |
| 1834 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1835 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1836 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1837 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1838 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) |
| 1839 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1840 | return RValue<Short4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1841 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1842 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1843 | RValue<Short4> Short4::operator=(const UShort4 &rhs) |
| 1844 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1845 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1846 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1847 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1848 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) |
| 1849 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1850 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1851 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1852 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1853 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1854 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1855 | return RValue<Short4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1856 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1857 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1858 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1859 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1860 | return RValue<Short4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1861 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1862 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1863 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1864 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1865 | return RValue<Short4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1866 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1867 | |
| 1868 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1869 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1870 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1871 | // } |
| 1872 | |
| 1873 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1874 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1875 | // return RValue<Short4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1876 | // } |
| 1877 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1878 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1879 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1880 | return RValue<Short4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1881 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1882 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1883 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1884 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1885 | return RValue<Short4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1886 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1887 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1888 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1889 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1890 | return RValue<Short4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1891 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1892 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1893 | RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs) |
| 1894 | { |
| 1895 | return lhs = lhs + rhs; |
| 1896 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1897 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1898 | RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs) |
| 1899 | { |
| 1900 | return lhs = lhs - rhs; |
| 1901 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1902 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1903 | RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs) |
| 1904 | { |
| 1905 | return lhs = lhs * rhs; |
| 1906 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1907 | |
| 1908 | // RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs) |
| 1909 | // { |
| 1910 | // return lhs = lhs / rhs; |
| 1911 | // } |
| 1912 | |
| 1913 | // RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs) |
| 1914 | // { |
| 1915 | // return lhs = lhs % rhs; |
| 1916 | // } |
| 1917 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1918 | RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs) |
| 1919 | { |
| 1920 | return lhs = lhs & rhs; |
| 1921 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1922 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1923 | RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs) |
| 1924 | { |
| 1925 | return lhs = lhs | rhs; |
| 1926 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1927 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1928 | RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs) |
| 1929 | { |
| 1930 | return lhs = lhs ^ rhs; |
| 1931 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1932 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1933 | RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs) |
| 1934 | { |
| 1935 | return lhs = lhs << rhs; |
| 1936 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1937 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1938 | RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs) |
| 1939 | { |
| 1940 | return lhs = lhs >> rhs; |
| 1941 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1942 | |
| 1943 | // RValue<Short4> operator+(RValue<Short4> val) |
| 1944 | // { |
| 1945 | // return val; |
| 1946 | // } |
| 1947 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1948 | RValue<Short4> operator-(RValue<Short4> val) |
| 1949 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1950 | return RValue<Short4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1951 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1952 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1953 | RValue<Short4> operator~(RValue<Short4> val) |
| 1954 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1955 | return RValue<Short4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1956 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1957 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1958 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
| 1959 | { |
| 1960 | RValue<Int4> int4 = RoundInt(cast); |
| 1961 | return As<Short4>(PackSigned(int4, int4)); |
| 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<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
| 1965 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1966 | 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] | 1967 | return As<Int2>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
| 1971 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1972 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1973 | 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] | 1974 | auto lowHigh = RValue<Short8>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1975 | return As<Int2>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1976 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1977 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1978 | RValue<Short4> Swizzle(RValue<Short4> x, uint16_t select) |
| 1979 | { |
| 1980 | // Real type is v8i16 |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1981 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1982 | int shuffle[8] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1983 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1984 | (select >> 8) & 0x03, |
| 1985 | (select >> 4) & 0x03, |
| 1986 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1987 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1988 | (select >> 8) & 0x03, |
| 1989 | (select >> 4) & 0x03, |
| 1990 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1991 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1992 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1993 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1994 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1995 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1996 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
| 1997 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1998 | return RValue<Short4>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1999 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2000 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2001 | RValue<Short> Extract(RValue<Short4> val, int i) |
| 2002 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2003 | return RValue<Short>(Nucleus::createExtractElement(val.value(), Short::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2004 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2005 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2006 | UShort4::UShort4(RValue<Int4> cast) |
| 2007 | { |
| 2008 | *this = Short4(cast); |
| 2009 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2010 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2011 | UShort4::UShort4(unsigned short xyzw) |
| 2012 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2013 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2014 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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 x, unsigned short y, unsigned short z, unsigned short w) |
| 2018 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2019 | int64_t constantVector[4] = { x, y, z, w }; |
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(RValue<UShort4> rhs) |
| 2024 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2025 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2026 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2027 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2028 | UShort4::UShort4(const UShort4 &rhs) |
| 2029 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2030 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2031 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2032 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2033 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 2034 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2035 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2036 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2037 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2038 | UShort4::UShort4(RValue<Short4> rhs) |
| 2039 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2040 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2041 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2042 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2043 | UShort4::UShort4(const Short4 &rhs) |
| 2044 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2045 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2046 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2047 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2048 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 2049 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2050 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2051 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2052 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2053 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) |
| 2054 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2055 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2056 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2057 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2058 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) |
| 2059 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2060 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2061 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2062 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2063 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) |
| 2064 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2065 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2066 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2067 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2068 | RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) |
| 2069 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2070 | return RValue<UShort4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2071 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2072 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2073 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) |
| 2074 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2075 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2076 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2077 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2078 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) |
| 2079 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2080 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2081 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2082 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2083 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2084 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2085 | return RValue<UShort4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2086 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2087 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2088 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2089 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2090 | return RValue<UShort4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2091 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2092 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2093 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2094 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2095 | return RValue<UShort4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2096 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2097 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2098 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2099 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2100 | return RValue<UShort4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2101 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2102 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2103 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2104 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2105 | return RValue<UShort4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2106 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2107 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2108 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2109 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2110 | return RValue<UShort4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2111 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2112 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2113 | RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs) |
| 2114 | { |
| 2115 | return lhs = lhs << rhs; |
| 2116 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2117 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2118 | RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs) |
| 2119 | { |
| 2120 | return lhs = lhs >> rhs; |
| 2121 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2122 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2123 | RValue<UShort4> operator~(RValue<UShort4> val) |
| 2124 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2125 | return RValue<UShort4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2126 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2127 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2128 | Short8::Short8(short c) |
| 2129 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2130 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2131 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
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 c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 2135 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2136 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
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(RValue<Short8> rhs) |
| 2141 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2142 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2143 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2144 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2145 | Short8::Short8(const Reference<Short8> &rhs) |
| 2146 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2147 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2148 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2149 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2150 | Short8::Short8(RValue<Short4> lo, RValue<Short4> hi) |
| 2151 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2152 | 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] | 2153 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2154 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2155 | storeValue(packed); |
| 2156 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2157 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2158 | RValue<Short8> Short8::operator=(RValue<Short8> rhs) |
| 2159 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2160 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2161 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2162 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2163 | RValue<Short8> Short8::operator=(const Short8 &rhs) |
| 2164 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2165 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2166 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2167 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2168 | RValue<Short8> Short8::operator=(const Reference<Short8> &rhs) |
| 2169 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2170 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2171 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2172 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2173 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2174 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2175 | return RValue<Short8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2176 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2177 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2178 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2179 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2180 | return RValue<Short8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2181 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2182 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2183 | RValue<Int4> Abs(RValue<Int4> x) |
| 2184 | { |
| 2185 | // TODO: Optimize. |
| 2186 | auto negative = x >> 31; |
| 2187 | return (x ^ negative) - negative; |
| 2188 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2189 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2190 | UShort8::UShort8(unsigned short c) |
| 2191 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2192 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2193 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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 c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7) |
| 2197 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2198 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
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(RValue<UShort8> rhs) |
| 2203 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2204 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2205 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2206 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2207 | UShort8::UShort8(const Reference<UShort8> &rhs) |
| 2208 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2209 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2210 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2211 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2212 | UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi) |
| 2213 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2214 | 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] | 2215 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2216 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2217 | storeValue(packed); |
| 2218 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2219 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2220 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) |
| 2221 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2222 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2223 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2224 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2225 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) |
| 2226 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2227 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2228 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2229 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2230 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) |
| 2231 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2232 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2233 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2234 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2235 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2236 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2237 | return RValue<UShort8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2238 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2239 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2240 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2241 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2242 | return RValue<UShort8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2243 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2244 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2245 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2246 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2247 | return RValue<UShort8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2248 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2249 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2250 | RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs) |
| 2251 | { |
| 2252 | return lhs = lhs + rhs; |
| 2253 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2254 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2255 | RValue<UShort8> operator~(RValue<UShort8> val) |
| 2256 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2257 | return RValue<UShort8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2258 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2259 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2260 | RValue<UShort8> Swizzle(RValue<UShort8> x, uint32_t select) |
| 2261 | { |
| 2262 | int swizzle[16] = { |
| 2263 | static_cast<int>((select >> 28) & 0x07), |
| 2264 | static_cast<int>((select >> 24) & 0x07), |
| 2265 | static_cast<int>((select >> 20) & 0x07), |
| 2266 | static_cast<int>((select >> 16) & 0x07), |
| 2267 | static_cast<int>((select >> 12) & 0x07), |
| 2268 | static_cast<int>((select >> 8) & 0x07), |
| 2269 | static_cast<int>((select >> 4) & 0x07), |
| 2270 | static_cast<int>((select >> 0) & 0x07), |
| 2271 | }; |
| 2272 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2273 | return RValue<UShort8>(Nucleus::createShuffleVector(x.value(), x.value(), swizzle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2274 | } |
| 2275 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2276 | Int::Int(Argument<Int> argument) |
| 2277 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2278 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2279 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2280 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2281 | Int::Int(RValue<Byte> cast) |
| 2282 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2283 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2284 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2285 | storeValue(integer); |
| 2286 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2287 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2288 | Int::Int(RValue<SByte> cast) |
| 2289 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2290 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2291 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2292 | storeValue(integer); |
| 2293 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2294 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2295 | Int::Int(RValue<Short> cast) |
| 2296 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2297 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2298 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2299 | storeValue(integer); |
| 2300 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2301 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2302 | Int::Int(RValue<UShort> cast) |
| 2303 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2304 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2305 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2306 | storeValue(integer); |
| 2307 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2308 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2309 | Int::Int(RValue<Int2> cast) |
| 2310 | { |
| 2311 | *this = Extract(cast, 0); |
| 2312 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2313 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2314 | Int::Int(RValue<Long> cast) |
| 2315 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2316 | Value *integer = Nucleus::createTrunc(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2317 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2318 | storeValue(integer); |
| 2319 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2320 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2321 | Int::Int(RValue<Float> cast) |
| 2322 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2323 | Value *integer = Nucleus::createFPToSI(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2324 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2325 | storeValue(integer); |
| 2326 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2327 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2328 | Int::Int(int x) |
| 2329 | { |
| 2330 | storeValue(Nucleus::createConstantInt(x)); |
| 2331 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2332 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2333 | Int::Int(RValue<Int> rhs) |
| 2334 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2335 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2336 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2337 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2338 | Int::Int(RValue<UInt> rhs) |
| 2339 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2340 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2341 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2342 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2343 | Int::Int(const Int &rhs) |
| 2344 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2345 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2346 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2347 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2348 | Int::Int(const Reference<Int> &rhs) |
| 2349 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2350 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2351 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2352 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2353 | Int::Int(const UInt &rhs) |
| 2354 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2355 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2356 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2357 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2358 | Int::Int(const Reference<UInt> &rhs) |
| 2359 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2360 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2361 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2362 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2363 | RValue<Int> Int::operator=(int rhs) |
| 2364 | { |
| 2365 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2366 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2367 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2368 | RValue<Int> Int::operator=(RValue<Int> rhs) |
| 2369 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2370 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2371 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2372 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2373 | RValue<Int> Int::operator=(RValue<UInt> rhs) |
| 2374 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2375 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2376 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2377 | return RValue<Int>(rhs); |
| 2378 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2379 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2380 | RValue<Int> Int::operator=(const Int &rhs) |
| 2381 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2382 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2383 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2384 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2385 | RValue<Int> Int::operator=(const Reference<Int> &rhs) |
| 2386 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2387 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2388 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2389 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2390 | RValue<Int> Int::operator=(const UInt &rhs) |
| 2391 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2392 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2393 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2394 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2395 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) |
| 2396 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2397 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2398 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2399 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2400 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) |
| 2401 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2402 | return RValue<Int>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2403 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2404 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2405 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) |
| 2406 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2407 | return RValue<Int>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2408 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2409 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2410 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) |
| 2411 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2412 | return RValue<Int>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2413 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2414 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2415 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
| 2416 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2417 | return RValue<Int>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2418 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2419 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2420 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
| 2421 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2422 | return RValue<Int>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2423 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2424 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2425 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
| 2426 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2427 | return RValue<Int>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2428 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2429 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2430 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
| 2431 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2432 | return RValue<Int>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2433 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2434 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2435 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
| 2436 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2437 | return RValue<Int>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2438 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2439 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2440 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
| 2441 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2442 | return RValue<Int>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2443 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2444 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2445 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
| 2446 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2447 | return RValue<Int>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2448 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2449 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2450 | RValue<Int> operator+=(Int &lhs, RValue<Int> rhs) |
| 2451 | { |
| 2452 | return lhs = lhs + rhs; |
| 2453 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2454 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2455 | RValue<Int> operator-=(Int &lhs, RValue<Int> rhs) |
| 2456 | { |
| 2457 | return lhs = lhs - rhs; |
| 2458 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2459 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2460 | RValue<Int> operator*=(Int &lhs, RValue<Int> rhs) |
| 2461 | { |
| 2462 | return lhs = lhs * rhs; |
| 2463 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2464 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2465 | RValue<Int> operator/=(Int &lhs, RValue<Int> rhs) |
| 2466 | { |
| 2467 | return lhs = lhs / rhs; |
| 2468 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2469 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2470 | RValue<Int> operator%=(Int &lhs, RValue<Int> rhs) |
| 2471 | { |
| 2472 | return lhs = lhs % rhs; |
| 2473 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2474 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2475 | RValue<Int> operator&=(Int &lhs, RValue<Int> rhs) |
| 2476 | { |
| 2477 | return lhs = lhs & rhs; |
| 2478 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2479 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2480 | RValue<Int> operator|=(Int &lhs, RValue<Int> rhs) |
| 2481 | { |
| 2482 | return lhs = lhs | rhs; |
| 2483 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2484 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2485 | RValue<Int> operator^=(Int &lhs, RValue<Int> rhs) |
| 2486 | { |
| 2487 | return lhs = lhs ^ rhs; |
| 2488 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2489 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2490 | RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs) |
| 2491 | { |
| 2492 | return lhs = lhs << rhs; |
| 2493 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2494 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2495 | RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs) |
| 2496 | { |
| 2497 | return lhs = lhs >> rhs; |
| 2498 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2499 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2500 | RValue<Int> operator+(RValue<Int> val) |
| 2501 | { |
| 2502 | return val; |
| 2503 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2504 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2505 | RValue<Int> operator-(RValue<Int> val) |
| 2506 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2507 | return RValue<Int>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2508 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2509 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2510 | RValue<Int> operator~(RValue<Int> val) |
| 2511 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2512 | return RValue<Int>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2513 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2514 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2515 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
| 2516 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2517 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2518 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2519 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2520 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
| 2521 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2522 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2523 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2524 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2525 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
| 2526 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2527 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2528 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2529 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2530 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
| 2531 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2532 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2533 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2534 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2535 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
| 2536 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2537 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2538 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2539 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2540 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
| 2541 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2542 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2543 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2544 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2545 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 2546 | { |
| 2547 | return IfThenElse(x > y, x, y); |
| 2548 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2549 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2550 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 2551 | { |
| 2552 | return IfThenElse(x < y, x, y); |
| 2553 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2554 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2555 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 2556 | { |
| 2557 | return Min(Max(x, min), max); |
| 2558 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2559 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2560 | Long::Long(RValue<Int> cast) |
| 2561 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2562 | Value *integer = Nucleus::createSExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2563 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2564 | storeValue(integer); |
| 2565 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2566 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2567 | Long::Long(RValue<UInt> cast) |
| 2568 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2569 | Value *integer = Nucleus::createZExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2570 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2571 | storeValue(integer); |
| 2572 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2573 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2574 | Long::Long(RValue<Long> rhs) |
| 2575 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2576 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2577 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2578 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2579 | RValue<Long> Long::operator=(int64_t rhs) |
| 2580 | { |
| 2581 | return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs))); |
| 2582 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2583 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2584 | RValue<Long> Long::operator=(RValue<Long> rhs) |
| 2585 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2586 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2587 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2588 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2589 | RValue<Long> Long::operator=(const Long &rhs) |
| 2590 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2591 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2592 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2593 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2594 | RValue<Long> Long::operator=(const Reference<Long> &rhs) |
| 2595 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2596 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2597 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2598 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2599 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
| 2600 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2601 | return RValue<Long>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2602 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2603 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2604 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
| 2605 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2606 | return RValue<Long>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2607 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2608 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2609 | RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs) |
| 2610 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2611 | return RValue<Long>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2612 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2613 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2614 | RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs) |
| 2615 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2616 | return RValue<Long>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2617 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2618 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2619 | RValue<Long> operator+=(Long &lhs, RValue<Long> rhs) |
| 2620 | { |
| 2621 | return lhs = lhs + rhs; |
| 2622 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2623 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2624 | RValue<Long> operator-=(Long &lhs, RValue<Long> rhs) |
| 2625 | { |
| 2626 | return lhs = lhs - rhs; |
| 2627 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2628 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2629 | RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2630 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2631 | return RValue<Long>(Nucleus::createAtomicAdd(x.value(), y.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2632 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2633 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2634 | 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] | 2635 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2636 | return RValue<UInt>(Nucleus::createAtomicAdd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2637 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2638 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2639 | 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] | 2640 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2641 | return RValue<UInt>(Nucleus::createAtomicSub(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2642 | } |
Chris Forbes | 707ed99 | 2019-04-18 18:17:35 -0700 | [diff] [blame] | 2643 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2644 | 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] | 2645 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2646 | return RValue<UInt>(Nucleus::createAtomicAnd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2647 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2648 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2649 | 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] | 2650 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2651 | return RValue<UInt>(Nucleus::createAtomicOr(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2652 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2653 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2654 | 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] | 2655 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2656 | return RValue<UInt>(Nucleus::createAtomicXor(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2657 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2658 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2659 | 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] | 2660 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2661 | return RValue<UInt>(Nucleus::createAtomicExchange(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2662 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2663 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2664 | 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] | 2665 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2666 | 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] | 2667 | } |
Chris Forbes | a16238d | 2019-04-18 16:31:54 -0700 | [diff] [blame] | 2668 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2669 | UInt::UInt(Argument<UInt> argument) |
| 2670 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2671 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2672 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2673 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2674 | UInt::UInt(RValue<UShort> cast) |
| 2675 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2676 | Value *integer = Nucleus::createZExt(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2677 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2678 | storeValue(integer); |
| 2679 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2680 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2681 | UInt::UInt(RValue<Long> cast) |
| 2682 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2683 | Value *integer = Nucleus::createTrunc(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2684 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2685 | storeValue(integer); |
| 2686 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2687 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2688 | UInt::UInt(int x) |
| 2689 | { |
| 2690 | storeValue(Nucleus::createConstantInt(x)); |
| 2691 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2692 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2693 | UInt::UInt(unsigned int x) |
| 2694 | { |
| 2695 | storeValue(Nucleus::createConstantInt(x)); |
| 2696 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2697 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2698 | UInt::UInt(RValue<UInt> rhs) |
| 2699 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2700 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2701 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2702 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2703 | UInt::UInt(RValue<Int> rhs) |
| 2704 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2705 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2706 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2707 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2708 | UInt::UInt(const UInt &rhs) |
| 2709 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2710 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2711 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2712 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2713 | UInt::UInt(const Reference<UInt> &rhs) |
| 2714 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2715 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2716 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2717 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2718 | UInt::UInt(const Int &rhs) |
| 2719 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2720 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2721 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2722 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2723 | UInt::UInt(const Reference<Int> &rhs) |
| 2724 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2725 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2726 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2727 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2728 | RValue<UInt> UInt::operator=(unsigned int rhs) |
| 2729 | { |
| 2730 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2731 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2732 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2733 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) |
| 2734 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2735 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2736 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2737 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2738 | RValue<UInt> UInt::operator=(RValue<Int> rhs) |
| 2739 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2740 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2741 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2742 | return RValue<UInt>(rhs); |
| 2743 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2744 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2745 | RValue<UInt> UInt::operator=(const UInt &rhs) |
| 2746 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2747 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2748 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2749 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2750 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) |
| 2751 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2752 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2753 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2754 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2755 | RValue<UInt> UInt::operator=(const Int &rhs) |
| 2756 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2757 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2758 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2759 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2760 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) |
| 2761 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2762 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2763 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2764 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2765 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2766 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2767 | return RValue<UInt>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2768 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2769 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2770 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2771 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2772 | return RValue<UInt>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2773 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2774 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2775 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2776 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2777 | return RValue<UInt>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2778 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2779 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2780 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2781 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2782 | return RValue<UInt>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2783 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2784 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2785 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2786 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2787 | return RValue<UInt>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2788 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2789 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2790 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2791 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2792 | return RValue<UInt>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2793 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2794 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2795 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2796 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2797 | return RValue<UInt>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2798 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2799 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2800 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2801 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2802 | return RValue<UInt>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2803 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2804 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2805 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2806 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2807 | return RValue<UInt>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2808 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2809 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2810 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2811 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2812 | return RValue<UInt>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2813 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2814 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2815 | RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs) |
| 2816 | { |
| 2817 | return lhs = lhs + rhs; |
| 2818 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2819 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2820 | RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs) |
| 2821 | { |
| 2822 | return lhs = lhs - rhs; |
| 2823 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2824 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2825 | RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs) |
| 2826 | { |
| 2827 | return lhs = lhs * rhs; |
| 2828 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2829 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2830 | RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs) |
| 2831 | { |
| 2832 | return lhs = lhs / rhs; |
| 2833 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2834 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2835 | RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs) |
| 2836 | { |
| 2837 | return lhs = lhs % rhs; |
| 2838 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2839 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2840 | RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs) |
| 2841 | { |
| 2842 | return lhs = lhs & rhs; |
| 2843 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2844 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2845 | RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs) |
| 2846 | { |
| 2847 | return lhs = lhs | rhs; |
| 2848 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2849 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2850 | RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs) |
| 2851 | { |
| 2852 | return lhs = lhs ^ rhs; |
| 2853 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2854 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2855 | RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs) |
| 2856 | { |
| 2857 | return lhs = lhs << rhs; |
| 2858 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2859 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2860 | RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs) |
| 2861 | { |
| 2862 | return lhs = lhs >> rhs; |
| 2863 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2864 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2865 | RValue<UInt> operator+(RValue<UInt> val) |
| 2866 | { |
| 2867 | return val; |
| 2868 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2869 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2870 | RValue<UInt> operator-(RValue<UInt> val) |
| 2871 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2872 | return RValue<UInt>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2873 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2874 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2875 | RValue<UInt> operator~(RValue<UInt> val) |
| 2876 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2877 | return RValue<UInt>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2878 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2879 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2880 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 2881 | { |
| 2882 | return IfThenElse(x > y, x, y); |
| 2883 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2884 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2885 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 2886 | { |
| 2887 | return IfThenElse(x < y, x, y); |
| 2888 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2889 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2890 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 2891 | { |
| 2892 | return Min(Max(x, min), max); |
| 2893 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2894 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2895 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2896 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2897 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2898 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2899 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2900 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2901 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2902 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2903 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2904 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2905 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2906 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2907 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2908 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2909 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2910 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2911 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2912 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2913 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2914 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2915 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2916 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2917 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2918 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2919 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2920 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2921 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2922 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2923 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2924 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2925 | Int2::Int2(RValue<Int4> cast) |
| 2926 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2927 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2928 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2929 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2930 | Int2::Int2(int x, int y) |
| 2931 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2932 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2933 | storeValue(Nucleus::createConstantVector(constantVector, 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(RValue<Int2> rhs) |
| 2937 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2938 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2939 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2940 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2941 | Int2::Int2(const Int2 &rhs) |
| 2942 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2943 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2944 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2945 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2946 | Int2::Int2(const Reference<Int2> &rhs) |
| 2947 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2948 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2949 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2950 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2951 | Int2::Int2(RValue<Int> lo, RValue<Int> hi) |
| 2952 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2953 | int shuffle[4] = { 0, 4, 1, 5 }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2954 | Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2955 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2956 | storeValue(Nucleus::createBitCast(packed, Int2::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2957 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2958 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2959 | RValue<Int2> Int2::operator=(RValue<Int2> rhs) |
| 2960 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2961 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2962 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2963 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2964 | RValue<Int2> Int2::operator=(const Int2 &rhs) |
| 2965 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2966 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2967 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2968 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2969 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) |
| 2970 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2971 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2972 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2973 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2974 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2975 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2976 | return RValue<Int2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2977 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2978 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2979 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2980 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2981 | return RValue<Int2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2982 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2983 | |
| 2984 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2985 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2986 | // return RValue<Int2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2987 | // } |
| 2988 | |
| 2989 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2990 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2991 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2992 | // } |
| 2993 | |
| 2994 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2995 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2996 | // return RValue<Int2>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2997 | // } |
| 2998 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2999 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3000 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3001 | return RValue<Int2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3002 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3003 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3004 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3005 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3006 | return RValue<Int2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3007 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3008 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3009 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3010 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3011 | return RValue<Int2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3012 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3013 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3014 | RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs) |
| 3015 | { |
| 3016 | return lhs = lhs + rhs; |
| 3017 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3018 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3019 | RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs) |
| 3020 | { |
| 3021 | return lhs = lhs - rhs; |
| 3022 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3023 | |
| 3024 | // RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs) |
| 3025 | // { |
| 3026 | // return lhs = lhs * rhs; |
| 3027 | // } |
| 3028 | |
| 3029 | // RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs) |
| 3030 | // { |
| 3031 | // return lhs = lhs / rhs; |
| 3032 | // } |
| 3033 | |
| 3034 | // RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs) |
| 3035 | // { |
| 3036 | // return lhs = lhs % rhs; |
| 3037 | // } |
| 3038 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3039 | RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs) |
| 3040 | { |
| 3041 | return lhs = lhs & rhs; |
| 3042 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3043 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3044 | RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs) |
| 3045 | { |
| 3046 | return lhs = lhs | rhs; |
| 3047 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3048 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3049 | RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs) |
| 3050 | { |
| 3051 | return lhs = lhs ^ rhs; |
| 3052 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3053 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3054 | RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs) |
| 3055 | { |
| 3056 | return lhs = lhs << rhs; |
| 3057 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3058 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3059 | RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs) |
| 3060 | { |
| 3061 | return lhs = lhs >> rhs; |
| 3062 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3063 | |
| 3064 | // RValue<Int2> operator+(RValue<Int2> val) |
| 3065 | // { |
| 3066 | // return val; |
| 3067 | // } |
| 3068 | |
| 3069 | // RValue<Int2> operator-(RValue<Int2> val) |
| 3070 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3071 | // return RValue<Int2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3072 | // } |
| 3073 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3074 | RValue<Int2> operator~(RValue<Int2> val) |
| 3075 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3076 | return RValue<Int2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3077 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3078 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3079 | RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
| 3080 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3081 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3082 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3083 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3084 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3085 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3086 | RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
| 3087 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3088 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3089 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3090 | auto lowHigh = RValue<Int4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3091 | return As<Short4>(Swizzle(lowHigh, 0x2323)); |
| 3092 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3093 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3094 | RValue<Int> Extract(RValue<Int2> val, int i) |
| 3095 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3096 | return RValue<Int>(Nucleus::createExtractElement(val.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3097 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3098 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3099 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
| 3100 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3101 | return RValue<Int2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3102 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3103 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3104 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 3105 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3106 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3107 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
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(RValue<UInt2> rhs) |
| 3111 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3112 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3113 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3114 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3115 | UInt2::UInt2(const UInt2 &rhs) |
| 3116 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3117 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3118 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3119 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3120 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 3121 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3122 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3123 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3124 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3125 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) |
| 3126 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3127 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3128 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3129 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3130 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) |
| 3131 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3132 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3133 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3134 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3135 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) |
| 3136 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3137 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3138 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3139 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3140 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3141 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3142 | return RValue<UInt2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3143 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3144 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3145 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3146 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3147 | return RValue<UInt2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3148 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3149 | |
| 3150 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3151 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3152 | // return RValue<UInt2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3153 | // } |
| 3154 | |
| 3155 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3156 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3157 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3158 | // } |
| 3159 | |
| 3160 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3161 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3162 | // return RValue<UInt2>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3163 | // } |
| 3164 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3165 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3166 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3167 | return RValue<UInt2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3168 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3169 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3170 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3171 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3172 | return RValue<UInt2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3173 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3174 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3175 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3176 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3177 | return RValue<UInt2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3178 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3179 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3180 | RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3181 | { |
| 3182 | return lhs = lhs + rhs; |
| 3183 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3184 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3185 | RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3186 | { |
| 3187 | return lhs = lhs - rhs; |
| 3188 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3189 | |
| 3190 | // RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3191 | // { |
| 3192 | // return lhs = lhs * rhs; |
| 3193 | // } |
| 3194 | |
| 3195 | // RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3196 | // { |
| 3197 | // return lhs = lhs / rhs; |
| 3198 | // } |
| 3199 | |
| 3200 | // RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3201 | // { |
| 3202 | // return lhs = lhs % rhs; |
| 3203 | // } |
| 3204 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3205 | RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3206 | { |
| 3207 | return lhs = lhs & rhs; |
| 3208 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3209 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3210 | RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3211 | { |
| 3212 | return lhs = lhs | rhs; |
| 3213 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3214 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3215 | RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3216 | { |
| 3217 | return lhs = lhs ^ rhs; |
| 3218 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3219 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3220 | RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs) |
| 3221 | { |
| 3222 | return lhs = lhs << rhs; |
| 3223 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3224 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3225 | RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs) |
| 3226 | { |
| 3227 | return lhs = lhs >> rhs; |
| 3228 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3229 | |
| 3230 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 3231 | // { |
| 3232 | // return val; |
| 3233 | // } |
| 3234 | |
| 3235 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 3236 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3237 | // return RValue<UInt2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3238 | // } |
| 3239 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3240 | RValue<UInt2> operator~(RValue<UInt2> val) |
| 3241 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3242 | return RValue<UInt2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3243 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3244 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3245 | RValue<UInt> Extract(RValue<UInt2> val, int i) |
| 3246 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3247 | return RValue<UInt>(Nucleus::createExtractElement(val.value(), UInt::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3248 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3249 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3250 | RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i) |
| 3251 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3252 | return RValue<UInt2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3253 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3254 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3255 | Int4::Int4() |
| 3256 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3257 | { |
| 3258 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3259 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3260 | Int4::Int4(RValue<Float4> cast) |
| 3261 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3262 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3263 | Value *xyzw = Nucleus::createFPToSI(cast.value(), Int4::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3264 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3265 | storeValue(xyzw); |
| 3266 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3267 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3268 | Int4::Int4(int xyzw) |
| 3269 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3270 | { |
| 3271 | constant(xyzw, xyzw, xyzw, 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 x, int yzw) |
| 3275 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3276 | { |
| 3277 | constant(x, yzw, yzw, yzw); |
| 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 y, int zw) |
| 3281 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3282 | { |
| 3283 | constant(x, y, zw, zw); |
| 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 z, int w) |
| 3287 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3288 | { |
| 3289 | constant(x, y, z, w); |
| 3290 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3291 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3292 | void Int4::constant(int x, int y, int z, int w) |
| 3293 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3294 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3295 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3296 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3297 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3298 | Int4::Int4(RValue<Int4> rhs) |
| 3299 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3300 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3301 | store(rhs); |
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(const Int4 &rhs) |
| 3305 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3306 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3307 | store(rhs.load()); |
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 Reference<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(RValue<UInt4> rhs) |
| 3317 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3318 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3319 | storeValue(rhs.value()); |
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(const UInt4 &rhs) |
| 3323 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3324 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3325 | storeValue(rhs.loadValue()); |
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 Reference<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(RValue<Int2> lo, RValue<Int2> hi) |
| 3335 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3336 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3337 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3338 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3339 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3340 | storeValue(packed); |
| 3341 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3342 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3343 | Int4::Int4(const Int &rhs) |
| 3344 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3345 | { |
| 3346 | *this = RValue<Int>(rhs.loadValue()); |
| 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 Reference<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 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3355 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) |
| 3356 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3357 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3358 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3359 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3360 | RValue<Int4> Int4::operator=(const Int4 &rhs) |
| 3361 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3362 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3363 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3364 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3365 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) |
| 3366 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3367 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3368 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3369 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3370 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3371 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3372 | return RValue<Int4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3373 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3374 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3375 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3376 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3377 | return RValue<Int4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3378 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3379 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3380 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3381 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3382 | return RValue<Int4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3383 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3384 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3385 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3386 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3387 | return RValue<Int4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3388 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3389 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3390 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3391 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3392 | return RValue<Int4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3393 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3394 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3395 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3396 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3397 | return RValue<Int4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3398 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3399 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3400 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3401 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3402 | return RValue<Int4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3403 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3404 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3405 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3406 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3407 | return RValue<Int4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3408 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3409 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3410 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3411 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3412 | return RValue<Int4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3413 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3414 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3415 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3416 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3417 | return RValue<Int4>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3418 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3419 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3420 | RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs) |
| 3421 | { |
| 3422 | return lhs = lhs + rhs; |
| 3423 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3424 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3425 | RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs) |
| 3426 | { |
| 3427 | return lhs = lhs - rhs; |
| 3428 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3429 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3430 | RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs) |
| 3431 | { |
| 3432 | return lhs = lhs * rhs; |
| 3433 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3434 | |
| 3435 | // RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs) |
| 3436 | // { |
| 3437 | // return lhs = lhs / rhs; |
| 3438 | // } |
| 3439 | |
| 3440 | // RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs) |
| 3441 | // { |
| 3442 | // return lhs = lhs % rhs; |
| 3443 | // } |
| 3444 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3445 | RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs) |
| 3446 | { |
| 3447 | return lhs = lhs & rhs; |
| 3448 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3449 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3450 | RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs) |
| 3451 | { |
| 3452 | return lhs = lhs | rhs; |
| 3453 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3454 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3455 | RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs) |
| 3456 | { |
| 3457 | return lhs = lhs ^ rhs; |
| 3458 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3459 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3460 | RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs) |
| 3461 | { |
| 3462 | return lhs = lhs << rhs; |
| 3463 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3464 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3465 | RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs) |
| 3466 | { |
| 3467 | return lhs = lhs >> rhs; |
| 3468 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3469 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3470 | RValue<Int4> operator+(RValue<Int4> val) |
| 3471 | { |
| 3472 | return val; |
| 3473 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3474 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3475 | RValue<Int4> operator-(RValue<Int4> val) |
| 3476 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3477 | return RValue<Int4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3478 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3479 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3480 | RValue<Int4> operator~(RValue<Int4> val) |
| 3481 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3482 | return RValue<Int4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3483 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3484 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3485 | RValue<Int> Extract(RValue<Int4> x, int i) |
| 3486 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3487 | return RValue<Int>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3488 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3489 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3490 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
| 3491 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3492 | return RValue<Int4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3493 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3494 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3495 | RValue<Int4> Swizzle(RValue<Int4> x, uint16_t select) |
| 3496 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3497 | return RValue<Int4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3498 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3499 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3500 | RValue<Int4> Shuffle(RValue<Int4> x, RValue<Int4> y, unsigned short select) |
| 3501 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3502 | return RValue<Int4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3503 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 3504 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3505 | UInt4::UInt4() |
| 3506 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3507 | { |
| 3508 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3509 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3510 | UInt4::UInt4(int xyzw) |
| 3511 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3512 | { |
| 3513 | constant(xyzw, xyzw, xyzw, xyzw); |
| 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 x, int yzw) |
| 3517 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3518 | { |
| 3519 | constant(x, yzw, yzw, yzw); |
| 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 y, int zw) |
| 3523 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3524 | { |
| 3525 | constant(x, y, zw, zw); |
| 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 z, int w) |
| 3529 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3530 | { |
| 3531 | constant(x, y, z, w); |
| 3532 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3533 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3534 | void UInt4::constant(int x, int y, int z, int w) |
| 3535 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3536 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3537 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3538 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3539 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3540 | UInt4::UInt4(RValue<UInt4> rhs) |
| 3541 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3542 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3543 | store(rhs); |
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(const UInt4 &rhs) |
| 3547 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3548 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3549 | store(rhs.load()); |
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 Reference<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(RValue<Int4> rhs) |
| 3559 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3560 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3561 | storeValue(rhs.value()); |
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(const Int4 &rhs) |
| 3565 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3566 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3567 | storeValue(rhs.loadValue()); |
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 Reference<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(RValue<UInt2> lo, RValue<UInt2> hi) |
| 3577 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3578 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3579 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3580 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3581 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3582 | storeValue(packed); |
| 3583 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3584 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3585 | UInt4::UInt4(const UInt &rhs) |
| 3586 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3587 | { |
| 3588 | *this = RValue<UInt>(rhs.loadValue()); |
| 3589 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3590 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3591 | UInt4::UInt4(const Reference<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 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3597 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) |
| 3598 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3599 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3600 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3601 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3602 | RValue<UInt4> UInt4::operator=(const UInt4 &rhs) |
| 3603 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3604 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3605 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3606 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3607 | RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) |
| 3608 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3609 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3610 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3611 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3612 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3613 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3614 | return RValue<UInt4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3615 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3616 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3617 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3618 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3619 | return RValue<UInt4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3620 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3621 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3622 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3623 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3624 | return RValue<UInt4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3625 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3626 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3627 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3628 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3629 | return RValue<UInt4>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3630 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3631 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3632 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3633 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3634 | return RValue<UInt4>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3635 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3636 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3637 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3638 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3639 | return RValue<UInt4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3640 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3641 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3642 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3643 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3644 | return RValue<UInt4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3645 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3646 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3647 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3648 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3649 | return RValue<UInt4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3650 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3651 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3652 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3653 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3654 | return RValue<UInt4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3655 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3656 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3657 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3658 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3659 | return RValue<UInt4>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3660 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3661 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3662 | RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3663 | { |
| 3664 | return lhs = lhs + rhs; |
| 3665 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3666 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3667 | RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3668 | { |
| 3669 | return lhs = lhs - rhs; |
| 3670 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3671 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3672 | RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3673 | { |
| 3674 | return lhs = lhs * rhs; |
| 3675 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3676 | |
| 3677 | // RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3678 | // { |
| 3679 | // return lhs = lhs / rhs; |
| 3680 | // } |
| 3681 | |
| 3682 | // RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3683 | // { |
| 3684 | // return lhs = lhs % rhs; |
| 3685 | // } |
| 3686 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3687 | RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3688 | { |
| 3689 | return lhs = lhs & rhs; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3690 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3691 | |
| 3692 | RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3693 | { |
| 3694 | return lhs = lhs | rhs; |
| 3695 | } |
| 3696 | |
| 3697 | RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3698 | { |
| 3699 | return lhs = lhs ^ rhs; |
| 3700 | } |
| 3701 | |
| 3702 | RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs) |
| 3703 | { |
| 3704 | return lhs = lhs << rhs; |
| 3705 | } |
| 3706 | |
| 3707 | RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs) |
| 3708 | { |
| 3709 | return lhs = lhs >> rhs; |
| 3710 | } |
| 3711 | |
| 3712 | RValue<UInt4> operator+(RValue<UInt4> val) |
| 3713 | { |
| 3714 | return val; |
| 3715 | } |
| 3716 | |
| 3717 | RValue<UInt4> operator-(RValue<UInt4> val) |
| 3718 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3719 | return RValue<UInt4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3720 | } |
| 3721 | |
| 3722 | RValue<UInt4> operator~(RValue<UInt4> val) |
| 3723 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3724 | return RValue<UInt4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3725 | } |
| 3726 | |
| 3727 | RValue<UInt> Extract(RValue<UInt4> x, int i) |
| 3728 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3729 | return RValue<UInt>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3730 | } |
| 3731 | |
| 3732 | RValue<UInt4> Insert(RValue<UInt4> x, RValue<UInt> element, int i) |
| 3733 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3734 | return RValue<UInt4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3735 | } |
| 3736 | |
| 3737 | RValue<UInt4> Swizzle(RValue<UInt4> x, uint16_t select) |
| 3738 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3739 | return RValue<UInt4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3740 | } |
| 3741 | |
| 3742 | RValue<UInt4> Shuffle(RValue<UInt4> x, RValue<UInt4> y, unsigned short select) |
| 3743 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3744 | return RValue<UInt4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3745 | } |
| 3746 | |
| 3747 | Half::Half(RValue<Float> cast) |
| 3748 | { |
| 3749 | UInt fp32i = As<UInt>(cast); |
| 3750 | UInt abs = fp32i & 0x7FFFFFFF; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3751 | UShort fp16i((fp32i & 0x80000000) >> 16); // sign |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3752 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3753 | If(abs > 0x47FFEFFF) // Infinity |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3754 | { |
| 3755 | fp16i |= UShort(0x7FFF); |
| 3756 | } |
| 3757 | Else |
| 3758 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3759 | If(abs < 0x38800000) // Denormal |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3760 | { |
| 3761 | Int mantissa = (abs & 0x007FFFFF) | 0x00800000; |
| 3762 | Int e = 113 - (abs >> 23); |
Nicolas Capens | 60f8c2e | 2019-12-12 13:40:15 -0500 | [diff] [blame] | 3763 | abs = IfThenElse(e < 24, (mantissa >> e), Int(0)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3764 | fp16i |= UShort((abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3765 | } |
| 3766 | Else |
| 3767 | { |
| 3768 | fp16i |= UShort((abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3769 | } |
| 3770 | } |
| 3771 | |
| 3772 | storeValue(fp16i.loadValue()); |
| 3773 | } |
| 3774 | |
| 3775 | Float::Float(RValue<Int> cast) |
| 3776 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3777 | Value *integer = Nucleus::createSIToFP(cast.value(), Float::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3778 | |
| 3779 | storeValue(integer); |
| 3780 | } |
| 3781 | |
| 3782 | Float::Float(RValue<UInt> cast) |
| 3783 | { |
| 3784 | RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) + |
| 3785 | As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u))); |
| 3786 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3787 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3788 | } |
| 3789 | |
| 3790 | Float::Float(RValue<Half> cast) |
| 3791 | { |
| 3792 | Int fp16i(As<UShort>(cast)); |
| 3793 | |
| 3794 | Int s = (fp16i >> 15) & 0x00000001; |
| 3795 | Int e = (fp16i >> 10) & 0x0000001F; |
| 3796 | Int m = fp16i & 0x000003FF; |
| 3797 | |
| 3798 | UInt fp32i(s << 31); |
| 3799 | If(e == 0) |
| 3800 | { |
| 3801 | If(m != 0) |
| 3802 | { |
| 3803 | While((m & 0x00000400) == 0) |
| 3804 | { |
| 3805 | m <<= 1; |
| 3806 | e -= 1; |
| 3807 | } |
| 3808 | |
| 3809 | fp32i |= As<UInt>(((e + (127 - 15) + 1) << 23) | ((m & ~0x00000400) << 13)); |
| 3810 | } |
| 3811 | } |
| 3812 | Else |
| 3813 | { |
| 3814 | fp32i |= As<UInt>(((e + (127 - 15)) << 23) | (m << 13)); |
| 3815 | } |
| 3816 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3817 | storeValue(As<Float>(fp32i).value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3818 | } |
| 3819 | |
| 3820 | Float::Float(float x) |
| 3821 | { |
| 3822 | // C++ does not have a way to write an infinite or NaN literal, |
| 3823 | // nor does it allow division by zero as a constant expression. |
| 3824 | // Thus we should not accept inf or NaN as a Reactor Float constant, |
| 3825 | // as this would typically idicate a bug, and avoids undefined |
| 3826 | // behavior. |
| 3827 | // |
| 3828 | // This also prevents the issue of the LLVM JIT only taking double |
| 3829 | // values for constructing floating-point constants. During the |
| 3830 | // conversion from single-precision to double, a signaling NaN can |
| 3831 | // become a quiet NaN, thus altering its bit pattern. Hence this |
| 3832 | // assert is also helpful for detecting cases where integers are |
| 3833 | // being reinterpreted as float and then bitcast to integer again, |
| 3834 | // which does not guarantee preserving the integer value. |
| 3835 | // |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3836 | // The inifinity() method can be used to obtain positive infinity. |
| 3837 | // Should NaN constants be required, methods like quiet_NaN() and |
| 3838 | // signaling_NaN() should be added (matching std::numeric_limits). |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3839 | ASSERT(std::isfinite(x)); |
| 3840 | |
| 3841 | storeValue(Nucleus::createConstantFloat(x)); |
| 3842 | } |
| 3843 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3844 | // TODO(b/140302841): Negative infinity can be obtained by using '-infinity()'. |
| 3845 | // This comes at a minor run-time JIT cost, and the backend may or may not |
| 3846 | // perform constant folding. This can be optimized by having Reactor perform |
| 3847 | // the folding, which would still be cheaper than having a capable backend do it. |
| 3848 | Float Float::infinity() |
| 3849 | { |
| 3850 | Float result; |
| 3851 | |
| 3852 | constexpr double inf = std::numeric_limits<double>::infinity(); |
| 3853 | result.storeValue(Nucleus::createConstantFloat(inf)); |
| 3854 | |
| 3855 | return result; |
| 3856 | } |
| 3857 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3858 | Float::Float(RValue<Float> rhs) |
| 3859 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3860 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3861 | } |
| 3862 | |
| 3863 | Float::Float(const Float &rhs) |
| 3864 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3865 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3866 | } |
| 3867 | |
| 3868 | Float::Float(const Reference<Float> &rhs) |
| 3869 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3870 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3871 | } |
| 3872 | |
| 3873 | Float::Float(Argument<Float> argument) |
| 3874 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3875 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3876 | } |
| 3877 | |
Nicolas Capens | 0aca3ca | 2020-09-19 23:59:08 -0400 | [diff] [blame] | 3878 | RValue<Float> Float::operator=(float rhs) |
| 3879 | { |
| 3880 | return RValue<Float>(storeValue(Nucleus::createConstantFloat(rhs))); |
| 3881 | } |
| 3882 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3883 | RValue<Float> Float::operator=(RValue<Float> rhs) |
| 3884 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3885 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3886 | } |
| 3887 | |
| 3888 | RValue<Float> Float::operator=(const Float &rhs) |
| 3889 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3890 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3891 | } |
| 3892 | |
| 3893 | RValue<Float> Float::operator=(const Reference<Float> &rhs) |
| 3894 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3895 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3896 | } |
| 3897 | |
| 3898 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
| 3899 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3900 | return RValue<Float>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3901 | } |
| 3902 | |
| 3903 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
| 3904 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3905 | return RValue<Float>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3906 | } |
| 3907 | |
| 3908 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
| 3909 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3910 | return RValue<Float>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3911 | } |
| 3912 | |
| 3913 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
| 3914 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3915 | return RValue<Float>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3916 | } |
| 3917 | |
| 3918 | RValue<Float> operator+=(Float &lhs, RValue<Float> rhs) |
| 3919 | { |
| 3920 | return lhs = lhs + rhs; |
| 3921 | } |
| 3922 | |
| 3923 | RValue<Float> operator-=(Float &lhs, RValue<Float> rhs) |
| 3924 | { |
| 3925 | return lhs = lhs - rhs; |
| 3926 | } |
| 3927 | |
| 3928 | RValue<Float> operator*=(Float &lhs, RValue<Float> rhs) |
| 3929 | { |
| 3930 | return lhs = lhs * rhs; |
| 3931 | } |
| 3932 | |
| 3933 | RValue<Float> operator/=(Float &lhs, RValue<Float> rhs) |
| 3934 | { |
| 3935 | return lhs = lhs / rhs; |
| 3936 | } |
| 3937 | |
| 3938 | RValue<Float> operator+(RValue<Float> val) |
| 3939 | { |
| 3940 | return val; |
| 3941 | } |
| 3942 | |
| 3943 | RValue<Float> operator-(RValue<Float> val) |
| 3944 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3945 | return RValue<Float>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3946 | } |
| 3947 | |
| 3948 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
| 3949 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3950 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3951 | } |
| 3952 | |
| 3953 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
| 3954 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3955 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3956 | } |
| 3957 | |
| 3958 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
| 3959 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3960 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3961 | } |
| 3962 | |
| 3963 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
| 3964 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3965 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3966 | } |
| 3967 | |
| 3968 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
| 3969 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3970 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3971 | } |
| 3972 | |
| 3973 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
| 3974 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3975 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3976 | } |
| 3977 | |
| 3978 | RValue<Float> Abs(RValue<Float> x) |
| 3979 | { |
| 3980 | return IfThenElse(x > 0.0f, x, -x); |
| 3981 | } |
| 3982 | |
| 3983 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
| 3984 | { |
| 3985 | return IfThenElse(x > y, x, y); |
| 3986 | } |
| 3987 | |
| 3988 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
| 3989 | { |
| 3990 | return IfThenElse(x < y, x, y); |
| 3991 | } |
| 3992 | |
| 3993 | Float2::Float2(RValue<Float4> cast) |
| 3994 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3995 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3996 | } |
| 3997 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3998 | Float4::Float4(RValue<Byte4> cast) |
| 3999 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4000 | { |
| 4001 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4002 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4003 | |
| 4004 | storeValue(xyzw); |
| 4005 | } |
| 4006 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4007 | Float4::Float4(RValue<SByte4> cast) |
| 4008 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4009 | { |
| 4010 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4011 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4012 | |
| 4013 | storeValue(xyzw); |
| 4014 | } |
| 4015 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4016 | Float4::Float4(RValue<Short4> cast) |
| 4017 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4018 | { |
| 4019 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4020 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4021 | } |
| 4022 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4023 | Float4::Float4(RValue<UShort4> cast) |
| 4024 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4025 | { |
| 4026 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4027 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4028 | } |
| 4029 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4030 | Float4::Float4(RValue<Int4> cast) |
| 4031 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4032 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4033 | Value *xyzw = Nucleus::createSIToFP(cast.value(), Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4034 | |
| 4035 | storeValue(xyzw); |
| 4036 | } |
| 4037 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4038 | Float4::Float4(RValue<UInt4> cast) |
| 4039 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4040 | { |
| 4041 | RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) + |
| 4042 | As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u))); |
| 4043 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4044 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4045 | } |
| 4046 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4047 | Float4::Float4() |
| 4048 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4049 | { |
| 4050 | } |
| 4051 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4052 | Float4::Float4(float xyzw) |
| 4053 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4054 | { |
| 4055 | constant(xyzw, xyzw, xyzw, xyzw); |
| 4056 | } |
| 4057 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4058 | Float4::Float4(float x, float yzw) |
| 4059 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4060 | { |
| 4061 | constant(x, yzw, yzw, yzw); |
| 4062 | } |
| 4063 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4064 | Float4::Float4(float x, float y, float zw) |
| 4065 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4066 | { |
| 4067 | constant(x, y, zw, zw); |
| 4068 | } |
| 4069 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4070 | Float4::Float4(float x, float y, float z, float w) |
| 4071 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4072 | { |
| 4073 | constant(x, y, z, w); |
| 4074 | } |
| 4075 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4076 | Float4 Float4::infinity() |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4077 | { |
| 4078 | Float4 result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4079 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4080 | constexpr double inf = std::numeric_limits<double>::infinity(); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4081 | double constantVector[4] = { inf, inf, inf, inf }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4082 | result.storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4083 | |
| 4084 | return result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | void Float4::constant(float x, float y, float z, float w) |
| 4088 | { |
| 4089 | // See Float(float) constructor for the rationale behind this assert. |
| 4090 | ASSERT(std::isfinite(x) && std::isfinite(y) && std::isfinite(z) && std::isfinite(w)); |
| 4091 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4092 | double constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4093 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4094 | } |
| 4095 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4096 | Float4::Float4(RValue<Float4> rhs) |
| 4097 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4098 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4099 | store(rhs); |
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(const Float4 &rhs) |
| 4103 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4104 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4105 | store(rhs.load()); |
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 Reference<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 Float &rhs) |
| 4115 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4116 | { |
| 4117 | *this = RValue<Float>(rhs.loadValue()); |
| 4118 | } |
| 4119 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4120 | Float4::Float4(const Reference<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 | |
Nicolas Capens | 419b7d7 | 2020-10-02 16:15:34 -0400 | [diff] [blame] | 4126 | Float4::Float4(RValue<Float2> lo, RValue<Float2> hi) |
| 4127 | : XYZW(this) |
| 4128 | { |
| 4129 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
| 4130 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
| 4131 | |
| 4132 | storeValue(packed); |
| 4133 | } |
| 4134 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4135 | RValue<Float4> Float4::operator=(float x) |
| 4136 | { |
| 4137 | return *this = Float4(x, x, x, x); |
| 4138 | } |
| 4139 | |
| 4140 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) |
| 4141 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4142 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4143 | } |
| 4144 | |
| 4145 | RValue<Float4> Float4::operator=(const Float4 &rhs) |
| 4146 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4147 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4148 | } |
| 4149 | |
| 4150 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) |
| 4151 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4152 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4153 | } |
| 4154 | |
| 4155 | RValue<Float4> Float4::operator=(RValue<Float> rhs) |
| 4156 | { |
| 4157 | return *this = Float4(rhs); |
| 4158 | } |
| 4159 | |
| 4160 | RValue<Float4> Float4::operator=(const Float &rhs) |
| 4161 | { |
| 4162 | return *this = Float4(rhs); |
| 4163 | } |
| 4164 | |
| 4165 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) |
| 4166 | { |
| 4167 | return *this = Float4(rhs); |
| 4168 | } |
| 4169 | |
| 4170 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4171 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4172 | return RValue<Float4>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4173 | } |
| 4174 | |
| 4175 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4176 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4177 | return RValue<Float4>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4178 | } |
| 4179 | |
| 4180 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4181 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4182 | return RValue<Float4>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4183 | } |
| 4184 | |
| 4185 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4186 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4187 | return RValue<Float4>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4188 | } |
| 4189 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4190 | RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs) |
| 4191 | { |
| 4192 | return lhs = lhs + rhs; |
| 4193 | } |
| 4194 | |
| 4195 | RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs) |
| 4196 | { |
| 4197 | return lhs = lhs - rhs; |
| 4198 | } |
| 4199 | |
| 4200 | RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs) |
| 4201 | { |
| 4202 | return lhs = lhs * rhs; |
| 4203 | } |
| 4204 | |
| 4205 | RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs) |
| 4206 | { |
| 4207 | return lhs = lhs / rhs; |
| 4208 | } |
| 4209 | |
| 4210 | RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs) |
| 4211 | { |
| 4212 | return lhs = lhs % rhs; |
| 4213 | } |
| 4214 | |
| 4215 | RValue<Float4> operator+(RValue<Float4> val) |
| 4216 | { |
| 4217 | return val; |
| 4218 | } |
| 4219 | |
| 4220 | RValue<Float4> operator-(RValue<Float4> val) |
| 4221 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4222 | return RValue<Float4>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4223 | } |
| 4224 | |
| 4225 | RValue<Float4> Abs(RValue<Float4> x) |
| 4226 | { |
| 4227 | // TODO: Optimize. |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4228 | Value *vector = Nucleus::createBitCast(x.value(), Int4::type()); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4229 | int64_t constantVector[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4230 | Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, Int4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4231 | |
| 4232 | return As<Float4>(result); |
| 4233 | } |
| 4234 | |
| 4235 | RValue<Float4> Insert(RValue<Float4> x, RValue<Float> element, int i) |
| 4236 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4237 | return RValue<Float4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4238 | } |
| 4239 | |
| 4240 | RValue<Float> Extract(RValue<Float4> x, int i) |
| 4241 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4242 | return RValue<Float>(Nucleus::createExtractElement(x.value(), Float::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4243 | } |
| 4244 | |
| 4245 | RValue<Float4> Swizzle(RValue<Float4> x, uint16_t select) |
| 4246 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4247 | return RValue<Float4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4248 | } |
| 4249 | |
| 4250 | RValue<Float4> Shuffle(RValue<Float4> x, RValue<Float4> y, uint16_t select) |
| 4251 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4252 | return RValue<Float4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4253 | } |
| 4254 | |
| 4255 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, uint16_t imm) |
| 4256 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4257 | int shuffle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4258 | ((imm >> 12) & 0x03) + 0, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4259 | ((imm >> 8) & 0x03) + 0, |
| 4260 | ((imm >> 4) & 0x03) + 4, |
| 4261 | ((imm >> 0) & 0x03) + 4, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4262 | }; |
| 4263 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4264 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4265 | } |
| 4266 | |
| 4267 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) |
| 4268 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4269 | int shuffle[4] = { 0, 4, 1, 5 }; |
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> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
| 4274 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4275 | int shuffle[4] = { 2, 6, 3, 7 }; |
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> Mask(Float4 &lhs, RValue<Float4> rhs, uint16_t select) |
| 4280 | { |
| 4281 | Value *vector = lhs.loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4282 | Value *result = createMask4(vector, rhs.value(), select); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4283 | lhs.storeValue(result); |
| 4284 | |
| 4285 | return RValue<Float4>(result); |
| 4286 | } |
| 4287 | |
| 4288 | RValue<Int4> IsInf(RValue<Float4> x) |
| 4289 | { |
| 4290 | return CmpEQ(As<Int4>(x) & Int4(0x7FFFFFFF), Int4(0x7F800000)); |
| 4291 | } |
| 4292 | |
| 4293 | RValue<Int4> IsNan(RValue<Float4> x) |
| 4294 | { |
| 4295 | return ~CmpEQ(x, x); |
| 4296 | } |
| 4297 | |
| 4298 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) |
| 4299 | { |
| 4300 | return lhs + RValue<Int>(Nucleus::createConstantInt(offset)); |
| 4301 | } |
| 4302 | |
| 4303 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4304 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4305 | 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] | 4306 | } |
| 4307 | |
| 4308 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4309 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4310 | 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] | 4311 | } |
| 4312 | |
| 4313 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset) |
| 4314 | { |
| 4315 | return lhs = lhs + offset; |
| 4316 | } |
| 4317 | |
| 4318 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4319 | { |
| 4320 | return lhs = lhs + offset; |
| 4321 | } |
| 4322 | |
| 4323 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4324 | { |
| 4325 | return lhs = lhs + offset; |
| 4326 | } |
| 4327 | |
| 4328 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset) |
| 4329 | { |
| 4330 | return lhs + -offset; |
| 4331 | } |
| 4332 | |
| 4333 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4334 | { |
| 4335 | return lhs + -offset; |
| 4336 | } |
| 4337 | |
| 4338 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4339 | { |
| 4340 | return lhs + -offset; |
| 4341 | } |
| 4342 | |
| 4343 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset) |
| 4344 | { |
| 4345 | return lhs = lhs - offset; |
| 4346 | } |
| 4347 | |
| 4348 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4349 | { |
| 4350 | return lhs = lhs - offset; |
| 4351 | } |
| 4352 | |
| 4353 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4354 | { |
| 4355 | return lhs = lhs - offset; |
| 4356 | } |
| 4357 | |
| 4358 | void Return() |
| 4359 | { |
| 4360 | Nucleus::createRetVoid(); |
| 4361 | // Place any unreachable instructions in an unreferenced block. |
| 4362 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 4363 | } |
| 4364 | |
| 4365 | void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
| 4366 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4367 | Nucleus::createCondBr(cmp.value(), bodyBB, endBB); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4368 | Nucleus::setInsertBlock(bodyBB); |
| 4369 | } |
| 4370 | |
| 4371 | RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4372 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4373 | 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] | 4374 | } |
| 4375 | |
| 4376 | RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4377 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4378 | 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] | 4379 | } |
| 4380 | |
| 4381 | void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment) |
| 4382 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4383 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4384 | } |
| 4385 | |
| 4386 | void MaskedStore(RValue<Pointer<Int4>> base, RValue<Int4> val, RValue<Int4> mask, unsigned int alignment) |
| 4387 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4388 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4389 | } |
| 4390 | |
| 4391 | void Fence(std::memory_order memoryOrder) |
| 4392 | { |
| 4393 | ASSERT_MSG(memoryOrder == std::memory_order_acquire || |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4394 | memoryOrder == std::memory_order_release || |
| 4395 | memoryOrder == std::memory_order_acq_rel || |
| 4396 | memoryOrder == std::memory_order_seq_cst, |
| 4397 | "Unsupported memoryOrder: %d", int(memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4398 | Nucleus::createFence(memoryOrder); |
| 4399 | } |
| 4400 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4401 | Bool CToReactor<bool>::cast(bool v) |
| 4402 | { |
| 4403 | return type(v); |
| 4404 | } |
| 4405 | Byte CToReactor<uint8_t>::cast(uint8_t v) |
| 4406 | { |
| 4407 | return type(v); |
| 4408 | } |
| 4409 | SByte CToReactor<int8_t>::cast(int8_t v) |
| 4410 | { |
| 4411 | return type(v); |
| 4412 | } |
| 4413 | Short CToReactor<int16_t>::cast(int16_t v) |
| 4414 | { |
| 4415 | return type(v); |
| 4416 | } |
| 4417 | UShort CToReactor<uint16_t>::cast(uint16_t v) |
| 4418 | { |
| 4419 | return type(v); |
| 4420 | } |
| 4421 | Int CToReactor<int32_t>::cast(int32_t v) |
| 4422 | { |
| 4423 | return type(v); |
| 4424 | } |
| 4425 | UInt CToReactor<uint32_t>::cast(uint32_t v) |
| 4426 | { |
| 4427 | return type(v); |
| 4428 | } |
| 4429 | Float CToReactor<float>::cast(float v) |
| 4430 | { |
| 4431 | return type(v); |
| 4432 | } |
| 4433 | Float4 CToReactor<float[4]>::cast(float v[4]) |
| 4434 | { |
| 4435 | return type(v[0], v[1], v[2], v[3]); |
| 4436 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4437 | |
| 4438 | // TODO: Long has no constructor that takes a uint64_t |
| 4439 | // Long CToReactor<uint64_t>::cast(uint64_t v) { return type(v); } |
| 4440 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4441 | #ifdef ENABLE_RR_PRINT |
| 4442 | static std::string replaceAll(std::string str, const std::string &substr, const std::string &replacement) |
| 4443 | { |
| 4444 | size_t pos = 0; |
| 4445 | while((pos = str.find(substr, pos)) != std::string::npos) |
| 4446 | { |
| 4447 | str.replace(pos, substr.length(), replacement); |
| 4448 | pos += replacement.length(); |
| 4449 | } |
| 4450 | return str; |
| 4451 | } |
| 4452 | |
| 4453 | // extractAll returns a vector containing the extracted n scalar value of |
| 4454 | // the vector vec. |
| 4455 | // TODO: Move to Reactor.cpp (LLVMReactor can use this too) |
| 4456 | static std::vector<Value *> extractAll(Value *vec, int n) |
| 4457 | { |
| 4458 | Type *elemTy = Nucleus::getContainedType(Nucleus::getType(vec)); |
| 4459 | std::vector<Value *> elements; |
| 4460 | elements.reserve(n); |
| 4461 | for(int i = 0; i < n; i++) |
| 4462 | { |
| 4463 | auto el = Nucleus::createExtractElement(vec, elemTy, i); |
| 4464 | elements.push_back(el); |
| 4465 | } |
| 4466 | return elements; |
| 4467 | } |
| 4468 | |
| 4469 | // toInt returns all the integer values in vals extended to a printf-required storage value |
| 4470 | static std::vector<Value *> toInt(const std::vector<Value *> &vals, bool isSigned) |
| 4471 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4472 | auto storageTy = Nucleus::getPrintfStorageType(Int::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4473 | std::vector<Value *> elements; |
| 4474 | elements.reserve(vals.size()); |
| 4475 | for(auto v : vals) |
| 4476 | { |
| 4477 | if(isSigned) |
| 4478 | { |
| 4479 | elements.push_back(Nucleus::createSExt(v, storageTy)); |
| 4480 | } |
| 4481 | else |
| 4482 | { |
| 4483 | elements.push_back(Nucleus::createZExt(v, storageTy)); |
| 4484 | } |
| 4485 | } |
| 4486 | return elements; |
| 4487 | } |
| 4488 | |
| 4489 | // toFloat returns all the float values in vals extended to extended to a printf-required storage value |
| 4490 | static std::vector<Value *> toFloat(const std::vector<Value *> &vals) |
| 4491 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4492 | auto storageTy = Nucleus::getPrintfStorageType(Float::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4493 | std::vector<Value *> elements; |
| 4494 | elements.reserve(vals.size()); |
| 4495 | for(auto v : vals) |
| 4496 | { |
| 4497 | elements.push_back(Nucleus::createFPExt(v, storageTy)); |
| 4498 | } |
| 4499 | return elements; |
| 4500 | } |
| 4501 | |
| 4502 | std::vector<Value *> PrintValue::Ty<Bool>::val(const RValue<Bool> &v) |
| 4503 | { |
| 4504 | auto t = Nucleus::createConstantString("true"); |
| 4505 | auto f = Nucleus::createConstantString("false"); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4506 | return { Nucleus::createSelect(v.value(), t, f) }; |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4507 | } |
| 4508 | |
| 4509 | std::vector<Value *> PrintValue::Ty<Byte>::val(const RValue<Byte> &v) |
| 4510 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4511 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4512 | } |
| 4513 | |
| 4514 | std::vector<Value *> PrintValue::Ty<Byte4>::val(const RValue<Byte4> &v) |
| 4515 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4516 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4517 | } |
| 4518 | |
| 4519 | std::vector<Value *> PrintValue::Ty<Int>::val(const RValue<Int> &v) |
| 4520 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4521 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4522 | } |
| 4523 | |
| 4524 | std::vector<Value *> PrintValue::Ty<Int2>::val(const RValue<Int2> &v) |
| 4525 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4526 | return toInt(extractAll(v.value(), 2), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4527 | } |
| 4528 | |
| 4529 | std::vector<Value *> PrintValue::Ty<Int4>::val(const RValue<Int4> &v) |
| 4530 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4531 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4532 | } |
| 4533 | |
| 4534 | std::vector<Value *> PrintValue::Ty<UInt>::val(const RValue<UInt> &v) |
| 4535 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4536 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4537 | } |
| 4538 | |
| 4539 | std::vector<Value *> PrintValue::Ty<UInt2>::val(const RValue<UInt2> &v) |
| 4540 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4541 | return toInt(extractAll(v.value(), 2), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4542 | } |
| 4543 | |
| 4544 | std::vector<Value *> PrintValue::Ty<UInt4>::val(const RValue<UInt4> &v) |
| 4545 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4546 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4547 | } |
| 4548 | |
| 4549 | std::vector<Value *> PrintValue::Ty<Short>::val(const RValue<Short> &v) |
| 4550 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4551 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4552 | } |
| 4553 | |
| 4554 | std::vector<Value *> PrintValue::Ty<Short4>::val(const RValue<Short4> &v) |
| 4555 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4556 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4557 | } |
| 4558 | |
| 4559 | std::vector<Value *> PrintValue::Ty<UShort>::val(const RValue<UShort> &v) |
| 4560 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4561 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4562 | } |
| 4563 | |
| 4564 | std::vector<Value *> PrintValue::Ty<UShort4>::val(const RValue<UShort4> &v) |
| 4565 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4566 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4567 | } |
| 4568 | |
| 4569 | std::vector<Value *> PrintValue::Ty<Float>::val(const RValue<Float> &v) |
| 4570 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4571 | return toFloat({ v.value() }); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4572 | } |
| 4573 | |
| 4574 | std::vector<Value *> PrintValue::Ty<Float4>::val(const RValue<Float4> &v) |
| 4575 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4576 | return toFloat(extractAll(v.value(), 4)); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4577 | } |
| 4578 | |
| 4579 | std::vector<Value *> PrintValue::Ty<const char *>::val(const char *v) |
| 4580 | { |
| 4581 | return { Nucleus::createConstantString(v) }; |
| 4582 | } |
| 4583 | |
| 4584 | void Printv(const char *function, const char *file, int line, const char *fmt, std::initializer_list<PrintValue> args) |
| 4585 | { |
| 4586 | // Build the printf format message string. |
| 4587 | std::string str; |
| 4588 | if(file != nullptr) { str += (line > 0) ? "%s:%d " : "%s "; } |
| 4589 | if(function != nullptr) { str += "%s "; } |
| 4590 | str += fmt; |
| 4591 | |
| 4592 | // Perform substitution on all '{n}' bracketed indices in the format |
| 4593 | // message. |
| 4594 | int i = 0; |
| 4595 | for(const PrintValue &arg : args) |
| 4596 | { |
| 4597 | str = replaceAll(str, "{" + std::to_string(i++) + "}", arg.format); |
| 4598 | } |
| 4599 | |
| 4600 | std::vector<Value *> vals; |
| 4601 | vals.reserve(8); |
| 4602 | |
| 4603 | // The format message is always the first argument. |
| 4604 | vals.push_back(Nucleus::createConstantString(str)); |
| 4605 | |
| 4606 | // Add optional file, line and function info if provided. |
| 4607 | if(file != nullptr) |
| 4608 | { |
| 4609 | vals.push_back(Nucleus::createConstantString(file)); |
| 4610 | if(line > 0) |
| 4611 | { |
| 4612 | vals.push_back(Nucleus::createConstantInt(line)); |
| 4613 | } |
| 4614 | } |
| 4615 | if(function != nullptr) |
| 4616 | { |
| 4617 | vals.push_back(Nucleus::createConstantString(function)); |
| 4618 | } |
| 4619 | |
| 4620 | // Add all format arguments. |
| 4621 | for(const PrintValue &arg : args) |
| 4622 | { |
| 4623 | for(auto val : arg.values) |
| 4624 | { |
| 4625 | vals.push_back(val); |
| 4626 | } |
| 4627 | } |
| 4628 | |
| 4629 | // This call is implemented by each backend |
| 4630 | VPrintf(vals); |
| 4631 | } |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 4632 | |
| 4633 | // This is the function that is called by VPrintf from the backends |
| 4634 | int DebugPrintf(const char *format, ...) |
| 4635 | { |
| 4636 | // Uncomment this to make it so that we do not print, but the call to this function is emitted. |
| 4637 | // Useful when debugging emitted code to see the Reactor source location. |
| 4638 | //# define RR_PRINT_OUTPUT_TYPE_STUB |
| 4639 | |
| 4640 | # if defined(RR_PRINT_OUTPUT_TYPE_STUB) |
| 4641 | return 0; |
| 4642 | # else |
| 4643 | |
| 4644 | int result; |
| 4645 | va_list args; |
| 4646 | |
| 4647 | va_start(args, format); |
| 4648 | char buffer[2048]; |
| 4649 | result = vsprintf(buffer, format, args); |
| 4650 | va_end(args); |
| 4651 | |
| 4652 | std::fputs(buffer, stdout); |
| 4653 | # if defined(_WIN32) |
| 4654 | OutputDebugString(buffer); |
| 4655 | # endif |
| 4656 | |
| 4657 | return result; |
| 4658 | # endif |
| 4659 | } |
| 4660 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4661 | #endif // ENABLE_RR_PRINT |
| 4662 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4663 | // Functions implemented by backends |
| 4664 | bool HasRcpApprox(); |
| 4665 | RValue<Float4> RcpApprox(RValue<Float4> x, bool exactAtPow2 = false); |
| 4666 | RValue<Float> RcpApprox(RValue<Float> x, bool exactAtPow2 = false); |
| 4667 | |
| 4668 | template<typename T> |
| 4669 | static RValue<T> DoRcp(RValue<T> x, Precision p, bool finite, bool exactAtPow2) |
| 4670 | { |
| 4671 | #if defined(__i386__) || defined(__x86_64__) // On x86, 1/x is fast enough, except for lower precision |
| 4672 | bool approx = HasRcpApprox() && (p != Precision::Full); |
| 4673 | #else |
| 4674 | bool approx = HasRcpApprox(); |
| 4675 | #endif |
| 4676 | |
| 4677 | T rcp; |
| 4678 | |
| 4679 | if(approx) |
| 4680 | { |
| 4681 | rcp = RcpApprox(x, exactAtPow2); |
| 4682 | |
| 4683 | if(p == Precision::Full) |
| 4684 | { |
| 4685 | // Perform one more iteration of Newton-Rhapson division to increase precision |
| 4686 | rcp = (rcp + rcp) - (x * rcp * rcp); |
| 4687 | } |
| 4688 | } |
| 4689 | else |
| 4690 | { |
| 4691 | rcp = T(1.0f) / x; |
| 4692 | } |
| 4693 | |
| 4694 | if(finite) |
| 4695 | { |
| 4696 | constexpr int big = 0x7F7FFFFF; |
| 4697 | rcp = Min(rcp, T((float &)big)); |
| 4698 | } |
| 4699 | |
| 4700 | return rcp; |
| 4701 | } |
| 4702 | |
| 4703 | RValue<Float4> Rcp(RValue<Float4> x, Precision p, bool finite, bool exactAtPow2) |
| 4704 | { |
| 4705 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 4706 | return DoRcp(x, p, finite, exactAtPow2); |
| 4707 | } |
| 4708 | |
| 4709 | RValue<Float> Rcp(RValue<Float> x, Precision p, bool finite, bool exactAtPow2) |
| 4710 | { |
| 4711 | RR_DEBUG_INFO_UPDATE_LOC(); |
| 4712 | return DoRcp(x, p, finite, exactAtPow2); |
| 4713 | } |
| 4714 | |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4715 | // Functions implemented by backends |
| 4716 | bool HasRcpSqrtApprox(); |
| 4717 | RValue<Float4> RcpSqrtApprox(RValue<Float4> x); |
| 4718 | RValue<Float> RcpSqrtApprox(RValue<Float> x); |
| 4719 | |
| 4720 | template<typename T> |
| 4721 | struct CastToIntType; |
| 4722 | |
| 4723 | template<> |
| 4724 | struct CastToIntType<Float4> |
| 4725 | { |
| 4726 | using type = Int4; |
| 4727 | }; |
| 4728 | |
| 4729 | template<> |
| 4730 | struct CastToIntType<Float> |
| 4731 | { |
| 4732 | using type = Int; |
| 4733 | }; |
| 4734 | |
| 4735 | // TODO: move to Reactor.hpp? |
| 4736 | RValue<Int> CmpNEQ(RValue<Int> x, RValue<Int> y) |
| 4737 | { |
| 4738 | return IfThenElse(x != y, Int(~0), Int(0)); |
| 4739 | } |
| 4740 | |
| 4741 | template<typename T> |
| 4742 | static RValue<T> DoRcpSqrt(RValue<T> x, Precision p) |
| 4743 | { |
| 4744 | #if defined(__i386__) || defined(__x86_64__) // On x86, 1/x is fast enough, except for lower precision |
| 4745 | bool approx = HasRcpApprox() && (p != Precision::Full); |
| 4746 | #else |
| 4747 | bool approx = HasRcpApprox(); |
| 4748 | #endif |
| 4749 | |
| 4750 | if(approx) |
| 4751 | { |
| 4752 | using IntType = typename CastToIntType<T>::type; |
| 4753 | |
| 4754 | T rsq = RcpSqrtApprox(x); |
| 4755 | |
| 4756 | if(p == Precision::Full) |
| 4757 | { |
| 4758 | rsq = rsq * (T(3.0f) - rsq * rsq * x) * T(0.5f); |
| 4759 | rsq = As<T>(CmpNEQ(As<IntType>(x), IntType(0x7F800000)) & As<IntType>(rsq)); |
| 4760 | } |
| 4761 | |
| 4762 | return rsq; |
| 4763 | } |
| 4764 | else |
| 4765 | { |
| 4766 | return T(1.0f) / Sqrt(x); |
| 4767 | } |
| 4768 | } |
| 4769 | |
| 4770 | RValue<Float4> RcpSqrt(RValue<Float4> x, Precision p) |
| 4771 | { |
| 4772 | return DoRcpSqrt(x, p); |
| 4773 | } |
| 4774 | |
| 4775 | RValue<Float> RcpSqrt(RValue<Float> x, Precision p) |
| 4776 | { |
| 4777 | return DoRcpSqrt(x, p); |
| 4778 | } |
| 4779 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4780 | } // namespace rr |