Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1 | // Copyright 2019 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #include "Reactor.hpp" |
Nicolas Capens | c7d5ec3 | 2020-04-22 01:11:37 -0400 | [diff] [blame] | 16 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 17 | #include "CPUID.hpp" |
Ben Clayton | b16c586 | 2019-05-08 14:01:38 +0100 | [diff] [blame] | 18 | #include "Debug.hpp" |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 19 | #include "Print.hpp" |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 20 | |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 21 | #if defined(_WIN32) |
| 22 | # ifndef WIN32_LEAN_AND_MEAN |
| 23 | # define WIN32_LEAN_AND_MEAN |
| 24 | # endif |
| 25 | # include <windows.h> |
| 26 | #endif |
| 27 | |
Nicolas Capens | 08c6200 | 2021-11-17 00:25:05 -0500 | [diff] [blame] | 28 | #include <algorithm> |
| 29 | #include <cmath> |
| 30 | |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 31 | // Define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION to non-zero to ensure all |
Nicolas Capens | 70505b4 | 2022-01-31 22:29:48 -0500 | [diff] [blame] | 32 | // variables have a stack location obtained through alloca(). |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 33 | #ifndef REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
| 34 | # define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION 0 |
| 35 | #endif |
| 36 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 37 | namespace rr { |
| 38 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 39 | Config Config::Edit::apply(const Config &cfg) const |
| 40 | { |
Daniele Vettorel | 45f7fdc | 2022-02-04 20:09:08 +0000 | [diff] [blame] | 41 | auto newDebugCfg = debugCfgChanged ? debugCfg : cfg.debugCfg; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 42 | auto level = optLevelChanged ? optLevel : cfg.optimization.getLevel(); |
| 43 | auto passes = cfg.optimization.getPasses(); |
| 44 | apply(optPassEdits, passes); |
Daniele Vettorel | 45f7fdc | 2022-02-04 20:09:08 +0000 | [diff] [blame] | 45 | return Config{ Optimization{ level, passes }, newDebugCfg }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 46 | } |
| 47 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 48 | template<typename T> |
| 49 | void rr::Config::Edit::apply(const std::vector<std::pair<ListEdit, T>> &edits, std::vector<T> &list) const |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 50 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 51 | for(auto &edit : edits) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 52 | { |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 53 | switch(edit.first) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 54 | { |
Nicolas Capens | 112faf4 | 2019-12-13 17:32:26 -0500 | [diff] [blame] | 55 | case ListEdit::Add: |
| 56 | list.push_back(edit.second); |
| 57 | break; |
| 58 | case ListEdit::Remove: |
| 59 | list.erase(std::remove_if(list.begin(), list.end(), [&](T item) { |
| 60 | return item == edit.second; |
| 61 | }), |
| 62 | list.end()); |
| 63 | break; |
| 64 | case ListEdit::Clear: |
| 65 | list.clear(); |
| 66 | break; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 67 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 71 | thread_local Variable::UnmaterializedVariables *Variable::unmaterializedVariables = nullptr; |
| 72 | |
| 73 | void Variable::UnmaterializedVariables::add(const Variable *v) |
| 74 | { |
| 75 | variables.emplace(v, counter++); |
| 76 | } |
| 77 | |
| 78 | void Variable::UnmaterializedVariables::remove(const Variable *v) |
| 79 | { |
| 80 | auto iter = variables.find(v); |
| 81 | if(iter != variables.end()) |
| 82 | { |
| 83 | variables.erase(iter); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | void Variable::UnmaterializedVariables::clear() |
| 88 | { |
| 89 | variables.clear(); |
| 90 | } |
| 91 | |
| 92 | void Variable::UnmaterializedVariables::materializeAll() |
| 93 | { |
| 94 | // Flatten map of Variable* to monotonically increasing counter to a vector, |
| 95 | // then sort it by the counter, so that we materialize in variable usage order. |
| 96 | std::vector<std::pair<const Variable *, int>> sorted; |
| 97 | sorted.resize(variables.size()); |
| 98 | std::copy(variables.begin(), variables.end(), sorted.begin()); |
| 99 | std::sort(sorted.begin(), sorted.end(), [&](auto &lhs, auto &rhs) { |
| 100 | return lhs.second < rhs.second; |
| 101 | }); |
| 102 | |
| 103 | for(auto &v : sorted) |
| 104 | { |
| 105 | v.first->materialize(); |
| 106 | } |
| 107 | |
| 108 | variables.clear(); |
| 109 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 110 | |
Antonio Maiorano | bae138d | 2020-12-02 14:25:10 -0500 | [diff] [blame] | 111 | Variable::Variable(Type *type, int arraySize) |
| 112 | : type(type) |
| 113 | , arraySize(arraySize) |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 114 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 115 | #if REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
| 116 | materialize(); |
| 117 | #else |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 118 | unmaterializedVariables->add(this); |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 119 | #endif |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 120 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 121 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 122 | Variable::~Variable() |
| 123 | { |
Nicolas Capens | 3d26cfc | 2021-01-22 16:51:00 -0500 | [diff] [blame] | 124 | // `unmaterializedVariables` can be null at this point due to the function |
| 125 | // already having been finalized, while classes derived from `Function<>` |
| 126 | // can have member `Variable` fields which are destructed afterwards. |
| 127 | if(unmaterializedVariables) |
| 128 | { |
| 129 | unmaterializedVariables->remove(this); |
| 130 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 131 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 132 | |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 133 | void Variable::materialize() const |
| 134 | { |
| 135 | if(!address) |
| 136 | { |
Antonio Maiorano | 84c61e1 | 2020-12-02 12:06:05 -0500 | [diff] [blame] | 137 | address = Nucleus::allocateStackVariable(getType(), arraySize); |
Nicolas Capens | 471c120 | 2020-05-28 09:58:46 -0400 | [diff] [blame] | 138 | RR_DEBUG_INFO_EMIT_VAR(address); |
| 139 | |
| 140 | if(rvalue) |
| 141 | { |
| 142 | storeValue(rvalue); |
| 143 | rvalue = nullptr; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | Value *Variable::loadValue() const |
| 149 | { |
| 150 | if(rvalue) |
| 151 | { |
| 152 | return rvalue; |
| 153 | } |
| 154 | |
| 155 | if(!address) |
| 156 | { |
| 157 | // TODO: Return undef instead. |
| 158 | materialize(); |
| 159 | } |
| 160 | |
| 161 | return Nucleus::createLoad(address, getType(), false, 0); |
| 162 | } |
| 163 | |
| 164 | Value *Variable::storeValue(Value *value) const |
| 165 | { |
| 166 | if(address) |
| 167 | { |
| 168 | return Nucleus::createStore(value, address, getType(), false, 0); |
| 169 | } |
| 170 | |
| 171 | rvalue = value; |
| 172 | |
| 173 | return value; |
| 174 | } |
| 175 | |
| 176 | Value *Variable::getBaseAddress() const |
| 177 | { |
| 178 | materialize(); |
| 179 | |
| 180 | return address; |
| 181 | } |
| 182 | |
| 183 | Value *Variable::getElementPointer(Value *index, bool unsignedIndex) const |
| 184 | { |
| 185 | return Nucleus::createGEP(getBaseAddress(), getType(), index, unsignedIndex); |
| 186 | } |
| 187 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 188 | void Variable::materializeAll() |
| 189 | { |
Antonio Maiorano | f14f6c4 | 2020-11-03 16:34:35 -0500 | [diff] [blame] | 190 | unmaterializedVariables->materializeAll(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 191 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 192 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 193 | void Variable::killUnmaterialized() |
| 194 | { |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 195 | unmaterializedVariables->clear(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 196 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 197 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 198 | // NOTE: Only 12 bits out of 16 of the |select| value are used. |
| 199 | // More specifically, the value should look like: |
| 200 | // |
| 201 | // msb lsb |
| 202 | // v v |
| 203 | // [.xxx|.yyy|.zzz|.www] where '.' means an ignored bit |
| 204 | // |
| 205 | // This format makes it easy to write calls with hexadecimal select values, |
| 206 | // since each hex digit is a separate swizzle index. |
| 207 | // |
| 208 | // For example: |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 209 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x0123 ) -> [a,b,c,d] |
| 210 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x4567 ) -> [e,f,g,h] |
| 211 | // 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] | 212 | // |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 213 | static Value *createShuffle4(Value *lhs, Value *rhs, uint16_t select) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 214 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 215 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 216 | (select >> 12) & 0x07, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 217 | (select >> 8) & 0x07, |
| 218 | (select >> 4) & 0x07, |
| 219 | (select >> 0) & 0x07, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 220 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 221 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 222 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 223 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 224 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 225 | // NOTE: Only 8 bits out of 16 of the |select| value are used. |
| 226 | // More specifically, the value should look like: |
| 227 | // |
| 228 | // msb lsb |
| 229 | // v v |
| 230 | // [..xx|..yy|..zz|..ww] where '.' means an ignored bit |
| 231 | // |
| 232 | // This format makes it easy to write calls with hexadecimal select values, |
| 233 | // since each hex digit is a separate swizzle index. |
| 234 | // |
| 235 | // For example: |
| 236 | // createSwizzle4( [a,b,c,d], 0x0123 ) -> [a,b,c,d] |
| 237 | // createSwizzle4( [a,b,c,d], 0x0033 ) -> [a,a,d,d] |
| 238 | // |
| 239 | static Value *createSwizzle4(Value *val, uint16_t select) |
| 240 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 241 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 242 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 243 | (select >> 8) & 0x03, |
| 244 | (select >> 4) & 0x03, |
| 245 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 246 | }; |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 247 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 248 | return Nucleus::createShuffleVector(val, val, swizzle); |
| 249 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 251 | static Value *createMask4(Value *lhs, Value *rhs, uint16_t select) |
| 252 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 253 | bool mask[4] = { false, false, false, false }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 254 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 255 | mask[(select >> 12) & 0x03] = true; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 256 | mask[(select >> 8) & 0x03] = true; |
| 257 | mask[(select >> 4) & 0x03] = true; |
| 258 | mask[(select >> 0) & 0x03] = true; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 259 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 260 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 261 | mask[0] ? 4 : 0, |
| 262 | mask[1] ? 5 : 1, |
| 263 | mask[2] ? 6 : 2, |
| 264 | mask[3] ? 7 : 3, |
| 265 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 266 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 267 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 268 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 269 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 270 | Bool::Bool(Argument<Bool> argument) |
| 271 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 272 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 273 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 274 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 275 | Bool::Bool(bool x) |
| 276 | { |
| 277 | storeValue(Nucleus::createConstantBool(x)); |
| 278 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 279 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 280 | Bool::Bool(RValue<Bool> rhs) |
| 281 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 282 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 283 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 284 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 285 | Bool::Bool(const Bool &rhs) |
| 286 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 287 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 288 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 289 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 290 | Bool::Bool(const Reference<Bool> &rhs) |
| 291 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 292 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 293 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 294 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 295 | RValue<Bool> Bool::operator=(RValue<Bool> rhs) |
| 296 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 297 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 298 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 299 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 300 | RValue<Bool> Bool::operator=(const Bool &rhs) |
| 301 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 302 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 303 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 304 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 305 | RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) |
| 306 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 307 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 308 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 309 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 310 | RValue<Bool> operator!(RValue<Bool> val) |
| 311 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 312 | return RValue<Bool>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 313 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 314 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 315 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) |
| 316 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 317 | return RValue<Bool>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 318 | } |
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 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) |
| 321 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 322 | return RValue<Bool>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 323 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 324 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 325 | RValue<Bool> operator!=(RValue<Bool> lhs, RValue<Bool> rhs) |
| 326 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 327 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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 | RValue<Bool> operator==(RValue<Bool> lhs, RValue<Bool> rhs) |
| 331 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 332 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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(Argument<Byte> argument) |
| 336 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 337 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 338 | } |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 339 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 340 | Byte::Byte(RValue<Int> cast) |
| 341 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 342 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 343 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 344 | storeValue(integer); |
| 345 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 346 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 347 | Byte::Byte(RValue<UInt> cast) |
| 348 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 349 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 350 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 351 | storeValue(integer); |
| 352 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 353 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 354 | Byte::Byte(RValue<UShort> cast) |
| 355 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 356 | Value *integer = Nucleus::createTrunc(cast.value(), Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 357 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 358 | storeValue(integer); |
| 359 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 360 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 361 | Byte::Byte(int x) |
| 362 | { |
| 363 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
| 364 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 365 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 366 | Byte::Byte(unsigned char x) |
| 367 | { |
| 368 | storeValue(Nucleus::createConstantByte(x)); |
| 369 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 370 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 371 | Byte::Byte(RValue<Byte> rhs) |
| 372 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 373 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 374 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 375 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 376 | Byte::Byte(const Byte &rhs) |
| 377 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 378 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 379 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 380 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 381 | Byte::Byte(const Reference<Byte> &rhs) |
| 382 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 383 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 384 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 385 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 386 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) |
| 387 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 388 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 389 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 390 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 391 | RValue<Byte> Byte::operator=(const Byte &rhs) |
| 392 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 393 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 394 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 395 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 396 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) |
| 397 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 398 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 399 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 400 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 401 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
| 402 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 403 | return RValue<Byte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 404 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 405 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 406 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
| 407 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 408 | return RValue<Byte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 409 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 410 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 411 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
| 412 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 413 | return RValue<Byte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 414 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 415 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 416 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
| 417 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 418 | return RValue<Byte>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 419 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 420 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 421 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
| 422 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 423 | return RValue<Byte>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 424 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 425 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 426 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
| 427 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 428 | return RValue<Byte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 429 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 430 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 431 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
| 432 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 433 | return RValue<Byte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 434 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 435 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 436 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
| 437 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 438 | return RValue<Byte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 439 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 440 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 441 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 442 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 443 | return RValue<Byte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 444 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 445 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 446 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 447 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 448 | return RValue<Byte>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 449 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 450 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 451 | RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs) |
| 452 | { |
| 453 | return lhs = lhs + rhs; |
| 454 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 455 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 456 | RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs) |
| 457 | { |
| 458 | return lhs = lhs - rhs; |
| 459 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 460 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 461 | RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs) |
| 462 | { |
| 463 | return lhs = lhs * rhs; |
| 464 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 465 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 466 | RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs) |
| 467 | { |
| 468 | return lhs = lhs / rhs; |
| 469 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 470 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 471 | RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs) |
| 472 | { |
| 473 | return lhs = lhs % rhs; |
| 474 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 475 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 476 | RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs) |
| 477 | { |
| 478 | return lhs = lhs & rhs; |
| 479 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 480 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 481 | RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs) |
| 482 | { |
| 483 | return lhs = lhs | rhs; |
| 484 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 485 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 486 | RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs) |
| 487 | { |
| 488 | return lhs = lhs ^ rhs; |
| 489 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 490 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 491 | RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs) |
| 492 | { |
| 493 | return lhs = lhs << rhs; |
| 494 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 495 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 496 | RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs) |
| 497 | { |
| 498 | return lhs = lhs >> rhs; |
| 499 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 500 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 501 | RValue<Byte> operator+(RValue<Byte> val) |
| 502 | { |
| 503 | return val; |
| 504 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 505 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 506 | RValue<Byte> operator-(RValue<Byte> val) |
| 507 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 508 | return RValue<Byte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 509 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 510 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 511 | RValue<Byte> operator~(RValue<Byte> val) |
| 512 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 513 | return RValue<Byte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 514 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 515 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 516 | RValue<Byte> operator++(Byte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 517 | { |
| 518 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 519 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 520 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 521 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 522 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 523 | return res; |
| 524 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 525 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 526 | const Byte &operator++(Byte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 527 | { |
| 528 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 529 | val.storeValue(inc); |
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 | return val; |
| 532 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 533 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 534 | RValue<Byte> operator--(Byte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 535 | { |
| 536 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 537 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 538 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((unsigned char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 539 | val.storeValue(inc); |
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 | return res; |
| 542 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 543 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 544 | const Byte &operator--(Byte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 545 | { |
| 546 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 547 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 548 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 549 | return val; |
| 550 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 551 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 552 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 553 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 554 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 555 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 556 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 557 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 558 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 559 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 560 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 561 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 562 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 563 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 564 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 565 | } |
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 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 568 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 569 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 570 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 571 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 572 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 573 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 574 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 575 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 576 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 577 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
| 578 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 579 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 580 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 581 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 582 | SByte::SByte(Argument<SByte> argument) |
| 583 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 584 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 585 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 586 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 587 | SByte::SByte(RValue<Int> cast) |
| 588 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 589 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 590 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 591 | storeValue(integer); |
| 592 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 593 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 594 | SByte::SByte(RValue<Short> cast) |
| 595 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 596 | Value *integer = Nucleus::createTrunc(cast.value(), SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 597 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 598 | storeValue(integer); |
| 599 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 600 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 601 | SByte::SByte(signed char x) |
| 602 | { |
| 603 | storeValue(Nucleus::createConstantByte(x)); |
| 604 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 605 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 606 | SByte::SByte(RValue<SByte> rhs) |
| 607 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 608 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 609 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 610 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 611 | SByte::SByte(const SByte &rhs) |
| 612 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 613 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 614 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 615 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 616 | SByte::SByte(const Reference<SByte> &rhs) |
| 617 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 618 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 619 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 620 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 621 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) |
| 622 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 623 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 624 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 625 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 626 | RValue<SByte> SByte::operator=(const SByte &rhs) |
| 627 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 628 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 629 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 630 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 631 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) |
| 632 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 633 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 634 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 635 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 636 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
| 637 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 638 | return RValue<SByte>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 639 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 640 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 641 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
| 642 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 643 | return RValue<SByte>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 644 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 645 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 646 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
| 647 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 648 | return RValue<SByte>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 649 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 650 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 651 | RValue<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
| 652 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 653 | return RValue<SByte>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 654 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 655 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 656 | RValue<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) |
| 657 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 658 | return RValue<SByte>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 659 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 660 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 661 | RValue<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) |
| 662 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 663 | return RValue<SByte>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 664 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 665 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 666 | RValue<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) |
| 667 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 668 | return RValue<SByte>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 669 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 670 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 671 | RValue<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) |
| 672 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 673 | return RValue<SByte>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 674 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 675 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 676 | RValue<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 677 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 678 | return RValue<SByte>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 679 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 680 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 681 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 682 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 683 | return RValue<SByte>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 684 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 685 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 686 | RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs) |
| 687 | { |
| 688 | return lhs = lhs + rhs; |
| 689 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 690 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 691 | RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs) |
| 692 | { |
| 693 | return lhs = lhs - rhs; |
| 694 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 695 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 696 | RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs) |
| 697 | { |
| 698 | return lhs = lhs * rhs; |
| 699 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 700 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 701 | RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs) |
| 702 | { |
| 703 | return lhs = lhs / rhs; |
| 704 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 705 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 706 | RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs) |
| 707 | { |
| 708 | return lhs = lhs % rhs; |
| 709 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 710 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 711 | RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs) |
| 712 | { |
| 713 | return lhs = lhs & rhs; |
| 714 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 715 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 716 | RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs) |
| 717 | { |
| 718 | return lhs = lhs | rhs; |
| 719 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 720 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 721 | RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs) |
| 722 | { |
| 723 | return lhs = lhs ^ rhs; |
| 724 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 725 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 726 | RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs) |
| 727 | { |
| 728 | return lhs = lhs << rhs; |
| 729 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 730 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 731 | RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs) |
| 732 | { |
| 733 | return lhs = lhs >> rhs; |
| 734 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 735 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 736 | RValue<SByte> operator+(RValue<SByte> val) |
| 737 | { |
| 738 | return val; |
| 739 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 740 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 741 | RValue<SByte> operator-(RValue<SByte> val) |
| 742 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 743 | return RValue<SByte>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 744 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 745 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 746 | RValue<SByte> operator~(RValue<SByte> val) |
| 747 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 748 | return RValue<SByte>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 749 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 750 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 751 | RValue<SByte> operator++(SByte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 752 | { |
| 753 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 754 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 755 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 756 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 757 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 758 | return res; |
| 759 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 760 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 761 | const SByte &operator++(SByte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 762 | { |
| 763 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 764 | val.storeValue(inc); |
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 | return val; |
| 767 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 768 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 769 | RValue<SByte> operator--(SByte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 770 | { |
| 771 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 772 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 773 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantByte((signed char)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 774 | val.storeValue(inc); |
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 | return res; |
| 777 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 778 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 779 | const SByte &operator--(SByte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 780 | { |
| 781 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 782 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 783 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 784 | return val; |
| 785 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 786 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 787 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 788 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 789 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 790 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 791 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 792 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 793 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 794 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 795 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 796 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 797 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 798 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 799 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 800 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 801 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 802 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 803 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 804 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 805 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 806 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 807 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 808 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 809 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 810 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 811 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 812 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) |
| 813 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 814 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 815 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 816 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 817 | Short::Short(Argument<Short> argument) |
| 818 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 819 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 820 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 821 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 822 | Short::Short(RValue<Int> cast) |
| 823 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 824 | Value *integer = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 825 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 826 | storeValue(integer); |
| 827 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 828 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 829 | Short::Short(short x) |
| 830 | { |
| 831 | storeValue(Nucleus::createConstantShort(x)); |
| 832 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 833 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 834 | Short::Short(RValue<Short> rhs) |
| 835 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 836 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 837 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 838 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 839 | Short::Short(const Short &rhs) |
| 840 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 841 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 842 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 843 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 844 | Short::Short(const Reference<Short> &rhs) |
| 845 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 846 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 847 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 848 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 849 | RValue<Short> Short::operator=(RValue<Short> rhs) |
| 850 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 851 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 852 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 853 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 854 | RValue<Short> Short::operator=(const Short &rhs) |
| 855 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 856 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 857 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 858 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 859 | RValue<Short> Short::operator=(const Reference<Short> &rhs) |
| 860 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 861 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 862 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 863 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 864 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
| 865 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 866 | return RValue<Short>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 867 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 868 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 869 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
| 870 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 871 | return RValue<Short>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 872 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 873 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 874 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
| 875 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 876 | return RValue<Short>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 877 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 878 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 879 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
| 880 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 881 | return RValue<Short>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 882 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 883 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 884 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) |
| 885 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 886 | return RValue<Short>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 887 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 888 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 889 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) |
| 890 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 891 | return RValue<Short>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 892 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 893 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 894 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) |
| 895 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 896 | return RValue<Short>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 897 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 898 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 899 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) |
| 900 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 901 | return RValue<Short>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 902 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 903 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 904 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) |
| 905 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 906 | return RValue<Short>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 907 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 908 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 909 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) |
| 910 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 911 | return RValue<Short>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 912 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 913 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 914 | RValue<Short> operator+=(Short &lhs, RValue<Short> rhs) |
| 915 | { |
| 916 | return lhs = lhs + rhs; |
| 917 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 918 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 919 | RValue<Short> operator-=(Short &lhs, RValue<Short> rhs) |
| 920 | { |
| 921 | return lhs = lhs - rhs; |
| 922 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 923 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 924 | RValue<Short> operator*=(Short &lhs, RValue<Short> rhs) |
| 925 | { |
| 926 | return lhs = lhs * rhs; |
| 927 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 928 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 929 | RValue<Short> operator/=(Short &lhs, RValue<Short> rhs) |
| 930 | { |
| 931 | return lhs = lhs / rhs; |
| 932 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 933 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 934 | RValue<Short> operator%=(Short &lhs, RValue<Short> rhs) |
| 935 | { |
| 936 | return lhs = lhs % rhs; |
| 937 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 938 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 939 | RValue<Short> operator&=(Short &lhs, RValue<Short> rhs) |
| 940 | { |
| 941 | return lhs = lhs & rhs; |
| 942 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 943 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 944 | RValue<Short> operator|=(Short &lhs, RValue<Short> rhs) |
| 945 | { |
| 946 | return lhs = lhs | rhs; |
| 947 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 948 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 949 | RValue<Short> operator^=(Short &lhs, RValue<Short> rhs) |
| 950 | { |
| 951 | return lhs = lhs ^ rhs; |
| 952 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 953 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 954 | RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs) |
| 955 | { |
| 956 | return lhs = lhs << rhs; |
| 957 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 958 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 959 | RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs) |
| 960 | { |
| 961 | return lhs = lhs >> rhs; |
| 962 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 963 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 964 | RValue<Short> operator+(RValue<Short> val) |
| 965 | { |
| 966 | return val; |
| 967 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 968 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 969 | RValue<Short> operator-(RValue<Short> val) |
| 970 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 971 | return RValue<Short>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 972 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 973 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 974 | RValue<Short> operator~(RValue<Short> val) |
| 975 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 976 | return RValue<Short>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 977 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 978 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 979 | RValue<Short> operator++(Short &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 980 | { |
| 981 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 982 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 983 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 984 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 985 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 986 | return res; |
| 987 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 988 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 989 | const Short &operator++(Short &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 990 | { |
| 991 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 992 | val.storeValue(inc); |
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 | return val; |
| 995 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 996 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 997 | RValue<Short> operator--(Short &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 998 | { |
| 999 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1000 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1001 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1002 | val.storeValue(inc); |
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 | return res; |
| 1005 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1006 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1007 | const Short &operator--(Short &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1008 | { |
| 1009 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 1010 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1011 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1012 | return val; |
| 1013 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1014 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1015 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
| 1016 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1017 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1018 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1019 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1020 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
| 1021 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1022 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1023 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1024 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1025 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
| 1026 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1027 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1028 | } |
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 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
| 1031 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1032 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1033 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1034 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1035 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) |
| 1036 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1037 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1038 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1039 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1040 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) |
| 1041 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1042 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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(Argument<UShort> argument) |
| 1046 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1047 | store(argument.rvalue()); |
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(RValue<UInt> cast) |
| 1051 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1052 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1053 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1054 | storeValue(integer); |
| 1055 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1056 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1057 | UShort::UShort(RValue<Int> cast) |
| 1058 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1059 | Value *integer = Nucleus::createTrunc(cast.value(), UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1060 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1061 | storeValue(integer); |
| 1062 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1063 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1064 | UShort::UShort(unsigned short x) |
| 1065 | { |
| 1066 | storeValue(Nucleus::createConstantShort(x)); |
| 1067 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1068 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1069 | UShort::UShort(RValue<UShort> rhs) |
| 1070 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1071 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1072 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1073 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1074 | UShort::UShort(const UShort &rhs) |
| 1075 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1076 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1077 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1078 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1079 | UShort::UShort(const Reference<UShort> &rhs) |
| 1080 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1081 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1082 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1083 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1084 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) |
| 1085 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1086 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1087 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1088 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1089 | RValue<UShort> UShort::operator=(const UShort &rhs) |
| 1090 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1091 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1092 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1093 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1094 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) |
| 1095 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1096 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1097 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1098 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1099 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1100 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1101 | return RValue<UShort>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1102 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1103 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1104 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1105 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1106 | return RValue<UShort>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1107 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1108 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1109 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1110 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1111 | return RValue<UShort>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1112 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1113 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1114 | RValue<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1115 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1116 | return RValue<UShort>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1117 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1118 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1119 | RValue<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1120 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1121 | return RValue<UShort>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1122 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1123 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1124 | RValue<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1125 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1126 | return RValue<UShort>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1127 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1128 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1129 | RValue<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1130 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1131 | return RValue<UShort>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1132 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1133 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1134 | RValue<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1135 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1136 | return RValue<UShort>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1137 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1138 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1139 | RValue<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1140 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1141 | return RValue<UShort>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1142 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1143 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1144 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1145 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1146 | return RValue<UShort>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1147 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1148 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1149 | RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs) |
| 1150 | { |
| 1151 | return lhs = lhs + rhs; |
| 1152 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1153 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1154 | RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs) |
| 1155 | { |
| 1156 | return lhs = lhs - rhs; |
| 1157 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1158 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1159 | RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs) |
| 1160 | { |
| 1161 | return lhs = lhs * rhs; |
| 1162 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1163 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1164 | RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs) |
| 1165 | { |
| 1166 | return lhs = lhs / rhs; |
| 1167 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1168 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1169 | RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs) |
| 1170 | { |
| 1171 | return lhs = lhs % rhs; |
| 1172 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1173 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1174 | RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs) |
| 1175 | { |
| 1176 | return lhs = lhs & rhs; |
| 1177 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1178 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1179 | RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs) |
| 1180 | { |
| 1181 | return lhs = lhs | rhs; |
| 1182 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1183 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1184 | RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs) |
| 1185 | { |
| 1186 | return lhs = lhs ^ rhs; |
| 1187 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1188 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1189 | RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs) |
| 1190 | { |
| 1191 | return lhs = lhs << rhs; |
| 1192 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1193 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1194 | RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs) |
| 1195 | { |
| 1196 | return lhs = lhs >> rhs; |
| 1197 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1198 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1199 | RValue<UShort> operator+(RValue<UShort> val) |
| 1200 | { |
| 1201 | return val; |
| 1202 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1203 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1204 | RValue<UShort> operator-(RValue<UShort> val) |
| 1205 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1206 | return RValue<UShort>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1207 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1208 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1209 | RValue<UShort> operator~(RValue<UShort> val) |
| 1210 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1211 | return RValue<UShort>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1212 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1213 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1214 | RValue<UShort> operator++(UShort &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1215 | { |
| 1216 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1217 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1218 | Value *inc = Nucleus::createAdd(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1219 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1220 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1221 | return res; |
| 1222 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1223 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1224 | const UShort &operator++(UShort &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1225 | { |
| 1226 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1227 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1228 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1229 | return val; |
| 1230 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1231 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1232 | RValue<UShort> operator--(UShort &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1233 | { |
| 1234 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1235 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1236 | Value *inc = Nucleus::createSub(res.value(), Nucleus::createConstantShort((unsigned short)1)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1237 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1238 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1239 | return res; |
| 1240 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1241 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1242 | const UShort &operator--(UShort &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1243 | { |
| 1244 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1245 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1246 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1247 | return val; |
| 1248 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1249 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1250 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1251 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1252 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1253 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1254 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1255 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1256 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1257 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1258 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1259 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1260 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1261 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1262 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1263 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1264 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1265 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1266 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1267 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1268 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1269 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1270 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1271 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1272 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1273 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1274 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1275 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1276 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1277 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1278 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1279 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1280 | Byte4::Byte4(RValue<Byte8> cast) |
| 1281 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1282 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1283 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1284 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1285 | Byte4::Byte4(RValue<UShort4> cast) |
| 1286 | { |
| 1287 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1288 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1289 | } |
| 1290 | |
| 1291 | Byte4::Byte4(RValue<Short4> cast) |
| 1292 | { |
| 1293 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1294 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1295 | } |
| 1296 | |
| 1297 | Byte4::Byte4(RValue<UInt4> cast) |
| 1298 | { |
| 1299 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1300 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1301 | } |
| 1302 | |
| 1303 | Byte4::Byte4(RValue<Int4> cast) |
| 1304 | { |
| 1305 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1306 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1307 | } |
| 1308 | |
| 1309 | Byte4::Byte4(RValue<Byte4> rhs) |
| 1310 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1311 | store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1312 | } |
| 1313 | |
| 1314 | Byte4::Byte4(const Byte4 &rhs) |
| 1315 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1316 | store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1317 | } |
| 1318 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1319 | Byte4::Byte4(const Reference<Byte4> &rhs) |
| 1320 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1321 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1322 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1323 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1324 | RValue<Byte4> Byte4::operator=(RValue<Byte4> rhs) |
| 1325 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1326 | return store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1327 | } |
| 1328 | |
| 1329 | RValue<Byte4> Byte4::operator=(const Byte4 &rhs) |
| 1330 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1331 | return store(rhs.load()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1332 | } |
| 1333 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1334 | 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) |
| 1335 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1336 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1337 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1338 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1339 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1340 | Byte8::Byte8(RValue<Byte8> rhs) |
| 1341 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1342 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1343 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1344 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1345 | Byte8::Byte8(const Byte8 &rhs) |
| 1346 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1347 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1348 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1349 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1350 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 1351 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1352 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1353 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1354 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1355 | RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) |
| 1356 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1357 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1358 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1359 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1360 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) |
| 1361 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1362 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1363 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1364 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1365 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) |
| 1366 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1367 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1368 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1369 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1370 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1371 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1372 | return RValue<Byte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1373 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1374 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1375 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1376 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1377 | return RValue<Byte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1378 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1379 | |
| 1380 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1381 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1382 | // return RValue<Byte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1383 | // } |
| 1384 | |
| 1385 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1386 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1387 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1388 | // } |
| 1389 | |
| 1390 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1391 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1392 | // return RValue<Byte8>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1393 | // } |
| 1394 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1395 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1396 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1397 | return RValue<Byte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1398 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1399 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1400 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1401 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1402 | return RValue<Byte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1403 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1404 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1405 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1406 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1407 | return RValue<Byte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1408 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1409 | |
| 1410 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
| 1411 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1412 | // return RValue<Byte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1413 | // } |
| 1414 | |
| 1415 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
| 1416 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1417 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1418 | // } |
| 1419 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1420 | RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1421 | { |
| 1422 | return lhs = lhs + rhs; |
| 1423 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1424 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1425 | RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1426 | { |
| 1427 | return lhs = lhs - rhs; |
| 1428 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1429 | |
| 1430 | // RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1431 | // { |
| 1432 | // return lhs = lhs * rhs; |
| 1433 | // } |
| 1434 | |
| 1435 | // RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1436 | // { |
| 1437 | // return lhs = lhs / rhs; |
| 1438 | // } |
| 1439 | |
| 1440 | // RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1441 | // { |
| 1442 | // return lhs = lhs % rhs; |
| 1443 | // } |
| 1444 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1445 | RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1446 | { |
| 1447 | return lhs = lhs & rhs; |
| 1448 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1449 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1450 | RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1451 | { |
| 1452 | return lhs = lhs | rhs; |
| 1453 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1454 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1455 | RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1456 | { |
| 1457 | return lhs = lhs ^ rhs; |
| 1458 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1459 | |
| 1460 | // RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1461 | // { |
| 1462 | // return lhs = lhs << rhs; |
| 1463 | // } |
| 1464 | |
| 1465 | // RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1466 | // { |
| 1467 | // return lhs = lhs >> rhs; |
| 1468 | // } |
| 1469 | |
| 1470 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 1471 | // { |
| 1472 | // return val; |
| 1473 | // } |
| 1474 | |
| 1475 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 1476 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1477 | // return RValue<Byte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1478 | // } |
| 1479 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1480 | RValue<Byte8> operator~(RValue<Byte8> val) |
| 1481 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1482 | return RValue<Byte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1483 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1484 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1485 | RValue<Byte8> Swizzle(RValue<Byte8> x, uint32_t select) |
| 1486 | { |
| 1487 | // Real type is v16i8 |
| 1488 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1489 | int shuffle[16] = { |
| 1490 | static_cast<int>((select >> 28) & 0x07), |
| 1491 | static_cast<int>((select >> 24) & 0x07), |
| 1492 | static_cast<int>((select >> 20) & 0x07), |
| 1493 | static_cast<int>((select >> 16) & 0x07), |
| 1494 | static_cast<int>((select >> 12) & 0x07), |
| 1495 | static_cast<int>((select >> 8) & 0x07), |
| 1496 | static_cast<int>((select >> 4) & 0x07), |
| 1497 | static_cast<int>((select >> 0) & 0x07), |
| 1498 | static_cast<int>((select >> 28) & 0x07), |
| 1499 | static_cast<int>((select >> 24) & 0x07), |
| 1500 | static_cast<int>((select >> 20) & 0x07), |
| 1501 | static_cast<int>((select >> 16) & 0x07), |
| 1502 | static_cast<int>((select >> 12) & 0x07), |
| 1503 | static_cast<int>((select >> 8) & 0x07), |
| 1504 | static_cast<int>((select >> 4) & 0x07), |
| 1505 | static_cast<int>((select >> 0) & 0x07), |
| 1506 | }; |
| 1507 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1508 | return As<Byte8>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1509 | } |
| 1510 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1511 | RValue<Short4> Unpack(RValue<Byte4> x) |
| 1512 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1513 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1514 | int shuffle[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1515 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1516 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1517 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1518 | RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y) |
| 1519 | { |
| 1520 | return UnpackLow(As<Byte8>(x), As<Byte8>(y)); |
| 1521 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1522 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1523 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 1524 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1525 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1526 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1527 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1528 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1529 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1530 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
| 1531 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1532 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1533 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1534 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1535 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1536 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1537 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1538 | 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) |
| 1539 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1540 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1541 | Value *vector = Nucleus::createConstantVector(constantVector, type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1542 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1543 | storeValue(Nucleus::createBitCast(vector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1544 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1545 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1546 | SByte8::SByte8(RValue<SByte8> rhs) |
| 1547 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1548 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1549 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1550 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1551 | SByte8::SByte8(const SByte8 &rhs) |
| 1552 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1553 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1554 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1555 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1556 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 1557 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1558 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1559 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1560 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1561 | RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) |
| 1562 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1563 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1564 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1565 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1566 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) |
| 1567 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1568 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1569 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1570 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1571 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) |
| 1572 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1573 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1574 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1575 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1576 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1577 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1578 | return RValue<SByte8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1579 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1580 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1581 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1582 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1583 | return RValue<SByte8>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1584 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1585 | |
| 1586 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1587 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1588 | // return RValue<SByte8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1589 | // } |
| 1590 | |
| 1591 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1592 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1593 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1594 | // } |
| 1595 | |
| 1596 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1597 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1598 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1599 | // } |
| 1600 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1601 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1602 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1603 | return RValue<SByte8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1604 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1605 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1606 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1607 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1608 | return RValue<SByte8>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1609 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1610 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1611 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1612 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1613 | return RValue<SByte8>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1614 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1615 | |
| 1616 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
| 1617 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1618 | // return RValue<SByte8>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1619 | // } |
| 1620 | |
| 1621 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
| 1622 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1623 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1624 | // } |
| 1625 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1626 | RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1627 | { |
| 1628 | return lhs = lhs + rhs; |
| 1629 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1630 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1631 | RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1632 | { |
| 1633 | return lhs = lhs - rhs; |
| 1634 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1635 | |
| 1636 | // RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1637 | // { |
| 1638 | // return lhs = lhs * rhs; |
| 1639 | // } |
| 1640 | |
| 1641 | // RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1642 | // { |
| 1643 | // return lhs = lhs / rhs; |
| 1644 | // } |
| 1645 | |
| 1646 | // RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1647 | // { |
| 1648 | // return lhs = lhs % rhs; |
| 1649 | // } |
| 1650 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1651 | RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1652 | { |
| 1653 | return lhs = lhs & rhs; |
| 1654 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1655 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1656 | RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1657 | { |
| 1658 | return lhs = lhs | rhs; |
| 1659 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1660 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1661 | RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1662 | { |
| 1663 | return lhs = lhs ^ rhs; |
| 1664 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1665 | |
| 1666 | // RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1667 | // { |
| 1668 | // return lhs = lhs << rhs; |
| 1669 | // } |
| 1670 | |
| 1671 | // RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1672 | // { |
| 1673 | // return lhs = lhs >> rhs; |
| 1674 | // } |
| 1675 | |
| 1676 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 1677 | // { |
| 1678 | // return val; |
| 1679 | // } |
| 1680 | |
| 1681 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 1682 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1683 | // return RValue<SByte8>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1684 | // } |
| 1685 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1686 | RValue<SByte8> operator~(RValue<SByte8> val) |
| 1687 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1688 | return RValue<SByte8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1689 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1690 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1691 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
| 1692 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1693 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1694 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1695 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1696 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1697 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1698 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
| 1699 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1700 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1701 | int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1702 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1703 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1704 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1705 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1706 | Byte16::Byte16(RValue<Byte16> rhs) |
| 1707 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1708 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1709 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1710 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1711 | Byte16::Byte16(const Byte16 &rhs) |
| 1712 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1713 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1714 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1715 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1716 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 1717 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1718 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1719 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1720 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1721 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) |
| 1722 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1723 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1724 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1725 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1726 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) |
| 1727 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1728 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1729 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1730 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1731 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) |
| 1732 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1733 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1734 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1735 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1736 | RValue<Byte16> Swizzle(RValue<Byte16> x, uint64_t select) |
| 1737 | { |
| 1738 | int shuffle[16] = { |
| 1739 | static_cast<int>((select >> 60) & 0x0F), |
| 1740 | static_cast<int>((select >> 56) & 0x0F), |
| 1741 | static_cast<int>((select >> 52) & 0x0F), |
| 1742 | static_cast<int>((select >> 48) & 0x0F), |
| 1743 | static_cast<int>((select >> 44) & 0x0F), |
| 1744 | static_cast<int>((select >> 40) & 0x0F), |
| 1745 | static_cast<int>((select >> 36) & 0x0F), |
| 1746 | static_cast<int>((select >> 32) & 0x0F), |
| 1747 | static_cast<int>((select >> 28) & 0x0F), |
| 1748 | static_cast<int>((select >> 24) & 0x0F), |
| 1749 | static_cast<int>((select >> 20) & 0x0F), |
| 1750 | static_cast<int>((select >> 16) & 0x0F), |
| 1751 | static_cast<int>((select >> 12) & 0x0F), |
| 1752 | static_cast<int>((select >> 8) & 0x0F), |
| 1753 | static_cast<int>((select >> 4) & 0x0F), |
| 1754 | static_cast<int>((select >> 0) & 0x0F), |
| 1755 | }; |
| 1756 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1757 | return As<Byte16>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1758 | } |
| 1759 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1760 | Short2::Short2(RValue<Short4> cast) |
| 1761 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1762 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1763 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1764 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1765 | UShort2::UShort2(RValue<UShort4> cast) |
| 1766 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1767 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1768 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1769 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1770 | Short4::Short4(RValue<Int> cast) |
| 1771 | { |
| 1772 | Value *vector = loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1773 | Value *element = Nucleus::createTrunc(cast.value(), Short::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1774 | Value *insert = Nucleus::createInsertElement(vector, element, 0); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1775 | Value *swizzle = Swizzle(RValue<Short4>(insert), 0x0000).value(); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1776 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1777 | storeValue(swizzle); |
| 1778 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1779 | |
Nicolas Capens | 7119686 | 2022-01-06 21:31:57 -0500 | [diff] [blame] | 1780 | Short4::Short4(RValue<UInt4> cast) |
| 1781 | : Short4(As<Int4>(cast)) |
| 1782 | { |
| 1783 | } |
| 1784 | |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1785 | // Short4::Short4(RValue<Float> cast) |
| 1786 | // { |
| 1787 | // } |
| 1788 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1789 | Short4::Short4(short xyzw) |
| 1790 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1791 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1792 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1793 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1794 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1795 | Short4::Short4(short x, short y, short z, short w) |
| 1796 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1797 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1798 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1799 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1800 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1801 | Short4::Short4(RValue<Short4> rhs) |
| 1802 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1803 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1804 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1805 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1806 | Short4::Short4(const Short4 &rhs) |
| 1807 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1808 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1809 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1810 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1811 | Short4::Short4(const Reference<Short4> &rhs) |
| 1812 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1813 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1814 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1815 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1816 | Short4::Short4(RValue<UShort4> rhs) |
| 1817 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1818 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1819 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1820 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1821 | Short4::Short4(const UShort4 &rhs) |
| 1822 | { |
| 1823 | storeValue(rhs.loadValue()); |
| 1824 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1825 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1826 | Short4::Short4(const Reference<UShort4> &rhs) |
| 1827 | { |
| 1828 | storeValue(rhs.loadValue()); |
| 1829 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1830 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1831 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) |
| 1832 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1833 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1834 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1835 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1836 | RValue<Short4> Short4::operator=(const Short4 &rhs) |
| 1837 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1838 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1839 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1840 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1841 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) |
| 1842 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 1843 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1844 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1845 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1846 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) |
| 1847 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1848 | return RValue<Short4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1849 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1850 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1851 | RValue<Short4> Short4::operator=(const UShort4 &rhs) |
| 1852 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1853 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1854 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1855 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1856 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) |
| 1857 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 1858 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1859 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1860 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1861 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1862 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1863 | return RValue<Short4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1864 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1865 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1866 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1867 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1868 | return RValue<Short4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1869 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1870 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1871 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1872 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1873 | return RValue<Short4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1874 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1875 | |
| 1876 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1877 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1878 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1879 | // } |
| 1880 | |
| 1881 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1882 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1883 | // return RValue<Short4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1884 | // } |
| 1885 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1886 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1887 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1888 | return RValue<Short4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1889 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1890 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1891 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1892 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1893 | return RValue<Short4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1894 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1895 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1896 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1897 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1898 | return RValue<Short4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1899 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1900 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1901 | RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs) |
| 1902 | { |
| 1903 | return lhs = lhs + rhs; |
| 1904 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1905 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1906 | RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs) |
| 1907 | { |
| 1908 | return lhs = lhs - rhs; |
| 1909 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1910 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1911 | RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs) |
| 1912 | { |
| 1913 | return lhs = lhs * rhs; |
| 1914 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1915 | |
| 1916 | // RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs) |
| 1917 | // { |
| 1918 | // return lhs = lhs / rhs; |
| 1919 | // } |
| 1920 | |
| 1921 | // RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs) |
| 1922 | // { |
| 1923 | // return lhs = lhs % rhs; |
| 1924 | // } |
| 1925 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1926 | RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs) |
| 1927 | { |
| 1928 | return lhs = lhs & rhs; |
| 1929 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1930 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1931 | RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs) |
| 1932 | { |
| 1933 | return lhs = lhs | rhs; |
| 1934 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1935 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1936 | RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs) |
| 1937 | { |
| 1938 | return lhs = lhs ^ rhs; |
| 1939 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1940 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1941 | RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs) |
| 1942 | { |
| 1943 | return lhs = lhs << rhs; |
| 1944 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1945 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1946 | RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs) |
| 1947 | { |
| 1948 | return lhs = lhs >> rhs; |
| 1949 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1950 | |
| 1951 | // RValue<Short4> operator+(RValue<Short4> val) |
| 1952 | // { |
| 1953 | // return val; |
| 1954 | // } |
| 1955 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1956 | RValue<Short4> operator-(RValue<Short4> val) |
| 1957 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1958 | return RValue<Short4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1959 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1960 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1961 | RValue<Short4> operator~(RValue<Short4> val) |
| 1962 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1963 | return RValue<Short4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1964 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1965 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1966 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
| 1967 | { |
| 1968 | RValue<Int4> int4 = RoundInt(cast); |
| 1969 | return As<Short4>(PackSigned(int4, int4)); |
| 1970 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1971 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1972 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
| 1973 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1974 | int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1975 | return As<Int2>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1976 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1977 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1978 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
| 1979 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1980 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1981 | int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 1982 | auto lowHigh = RValue<Short8>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1983 | return As<Int2>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1984 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1985 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1986 | RValue<Short4> Swizzle(RValue<Short4> x, uint16_t select) |
| 1987 | { |
| 1988 | // Real type is v8i16 |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1989 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1990 | int shuffle[8] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1991 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1992 | (select >> 8) & 0x03, |
| 1993 | (select >> 4) & 0x03, |
| 1994 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1995 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1996 | (select >> 8) & 0x03, |
| 1997 | (select >> 4) & 0x03, |
| 1998 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1999 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2000 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2001 | return As<Short4>(Nucleus::createShuffleVector(x.value(), x.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2002 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2003 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2004 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
| 2005 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2006 | return RValue<Short4>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2007 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2008 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2009 | RValue<Short> Extract(RValue<Short4> val, int i) |
| 2010 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2011 | return RValue<Short>(Nucleus::createExtractElement(val.value(), Short::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2012 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2013 | |
Nicolas Capens | 7119686 | 2022-01-06 21:31:57 -0500 | [diff] [blame] | 2014 | UShort4::UShort4(RValue<UInt4> cast) |
| 2015 | : UShort4(As<Int4>(cast)) |
| 2016 | { |
| 2017 | } |
| 2018 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2019 | UShort4::UShort4(RValue<Int4> cast) |
| 2020 | { |
| 2021 | *this = Short4(cast); |
| 2022 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2023 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2024 | UShort4::UShort4(unsigned short xyzw) |
| 2025 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2026 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2027 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2028 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2029 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2030 | UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) |
| 2031 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2032 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2033 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2034 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2035 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2036 | UShort4::UShort4(RValue<UShort4> rhs) |
| 2037 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2038 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2039 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2040 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2041 | UShort4::UShort4(const UShort4 &rhs) |
| 2042 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2043 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2044 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2045 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2046 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 2047 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2048 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2049 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2050 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2051 | UShort4::UShort4(RValue<Short4> rhs) |
| 2052 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2053 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2054 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2055 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2056 | UShort4::UShort4(const Short4 &rhs) |
| 2057 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2058 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2059 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2060 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2061 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 2062 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2063 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2064 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2065 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2066 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) |
| 2067 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2068 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2069 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2070 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2071 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) |
| 2072 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2073 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2074 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2075 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2076 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) |
| 2077 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2078 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2079 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2080 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2081 | RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) |
| 2082 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2083 | return RValue<UShort4>(storeValue(rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2084 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2085 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2086 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) |
| 2087 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2088 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2089 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2090 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2091 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) |
| 2092 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2093 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2094 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2095 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2096 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2097 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2098 | return RValue<UShort4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2099 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2100 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2101 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2102 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2103 | return RValue<UShort4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2104 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2105 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2106 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2107 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2108 | return RValue<UShort4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2109 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2110 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2111 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2112 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2113 | return RValue<UShort4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2114 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2115 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2116 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2117 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2118 | return RValue<UShort4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2119 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2120 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2121 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2122 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2123 | return RValue<UShort4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2124 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2125 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2126 | RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs) |
| 2127 | { |
| 2128 | return lhs = lhs << rhs; |
| 2129 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2130 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2131 | RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs) |
| 2132 | { |
| 2133 | return lhs = lhs >> rhs; |
| 2134 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2135 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2136 | RValue<UShort4> operator~(RValue<UShort4> val) |
| 2137 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2138 | return RValue<UShort4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2139 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2140 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2141 | Short8::Short8(short c) |
| 2142 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2143 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2144 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2145 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2146 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2147 | Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 2148 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2149 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2150 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2151 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2152 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2153 | Short8::Short8(RValue<Short8> rhs) |
| 2154 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2155 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2156 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2157 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2158 | Short8::Short8(const Reference<Short8> &rhs) |
| 2159 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2160 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2161 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2162 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2163 | Short8::Short8(RValue<Short4> lo, RValue<Short4> hi) |
| 2164 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2165 | int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2166 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2167 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2168 | storeValue(packed); |
| 2169 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2170 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2171 | RValue<Short8> Short8::operator=(RValue<Short8> rhs) |
| 2172 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2173 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2174 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2175 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2176 | RValue<Short8> Short8::operator=(const Short8 &rhs) |
| 2177 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2178 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2179 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2180 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2181 | RValue<Short8> Short8::operator=(const Reference<Short8> &rhs) |
| 2182 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2183 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2184 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2185 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2186 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2187 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2188 | return RValue<Short8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2189 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2190 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2191 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2192 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2193 | return RValue<Short8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2194 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2195 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2196 | UShort8::UShort8(unsigned short c) |
| 2197 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2198 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2199 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2200 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2201 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2202 | UShort8::UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7) |
| 2203 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2204 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2205 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2206 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2207 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2208 | UShort8::UShort8(RValue<UShort8> rhs) |
| 2209 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2210 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2211 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2212 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2213 | UShort8::UShort8(const Reference<UShort8> &rhs) |
| 2214 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2215 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2216 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2217 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2218 | UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi) |
| 2219 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2220 | int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2221 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2222 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2223 | storeValue(packed); |
| 2224 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2225 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2226 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) |
| 2227 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2228 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2229 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2230 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2231 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) |
| 2232 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2233 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2234 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2235 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2236 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) |
| 2237 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2238 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2239 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2240 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2241 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2242 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2243 | return RValue<UShort8>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2244 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2245 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2246 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2247 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2248 | return RValue<UShort8>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2249 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2251 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2252 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2253 | return RValue<UShort8>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2254 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2255 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2256 | RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs) |
| 2257 | { |
| 2258 | return lhs = lhs + rhs; |
| 2259 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2260 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2261 | RValue<UShort8> operator~(RValue<UShort8> val) |
| 2262 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2263 | return RValue<UShort8>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2264 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2265 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2266 | RValue<UShort8> Swizzle(RValue<UShort8> x, uint32_t select) |
| 2267 | { |
| 2268 | int swizzle[16] = { |
| 2269 | static_cast<int>((select >> 28) & 0x07), |
| 2270 | static_cast<int>((select >> 24) & 0x07), |
| 2271 | static_cast<int>((select >> 20) & 0x07), |
| 2272 | static_cast<int>((select >> 16) & 0x07), |
| 2273 | static_cast<int>((select >> 12) & 0x07), |
| 2274 | static_cast<int>((select >> 8) & 0x07), |
| 2275 | static_cast<int>((select >> 4) & 0x07), |
| 2276 | static_cast<int>((select >> 0) & 0x07), |
| 2277 | }; |
| 2278 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2279 | return RValue<UShort8>(Nucleus::createShuffleVector(x.value(), x.value(), swizzle)); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2280 | } |
| 2281 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2282 | Int::Int(Argument<Int> argument) |
| 2283 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2284 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2285 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2286 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2287 | Int::Int(RValue<Byte> cast) |
| 2288 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2289 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2290 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2291 | storeValue(integer); |
| 2292 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2293 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2294 | Int::Int(RValue<SByte> cast) |
| 2295 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2296 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2297 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2298 | storeValue(integer); |
| 2299 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2300 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2301 | Int::Int(RValue<Short> cast) |
| 2302 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2303 | Value *integer = Nucleus::createSExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2304 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2305 | storeValue(integer); |
| 2306 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2307 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2308 | Int::Int(RValue<UShort> cast) |
| 2309 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2310 | Value *integer = Nucleus::createZExt(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2311 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2312 | storeValue(integer); |
| 2313 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2314 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2315 | Int::Int(RValue<Int2> cast) |
| 2316 | { |
| 2317 | *this = Extract(cast, 0); |
| 2318 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2319 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2320 | Int::Int(RValue<Long> cast) |
| 2321 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2322 | Value *integer = Nucleus::createTrunc(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2323 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2324 | storeValue(integer); |
| 2325 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2326 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2327 | Int::Int(RValue<Float> cast) |
| 2328 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2329 | Value *integer = Nucleus::createFPToSI(cast.value(), Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2330 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2331 | storeValue(integer); |
| 2332 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2333 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2334 | Int::Int(int x) |
| 2335 | { |
| 2336 | storeValue(Nucleus::createConstantInt(x)); |
| 2337 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2338 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2339 | Int::Int(RValue<Int> rhs) |
| 2340 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2341 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2342 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2343 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2344 | Int::Int(RValue<UInt> rhs) |
| 2345 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2346 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2347 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2348 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2349 | Int::Int(const Int &rhs) |
| 2350 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2351 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2352 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2353 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2354 | Int::Int(const Reference<Int> &rhs) |
| 2355 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2356 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2357 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2358 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2359 | Int::Int(const UInt &rhs) |
| 2360 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2361 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2362 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2363 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2364 | Int::Int(const Reference<UInt> &rhs) |
| 2365 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2366 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2367 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2368 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2369 | RValue<Int> Int::operator=(int rhs) |
| 2370 | { |
| 2371 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2372 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2373 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2374 | RValue<Int> Int::operator=(RValue<Int> rhs) |
| 2375 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2376 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2377 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2378 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2379 | RValue<Int> Int::operator=(RValue<UInt> rhs) |
| 2380 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2381 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2382 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2383 | return RValue<Int>(rhs); |
| 2384 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2385 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2386 | RValue<Int> Int::operator=(const Int &rhs) |
| 2387 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2388 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2389 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2390 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2391 | RValue<Int> Int::operator=(const Reference<Int> &rhs) |
| 2392 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2393 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2394 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2395 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2396 | RValue<Int> Int::operator=(const UInt &rhs) |
| 2397 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2398 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2399 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2400 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2401 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) |
| 2402 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2403 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2404 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2405 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2406 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) |
| 2407 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2408 | return RValue<Int>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2409 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2410 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2411 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) |
| 2412 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2413 | return RValue<Int>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2414 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2415 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2416 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) |
| 2417 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2418 | return RValue<Int>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2419 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2420 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2421 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
| 2422 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2423 | return RValue<Int>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2424 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2425 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2426 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
| 2427 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2428 | return RValue<Int>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2429 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2430 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2431 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
| 2432 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2433 | return RValue<Int>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2434 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2435 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2436 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
| 2437 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2438 | return RValue<Int>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2439 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2440 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2441 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
| 2442 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2443 | return RValue<Int>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2444 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2445 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2446 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
| 2447 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2448 | return RValue<Int>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2449 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2450 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2451 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
| 2452 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2453 | return RValue<Int>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2454 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2455 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2456 | RValue<Int> operator+=(Int &lhs, RValue<Int> rhs) |
| 2457 | { |
| 2458 | return lhs = lhs + rhs; |
| 2459 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2460 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2461 | RValue<Int> operator-=(Int &lhs, RValue<Int> rhs) |
| 2462 | { |
| 2463 | return lhs = lhs - rhs; |
| 2464 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2465 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2466 | RValue<Int> operator*=(Int &lhs, RValue<Int> rhs) |
| 2467 | { |
| 2468 | return lhs = lhs * rhs; |
| 2469 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2470 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2471 | RValue<Int> operator/=(Int &lhs, RValue<Int> rhs) |
| 2472 | { |
| 2473 | return lhs = lhs / rhs; |
| 2474 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2475 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2476 | RValue<Int> operator%=(Int &lhs, RValue<Int> rhs) |
| 2477 | { |
| 2478 | return lhs = lhs % rhs; |
| 2479 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2480 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2481 | RValue<Int> operator&=(Int &lhs, RValue<Int> rhs) |
| 2482 | { |
| 2483 | return lhs = lhs & rhs; |
| 2484 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2485 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2486 | RValue<Int> operator|=(Int &lhs, RValue<Int> rhs) |
| 2487 | { |
| 2488 | return lhs = lhs | rhs; |
| 2489 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2490 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2491 | RValue<Int> operator^=(Int &lhs, RValue<Int> rhs) |
| 2492 | { |
| 2493 | return lhs = lhs ^ rhs; |
| 2494 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2495 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2496 | RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs) |
| 2497 | { |
| 2498 | return lhs = lhs << rhs; |
| 2499 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2500 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2501 | RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs) |
| 2502 | { |
| 2503 | return lhs = lhs >> rhs; |
| 2504 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2505 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2506 | RValue<Int> operator+(RValue<Int> val) |
| 2507 | { |
| 2508 | return val; |
| 2509 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2510 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2511 | RValue<Int> operator-(RValue<Int> val) |
| 2512 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2513 | return RValue<Int>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2514 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2515 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2516 | RValue<Int> operator~(RValue<Int> val) |
| 2517 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2518 | return RValue<Int>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2519 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2520 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2521 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
| 2522 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2523 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2524 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2525 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2526 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
| 2527 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2528 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2529 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2530 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2531 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
| 2532 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2533 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2534 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2535 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2536 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
| 2537 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2538 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2539 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2540 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2541 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
| 2542 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2543 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2544 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2545 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2546 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
| 2547 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2548 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2549 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2550 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2551 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 2552 | { |
| 2553 | return IfThenElse(x > y, x, y); |
| 2554 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2555 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2556 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 2557 | { |
| 2558 | return IfThenElse(x < y, x, y); |
| 2559 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2560 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2561 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 2562 | { |
| 2563 | return Min(Max(x, min), max); |
| 2564 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2565 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2566 | Long::Long(RValue<Int> cast) |
| 2567 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2568 | Value *integer = Nucleus::createSExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2569 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2570 | storeValue(integer); |
| 2571 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2572 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2573 | Long::Long(RValue<UInt> cast) |
| 2574 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2575 | Value *integer = Nucleus::createZExt(cast.value(), Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2576 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2577 | storeValue(integer); |
| 2578 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2579 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2580 | Long::Long(RValue<Long> rhs) |
| 2581 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2582 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2583 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2584 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2585 | RValue<Long> Long::operator=(int64_t rhs) |
| 2586 | { |
| 2587 | return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs))); |
| 2588 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2589 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2590 | RValue<Long> Long::operator=(RValue<Long> rhs) |
| 2591 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2592 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2593 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2594 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2595 | RValue<Long> Long::operator=(const Long &rhs) |
| 2596 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2597 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2598 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2599 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2600 | RValue<Long> Long::operator=(const Reference<Long> &rhs) |
| 2601 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2602 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2603 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2604 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2605 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
| 2606 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2607 | return RValue<Long>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2608 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2609 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2610 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
| 2611 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2612 | return RValue<Long>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2613 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2614 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2615 | RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs) |
| 2616 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2617 | return RValue<Long>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2618 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2619 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2620 | RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs) |
| 2621 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2622 | return RValue<Long>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2623 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2624 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2625 | RValue<Long> operator+=(Long &lhs, RValue<Long> rhs) |
| 2626 | { |
| 2627 | return lhs = lhs + rhs; |
| 2628 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2629 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2630 | RValue<Long> operator-=(Long &lhs, RValue<Long> rhs) |
| 2631 | { |
| 2632 | return lhs = lhs - rhs; |
| 2633 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2634 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2635 | RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2636 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2637 | return RValue<Long>(Nucleus::createAtomicAdd(x.value(), y.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2638 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2639 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2640 | RValue<UInt> AddAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2641 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2642 | return RValue<UInt>(Nucleus::createAtomicAdd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2643 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2644 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2645 | RValue<UInt> SubAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2646 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2647 | return RValue<UInt>(Nucleus::createAtomicSub(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2648 | } |
Chris Forbes | 707ed99 | 2019-04-18 18:17:35 -0700 | [diff] [blame] | 2649 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2650 | RValue<UInt> AndAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2651 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2652 | return RValue<UInt>(Nucleus::createAtomicAnd(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2653 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2654 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2655 | RValue<UInt> OrAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2656 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2657 | return RValue<UInt>(Nucleus::createAtomicOr(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2658 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2659 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2660 | RValue<UInt> XorAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2661 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2662 | return RValue<UInt>(Nucleus::createAtomicXor(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2663 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2664 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2665 | RValue<UInt> ExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2666 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2667 | return RValue<UInt>(Nucleus::createAtomicExchange(x.value(), y.value(), memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2668 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2669 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2670 | RValue<UInt> CompareExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, RValue<UInt> compare, std::memory_order memoryOrderEqual, std::memory_order memoryOrderUnequal) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2671 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2672 | return RValue<UInt>(Nucleus::createAtomicCompareExchange(x.value(), y.value(), compare.value(), memoryOrderEqual, memoryOrderUnequal)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2673 | } |
Chris Forbes | a16238d | 2019-04-18 16:31:54 -0700 | [diff] [blame] | 2674 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2675 | UInt::UInt(Argument<UInt> argument) |
| 2676 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2677 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2678 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2679 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2680 | UInt::UInt(RValue<UShort> cast) |
| 2681 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2682 | Value *integer = Nucleus::createZExt(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2683 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2684 | storeValue(integer); |
| 2685 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2686 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2687 | UInt::UInt(RValue<Long> cast) |
| 2688 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2689 | Value *integer = Nucleus::createTrunc(cast.value(), UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2690 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2691 | storeValue(integer); |
| 2692 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2693 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2694 | UInt::UInt(int x) |
| 2695 | { |
| 2696 | storeValue(Nucleus::createConstantInt(x)); |
| 2697 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2698 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2699 | UInt::UInt(unsigned int x) |
| 2700 | { |
| 2701 | storeValue(Nucleus::createConstantInt(x)); |
| 2702 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2703 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2704 | UInt::UInt(RValue<UInt> rhs) |
| 2705 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2706 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2707 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2708 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2709 | UInt::UInt(RValue<Int> rhs) |
| 2710 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2711 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2712 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2713 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2714 | UInt::UInt(const UInt &rhs) |
| 2715 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2716 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2717 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2718 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2719 | UInt::UInt(const Reference<UInt> &rhs) |
| 2720 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2721 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2722 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2723 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2724 | UInt::UInt(const Int &rhs) |
| 2725 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2726 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2727 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2728 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2729 | UInt::UInt(const Reference<Int> &rhs) |
| 2730 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2731 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2732 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2733 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2734 | RValue<UInt> UInt::operator=(unsigned int rhs) |
| 2735 | { |
| 2736 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2737 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2738 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2739 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) |
| 2740 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2741 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2742 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2743 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2744 | RValue<UInt> UInt::operator=(RValue<Int> rhs) |
| 2745 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2746 | storeValue(rhs.value()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2747 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2748 | return RValue<UInt>(rhs); |
| 2749 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2750 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2751 | RValue<UInt> UInt::operator=(const UInt &rhs) |
| 2752 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2753 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2754 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2755 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2756 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) |
| 2757 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2758 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2759 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2760 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2761 | RValue<UInt> UInt::operator=(const Int &rhs) |
| 2762 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2763 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2764 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2765 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2766 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) |
| 2767 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2768 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2769 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2770 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2771 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2772 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2773 | return RValue<UInt>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2774 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2775 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2776 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2777 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2778 | return RValue<UInt>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2779 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2780 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2781 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2782 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2783 | return RValue<UInt>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2784 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2785 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2786 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2787 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2788 | return RValue<UInt>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2789 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2790 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2791 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2792 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2793 | return RValue<UInt>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2794 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2795 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2796 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2797 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2798 | return RValue<UInt>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2799 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2800 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2801 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2802 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2803 | return RValue<UInt>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2804 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2805 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2806 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2807 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2808 | return RValue<UInt>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2809 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2810 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2811 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2812 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2813 | return RValue<UInt>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2814 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2815 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2816 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2817 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2818 | return RValue<UInt>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2819 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2820 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2821 | RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs) |
| 2822 | { |
| 2823 | return lhs = lhs + rhs; |
| 2824 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2825 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2826 | RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs) |
| 2827 | { |
| 2828 | return lhs = lhs - rhs; |
| 2829 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2830 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2831 | RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs) |
| 2832 | { |
| 2833 | return lhs = lhs * rhs; |
| 2834 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2835 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2836 | RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs) |
| 2837 | { |
| 2838 | return lhs = lhs / rhs; |
| 2839 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2840 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2841 | RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs) |
| 2842 | { |
| 2843 | return lhs = lhs % rhs; |
| 2844 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2845 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2846 | RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs) |
| 2847 | { |
| 2848 | return lhs = lhs & rhs; |
| 2849 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2850 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2851 | RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs) |
| 2852 | { |
| 2853 | return lhs = lhs | rhs; |
| 2854 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2855 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2856 | RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs) |
| 2857 | { |
| 2858 | return lhs = lhs ^ rhs; |
| 2859 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2860 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2861 | RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs) |
| 2862 | { |
| 2863 | return lhs = lhs << rhs; |
| 2864 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2865 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2866 | RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs) |
| 2867 | { |
| 2868 | return lhs = lhs >> rhs; |
| 2869 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2870 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2871 | RValue<UInt> operator+(RValue<UInt> val) |
| 2872 | { |
| 2873 | return val; |
| 2874 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2875 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2876 | RValue<UInt> operator-(RValue<UInt> val) |
| 2877 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2878 | return RValue<UInt>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2879 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2880 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2881 | RValue<UInt> operator~(RValue<UInt> val) |
| 2882 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2883 | return RValue<UInt>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2884 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2885 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2886 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 2887 | { |
| 2888 | return IfThenElse(x > y, x, y); |
| 2889 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2890 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2891 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 2892 | { |
| 2893 | return IfThenElse(x < y, x, y); |
| 2894 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2895 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2896 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 2897 | { |
| 2898 | return Min(Max(x, min), max); |
| 2899 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2900 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2901 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2902 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2903 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2904 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2905 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2906 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2907 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2908 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2909 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2910 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2911 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2912 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2913 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2914 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2915 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2916 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2917 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2918 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2919 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2920 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2921 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2922 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2923 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2924 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2925 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2926 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2927 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2928 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2929 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2930 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2931 | Int2::Int2(RValue<Int4> cast) |
| 2932 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2933 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2934 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2935 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2936 | Int2::Int2(int x, int y) |
| 2937 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2938 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2939 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2940 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2941 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2942 | Int2::Int2(RValue<Int2> rhs) |
| 2943 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2944 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2945 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2946 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2947 | Int2::Int2(const Int2 &rhs) |
| 2948 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2949 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2950 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2951 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2952 | Int2::Int2(const Reference<Int2> &rhs) |
| 2953 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2954 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2955 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2956 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2957 | Int2::Int2(RValue<Int> lo, RValue<Int> hi) |
| 2958 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2959 | int shuffle[4] = { 0, 4, 1, 5 }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2960 | Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2961 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2962 | storeValue(Nucleus::createBitCast(packed, Int2::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2963 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2964 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2965 | RValue<Int2> Int2::operator=(RValue<Int2> rhs) |
| 2966 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 2967 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2968 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2969 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2970 | RValue<Int2> Int2::operator=(const Int2 &rhs) |
| 2971 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2972 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2973 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2974 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2975 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) |
| 2976 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 2977 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2978 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2979 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2980 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2981 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2982 | return RValue<Int2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2983 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2984 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2985 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2986 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2987 | return RValue<Int2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2988 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2989 | |
| 2990 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2991 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2992 | // return RValue<Int2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2993 | // } |
| 2994 | |
| 2995 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2996 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 2997 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2998 | // } |
| 2999 | |
| 3000 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3001 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3002 | // return RValue<Int2>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3003 | // } |
| 3004 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3005 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3006 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3007 | return RValue<Int2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3008 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3009 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3010 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3011 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3012 | return RValue<Int2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3013 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3014 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3015 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
| 3016 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3017 | return RValue<Int2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3018 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3019 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3020 | RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs) |
| 3021 | { |
| 3022 | return lhs = lhs + rhs; |
| 3023 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3024 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3025 | RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs) |
| 3026 | { |
| 3027 | return lhs = lhs - rhs; |
| 3028 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3029 | |
| 3030 | // RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs) |
| 3031 | // { |
| 3032 | // return lhs = lhs * rhs; |
| 3033 | // } |
| 3034 | |
| 3035 | // RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs) |
| 3036 | // { |
| 3037 | // return lhs = lhs / rhs; |
| 3038 | // } |
| 3039 | |
| 3040 | // RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs) |
| 3041 | // { |
| 3042 | // return lhs = lhs % rhs; |
| 3043 | // } |
| 3044 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3045 | RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs) |
| 3046 | { |
| 3047 | return lhs = lhs & rhs; |
| 3048 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3049 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3050 | RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs) |
| 3051 | { |
| 3052 | return lhs = lhs | rhs; |
| 3053 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3054 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3055 | RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs) |
| 3056 | { |
| 3057 | return lhs = lhs ^ rhs; |
| 3058 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3059 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3060 | RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs) |
| 3061 | { |
| 3062 | return lhs = lhs << rhs; |
| 3063 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3064 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3065 | RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs) |
| 3066 | { |
| 3067 | return lhs = lhs >> rhs; |
| 3068 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3069 | |
| 3070 | // RValue<Int2> operator+(RValue<Int2> val) |
| 3071 | // { |
| 3072 | // return val; |
| 3073 | // } |
| 3074 | |
| 3075 | // RValue<Int2> operator-(RValue<Int2> val) |
| 3076 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3077 | // return RValue<Int2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3078 | // } |
| 3079 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3080 | RValue<Int2> operator~(RValue<Int2> val) |
| 3081 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3082 | return RValue<Int2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3083 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3084 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3085 | RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
| 3086 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3087 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3088 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3089 | return As<Short4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3090 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3091 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3092 | RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
| 3093 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 3094 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3095 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3096 | auto lowHigh = RValue<Int4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3097 | return As<Short4>(Swizzle(lowHigh, 0x2323)); |
| 3098 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3099 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3100 | RValue<Int> Extract(RValue<Int2> val, int i) |
| 3101 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3102 | return RValue<Int>(Nucleus::createExtractElement(val.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3103 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3104 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3105 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
| 3106 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3107 | return RValue<Int2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3108 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3109 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3110 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 3111 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3112 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3113 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3114 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3115 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3116 | UInt2::UInt2(RValue<UInt2> rhs) |
| 3117 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3118 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3119 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3120 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3121 | UInt2::UInt2(const UInt2 &rhs) |
| 3122 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3123 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3124 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3125 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3126 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 3127 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3128 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3129 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3130 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3131 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) |
| 3132 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3133 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3134 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3135 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3136 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) |
| 3137 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3138 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3139 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3140 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3141 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) |
| 3142 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3143 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3144 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3145 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3146 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3147 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3148 | return RValue<UInt2>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3149 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3150 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3151 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3152 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3153 | return RValue<UInt2>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3154 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3155 | |
| 3156 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3157 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3158 | // return RValue<UInt2>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3159 | // } |
| 3160 | |
| 3161 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3162 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3163 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3164 | // } |
| 3165 | |
| 3166 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3167 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3168 | // return RValue<UInt2>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3169 | // } |
| 3170 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3171 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3172 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3173 | return RValue<UInt2>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3174 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3175 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3176 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3177 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3178 | return RValue<UInt2>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3179 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3180 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3181 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3182 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3183 | return RValue<UInt2>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3184 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3185 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3186 | RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3187 | { |
| 3188 | return lhs = lhs + rhs; |
| 3189 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3190 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3191 | RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3192 | { |
| 3193 | return lhs = lhs - rhs; |
| 3194 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3195 | |
| 3196 | // RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3197 | // { |
| 3198 | // return lhs = lhs * rhs; |
| 3199 | // } |
| 3200 | |
| 3201 | // RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3202 | // { |
| 3203 | // return lhs = lhs / rhs; |
| 3204 | // } |
| 3205 | |
| 3206 | // RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3207 | // { |
| 3208 | // return lhs = lhs % rhs; |
| 3209 | // } |
| 3210 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3211 | RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3212 | { |
| 3213 | return lhs = lhs & rhs; |
| 3214 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3215 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3216 | RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3217 | { |
| 3218 | return lhs = lhs | rhs; |
| 3219 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3220 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3221 | RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3222 | { |
| 3223 | return lhs = lhs ^ rhs; |
| 3224 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3225 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3226 | RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs) |
| 3227 | { |
| 3228 | return lhs = lhs << rhs; |
| 3229 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3230 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3231 | RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs) |
| 3232 | { |
| 3233 | return lhs = lhs >> rhs; |
| 3234 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3235 | |
| 3236 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 3237 | // { |
| 3238 | // return val; |
| 3239 | // } |
| 3240 | |
| 3241 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 3242 | // { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3243 | // return RValue<UInt2>(Nucleus::createNeg(val.value())); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3244 | // } |
| 3245 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3246 | RValue<UInt2> operator~(RValue<UInt2> val) |
| 3247 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3248 | return RValue<UInt2>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3249 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3251 | RValue<UInt> Extract(RValue<UInt2> val, int i) |
| 3252 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3253 | return RValue<UInt>(Nucleus::createExtractElement(val.value(), UInt::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3254 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3255 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3256 | RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i) |
| 3257 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3258 | return RValue<UInt2>(Nucleus::createInsertElement(val.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3259 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3260 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3261 | Int4::Int4() |
| 3262 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3263 | { |
| 3264 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3265 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3266 | Int4::Int4(RValue<Float4> cast) |
| 3267 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3268 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3269 | Value *xyzw = Nucleus::createFPToSI(cast.value(), Int4::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3270 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3271 | storeValue(xyzw); |
| 3272 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3273 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3274 | Int4::Int4(int xyzw) |
| 3275 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3276 | { |
| 3277 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3278 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3279 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3280 | Int4::Int4(int x, int yzw) |
| 3281 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3282 | { |
| 3283 | constant(x, yzw, yzw, yzw); |
| 3284 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3285 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3286 | Int4::Int4(int x, int y, int zw) |
| 3287 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3288 | { |
| 3289 | constant(x, y, zw, zw); |
| 3290 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3291 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3292 | Int4::Int4(int x, int y, int z, int w) |
| 3293 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3294 | { |
| 3295 | constant(x, y, z, w); |
| 3296 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3297 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3298 | void Int4::constant(int x, int y, int z, int w) |
| 3299 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3300 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3301 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3302 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3303 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3304 | Int4::Int4(RValue<Int4> rhs) |
| 3305 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3306 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3307 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3308 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3309 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3310 | Int4::Int4(const Int4 &rhs) |
| 3311 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3312 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3313 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3314 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3315 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3316 | Int4::Int4(const Reference<Int4> &rhs) |
| 3317 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3318 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3319 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3320 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3321 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3322 | Int4::Int4(RValue<UInt4> rhs) |
| 3323 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3324 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3325 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3326 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3327 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3328 | Int4::Int4(const UInt4 &rhs) |
| 3329 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3330 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3331 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3332 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3333 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3334 | Int4::Int4(const Reference<UInt4> &rhs) |
| 3335 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3336 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3337 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3338 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3339 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3340 | Int4::Int4(RValue<Int2> lo, RValue<Int2> hi) |
| 3341 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3342 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3343 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3344 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3345 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3346 | storeValue(packed); |
| 3347 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3348 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3349 | Int4::Int4(const Int &rhs) |
| 3350 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3351 | { |
| 3352 | *this = RValue<Int>(rhs.loadValue()); |
| 3353 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3354 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3355 | Int4::Int4(const Reference<Int> &rhs) |
| 3356 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3357 | { |
| 3358 | *this = RValue<Int>(rhs.loadValue()); |
| 3359 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3360 | |
Nicolas Capens | 82d425d | 2022-03-02 16:35:20 -0500 | [diff] [blame] | 3361 | RValue<Int4> Int4::operator=(int x) |
| 3362 | { |
| 3363 | return *this = Int4(x, x, x, x); |
| 3364 | } |
| 3365 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3366 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) |
| 3367 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3368 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3369 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3370 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3371 | RValue<Int4> Int4::operator=(const Int4 &rhs) |
| 3372 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3373 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3374 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3375 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3376 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) |
| 3377 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3378 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3379 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3380 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3381 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3382 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3383 | return RValue<Int4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3384 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3385 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3386 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3387 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3388 | return RValue<Int4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3389 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3390 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3391 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3392 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3393 | return RValue<Int4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3394 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3395 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3396 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3397 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3398 | return RValue<Int4>(Nucleus::createSDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3399 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3400 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3401 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3402 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3403 | return RValue<Int4>(Nucleus::createSRem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3404 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3405 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3406 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3407 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3408 | return RValue<Int4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3409 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3410 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3411 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3412 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3413 | return RValue<Int4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3414 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3415 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3416 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3417 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3418 | return RValue<Int4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3419 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3420 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3421 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3422 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3423 | return RValue<Int4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3424 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3425 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3426 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3427 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3428 | return RValue<Int4>(Nucleus::createAShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3429 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3430 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3431 | RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs) |
| 3432 | { |
| 3433 | return lhs = lhs + rhs; |
| 3434 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3435 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3436 | RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs) |
| 3437 | { |
| 3438 | return lhs = lhs - rhs; |
| 3439 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3440 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3441 | RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs) |
| 3442 | { |
| 3443 | return lhs = lhs * rhs; |
| 3444 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3445 | |
| 3446 | // RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs) |
| 3447 | // { |
| 3448 | // return lhs = lhs / rhs; |
| 3449 | // } |
| 3450 | |
| 3451 | // RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs) |
| 3452 | // { |
| 3453 | // return lhs = lhs % rhs; |
| 3454 | // } |
| 3455 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3456 | RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs) |
| 3457 | { |
| 3458 | return lhs = lhs & rhs; |
| 3459 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3460 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3461 | RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs) |
| 3462 | { |
| 3463 | return lhs = lhs | rhs; |
| 3464 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3465 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3466 | RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs) |
| 3467 | { |
| 3468 | return lhs = lhs ^ rhs; |
| 3469 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3470 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3471 | RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs) |
| 3472 | { |
| 3473 | return lhs = lhs << rhs; |
| 3474 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3475 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3476 | RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs) |
| 3477 | { |
| 3478 | return lhs = lhs >> rhs; |
| 3479 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3480 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3481 | RValue<Int4> operator+(RValue<Int4> val) |
| 3482 | { |
| 3483 | return val; |
| 3484 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3485 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3486 | RValue<Int4> operator-(RValue<Int4> val) |
| 3487 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3488 | return RValue<Int4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3489 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3490 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3491 | RValue<Int4> operator~(RValue<Int4> val) |
| 3492 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3493 | return RValue<Int4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3494 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3495 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3496 | RValue<Int> Extract(RValue<Int4> x, int i) |
| 3497 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3498 | return RValue<Int>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3499 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3500 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3501 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
| 3502 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3503 | return RValue<Int4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3504 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3505 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3506 | RValue<Int4> Swizzle(RValue<Int4> x, uint16_t select) |
| 3507 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3508 | return RValue<Int4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3509 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3510 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3511 | RValue<Int4> Shuffle(RValue<Int4> x, RValue<Int4> y, unsigned short select) |
| 3512 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3513 | return RValue<Int4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3514 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 3515 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3516 | UInt4::UInt4() |
| 3517 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3518 | { |
| 3519 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3520 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3521 | UInt4::UInt4(int xyzw) |
| 3522 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3523 | { |
| 3524 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3525 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3526 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3527 | UInt4::UInt4(int x, int yzw) |
| 3528 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3529 | { |
| 3530 | constant(x, yzw, yzw, yzw); |
| 3531 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3532 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3533 | UInt4::UInt4(int x, int y, int zw) |
| 3534 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3535 | { |
| 3536 | constant(x, y, zw, zw); |
| 3537 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3538 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3539 | UInt4::UInt4(int x, int y, int z, int w) |
| 3540 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3541 | { |
| 3542 | constant(x, y, z, w); |
| 3543 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3544 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3545 | void UInt4::constant(int x, int y, int z, int w) |
| 3546 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3547 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3548 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3549 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3550 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3551 | UInt4::UInt4(RValue<UInt4> rhs) |
| 3552 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3553 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3554 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3555 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3556 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3557 | UInt4::UInt4(const UInt4 &rhs) |
| 3558 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3559 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3560 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3561 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3562 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3563 | UInt4::UInt4(const Reference<UInt4> &rhs) |
| 3564 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3565 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3566 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3567 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3568 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3569 | UInt4::UInt4(RValue<Int4> rhs) |
| 3570 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3571 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3572 | storeValue(rhs.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3573 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3574 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3575 | UInt4::UInt4(const Int4 &rhs) |
| 3576 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3577 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3578 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3579 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3580 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3581 | UInt4::UInt4(const Reference<Int4> &rhs) |
| 3582 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3583 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3584 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3585 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3586 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3587 | UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi) |
| 3588 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3589 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3590 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3591 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3592 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3593 | storeValue(packed); |
| 3594 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3595 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3596 | UInt4::UInt4(const UInt &rhs) |
| 3597 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3598 | { |
| 3599 | *this = RValue<UInt>(rhs.loadValue()); |
| 3600 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3601 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3602 | UInt4::UInt4(const Reference<UInt> &rhs) |
| 3603 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3604 | { |
| 3605 | *this = RValue<UInt>(rhs.loadValue()); |
| 3606 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3607 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3608 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) |
| 3609 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3610 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3611 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3612 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3613 | RValue<UInt4> UInt4::operator=(const UInt4 &rhs) |
| 3614 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3615 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3616 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3617 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3618 | RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) |
| 3619 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3620 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3621 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3622 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3623 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3624 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3625 | return RValue<UInt4>(Nucleus::createAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3626 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3627 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3628 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3629 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3630 | return RValue<UInt4>(Nucleus::createSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3631 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3632 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3633 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3634 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3635 | return RValue<UInt4>(Nucleus::createMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3636 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3637 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3638 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3639 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3640 | return RValue<UInt4>(Nucleus::createUDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3641 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3642 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3643 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3644 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3645 | return RValue<UInt4>(Nucleus::createURem(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3646 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3647 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3648 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3649 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3650 | return RValue<UInt4>(Nucleus::createAnd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3651 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3652 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3653 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3654 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3655 | return RValue<UInt4>(Nucleus::createOr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3656 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3657 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3658 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3659 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3660 | return RValue<UInt4>(Nucleus::createXor(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3661 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3662 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3663 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3664 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3665 | return RValue<UInt4>(Nucleus::createShl(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3666 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3667 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3668 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3669 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3670 | return RValue<UInt4>(Nucleus::createLShr(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3671 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3672 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3673 | RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3674 | { |
| 3675 | return lhs = lhs + rhs; |
| 3676 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3677 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3678 | RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3679 | { |
| 3680 | return lhs = lhs - rhs; |
| 3681 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3682 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3683 | RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3684 | { |
| 3685 | return lhs = lhs * rhs; |
| 3686 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3687 | |
| 3688 | // RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3689 | // { |
| 3690 | // return lhs = lhs / rhs; |
| 3691 | // } |
| 3692 | |
| 3693 | // RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3694 | // { |
| 3695 | // return lhs = lhs % rhs; |
| 3696 | // } |
| 3697 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3698 | RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3699 | { |
| 3700 | return lhs = lhs & rhs; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3701 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3702 | |
| 3703 | RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3704 | { |
| 3705 | return lhs = lhs | rhs; |
| 3706 | } |
| 3707 | |
| 3708 | RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3709 | { |
| 3710 | return lhs = lhs ^ rhs; |
| 3711 | } |
| 3712 | |
| 3713 | RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs) |
| 3714 | { |
| 3715 | return lhs = lhs << rhs; |
| 3716 | } |
| 3717 | |
| 3718 | RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs) |
| 3719 | { |
| 3720 | return lhs = lhs >> rhs; |
| 3721 | } |
| 3722 | |
| 3723 | RValue<UInt4> operator+(RValue<UInt4> val) |
| 3724 | { |
| 3725 | return val; |
| 3726 | } |
| 3727 | |
| 3728 | RValue<UInt4> operator-(RValue<UInt4> val) |
| 3729 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3730 | return RValue<UInt4>(Nucleus::createNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3731 | } |
| 3732 | |
| 3733 | RValue<UInt4> operator~(RValue<UInt4> val) |
| 3734 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3735 | return RValue<UInt4>(Nucleus::createNot(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3736 | } |
| 3737 | |
| 3738 | RValue<UInt> Extract(RValue<UInt4> x, int i) |
| 3739 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3740 | return RValue<UInt>(Nucleus::createExtractElement(x.value(), Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3741 | } |
| 3742 | |
| 3743 | RValue<UInt4> Insert(RValue<UInt4> x, RValue<UInt> element, int i) |
| 3744 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3745 | return RValue<UInt4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | RValue<UInt4> Swizzle(RValue<UInt4> x, uint16_t select) |
| 3749 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3750 | return RValue<UInt4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3751 | } |
| 3752 | |
| 3753 | RValue<UInt4> Shuffle(RValue<UInt4> x, RValue<UInt4> y, unsigned short select) |
| 3754 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3755 | return RValue<UInt4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3756 | } |
| 3757 | |
| 3758 | Half::Half(RValue<Float> cast) |
| 3759 | { |
| 3760 | UInt fp32i = As<UInt>(cast); |
| 3761 | UInt abs = fp32i & 0x7FFFFFFF; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3762 | UShort fp16i((fp32i & 0x80000000) >> 16); // sign |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3763 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3764 | If(abs > 0x47FFEFFF) // Infinity |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3765 | { |
| 3766 | fp16i |= UShort(0x7FFF); |
| 3767 | } |
| 3768 | Else |
| 3769 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3770 | If(abs < 0x38800000) // Denormal |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3771 | { |
| 3772 | Int mantissa = (abs & 0x007FFFFF) | 0x00800000; |
| 3773 | Int e = 113 - (abs >> 23); |
Nicolas Capens | 60f8c2e | 2019-12-12 13:40:15 -0500 | [diff] [blame] | 3774 | abs = IfThenElse(e < 24, (mantissa >> e), Int(0)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3775 | fp16i |= UShort((abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3776 | } |
| 3777 | Else |
| 3778 | { |
| 3779 | fp16i |= UShort((abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3780 | } |
| 3781 | } |
| 3782 | |
| 3783 | storeValue(fp16i.loadValue()); |
| 3784 | } |
| 3785 | |
| 3786 | Float::Float(RValue<Int> cast) |
| 3787 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3788 | Value *integer = Nucleus::createSIToFP(cast.value(), Float::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3789 | |
| 3790 | storeValue(integer); |
| 3791 | } |
| 3792 | |
| 3793 | Float::Float(RValue<UInt> cast) |
| 3794 | { |
| 3795 | RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) + |
| 3796 | As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u))); |
| 3797 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3798 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3799 | } |
| 3800 | |
| 3801 | Float::Float(RValue<Half> cast) |
| 3802 | { |
| 3803 | Int fp16i(As<UShort>(cast)); |
| 3804 | |
| 3805 | Int s = (fp16i >> 15) & 0x00000001; |
| 3806 | Int e = (fp16i >> 10) & 0x0000001F; |
| 3807 | Int m = fp16i & 0x000003FF; |
| 3808 | |
| 3809 | UInt fp32i(s << 31); |
| 3810 | If(e == 0) |
| 3811 | { |
| 3812 | If(m != 0) |
| 3813 | { |
| 3814 | While((m & 0x00000400) == 0) |
| 3815 | { |
| 3816 | m <<= 1; |
| 3817 | e -= 1; |
| 3818 | } |
| 3819 | |
| 3820 | fp32i |= As<UInt>(((e + (127 - 15) + 1) << 23) | ((m & ~0x00000400) << 13)); |
| 3821 | } |
| 3822 | } |
| 3823 | Else |
| 3824 | { |
| 3825 | fp32i |= As<UInt>(((e + (127 - 15)) << 23) | (m << 13)); |
| 3826 | } |
| 3827 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3828 | storeValue(As<Float>(fp32i).value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3829 | } |
| 3830 | |
| 3831 | Float::Float(float x) |
| 3832 | { |
| 3833 | // C++ does not have a way to write an infinite or NaN literal, |
| 3834 | // nor does it allow division by zero as a constant expression. |
| 3835 | // Thus we should not accept inf or NaN as a Reactor Float constant, |
| 3836 | // as this would typically idicate a bug, and avoids undefined |
| 3837 | // behavior. |
| 3838 | // |
| 3839 | // This also prevents the issue of the LLVM JIT only taking double |
| 3840 | // values for constructing floating-point constants. During the |
| 3841 | // conversion from single-precision to double, a signaling NaN can |
| 3842 | // become a quiet NaN, thus altering its bit pattern. Hence this |
| 3843 | // assert is also helpful for detecting cases where integers are |
| 3844 | // being reinterpreted as float and then bitcast to integer again, |
| 3845 | // which does not guarantee preserving the integer value. |
| 3846 | // |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3847 | // The inifinity() method can be used to obtain positive infinity. |
| 3848 | // Should NaN constants be required, methods like quiet_NaN() and |
| 3849 | // signaling_NaN() should be added (matching std::numeric_limits). |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3850 | ASSERT(std::isfinite(x)); |
| 3851 | |
| 3852 | storeValue(Nucleus::createConstantFloat(x)); |
| 3853 | } |
| 3854 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3855 | // TODO(b/140302841): Negative infinity can be obtained by using '-infinity()'. |
| 3856 | // This comes at a minor run-time JIT cost, and the backend may or may not |
| 3857 | // perform constant folding. This can be optimized by having Reactor perform |
| 3858 | // the folding, which would still be cheaper than having a capable backend do it. |
| 3859 | Float Float::infinity() |
| 3860 | { |
| 3861 | Float result; |
| 3862 | |
| 3863 | constexpr double inf = std::numeric_limits<double>::infinity(); |
| 3864 | result.storeValue(Nucleus::createConstantFloat(inf)); |
| 3865 | |
| 3866 | return result; |
| 3867 | } |
| 3868 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3869 | Float::Float(RValue<Float> rhs) |
| 3870 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3871 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3872 | } |
| 3873 | |
| 3874 | Float::Float(const Float &rhs) |
| 3875 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3876 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3877 | } |
| 3878 | |
| 3879 | Float::Float(const Reference<Float> &rhs) |
| 3880 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3881 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3882 | } |
| 3883 | |
| 3884 | Float::Float(Argument<Float> argument) |
| 3885 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3886 | store(argument.rvalue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3887 | } |
| 3888 | |
Nicolas Capens | 0aca3ca | 2020-09-19 23:59:08 -0400 | [diff] [blame] | 3889 | RValue<Float> Float::operator=(float rhs) |
| 3890 | { |
| 3891 | return RValue<Float>(storeValue(Nucleus::createConstantFloat(rhs))); |
| 3892 | } |
| 3893 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3894 | RValue<Float> Float::operator=(RValue<Float> rhs) |
| 3895 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 3896 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3897 | } |
| 3898 | |
| 3899 | RValue<Float> Float::operator=(const Float &rhs) |
| 3900 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3901 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3902 | } |
| 3903 | |
| 3904 | RValue<Float> Float::operator=(const Reference<Float> &rhs) |
| 3905 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 3906 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3907 | } |
| 3908 | |
| 3909 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
| 3910 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3911 | return RValue<Float>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3912 | } |
| 3913 | |
| 3914 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
| 3915 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3916 | return RValue<Float>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3917 | } |
| 3918 | |
| 3919 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
| 3920 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3921 | return RValue<Float>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3922 | } |
| 3923 | |
| 3924 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
| 3925 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3926 | return RValue<Float>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3927 | } |
| 3928 | |
| 3929 | RValue<Float> operator+=(Float &lhs, RValue<Float> rhs) |
| 3930 | { |
| 3931 | return lhs = lhs + rhs; |
| 3932 | } |
| 3933 | |
| 3934 | RValue<Float> operator-=(Float &lhs, RValue<Float> rhs) |
| 3935 | { |
| 3936 | return lhs = lhs - rhs; |
| 3937 | } |
| 3938 | |
| 3939 | RValue<Float> operator*=(Float &lhs, RValue<Float> rhs) |
| 3940 | { |
| 3941 | return lhs = lhs * rhs; |
| 3942 | } |
| 3943 | |
| 3944 | RValue<Float> operator/=(Float &lhs, RValue<Float> rhs) |
| 3945 | { |
| 3946 | return lhs = lhs / rhs; |
| 3947 | } |
| 3948 | |
| 3949 | RValue<Float> operator+(RValue<Float> val) |
| 3950 | { |
| 3951 | return val; |
| 3952 | } |
| 3953 | |
| 3954 | RValue<Float> operator-(RValue<Float> val) |
| 3955 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3956 | return RValue<Float>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3957 | } |
| 3958 | |
| 3959 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
| 3960 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3961 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3962 | } |
| 3963 | |
| 3964 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
| 3965 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3966 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3967 | } |
| 3968 | |
| 3969 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
| 3970 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3971 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3972 | } |
| 3973 | |
| 3974 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
| 3975 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3976 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3977 | } |
| 3978 | |
| 3979 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
| 3980 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3981 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3982 | } |
| 3983 | |
| 3984 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
| 3985 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 3986 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3987 | } |
| 3988 | |
| 3989 | RValue<Float> Abs(RValue<Float> x) |
| 3990 | { |
| 3991 | return IfThenElse(x > 0.0f, x, -x); |
| 3992 | } |
| 3993 | |
| 3994 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
| 3995 | { |
| 3996 | return IfThenElse(x > y, x, y); |
| 3997 | } |
| 3998 | |
| 3999 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
| 4000 | { |
| 4001 | return IfThenElse(x < y, x, y); |
| 4002 | } |
| 4003 | |
| 4004 | Float2::Float2(RValue<Float4> cast) |
| 4005 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4006 | storeValue(Nucleus::createBitCast(cast.value(), type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4007 | } |
| 4008 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4009 | Float4::Float4(RValue<Byte4> cast) |
| 4010 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4011 | { |
| 4012 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4013 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4014 | |
| 4015 | storeValue(xyzw); |
| 4016 | } |
| 4017 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4018 | Float4::Float4(RValue<SByte4> cast) |
| 4019 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4020 | { |
| 4021 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4022 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4023 | |
| 4024 | storeValue(xyzw); |
| 4025 | } |
| 4026 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4027 | Float4::Float4(RValue<Short4> cast) |
| 4028 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4029 | { |
| 4030 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4031 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4032 | } |
| 4033 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4034 | Float4::Float4(RValue<UShort4> cast) |
| 4035 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4036 | { |
| 4037 | Int4 c(cast); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4038 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value(), Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4039 | } |
| 4040 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4041 | Float4::Float4(RValue<Int4> cast) |
| 4042 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4043 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4044 | Value *xyzw = Nucleus::createSIToFP(cast.value(), Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4045 | |
| 4046 | storeValue(xyzw); |
| 4047 | } |
| 4048 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4049 | Float4::Float4(RValue<UInt4> cast) |
| 4050 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4051 | { |
| 4052 | RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) + |
| 4053 | As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u))); |
| 4054 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4055 | storeValue(result.value()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4056 | } |
| 4057 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4058 | Float4::Float4() |
| 4059 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4060 | { |
| 4061 | } |
| 4062 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4063 | Float4::Float4(float xyzw) |
| 4064 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4065 | { |
| 4066 | constant(xyzw, xyzw, xyzw, xyzw); |
| 4067 | } |
| 4068 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4069 | Float4::Float4(float x, float yzw) |
| 4070 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4071 | { |
| 4072 | constant(x, yzw, yzw, yzw); |
| 4073 | } |
| 4074 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4075 | Float4::Float4(float x, float y, float zw) |
| 4076 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4077 | { |
| 4078 | constant(x, y, zw, zw); |
| 4079 | } |
| 4080 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4081 | Float4::Float4(float x, float y, float z, float w) |
| 4082 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4083 | { |
| 4084 | constant(x, y, z, w); |
| 4085 | } |
| 4086 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4087 | Float4 Float4::infinity() |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4088 | { |
| 4089 | Float4 result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4090 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4091 | constexpr double inf = std::numeric_limits<double>::infinity(); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4092 | double constantVector[4] = { inf, inf, inf, inf }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4093 | result.storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 4094 | |
| 4095 | return result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4096 | } |
| 4097 | |
| 4098 | void Float4::constant(float x, float y, float z, float w) |
| 4099 | { |
| 4100 | // See Float(float) constructor for the rationale behind this assert. |
| 4101 | ASSERT(std::isfinite(x) && std::isfinite(y) && std::isfinite(z) && std::isfinite(w)); |
| 4102 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4103 | double constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4104 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4105 | } |
| 4106 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4107 | Float4::Float4(RValue<Float4> rhs) |
| 4108 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4109 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4110 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4111 | } |
| 4112 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4113 | Float4::Float4(const Float4 &rhs) |
| 4114 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4115 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4116 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4117 | } |
| 4118 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4119 | Float4::Float4(const Reference<Float4> &rhs) |
| 4120 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4121 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4122 | store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4123 | } |
| 4124 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4125 | Float4::Float4(const Float &rhs) |
| 4126 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4127 | { |
| 4128 | *this = RValue<Float>(rhs.loadValue()); |
| 4129 | } |
| 4130 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4131 | Float4::Float4(const Reference<Float> &rhs) |
| 4132 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4133 | { |
| 4134 | *this = RValue<Float>(rhs.loadValue()); |
| 4135 | } |
| 4136 | |
Nicolas Capens | 419b7d7 | 2020-10-02 16:15:34 -0400 | [diff] [blame] | 4137 | Float4::Float4(RValue<Float2> lo, RValue<Float2> hi) |
| 4138 | : XYZW(this) |
| 4139 | { |
| 4140 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
| 4141 | Value *packed = Nucleus::createShuffleVector(lo.value(), hi.value(), shuffle); |
| 4142 | |
| 4143 | storeValue(packed); |
| 4144 | } |
| 4145 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4146 | RValue<Float4> Float4::operator=(float x) |
| 4147 | { |
| 4148 | return *this = Float4(x, x, x, x); |
| 4149 | } |
| 4150 | |
| 4151 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) |
| 4152 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame] | 4153 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4154 | } |
| 4155 | |
| 4156 | RValue<Float4> Float4::operator=(const Float4 &rhs) |
| 4157 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4158 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4159 | } |
| 4160 | |
| 4161 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) |
| 4162 | { |
Nicolas Capens | b4e4f11 | 2020-05-01 23:06:41 -0400 | [diff] [blame] | 4163 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4164 | } |
| 4165 | |
| 4166 | RValue<Float4> Float4::operator=(RValue<Float> rhs) |
| 4167 | { |
| 4168 | return *this = Float4(rhs); |
| 4169 | } |
| 4170 | |
| 4171 | RValue<Float4> Float4::operator=(const Float &rhs) |
| 4172 | { |
| 4173 | return *this = Float4(rhs); |
| 4174 | } |
| 4175 | |
| 4176 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) |
| 4177 | { |
| 4178 | return *this = Float4(rhs); |
| 4179 | } |
| 4180 | |
| 4181 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4182 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4183 | return RValue<Float4>(Nucleus::createFAdd(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4184 | } |
| 4185 | |
| 4186 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4187 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4188 | return RValue<Float4>(Nucleus::createFSub(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4189 | } |
| 4190 | |
| 4191 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4192 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4193 | return RValue<Float4>(Nucleus::createFMul(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4194 | } |
| 4195 | |
| 4196 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4197 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4198 | return RValue<Float4>(Nucleus::createFDiv(lhs.value(), rhs.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4199 | } |
| 4200 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4201 | RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs) |
| 4202 | { |
| 4203 | return lhs = lhs + rhs; |
| 4204 | } |
| 4205 | |
| 4206 | RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs) |
| 4207 | { |
| 4208 | return lhs = lhs - rhs; |
| 4209 | } |
| 4210 | |
| 4211 | RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs) |
| 4212 | { |
| 4213 | return lhs = lhs * rhs; |
| 4214 | } |
| 4215 | |
| 4216 | RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs) |
| 4217 | { |
| 4218 | return lhs = lhs / rhs; |
| 4219 | } |
| 4220 | |
| 4221 | RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs) |
| 4222 | { |
| 4223 | return lhs = lhs % rhs; |
| 4224 | } |
| 4225 | |
| 4226 | RValue<Float4> operator+(RValue<Float4> val) |
| 4227 | { |
| 4228 | return val; |
| 4229 | } |
| 4230 | |
| 4231 | RValue<Float4> operator-(RValue<Float4> val) |
| 4232 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4233 | return RValue<Float4>(Nucleus::createFNeg(val.value())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4234 | } |
| 4235 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4236 | RValue<Float4> Insert(RValue<Float4> x, RValue<Float> element, int i) |
| 4237 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4238 | return RValue<Float4>(Nucleus::createInsertElement(x.value(), element.value(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4239 | } |
| 4240 | |
| 4241 | RValue<Float> Extract(RValue<Float4> x, int i) |
| 4242 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4243 | return RValue<Float>(Nucleus::createExtractElement(x.value(), Float::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4244 | } |
| 4245 | |
| 4246 | RValue<Float4> Swizzle(RValue<Float4> x, uint16_t select) |
| 4247 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4248 | return RValue<Float4>(createSwizzle4(x.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4249 | } |
| 4250 | |
| 4251 | RValue<Float4> Shuffle(RValue<Float4> x, RValue<Float4> y, uint16_t select) |
| 4252 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4253 | return RValue<Float4>(createShuffle4(x.value(), y.value(), select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4254 | } |
| 4255 | |
| 4256 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, uint16_t imm) |
| 4257 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4258 | int shuffle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4259 | ((imm >> 12) & 0x03) + 0, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4260 | ((imm >> 8) & 0x03) + 0, |
| 4261 | ((imm >> 4) & 0x03) + 4, |
| 4262 | ((imm >> 0) & 0x03) + 4, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4263 | }; |
| 4264 | |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4265 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4266 | } |
| 4267 | |
| 4268 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) |
| 4269 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4270 | int shuffle[4] = { 0, 4, 1, 5 }; |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4271 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4272 | } |
| 4273 | |
| 4274 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
| 4275 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4276 | int shuffle[4] = { 2, 6, 3, 7 }; |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4277 | return RValue<Float4>(Nucleus::createShuffleVector(x.value(), y.value(), shuffle)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4278 | } |
| 4279 | |
| 4280 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, uint16_t select) |
| 4281 | { |
| 4282 | Value *vector = lhs.loadValue(); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4283 | Value *result = createMask4(vector, rhs.value(), select); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4284 | lhs.storeValue(result); |
| 4285 | |
| 4286 | return RValue<Float4>(result); |
| 4287 | } |
| 4288 | |
| 4289 | RValue<Int4> IsInf(RValue<Float4> x) |
| 4290 | { |
| 4291 | return CmpEQ(As<Int4>(x) & Int4(0x7FFFFFFF), Int4(0x7F800000)); |
| 4292 | } |
| 4293 | |
| 4294 | RValue<Int4> IsNan(RValue<Float4> x) |
| 4295 | { |
| 4296 | return ~CmpEQ(x, x); |
| 4297 | } |
| 4298 | |
| 4299 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) |
| 4300 | { |
| 4301 | return lhs + RValue<Int>(Nucleus::createConstantInt(offset)); |
| 4302 | } |
| 4303 | |
| 4304 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4305 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4306 | 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] | 4307 | } |
| 4308 | |
| 4309 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4310 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4311 | return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value(), Byte::type(), offset.value(), true)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4312 | } |
| 4313 | |
| 4314 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset) |
| 4315 | { |
| 4316 | return lhs = lhs + offset; |
| 4317 | } |
| 4318 | |
| 4319 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4320 | { |
| 4321 | return lhs = lhs + offset; |
| 4322 | } |
| 4323 | |
| 4324 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4325 | { |
| 4326 | return lhs = lhs + offset; |
| 4327 | } |
| 4328 | |
| 4329 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset) |
| 4330 | { |
| 4331 | return lhs + -offset; |
| 4332 | } |
| 4333 | |
| 4334 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4335 | { |
| 4336 | return lhs + -offset; |
| 4337 | } |
| 4338 | |
| 4339 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4340 | { |
| 4341 | return lhs + -offset; |
| 4342 | } |
| 4343 | |
| 4344 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset) |
| 4345 | { |
| 4346 | return lhs = lhs - offset; |
| 4347 | } |
| 4348 | |
| 4349 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4350 | { |
| 4351 | return lhs = lhs - offset; |
| 4352 | } |
| 4353 | |
| 4354 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4355 | { |
| 4356 | return lhs = lhs - offset; |
| 4357 | } |
| 4358 | |
| 4359 | void Return() |
| 4360 | { |
| 4361 | Nucleus::createRetVoid(); |
| 4362 | // Place any unreachable instructions in an unreferenced block. |
| 4363 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 4364 | } |
| 4365 | |
| 4366 | void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
| 4367 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4368 | Nucleus::createCondBr(cmp.value(), bodyBB, endBB); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4369 | Nucleus::setInsertBlock(bodyBB); |
| 4370 | } |
| 4371 | |
| 4372 | RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4373 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4374 | 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] | 4375 | } |
| 4376 | |
| 4377 | RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4378 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4379 | return RValue<Int4>(Nucleus::createMaskedLoad(base.value(), Int::type(), mask.value(), alignment, zeroMaskedLanes)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4380 | } |
| 4381 | |
| 4382 | void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment) |
| 4383 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4384 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4385 | } |
| 4386 | |
| 4387 | void MaskedStore(RValue<Pointer<Int4>> base, RValue<Int4> val, RValue<Int4> mask, unsigned int alignment) |
| 4388 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4389 | Nucleus::createMaskedStore(base.value(), val.value(), mask.value(), alignment); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4390 | } |
| 4391 | |
| 4392 | void Fence(std::memory_order memoryOrder) |
| 4393 | { |
| 4394 | ASSERT_MSG(memoryOrder == std::memory_order_acquire || |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4395 | memoryOrder == std::memory_order_release || |
| 4396 | memoryOrder == std::memory_order_acq_rel || |
| 4397 | memoryOrder == std::memory_order_seq_cst, |
| 4398 | "Unsupported memoryOrder: %d", int(memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4399 | Nucleus::createFence(memoryOrder); |
| 4400 | } |
| 4401 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4402 | Bool CToReactor<bool>::cast(bool v) |
| 4403 | { |
| 4404 | return type(v); |
| 4405 | } |
| 4406 | Byte CToReactor<uint8_t>::cast(uint8_t v) |
| 4407 | { |
| 4408 | return type(v); |
| 4409 | } |
| 4410 | SByte CToReactor<int8_t>::cast(int8_t v) |
| 4411 | { |
| 4412 | return type(v); |
| 4413 | } |
| 4414 | Short CToReactor<int16_t>::cast(int16_t v) |
| 4415 | { |
| 4416 | return type(v); |
| 4417 | } |
| 4418 | UShort CToReactor<uint16_t>::cast(uint16_t v) |
| 4419 | { |
| 4420 | return type(v); |
| 4421 | } |
| 4422 | Int CToReactor<int32_t>::cast(int32_t v) |
| 4423 | { |
| 4424 | return type(v); |
| 4425 | } |
| 4426 | UInt CToReactor<uint32_t>::cast(uint32_t v) |
| 4427 | { |
| 4428 | return type(v); |
| 4429 | } |
| 4430 | Float CToReactor<float>::cast(float v) |
| 4431 | { |
| 4432 | return type(v); |
| 4433 | } |
| 4434 | Float4 CToReactor<float[4]>::cast(float v[4]) |
| 4435 | { |
| 4436 | return type(v[0], v[1], v[2], v[3]); |
| 4437 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4438 | |
| 4439 | // TODO: Long has no constructor that takes a uint64_t |
| 4440 | // Long CToReactor<uint64_t>::cast(uint64_t v) { return type(v); } |
| 4441 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4442 | #ifdef ENABLE_RR_PRINT |
| 4443 | static std::string replaceAll(std::string str, const std::string &substr, const std::string &replacement) |
| 4444 | { |
| 4445 | size_t pos = 0; |
| 4446 | while((pos = str.find(substr, pos)) != std::string::npos) |
| 4447 | { |
| 4448 | str.replace(pos, substr.length(), replacement); |
| 4449 | pos += replacement.length(); |
| 4450 | } |
| 4451 | return str; |
| 4452 | } |
| 4453 | |
| 4454 | // extractAll returns a vector containing the extracted n scalar value of |
| 4455 | // the vector vec. |
| 4456 | // TODO: Move to Reactor.cpp (LLVMReactor can use this too) |
| 4457 | static std::vector<Value *> extractAll(Value *vec, int n) |
| 4458 | { |
| 4459 | Type *elemTy = Nucleus::getContainedType(Nucleus::getType(vec)); |
| 4460 | std::vector<Value *> elements; |
| 4461 | elements.reserve(n); |
| 4462 | for(int i = 0; i < n; i++) |
| 4463 | { |
| 4464 | auto el = Nucleus::createExtractElement(vec, elemTy, i); |
| 4465 | elements.push_back(el); |
| 4466 | } |
| 4467 | return elements; |
| 4468 | } |
| 4469 | |
| 4470 | // toInt returns all the integer values in vals extended to a printf-required storage value |
| 4471 | static std::vector<Value *> toInt(const std::vector<Value *> &vals, bool isSigned) |
| 4472 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4473 | auto storageTy = Nucleus::getPrintfStorageType(Int::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4474 | std::vector<Value *> elements; |
| 4475 | elements.reserve(vals.size()); |
| 4476 | for(auto v : vals) |
| 4477 | { |
| 4478 | if(isSigned) |
| 4479 | { |
| 4480 | elements.push_back(Nucleus::createSExt(v, storageTy)); |
| 4481 | } |
| 4482 | else |
| 4483 | { |
| 4484 | elements.push_back(Nucleus::createZExt(v, storageTy)); |
| 4485 | } |
| 4486 | } |
| 4487 | return elements; |
| 4488 | } |
| 4489 | |
| 4490 | // toFloat returns all the float values in vals extended to extended to a printf-required storage value |
| 4491 | static std::vector<Value *> toFloat(const std::vector<Value *> &vals) |
| 4492 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4493 | auto storageTy = Nucleus::getPrintfStorageType(Float::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4494 | std::vector<Value *> elements; |
| 4495 | elements.reserve(vals.size()); |
| 4496 | for(auto v : vals) |
| 4497 | { |
| 4498 | elements.push_back(Nucleus::createFPExt(v, storageTy)); |
| 4499 | } |
| 4500 | return elements; |
| 4501 | } |
| 4502 | |
| 4503 | std::vector<Value *> PrintValue::Ty<Bool>::val(const RValue<Bool> &v) |
| 4504 | { |
| 4505 | auto t = Nucleus::createConstantString("true"); |
| 4506 | auto f = Nucleus::createConstantString("false"); |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4507 | return { Nucleus::createSelect(v.value(), t, f) }; |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4508 | } |
| 4509 | |
| 4510 | std::vector<Value *> PrintValue::Ty<Byte>::val(const RValue<Byte> &v) |
| 4511 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4512 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4513 | } |
| 4514 | |
| 4515 | std::vector<Value *> PrintValue::Ty<Byte4>::val(const RValue<Byte4> &v) |
| 4516 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4517 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4518 | } |
| 4519 | |
| 4520 | std::vector<Value *> PrintValue::Ty<Int>::val(const RValue<Int> &v) |
| 4521 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4522 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4523 | } |
| 4524 | |
| 4525 | std::vector<Value *> PrintValue::Ty<Int2>::val(const RValue<Int2> &v) |
| 4526 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4527 | return toInt(extractAll(v.value(), 2), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4528 | } |
| 4529 | |
| 4530 | std::vector<Value *> PrintValue::Ty<Int4>::val(const RValue<Int4> &v) |
| 4531 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4532 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4533 | } |
| 4534 | |
| 4535 | std::vector<Value *> PrintValue::Ty<UInt>::val(const RValue<UInt> &v) |
| 4536 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4537 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4538 | } |
| 4539 | |
| 4540 | std::vector<Value *> PrintValue::Ty<UInt2>::val(const RValue<UInt2> &v) |
| 4541 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4542 | return toInt(extractAll(v.value(), 2), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4543 | } |
| 4544 | |
| 4545 | std::vector<Value *> PrintValue::Ty<UInt4>::val(const RValue<UInt4> &v) |
| 4546 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4547 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4548 | } |
| 4549 | |
| 4550 | std::vector<Value *> PrintValue::Ty<Short>::val(const RValue<Short> &v) |
| 4551 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4552 | return toInt({ v.value() }, true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4553 | } |
| 4554 | |
| 4555 | std::vector<Value *> PrintValue::Ty<Short4>::val(const RValue<Short4> &v) |
| 4556 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4557 | return toInt(extractAll(v.value(), 4), true); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4558 | } |
| 4559 | |
| 4560 | std::vector<Value *> PrintValue::Ty<UShort>::val(const RValue<UShort> &v) |
| 4561 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4562 | return toInt({ v.value() }, false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4563 | } |
| 4564 | |
| 4565 | std::vector<Value *> PrintValue::Ty<UShort4>::val(const RValue<UShort4> &v) |
| 4566 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4567 | return toInt(extractAll(v.value(), 4), false); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4568 | } |
| 4569 | |
| 4570 | std::vector<Value *> PrintValue::Ty<Float>::val(const RValue<Float> &v) |
| 4571 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4572 | return toFloat({ v.value() }); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4573 | } |
| 4574 | |
| 4575 | std::vector<Value *> PrintValue::Ty<Float4>::val(const RValue<Float4> &v) |
| 4576 | { |
Nicolas Capens | b6e8c3f | 2020-05-01 23:28:37 -0400 | [diff] [blame] | 4577 | return toFloat(extractAll(v.value(), 4)); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | std::vector<Value *> PrintValue::Ty<const char *>::val(const char *v) |
| 4581 | { |
| 4582 | return { Nucleus::createConstantString(v) }; |
| 4583 | } |
| 4584 | |
| 4585 | void Printv(const char *function, const char *file, int line, const char *fmt, std::initializer_list<PrintValue> args) |
| 4586 | { |
| 4587 | // Build the printf format message string. |
| 4588 | std::string str; |
| 4589 | if(file != nullptr) { str += (line > 0) ? "%s:%d " : "%s "; } |
| 4590 | if(function != nullptr) { str += "%s "; } |
| 4591 | str += fmt; |
| 4592 | |
| 4593 | // Perform substitution on all '{n}' bracketed indices in the format |
| 4594 | // message. |
| 4595 | int i = 0; |
| 4596 | for(const PrintValue &arg : args) |
| 4597 | { |
| 4598 | str = replaceAll(str, "{" + std::to_string(i++) + "}", arg.format); |
| 4599 | } |
| 4600 | |
| 4601 | std::vector<Value *> vals; |
| 4602 | vals.reserve(8); |
| 4603 | |
| 4604 | // The format message is always the first argument. |
| 4605 | vals.push_back(Nucleus::createConstantString(str)); |
| 4606 | |
| 4607 | // Add optional file, line and function info if provided. |
| 4608 | if(file != nullptr) |
| 4609 | { |
| 4610 | vals.push_back(Nucleus::createConstantString(file)); |
| 4611 | if(line > 0) |
| 4612 | { |
| 4613 | vals.push_back(Nucleus::createConstantInt(line)); |
| 4614 | } |
| 4615 | } |
| 4616 | if(function != nullptr) |
| 4617 | { |
| 4618 | vals.push_back(Nucleus::createConstantString(function)); |
| 4619 | } |
| 4620 | |
| 4621 | // Add all format arguments. |
| 4622 | for(const PrintValue &arg : args) |
| 4623 | { |
| 4624 | for(auto val : arg.values) |
| 4625 | { |
| 4626 | vals.push_back(val); |
| 4627 | } |
| 4628 | } |
| 4629 | |
| 4630 | // This call is implemented by each backend |
| 4631 | VPrintf(vals); |
| 4632 | } |
Antonio Maiorano | 8cbee41 | 2020-06-10 15:59:20 -0400 | [diff] [blame] | 4633 | |
| 4634 | // This is the function that is called by VPrintf from the backends |
| 4635 | int DebugPrintf(const char *format, ...) |
| 4636 | { |
| 4637 | // Uncomment this to make it so that we do not print, but the call to this function is emitted. |
| 4638 | // Useful when debugging emitted code to see the Reactor source location. |
| 4639 | //# define RR_PRINT_OUTPUT_TYPE_STUB |
| 4640 | |
| 4641 | # if defined(RR_PRINT_OUTPUT_TYPE_STUB) |
| 4642 | return 0; |
| 4643 | # else |
| 4644 | |
| 4645 | int result; |
| 4646 | va_list args; |
| 4647 | |
| 4648 | va_start(args, format); |
| 4649 | char buffer[2048]; |
| 4650 | result = vsprintf(buffer, format, args); |
| 4651 | va_end(args); |
| 4652 | |
| 4653 | std::fputs(buffer, stdout); |
| 4654 | # if defined(_WIN32) |
| 4655 | OutputDebugString(buffer); |
| 4656 | # endif |
| 4657 | |
| 4658 | return result; |
| 4659 | # endif |
| 4660 | } |
| 4661 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4662 | #endif // ENABLE_RR_PRINT |
| 4663 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4664 | // Functions implemented by backends |
| 4665 | bool HasRcpApprox(); |
| 4666 | RValue<Float4> RcpApprox(RValue<Float4> x, bool exactAtPow2 = false); |
| 4667 | RValue<Float> RcpApprox(RValue<Float> x, bool exactAtPow2 = false); |
| 4668 | |
| 4669 | template<typename T> |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4670 | static RValue<T> DoRcp(RValue<T> x, bool relaxedPrecision, bool exactAtPow2) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4671 | { |
| 4672 | #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] | 4673 | bool approx = HasRcpApprox() && relaxedPrecision; |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4674 | #else |
| 4675 | bool approx = HasRcpApprox(); |
| 4676 | #endif |
| 4677 | |
| 4678 | T rcp; |
| 4679 | |
| 4680 | if(approx) |
| 4681 | { |
| 4682 | rcp = RcpApprox(x, exactAtPow2); |
| 4683 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4684 | if(!relaxedPrecision) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4685 | { |
| 4686 | // Perform one more iteration of Newton-Rhapson division to increase precision |
| 4687 | rcp = (rcp + rcp) - (x * rcp * rcp); |
| 4688 | } |
| 4689 | } |
| 4690 | else |
| 4691 | { |
| 4692 | rcp = T(1.0f) / x; |
| 4693 | } |
| 4694 | |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4695 | return rcp; |
| 4696 | } |
| 4697 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4698 | RValue<Float4> Rcp(RValue<Float4> x, bool relaxedPrecision, bool exactAtPow2) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4699 | { |
| 4700 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4701 | return DoRcp(x, relaxedPrecision, exactAtPow2); |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4702 | } |
| 4703 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4704 | RValue<Float> Rcp(RValue<Float> x, bool relaxedPrecision, bool exactAtPow2) |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4705 | { |
| 4706 | RR_DEBUG_INFO_UPDATE_LOC(); |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4707 | return DoRcp(x, relaxedPrecision, exactAtPow2); |
Antonio Maiorano | d156187 | 2020-12-14 14:03:53 -0500 | [diff] [blame] | 4708 | } |
| 4709 | |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4710 | // Functions implemented by backends |
| 4711 | bool HasRcpSqrtApprox(); |
| 4712 | RValue<Float4> RcpSqrtApprox(RValue<Float4> x); |
| 4713 | RValue<Float> RcpSqrtApprox(RValue<Float> x); |
| 4714 | |
| 4715 | template<typename T> |
| 4716 | struct CastToIntType; |
| 4717 | |
| 4718 | template<> |
| 4719 | struct CastToIntType<Float4> |
| 4720 | { |
| 4721 | using type = Int4; |
| 4722 | }; |
| 4723 | |
| 4724 | template<> |
| 4725 | struct CastToIntType<Float> |
| 4726 | { |
| 4727 | using type = Int; |
| 4728 | }; |
| 4729 | |
| 4730 | // TODO: move to Reactor.hpp? |
| 4731 | RValue<Int> CmpNEQ(RValue<Int> x, RValue<Int> y) |
| 4732 | { |
| 4733 | return IfThenElse(x != y, Int(~0), Int(0)); |
| 4734 | } |
| 4735 | |
| 4736 | template<typename T> |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4737 | static RValue<T> DoRcpSqrt(RValue<T> x, bool relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4738 | { |
| 4739 | #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] | 4740 | bool approx = HasRcpApprox() && relaxedPrecision; |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4741 | #else |
| 4742 | bool approx = HasRcpApprox(); |
| 4743 | #endif |
| 4744 | |
| 4745 | if(approx) |
| 4746 | { |
| 4747 | using IntType = typename CastToIntType<T>::type; |
| 4748 | |
| 4749 | T rsq = RcpSqrtApprox(x); |
| 4750 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4751 | if(!relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4752 | { |
| 4753 | rsq = rsq * (T(3.0f) - rsq * rsq * x) * T(0.5f); |
| 4754 | rsq = As<T>(CmpNEQ(As<IntType>(x), IntType(0x7F800000)) & As<IntType>(rsq)); |
| 4755 | } |
| 4756 | |
| 4757 | return rsq; |
| 4758 | } |
| 4759 | else |
| 4760 | { |
| 4761 | return T(1.0f) / Sqrt(x); |
| 4762 | } |
| 4763 | } |
| 4764 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4765 | RValue<Float4> RcpSqrt(RValue<Float4> x, bool relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4766 | { |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4767 | return DoRcpSqrt(x, relaxedPrecision); |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4768 | } |
| 4769 | |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4770 | RValue<Float> RcpSqrt(RValue<Float> x, bool relaxedPrecision) |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4771 | { |
Nicolas Capens | d04f3f5 | 2022-02-05 01:19:14 -0500 | [diff] [blame] | 4772 | return DoRcpSqrt(x, relaxedPrecision); |
Antonio Maiorano | 1cc5b33 | 2020-12-14 16:57:28 -0500 | [diff] [blame] | 4773 | } |
| 4774 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4775 | } // namespace rr |