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 | |
Sean Risser | 19e3080 | 2022-06-01 10:58:10 -0400 | [diff] [blame] | 17 | #include "Assert.hpp" |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 18 | #include "CPUID.hpp" |
Ben Clayton | b16c586 | 2019-05-08 14:01:38 +0100 | [diff] [blame] | 19 | #include "Debug.hpp" |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 20 | #include "Print.hpp" |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 21 | |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 22 | #if defined(_WIN32) |
| 23 | # ifndef WIN32_LEAN_AND_MEAN |
| 24 | # define WIN32_LEAN_AND_MEAN |
| 25 | # endif |
| 26 | # include <windows.h> |
| 27 | #endif |
| 28 | |
Nicolas Capens | 08c6200 | 2021-11-17 00:25:05 -0500 | [diff] [blame] | 29 | #include <algorithm> |
| 30 | #include <cmath> |
| 31 | |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 32 | // Define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION to non-zero to ensure all |
Nicolas Capens | 70505b4 | 2022-01-31 22:29:48 -0500 | [diff] [blame] | 33 | // variables have a stack location obtained through alloca(). |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 34 | #ifndef REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
| 35 | # define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION 0 |
| 36 | #endif |
| 37 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 38 | namespace rr { |
| 39 | |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 40 | thread_local Variable::UnmaterializedVariables *Variable::unmaterializedVariables = nullptr; |
| 41 | |
| 42 | void Variable::UnmaterializedVariables::add(const Variable *v) |
| 43 | { |
| 44 | variables.emplace(v, counter++); |
| 45 | } |
| 46 | |
| 47 | void Variable::UnmaterializedVariables::remove(const Variable *v) |
| 48 | { |
| 49 | auto iter = variables.find(v); |
| 50 | if(iter != variables.end()) |
| 51 | { |
| 52 | variables.erase(iter); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | void Variable::UnmaterializedVariables::clear() |
| 57 | { |
| 58 | variables.clear(); |
| 59 | } |
| 60 | |
| 61 | void Variable::UnmaterializedVariables::materializeAll() |
| 62 | { |
| 63 | // Flatten map of Variable* to monotonically increasing counter to a vector, |
| 64 | // then sort it by the counter, so that we materialize in variable usage order. |
| 65 | std::vector<std::pair<const Variable *, int>> sorted; |
| 66 | sorted.resize(variables.size()); |
| 67 | std::copy(variables.begin(), variables.end(), sorted.begin()); |
| 68 | std::sort(sorted.begin(), sorted.end(), [&](auto &lhs, auto &rhs) { |
| 69 | return lhs.second < rhs.second; |
| 70 | }); |
| 71 | |
| 72 | for(auto &v : sorted) |
| 73 | { |
| 74 | v.first->materialize(); |
| 75 | } |
| 76 | |
| 77 | variables.clear(); |
| 78 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 79 | |
Antonio Maiorano | bae138d | 2020-12-02 14:25:10 -0500 | [diff] [blame] | 80 | Variable::Variable(Type *type, int arraySize) |
| 81 | : type(type) |
| 82 | , arraySize(arraySize) |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 83 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 84 | #if REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
| 85 | materialize(); |
| 86 | #else |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 87 | unmaterializedVariables->add(this); |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 88 | #endif |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 89 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 90 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 91 | Variable::~Variable() |
| 92 | { |
Nicolas Capens | 3d26cfc | 2021-01-22 16:51:00 -0500 | [diff] [blame] | 93 | // `unmaterializedVariables` can be null at this point due to the function |
| 94 | // already having been finalized, while classes derived from `Function<>` |
| 95 | // can have member `Variable` fields which are destructed afterwards. |
| 96 | if(unmaterializedVariables) |
| 97 | { |
| 98 | unmaterializedVariables->remove(this); |
| 99 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 100 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 101 | |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 102 | void Variable::materialize() const |
| 103 | { |
| 104 | if(!address) |
| 105 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 106 | address = Nucleus::allocateStackVariable(getType(), arraySize); |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 107 | RR_DEBUG_INFO_EMIT_VAR(address); |
| 108 | |
| 109 | if(rvalue) |
| 110 | { |
| 111 | storeValue(rvalue); |
| 112 | rvalue = nullptr; |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | Value *Variable::loadValue() const |
| 118 | { |
| 119 | if(rvalue) |
| 120 | { |
| 121 | return rvalue; |
| 122 | } |
| 123 | |
| 124 | if(!address) |
| 125 | { |
| 126 | // TODO: Return undef instead. |
| 127 | materialize(); |
| 128 | } |
| 129 | |
| 130 | return Nucleus::createLoad(address, getType(), false, 0); |
| 131 | } |
| 132 | |
| 133 | Value *Variable::storeValue(Value *value) const |
| 134 | { |
| 135 | if(address) |
| 136 | { |
| 137 | return Nucleus::createStore(value, address, getType(), false, 0); |
| 138 | } |
| 139 | |
| 140 | rvalue = value; |
| 141 | |
| 142 | return value; |
| 143 | } |
| 144 | |
| 145 | Value *Variable::getBaseAddress() const |
| 146 | { |
| 147 | materialize(); |
| 148 | |
| 149 | return address; |
| 150 | } |
| 151 | |
| 152 | Value *Variable::getElementPointer(Value *index, bool unsignedIndex) const |
| 153 | { |
| 154 | return Nucleus::createGEP(getBaseAddress(), getType(), index, unsignedIndex); |
| 155 | } |
| 156 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 157 | void Variable::materializeAll() |
| 158 | { |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 159 | unmaterializedVariables->materializeAll(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 160 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 161 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 162 | void Variable::killUnmaterialized() |
| 163 | { |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 164 | unmaterializedVariables->clear(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 165 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 166 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 167 | // NOTE: Only 12 bits out of 16 of the |select| value are used. |
| 168 | // More specifically, the value should look like: |
| 169 | // |
| 170 | // msb lsb |
| 171 | // v v |
| 172 | // [.xxx|.yyy|.zzz|.www] where '.' means an ignored bit |
| 173 | // |
| 174 | // This format makes it easy to write calls with hexadecimal select values, |
| 175 | // since each hex digit is a separate swizzle index. |
| 176 | // |
| 177 | // For example: |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 178 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x0123 ) -> [a,b,c,d] |
| 179 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x4567 ) -> [e,f,g,h] |
| 180 | // 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] | 181 | // |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 182 | static Value *createShuffle4(Value *lhs, Value *rhs, uint16_t select) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 183 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 184 | std::vector<int> swizzle = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 185 | (select >> 12) & 0x07, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 186 | (select >> 8) & 0x07, |
| 187 | (select >> 4) & 0x07, |
| 188 | (select >> 0) & 0x07, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 189 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 190 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 191 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 192 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 193 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 194 | // NOTE: Only 8 bits out of 16 of the |select| value are used. |
| 195 | // More specifically, the value should look like: |
| 196 | // |
| 197 | // msb lsb |
| 198 | // v v |
| 199 | // [..xx|..yy|..zz|..ww] where '.' means an ignored bit |
| 200 | // |
| 201 | // This format makes it easy to write calls with hexadecimal select values, |
| 202 | // since each hex digit is a separate swizzle index. |
| 203 | // |
| 204 | // For example: |
| 205 | // createSwizzle4( [a,b,c,d], 0x0123 ) -> [a,b,c,d] |
| 206 | // createSwizzle4( [a,b,c,d], 0x0033 ) -> [a,a,d,d] |
| 207 | // |
| 208 | static Value *createSwizzle4(Value *val, uint16_t select) |
| 209 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 210 | std::vector<int> swizzle = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 211 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 212 | (select >> 8) & 0x03, |
| 213 | (select >> 4) & 0x03, |
| 214 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 215 | }; |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 216 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 217 | return Nucleus::createShuffleVector(val, val, swizzle); |
| 218 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 219 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 220 | static Value *createMask4(Value *lhs, Value *rhs, uint16_t select) |
| 221 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 222 | bool mask[4] = { false, false, false, false }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 223 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 224 | mask[(select >> 12) & 0x03] = true; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 225 | mask[(select >> 8) & 0x03] = true; |
| 226 | mask[(select >> 4) & 0x03] = true; |
| 227 | mask[(select >> 0) & 0x03] = true; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 228 | |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 229 | std::vector<int> swizzle = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 230 | mask[0] ? 4 : 0, |
| 231 | mask[1] ? 5 : 1, |
| 232 | mask[2] ? 6 : 2, |
| 233 | mask[3] ? 7 : 3, |
| 234 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 235 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 236 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 237 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 238 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 239 | Bool::Bool(Argument<Bool> argument) |
| 240 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 241 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 242 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 243 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 244 | Bool::Bool(bool x) |
| 245 | { |
| 246 | storeValue(Nucleus::createConstantBool(x)); |
| 247 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 248 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 249 | Bool::Bool(RValue<Bool> rhs) |
| 250 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 251 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 252 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 253 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 254 | Bool::Bool(const Bool &rhs) |
| 255 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 256 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 257 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 258 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 259 | Bool::Bool(const Reference<Bool> &rhs) |
| 260 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 261 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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 | RValue<Bool> Bool::operator=(RValue<Bool> rhs) |
| 265 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 266 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 267 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 268 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 269 | RValue<Bool> Bool::operator=(const Bool &rhs) |
| 270 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 271 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 272 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 273 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 274 | RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) |
| 275 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 276 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 277 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 278 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 279 | RValue<Bool> operator!(RValue<Bool> val) |
| 280 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 281 | return RValue<Bool>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 282 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 283 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 284 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) |
| 285 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 286 | return RValue<Bool>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 287 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 288 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 289 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) |
| 290 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 291 | return RValue<Bool>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 292 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 293 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 294 | RValue<Bool> operator!=(RValue<Bool> lhs, RValue<Bool> rhs) |
| 295 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 296 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 297 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 298 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 299 | RValue<Bool> operator==(RValue<Bool> lhs, RValue<Bool> rhs) |
| 300 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 301 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 302 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 303 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 304 | Byte::Byte(Argument<Byte> argument) |
| 305 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 306 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 307 | } |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 308 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 309 | Byte::Byte(RValue<Int> cast) |
| 310 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 311 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 312 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 313 | storeValue(integer); |
| 314 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 315 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 316 | Byte::Byte(RValue<UInt> cast) |
| 317 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 318 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 319 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 320 | storeValue(integer); |
| 321 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 322 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 323 | Byte::Byte(RValue<UShort> cast) |
| 324 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 325 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
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 | storeValue(integer); |
| 328 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 329 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 330 | Byte::Byte(int x) |
| 331 | { |
| 332 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
| 333 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 334 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 335 | Byte::Byte(unsigned char x) |
| 336 | { |
| 337 | storeValue(Nucleus::createConstantByte(x)); |
| 338 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 339 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 340 | Byte::Byte(RValue<Byte> rhs) |
| 341 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 342 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 343 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 344 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 345 | Byte::Byte(const Byte &rhs) |
| 346 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 347 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 348 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 349 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 350 | Byte::Byte(const Reference<Byte> &rhs) |
| 351 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 352 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 353 | } |
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 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) |
| 356 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 357 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 358 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 359 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 360 | RValue<Byte> Byte::operator=(const Byte &rhs) |
| 361 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 362 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 363 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 364 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 365 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) |
| 366 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 367 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 368 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 369 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 370 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
| 371 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 372 | return RValue<Byte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 373 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 374 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 375 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
| 376 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 377 | return RValue<Byte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 378 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 379 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 380 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
| 381 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 382 | return RValue<Byte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 383 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 384 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 385 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
| 386 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 387 | return RValue<Byte>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 388 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 389 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 390 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
| 391 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 392 | return RValue<Byte>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 393 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 394 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 395 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
| 396 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 397 | return RValue<Byte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 398 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 399 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 400 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
| 401 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 402 | return RValue<Byte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 403 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 404 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 405 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
| 406 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 407 | return RValue<Byte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 408 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 409 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 410 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 411 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 412 | return RValue<Byte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 413 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 414 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 415 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 416 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 417 | return RValue<Byte>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 418 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 419 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 420 | RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs) |
| 421 | { |
| 422 | return lhs = lhs + rhs; |
| 423 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 424 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 425 | RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs) |
| 426 | { |
| 427 | return lhs = lhs - rhs; |
| 428 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 429 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 430 | RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs) |
| 431 | { |
| 432 | return lhs = lhs * rhs; |
| 433 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 434 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 435 | RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs) |
| 436 | { |
| 437 | return lhs = lhs / rhs; |
| 438 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 439 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 440 | RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs) |
| 441 | { |
| 442 | return lhs = lhs % rhs; |
| 443 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 444 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 445 | RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs) |
| 446 | { |
| 447 | return lhs = lhs & rhs; |
| 448 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 449 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 450 | RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs) |
| 451 | { |
| 452 | return lhs = lhs | rhs; |
| 453 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 454 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 455 | RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs) |
| 456 | { |
| 457 | return lhs = lhs ^ rhs; |
| 458 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 459 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 460 | RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs) |
| 461 | { |
| 462 | return lhs = lhs << rhs; |
| 463 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 464 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 465 | RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs) |
| 466 | { |
| 467 | return lhs = lhs >> rhs; |
| 468 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 469 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 470 | RValue<Byte> operator+(RValue<Byte> val) |
| 471 | { |
| 472 | return val; |
| 473 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 474 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 475 | RValue<Byte> operator-(RValue<Byte> val) |
| 476 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 477 | return RValue<Byte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 478 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 479 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 480 | RValue<Byte> operator~(RValue<Byte> val) |
| 481 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 482 | return RValue<Byte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 483 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 484 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 485 | RValue<Byte> operator++(Byte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 486 | { |
| 487 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 488 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 489 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 490 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 491 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 492 | return res; |
| 493 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 494 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 495 | const Byte &operator++(Byte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 496 | { |
| 497 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 498 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 499 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 500 | return val; |
| 501 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 502 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 503 | RValue<Byte> operator--(Byte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 504 | { |
| 505 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 506 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 507 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 508 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 509 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 510 | return res; |
| 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 | const Byte &operator--(Byte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 514 | { |
| 515 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 516 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 517 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 518 | return val; |
| 519 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 520 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 521 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 522 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 523 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 524 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 525 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 526 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 527 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 528 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 529 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 530 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 531 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 532 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 533 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 534 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 535 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 536 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 537 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 538 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 539 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 540 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 541 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 542 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 543 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 544 | } |
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 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
| 547 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 548 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 549 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 550 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 551 | SByte::SByte(Argument<SByte> argument) |
| 552 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 553 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 554 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 555 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 556 | SByte::SByte(RValue<Int> cast) |
| 557 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 558 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 559 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 560 | storeValue(integer); |
| 561 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 562 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 563 | SByte::SByte(RValue<Short> cast) |
| 564 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 565 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 566 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 567 | storeValue(integer); |
| 568 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 569 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 570 | SByte::SByte(signed char x) |
| 571 | { |
| 572 | storeValue(Nucleus::createConstantByte(x)); |
| 573 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 574 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 575 | SByte::SByte(RValue<SByte> rhs) |
| 576 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 577 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 578 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 579 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 580 | SByte::SByte(const SByte &rhs) |
| 581 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 582 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 583 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 584 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 585 | SByte::SByte(const Reference<SByte> &rhs) |
| 586 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 587 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 588 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 589 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 590 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) |
| 591 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 592 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 593 | } |
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 | RValue<SByte> SByte::operator=(const SByte &rhs) |
| 596 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 597 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 598 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 599 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 600 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) |
| 601 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 602 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 603 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 604 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 605 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
| 606 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 607 | return RValue<SByte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 608 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 609 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 610 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
| 611 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 612 | return RValue<SByte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 613 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 614 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 615 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
| 616 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 617 | return RValue<SByte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 618 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 619 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 620 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
| 621 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 622 | return RValue<SByte>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 623 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 624 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 625 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) |
| 626 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 627 | return RValue<SByte>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 628 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 629 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 630 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) |
| 631 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 632 | return RValue<SByte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 633 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 634 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 635 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) |
| 636 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 637 | return RValue<SByte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 638 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 639 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 640 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) |
| 641 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 642 | return RValue<SByte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 643 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 644 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 645 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 646 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 647 | return RValue<SByte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 648 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 649 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 650 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 651 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 652 | return RValue<SByte>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 653 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 654 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 655 | RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs) |
| 656 | { |
| 657 | return lhs = lhs + rhs; |
| 658 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 659 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 660 | RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs) |
| 661 | { |
| 662 | return lhs = lhs - rhs; |
| 663 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 664 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 665 | RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs) |
| 666 | { |
| 667 | return lhs = lhs * rhs; |
| 668 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 669 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 670 | RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs) |
| 671 | { |
| 672 | return lhs = lhs / rhs; |
| 673 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 674 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 675 | RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs) |
| 676 | { |
| 677 | return lhs = lhs % rhs; |
| 678 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 679 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 680 | RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs) |
| 681 | { |
| 682 | return lhs = lhs & rhs; |
| 683 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 684 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 685 | RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs) |
| 686 | { |
| 687 | return lhs = lhs | rhs; |
| 688 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 689 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 690 | RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs) |
| 691 | { |
| 692 | return lhs = lhs ^ rhs; |
| 693 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 694 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 695 | RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs) |
| 696 | { |
| 697 | return lhs = lhs << rhs; |
| 698 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 699 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 700 | RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs) |
| 701 | { |
| 702 | return lhs = lhs >> rhs; |
| 703 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 704 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 705 | RValue<SByte> operator+(RValue<SByte> val) |
| 706 | { |
| 707 | return val; |
| 708 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 709 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 710 | RValue<SByte> operator-(RValue<SByte> val) |
| 711 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 712 | return RValue<SByte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 713 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 714 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 715 | RValue<SByte> operator~(RValue<SByte> val) |
| 716 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 717 | return RValue<SByte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 718 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 719 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 720 | RValue<SByte> operator++(SByte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 721 | { |
| 722 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 723 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 724 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 725 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 726 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 727 | return res; |
| 728 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 729 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 730 | const SByte &operator++(SByte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 731 | { |
| 732 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 733 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 734 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 735 | return val; |
| 736 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 737 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 738 | RValue<SByte> operator--(SByte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 739 | { |
| 740 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 741 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 742 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 743 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 744 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 745 | return res; |
| 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 | const SByte &operator--(SByte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 749 | { |
| 750 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 751 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 752 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 753 | return val; |
| 754 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 755 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 756 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 757 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 758 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 759 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 760 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 761 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 762 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 763 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 764 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 765 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 766 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 767 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 768 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 769 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 770 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 771 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 772 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 773 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 774 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 775 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 776 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 777 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 778 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 779 | } |
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 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) |
| 782 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 783 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 784 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 785 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 786 | Short::Short(Argument<Short> argument) |
| 787 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 788 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 789 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 790 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 791 | Short::Short(RValue<Int> cast) |
| 792 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 793 | Value *integer = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 794 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 795 | storeValue(integer); |
| 796 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 797 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 798 | Short::Short(short x) |
| 799 | { |
| 800 | storeValue(Nucleus::createConstantShort(x)); |
| 801 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 802 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 803 | Short::Short(RValue<Short> rhs) |
| 804 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 805 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 806 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 807 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 808 | Short::Short(const Short &rhs) |
| 809 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 810 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 811 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 812 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 813 | Short::Short(const Reference<Short> &rhs) |
| 814 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 815 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 816 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 817 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 818 | RValue<Short> Short::operator=(RValue<Short> rhs) |
| 819 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 820 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 821 | } |
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 | RValue<Short> Short::operator=(const Short &rhs) |
| 824 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 825 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 826 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 827 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 828 | RValue<Short> Short::operator=(const Reference<Short> &rhs) |
| 829 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 830 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 831 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 832 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 833 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
| 834 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 835 | return RValue<Short>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 836 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 837 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 838 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
| 839 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 840 | return RValue<Short>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 841 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 842 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 843 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
| 844 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 845 | return RValue<Short>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 846 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 847 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 848 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
| 849 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 850 | return RValue<Short>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 851 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 852 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 853 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) |
| 854 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 855 | return RValue<Short>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 856 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 857 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 858 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) |
| 859 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 860 | return RValue<Short>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 861 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 862 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 863 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) |
| 864 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 865 | return RValue<Short>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 866 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 867 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 868 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) |
| 869 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 870 | return RValue<Short>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 871 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 872 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 873 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) |
| 874 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 875 | return RValue<Short>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 876 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 877 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 878 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) |
| 879 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 880 | return RValue<Short>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 881 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 882 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 883 | RValue<Short> operator+=(Short &lhs, RValue<Short> rhs) |
| 884 | { |
| 885 | return lhs = lhs + rhs; |
| 886 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 887 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 888 | RValue<Short> operator-=(Short &lhs, RValue<Short> rhs) |
| 889 | { |
| 890 | return lhs = lhs - rhs; |
| 891 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 892 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 893 | RValue<Short> operator*=(Short &lhs, RValue<Short> rhs) |
| 894 | { |
| 895 | return lhs = lhs * rhs; |
| 896 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 897 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 898 | RValue<Short> operator/=(Short &lhs, RValue<Short> rhs) |
| 899 | { |
| 900 | return lhs = lhs / rhs; |
| 901 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 902 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 903 | RValue<Short> operator%=(Short &lhs, RValue<Short> rhs) |
| 904 | { |
| 905 | return lhs = lhs % rhs; |
| 906 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 907 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 908 | RValue<Short> operator&=(Short &lhs, RValue<Short> rhs) |
| 909 | { |
| 910 | return lhs = lhs & rhs; |
| 911 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 912 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 913 | RValue<Short> operator|=(Short &lhs, RValue<Short> rhs) |
| 914 | { |
| 915 | return lhs = lhs | rhs; |
| 916 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 917 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 918 | RValue<Short> operator^=(Short &lhs, RValue<Short> rhs) |
| 919 | { |
| 920 | return lhs = lhs ^ rhs; |
| 921 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 922 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 923 | RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs) |
| 924 | { |
| 925 | return lhs = lhs << rhs; |
| 926 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 927 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 928 | RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs) |
| 929 | { |
| 930 | return lhs = lhs >> rhs; |
| 931 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 932 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 933 | RValue<Short> operator+(RValue<Short> val) |
| 934 | { |
| 935 | return val; |
| 936 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 937 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 938 | RValue<Short> operator-(RValue<Short> val) |
| 939 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 940 | return RValue<Short>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 941 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 942 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 943 | RValue<Short> operator~(RValue<Short> val) |
| 944 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 945 | return RValue<Short>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 946 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 947 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 948 | RValue<Short> operator++(Short &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 949 | { |
| 950 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 951 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 952 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 953 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 954 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 955 | return res; |
| 956 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 957 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 958 | const Short &operator++(Short &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 959 | { |
| 960 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 961 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 962 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 963 | return val; |
| 964 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 965 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 966 | RValue<Short> operator--(Short &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 967 | { |
| 968 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 969 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 970 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 971 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 972 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 973 | return res; |
| 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 | const Short &operator--(Short &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 977 | { |
| 978 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 979 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 980 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 981 | return val; |
| 982 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 983 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 984 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
| 985 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 986 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 987 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 988 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 989 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
| 990 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 991 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 992 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 993 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 994 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
| 995 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 996 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 997 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 998 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 999 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
| 1000 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1001 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1002 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1003 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1004 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) |
| 1005 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1006 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1007 | } |
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 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) |
| 1010 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1011 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1012 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1013 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1014 | UShort::UShort(Argument<UShort> argument) |
| 1015 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1016 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1017 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1018 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1019 | UShort::UShort(RValue<UInt> cast) |
| 1020 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1021 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1022 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1023 | storeValue(integer); |
| 1024 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1025 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1026 | UShort::UShort(RValue<Int> cast) |
| 1027 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1028 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1029 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1030 | storeValue(integer); |
| 1031 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1032 | |
Jason Macnak | 341ad7e | 2022-03-16 18:17:57 -0700 | [diff] [blame] | 1033 | UShort::UShort(RValue<Byte> cast) |
| 1034 | { |
| 1035 | Value *integer = Nucleus::createZExt(cast.value(), UShort::type()); |
| 1036 | |
| 1037 | storeValue(integer); |
| 1038 | } |
| 1039 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1040 | UShort::UShort(unsigned short x) |
| 1041 | { |
| 1042 | storeValue(Nucleus::createConstantShort(x)); |
| 1043 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1044 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1045 | UShort::UShort(RValue<UShort> rhs) |
| 1046 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1047 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1048 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1049 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1050 | UShort::UShort(const UShort &rhs) |
| 1051 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1052 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1053 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1054 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1055 | UShort::UShort(const Reference<UShort> &rhs) |
| 1056 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1057 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1058 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1059 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1060 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) |
| 1061 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1062 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1063 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1064 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1065 | RValue<UShort> UShort::operator=(const UShort &rhs) |
| 1066 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1067 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1068 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1069 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1070 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) |
| 1071 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1072 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1073 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1074 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1075 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1076 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1077 | return RValue<UShort>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1078 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1079 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1080 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1081 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1082 | return RValue<UShort>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1083 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1084 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1085 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1086 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1087 | return RValue<UShort>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1088 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1089 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1090 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1091 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1092 | return RValue<UShort>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1093 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1094 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1095 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1096 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1097 | return RValue<UShort>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1098 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1099 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1100 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1101 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1102 | return RValue<UShort>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1103 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1104 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1105 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1106 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1107 | return RValue<UShort>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1108 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1109 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1110 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1111 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1112 | return RValue<UShort>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1113 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1114 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1115 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1116 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1117 | return RValue<UShort>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1118 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1119 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1120 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1121 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1122 | return RValue<UShort>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1123 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1124 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1125 | RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs) |
| 1126 | { |
| 1127 | return lhs = lhs + rhs; |
| 1128 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1129 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1130 | RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs) |
| 1131 | { |
| 1132 | return lhs = lhs - rhs; |
| 1133 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1134 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1135 | RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs) |
| 1136 | { |
| 1137 | return lhs = lhs * rhs; |
| 1138 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1139 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1140 | RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs) |
| 1141 | { |
| 1142 | return lhs = lhs / rhs; |
| 1143 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1144 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1145 | RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs) |
| 1146 | { |
| 1147 | return lhs = lhs % rhs; |
| 1148 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1149 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1150 | RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs) |
| 1151 | { |
| 1152 | return lhs = lhs & rhs; |
| 1153 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1154 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1155 | RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs) |
| 1156 | { |
| 1157 | return lhs = lhs | rhs; |
| 1158 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1159 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1160 | RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs) |
| 1161 | { |
| 1162 | return lhs = lhs ^ rhs; |
| 1163 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1164 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1165 | RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs) |
| 1166 | { |
| 1167 | return lhs = lhs << rhs; |
| 1168 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1169 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1170 | RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs) |
| 1171 | { |
| 1172 | return lhs = lhs >> rhs; |
| 1173 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1174 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1175 | RValue<UShort> operator+(RValue<UShort> val) |
| 1176 | { |
| 1177 | return val; |
| 1178 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1179 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1180 | RValue<UShort> operator-(RValue<UShort> val) |
| 1181 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1182 | return RValue<UShort>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1183 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1184 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1185 | RValue<UShort> operator~(RValue<UShort> val) |
| 1186 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1187 | return RValue<UShort>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1188 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1189 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1190 | RValue<UShort> operator++(UShort &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1191 | { |
| 1192 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1193 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1194 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1195 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1196 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1197 | return res; |
| 1198 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1199 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1200 | const UShort &operator++(UShort &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1201 | { |
| 1202 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1203 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1204 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1205 | return val; |
| 1206 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1207 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1208 | RValue<UShort> operator--(UShort &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1209 | { |
| 1210 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1211 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1212 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1213 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1214 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1215 | return res; |
| 1216 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1217 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1218 | const UShort &operator--(UShort &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1219 | { |
| 1220 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1221 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1222 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1223 | return val; |
| 1224 | } |
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 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1227 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1228 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1229 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1230 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1231 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1232 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1233 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1234 | } |
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 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1237 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1238 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1239 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1240 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1241 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1242 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1243 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1244 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1245 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1246 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1247 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1248 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1249 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1251 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1252 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1253 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1254 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1255 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1256 | Byte4::Byte4(RValue<Byte8> cast) |
| 1257 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1258 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1259 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1260 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1261 | Byte4::Byte4(RValue<UShort4> cast) |
| 1262 | { |
| 1263 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1264 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1265 | } |
| 1266 | |
| 1267 | Byte4::Byte4(RValue<Short4> cast) |
| 1268 | { |
| 1269 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1270 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1271 | } |
| 1272 | |
| 1273 | Byte4::Byte4(RValue<UInt4> cast) |
| 1274 | { |
| 1275 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1276 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1277 | } |
| 1278 | |
| 1279 | Byte4::Byte4(RValue<Int4> cast) |
| 1280 | { |
| 1281 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1282 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1283 | } |
| 1284 | |
| 1285 | Byte4::Byte4(RValue<Byte4> rhs) |
| 1286 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1287 | store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | Byte4::Byte4(const Byte4 &rhs) |
| 1291 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1292 | store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1293 | } |
| 1294 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1295 | Byte4::Byte4(const Reference<Byte4> &rhs) |
| 1296 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1297 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1298 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1299 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1300 | RValue<Byte4> Byte4::operator=(RValue<Byte4> rhs) |
| 1301 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1302 | return store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | RValue<Byte4> Byte4::operator=(const Byte4 &rhs) |
| 1306 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1307 | return store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1308 | } |
| 1309 | |
Jason Macnak | 341ad7e | 2022-03-16 18:17:57 -0700 | [diff] [blame] | 1310 | RValue<Byte4> Insert(RValue<Byte4> val, RValue<Byte> element, int i) |
| 1311 | { |
| 1312 | return RValue<Byte4>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
| 1313 | } |
| 1314 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1315 | 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) |
| 1316 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1317 | std::vector<int64_t> constantVector = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1318 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
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 | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1321 | Byte8::Byte8(RValue<Byte8> rhs) |
| 1322 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1323 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1324 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1325 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1326 | Byte8::Byte8(const Byte8 &rhs) |
| 1327 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1328 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1329 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1330 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1331 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 1332 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1333 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1334 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1335 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1336 | RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) |
| 1337 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1338 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1339 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1340 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1341 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) |
| 1342 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1343 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1344 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1345 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1346 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) |
| 1347 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1348 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1349 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1350 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1351 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1352 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1353 | return RValue<Byte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1354 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1355 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1356 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1357 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1358 | return RValue<Byte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1359 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1360 | |
| 1361 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1362 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1363 | // return RValue<Byte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1364 | // } |
| 1365 | |
| 1366 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1367 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1368 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1369 | // } |
| 1370 | |
| 1371 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1372 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1373 | // return RValue<Byte8>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1374 | // } |
| 1375 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1376 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1377 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1378 | return RValue<Byte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1379 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1380 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1381 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1382 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1383 | return RValue<Byte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1384 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1385 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1386 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1387 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1388 | return RValue<Byte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1389 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1390 | |
| 1391 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
| 1392 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1393 | // return RValue<Byte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1394 | // } |
| 1395 | |
| 1396 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
| 1397 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1398 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1399 | // } |
| 1400 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1401 | RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1402 | { |
| 1403 | return lhs = lhs + rhs; |
| 1404 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1405 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1406 | RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1407 | { |
| 1408 | return lhs = lhs - rhs; |
| 1409 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1410 | |
| 1411 | // RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1412 | // { |
| 1413 | // return lhs = lhs * rhs; |
| 1414 | // } |
| 1415 | |
| 1416 | // RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1417 | // { |
| 1418 | // return lhs = lhs / rhs; |
| 1419 | // } |
| 1420 | |
| 1421 | // RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1422 | // { |
| 1423 | // return lhs = lhs % rhs; |
| 1424 | // } |
| 1425 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1426 | RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1427 | { |
| 1428 | return lhs = lhs & rhs; |
| 1429 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1430 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1431 | RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1432 | { |
| 1433 | return lhs = lhs | rhs; |
| 1434 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1435 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1436 | RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1437 | { |
| 1438 | return lhs = lhs ^ rhs; |
| 1439 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1440 | |
| 1441 | // RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1442 | // { |
| 1443 | // return lhs = lhs << rhs; |
| 1444 | // } |
| 1445 | |
| 1446 | // RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1447 | // { |
| 1448 | // return lhs = lhs >> rhs; |
| 1449 | // } |
| 1450 | |
| 1451 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 1452 | // { |
| 1453 | // return val; |
| 1454 | // } |
| 1455 | |
| 1456 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 1457 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1458 | // return RValue<Byte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1459 | // } |
| 1460 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1461 | RValue<Byte8> operator~(RValue<Byte8> val) |
| 1462 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1463 | return RValue<Byte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1464 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1465 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1466 | RValue<Byte8> Swizzle(RValue<Byte8> x, uint32_t select) |
| 1467 | { |
| 1468 | // Real type is v16i8 |
| 1469 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1470 | std::vector<int> shuffle = { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1471 | static_cast<int>((select >> 28) & 0x07), |
| 1472 | static_cast<int>((select >> 24) & 0x07), |
| 1473 | static_cast<int>((select >> 20) & 0x07), |
| 1474 | static_cast<int>((select >> 16) & 0x07), |
| 1475 | static_cast<int>((select >> 12) & 0x07), |
| 1476 | static_cast<int>((select >> 8) & 0x07), |
| 1477 | static_cast<int>((select >> 4) & 0x07), |
| 1478 | static_cast<int>((select >> 0) & 0x07), |
| 1479 | static_cast<int>((select >> 28) & 0x07), |
| 1480 | static_cast<int>((select >> 24) & 0x07), |
| 1481 | static_cast<int>((select >> 20) & 0x07), |
| 1482 | static_cast<int>((select >> 16) & 0x07), |
| 1483 | static_cast<int>((select >> 12) & 0x07), |
| 1484 | static_cast<int>((select >> 8) & 0x07), |
| 1485 | static_cast<int>((select >> 4) & 0x07), |
| 1486 | static_cast<int>((select >> 0) & 0x07), |
| 1487 | }; |
| 1488 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1489 | return As<Byte8>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1490 | } |
| 1491 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1492 | RValue<Short4> Unpack(RValue<Byte4> x) |
| 1493 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1494 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1495 | std::vector<int> shuffle = { 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] | 1496 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1497 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1498 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1499 | RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y) |
| 1500 | { |
| 1501 | return UnpackLow(As<Byte8>(x), As<Byte8>(y)); |
| 1502 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1503 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1504 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 1505 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1506 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1507 | std::vector<int> shuffle = { 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] | 1508 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1509 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1510 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1511 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
| 1512 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1513 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1514 | std::vector<int> shuffle = { 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] | 1515 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1516 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1517 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1518 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1519 | 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) |
| 1520 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1521 | std::vector<int64_t> constantVector = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1522 | Value *vector = Nucleus::createConstantVector(constantVector, type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1523 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1524 | storeValue(Nucleus::createBitCast(vector, type())); |
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 | SByte8::SByte8(RValue<SByte8> rhs) |
| 1528 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1529 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1530 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1531 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1532 | SByte8::SByte8(const SByte8 &rhs) |
| 1533 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1534 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1535 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1536 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1537 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 1538 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1539 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1540 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1541 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1542 | RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) |
| 1543 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1544 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1545 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1546 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1547 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) |
| 1548 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1549 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1550 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1551 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1552 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) |
| 1553 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1554 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1555 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1556 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1557 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1558 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1559 | return RValue<SByte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1560 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1561 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1562 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1563 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1564 | return RValue<SByte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1565 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1566 | |
| 1567 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1568 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1569 | // return RValue<SByte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1570 | // } |
| 1571 | |
| 1572 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1573 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1574 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1575 | // } |
| 1576 | |
| 1577 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1578 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1579 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1580 | // } |
| 1581 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1582 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1583 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1584 | return RValue<SByte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1585 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1586 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1587 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1588 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1589 | return RValue<SByte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1590 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1591 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1592 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1593 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1594 | return RValue<SByte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1595 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1596 | |
| 1597 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
| 1598 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1599 | // return RValue<SByte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1600 | // } |
| 1601 | |
| 1602 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
| 1603 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1604 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1605 | // } |
| 1606 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1607 | RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1608 | { |
| 1609 | return lhs = lhs + rhs; |
| 1610 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1611 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1612 | RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1613 | { |
| 1614 | return lhs = lhs - rhs; |
| 1615 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1616 | |
| 1617 | // RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1618 | // { |
| 1619 | // return lhs = lhs * rhs; |
| 1620 | // } |
| 1621 | |
| 1622 | // RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1623 | // { |
| 1624 | // return lhs = lhs / rhs; |
| 1625 | // } |
| 1626 | |
| 1627 | // RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1628 | // { |
| 1629 | // return lhs = lhs % rhs; |
| 1630 | // } |
| 1631 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1632 | RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1633 | { |
| 1634 | return lhs = lhs & rhs; |
| 1635 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1636 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1637 | RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1638 | { |
| 1639 | return lhs = lhs | rhs; |
| 1640 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1641 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1642 | RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1643 | { |
| 1644 | return lhs = lhs ^ rhs; |
| 1645 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1646 | |
| 1647 | // RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1648 | // { |
| 1649 | // return lhs = lhs << rhs; |
| 1650 | // } |
| 1651 | |
| 1652 | // RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1653 | // { |
| 1654 | // return lhs = lhs >> rhs; |
| 1655 | // } |
| 1656 | |
| 1657 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 1658 | // { |
| 1659 | // return val; |
| 1660 | // } |
| 1661 | |
| 1662 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 1663 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1664 | // return RValue<SByte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1665 | // } |
| 1666 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1667 | RValue<SByte8> operator~(RValue<SByte8> val) |
| 1668 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1669 | return RValue<SByte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1670 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1671 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1672 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
| 1673 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1674 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1675 | std::vector<int> shuffle = { 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] | 1676 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1677 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1678 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1679 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
| 1680 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1681 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1682 | std::vector<int> shuffle = { 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] | 1683 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1684 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1685 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1686 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1687 | Byte16::Byte16(RValue<Byte16> rhs) |
| 1688 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1689 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1690 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1691 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1692 | Byte16::Byte16(const Byte16 &rhs) |
| 1693 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1694 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1695 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1696 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1697 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 1698 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1699 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1700 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1701 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1702 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) |
| 1703 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1704 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1705 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1706 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1707 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) |
| 1708 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1709 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1710 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1711 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1712 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) |
| 1713 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1714 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1715 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1716 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1717 | RValue<Byte16> Swizzle(RValue<Byte16> x, uint64_t select) |
| 1718 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1719 | std::vector<int> shuffle = { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1720 | static_cast<int>((select >> 60) & 0x0F), |
| 1721 | static_cast<int>((select >> 56) & 0x0F), |
| 1722 | static_cast<int>((select >> 52) & 0x0F), |
| 1723 | static_cast<int>((select >> 48) & 0x0F), |
| 1724 | static_cast<int>((select >> 44) & 0x0F), |
| 1725 | static_cast<int>((select >> 40) & 0x0F), |
| 1726 | static_cast<int>((select >> 36) & 0x0F), |
| 1727 | static_cast<int>((select >> 32) & 0x0F), |
| 1728 | static_cast<int>((select >> 28) & 0x0F), |
| 1729 | static_cast<int>((select >> 24) & 0x0F), |
| 1730 | static_cast<int>((select >> 20) & 0x0F), |
| 1731 | static_cast<int>((select >> 16) & 0x0F), |
| 1732 | static_cast<int>((select >> 12) & 0x0F), |
| 1733 | static_cast<int>((select >> 8) & 0x0F), |
| 1734 | static_cast<int>((select >> 4) & 0x0F), |
| 1735 | static_cast<int>((select >> 0) & 0x0F), |
| 1736 | }; |
| 1737 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1738 | return As<Byte16>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1739 | } |
| 1740 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1741 | Short2::Short2(RValue<Short4> cast) |
| 1742 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1743 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1744 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1745 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1746 | UShort2::UShort2(RValue<UShort4> cast) |
| 1747 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1748 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1749 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1750 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1751 | Short4::Short4(RValue<Int> cast) |
| 1752 | { |
| 1753 | Value *vector = loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1754 | Value *element = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1755 | Value *insert = Nucleus::createInsertElement(vector, element, 0); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1756 | Value *swizzle = Swizzle(RValue<Short4>(insert), 0x0000).value(); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1757 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1758 | storeValue(swizzle); |
| 1759 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1760 | |
Nicolas Capens | 7119686 | 2022-01-06 21:31:57 -0500 | [diff] [blame] | 1761 | Short4::Short4(RValue<UInt4> cast) |
| 1762 | : Short4(As<Int4>(cast)) |
| 1763 | { |
| 1764 | } |
| 1765 | |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1766 | // Short4::Short4(RValue<Float> cast) |
| 1767 | // { |
| 1768 | // } |
| 1769 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1770 | Short4::Short4(short xyzw) |
| 1771 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1772 | std::vector<int64_t> constantVector = { xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1773 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1774 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1775 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1776 | Short4::Short4(short x, short y, short z, short w) |
| 1777 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1778 | std::vector<int64_t> constantVector = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1779 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1780 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1781 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1782 | Short4::Short4(RValue<Short4> rhs) |
| 1783 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1784 | store(rhs); |
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(const Short4 &rhs) |
| 1788 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1789 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1790 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1791 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1792 | Short4::Short4(const Reference<Short4> &rhs) |
| 1793 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1794 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1795 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1796 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1797 | Short4::Short4(RValue<UShort4> rhs) |
| 1798 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1799 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1800 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1801 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1802 | Short4::Short4(const UShort4 &rhs) |
| 1803 | { |
| 1804 | storeValue(rhs.loadValue()); |
| 1805 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1806 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1807 | Short4::Short4(const Reference<UShort4> &rhs) |
| 1808 | { |
| 1809 | storeValue(rhs.loadValue()); |
| 1810 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1811 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1812 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) |
| 1813 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1814 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1815 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1816 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1817 | RValue<Short4> Short4::operator=(const Short4 &rhs) |
| 1818 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1819 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1820 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1821 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1822 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) |
| 1823 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1824 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1825 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1826 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1827 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) |
| 1828 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1829 | return RValue<Short4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1830 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1831 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1832 | RValue<Short4> Short4::operator=(const UShort4 &rhs) |
| 1833 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1834 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1835 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1836 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1837 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) |
| 1838 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1839 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1840 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1841 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1842 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1843 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1844 | return RValue<Short4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1845 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1846 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1847 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1848 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1849 | return RValue<Short4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1850 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1851 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1852 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1853 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1854 | return RValue<Short4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1855 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1856 | |
| 1857 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1858 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1859 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1860 | // } |
| 1861 | |
| 1862 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1863 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1864 | // return RValue<Short4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1865 | // } |
| 1866 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1867 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1868 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1869 | return RValue<Short4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1870 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1871 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1872 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1873 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1874 | return RValue<Short4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1875 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1876 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1877 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1878 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1879 | return RValue<Short4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1880 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1881 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1882 | RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs) |
| 1883 | { |
| 1884 | return lhs = lhs + rhs; |
| 1885 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1886 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1887 | RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs) |
| 1888 | { |
| 1889 | return lhs = lhs - rhs; |
| 1890 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1891 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1892 | RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs) |
| 1893 | { |
| 1894 | return lhs = lhs * rhs; |
| 1895 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1896 | |
| 1897 | // RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs) |
| 1898 | // { |
| 1899 | // return lhs = lhs / rhs; |
| 1900 | // } |
| 1901 | |
| 1902 | // RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs) |
| 1903 | // { |
| 1904 | // return lhs = lhs % rhs; |
| 1905 | // } |
| 1906 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1907 | RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs) |
| 1908 | { |
| 1909 | return lhs = lhs & rhs; |
| 1910 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1911 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1912 | RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs) |
| 1913 | { |
| 1914 | return lhs = lhs | rhs; |
| 1915 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1916 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1917 | RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs) |
| 1918 | { |
| 1919 | return lhs = lhs ^ rhs; |
| 1920 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1921 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1922 | RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs) |
| 1923 | { |
| 1924 | return lhs = lhs << rhs; |
| 1925 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1926 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1927 | RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs) |
| 1928 | { |
| 1929 | return lhs = lhs >> rhs; |
| 1930 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1931 | |
| 1932 | // RValue<Short4> operator+(RValue<Short4> val) |
| 1933 | // { |
| 1934 | // return val; |
| 1935 | // } |
| 1936 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1937 | RValue<Short4> operator-(RValue<Short4> val) |
| 1938 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1939 | return RValue<Short4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1940 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1941 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1942 | RValue<Short4> operator~(RValue<Short4> val) |
| 1943 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1944 | return RValue<Short4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1945 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1946 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1947 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
| 1948 | { |
| 1949 | RValue<Int4> int4 = RoundInt(cast); |
| 1950 | return As<Short4>(PackSigned(int4, int4)); |
| 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<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
| 1954 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1955 | std::vector<int> shuffle = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1956 | return As<Int2>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1957 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1958 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1959 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
| 1960 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1961 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1962 | std::vector<int> shuffle = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1963 | auto lowHigh = RValue<Short8>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1964 | return As<Int2>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1965 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1966 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1967 | RValue<Short4> Swizzle(RValue<Short4> x, uint16_t select) |
| 1968 | { |
| 1969 | // Real type is v8i16 |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1970 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 1971 | std::vector<int> shuffle = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1972 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1973 | (select >> 8) & 0x03, |
| 1974 | (select >> 4) & 0x03, |
| 1975 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1976 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1977 | (select >> 8) & 0x03, |
| 1978 | (select >> 4) & 0x03, |
| 1979 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1980 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1981 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1982 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1983 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1984 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1985 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
| 1986 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1987 | return RValue<Short4>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1988 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1989 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1990 | RValue<Short> Extract(RValue<Short4> val, int i) |
| 1991 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1992 | return RValue<Short>(Nucleus::createExtractElement(val.value(), Short::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1993 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1994 | |
Nicolas Capens | 7119686 | 2022-01-06 21:31:57 -0500 | [diff] [blame] | 1995 | UShort4::UShort4(RValue<UInt4> cast) |
| 1996 | : UShort4(As<Int4>(cast)) |
| 1997 | { |
| 1998 | } |
| 1999 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2000 | UShort4::UShort4(RValue<Int4> cast) |
| 2001 | { |
| 2002 | *this = Short4(cast); |
| 2003 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2004 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2005 | UShort4::UShort4(unsigned short xyzw) |
| 2006 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2007 | std::vector<int64_t> constantVector = { xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2008 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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 x, unsigned short y, unsigned short z, unsigned short w) |
| 2012 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2013 | std::vector<int64_t> constantVector = { x, y, z, w }; |
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(RValue<UShort4> rhs) |
| 2018 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2019 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2020 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2021 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2022 | UShort4::UShort4(const UShort4 &rhs) |
| 2023 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2024 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2025 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2026 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2027 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 2028 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2029 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2030 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2031 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2032 | UShort4::UShort4(RValue<Short4> rhs) |
| 2033 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2034 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2035 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2036 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2037 | UShort4::UShort4(const Short4 &rhs) |
| 2038 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2039 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2040 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2041 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2042 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 2043 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2044 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2045 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2046 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2047 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) |
| 2048 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2049 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2050 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2051 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2052 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) |
| 2053 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2054 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2055 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2056 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2057 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) |
| 2058 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2059 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2060 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2061 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2062 | RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) |
| 2063 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2064 | return RValue<UShort4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2065 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2066 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2067 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) |
| 2068 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2069 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2070 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2071 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2072 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) |
| 2073 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2074 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2075 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2076 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2077 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2078 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2079 | return RValue<UShort4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2080 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2081 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2082 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2083 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2084 | return RValue<UShort4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2085 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2086 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2087 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2088 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2089 | return RValue<UShort4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2090 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2091 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2092 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2093 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2094 | return RValue<UShort4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2095 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2096 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2097 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2098 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2099 | return RValue<UShort4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2100 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2101 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2102 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2103 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2104 | return RValue<UShort4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2105 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2106 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2107 | RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs) |
| 2108 | { |
| 2109 | return lhs = lhs << rhs; |
| 2110 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2111 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2112 | RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs) |
| 2113 | { |
| 2114 | return lhs = lhs >> rhs; |
| 2115 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2116 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2117 | RValue<UShort4> operator~(RValue<UShort4> val) |
| 2118 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2119 | return RValue<UShort4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2120 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2121 | |
Jason Macnak | 0587e07 | 2022-02-11 16:49:02 -0800 | [diff] [blame] | 2122 | RValue<UShort4> Insert(RValue<UShort4> val, RValue<UShort> element, int i) |
| 2123 | { |
| 2124 | return RValue<UShort4>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
| 2125 | } |
| 2126 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2127 | Short8::Short8(short c) |
| 2128 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2129 | std::vector<int64_t> constantVector = { c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2130 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2131 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2132 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2133 | Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 2134 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2135 | std::vector<int64_t> constantVector = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2136 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2137 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2138 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2139 | Short8::Short8(RValue<Short8> rhs) |
| 2140 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2141 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2142 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2143 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2144 | Short8::Short8(const Reference<Short8> &rhs) |
| 2145 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2146 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2147 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2148 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2149 | Short8::Short8(RValue<Short4> lo, RValue<Short4> hi) |
| 2150 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2151 | std::vector<int> shuffle = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2152 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2153 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2154 | storeValue(packed); |
| 2155 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2156 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2157 | RValue<Short8> Short8::operator=(RValue<Short8> rhs) |
| 2158 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2159 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2160 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2161 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2162 | RValue<Short8> Short8::operator=(const Short8 &rhs) |
| 2163 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2164 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2165 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2166 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2167 | RValue<Short8> Short8::operator=(const Reference<Short8> &rhs) |
| 2168 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2169 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2170 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2171 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2172 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2173 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2174 | return RValue<Short8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2175 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2176 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2177 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2178 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2179 | return RValue<Short8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2180 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2181 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2182 | UShort8::UShort8(unsigned short c) |
| 2183 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2184 | std::vector<int64_t> constantVector = { c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2185 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2186 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2187 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2188 | 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) |
| 2189 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2190 | std::vector<int64_t> constantVector = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2191 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2192 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2193 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2194 | UShort8::UShort8(RValue<UShort8> rhs) |
| 2195 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2196 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2197 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2198 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2199 | UShort8::UShort8(const Reference<UShort8> &rhs) |
| 2200 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2201 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2202 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2203 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2204 | UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi) |
| 2205 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2206 | std::vector<int> shuffle = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2207 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2208 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2209 | storeValue(packed); |
| 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 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) |
| 2213 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2214 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2215 | } |
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 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) |
| 2218 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2219 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2220 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2221 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2222 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) |
| 2223 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2224 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2225 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2226 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2227 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2228 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2229 | return RValue<UShort8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2230 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2231 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2232 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2233 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2234 | return RValue<UShort8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2235 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2236 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2237 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2238 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2239 | return RValue<UShort8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2240 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2241 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2242 | RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs) |
| 2243 | { |
| 2244 | return lhs = lhs + rhs; |
| 2245 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2246 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2247 | RValue<UShort8> operator~(RValue<UShort8> val) |
| 2248 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2249 | return RValue<UShort8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2250 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2251 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2252 | RValue<UShort8> Swizzle(RValue<UShort8> x, uint32_t select) |
| 2253 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2254 | std::vector<int> swizzle = { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2255 | static_cast<int>((select >> 28) & 0x07), |
| 2256 | static_cast<int>((select >> 24) & 0x07), |
| 2257 | static_cast<int>((select >> 20) & 0x07), |
| 2258 | static_cast<int>((select >> 16) & 0x07), |
| 2259 | static_cast<int>((select >> 12) & 0x07), |
| 2260 | static_cast<int>((select >> 8) & 0x07), |
| 2261 | static_cast<int>((select >> 4) & 0x07), |
| 2262 | static_cast<int>((select >> 0) & 0x07), |
| 2263 | }; |
| 2264 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2265 | return RValue<UShort8>(Nucleus::createShuffleVector(x.value(), x.value(), swizzle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2266 | } |
| 2267 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2268 | Int::Int(Argument<Int> argument) |
| 2269 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2270 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2271 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2272 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2273 | Int::Int(RValue<Byte> cast) |
| 2274 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2275 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2276 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2277 | storeValue(integer); |
| 2278 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2279 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2280 | Int::Int(RValue<SByte> cast) |
| 2281 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2282 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2283 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2284 | storeValue(integer); |
| 2285 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2286 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2287 | Int::Int(RValue<Short> cast) |
| 2288 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2289 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2290 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2291 | storeValue(integer); |
| 2292 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2293 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2294 | Int::Int(RValue<UShort> cast) |
| 2295 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2296 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2297 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2298 | storeValue(integer); |
| 2299 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2300 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2301 | Int::Int(RValue<Int2> cast) |
| 2302 | { |
| 2303 | *this = Extract(cast, 0); |
| 2304 | } |
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 | Int::Int(RValue<Long> cast) |
| 2307 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2308 | Value *integer = Nucleus::createTrunc(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2309 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2310 | storeValue(integer); |
| 2311 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2312 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2313 | Int::Int(RValue<Float> cast) |
| 2314 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2315 | Value *integer = Nucleus::createFPToSI(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2316 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2317 | storeValue(integer); |
| 2318 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2319 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2320 | Int::Int(int x) |
| 2321 | { |
| 2322 | storeValue(Nucleus::createConstantInt(x)); |
| 2323 | } |
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 | Int::Int(RValue<Int> rhs) |
| 2326 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2327 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2328 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2329 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2330 | Int::Int(RValue<UInt> rhs) |
| 2331 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2332 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2333 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2334 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2335 | Int::Int(const Int &rhs) |
| 2336 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2337 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2338 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2339 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2340 | Int::Int(const Reference<Int> &rhs) |
| 2341 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2342 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2343 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2344 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2345 | Int::Int(const UInt &rhs) |
| 2346 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2347 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2348 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2349 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2350 | Int::Int(const Reference<UInt> &rhs) |
| 2351 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2352 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2353 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2354 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2355 | RValue<Int> Int::operator=(int rhs) |
| 2356 | { |
| 2357 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2358 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2359 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2360 | RValue<Int> Int::operator=(RValue<Int> rhs) |
| 2361 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2362 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2363 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2364 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2365 | RValue<Int> Int::operator=(RValue<UInt> rhs) |
| 2366 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2367 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2368 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2369 | return RValue<Int>(rhs); |
| 2370 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2371 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2372 | RValue<Int> Int::operator=(const Int &rhs) |
| 2373 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2374 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2375 | } |
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 | RValue<Int> Int::operator=(const Reference<Int> &rhs) |
| 2378 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2379 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2380 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2381 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2382 | RValue<Int> Int::operator=(const UInt &rhs) |
| 2383 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2384 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2385 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2386 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2387 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) |
| 2388 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2389 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2390 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2391 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2392 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) |
| 2393 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2394 | return RValue<Int>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2395 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2396 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2397 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) |
| 2398 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2399 | return RValue<Int>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2400 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2401 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2402 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) |
| 2403 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2404 | return RValue<Int>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2405 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2406 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2407 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
| 2408 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2409 | return RValue<Int>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2410 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2411 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2412 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
| 2413 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2414 | return RValue<Int>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2415 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2416 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2417 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
| 2418 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2419 | return RValue<Int>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2420 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2421 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2422 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
| 2423 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2424 | return RValue<Int>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2425 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2426 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2427 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
| 2428 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2429 | return RValue<Int>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2430 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2431 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2432 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
| 2433 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2434 | return RValue<Int>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2435 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2436 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2437 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
| 2438 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2439 | return RValue<Int>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2440 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2441 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2442 | RValue<Int> operator+=(Int &lhs, RValue<Int> rhs) |
| 2443 | { |
| 2444 | return lhs = lhs + rhs; |
| 2445 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2446 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2447 | RValue<Int> operator-=(Int &lhs, RValue<Int> rhs) |
| 2448 | { |
| 2449 | return lhs = lhs - rhs; |
| 2450 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2451 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2452 | RValue<Int> operator*=(Int &lhs, RValue<Int> rhs) |
| 2453 | { |
| 2454 | return lhs = lhs * rhs; |
| 2455 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2456 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2457 | RValue<Int> operator/=(Int &lhs, RValue<Int> rhs) |
| 2458 | { |
| 2459 | return lhs = lhs / rhs; |
| 2460 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2461 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2462 | RValue<Int> operator%=(Int &lhs, RValue<Int> rhs) |
| 2463 | { |
| 2464 | return lhs = lhs % rhs; |
| 2465 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2466 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2467 | RValue<Int> operator&=(Int &lhs, RValue<Int> rhs) |
| 2468 | { |
| 2469 | return lhs = lhs & rhs; |
| 2470 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2471 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2472 | RValue<Int> operator|=(Int &lhs, RValue<Int> rhs) |
| 2473 | { |
| 2474 | return lhs = lhs | rhs; |
| 2475 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2476 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2477 | RValue<Int> operator^=(Int &lhs, RValue<Int> rhs) |
| 2478 | { |
| 2479 | return lhs = lhs ^ rhs; |
| 2480 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2481 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2482 | RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs) |
| 2483 | { |
| 2484 | return lhs = lhs << rhs; |
| 2485 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2486 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2487 | RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs) |
| 2488 | { |
| 2489 | return lhs = lhs >> rhs; |
| 2490 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2491 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2492 | RValue<Int> operator+(RValue<Int> val) |
| 2493 | { |
| 2494 | return val; |
| 2495 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2496 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2497 | RValue<Int> operator-(RValue<Int> val) |
| 2498 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2499 | return RValue<Int>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2500 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2501 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2502 | RValue<Int> operator~(RValue<Int> val) |
| 2503 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2504 | return RValue<Int>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2505 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2506 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2507 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
| 2508 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2509 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2510 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2511 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2512 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
| 2513 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2514 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2515 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2516 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2517 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
| 2518 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2519 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2520 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2521 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2522 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
| 2523 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2524 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2525 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2526 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2527 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
| 2528 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2529 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2530 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2531 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2532 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
| 2533 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2534 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2535 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2536 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2537 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 2538 | { |
| 2539 | return IfThenElse(x > y, x, y); |
| 2540 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2541 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2542 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 2543 | { |
| 2544 | return IfThenElse(x < y, x, y); |
| 2545 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2546 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2547 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 2548 | { |
| 2549 | return Min(Max(x, min), max); |
| 2550 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2551 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2552 | Long::Long(RValue<Int> cast) |
| 2553 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2554 | Value *integer = Nucleus::createSExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2555 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2556 | storeValue(integer); |
| 2557 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2558 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2559 | Long::Long(RValue<UInt> cast) |
| 2560 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2561 | Value *integer = Nucleus::createZExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2562 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2563 | storeValue(integer); |
| 2564 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2565 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2566 | Long::Long(RValue<Long> rhs) |
| 2567 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2568 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2569 | } |
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 | RValue<Long> Long::operator=(int64_t rhs) |
| 2572 | { |
| 2573 | return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs))); |
| 2574 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2575 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2576 | RValue<Long> Long::operator=(RValue<Long> rhs) |
| 2577 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2578 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2579 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2580 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2581 | RValue<Long> Long::operator=(const Long &rhs) |
| 2582 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2583 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2584 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2585 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2586 | RValue<Long> Long::operator=(const Reference<Long> &rhs) |
| 2587 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2588 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2589 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2590 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2591 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
| 2592 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2593 | return RValue<Long>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2594 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2595 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2596 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
| 2597 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2598 | return RValue<Long>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2599 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2600 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2601 | RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs) |
| 2602 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2603 | return RValue<Long>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2604 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2605 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2606 | RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs) |
| 2607 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2608 | return RValue<Long>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2609 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2610 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2611 | RValue<Long> operator+=(Long &lhs, RValue<Long> rhs) |
| 2612 | { |
| 2613 | return lhs = lhs + rhs; |
| 2614 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2615 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2616 | RValue<Long> operator-=(Long &lhs, RValue<Long> rhs) |
| 2617 | { |
| 2618 | return lhs = lhs - rhs; |
| 2619 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2620 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2621 | RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2622 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2623 | return RValue<Long>(Nucleus::createAtomicAdd(x.value(), y.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2624 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2625 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2626 | 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] | 2627 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2628 | return RValue<UInt>(Nucleus::createAtomicAdd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2629 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2630 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2631 | 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] | 2632 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2633 | return RValue<UInt>(Nucleus::createAtomicSub(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2634 | } |
Chris Forbes | 707ed99 | 2019-04-18 18:17:35 -0700 | [diff] [blame] | 2635 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2636 | 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] | 2637 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2638 | return RValue<UInt>(Nucleus::createAtomicAnd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2639 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2640 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2641 | 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] | 2642 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2643 | return RValue<UInt>(Nucleus::createAtomicOr(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2644 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2645 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2646 | 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] | 2647 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2648 | return RValue<UInt>(Nucleus::createAtomicXor(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2649 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2650 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2651 | 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] | 2652 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2653 | return RValue<UInt>(Nucleus::createAtomicExchange(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2654 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2655 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2656 | 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] | 2657 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2658 | 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] | 2659 | } |
Chris Forbes | a16238d | 2019-04-18 16:31:54 -0700 | [diff] [blame] | 2660 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2661 | UInt::UInt(Argument<UInt> argument) |
| 2662 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2663 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2664 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2665 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2666 | UInt::UInt(RValue<UShort> cast) |
| 2667 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2668 | Value *integer = Nucleus::createZExt(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2669 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2670 | storeValue(integer); |
| 2671 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2672 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2673 | UInt::UInt(RValue<Long> cast) |
| 2674 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2675 | Value *integer = Nucleus::createTrunc(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2676 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2677 | storeValue(integer); |
| 2678 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2679 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2680 | UInt::UInt(int x) |
| 2681 | { |
| 2682 | storeValue(Nucleus::createConstantInt(x)); |
| 2683 | } |
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 | UInt::UInt(unsigned int x) |
| 2686 | { |
| 2687 | storeValue(Nucleus::createConstantInt(x)); |
| 2688 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2689 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2690 | UInt::UInt(RValue<UInt> rhs) |
| 2691 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2692 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2693 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2694 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2695 | UInt::UInt(RValue<Int> rhs) |
| 2696 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2697 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2698 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2699 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2700 | UInt::UInt(const UInt &rhs) |
| 2701 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2702 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2703 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2704 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2705 | UInt::UInt(const Reference<UInt> &rhs) |
| 2706 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2707 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2708 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2709 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2710 | UInt::UInt(const Int &rhs) |
| 2711 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2712 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2713 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2714 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2715 | UInt::UInt(const Reference<Int> &rhs) |
| 2716 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2717 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2718 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2719 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2720 | RValue<UInt> UInt::operator=(unsigned int rhs) |
| 2721 | { |
| 2722 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2723 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2724 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2725 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) |
| 2726 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2727 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2728 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2729 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2730 | RValue<UInt> UInt::operator=(RValue<Int> rhs) |
| 2731 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2732 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2733 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2734 | return RValue<UInt>(rhs); |
| 2735 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2736 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2737 | RValue<UInt> UInt::operator=(const UInt &rhs) |
| 2738 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2739 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2740 | } |
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 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) |
| 2743 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2744 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2745 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2746 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2747 | RValue<UInt> UInt::operator=(const Int &rhs) |
| 2748 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2749 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2750 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2751 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2752 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) |
| 2753 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2754 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2755 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2756 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2757 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2758 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2759 | return RValue<UInt>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2760 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2761 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2762 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2763 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2764 | return RValue<UInt>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2765 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2766 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2767 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2768 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2769 | return RValue<UInt>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2770 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2771 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2772 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2773 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2774 | return RValue<UInt>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2775 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2776 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2777 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2778 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2779 | return RValue<UInt>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2780 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2781 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2782 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2783 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2784 | return RValue<UInt>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2785 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2786 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2787 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2788 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2789 | return RValue<UInt>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2790 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2791 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2792 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2793 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2794 | return RValue<UInt>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2795 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2796 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2797 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2798 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2799 | return RValue<UInt>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2800 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2801 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2802 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2803 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2804 | return RValue<UInt>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2805 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2806 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2807 | RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs) |
| 2808 | { |
| 2809 | return lhs = lhs + rhs; |
| 2810 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2811 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2812 | RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs) |
| 2813 | { |
| 2814 | return lhs = lhs - rhs; |
| 2815 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2816 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2817 | RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs) |
| 2818 | { |
| 2819 | return lhs = lhs * rhs; |
| 2820 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2821 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2822 | RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs) |
| 2823 | { |
| 2824 | return lhs = lhs / rhs; |
| 2825 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2826 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2827 | RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs) |
| 2828 | { |
| 2829 | return lhs = lhs % rhs; |
| 2830 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2831 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2832 | RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs) |
| 2833 | { |
| 2834 | return lhs = lhs & rhs; |
| 2835 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2836 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2837 | RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs) |
| 2838 | { |
| 2839 | return lhs = lhs | rhs; |
| 2840 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2841 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2842 | RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs) |
| 2843 | { |
| 2844 | return lhs = lhs ^ rhs; |
| 2845 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2846 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2847 | RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs) |
| 2848 | { |
| 2849 | return lhs = lhs << rhs; |
| 2850 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2851 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2852 | RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs) |
| 2853 | { |
| 2854 | return lhs = lhs >> rhs; |
| 2855 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2856 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2857 | RValue<UInt> operator+(RValue<UInt> val) |
| 2858 | { |
| 2859 | return val; |
| 2860 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2861 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2862 | RValue<UInt> operator-(RValue<UInt> val) |
| 2863 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2864 | return RValue<UInt>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2865 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2866 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2867 | RValue<UInt> operator~(RValue<UInt> val) |
| 2868 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2869 | return RValue<UInt>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2870 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2871 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2872 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 2873 | { |
| 2874 | return IfThenElse(x > y, x, y); |
| 2875 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2876 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2877 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 2878 | { |
| 2879 | return IfThenElse(x < y, x, y); |
| 2880 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2881 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2882 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 2883 | { |
| 2884 | return Min(Max(x, min), max); |
| 2885 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2886 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2887 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2888 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2889 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2890 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2891 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2892 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2893 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2894 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2895 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2896 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2897 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2898 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2899 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2900 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2901 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2902 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2903 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2904 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2905 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2906 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2907 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2908 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2909 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2910 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2911 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2912 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2913 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2914 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2915 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2916 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2917 | Int2::Int2(RValue<Int4> cast) |
| 2918 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2919 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2920 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2921 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2922 | Int2::Int2(int x, int y) |
| 2923 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2924 | std::vector<int64_t> constantVector = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2925 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2926 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2927 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2928 | Int2::Int2(RValue<Int2> rhs) |
| 2929 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2930 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2931 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2932 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2933 | Int2::Int2(const Int2 &rhs) |
| 2934 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2935 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2936 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2937 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2938 | Int2::Int2(const Reference<Int2> &rhs) |
| 2939 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2940 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2941 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2942 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2943 | Int2::Int2(RValue<Int> lo, RValue<Int> hi) |
| 2944 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 2945 | std::vector<int> shuffle = { 0, 4, 1, 5 }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2946 | Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2947 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2948 | storeValue(Nucleus::createBitCast(packed, Int2::type())); |
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 | RValue<Int2> Int2::operator=(RValue<Int2> rhs) |
| 2952 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2953 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2954 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2955 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2956 | RValue<Int2> Int2::operator=(const Int2 &rhs) |
| 2957 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2958 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2959 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2960 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2961 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) |
| 2962 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2963 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2964 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2965 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2966 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2967 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2968 | return RValue<Int2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2969 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2970 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2971 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2972 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2973 | return RValue<Int2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2974 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2975 | |
| 2976 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2977 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2978 | // return RValue<Int2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2979 | // } |
| 2980 | |
| 2981 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2982 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2983 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2984 | // } |
| 2985 | |
| 2986 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2987 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2988 | // return RValue<Int2>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2989 | // } |
| 2990 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2991 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2992 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2993 | return RValue<Int2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2994 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2995 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2996 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2997 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2998 | return RValue<Int2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2999 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3000 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3001 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3002 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3003 | return RValue<Int2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3004 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3005 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3006 | RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs) |
| 3007 | { |
| 3008 | return lhs = lhs + rhs; |
| 3009 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3010 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3011 | RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs) |
| 3012 | { |
| 3013 | return lhs = lhs - rhs; |
| 3014 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3015 | |
| 3016 | // RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs) |
| 3017 | // { |
| 3018 | // return lhs = lhs * rhs; |
| 3019 | // } |
| 3020 | |
| 3021 | // RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs) |
| 3022 | // { |
| 3023 | // return lhs = lhs / rhs; |
| 3024 | // } |
| 3025 | |
| 3026 | // RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs) |
| 3027 | // { |
| 3028 | // return lhs = lhs % rhs; |
| 3029 | // } |
| 3030 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3031 | RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs) |
| 3032 | { |
| 3033 | return lhs = lhs & rhs; |
| 3034 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3035 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3036 | RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs) |
| 3037 | { |
| 3038 | return lhs = lhs | rhs; |
| 3039 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3040 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3041 | RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs) |
| 3042 | { |
| 3043 | return lhs = lhs ^ rhs; |
| 3044 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3045 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3046 | RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs) |
| 3047 | { |
| 3048 | return lhs = lhs << rhs; |
| 3049 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3050 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3051 | RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs) |
| 3052 | { |
| 3053 | return lhs = lhs >> rhs; |
| 3054 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3055 | |
| 3056 | // RValue<Int2> operator+(RValue<Int2> val) |
| 3057 | // { |
| 3058 | // return val; |
| 3059 | // } |
| 3060 | |
| 3061 | // RValue<Int2> operator-(RValue<Int2> val) |
| 3062 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3063 | // return RValue<Int2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3064 | // } |
| 3065 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3066 | RValue<Int2> operator~(RValue<Int2> val) |
| 3067 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3068 | return RValue<Int2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3069 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3070 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3071 | RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
| 3072 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3073 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 3074 | std::vector<int> shuffle = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3075 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3076 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3077 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3078 | RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
| 3079 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3080 | // TODO(b/148379603): Optimize narrowing swizzle. |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 3081 | std::vector<int> shuffle = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3082 | auto lowHigh = RValue<Int4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3083 | return As<Short4>(Swizzle(lowHigh, 0x2323)); |
| 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<Int> Extract(RValue<Int2> val, int i) |
| 3087 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3088 | return RValue<Int>(Nucleus::createExtractElement(val.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3089 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3090 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3091 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
| 3092 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3093 | return RValue<Int2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3094 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3095 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3096 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 3097 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 3098 | std::vector<int64_t> constantVector = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3099 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3100 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3101 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3102 | UInt2::UInt2(RValue<UInt2> rhs) |
| 3103 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3104 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3105 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3106 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3107 | UInt2::UInt2(const UInt2 &rhs) |
| 3108 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3109 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3110 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3111 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3112 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 3113 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3114 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3115 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3116 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3117 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) |
| 3118 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3119 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3120 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3121 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3122 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) |
| 3123 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3124 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3125 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3126 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3127 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) |
| 3128 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3129 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3130 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3131 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3132 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3133 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3134 | return RValue<UInt2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3135 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3136 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3137 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3138 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3139 | return RValue<UInt2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3140 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3141 | |
| 3142 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3143 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3144 | // return RValue<UInt2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3145 | // } |
| 3146 | |
| 3147 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3148 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3149 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3150 | // } |
| 3151 | |
| 3152 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3153 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3154 | // return RValue<UInt2>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3155 | // } |
| 3156 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3157 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3158 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3159 | return RValue<UInt2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3160 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3161 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3162 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3163 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3164 | return RValue<UInt2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3165 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3166 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3167 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3168 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3169 | return RValue<UInt2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3170 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3171 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3172 | RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3173 | { |
| 3174 | return lhs = lhs + rhs; |
| 3175 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3176 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3177 | RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3178 | { |
| 3179 | return lhs = lhs - rhs; |
| 3180 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3181 | |
| 3182 | // RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3183 | // { |
| 3184 | // return lhs = lhs * rhs; |
| 3185 | // } |
| 3186 | |
| 3187 | // RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3188 | // { |
| 3189 | // return lhs = lhs / rhs; |
| 3190 | // } |
| 3191 | |
| 3192 | // RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3193 | // { |
| 3194 | // return lhs = lhs % rhs; |
| 3195 | // } |
| 3196 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3197 | RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3198 | { |
| 3199 | return lhs = lhs & rhs; |
| 3200 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3201 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3202 | RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3203 | { |
| 3204 | return lhs = lhs | rhs; |
| 3205 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3206 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3207 | RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3208 | { |
| 3209 | return lhs = lhs ^ rhs; |
| 3210 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3211 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3212 | RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs) |
| 3213 | { |
| 3214 | return lhs = lhs << rhs; |
| 3215 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3216 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3217 | RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs) |
| 3218 | { |
| 3219 | return lhs = lhs >> rhs; |
| 3220 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3221 | |
| 3222 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 3223 | // { |
| 3224 | // return val; |
| 3225 | // } |
| 3226 | |
| 3227 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 3228 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3229 | // return RValue<UInt2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3230 | // } |
| 3231 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3232 | RValue<UInt2> operator~(RValue<UInt2> val) |
| 3233 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3234 | return RValue<UInt2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3235 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3236 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3237 | RValue<UInt> Extract(RValue<UInt2> val, int i) |
| 3238 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3239 | return RValue<UInt>(Nucleus::createExtractElement(val.value(), UInt::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3240 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3241 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3242 | RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i) |
| 3243 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3244 | return RValue<UInt2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3245 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3246 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3247 | Int4::Int4() |
| 3248 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3249 | { |
| 3250 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3251 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3252 | Int4::Int4(RValue<Float4> cast) |
| 3253 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3254 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3255 | Value *xyzw = Nucleus::createFPToSI(cast.value(), Int4::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3256 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3257 | storeValue(xyzw); |
| 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(int xyzw) |
| 3261 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3262 | { |
| 3263 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3264 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3265 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3266 | Int4::Int4(int x, int yzw) |
| 3267 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3268 | { |
| 3269 | constant(x, yzw, yzw, yzw); |
| 3270 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3271 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3272 | Int4::Int4(int x, int y, int zw) |
| 3273 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3274 | { |
| 3275 | constant(x, y, zw, zw); |
| 3276 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3277 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3278 | Int4::Int4(int x, int y, int z, int w) |
| 3279 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3280 | { |
| 3281 | constant(x, y, z, w); |
| 3282 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3283 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3284 | void Int4::constant(int x, int y, int z, int w) |
| 3285 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 3286 | std::vector<int64_t> constantVector = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3287 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3288 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3289 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3290 | Int4::Int4(RValue<Int4> rhs) |
| 3291 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3292 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3293 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3294 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3295 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3296 | Int4::Int4(const Int4 &rhs) |
| 3297 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3298 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3299 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3300 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3301 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3302 | Int4::Int4(const Reference<Int4> &rhs) |
| 3303 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3304 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3305 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3306 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3307 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3308 | Int4::Int4(RValue<UInt4> rhs) |
| 3309 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3310 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3311 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3312 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3313 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3314 | Int4::Int4(const UInt4 &rhs) |
| 3315 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3316 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3317 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3318 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3319 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3320 | Int4::Int4(const Reference<UInt4> &rhs) |
| 3321 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3322 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3323 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3324 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3325 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3326 | Int4::Int4(RValue<Int2> lo, RValue<Int2> hi) |
| 3327 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3328 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 3329 | std::vector<int> shuffle = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3330 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3331 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3332 | storeValue(packed); |
| 3333 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3334 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3335 | Int4::Int4(const Int &rhs) |
| 3336 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3337 | { |
| 3338 | *this = RValue<Int>(rhs.loadValue()); |
| 3339 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3340 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3341 | Int4::Int4(const Reference<Int> &rhs) |
| 3342 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3343 | { |
| 3344 | *this = RValue<Int>(rhs.loadValue()); |
| 3345 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3346 | |
Nicolas Capens | 82d425d | 2022-03-02 16:35:20 -0500 | [diff] [blame] | 3347 | RValue<Int4> Int4::operator=(int x) |
| 3348 | { |
| 3349 | return *this = Int4(x, x, x, x); |
| 3350 | } |
| 3351 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3352 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) |
| 3353 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3354 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3355 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3356 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3357 | RValue<Int4> Int4::operator=(const Int4 &rhs) |
| 3358 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3359 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3360 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3361 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3362 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) |
| 3363 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3364 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3365 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3366 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3367 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3368 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3369 | return RValue<Int4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3370 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3371 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3372 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3373 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3374 | return RValue<Int4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3375 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3376 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3377 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3378 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3379 | return RValue<Int4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3380 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3381 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3382 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3383 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3384 | return RValue<Int4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3385 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3386 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3387 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3388 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3389 | return RValue<Int4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3390 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3391 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3392 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3393 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3394 | return RValue<Int4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3395 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3396 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3397 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3398 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3399 | return RValue<Int4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3400 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3401 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3402 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3403 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3404 | return RValue<Int4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3405 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3406 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3407 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3408 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3409 | return RValue<Int4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3410 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3411 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3412 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3413 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3414 | return RValue<Int4>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3415 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3416 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3417 | RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs) |
| 3418 | { |
| 3419 | return lhs = lhs + rhs; |
| 3420 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3421 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3422 | RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs) |
| 3423 | { |
| 3424 | return lhs = lhs - rhs; |
| 3425 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3426 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3427 | RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs) |
| 3428 | { |
| 3429 | return lhs = lhs * rhs; |
| 3430 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3431 | |
| 3432 | // RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs) |
| 3433 | // { |
| 3434 | // return lhs = lhs / rhs; |
| 3435 | // } |
| 3436 | |
| 3437 | // RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs) |
| 3438 | // { |
| 3439 | // return lhs = lhs % rhs; |
| 3440 | // } |
| 3441 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3442 | RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs) |
| 3443 | { |
| 3444 | return lhs = lhs & rhs; |
| 3445 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3446 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3447 | RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs) |
| 3448 | { |
| 3449 | return lhs = lhs | rhs; |
| 3450 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3451 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3452 | RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs) |
| 3453 | { |
| 3454 | return lhs = lhs ^ rhs; |
| 3455 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3456 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3457 | RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs) |
| 3458 | { |
| 3459 | return lhs = lhs << rhs; |
| 3460 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3461 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3462 | RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs) |
| 3463 | { |
| 3464 | return lhs = lhs >> rhs; |
| 3465 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3466 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3467 | RValue<Int4> operator+(RValue<Int4> val) |
| 3468 | { |
| 3469 | return val; |
| 3470 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3471 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3472 | RValue<Int4> operator-(RValue<Int4> val) |
| 3473 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3474 | return RValue<Int4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3475 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3476 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3477 | RValue<Int4> operator~(RValue<Int4> val) |
| 3478 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3479 | return RValue<Int4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3480 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3481 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3482 | RValue<Int> Extract(RValue<Int4> x, int i) |
| 3483 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3484 | return RValue<Int>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3485 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3486 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3487 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
| 3488 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3489 | return RValue<Int4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3490 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3491 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3492 | RValue<Int4> Swizzle(RValue<Int4> x, uint16_t select) |
| 3493 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3494 | return RValue<Int4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3495 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3496 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3497 | RValue<Int4> Shuffle(RValue<Int4> x, RValue<Int4> y, unsigned short select) |
| 3498 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3499 | return RValue<Int4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3500 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 3501 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3502 | UInt4::UInt4() |
| 3503 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3504 | { |
| 3505 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3506 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3507 | UInt4::UInt4(int xyzw) |
| 3508 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3509 | { |
| 3510 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3511 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3512 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3513 | UInt4::UInt4(int x, int yzw) |
| 3514 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3515 | { |
| 3516 | constant(x, yzw, yzw, yzw); |
| 3517 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3518 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3519 | UInt4::UInt4(int x, int y, int zw) |
| 3520 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3521 | { |
| 3522 | constant(x, y, zw, zw); |
| 3523 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3524 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3525 | UInt4::UInt4(int x, int y, int z, int w) |
| 3526 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3527 | { |
| 3528 | constant(x, y, z, w); |
| 3529 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3530 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3531 | void UInt4::constant(int x, int y, int z, int w) |
| 3532 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 3533 | std::vector<int64_t> constantVector = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3534 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3535 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3536 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3537 | UInt4::UInt4(RValue<UInt4> rhs) |
| 3538 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3539 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3540 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3541 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3542 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3543 | UInt4::UInt4(const UInt4 &rhs) |
| 3544 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3545 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3546 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3547 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3548 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3549 | UInt4::UInt4(const Reference<UInt4> &rhs) |
| 3550 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3551 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3552 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3553 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3554 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3555 | UInt4::UInt4(RValue<Int4> rhs) |
| 3556 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3557 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3558 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3559 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3560 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3561 | UInt4::UInt4(const Int4 &rhs) |
| 3562 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3563 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3564 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3565 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3566 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3567 | UInt4::UInt4(const Reference<Int4> &rhs) |
| 3568 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3569 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3570 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3571 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3572 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3573 | UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi) |
| 3574 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3575 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 3576 | std::vector<int> shuffle = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3577 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3578 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3579 | storeValue(packed); |
| 3580 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3581 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3582 | UInt4::UInt4(const UInt &rhs) |
| 3583 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3584 | { |
| 3585 | *this = RValue<UInt>(rhs.loadValue()); |
| 3586 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3587 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3588 | UInt4::UInt4(const Reference<UInt> &rhs) |
| 3589 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3590 | { |
| 3591 | *this = RValue<UInt>(rhs.loadValue()); |
| 3592 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3593 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3594 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) |
| 3595 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3596 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3597 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3598 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3599 | RValue<UInt4> UInt4::operator=(const UInt4 &rhs) |
| 3600 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3601 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3602 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3603 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3604 | RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) |
| 3605 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3606 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3607 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3608 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3609 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3610 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3611 | return RValue<UInt4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3612 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3613 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3614 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3615 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3616 | return RValue<UInt4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3617 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3618 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3619 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3620 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3621 | return RValue<UInt4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3622 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3623 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3624 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3625 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3626 | return RValue<UInt4>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3627 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3628 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3629 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3630 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3631 | return RValue<UInt4>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3632 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3633 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3634 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3635 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3636 | return RValue<UInt4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3637 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3638 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3639 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3640 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3641 | return RValue<UInt4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3642 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3643 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3644 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3645 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3646 | return RValue<UInt4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3647 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3648 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3649 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3650 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3651 | return RValue<UInt4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3652 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3653 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3654 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3655 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3656 | return RValue<UInt4>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3657 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3658 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3659 | RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3660 | { |
| 3661 | return lhs = lhs + rhs; |
| 3662 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3663 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3664 | RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3665 | { |
| 3666 | return lhs = lhs - rhs; |
| 3667 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3668 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3669 | RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3670 | { |
| 3671 | return lhs = lhs * rhs; |
| 3672 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3673 | |
| 3674 | // RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3675 | // { |
| 3676 | // return lhs = lhs / rhs; |
| 3677 | // } |
| 3678 | |
| 3679 | // RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3680 | // { |
| 3681 | // return lhs = lhs % rhs; |
| 3682 | // } |
| 3683 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3684 | RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3685 | { |
| 3686 | return lhs = lhs & rhs; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3687 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3688 | |
| 3689 | RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3690 | { |
| 3691 | return lhs = lhs | rhs; |
| 3692 | } |
| 3693 | |
| 3694 | RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3695 | { |
| 3696 | return lhs = lhs ^ rhs; |
| 3697 | } |
| 3698 | |
| 3699 | RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs) |
| 3700 | { |
| 3701 | return lhs = lhs << rhs; |
| 3702 | } |
| 3703 | |
| 3704 | RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs) |
| 3705 | { |
| 3706 | return lhs = lhs >> rhs; |
| 3707 | } |
| 3708 | |
| 3709 | RValue<UInt4> operator+(RValue<UInt4> val) |
| 3710 | { |
| 3711 | return val; |
| 3712 | } |
| 3713 | |
| 3714 | RValue<UInt4> operator-(RValue<UInt4> val) |
| 3715 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3716 | return RValue<UInt4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3717 | } |
| 3718 | |
| 3719 | RValue<UInt4> operator~(RValue<UInt4> val) |
| 3720 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3721 | return RValue<UInt4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3722 | } |
| 3723 | |
| 3724 | RValue<UInt> Extract(RValue<UInt4> x, int i) |
| 3725 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3726 | return RValue<UInt>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3727 | } |
| 3728 | |
| 3729 | RValue<UInt4> Insert(RValue<UInt4> x, RValue<UInt> element, int i) |
| 3730 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3731 | return RValue<UInt4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3732 | } |
| 3733 | |
| 3734 | RValue<UInt4> Swizzle(RValue<UInt4> x, uint16_t select) |
| 3735 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3736 | return RValue<UInt4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3737 | } |
| 3738 | |
| 3739 | RValue<UInt4> Shuffle(RValue<UInt4> x, RValue<UInt4> y, unsigned short select) |
| 3740 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3741 | return RValue<UInt4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3742 | } |
| 3743 | |
| 3744 | Half::Half(RValue<Float> cast) |
| 3745 | { |
| 3746 | UInt fp32i = As<UInt>(cast); |
| 3747 | UInt abs = fp32i & 0x7FFFFFFF; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3748 | UShort fp16i((fp32i & 0x80000000) >> 16); // sign |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3749 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3750 | If(abs > 0x47FFEFFF) // Infinity |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3751 | { |
| 3752 | fp16i |= UShort(0x7FFF); |
| 3753 | } |
| 3754 | Else |
| 3755 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3756 | If(abs < 0x38800000) // Denormal |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3757 | { |
| 3758 | Int mantissa = (abs & 0x007FFFFF) | 0x00800000; |
| 3759 | Int e = 113 - (abs >> 23); |
Nicolas Capens | 60f8c2e | 2019-12-12 13:40:15 -0500 | [diff] [blame] | 3760 | abs = IfThenElse(e < 24, (mantissa >> e), Int(0)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3761 | fp16i |= UShort((abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3762 | } |
| 3763 | Else |
| 3764 | { |
| 3765 | fp16i |= UShort((abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3766 | } |
| 3767 | } |
| 3768 | |
| 3769 | storeValue(fp16i.loadValue()); |
| 3770 | } |
| 3771 | |
| 3772 | Float::Float(RValue<Int> cast) |
| 3773 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3774 | Value *integer = Nucleus::createSIToFP(cast.value(), Float::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3775 | |
| 3776 | storeValue(integer); |
| 3777 | } |
| 3778 | |
| 3779 | Float::Float(RValue<UInt> cast) |
| 3780 | { |
| 3781 | RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) + |
| 3782 | As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u))); |
| 3783 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3784 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3785 | } |
| 3786 | |
| 3787 | Float::Float(RValue<Half> cast) |
| 3788 | { |
| 3789 | Int fp16i(As<UShort>(cast)); |
| 3790 | |
| 3791 | Int s = (fp16i >> 15) & 0x00000001; |
| 3792 | Int e = (fp16i >> 10) & 0x0000001F; |
| 3793 | Int m = fp16i & 0x000003FF; |
| 3794 | |
| 3795 | UInt fp32i(s << 31); |
| 3796 | If(e == 0) |
| 3797 | { |
| 3798 | If(m != 0) |
| 3799 | { |
| 3800 | While((m & 0x00000400) == 0) |
| 3801 | { |
| 3802 | m <<= 1; |
| 3803 | e -= 1; |
| 3804 | } |
| 3805 | |
| 3806 | fp32i |= As<UInt>(((e + (127 - 15) + 1) << 23) | ((m & ~0x00000400) << 13)); |
| 3807 | } |
| 3808 | } |
| 3809 | Else |
| 3810 | { |
| 3811 | fp32i |= As<UInt>(((e + (127 - 15)) << 23) | (m << 13)); |
| 3812 | } |
| 3813 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3814 | storeValue(As<Float>(fp32i).value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3815 | } |
| 3816 | |
| 3817 | Float::Float(float x) |
| 3818 | { |
| 3819 | // C++ does not have a way to write an infinite or NaN literal, |
| 3820 | // nor does it allow division by zero as a constant expression. |
| 3821 | // Thus we should not accept inf or NaN as a Reactor Float constant, |
| 3822 | // as this would typically idicate a bug, and avoids undefined |
| 3823 | // behavior. |
| 3824 | // |
| 3825 | // This also prevents the issue of the LLVM JIT only taking double |
| 3826 | // values for constructing floating-point constants. During the |
| 3827 | // conversion from single-precision to double, a signaling NaN can |
| 3828 | // become a quiet NaN, thus altering its bit pattern. Hence this |
| 3829 | // assert is also helpful for detecting cases where integers are |
| 3830 | // being reinterpreted as float and then bitcast to integer again, |
| 3831 | // which does not guarantee preserving the integer value. |
| 3832 | // |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3833 | // The inifinity() method can be used to obtain positive infinity. |
| 3834 | // Should NaN constants be required, methods like quiet_NaN() and |
| 3835 | // signaling_NaN() should be added (matching std::numeric_limits). |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3836 | ASSERT(std::isfinite(x)); |
| 3837 | |
| 3838 | storeValue(Nucleus::createConstantFloat(x)); |
| 3839 | } |
| 3840 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3841 | // TODO(b/140302841): Negative infinity can be obtained by using '-infinity()'. |
| 3842 | // This comes at a minor run-time JIT cost, and the backend may or may not |
| 3843 | // perform constant folding. This can be optimized by having Reactor perform |
| 3844 | // the folding, which would still be cheaper than having a capable backend do it. |
| 3845 | Float Float::infinity() |
| 3846 | { |
| 3847 | Float result; |
| 3848 | |
| 3849 | constexpr double inf = std::numeric_limits<double>::infinity(); |
| 3850 | result.storeValue(Nucleus::createConstantFloat(inf)); |
| 3851 | |
| 3852 | return result; |
| 3853 | } |
| 3854 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3855 | Float::Float(RValue<Float> rhs) |
| 3856 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3857 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3858 | } |
| 3859 | |
| 3860 | Float::Float(const Float &rhs) |
| 3861 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3862 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3863 | } |
| 3864 | |
| 3865 | Float::Float(const Reference<Float> &rhs) |
| 3866 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3867 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3868 | } |
| 3869 | |
| 3870 | Float::Float(Argument<Float> argument) |
| 3871 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3872 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3873 | } |
| 3874 | |
Nicolas Capens | 0aca3ca | 2020-09-19 23:59:08 -0400 | [diff] [blame] | 3875 | RValue<Float> Float::operator=(float rhs) |
| 3876 | { |
| 3877 | return RValue<Float>(storeValue(Nucleus::createConstantFloat(rhs))); |
| 3878 | } |
| 3879 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3880 | RValue<Float> Float::operator=(RValue<Float> rhs) |
| 3881 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3882 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3883 | } |
| 3884 | |
| 3885 | RValue<Float> Float::operator=(const Float &rhs) |
| 3886 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3887 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3888 | } |
| 3889 | |
| 3890 | RValue<Float> Float::operator=(const Reference<Float> &rhs) |
| 3891 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3892 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3893 | } |
| 3894 | |
| 3895 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
| 3896 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3897 | return RValue<Float>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3898 | } |
| 3899 | |
| 3900 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
| 3901 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3902 | return RValue<Float>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3903 | } |
| 3904 | |
| 3905 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
| 3906 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3907 | return RValue<Float>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3908 | } |
| 3909 | |
| 3910 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
| 3911 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3912 | return RValue<Float>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3913 | } |
| 3914 | |
| 3915 | RValue<Float> operator+=(Float &lhs, RValue<Float> rhs) |
| 3916 | { |
| 3917 | return lhs = lhs + rhs; |
| 3918 | } |
| 3919 | |
| 3920 | RValue<Float> operator-=(Float &lhs, RValue<Float> rhs) |
| 3921 | { |
| 3922 | return lhs = lhs - rhs; |
| 3923 | } |
| 3924 | |
| 3925 | RValue<Float> operator*=(Float &lhs, RValue<Float> rhs) |
| 3926 | { |
| 3927 | return lhs = lhs * rhs; |
| 3928 | } |
| 3929 | |
| 3930 | RValue<Float> operator/=(Float &lhs, RValue<Float> rhs) |
| 3931 | { |
| 3932 | return lhs = lhs / rhs; |
| 3933 | } |
| 3934 | |
| 3935 | RValue<Float> operator+(RValue<Float> val) |
| 3936 | { |
| 3937 | return val; |
| 3938 | } |
| 3939 | |
| 3940 | RValue<Float> operator-(RValue<Float> val) |
| 3941 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3942 | return RValue<Float>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3943 | } |
| 3944 | |
| 3945 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
| 3946 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3947 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3948 | } |
| 3949 | |
| 3950 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
| 3951 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3952 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3953 | } |
| 3954 | |
| 3955 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
| 3956 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3957 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3958 | } |
| 3959 | |
| 3960 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
| 3961 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3962 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3963 | } |
| 3964 | |
| 3965 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
| 3966 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3967 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3968 | } |
| 3969 | |
| 3970 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
| 3971 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3972 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3973 | } |
| 3974 | |
| 3975 | RValue<Float> Abs(RValue<Float> x) |
| 3976 | { |
| 3977 | return IfThenElse(x > 0.0f, x, -x); |
| 3978 | } |
| 3979 | |
| 3980 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
| 3981 | { |
| 3982 | return IfThenElse(x > y, x, y); |
| 3983 | } |
| 3984 | |
| 3985 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
| 3986 | { |
| 3987 | return IfThenElse(x < y, x, y); |
| 3988 | } |
| 3989 | |
| 3990 | Float2::Float2(RValue<Float4> cast) |
| 3991 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3992 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3993 | } |
| 3994 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3995 | Float4::Float4(RValue<Byte4> cast) |
| 3996 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3997 | { |
| 3998 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3999 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4000 | |
| 4001 | storeValue(xyzw); |
| 4002 | } |
| 4003 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4004 | Float4::Float4(RValue<SByte4> cast) |
| 4005 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4006 | { |
| 4007 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4008 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4009 | |
| 4010 | storeValue(xyzw); |
| 4011 | } |
| 4012 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4013 | Float4::Float4(RValue<Short4> cast) |
| 4014 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4015 | { |
| 4016 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4017 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4018 | } |
| 4019 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4020 | Float4::Float4(RValue<UShort4> cast) |
| 4021 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4022 | { |
| 4023 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4024 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4025 | } |
| 4026 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4027 | Float4::Float4(RValue<Int4> cast) |
| 4028 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4029 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4030 | Value *xyzw = Nucleus::createSIToFP(cast.value(), Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4031 | |
| 4032 | storeValue(xyzw); |
| 4033 | } |
| 4034 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4035 | Float4::Float4(RValue<UInt4> cast) |
| 4036 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4037 | { |
| 4038 | RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) + |
| 4039 | As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u))); |
| 4040 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4041 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4042 | } |
| 4043 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4044 | Float4::Float4() |
| 4045 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4046 | { |
| 4047 | } |
| 4048 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4049 | Float4::Float4(float xyzw) |
| 4050 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4051 | { |
| 4052 | constant(xyzw, xyzw, xyzw, xyzw); |
| 4053 | } |
| 4054 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4055 | Float4::Float4(float x, float yzw) |
| 4056 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4057 | { |
| 4058 | constant(x, yzw, yzw, yzw); |
| 4059 | } |
| 4060 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4061 | Float4::Float4(float x, float y, float zw) |
| 4062 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4063 | { |
| 4064 | constant(x, y, zw, zw); |
| 4065 | } |
| 4066 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4067 | Float4::Float4(float x, float y, float z, float w) |
| 4068 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4069 | { |
| 4070 | constant(x, y, z, w); |
| 4071 | } |
| 4072 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4073 | Float4 Float4::infinity() |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4074 | { |
| 4075 | Float4 result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4076 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4077 | constexpr double inf = std::numeric_limits<double>::infinity(); |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 4078 | std::vector<double> constantVector = { inf }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4079 | result.storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4080 | |
| 4081 | return result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4082 | } |
| 4083 | |
| 4084 | void Float4::constant(float x, float y, float z, float w) |
| 4085 | { |
| 4086 | // See Float(float) constructor for the rationale behind this assert. |
| 4087 | ASSERT(std::isfinite(x) && std::isfinite(y) && std::isfinite(z) && std::isfinite(w)); |
| 4088 | |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 4089 | std::vector<double> constantVector = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4090 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4091 | } |
| 4092 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4093 | Float4::Float4(RValue<Float4> rhs) |
| 4094 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4095 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4096 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4097 | } |
| 4098 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4099 | Float4::Float4(const Float4 &rhs) |
| 4100 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4101 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4102 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4103 | } |
| 4104 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4105 | Float4::Float4(const Reference<Float4> &rhs) |
| 4106 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4107 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4108 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4109 | } |
| 4110 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4111 | Float4::Float4(const Float &rhs) |
| 4112 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4113 | { |
| 4114 | *this = RValue<Float>(rhs.loadValue()); |
| 4115 | } |
| 4116 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4117 | Float4::Float4(const Reference<Float> &rhs) |
| 4118 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4119 | { |
| 4120 | *this = RValue<Float>(rhs.loadValue()); |
| 4121 | } |
| 4122 | |
Nicolas Capens | 419b7d7 | 2020-10-02 16:15:34 -0400 | [diff] [blame] | 4123 | Float4::Float4(RValue<Float2> lo, RValue<Float2> hi) |
| 4124 | : XYZW(this) |
| 4125 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 4126 | std::vector<int> shuffle = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | 419b7d7 | 2020-10-02 16:15:34 -0400 | [diff] [blame] | 4127 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
| 4128 | |
| 4129 | storeValue(packed); |
| 4130 | } |
| 4131 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4132 | RValue<Float4> Float4::operator=(float x) |
| 4133 | { |
| 4134 | return *this = Float4(x, x, x, x); |
| 4135 | } |
| 4136 | |
| 4137 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) |
| 4138 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4139 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4140 | } |
| 4141 | |
| 4142 | RValue<Float4> Float4::operator=(const Float4 &rhs) |
| 4143 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4144 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4145 | } |
| 4146 | |
| 4147 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) |
| 4148 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4149 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4150 | } |
| 4151 | |
| 4152 | RValue<Float4> Float4::operator=(RValue<Float> rhs) |
| 4153 | { |
| 4154 | return *this = Float4(rhs); |
| 4155 | } |
| 4156 | |
| 4157 | RValue<Float4> Float4::operator=(const Float &rhs) |
| 4158 | { |
| 4159 | return *this = Float4(rhs); |
| 4160 | } |
| 4161 | |
| 4162 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) |
| 4163 | { |
| 4164 | return *this = Float4(rhs); |
| 4165 | } |
| 4166 | |
| 4167 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4168 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4169 | return RValue<Float4>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4170 | } |
| 4171 | |
| 4172 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4173 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4174 | return RValue<Float4>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4175 | } |
| 4176 | |
| 4177 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4178 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4179 | return RValue<Float4>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4180 | } |
| 4181 | |
| 4182 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4183 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4184 | return RValue<Float4>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4185 | } |
| 4186 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4187 | RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs) |
| 4188 | { |
| 4189 | return lhs = lhs + rhs; |
| 4190 | } |
| 4191 | |
| 4192 | RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs) |
| 4193 | { |
| 4194 | return lhs = lhs - rhs; |
| 4195 | } |
| 4196 | |
| 4197 | RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs) |
| 4198 | { |
| 4199 | return lhs = lhs * rhs; |
| 4200 | } |
| 4201 | |
| 4202 | RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs) |
| 4203 | { |
| 4204 | return lhs = lhs / rhs; |
| 4205 | } |
| 4206 | |
| 4207 | RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs) |
| 4208 | { |
| 4209 | return lhs = lhs % rhs; |
| 4210 | } |
| 4211 | |
| 4212 | RValue<Float4> operator+(RValue<Float4> val) |
| 4213 | { |
| 4214 | return val; |
| 4215 | } |
| 4216 | |
| 4217 | RValue<Float4> operator-(RValue<Float4> val) |
| 4218 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4219 | return RValue<Float4>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4220 | } |
| 4221 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4222 | RValue<Float4> Insert(RValue<Float4> x, RValue<Float> element, int i) |
| 4223 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4224 | return RValue<Float4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4225 | } |
| 4226 | |
| 4227 | RValue<Float> Extract(RValue<Float4> x, int i) |
| 4228 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4229 | return RValue<Float>(Nucleus::createExtractElement(x.value(), Float::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4230 | } |
| 4231 | |
| 4232 | RValue<Float4> Swizzle(RValue<Float4> x, uint16_t select) |
| 4233 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4234 | return RValue<Float4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4235 | } |
| 4236 | |
| 4237 | RValue<Float4> Shuffle(RValue<Float4> x, RValue<Float4> y, uint16_t select) |
| 4238 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4239 | return RValue<Float4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4240 | } |
| 4241 | |
| 4242 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, uint16_t imm) |
| 4243 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 4244 | std::vector<int> shuffle = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4245 | ((imm >> 12) & 0x03) + 0, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4246 | ((imm >> 8) & 0x03) + 0, |
| 4247 | ((imm >> 4) & 0x03) + 4, |
| 4248 | ((imm >> 0) & 0x03) + 4, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4249 | }; |
| 4250 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4251 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4252 | } |
| 4253 | |
| 4254 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) |
| 4255 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 4256 | std::vector<int> shuffle = { 0, 4, 1, 5 }; |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4257 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4258 | } |
| 4259 | |
| 4260 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
| 4261 | { |
Nicolas Capens | 4e7d310 | 2022-06-21 01:42:18 -0400 | [diff] [blame] | 4262 | std::vector<int> shuffle = { 2, 6, 3, 7 }; |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4263 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4264 | } |
| 4265 | |
| 4266 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, uint16_t select) |
| 4267 | { |
| 4268 | Value *vector = lhs.loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4269 | Value *result = createMask4(vector, rhs.value(), select); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4270 | lhs.storeValue(result); |
| 4271 | |
| 4272 | return RValue<Float4>(result); |
| 4273 | } |
| 4274 | |
| 4275 | RValue<Int4> IsInf(RValue<Float4> x) |
| 4276 | { |
| 4277 | return CmpEQ(As<Int4>(x) & Int4(0x7FFFFFFF), Int4(0x7F800000)); |
| 4278 | } |
| 4279 | |
| 4280 | RValue<Int4> IsNan(RValue<Float4> x) |
| 4281 | { |
| 4282 | return ~CmpEQ(x, x); |
| 4283 | } |
| 4284 | |
Nicolas Capens | 442e25b | 2022-06-22 12:02:52 -0400 | [diff] [blame] | 4285 | RValue<Float> Exp2(RValue<Float> x) |
| 4286 | { |
| 4287 | return Call(exp2f, x); |
| 4288 | } |
| 4289 | |
| 4290 | RValue<Float> Log2(RValue<Float> x) |
| 4291 | { |
| 4292 | return Call(log2f, x); |
| 4293 | } |
| 4294 | |
| 4295 | RValue<Float4> Sin(RValue<Float4> x) |
| 4296 | { |
| 4297 | return ScalarizeCall(sinf, x); |
| 4298 | } |
| 4299 | |
| 4300 | RValue<Float4> Cos(RValue<Float4> x) |
| 4301 | { |
| 4302 | return ScalarizeCall(cosf, x); |
| 4303 | } |
| 4304 | |
| 4305 | RValue<Float4> Tan(RValue<Float4> x) |
| 4306 | { |
| 4307 | return ScalarizeCall(tanf, x); |
| 4308 | } |
| 4309 | |
| 4310 | RValue<Float4> Asin(RValue<Float4> x) |
| 4311 | { |
| 4312 | return ScalarizeCall(asinf, x); |
| 4313 | } |
| 4314 | |
| 4315 | RValue<Float4> Acos(RValue<Float4> x) |
| 4316 | { |
| 4317 | return ScalarizeCall(acosf, x); |
| 4318 | } |
| 4319 | |
| 4320 | RValue<Float4> Atan(RValue<Float4> x) |
| 4321 | { |
| 4322 | return ScalarizeCall(atanf, x); |
| 4323 | } |
| 4324 | |
| 4325 | RValue<Float4> Sinh(RValue<Float4> x) |
| 4326 | { |
| 4327 | return ScalarizeCall(sinhf, x); |
| 4328 | } |
| 4329 | |
| 4330 | RValue<Float4> Cosh(RValue<Float4> x) |
| 4331 | { |
| 4332 | return ScalarizeCall(coshf, x); |
| 4333 | } |
| 4334 | |
| 4335 | RValue<Float4> Tanh(RValue<Float4> x) |
| 4336 | { |
| 4337 | return ScalarizeCall(tanhf, x); |
| 4338 | } |
| 4339 | |
| 4340 | RValue<Float4> Asinh(RValue<Float4> x) |
| 4341 | { |
| 4342 | return ScalarizeCall(asinhf, x); |
| 4343 | } |
| 4344 | |
| 4345 | RValue<Float4> Acosh(RValue<Float4> x) |
| 4346 | { |
| 4347 | return ScalarizeCall(acoshf, x); |
| 4348 | } |
| 4349 | |
| 4350 | RValue<Float4> Atanh(RValue<Float4> x) |
| 4351 | { |
| 4352 | return ScalarizeCall(atanhf, x); |
| 4353 | } |
| 4354 | |
| 4355 | RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y) |
| 4356 | { |
| 4357 | return ScalarizeCall(atan2f, x, y); |
| 4358 | } |
| 4359 | |
| 4360 | RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y) |
| 4361 | { |
| 4362 | return ScalarizeCall(powf, x, y); |
| 4363 | } |
| 4364 | |
| 4365 | RValue<Float4> Exp(RValue<Float4> x) |
| 4366 | { |
| 4367 | return ScalarizeCall(expf, x); |
| 4368 | } |
| 4369 | |
| 4370 | RValue<Float4> Log(RValue<Float4> x) |
| 4371 | { |
| 4372 | return ScalarizeCall(logf, x); |
| 4373 | } |
| 4374 | |
| 4375 | RValue<Float4> Exp2(RValue<Float4> x) |
| 4376 | { |
| 4377 | return ScalarizeCall(exp2f, x); |
| 4378 | } |
| 4379 | |
| 4380 | RValue<Float4> Log2(RValue<Float4> x) |
| 4381 | { |
| 4382 | return ScalarizeCall(log2f, x); |
| 4383 | } |
| 4384 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4385 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) |
| 4386 | { |
| 4387 | return lhs + RValue<Int>(Nucleus::createConstantInt(offset)); |
| 4388 | } |
| 4389 | |
| 4390 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4391 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4392 | 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] | 4393 | } |
| 4394 | |
| 4395 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4396 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4397 | 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] | 4398 | } |
| 4399 | |
| 4400 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset) |
| 4401 | { |
| 4402 | return lhs = lhs + offset; |
| 4403 | } |
| 4404 | |
| 4405 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4406 | { |
| 4407 | return lhs = lhs + offset; |
| 4408 | } |
| 4409 | |
| 4410 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4411 | { |
| 4412 | return lhs = lhs + offset; |
| 4413 | } |
| 4414 | |
| 4415 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset) |
| 4416 | { |
| 4417 | return lhs + -offset; |
| 4418 | } |
| 4419 | |
| 4420 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4421 | { |
| 4422 | return lhs + -offset; |
| 4423 | } |
| 4424 | |
| 4425 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4426 | { |
| 4427 | return lhs + -offset; |
| 4428 | } |
| 4429 | |
| 4430 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset) |
| 4431 | { |
| 4432 | return lhs = lhs - offset; |
| 4433 | } |
| 4434 | |
| 4435 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4436 | { |
| 4437 | return lhs = lhs - offset; |
| 4438 | } |
| 4439 | |
| 4440 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4441 | { |
| 4442 | return lhs = lhs - offset; |
| 4443 | } |
| 4444 | |
Sean Risser | 19e3080 | 2022-06-01 10:58:10 -0400 | [diff] [blame] | 4445 | RValue<Bool> AnyTrue(const RValue<Int4> &bools) |
| 4446 | { |
| 4447 | return SignMask(bools) != 0; |
| 4448 | } |
| 4449 | |
| 4450 | RValue<Bool> AnyFalse(const RValue<Int4> &bools) |
| 4451 | { |
| 4452 | return SignMask(~bools) != 0; // TODO(b/214588983): Compare against mask of 4 1's to avoid bitwise NOT. |
| 4453 | } |
| 4454 | |
| 4455 | RValue<Bool> AllTrue(const RValue<Int4> &bools) |
| 4456 | { |
| 4457 | return SignMask(~bools) == 0; // TODO(b/214588983): Compare against mask of 4 1's to avoid bitwise NOT. |
| 4458 | } |
| 4459 | |
| 4460 | RValue<Bool> AllFalse(const RValue<Int4> &bools) |
| 4461 | { |
| 4462 | return SignMask(bools) == 0; |
| 4463 | } |
| 4464 | |
| 4465 | RValue<Bool> Divergent(const RValue<Int4> &ints) |
| 4466 | { |
| 4467 | auto broadcastFirst = Int4(Extract(ints, 0)); |
| 4468 | return AnyTrue(CmpNEQ(broadcastFirst, ints)); |
| 4469 | } |
| 4470 | |
| 4471 | RValue<Bool> Divergent(const RValue<Float4> &floats) |
| 4472 | { |
| 4473 | auto broadcastFirst = Float4(Extract(floats, 0)); |
| 4474 | return AnyTrue(CmpNEQ(broadcastFirst, floats)); |
| 4475 | } |
| 4476 | |
| 4477 | RValue<Bool> Uniform(const RValue<Int4> &ints) |
| 4478 | { |
| 4479 | auto broadcastFirst = Int4(Extract(ints, 0)); |
| 4480 | return AllFalse(CmpNEQ(broadcastFirst, ints)); |
| 4481 | } |
| 4482 | |
| 4483 | RValue<Bool> Uniform(const RValue<Float4> &floats) |
| 4484 | { |
| 4485 | auto broadcastFirst = Float4(Extract(floats, 0)); |
| 4486 | return AllFalse(CmpNEQ(broadcastFirst, floats)); |
| 4487 | } |
| 4488 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4489 | void Return() |
| 4490 | { |
| 4491 | Nucleus::createRetVoid(); |
| 4492 | // Place any unreachable instructions in an unreferenced block. |
| 4493 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 4494 | } |
| 4495 | |
| 4496 | void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
| 4497 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4498 | Nucleus::createCondBr(cmp.value(), bodyBB, endBB); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4499 | Nucleus::setInsertBlock(bodyBB); |
| 4500 | } |
| 4501 | |
| 4502 | RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4503 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4504 | 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] | 4505 | } |
| 4506 | |
| 4507 | RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4508 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4509 | 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] | 4510 | } |
| 4511 | |
| 4512 | void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment) |
| 4513 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4514 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4515 | } |
| 4516 | |
| 4517 | void MaskedStore(RValue<Pointer<Int4>> base, RValue<Int4> val, RValue<Int4> mask, unsigned int alignment) |
| 4518 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4519 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4520 | } |
| 4521 | |
| 4522 | void Fence(std::memory_order memoryOrder) |
| 4523 | { |
| 4524 | ASSERT_MSG(memoryOrder == std::memory_order_acquire || |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4525 | memoryOrder == std::memory_order_release || |
| 4526 | memoryOrder == std::memory_order_acq_rel || |
| 4527 | memoryOrder == std::memory_order_seq_cst, |
| 4528 | "Unsupported memoryOrder: %d", int(memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4529 | Nucleus::createFence(memoryOrder); |
| 4530 | } |
| 4531 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4532 | Bool CToReactor<bool>::cast(bool v) |
| 4533 | { |
| 4534 | return type(v); |
| 4535 | } |
| 4536 | Byte CToReactor<uint8_t>::cast(uint8_t v) |
| 4537 | { |
| 4538 | return type(v); |
| 4539 | } |
| 4540 | SByte CToReactor<int8_t>::cast(int8_t v) |
| 4541 | { |
| 4542 | return type(v); |
| 4543 | } |
| 4544 | Short CToReactor<int16_t>::cast(int16_t v) |
| 4545 | { |
| 4546 | return type(v); |
| 4547 | } |
| 4548 | UShort CToReactor<uint16_t>::cast(uint16_t v) |
| 4549 | { |
| 4550 | return type(v); |
| 4551 | } |
| 4552 | Int CToReactor<int32_t>::cast(int32_t v) |
| 4553 | { |
| 4554 | return type(v); |
| 4555 | } |
| 4556 | UInt CToReactor<uint32_t>::cast(uint32_t v) |
| 4557 | { |
| 4558 | return type(v); |
| 4559 | } |
| 4560 | Float CToReactor<float>::cast(float v) |
| 4561 | { |
| 4562 | return type(v); |
| 4563 | } |
| 4564 | Float4 CToReactor<float[4]>::cast(float v[4]) |
| 4565 | { |
| 4566 | return type(v[0], v[1], v[2], v[3]); |
| 4567 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4568 | |
| 4569 | // TODO: Long has no constructor that takes a uint64_t |
| 4570 | // Long CToReactor<uint64_t>::cast(uint64_t v) { return type(v); } |
| 4571 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4572 | #ifdef ENABLE_RR_PRINT |
| 4573 | static std::string replaceAll(std::string str, const std::string &substr, const std::string &replacement) |
| 4574 | { |
| 4575 | size_t pos = 0; |
| 4576 | while((pos = str.find(substr, pos)) != std::string::npos) |
| 4577 | { |
| 4578 | str.replace(pos, substr.length(), replacement); |
| 4579 | pos += replacement.length(); |
| 4580 | } |
| 4581 | return str; |
| 4582 | } |
| 4583 | |
Nicolas Capens | 90fdde3 | 2022-06-27 12:29:57 -0400 | [diff] [blame] | 4584 | // extractAll returns a vector containing the extracted n scalar values of the vector vec. |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4585 | static std::vector<Value *> extractAll(Value *vec, int n) |
| 4586 | { |
| 4587 | Type *elemTy = Nucleus::getContainedType(Nucleus::getType(vec)); |
| 4588 | std::vector<Value *> elements; |
| 4589 | elements.reserve(n); |
| 4590 | for(int i = 0; i < n; i++) |
| 4591 | { |
| 4592 | auto el = Nucleus::createExtractElement(vec, elemTy, i); |
| 4593 | elements.push_back(el); |
| 4594 | } |
| 4595 | return elements; |
| 4596 | } |
| 4597 | |
| 4598 | // toInt returns all the integer values in vals extended to a printf-required storage value |
| 4599 | static std::vector<Value *> toInt(const std::vector<Value *> &vals, bool isSigned) |
| 4600 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4601 | auto storageTy = Nucleus::getPrintfStorageType(Int::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4602 | std::vector<Value *> elements; |
| 4603 | elements.reserve(vals.size()); |
| 4604 | for(auto v : vals) |
| 4605 | { |
| 4606 | if(isSigned) |
| 4607 | { |
| 4608 | elements.push_back(Nucleus::createSExt(v, storageTy)); |
| 4609 | } |
| 4610 | else |
| 4611 | { |
| 4612 | elements.push_back(Nucleus::createZExt(v, storageTy)); |
| 4613 | } |
| 4614 | } |
| 4615 | return elements; |
| 4616 | } |
| 4617 | |
| 4618 | // toFloat returns all the float values in vals extended to extended to a printf-required storage value |
| 4619 | static std::vector<Value *> toFloat(const std::vector<Value *> &vals) |
| 4620 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4621 | auto storageTy = Nucleus::getPrintfStorageType(Float::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4622 | std::vector<Value *> elements; |
| 4623 | elements.reserve(vals.size()); |
| 4624 | for(auto v : vals) |
| 4625 | { |
| 4626 | elements.push_back(Nucleus::createFPExt(v, storageTy)); |
| 4627 | } |
| 4628 | return elements; |
| 4629 | } |
| 4630 | |
| 4631 | std::vector<Value *> PrintValue::Ty<Bool>::val(const RValue<Bool> &v) |
| 4632 | { |
| 4633 | auto t = Nucleus::createConstantString("true"); |
| 4634 | auto f = Nucleus::createConstantString("false"); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4635 | return { Nucleus::createSelect(v.value(), t, f) }; |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4636 | } |
| 4637 | |
| 4638 | std::vector<Value *> PrintValue::Ty<Byte>::val(const RValue<Byte> &v) |
| 4639 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4640 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4641 | } |
| 4642 | |
| 4643 | std::vector<Value *> PrintValue::Ty<Byte4>::val(const RValue<Byte4> &v) |
| 4644 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4645 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4646 | } |
| 4647 | |
| 4648 | std::vector<Value *> PrintValue::Ty<Int>::val(const RValue<Int> &v) |
| 4649 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4650 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4651 | } |
| 4652 | |
| 4653 | std::vector<Value *> PrintValue::Ty<Int2>::val(const RValue<Int2> &v) |
| 4654 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4655 | return toInt(extractAll(v.value(), 2), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4656 | } |
| 4657 | |
| 4658 | std::vector<Value *> PrintValue::Ty<Int4>::val(const RValue<Int4> &v) |
| 4659 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4660 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4661 | } |
| 4662 | |
| 4663 | std::vector<Value *> PrintValue::Ty<UInt>::val(const RValue<UInt> &v) |
| 4664 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4665 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4666 | } |
| 4667 | |
| 4668 | std::vector<Value *> PrintValue::Ty<UInt2>::val(const RValue<UInt2> &v) |
| 4669 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4670 | return toInt(extractAll(v.value(), 2), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4671 | } |
| 4672 | |
| 4673 | std::vector<Value *> PrintValue::Ty<UInt4>::val(const RValue<UInt4> &v) |
| 4674 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4675 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4676 | } |
| 4677 | |
| 4678 | std::vector<Value *> PrintValue::Ty<Short>::val(const RValue<Short> &v) |
| 4679 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4680 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4681 | } |
| 4682 | |
| 4683 | std::vector<Value *> PrintValue::Ty<Short4>::val(const RValue<Short4> &v) |
| 4684 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4685 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4686 | } |
| 4687 | |
| 4688 | std::vector<Value *> PrintValue::Ty<UShort>::val(const RValue<UShort> &v) |
| 4689 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4690 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4691 | } |
| 4692 | |
| 4693 | std::vector<Value *> PrintValue::Ty<UShort4>::val(const RValue<UShort4> &v) |
| 4694 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4695 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4696 | } |
| 4697 | |
| 4698 | std::vector<Value *> PrintValue::Ty<Float>::val(const RValue<Float> &v) |
| 4699 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4700 | return toFloat({ v.value() }); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4701 | } |
| 4702 | |
| 4703 | std::vector<Value *> PrintValue::Ty<Float4>::val(const RValue<Float4> &v) |
| 4704 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4705 | return toFloat(extractAll(v.value(), 4)); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4706 | } |
| 4707 | |
Nicolas Capens | 90fdde3 | 2022-06-27 12:29:57 -0400 | [diff] [blame] | 4708 | std::vector<Value *> PrintValue::Ty<SIMD::Int>::val(const RValue<SIMD::Int> &v) |
| 4709 | { |
| 4710 | return toInt(extractAll(v.value(), SIMD::Width), true); |
| 4711 | } |
| 4712 | |
| 4713 | std::vector<Value *> PrintValue::Ty<SIMD::UInt>::val(const RValue<SIMD::UInt> &v) |
| 4714 | { |
| 4715 | return toInt(extractAll(v.value(), SIMD::Width), false); |
| 4716 | } |
| 4717 | |
| 4718 | std::vector<Value *> PrintValue::Ty<SIMD::Float>::val(const RValue<SIMD::Float> &v) |
| 4719 | { |
| 4720 | return toFloat(extractAll(v.value(), SIMD::Width)); |
| 4721 | } |
| 4722 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4723 | std::vector<Value *> PrintValue::Ty<const char *>::val(const char *v) |
| 4724 | { |
| 4725 | return { Nucleus::createConstantString(v) }; |
| 4726 | } |
| 4727 | |
| 4728 | void Printv(const char *function, const char *file, int line, const char *fmt, std::initializer_list<PrintValue> args) |
| 4729 | { |
| 4730 | // Build the printf format message string. |
| 4731 | std::string str; |
| 4732 | if(file != nullptr) { str += (line > 0) ? "%s:%d " : "%s "; } |
| 4733 | if(function != nullptr) { str += "%s "; } |
| 4734 | str += fmt; |
| 4735 | |
| 4736 | // Perform substitution on all '{n}' bracketed indices in the format |
| 4737 | // message. |
| 4738 | int i = 0; |
| 4739 | for(const PrintValue &arg : args) |
| 4740 | { |
| 4741 | str = replaceAll(str, "{" + std::to_string(i++) + "}", arg.format); |
| 4742 | } |
| 4743 | |
| 4744 | std::vector<Value *> vals; |
| 4745 | vals.reserve(8); |
| 4746 | |
| 4747 | // The format message is always the first argument. |
| 4748 | vals.push_back(Nucleus::createConstantString(str)); |
| 4749 | |
| 4750 | // Add optional file, line and function info if provided. |
| 4751 | if(file != nullptr) |
| 4752 | { |
| 4753 | vals.push_back(Nucleus::createConstantString(file)); |
| 4754 | if(line > 0) |
| 4755 | { |
| 4756 | vals.push_back(Nucleus::createConstantInt(line)); |
| 4757 | } |
| 4758 | } |
| 4759 | if(function != nullptr) |
| 4760 | { |
| 4761 | vals.push_back(Nucleus::createConstantString(function)); |
| 4762 | } |
| 4763 | |
| 4764 | // Add all format arguments. |
| 4765 | for(const PrintValue &arg : args) |
| 4766 | { |
| 4767 | for(auto val : arg.values) |
| 4768 | { |
| 4769 | vals.push_back(val); |
| 4770 | } |
| 4771 | } |
| 4772 | |
| 4773 | // This call is implemented by each backend |
| 4774 | VPrintf(vals); |
| 4775 | } |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 4776 | |
| 4777 | // This is the function that is called by VPrintf from the backends |
| 4778 | int DebugPrintf(const char *format, ...) |
| 4779 | { |
| 4780 | // Uncomment this to make it so that we do not print, but the call to this function is emitted. |
| 4781 | // Useful when debugging emitted code to see the Reactor source location. |
Sean Risser | ee0d0b4 | 2022-04-20 16:27:26 -0400 | [diff] [blame] | 4782 | // # define RR_PRINT_OUTPUT_TYPE_STUB |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 4783 | |
| 4784 | # if defined(RR_PRINT_OUTPUT_TYPE_STUB) |
| 4785 | return 0; |
| 4786 | # else |
| 4787 | |
| 4788 | int result; |
| 4789 | va_list args; |
| 4790 | |
| 4791 | va_start(args, format); |
| 4792 | char buffer[2048]; |
| 4793 | result = vsprintf(buffer, format, args); |
| 4794 | va_end(args); |
| 4795 | |
| 4796 | std::fputs(buffer, stdout); |
| 4797 | # if defined(_WIN32) |
| 4798 | OutputDebugString(buffer); |
| 4799 | # endif |
| 4800 | |
| 4801 | return result; |
| 4802 | # endif |
| 4803 | } |
| 4804 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4805 | #endif // ENABLE_RR_PRINT |
| 4806 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4807 | // Functions implemented by backends |
| 4808 | bool HasRcpApprox(); |
| 4809 | RValue<Float4> RcpApprox(RValue<Float4> x, bool exactAtPow2 = false); |
| 4810 | RValue<Float> RcpApprox(RValue<Float> x, bool exactAtPow2 = false); |
| 4811 | |
| 4812 | template<typename T> |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4813 | static RValue<T> DoRcp(RValue<T> x, bool relaxedPrecision, bool exactAtPow2) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4814 | { |
| 4815 | #if defined(__i386__) || defined(__x86_64__) // On x86, 1/x is fast enough, except for lower precision |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4816 | bool approx = HasRcpApprox() && relaxedPrecision; |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4817 | #else |
| 4818 | bool approx = HasRcpApprox(); |
| 4819 | #endif |
| 4820 | |
| 4821 | T rcp; |
| 4822 | |
| 4823 | if(approx) |
| 4824 | { |
| 4825 | rcp = RcpApprox(x, exactAtPow2); |
| 4826 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4827 | if(!relaxedPrecision) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4828 | { |
| 4829 | // Perform one more iteration of Newton-Rhapson division to increase precision |
| 4830 | rcp = (rcp + rcp) - (x * rcp * rcp); |
| 4831 | } |
| 4832 | } |
| 4833 | else |
| 4834 | { |
| 4835 | rcp = T(1.0f) / x; |
| 4836 | } |
| 4837 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4838 | return rcp; |
| 4839 | } |
| 4840 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4841 | RValue<Float4> Rcp(RValue<Float4> x, bool relaxedPrecision, bool exactAtPow2) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4842 | { |
| 4843 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4844 | return DoRcp(x, relaxedPrecision, exactAtPow2); |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4845 | } |
| 4846 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4847 | RValue<Float> Rcp(RValue<Float> x, bool relaxedPrecision, bool exactAtPow2) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4848 | { |
| 4849 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4850 | return DoRcp(x, relaxedPrecision, exactAtPow2); |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4851 | } |
| 4852 | |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4853 | // Functions implemented by backends |
| 4854 | bool HasRcpSqrtApprox(); |
| 4855 | RValue<Float4> RcpSqrtApprox(RValue<Float4> x); |
| 4856 | RValue<Float> RcpSqrtApprox(RValue<Float> x); |
| 4857 | |
| 4858 | template<typename T> |
| 4859 | struct CastToIntType; |
| 4860 | |
| 4861 | template<> |
| 4862 | struct CastToIntType<Float4> |
| 4863 | { |
| 4864 | using type = Int4; |
| 4865 | }; |
| 4866 | |
| 4867 | template<> |
| 4868 | struct CastToIntType<Float> |
| 4869 | { |
| 4870 | using type = Int; |
| 4871 | }; |
| 4872 | |
| 4873 | // TODO: move to Reactor.hpp? |
| 4874 | RValue<Int> CmpNEQ(RValue<Int> x, RValue<Int> y) |
| 4875 | { |
| 4876 | return IfThenElse(x != y, Int(~0), Int(0)); |
| 4877 | } |
| 4878 | |
| 4879 | template<typename T> |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4880 | static RValue<T> DoRcpSqrt(RValue<T> x, bool relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4881 | { |
| 4882 | #if defined(__i386__) || defined(__x86_64__) // On x86, 1/x is fast enough, except for lower precision |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4883 | bool approx = HasRcpApprox() && relaxedPrecision; |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4884 | #else |
| 4885 | bool approx = HasRcpApprox(); |
| 4886 | #endif |
| 4887 | |
| 4888 | if(approx) |
| 4889 | { |
| 4890 | using IntType = typename CastToIntType<T>::type; |
| 4891 | |
| 4892 | T rsq = RcpSqrtApprox(x); |
| 4893 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4894 | if(!relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4895 | { |
| 4896 | rsq = rsq * (T(3.0f) - rsq * rsq * x) * T(0.5f); |
| 4897 | rsq = As<T>(CmpNEQ(As<IntType>(x), IntType(0x7F800000)) & As<IntType>(rsq)); |
| 4898 | } |
| 4899 | |
| 4900 | return rsq; |
| 4901 | } |
| 4902 | else |
| 4903 | { |
| 4904 | return T(1.0f) / Sqrt(x); |
| 4905 | } |
| 4906 | } |
| 4907 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4908 | RValue<Float4> RcpSqrt(RValue<Float4> x, bool relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4909 | { |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4910 | return DoRcpSqrt(x, relaxedPrecision); |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4911 | } |
| 4912 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4913 | RValue<Float> RcpSqrt(RValue<Float> x, bool relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4914 | { |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4915 | return DoRcpSqrt(x, relaxedPrecision); |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4916 | } |
| 4917 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4918 | } // namespace rr |