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 | |
Ben Clayton | b16c586 | 2019-05-08 14:01:38 +0100 | [diff] [blame] | 17 | #include "Debug.hpp" |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 18 | #include "Print.hpp" |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 19 | |
Ben Clayton | 983761c | 2020-04-01 19:49:44 +0100 | [diff] [blame] | 20 | #include <algorithm> |
Nicolas Capens | d94d6a3 | 2019-08-31 04:04:37 +0000 | [diff] [blame] | 21 | #include <cmath> |
| 22 | |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 23 | // Define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION to non-zero to ensure all |
| 24 | // variables have a stack location obtained throuch alloca(). |
| 25 | #ifndef REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 26 | # define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION 0 |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 27 | #endif |
| 28 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 29 | namespace rr { |
| 30 | |
| 31 | const Config::Edit Config::Edit::None = {}; |
| 32 | |
| 33 | Config Config::Edit::apply(const Config &cfg) const |
| 34 | { |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 35 | if(this == &None) { return cfg; } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 36 | |
| 37 | auto level = optLevelChanged ? optLevel : cfg.optimization.getLevel(); |
| 38 | auto passes = cfg.optimization.getPasses(); |
| 39 | apply(optPassEdits, passes); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 40 | return Config{ Optimization{ level, passes } }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 41 | } |
| 42 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 43 | template<typename T> |
| 44 | 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] | 45 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 46 | for(auto &edit : edits) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 47 | { |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 48 | switch(edit.first) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 49 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 50 | case ListEdit::Add: |
| 51 | list.push_back(edit.second); |
| 52 | break; |
| 53 | case ListEdit::Remove: |
Ben Clayton | 983761c | 2020-04-01 19:49:44 +0100 | [diff] [blame] | 54 | list.erase(std::remove_if(list.begin(), list.end(), [&](T item) { |
| 55 | return item == edit.second; |
| 56 | }), |
| 57 | list.end()); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 58 | break; |
| 59 | case ListEdit::Clear: |
| 60 | list.clear(); |
| 61 | break; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 62 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 66 | // Set of variables that do not have a stack location yet. |
Nicolas Capens | 67cdce9 | 2020-05-01 21:37:20 -0400 | [diff] [blame] | 67 | thread_local std::unordered_set<const Variable *> *Variable::unmaterializedVariables = nullptr; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 68 | |
Nicolas Capens | 67cdce9 | 2020-05-01 21:37:20 -0400 | [diff] [blame] | 69 | Variable::Variable(int arraySize) |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 70 | : arraySize(arraySize) |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 71 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 72 | #if REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION |
| 73 | materialize(); |
| 74 | #else |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 75 | unmaterializedVariables->emplace(this); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 76 | #endif |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 77 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 78 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 79 | Variable::~Variable() |
| 80 | { |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 81 | unmaterializedVariables->erase(this); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 82 | } |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 83 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 84 | void Variable::materializeAll() |
| 85 | { |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 86 | for(auto *var : *unmaterializedVariables) |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 87 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 88 | var->materialize(); |
Ben Clayton | 55bc37a | 2019-07-04 12:17:12 +0100 | [diff] [blame] | 89 | } |
| 90 | |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 91 | unmaterializedVariables->clear(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 92 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 93 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 94 | void Variable::killUnmaterialized() |
| 95 | { |
Nicolas Capens | 7d6b591 | 2020-04-28 15:57:57 -0400 | [diff] [blame] | 96 | unmaterializedVariables->clear(); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 97 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 98 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 99 | // NOTE: Only 12 bits out of 16 of the |select| value are used. |
| 100 | // More specifically, the value should look like: |
| 101 | // |
| 102 | // msb lsb |
| 103 | // v v |
| 104 | // [.xxx|.yyy|.zzz|.www] where '.' means an ignored bit |
| 105 | // |
| 106 | // This format makes it easy to write calls with hexadecimal select values, |
| 107 | // since each hex digit is a separate swizzle index. |
| 108 | // |
| 109 | // For example: |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 110 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x0123 ) -> [a,b,c,d] |
| 111 | // createShuffle4( [a,b,c,d], [e,f,g,h], 0x4567 ) -> [e,f,g,h] |
| 112 | // 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] | 113 | // |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 114 | static Value *createShuffle4(Value *lhs, Value *rhs, uint16_t select) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 115 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 116 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 117 | (select >> 12) & 0x07, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 118 | (select >> 8) & 0x07, |
| 119 | (select >> 4) & 0x07, |
| 120 | (select >> 0) & 0x07, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 121 | }; |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 122 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 123 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 124 | } |
Nicolas Capens | 0192d15 | 2019-03-27 14:46:07 -0400 | [diff] [blame] | 125 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 126 | // NOTE: Only 8 bits out of 16 of the |select| value are used. |
| 127 | // More specifically, the value should look like: |
| 128 | // |
| 129 | // msb lsb |
| 130 | // v v |
| 131 | // [..xx|..yy|..zz|..ww] where '.' means an ignored bit |
| 132 | // |
| 133 | // This format makes it easy to write calls with hexadecimal select values, |
| 134 | // since each hex digit is a separate swizzle index. |
| 135 | // |
| 136 | // For example: |
| 137 | // createSwizzle4( [a,b,c,d], 0x0123 ) -> [a,b,c,d] |
| 138 | // createSwizzle4( [a,b,c,d], 0x0033 ) -> [a,a,d,d] |
| 139 | // |
| 140 | static Value *createSwizzle4(Value *val, uint16_t select) |
| 141 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 142 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 143 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 144 | (select >> 8) & 0x03, |
| 145 | (select >> 4) & 0x03, |
| 146 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 147 | }; |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 148 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 149 | return Nucleus::createShuffleVector(val, val, swizzle); |
| 150 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 151 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 152 | static Value *createMask4(Value *lhs, Value *rhs, uint16_t select) |
| 153 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 154 | bool mask[4] = { false, false, false, false }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 155 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 156 | mask[(select >> 12) & 0x03] = true; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 157 | mask[(select >> 8) & 0x03] = true; |
| 158 | mask[(select >> 4) & 0x03] = true; |
| 159 | mask[(select >> 0) & 0x03] = true; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 160 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 161 | int swizzle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 162 | mask[0] ? 4 : 0, |
| 163 | mask[1] ? 5 : 1, |
| 164 | mask[2] ? 6 : 2, |
| 165 | mask[3] ? 7 : 3, |
| 166 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 167 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 168 | return Nucleus::createShuffleVector(lhs, rhs, swizzle); |
| 169 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 170 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 171 | Bool::Bool(Argument<Bool> argument) |
| 172 | { |
| 173 | storeValue(argument.value); |
| 174 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 175 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 176 | Bool::Bool(bool x) |
| 177 | { |
| 178 | storeValue(Nucleus::createConstantBool(x)); |
| 179 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 180 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 181 | Bool::Bool(RValue<Bool> rhs) |
| 182 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 183 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 184 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 185 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 186 | Bool::Bool(const Bool &rhs) |
| 187 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 188 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 189 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 190 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 191 | Bool::Bool(const Reference<Bool> &rhs) |
| 192 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 193 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 194 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 195 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 196 | RValue<Bool> Bool::operator=(RValue<Bool> rhs) |
| 197 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 198 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 199 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 200 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 201 | RValue<Bool> Bool::operator=(const Bool &rhs) |
| 202 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 203 | return RValue<Bool>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 204 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 205 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 206 | RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) |
| 207 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 208 | return RValue<Bool>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 209 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 210 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 211 | RValue<Bool> operator!(RValue<Bool> val) |
| 212 | { |
| 213 | return RValue<Bool>(Nucleus::createNot(val.value)); |
| 214 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 215 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 216 | RValue<Bool> operator&&(RValue<Bool> lhs, RValue<Bool> rhs) |
| 217 | { |
| 218 | return RValue<Bool>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 219 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 220 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 221 | RValue<Bool> operator||(RValue<Bool> lhs, RValue<Bool> rhs) |
| 222 | { |
| 223 | return RValue<Bool>(Nucleus::createOr(lhs.value, rhs.value)); |
| 224 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 225 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 226 | RValue<Bool> operator!=(RValue<Bool> lhs, RValue<Bool> rhs) |
| 227 | { |
| 228 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 229 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 230 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 231 | RValue<Bool> operator==(RValue<Bool> lhs, RValue<Bool> rhs) |
| 232 | { |
| 233 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 234 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 235 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 236 | Byte::Byte(Argument<Byte> argument) |
| 237 | { |
| 238 | storeValue(argument.value); |
| 239 | } |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 240 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 241 | Byte::Byte(RValue<Int> cast) |
| 242 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 243 | Value *integer = Nucleus::createTrunc(cast.value, Byte::type()); |
Ben Clayton | f3b5797 | 2019-03-15 09:56:47 +0000 | [diff] [blame] | 244 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 245 | storeValue(integer); |
| 246 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 247 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 248 | Byte::Byte(RValue<UInt> cast) |
| 249 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 250 | Value *integer = Nucleus::createTrunc(cast.value, Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 251 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 252 | storeValue(integer); |
| 253 | } |
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 | Byte::Byte(RValue<UShort> cast) |
| 256 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 257 | Value *integer = Nucleus::createTrunc(cast.value, Byte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 258 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 259 | storeValue(integer); |
| 260 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 261 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 262 | Byte::Byte(int x) |
| 263 | { |
| 264 | storeValue(Nucleus::createConstantByte((unsigned char)x)); |
| 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 | Byte::Byte(unsigned char x) |
| 268 | { |
| 269 | storeValue(Nucleus::createConstantByte(x)); |
| 270 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 271 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 272 | Byte::Byte(RValue<Byte> rhs) |
| 273 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 274 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 275 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 276 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 277 | Byte::Byte(const Byte &rhs) |
| 278 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 279 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 280 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 281 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 282 | Byte::Byte(const Reference<Byte> &rhs) |
| 283 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 284 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 285 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 286 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 287 | RValue<Byte> Byte::operator=(RValue<Byte> rhs) |
| 288 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 289 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 290 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 291 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 292 | RValue<Byte> Byte::operator=(const Byte &rhs) |
| 293 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 294 | return RValue<Byte>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 295 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 296 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 297 | RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) |
| 298 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 299 | return RValue<Byte>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 300 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 301 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 302 | RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs) |
| 303 | { |
| 304 | return RValue<Byte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 305 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 306 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 307 | RValue<Byte> operator-(RValue<Byte> lhs, RValue<Byte> rhs) |
| 308 | { |
| 309 | return RValue<Byte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 310 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 311 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 312 | RValue<Byte> operator*(RValue<Byte> lhs, RValue<Byte> rhs) |
| 313 | { |
| 314 | return RValue<Byte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 315 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 316 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 317 | RValue<Byte> operator/(RValue<Byte> lhs, RValue<Byte> rhs) |
| 318 | { |
| 319 | return RValue<Byte>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 320 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 321 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 322 | RValue<Byte> operator%(RValue<Byte> lhs, RValue<Byte> rhs) |
| 323 | { |
| 324 | return RValue<Byte>(Nucleus::createURem(lhs.value, rhs.value)); |
| 325 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 326 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 327 | RValue<Byte> operator&(RValue<Byte> lhs, RValue<Byte> rhs) |
| 328 | { |
| 329 | return RValue<Byte>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 330 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 331 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 332 | RValue<Byte> operator|(RValue<Byte> lhs, RValue<Byte> rhs) |
| 333 | { |
| 334 | return RValue<Byte>(Nucleus::createOr(lhs.value, rhs.value)); |
| 335 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 336 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 337 | RValue<Byte> operator^(RValue<Byte> lhs, RValue<Byte> rhs) |
| 338 | { |
| 339 | return RValue<Byte>(Nucleus::createXor(lhs.value, rhs.value)); |
| 340 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 341 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 342 | RValue<Byte> operator<<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 343 | { |
| 344 | return RValue<Byte>(Nucleus::createShl(lhs.value, rhs.value)); |
| 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 | RValue<Byte> operator>>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 348 | { |
| 349 | return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 350 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 351 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 352 | RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs) |
| 353 | { |
| 354 | return lhs = lhs + rhs; |
| 355 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 356 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 357 | RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs) |
| 358 | { |
| 359 | return lhs = lhs - rhs; |
| 360 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 361 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 362 | RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs) |
| 363 | { |
| 364 | return lhs = lhs * rhs; |
| 365 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 366 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 367 | RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs) |
| 368 | { |
| 369 | return lhs = lhs / rhs; |
| 370 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 371 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 372 | RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs) |
| 373 | { |
| 374 | return lhs = lhs % rhs; |
| 375 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 376 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 377 | RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs) |
| 378 | { |
| 379 | return lhs = lhs & rhs; |
| 380 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 381 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 382 | RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs) |
| 383 | { |
| 384 | return lhs = lhs | rhs; |
| 385 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 386 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 387 | RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs) |
| 388 | { |
| 389 | return lhs = lhs ^ rhs; |
| 390 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 391 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 392 | RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs) |
| 393 | { |
| 394 | return lhs = lhs << rhs; |
| 395 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 396 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 397 | RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs) |
| 398 | { |
| 399 | return lhs = lhs >> rhs; |
| 400 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 401 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 402 | RValue<Byte> operator+(RValue<Byte> val) |
| 403 | { |
| 404 | return val; |
| 405 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 406 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 407 | RValue<Byte> operator-(RValue<Byte> val) |
| 408 | { |
| 409 | return RValue<Byte>(Nucleus::createNeg(val.value)); |
| 410 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 411 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 412 | RValue<Byte> operator~(RValue<Byte> val) |
| 413 | { |
| 414 | return RValue<Byte>(Nucleus::createNot(val.value)); |
| 415 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 416 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 417 | RValue<Byte> operator++(Byte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 418 | { |
| 419 | RValue<Byte> res = val; |
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 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantByte((unsigned char)1)); |
| 422 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 423 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 424 | return res; |
| 425 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 426 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 427 | const Byte &operator++(Byte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 428 | { |
| 429 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 430 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 431 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 432 | return val; |
| 433 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 434 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 435 | RValue<Byte> operator--(Byte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 436 | { |
| 437 | RValue<Byte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 438 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 439 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantByte((unsigned char)1)); |
| 440 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 441 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 442 | return res; |
| 443 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 444 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 445 | const Byte &operator--(Byte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 446 | { |
| 447 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1)); |
| 448 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 449 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 450 | return val; |
| 451 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 452 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 453 | RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs) |
| 454 | { |
| 455 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 456 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 457 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 458 | RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 459 | { |
| 460 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 461 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 462 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 463 | RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs) |
| 464 | { |
| 465 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 466 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 467 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 468 | RValue<Bool> operator>=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 469 | { |
| 470 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 471 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 472 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 473 | RValue<Bool> operator!=(RValue<Byte> lhs, RValue<Byte> rhs) |
| 474 | { |
| 475 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 476 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 477 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 478 | RValue<Bool> operator==(RValue<Byte> lhs, RValue<Byte> rhs) |
| 479 | { |
| 480 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 481 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 482 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 483 | SByte::SByte(Argument<SByte> argument) |
| 484 | { |
| 485 | storeValue(argument.value); |
| 486 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 487 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 488 | SByte::SByte(RValue<Int> cast) |
| 489 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 490 | Value *integer = Nucleus::createTrunc(cast.value, SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 491 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 492 | storeValue(integer); |
| 493 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 494 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 495 | SByte::SByte(RValue<Short> cast) |
| 496 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 497 | Value *integer = Nucleus::createTrunc(cast.value, SByte::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 498 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 499 | storeValue(integer); |
| 500 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 501 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 502 | SByte::SByte(signed char x) |
| 503 | { |
| 504 | storeValue(Nucleus::createConstantByte(x)); |
| 505 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 506 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 507 | SByte::SByte(RValue<SByte> rhs) |
| 508 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 509 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 510 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 511 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 512 | SByte::SByte(const SByte &rhs) |
| 513 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 514 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 515 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 516 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 517 | SByte::SByte(const Reference<SByte> &rhs) |
| 518 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 519 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 520 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 521 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 522 | RValue<SByte> SByte::operator=(RValue<SByte> rhs) |
| 523 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 524 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 525 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 526 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 527 | RValue<SByte> SByte::operator=(const SByte &rhs) |
| 528 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 529 | return RValue<SByte>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 530 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 531 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 532 | RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) |
| 533 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 534 | return RValue<SByte>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 535 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 536 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 537 | RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs) |
| 538 | { |
| 539 | return RValue<SByte>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 540 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 541 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 542 | RValue<SByte> operator-(RValue<SByte> lhs, RValue<SByte> rhs) |
| 543 | { |
| 544 | return RValue<SByte>(Nucleus::createSub(lhs.value, rhs.value)); |
| 545 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 546 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 547 | RValue<SByte> operator*(RValue<SByte> lhs, RValue<SByte> rhs) |
| 548 | { |
| 549 | return RValue<SByte>(Nucleus::createMul(lhs.value, rhs.value)); |
| 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<SByte> operator/(RValue<SByte> lhs, RValue<SByte> rhs) |
| 553 | { |
| 554 | return RValue<SByte>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 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<SByte> operator%(RValue<SByte> lhs, RValue<SByte> rhs) |
| 558 | { |
| 559 | return RValue<SByte>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 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<SByte> operator&(RValue<SByte> lhs, RValue<SByte> rhs) |
| 563 | { |
| 564 | return RValue<SByte>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 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<SByte> operator|(RValue<SByte> lhs, RValue<SByte> rhs) |
| 568 | { |
| 569 | return RValue<SByte>(Nucleus::createOr(lhs.value, rhs.value)); |
| 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<SByte> operator^(RValue<SByte> lhs, RValue<SByte> rhs) |
| 573 | { |
| 574 | return RValue<SByte>(Nucleus::createXor(lhs.value, rhs.value)); |
| 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<SByte> operator<<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 578 | { |
| 579 | return RValue<SByte>(Nucleus::createShl(lhs.value, rhs.value)); |
| 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 | RValue<SByte> operator>>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 583 | { |
| 584 | return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 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 | RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs) |
| 588 | { |
| 589 | return lhs = lhs + rhs; |
| 590 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 591 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 592 | RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs) |
| 593 | { |
| 594 | return lhs = lhs - rhs; |
| 595 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 596 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 597 | RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs) |
| 598 | { |
| 599 | return lhs = lhs * rhs; |
| 600 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 601 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 602 | RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs) |
| 603 | { |
| 604 | return lhs = lhs / rhs; |
| 605 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 606 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 607 | RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs) |
| 608 | { |
| 609 | return lhs = lhs % rhs; |
| 610 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 611 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 612 | RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs) |
| 613 | { |
| 614 | return lhs = lhs & rhs; |
| 615 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 616 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 617 | RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs) |
| 618 | { |
| 619 | return lhs = lhs | rhs; |
| 620 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 621 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 622 | RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs) |
| 623 | { |
| 624 | return lhs = lhs ^ rhs; |
| 625 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 626 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 627 | RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs) |
| 628 | { |
| 629 | return lhs = lhs << rhs; |
| 630 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 631 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 632 | RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs) |
| 633 | { |
| 634 | return lhs = lhs >> rhs; |
| 635 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 636 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 637 | RValue<SByte> operator+(RValue<SByte> val) |
| 638 | { |
| 639 | return val; |
| 640 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 641 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 642 | RValue<SByte> operator-(RValue<SByte> val) |
| 643 | { |
| 644 | return RValue<SByte>(Nucleus::createNeg(val.value)); |
| 645 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 646 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 647 | RValue<SByte> operator~(RValue<SByte> val) |
| 648 | { |
| 649 | return RValue<SByte>(Nucleus::createNot(val.value)); |
| 650 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 651 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 652 | RValue<SByte> operator++(SByte &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 653 | { |
| 654 | RValue<SByte> res = val; |
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 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantByte((signed char)1)); |
| 657 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 658 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 659 | return res; |
| 660 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 661 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 662 | const SByte &operator++(SByte &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 663 | { |
| 664 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 665 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 666 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 667 | return val; |
| 668 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 669 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 670 | RValue<SByte> operator--(SByte &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 671 | { |
| 672 | RValue<SByte> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 673 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 674 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantByte((signed char)1)); |
| 675 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 676 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 677 | return res; |
| 678 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 679 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 680 | const SByte &operator--(SByte &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 681 | { |
| 682 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1)); |
| 683 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 684 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 685 | return val; |
| 686 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 687 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 688 | RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs) |
| 689 | { |
| 690 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 691 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 692 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 693 | RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 694 | { |
| 695 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 696 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 697 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 698 | RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs) |
| 699 | { |
| 700 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 701 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 702 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 703 | RValue<Bool> operator>=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 704 | { |
| 705 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 706 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 707 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 708 | RValue<Bool> operator!=(RValue<SByte> lhs, RValue<SByte> rhs) |
| 709 | { |
| 710 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 711 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 712 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 713 | RValue<Bool> operator==(RValue<SByte> lhs, RValue<SByte> rhs) |
| 714 | { |
| 715 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 716 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 717 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 718 | Short::Short(Argument<Short> argument) |
| 719 | { |
| 720 | storeValue(argument.value); |
| 721 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 722 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 723 | Short::Short(RValue<Int> cast) |
| 724 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 725 | Value *integer = Nucleus::createTrunc(cast.value, Short::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 726 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 727 | storeValue(integer); |
| 728 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 729 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 730 | Short::Short(short x) |
| 731 | { |
| 732 | storeValue(Nucleus::createConstantShort(x)); |
| 733 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 734 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 735 | Short::Short(RValue<Short> rhs) |
| 736 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 737 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 738 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 739 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 740 | Short::Short(const Short &rhs) |
| 741 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 742 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 743 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 744 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 745 | Short::Short(const Reference<Short> &rhs) |
| 746 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 747 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 748 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 749 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 750 | RValue<Short> Short::operator=(RValue<Short> rhs) |
| 751 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 752 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 753 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 754 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 755 | RValue<Short> Short::operator=(const Short &rhs) |
| 756 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 757 | return RValue<Short>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 758 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 759 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 760 | RValue<Short> Short::operator=(const Reference<Short> &rhs) |
| 761 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 762 | return RValue<Short>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 763 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 764 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 765 | RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs) |
| 766 | { |
| 767 | return RValue<Short>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 768 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 769 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 770 | RValue<Short> operator-(RValue<Short> lhs, RValue<Short> rhs) |
| 771 | { |
| 772 | return RValue<Short>(Nucleus::createSub(lhs.value, rhs.value)); |
| 773 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 774 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 775 | RValue<Short> operator*(RValue<Short> lhs, RValue<Short> rhs) |
| 776 | { |
| 777 | return RValue<Short>(Nucleus::createMul(lhs.value, rhs.value)); |
| 778 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 779 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 780 | RValue<Short> operator/(RValue<Short> lhs, RValue<Short> rhs) |
| 781 | { |
| 782 | return RValue<Short>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 783 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 784 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 785 | RValue<Short> operator%(RValue<Short> lhs, RValue<Short> rhs) |
| 786 | { |
| 787 | return RValue<Short>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 788 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 789 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 790 | RValue<Short> operator&(RValue<Short> lhs, RValue<Short> rhs) |
| 791 | { |
| 792 | return RValue<Short>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 793 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 794 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 795 | RValue<Short> operator|(RValue<Short> lhs, RValue<Short> rhs) |
| 796 | { |
| 797 | return RValue<Short>(Nucleus::createOr(lhs.value, rhs.value)); |
| 798 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 799 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 800 | RValue<Short> operator^(RValue<Short> lhs, RValue<Short> rhs) |
| 801 | { |
| 802 | return RValue<Short>(Nucleus::createXor(lhs.value, rhs.value)); |
| 803 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 804 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 805 | RValue<Short> operator<<(RValue<Short> lhs, RValue<Short> rhs) |
| 806 | { |
| 807 | return RValue<Short>(Nucleus::createShl(lhs.value, rhs.value)); |
| 808 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 809 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 810 | RValue<Short> operator>>(RValue<Short> lhs, RValue<Short> rhs) |
| 811 | { |
| 812 | return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 813 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 814 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 815 | RValue<Short> operator+=(Short &lhs, RValue<Short> rhs) |
| 816 | { |
| 817 | return lhs = lhs + rhs; |
| 818 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 819 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 820 | RValue<Short> operator-=(Short &lhs, RValue<Short> rhs) |
| 821 | { |
| 822 | return lhs = lhs - rhs; |
| 823 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 824 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 825 | RValue<Short> operator*=(Short &lhs, RValue<Short> rhs) |
| 826 | { |
| 827 | return lhs = lhs * rhs; |
| 828 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 829 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 830 | RValue<Short> operator/=(Short &lhs, RValue<Short> rhs) |
| 831 | { |
| 832 | return lhs = lhs / rhs; |
| 833 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 834 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 835 | RValue<Short> operator%=(Short &lhs, RValue<Short> rhs) |
| 836 | { |
| 837 | return lhs = lhs % rhs; |
| 838 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 839 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 840 | RValue<Short> operator&=(Short &lhs, RValue<Short> rhs) |
| 841 | { |
| 842 | return lhs = lhs & rhs; |
| 843 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 844 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 845 | RValue<Short> operator|=(Short &lhs, RValue<Short> rhs) |
| 846 | { |
| 847 | return lhs = lhs | rhs; |
| 848 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 849 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 850 | RValue<Short> operator^=(Short &lhs, RValue<Short> rhs) |
| 851 | { |
| 852 | return lhs = lhs ^ rhs; |
| 853 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 854 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 855 | RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs) |
| 856 | { |
| 857 | return lhs = lhs << rhs; |
| 858 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 859 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 860 | RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs) |
| 861 | { |
| 862 | return lhs = lhs >> rhs; |
| 863 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 864 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 865 | RValue<Short> operator+(RValue<Short> val) |
| 866 | { |
| 867 | return val; |
| 868 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 869 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 870 | RValue<Short> operator-(RValue<Short> val) |
| 871 | { |
| 872 | return RValue<Short>(Nucleus::createNeg(val.value)); |
| 873 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 874 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 875 | RValue<Short> operator~(RValue<Short> val) |
| 876 | { |
| 877 | return RValue<Short>(Nucleus::createNot(val.value)); |
| 878 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 879 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 880 | RValue<Short> operator++(Short &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 881 | { |
| 882 | RValue<Short> res = val; |
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 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantShort((short)1)); |
| 885 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 886 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 887 | return res; |
| 888 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 889 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 890 | const Short &operator++(Short &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 891 | { |
| 892 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 893 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 894 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 895 | return val; |
| 896 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 897 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 898 | RValue<Short> operator--(Short &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 899 | { |
| 900 | RValue<Short> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 901 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 902 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantShort((short)1)); |
| 903 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 904 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 905 | return res; |
| 906 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 907 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 908 | const Short &operator--(Short &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 909 | { |
| 910 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1)); |
| 911 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 912 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 913 | return val; |
| 914 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 915 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 916 | RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs) |
| 917 | { |
| 918 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 919 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 920 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 921 | RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs) |
| 922 | { |
| 923 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 924 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 925 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 926 | RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs) |
| 927 | { |
| 928 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 929 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 930 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 931 | RValue<Bool> operator>=(RValue<Short> lhs, RValue<Short> rhs) |
| 932 | { |
| 933 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 934 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 935 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 936 | RValue<Bool> operator!=(RValue<Short> lhs, RValue<Short> rhs) |
| 937 | { |
| 938 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 939 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 940 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 941 | RValue<Bool> operator==(RValue<Short> lhs, RValue<Short> rhs) |
| 942 | { |
| 943 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 944 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 945 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 946 | UShort::UShort(Argument<UShort> argument) |
| 947 | { |
| 948 | storeValue(argument.value); |
| 949 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 950 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 951 | UShort::UShort(RValue<UInt> cast) |
| 952 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 953 | Value *integer = Nucleus::createTrunc(cast.value, UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 954 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 955 | storeValue(integer); |
| 956 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 957 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 958 | UShort::UShort(RValue<Int> cast) |
| 959 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 960 | Value *integer = Nucleus::createTrunc(cast.value, UShort::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 961 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 962 | storeValue(integer); |
| 963 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 964 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 965 | UShort::UShort(unsigned short x) |
| 966 | { |
| 967 | storeValue(Nucleus::createConstantShort(x)); |
| 968 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 969 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 970 | UShort::UShort(RValue<UShort> rhs) |
| 971 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 972 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 973 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 974 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 975 | UShort::UShort(const UShort &rhs) |
| 976 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 977 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 978 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 979 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 980 | UShort::UShort(const Reference<UShort> &rhs) |
| 981 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 982 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 983 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 984 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 985 | RValue<UShort> UShort::operator=(RValue<UShort> rhs) |
| 986 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 987 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 988 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 989 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 990 | RValue<UShort> UShort::operator=(const UShort &rhs) |
| 991 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 992 | return RValue<UShort>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 993 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 994 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 995 | RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) |
| 996 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 997 | return RValue<UShort>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 998 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 999 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1000 | RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1001 | { |
| 1002 | return RValue<UShort>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1003 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1004 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1005 | RValue<UShort> operator-(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1006 | { |
| 1007 | return RValue<UShort>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1008 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1009 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1010 | RValue<UShort> operator*(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1011 | { |
| 1012 | return RValue<UShort>(Nucleus::createMul(lhs.value, rhs.value)); |
| 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<UShort> operator/(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1016 | { |
| 1017 | return RValue<UShort>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 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<UShort> operator%(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1021 | { |
| 1022 | return RValue<UShort>(Nucleus::createURem(lhs.value, rhs.value)); |
| 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<UShort> operator&(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1026 | { |
| 1027 | return RValue<UShort>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 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<UShort> operator|(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1031 | { |
| 1032 | return RValue<UShort>(Nucleus::createOr(lhs.value, rhs.value)); |
| 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<UShort> operator^(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1036 | { |
| 1037 | return RValue<UShort>(Nucleus::createXor(lhs.value, rhs.value)); |
| 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<UShort> operator<<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1041 | { |
| 1042 | return RValue<UShort>(Nucleus::createShl(lhs.value, rhs.value)); |
| 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 | RValue<UShort> operator>>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1046 | { |
| 1047 | return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 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 | RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs) |
| 1051 | { |
| 1052 | return lhs = lhs + rhs; |
| 1053 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1054 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1055 | RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs) |
| 1056 | { |
| 1057 | return lhs = lhs - rhs; |
| 1058 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1059 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1060 | RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs) |
| 1061 | { |
| 1062 | return lhs = lhs * rhs; |
| 1063 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1064 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1065 | RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs) |
| 1066 | { |
| 1067 | return lhs = lhs / rhs; |
| 1068 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1069 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1070 | RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs) |
| 1071 | { |
| 1072 | return lhs = lhs % rhs; |
| 1073 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1074 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1075 | RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs) |
| 1076 | { |
| 1077 | return lhs = lhs & rhs; |
| 1078 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1079 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1080 | RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs) |
| 1081 | { |
| 1082 | return lhs = lhs | rhs; |
| 1083 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1084 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1085 | RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs) |
| 1086 | { |
| 1087 | return lhs = lhs ^ rhs; |
| 1088 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1089 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1090 | RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs) |
| 1091 | { |
| 1092 | return lhs = lhs << rhs; |
| 1093 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1094 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1095 | RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs) |
| 1096 | { |
| 1097 | return lhs = lhs >> rhs; |
| 1098 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1099 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1100 | RValue<UShort> operator+(RValue<UShort> val) |
| 1101 | { |
| 1102 | return val; |
| 1103 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1104 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1105 | RValue<UShort> operator-(RValue<UShort> val) |
| 1106 | { |
| 1107 | return RValue<UShort>(Nucleus::createNeg(val.value)); |
| 1108 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1109 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1110 | RValue<UShort> operator~(RValue<UShort> val) |
| 1111 | { |
| 1112 | return RValue<UShort>(Nucleus::createNot(val.value)); |
| 1113 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1114 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1115 | RValue<UShort> operator++(UShort &val, int) // Post-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1116 | { |
| 1117 | RValue<UShort> res = val; |
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 | Value *inc = Nucleus::createAdd(res.value, Nucleus::createConstantShort((unsigned short)1)); |
| 1120 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1121 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1122 | return res; |
| 1123 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1124 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1125 | const UShort &operator++(UShort &val) // Pre-increment |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1126 | { |
| 1127 | Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1128 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1129 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1130 | return val; |
| 1131 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1132 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1133 | RValue<UShort> operator--(UShort &val, int) // Post-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1134 | { |
| 1135 | RValue<UShort> res = val; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1136 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1137 | Value *inc = Nucleus::createSub(res.value, Nucleus::createConstantShort((unsigned short)1)); |
| 1138 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1139 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1140 | return res; |
| 1141 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1142 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1143 | const UShort &operator--(UShort &val) // Pre-decrement |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1144 | { |
| 1145 | Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1)); |
| 1146 | val.storeValue(inc); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1147 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1148 | return val; |
| 1149 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1150 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1151 | RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1152 | { |
| 1153 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 1154 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1155 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1156 | RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1157 | { |
| 1158 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 1159 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1160 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1161 | RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1162 | { |
| 1163 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 1164 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1165 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1166 | RValue<Bool> operator>=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1167 | { |
| 1168 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 1169 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1170 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1171 | RValue<Bool> operator!=(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1172 | { |
| 1173 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 1174 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1175 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1176 | RValue<Bool> operator==(RValue<UShort> lhs, RValue<UShort> rhs) |
| 1177 | { |
| 1178 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 1179 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1180 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1181 | Byte4::Byte4(RValue<Byte8> cast) |
| 1182 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1183 | storeValue(Nucleus::createBitCast(cast.value, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1184 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1185 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1186 | Byte4::Byte4(RValue<UShort4> cast) |
| 1187 | { |
| 1188 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1189 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1190 | } |
| 1191 | |
| 1192 | Byte4::Byte4(RValue<Short4> cast) |
| 1193 | { |
| 1194 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1195 | *this = As<Byte4>(Swizzle(As<Byte8>(cast), 0x0246'0246)); |
| 1196 | } |
| 1197 | |
| 1198 | Byte4::Byte4(RValue<UInt4> cast) |
| 1199 | { |
| 1200 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1201 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1202 | } |
| 1203 | |
| 1204 | Byte4::Byte4(RValue<Int4> cast) |
| 1205 | { |
| 1206 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1207 | *this = As<Byte4>(Swizzle(As<Byte16>(cast), 0x048C'048C'048C'048C)); |
| 1208 | } |
| 1209 | |
| 1210 | Byte4::Byte4(RValue<Byte4> rhs) |
| 1211 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1212 | store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | Byte4::Byte4(const Byte4 &rhs) |
| 1216 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1217 | storeValue(rhs.loadValue()); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1218 | } |
| 1219 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1220 | Byte4::Byte4(const Reference<Byte4> &rhs) |
| 1221 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1222 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1223 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1224 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1225 | RValue<Byte4> Byte4::operator=(RValue<Byte4> rhs) |
| 1226 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1227 | return store(rhs); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | RValue<Byte4> Byte4::operator=(const Byte4 &rhs) |
| 1231 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1232 | return RValue<Byte4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1233 | } |
| 1234 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1235 | 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) |
| 1236 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1237 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1238 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1239 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1240 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1241 | Byte8::Byte8(RValue<Byte8> rhs) |
| 1242 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1243 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1244 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1245 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1246 | Byte8::Byte8(const Byte8 &rhs) |
| 1247 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1248 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1249 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1250 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1251 | Byte8::Byte8(const Reference<Byte8> &rhs) |
| 1252 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1253 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1254 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1255 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1256 | RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) |
| 1257 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1258 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1259 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1260 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1261 | RValue<Byte8> Byte8::operator=(const Byte8 &rhs) |
| 1262 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1263 | return RValue<Byte8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1264 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1265 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1266 | RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) |
| 1267 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1268 | return RValue<Byte8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1269 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1270 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1271 | RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1272 | { |
| 1273 | return RValue<Byte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1274 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1275 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1276 | RValue<Byte8> operator-(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1277 | { |
| 1278 | return RValue<Byte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1279 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1280 | |
| 1281 | // RValue<Byte8> operator*(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1282 | // { |
| 1283 | // return RValue<Byte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1284 | // } |
| 1285 | |
| 1286 | // RValue<Byte8> operator/(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1287 | // { |
| 1288 | // return RValue<Byte8>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 1289 | // } |
| 1290 | |
| 1291 | // RValue<Byte8> operator%(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1292 | // { |
| 1293 | // return RValue<Byte8>(Nucleus::createURem(lhs.value, rhs.value)); |
| 1294 | // } |
| 1295 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1296 | RValue<Byte8> operator&(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1297 | { |
| 1298 | return RValue<Byte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1299 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1300 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1301 | RValue<Byte8> operator|(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1302 | { |
| 1303 | return RValue<Byte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1304 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1305 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1306 | RValue<Byte8> operator^(RValue<Byte8> lhs, RValue<Byte8> rhs) |
| 1307 | { |
| 1308 | return RValue<Byte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1309 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1310 | |
| 1311 | // RValue<Byte8> operator<<(RValue<Byte8> lhs, unsigned char rhs) |
| 1312 | // { |
| 1313 | // return RValue<Byte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1314 | // } |
| 1315 | |
| 1316 | // RValue<Byte8> operator>>(RValue<Byte8> lhs, unsigned char rhs) |
| 1317 | // { |
| 1318 | // return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 1319 | // } |
| 1320 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1321 | RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1322 | { |
| 1323 | return lhs = lhs + rhs; |
| 1324 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1325 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1326 | RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1327 | { |
| 1328 | return lhs = lhs - rhs; |
| 1329 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1330 | |
| 1331 | // RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1332 | // { |
| 1333 | // return lhs = lhs * rhs; |
| 1334 | // } |
| 1335 | |
| 1336 | // RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1337 | // { |
| 1338 | // return lhs = lhs / rhs; |
| 1339 | // } |
| 1340 | |
| 1341 | // RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1342 | // { |
| 1343 | // return lhs = lhs % rhs; |
| 1344 | // } |
| 1345 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1346 | RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1347 | { |
| 1348 | return lhs = lhs & rhs; |
| 1349 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1350 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1351 | RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1352 | { |
| 1353 | return lhs = lhs | rhs; |
| 1354 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1355 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1356 | RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1357 | { |
| 1358 | return lhs = lhs ^ rhs; |
| 1359 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1360 | |
| 1361 | // RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1362 | // { |
| 1363 | // return lhs = lhs << rhs; |
| 1364 | // } |
| 1365 | |
| 1366 | // RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs) |
| 1367 | // { |
| 1368 | // return lhs = lhs >> rhs; |
| 1369 | // } |
| 1370 | |
| 1371 | // RValue<Byte8> operator+(RValue<Byte8> val) |
| 1372 | // { |
| 1373 | // return val; |
| 1374 | // } |
| 1375 | |
| 1376 | // RValue<Byte8> operator-(RValue<Byte8> val) |
| 1377 | // { |
| 1378 | // return RValue<Byte8>(Nucleus::createNeg(val.value)); |
| 1379 | // } |
| 1380 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1381 | RValue<Byte8> operator~(RValue<Byte8> val) |
| 1382 | { |
| 1383 | return RValue<Byte8>(Nucleus::createNot(val.value)); |
| 1384 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1385 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1386 | RValue<Byte8> Swizzle(RValue<Byte8> x, uint32_t select) |
| 1387 | { |
| 1388 | // Real type is v16i8 |
| 1389 | // TODO(b/148379603): Optimize narrowing swizzle. |
| 1390 | int shuffle[16] = { |
| 1391 | static_cast<int>((select >> 28) & 0x07), |
| 1392 | static_cast<int>((select >> 24) & 0x07), |
| 1393 | static_cast<int>((select >> 20) & 0x07), |
| 1394 | static_cast<int>((select >> 16) & 0x07), |
| 1395 | static_cast<int>((select >> 12) & 0x07), |
| 1396 | static_cast<int>((select >> 8) & 0x07), |
| 1397 | static_cast<int>((select >> 4) & 0x07), |
| 1398 | static_cast<int>((select >> 0) & 0x07), |
| 1399 | static_cast<int>((select >> 28) & 0x07), |
| 1400 | static_cast<int>((select >> 24) & 0x07), |
| 1401 | static_cast<int>((select >> 20) & 0x07), |
| 1402 | static_cast<int>((select >> 16) & 0x07), |
| 1403 | static_cast<int>((select >> 12) & 0x07), |
| 1404 | static_cast<int>((select >> 8) & 0x07), |
| 1405 | static_cast<int>((select >> 4) & 0x07), |
| 1406 | static_cast<int>((select >> 0) & 0x07), |
| 1407 | }; |
| 1408 | |
| 1409 | return As<Byte8>(Nucleus::createShuffleVector(x.value, x.value, shuffle)); |
| 1410 | } |
| 1411 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1412 | RValue<Short4> Unpack(RValue<Byte4> x) |
| 1413 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1414 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1415 | 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 | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1416 | return As<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle)); |
| 1417 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1418 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1419 | RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y) |
| 1420 | { |
| 1421 | return UnpackLow(As<Byte8>(x), As<Byte8>(y)); |
| 1422 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1423 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1424 | RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y) |
| 1425 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1426 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1427 | 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 | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1428 | return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 1429 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1430 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1431 | RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y) |
| 1432 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1433 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1434 | 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 | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1435 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 1436 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1437 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1438 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1439 | 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) |
| 1440 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1441 | int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1442 | Value *vector = Nucleus::createConstantVector(constantVector, type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1443 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1444 | storeValue(Nucleus::createBitCast(vector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1445 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1446 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1447 | SByte8::SByte8(RValue<SByte8> rhs) |
| 1448 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1449 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1450 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1451 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1452 | SByte8::SByte8(const SByte8 &rhs) |
| 1453 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1454 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1455 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1456 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1457 | SByte8::SByte8(const Reference<SByte8> &rhs) |
| 1458 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1459 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1460 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1461 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1462 | RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) |
| 1463 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1464 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1465 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1466 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1467 | RValue<SByte8> SByte8::operator=(const SByte8 &rhs) |
| 1468 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1469 | return RValue<SByte8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1470 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1471 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1472 | RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) |
| 1473 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1474 | return RValue<SByte8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1475 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1476 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1477 | RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1478 | { |
| 1479 | return RValue<SByte8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1480 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1481 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1482 | RValue<SByte8> operator-(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1483 | { |
| 1484 | return RValue<SByte8>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1485 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1486 | |
| 1487 | // RValue<SByte8> operator*(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1488 | // { |
| 1489 | // return RValue<SByte8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1490 | // } |
| 1491 | |
| 1492 | // RValue<SByte8> operator/(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1493 | // { |
| 1494 | // return RValue<SByte8>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 1495 | // } |
| 1496 | |
| 1497 | // RValue<SByte8> operator%(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1498 | // { |
| 1499 | // return RValue<SByte8>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 1500 | // } |
| 1501 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1502 | RValue<SByte8> operator&(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1503 | { |
| 1504 | return RValue<SByte8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1505 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1506 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1507 | RValue<SByte8> operator|(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1508 | { |
| 1509 | return RValue<SByte8>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1510 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1511 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1512 | RValue<SByte8> operator^(RValue<SByte8> lhs, RValue<SByte8> rhs) |
| 1513 | { |
| 1514 | return RValue<SByte8>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1515 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1516 | |
| 1517 | // RValue<SByte8> operator<<(RValue<SByte8> lhs, unsigned char rhs) |
| 1518 | // { |
| 1519 | // return RValue<SByte8>(Nucleus::createShl(lhs.value, rhs.value)); |
| 1520 | // } |
| 1521 | |
| 1522 | // RValue<SByte8> operator>>(RValue<SByte8> lhs, unsigned char rhs) |
| 1523 | // { |
| 1524 | // return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 1525 | // } |
| 1526 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1527 | RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1528 | { |
| 1529 | return lhs = lhs + rhs; |
| 1530 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1531 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1532 | RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1533 | { |
| 1534 | return lhs = lhs - rhs; |
| 1535 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1536 | |
| 1537 | // RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1538 | // { |
| 1539 | // return lhs = lhs * rhs; |
| 1540 | // } |
| 1541 | |
| 1542 | // RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1543 | // { |
| 1544 | // return lhs = lhs / rhs; |
| 1545 | // } |
| 1546 | |
| 1547 | // RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1548 | // { |
| 1549 | // return lhs = lhs % rhs; |
| 1550 | // } |
| 1551 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1552 | RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1553 | { |
| 1554 | return lhs = lhs & rhs; |
| 1555 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1556 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1557 | RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1558 | { |
| 1559 | return lhs = lhs | rhs; |
| 1560 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1561 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1562 | RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1563 | { |
| 1564 | return lhs = lhs ^ rhs; |
| 1565 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1566 | |
| 1567 | // RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1568 | // { |
| 1569 | // return lhs = lhs << rhs; |
| 1570 | // } |
| 1571 | |
| 1572 | // RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs) |
| 1573 | // { |
| 1574 | // return lhs = lhs >> rhs; |
| 1575 | // } |
| 1576 | |
| 1577 | // RValue<SByte8> operator+(RValue<SByte8> val) |
| 1578 | // { |
| 1579 | // return val; |
| 1580 | // } |
| 1581 | |
| 1582 | // RValue<SByte8> operator-(RValue<SByte8> val) |
| 1583 | // { |
| 1584 | // return RValue<SByte8>(Nucleus::createNeg(val.value)); |
| 1585 | // } |
| 1586 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1587 | RValue<SByte8> operator~(RValue<SByte8> val) |
| 1588 | { |
| 1589 | return RValue<SByte8>(Nucleus::createNot(val.value)); |
| 1590 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1591 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1592 | RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y) |
| 1593 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1594 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1595 | 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 | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1596 | return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 1597 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1598 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1599 | RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y) |
| 1600 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1601 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1602 | 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 | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1603 | auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 1604 | return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1605 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1606 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1607 | Byte16::Byte16(RValue<Byte16> rhs) |
| 1608 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1609 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1610 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1611 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1612 | Byte16::Byte16(const Byte16 &rhs) |
| 1613 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1614 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1615 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1616 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1617 | Byte16::Byte16(const Reference<Byte16> &rhs) |
| 1618 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1619 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1620 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1621 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1622 | RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) |
| 1623 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1624 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1625 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1626 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1627 | RValue<Byte16> Byte16::operator=(const Byte16 &rhs) |
| 1628 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1629 | return RValue<Byte16>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1630 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1631 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1632 | RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) |
| 1633 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1634 | return RValue<Byte16>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1635 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1636 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1637 | RValue<Byte16> Swizzle(RValue<Byte16> x, uint64_t select) |
| 1638 | { |
| 1639 | int shuffle[16] = { |
| 1640 | static_cast<int>((select >> 60) & 0x0F), |
| 1641 | static_cast<int>((select >> 56) & 0x0F), |
| 1642 | static_cast<int>((select >> 52) & 0x0F), |
| 1643 | static_cast<int>((select >> 48) & 0x0F), |
| 1644 | static_cast<int>((select >> 44) & 0x0F), |
| 1645 | static_cast<int>((select >> 40) & 0x0F), |
| 1646 | static_cast<int>((select >> 36) & 0x0F), |
| 1647 | static_cast<int>((select >> 32) & 0x0F), |
| 1648 | static_cast<int>((select >> 28) & 0x0F), |
| 1649 | static_cast<int>((select >> 24) & 0x0F), |
| 1650 | static_cast<int>((select >> 20) & 0x0F), |
| 1651 | static_cast<int>((select >> 16) & 0x0F), |
| 1652 | static_cast<int>((select >> 12) & 0x0F), |
| 1653 | static_cast<int>((select >> 8) & 0x0F), |
| 1654 | static_cast<int>((select >> 4) & 0x0F), |
| 1655 | static_cast<int>((select >> 0) & 0x0F), |
| 1656 | }; |
| 1657 | |
| 1658 | return As<Byte16>(Nucleus::createShuffleVector(x.value, x.value, shuffle)); |
| 1659 | } |
| 1660 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1661 | Short2::Short2(RValue<Short4> cast) |
| 1662 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1663 | storeValue(Nucleus::createBitCast(cast.value, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1664 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1665 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1666 | UShort2::UShort2(RValue<UShort4> cast) |
| 1667 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1668 | storeValue(Nucleus::createBitCast(cast.value, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1669 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1670 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1671 | Short4::Short4(RValue<Int> cast) |
| 1672 | { |
| 1673 | Value *vector = loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1674 | Value *element = Nucleus::createTrunc(cast.value, Short::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1675 | Value *insert = Nucleus::createInsertElement(vector, element, 0); |
| 1676 | Value *swizzle = Swizzle(RValue<Short4>(insert), 0x0000).value; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1677 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1678 | storeValue(swizzle); |
| 1679 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1680 | |
| 1681 | // Short4::Short4(RValue<Float> cast) |
| 1682 | // { |
| 1683 | // } |
| 1684 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1685 | Short4::Short4(short xyzw) |
| 1686 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1687 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1688 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
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 | Short4::Short4(short x, short y, short z, short w) |
| 1692 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1693 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1694 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1695 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1696 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1697 | Short4::Short4(RValue<Short4> rhs) |
| 1698 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1699 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1700 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1701 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1702 | Short4::Short4(const Short4 &rhs) |
| 1703 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1704 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1705 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1706 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1707 | Short4::Short4(const Reference<Short4> &rhs) |
| 1708 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1709 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1710 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1711 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1712 | Short4::Short4(RValue<UShort4> rhs) |
| 1713 | { |
| 1714 | storeValue(rhs.value); |
| 1715 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1716 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1717 | Short4::Short4(const UShort4 &rhs) |
| 1718 | { |
| 1719 | storeValue(rhs.loadValue()); |
| 1720 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1721 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1722 | Short4::Short4(const Reference<UShort4> &rhs) |
| 1723 | { |
| 1724 | storeValue(rhs.loadValue()); |
| 1725 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1726 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1727 | RValue<Short4> Short4::operator=(RValue<Short4> rhs) |
| 1728 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1729 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1730 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1731 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1732 | RValue<Short4> Short4::operator=(const Short4 &rhs) |
| 1733 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1734 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1735 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1736 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1737 | RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) |
| 1738 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1739 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1740 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1741 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1742 | RValue<Short4> Short4::operator=(RValue<UShort4> rhs) |
| 1743 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1744 | return RValue<Short4>(storeValue(rhs.value)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1745 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1746 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1747 | RValue<Short4> Short4::operator=(const UShort4 &rhs) |
| 1748 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1749 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1750 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1751 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1752 | RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) |
| 1753 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1754 | return RValue<Short4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1755 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1756 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1757 | RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1758 | { |
| 1759 | return RValue<Short4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1760 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1761 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1762 | RValue<Short4> operator-(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1763 | { |
| 1764 | return RValue<Short4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1765 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1766 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1767 | RValue<Short4> operator*(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1768 | { |
| 1769 | return RValue<Short4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 1770 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1771 | |
| 1772 | // RValue<Short4> operator/(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1773 | // { |
| 1774 | // return RValue<Short4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 1775 | // } |
| 1776 | |
| 1777 | // RValue<Short4> operator%(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1778 | // { |
| 1779 | // return RValue<Short4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 1780 | // } |
| 1781 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1782 | RValue<Short4> operator&(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1783 | { |
| 1784 | return RValue<Short4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 1785 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1786 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1787 | RValue<Short4> operator|(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1788 | { |
| 1789 | return RValue<Short4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 1790 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1791 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1792 | RValue<Short4> operator^(RValue<Short4> lhs, RValue<Short4> rhs) |
| 1793 | { |
| 1794 | return RValue<Short4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 1795 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1796 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1797 | RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs) |
| 1798 | { |
| 1799 | return lhs = lhs + rhs; |
| 1800 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1801 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1802 | RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs) |
| 1803 | { |
| 1804 | return lhs = lhs - rhs; |
| 1805 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1806 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1807 | RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs) |
| 1808 | { |
| 1809 | return lhs = lhs * rhs; |
| 1810 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1811 | |
| 1812 | // RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs) |
| 1813 | // { |
| 1814 | // return lhs = lhs / rhs; |
| 1815 | // } |
| 1816 | |
| 1817 | // RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs) |
| 1818 | // { |
| 1819 | // return lhs = lhs % rhs; |
| 1820 | // } |
| 1821 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1822 | RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs) |
| 1823 | { |
| 1824 | return lhs = lhs & rhs; |
| 1825 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1826 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1827 | RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs) |
| 1828 | { |
| 1829 | return lhs = lhs | rhs; |
| 1830 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1831 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1832 | RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs) |
| 1833 | { |
| 1834 | return lhs = lhs ^ rhs; |
| 1835 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1836 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1837 | RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs) |
| 1838 | { |
| 1839 | return lhs = lhs << rhs; |
| 1840 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1841 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1842 | RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs) |
| 1843 | { |
| 1844 | return lhs = lhs >> rhs; |
| 1845 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1846 | |
| 1847 | // RValue<Short4> operator+(RValue<Short4> val) |
| 1848 | // { |
| 1849 | // return val; |
| 1850 | // } |
| 1851 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1852 | RValue<Short4> operator-(RValue<Short4> val) |
| 1853 | { |
| 1854 | return RValue<Short4>(Nucleus::createNeg(val.value)); |
| 1855 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1856 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1857 | RValue<Short4> operator~(RValue<Short4> val) |
| 1858 | { |
| 1859 | return RValue<Short4>(Nucleus::createNot(val.value)); |
| 1860 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1861 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1862 | RValue<Short4> RoundShort4(RValue<Float4> cast) |
| 1863 | { |
| 1864 | RValue<Int4> int4 = RoundInt(cast); |
| 1865 | return As<Short4>(PackSigned(int4, int4)); |
| 1866 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1867 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1868 | RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y) |
| 1869 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1870 | int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1871 | return As<Int2>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 1872 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1873 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1874 | RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y) |
| 1875 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1876 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1877 | int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1878 | auto lowHigh = RValue<Short8>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 1879 | return As<Int2>(Swizzle(As<Int4>(lowHigh), 0x2323)); |
| 1880 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1881 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1882 | RValue<Short4> Swizzle(RValue<Short4> x, uint16_t select) |
| 1883 | { |
| 1884 | // Real type is v8i16 |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 1885 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1886 | int shuffle[8] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1887 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1888 | (select >> 8) & 0x03, |
| 1889 | (select >> 4) & 0x03, |
| 1890 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1891 | (select >> 12) & 0x03, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1892 | (select >> 8) & 0x03, |
| 1893 | (select >> 4) & 0x03, |
| 1894 | (select >> 0) & 0x03, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1895 | }; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1896 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1897 | return As<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle)); |
| 1898 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1899 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1900 | RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) |
| 1901 | { |
| 1902 | return RValue<Short4>(Nucleus::createInsertElement(val.value, element.value, i)); |
| 1903 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1904 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1905 | RValue<Short> Extract(RValue<Short4> val, int i) |
| 1906 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1907 | return RValue<Short>(Nucleus::createExtractElement(val.value, Short::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1908 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1909 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1910 | UShort4::UShort4(RValue<Int4> cast) |
| 1911 | { |
| 1912 | *this = Short4(cast); |
| 1913 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1914 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1915 | UShort4::UShort4(unsigned short xyzw) |
| 1916 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1917 | int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1918 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1919 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1920 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1921 | UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) |
| 1922 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 1923 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 1924 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1925 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1926 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1927 | UShort4::UShort4(RValue<UShort4> rhs) |
| 1928 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1929 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1930 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1931 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1932 | UShort4::UShort4(const UShort4 &rhs) |
| 1933 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1934 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1935 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1936 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1937 | UShort4::UShort4(const Reference<UShort4> &rhs) |
| 1938 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1939 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1940 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1941 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1942 | UShort4::UShort4(RValue<Short4> rhs) |
| 1943 | { |
| 1944 | storeValue(rhs.value); |
| 1945 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1946 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1947 | UShort4::UShort4(const Short4 &rhs) |
| 1948 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1949 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1950 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1951 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1952 | UShort4::UShort4(const Reference<Short4> &rhs) |
| 1953 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1954 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1955 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1956 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1957 | RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) |
| 1958 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1959 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1960 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1961 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1962 | RValue<UShort4> UShort4::operator=(const UShort4 &rhs) |
| 1963 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1964 | return store(rhs.load()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1965 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1966 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1967 | RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) |
| 1968 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1969 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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<UShort4> UShort4::operator=(RValue<Short4> rhs) |
| 1973 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1974 | return RValue<UShort4>(storeValue(rhs.value)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1975 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1976 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1977 | RValue<UShort4> UShort4::operator=(const Short4 &rhs) |
| 1978 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1979 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1980 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1981 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1982 | RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) |
| 1983 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 1984 | return RValue<UShort4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1985 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1986 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1987 | RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 1988 | { |
| 1989 | return RValue<UShort4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 1990 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1991 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1992 | RValue<UShort4> operator-(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 1993 | { |
| 1994 | return RValue<UShort4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 1995 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 1996 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1997 | RValue<UShort4> operator*(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 1998 | { |
| 1999 | return RValue<UShort4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2000 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2001 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2002 | RValue<UShort4> operator&(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2003 | { |
| 2004 | return RValue<UShort4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2005 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2006 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2007 | RValue<UShort4> operator|(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2008 | { |
| 2009 | return RValue<UShort4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2010 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2011 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2012 | RValue<UShort4> operator^(RValue<UShort4> lhs, RValue<UShort4> rhs) |
| 2013 | { |
| 2014 | return RValue<UShort4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2015 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2016 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2017 | RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs) |
| 2018 | { |
| 2019 | return lhs = lhs << rhs; |
| 2020 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2021 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2022 | RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs) |
| 2023 | { |
| 2024 | return lhs = lhs >> rhs; |
| 2025 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2026 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2027 | RValue<UShort4> operator~(RValue<UShort4> val) |
| 2028 | { |
| 2029 | return RValue<UShort4>(Nucleus::createNot(val.value)); |
| 2030 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2031 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2032 | Short8::Short8(short c) |
| 2033 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2034 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2035 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2036 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2037 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2038 | Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7) |
| 2039 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2040 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2041 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2042 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2043 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2044 | Short8::Short8(RValue<Short8> rhs) |
| 2045 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2046 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2047 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2048 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2049 | Short8::Short8(const Reference<Short8> &rhs) |
| 2050 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2051 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2052 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2053 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2054 | Short8::Short8(RValue<Short4> lo, RValue<Short4> hi) |
| 2055 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2056 | int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2057 | Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2058 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2059 | storeValue(packed); |
| 2060 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2061 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2062 | RValue<Short8> Short8::operator=(RValue<Short8> rhs) |
| 2063 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2064 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2065 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2066 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2067 | RValue<Short8> Short8::operator=(const Short8 &rhs) |
| 2068 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2069 | return RValue<Short8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2070 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2071 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2072 | RValue<Short8> Short8::operator=(const Reference<Short8> &rhs) |
| 2073 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2074 | return RValue<Short8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2075 | } |
Nicolas Capens | f1beca4 | 2019-03-26 17:18:57 -0400 | [diff] [blame] | 2076 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2077 | RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2078 | { |
| 2079 | return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2080 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2081 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2082 | RValue<Short8> operator&(RValue<Short8> lhs, RValue<Short8> rhs) |
| 2083 | { |
| 2084 | return RValue<Short8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2085 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2086 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2087 | RValue<Int4> Abs(RValue<Int4> x) |
| 2088 | { |
| 2089 | // TODO: Optimize. |
| 2090 | auto negative = x >> 31; |
| 2091 | return (x ^ negative) - negative; |
| 2092 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2093 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2094 | UShort8::UShort8(unsigned short c) |
| 2095 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2096 | int64_t constantVector[8] = { c, c, c, c, c, c, c, c }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2097 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2098 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2099 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2100 | 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) |
| 2101 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2102 | int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2103 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
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 | UShort8::UShort8(RValue<UShort8> rhs) |
| 2107 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2108 | store(rhs); |
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 | UShort8::UShort8(const Reference<UShort8> &rhs) |
| 2112 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2113 | storeValue(rhs.loadValue()); |
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 | UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi) |
| 2117 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2118 | int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2119 | Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); |
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 | storeValue(packed); |
| 2122 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2123 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2124 | RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) |
| 2125 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2126 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2127 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2128 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2129 | RValue<UShort8> UShort8::operator=(const UShort8 &rhs) |
| 2130 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2131 | return RValue<UShort8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2132 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2133 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2134 | RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) |
| 2135 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2136 | return RValue<UShort8>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2137 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2138 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2139 | RValue<UShort8> operator&(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2140 | { |
| 2141 | return RValue<UShort8>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2142 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2143 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2144 | RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2145 | { |
| 2146 | return RValue<UShort8>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2147 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2148 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2149 | RValue<UShort8> operator*(RValue<UShort8> lhs, RValue<UShort8> rhs) |
| 2150 | { |
| 2151 | return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2152 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2153 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2154 | RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs) |
| 2155 | { |
| 2156 | return lhs = lhs + rhs; |
| 2157 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2158 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2159 | RValue<UShort8> operator~(RValue<UShort8> val) |
| 2160 | { |
| 2161 | return RValue<UShort8>(Nucleus::createNot(val.value)); |
| 2162 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2163 | |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2164 | RValue<UShort8> Swizzle(RValue<UShort8> x, uint32_t select) |
| 2165 | { |
| 2166 | int swizzle[16] = { |
| 2167 | static_cast<int>((select >> 28) & 0x07), |
| 2168 | static_cast<int>((select >> 24) & 0x07), |
| 2169 | static_cast<int>((select >> 20) & 0x07), |
| 2170 | static_cast<int>((select >> 16) & 0x07), |
| 2171 | static_cast<int>((select >> 12) & 0x07), |
| 2172 | static_cast<int>((select >> 8) & 0x07), |
| 2173 | static_cast<int>((select >> 4) & 0x07), |
| 2174 | static_cast<int>((select >> 0) & 0x07), |
| 2175 | }; |
| 2176 | |
| 2177 | return RValue<UShort8>(Nucleus::createShuffleVector(x.value, x.value, swizzle)); |
| 2178 | } |
| 2179 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2180 | Int::Int(Argument<Int> argument) |
| 2181 | { |
| 2182 | storeValue(argument.value); |
| 2183 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2184 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2185 | Int::Int(RValue<Byte> cast) |
| 2186 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2187 | Value *integer = Nucleus::createZExt(cast.value, Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2188 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2189 | storeValue(integer); |
| 2190 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2191 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2192 | Int::Int(RValue<SByte> cast) |
| 2193 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2194 | Value *integer = Nucleus::createSExt(cast.value, Int::type()); |
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 | storeValue(integer); |
| 2197 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2198 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2199 | Int::Int(RValue<Short> cast) |
| 2200 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2201 | Value *integer = Nucleus::createSExt(cast.value, Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2202 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2203 | storeValue(integer); |
| 2204 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2205 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2206 | Int::Int(RValue<UShort> cast) |
| 2207 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2208 | Value *integer = Nucleus::createZExt(cast.value, Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2209 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2210 | storeValue(integer); |
| 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 | Int::Int(RValue<Int2> cast) |
| 2214 | { |
| 2215 | *this = Extract(cast, 0); |
| 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 | Int::Int(RValue<Long> cast) |
| 2219 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2220 | Value *integer = Nucleus::createTrunc(cast.value, Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2221 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2222 | storeValue(integer); |
| 2223 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2224 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2225 | Int::Int(RValue<Float> cast) |
| 2226 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2227 | Value *integer = Nucleus::createFPToSI(cast.value, Int::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2228 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2229 | storeValue(integer); |
| 2230 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2231 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2232 | Int::Int(int x) |
| 2233 | { |
| 2234 | storeValue(Nucleus::createConstantInt(x)); |
| 2235 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2236 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2237 | Int::Int(RValue<Int> rhs) |
| 2238 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2239 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2240 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2241 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2242 | Int::Int(RValue<UInt> rhs) |
| 2243 | { |
| 2244 | storeValue(rhs.value); |
| 2245 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2246 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2247 | Int::Int(const Int &rhs) |
| 2248 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2249 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2250 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2251 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2252 | Int::Int(const Reference<Int> &rhs) |
| 2253 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2254 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2255 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2256 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2257 | Int::Int(const UInt &rhs) |
| 2258 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2259 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2260 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2261 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2262 | Int::Int(const Reference<UInt> &rhs) |
| 2263 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2264 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2265 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2266 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2267 | RValue<Int> Int::operator=(int rhs) |
| 2268 | { |
| 2269 | return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2270 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2271 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2272 | RValue<Int> Int::operator=(RValue<Int> rhs) |
| 2273 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2274 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2275 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2276 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2277 | RValue<Int> Int::operator=(RValue<UInt> rhs) |
| 2278 | { |
| 2279 | storeValue(rhs.value); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2280 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2281 | return RValue<Int>(rhs); |
| 2282 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2283 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2284 | RValue<Int> Int::operator=(const Int &rhs) |
| 2285 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2286 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2287 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2288 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2289 | RValue<Int> Int::operator=(const Reference<Int> &rhs) |
| 2290 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2291 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 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 | RValue<Int> Int::operator=(const UInt &rhs) |
| 2295 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2296 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2297 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2298 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2299 | RValue<Int> Int::operator=(const Reference<UInt> &rhs) |
| 2300 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2301 | return RValue<Int>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2302 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2303 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2304 | RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs) |
| 2305 | { |
| 2306 | return RValue<Int>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2307 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2308 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2309 | RValue<Int> operator-(RValue<Int> lhs, RValue<Int> rhs) |
| 2310 | { |
| 2311 | return RValue<Int>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2312 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2313 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2314 | RValue<Int> operator*(RValue<Int> lhs, RValue<Int> rhs) |
| 2315 | { |
| 2316 | return RValue<Int>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2317 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2318 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2319 | RValue<Int> operator/(RValue<Int> lhs, RValue<Int> rhs) |
| 2320 | { |
| 2321 | return RValue<Int>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2322 | } |
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 | RValue<Int> operator%(RValue<Int> lhs, RValue<Int> rhs) |
| 2325 | { |
| 2326 | return RValue<Int>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2327 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2328 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2329 | RValue<Int> operator&(RValue<Int> lhs, RValue<Int> rhs) |
| 2330 | { |
| 2331 | return RValue<Int>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 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 | RValue<Int> operator|(RValue<Int> lhs, RValue<Int> rhs) |
| 2335 | { |
| 2336 | return RValue<Int>(Nucleus::createOr(lhs.value, rhs.value)); |
| 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 | RValue<Int> operator^(RValue<Int> lhs, RValue<Int> rhs) |
| 2340 | { |
| 2341 | return RValue<Int>(Nucleus::createXor(lhs.value, rhs.value)); |
| 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 | RValue<Int> operator<<(RValue<Int> lhs, RValue<Int> rhs) |
| 2345 | { |
| 2346 | return RValue<Int>(Nucleus::createShl(lhs.value, rhs.value)); |
| 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 | RValue<Int> operator>>(RValue<Int> lhs, RValue<Int> rhs) |
| 2350 | { |
| 2351 | return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 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 | RValue<Int> operator+=(Int &lhs, RValue<Int> rhs) |
| 2355 | { |
| 2356 | return lhs = lhs + rhs; |
| 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 | RValue<Int> operator-=(Int &lhs, RValue<Int> rhs) |
| 2360 | { |
| 2361 | return lhs = lhs - rhs; |
| 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 | RValue<Int> operator*=(Int &lhs, RValue<Int> rhs) |
| 2365 | { |
| 2366 | return lhs = lhs * rhs; |
| 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> operator/=(Int &lhs, RValue<Int> rhs) |
| 2370 | { |
| 2371 | return lhs = lhs / 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> operator%=(Int &lhs, RValue<Int> rhs) |
| 2375 | { |
| 2376 | return lhs = lhs % rhs; |
| 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> operator&=(Int &lhs, RValue<Int> rhs) |
| 2380 | { |
| 2381 | return lhs = lhs & rhs; |
| 2382 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2383 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2384 | RValue<Int> operator|=(Int &lhs, RValue<Int> rhs) |
| 2385 | { |
| 2386 | return lhs = lhs | rhs; |
| 2387 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2388 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2389 | RValue<Int> operator^=(Int &lhs, RValue<Int> rhs) |
| 2390 | { |
| 2391 | return lhs = lhs ^ rhs; |
| 2392 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2393 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2394 | RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs) |
| 2395 | { |
| 2396 | return lhs = lhs << rhs; |
| 2397 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2398 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2399 | RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs) |
| 2400 | { |
| 2401 | return lhs = lhs >> rhs; |
| 2402 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2403 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2404 | RValue<Int> operator+(RValue<Int> val) |
| 2405 | { |
| 2406 | return val; |
| 2407 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2408 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2409 | RValue<Int> operator-(RValue<Int> val) |
| 2410 | { |
| 2411 | return RValue<Int>(Nucleus::createNeg(val.value)); |
| 2412 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2413 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2414 | RValue<Int> operator~(RValue<Int> val) |
| 2415 | { |
| 2416 | return RValue<Int>(Nucleus::createNot(val.value)); |
| 2417 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2418 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2419 | RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) |
| 2420 | { |
| 2421 | return RValue<Bool>(Nucleus::createICmpSLT(lhs.value, rhs.value)); |
| 2422 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2423 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2424 | RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs) |
| 2425 | { |
| 2426 | return RValue<Bool>(Nucleus::createICmpSLE(lhs.value, rhs.value)); |
| 2427 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2428 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2429 | RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs) |
| 2430 | { |
| 2431 | return RValue<Bool>(Nucleus::createICmpSGT(lhs.value, rhs.value)); |
| 2432 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2433 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2434 | RValue<Bool> operator>=(RValue<Int> lhs, RValue<Int> rhs) |
| 2435 | { |
| 2436 | return RValue<Bool>(Nucleus::createICmpSGE(lhs.value, rhs.value)); |
| 2437 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2438 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2439 | RValue<Bool> operator!=(RValue<Int> lhs, RValue<Int> rhs) |
| 2440 | { |
| 2441 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 2442 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2443 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2444 | RValue<Bool> operator==(RValue<Int> lhs, RValue<Int> rhs) |
| 2445 | { |
| 2446 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 2447 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2448 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2449 | RValue<Int> Max(RValue<Int> x, RValue<Int> y) |
| 2450 | { |
| 2451 | return IfThenElse(x > y, x, y); |
| 2452 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2453 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2454 | RValue<Int> Min(RValue<Int> x, RValue<Int> y) |
| 2455 | { |
| 2456 | return IfThenElse(x < y, x, y); |
| 2457 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2458 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2459 | RValue<Int> Clamp(RValue<Int> x, RValue<Int> min, RValue<Int> max) |
| 2460 | { |
| 2461 | return Min(Max(x, min), max); |
| 2462 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2463 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2464 | Long::Long(RValue<Int> cast) |
| 2465 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2466 | Value *integer = Nucleus::createSExt(cast.value, Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2467 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2468 | storeValue(integer); |
| 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 | Long::Long(RValue<UInt> cast) |
| 2472 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2473 | Value *integer = Nucleus::createZExt(cast.value, Long::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2474 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2475 | storeValue(integer); |
| 2476 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2477 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2478 | Long::Long(RValue<Long> rhs) |
| 2479 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2480 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2481 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2482 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2483 | RValue<Long> Long::operator=(int64_t rhs) |
| 2484 | { |
| 2485 | return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs))); |
| 2486 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2487 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2488 | RValue<Long> Long::operator=(RValue<Long> rhs) |
| 2489 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2490 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2491 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2492 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2493 | RValue<Long> Long::operator=(const Long &rhs) |
| 2494 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2495 | return RValue<Long>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2496 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2497 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2498 | RValue<Long> Long::operator=(const Reference<Long> &rhs) |
| 2499 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2500 | return RValue<Long>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2501 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2502 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2503 | RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs) |
| 2504 | { |
| 2505 | return RValue<Long>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2506 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2507 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2508 | RValue<Long> operator-(RValue<Long> lhs, RValue<Long> rhs) |
| 2509 | { |
| 2510 | return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2511 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2512 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2513 | RValue<Long> operator*(RValue<Long> lhs, RValue<Long> rhs) |
| 2514 | { |
| 2515 | return RValue<Long>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2516 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2517 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2518 | RValue<Long> operator>>(RValue<Long> lhs, RValue<Long> rhs) |
| 2519 | { |
| 2520 | return RValue<Long>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 2521 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2522 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2523 | RValue<Long> operator+=(Long &lhs, RValue<Long> rhs) |
| 2524 | { |
| 2525 | return lhs = lhs + rhs; |
| 2526 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2527 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2528 | RValue<Long> operator-=(Long &lhs, RValue<Long> rhs) |
| 2529 | { |
| 2530 | return lhs = lhs - rhs; |
| 2531 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2532 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2533 | RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2534 | { |
| 2535 | return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value)); |
| 2536 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2537 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2538 | 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] | 2539 | { |
| 2540 | return RValue<UInt>(Nucleus::createAtomicAdd(x.value, y.value, memoryOrder)); |
| 2541 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2542 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2543 | 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] | 2544 | { |
| 2545 | return RValue<UInt>(Nucleus::createAtomicSub(x.value, y.value, memoryOrder)); |
| 2546 | } |
Chris Forbes | 707ed99 | 2019-04-18 18:17:35 -0700 | [diff] [blame] | 2547 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2548 | 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] | 2549 | { |
| 2550 | return RValue<UInt>(Nucleus::createAtomicAnd(x.value, y.value, memoryOrder)); |
| 2551 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2552 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2553 | 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] | 2554 | { |
| 2555 | return RValue<UInt>(Nucleus::createAtomicOr(x.value, y.value, memoryOrder)); |
| 2556 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2557 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2558 | 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] | 2559 | { |
| 2560 | return RValue<UInt>(Nucleus::createAtomicXor(x.value, y.value, memoryOrder)); |
| 2561 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2562 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2563 | 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] | 2564 | { |
| 2565 | return RValue<UInt>(Nucleus::createAtomicExchange(x.value, y.value, memoryOrder)); |
| 2566 | } |
Chris Forbes | 1781393 | 2019-04-18 11:45:54 -0700 | [diff] [blame] | 2567 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2568 | 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] | 2569 | { |
| 2570 | return RValue<UInt>(Nucleus::createAtomicCompareExchange(x.value, y.value, compare.value, memoryOrderEqual, memoryOrderUnequal)); |
| 2571 | } |
Chris Forbes | a16238d | 2019-04-18 16:31:54 -0700 | [diff] [blame] | 2572 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2573 | UInt::UInt(Argument<UInt> argument) |
| 2574 | { |
| 2575 | storeValue(argument.value); |
| 2576 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2577 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2578 | UInt::UInt(RValue<UShort> cast) |
| 2579 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2580 | Value *integer = Nucleus::createZExt(cast.value, UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2581 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2582 | storeValue(integer); |
| 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 | UInt::UInt(RValue<Long> cast) |
| 2586 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2587 | Value *integer = Nucleus::createTrunc(cast.value, UInt::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2588 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2589 | storeValue(integer); |
| 2590 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2591 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2592 | UInt::UInt(int x) |
| 2593 | { |
| 2594 | storeValue(Nucleus::createConstantInt(x)); |
| 2595 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2596 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2597 | UInt::UInt(unsigned int x) |
| 2598 | { |
| 2599 | storeValue(Nucleus::createConstantInt(x)); |
| 2600 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2601 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2602 | UInt::UInt(RValue<UInt> rhs) |
| 2603 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2604 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2605 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2606 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2607 | UInt::UInt(RValue<Int> rhs) |
| 2608 | { |
| 2609 | storeValue(rhs.value); |
| 2610 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2611 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2612 | UInt::UInt(const UInt &rhs) |
| 2613 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2614 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2615 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2616 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2617 | UInt::UInt(const Reference<UInt> &rhs) |
| 2618 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2619 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2620 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2621 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2622 | UInt::UInt(const Int &rhs) |
| 2623 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2624 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2625 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2626 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2627 | UInt::UInt(const Reference<Int> &rhs) |
| 2628 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2629 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2630 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2631 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2632 | RValue<UInt> UInt::operator=(unsigned int rhs) |
| 2633 | { |
| 2634 | return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs))); |
| 2635 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2636 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2637 | RValue<UInt> UInt::operator=(RValue<UInt> rhs) |
| 2638 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2639 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2640 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2641 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2642 | RValue<UInt> UInt::operator=(RValue<Int> rhs) |
| 2643 | { |
| 2644 | storeValue(rhs.value); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2645 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2646 | return RValue<UInt>(rhs); |
| 2647 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2648 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2649 | RValue<UInt> UInt::operator=(const UInt &rhs) |
| 2650 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2651 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2652 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2653 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2654 | RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) |
| 2655 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2656 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2657 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2658 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2659 | RValue<UInt> UInt::operator=(const Int &rhs) |
| 2660 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2661 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2662 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2663 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2664 | RValue<UInt> UInt::operator=(const Reference<Int> &rhs) |
| 2665 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2666 | return RValue<UInt>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2667 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2668 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2669 | RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2670 | { |
| 2671 | return RValue<UInt>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2672 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2673 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2674 | RValue<UInt> operator-(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2675 | { |
| 2676 | return RValue<UInt>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2677 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2678 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2679 | RValue<UInt> operator*(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2680 | { |
| 2681 | return RValue<UInt>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2682 | } |
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 | RValue<UInt> operator/(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2685 | { |
| 2686 | return RValue<UInt>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 2687 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2688 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2689 | RValue<UInt> operator%(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2690 | { |
| 2691 | return RValue<UInt>(Nucleus::createURem(lhs.value, rhs.value)); |
| 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 | RValue<UInt> operator&(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2695 | { |
| 2696 | return RValue<UInt>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 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 | RValue<UInt> operator|(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2700 | { |
| 2701 | return RValue<UInt>(Nucleus::createOr(lhs.value, rhs.value)); |
| 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 | RValue<UInt> operator^(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2705 | { |
| 2706 | return RValue<UInt>(Nucleus::createXor(lhs.value, rhs.value)); |
| 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 | RValue<UInt> operator<<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2710 | { |
| 2711 | return RValue<UInt>(Nucleus::createShl(lhs.value, rhs.value)); |
| 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 | RValue<UInt> operator>>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2715 | { |
| 2716 | return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 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 | RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs) |
| 2720 | { |
| 2721 | return lhs = lhs + rhs; |
| 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 | RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs) |
| 2725 | { |
| 2726 | return lhs = lhs - rhs; |
| 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 | RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs) |
| 2730 | { |
| 2731 | return lhs = lhs * rhs; |
| 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> operator/=(UInt &lhs, RValue<UInt> rhs) |
| 2735 | { |
| 2736 | return lhs = lhs / 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> operator%=(UInt &lhs, RValue<UInt> rhs) |
| 2740 | { |
| 2741 | return lhs = lhs % rhs; |
| 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> operator&=(UInt &lhs, RValue<UInt> rhs) |
| 2745 | { |
| 2746 | return lhs = lhs & rhs; |
| 2747 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2748 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2749 | RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs) |
| 2750 | { |
| 2751 | return lhs = lhs | rhs; |
| 2752 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2753 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2754 | RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs) |
| 2755 | { |
| 2756 | return lhs = lhs ^ rhs; |
| 2757 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2758 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2759 | RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs) |
| 2760 | { |
| 2761 | return lhs = lhs << rhs; |
| 2762 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2763 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2764 | RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs) |
| 2765 | { |
| 2766 | return lhs = lhs >> rhs; |
| 2767 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2768 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2769 | RValue<UInt> operator+(RValue<UInt> val) |
| 2770 | { |
| 2771 | return val; |
| 2772 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2773 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2774 | RValue<UInt> operator-(RValue<UInt> val) |
| 2775 | { |
| 2776 | return RValue<UInt>(Nucleus::createNeg(val.value)); |
| 2777 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2778 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2779 | RValue<UInt> operator~(RValue<UInt> val) |
| 2780 | { |
| 2781 | return RValue<UInt>(Nucleus::createNot(val.value)); |
| 2782 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2783 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2784 | RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) |
| 2785 | { |
| 2786 | return IfThenElse(x > y, x, y); |
| 2787 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2788 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2789 | RValue<UInt> Min(RValue<UInt> x, RValue<UInt> y) |
| 2790 | { |
| 2791 | return IfThenElse(x < y, x, y); |
| 2792 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2793 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2794 | RValue<UInt> Clamp(RValue<UInt> x, RValue<UInt> min, RValue<UInt> max) |
| 2795 | { |
| 2796 | return Min(Max(x, min), max); |
| 2797 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2798 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2799 | RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2800 | { |
| 2801 | return RValue<Bool>(Nucleus::createICmpULT(lhs.value, rhs.value)); |
| 2802 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2803 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2804 | RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2805 | { |
| 2806 | return RValue<Bool>(Nucleus::createICmpULE(lhs.value, rhs.value)); |
| 2807 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2808 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2809 | RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2810 | { |
| 2811 | return RValue<Bool>(Nucleus::createICmpUGT(lhs.value, rhs.value)); |
| 2812 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2813 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2814 | RValue<Bool> operator>=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2815 | { |
| 2816 | return RValue<Bool>(Nucleus::createICmpUGE(lhs.value, rhs.value)); |
| 2817 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2818 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2819 | RValue<Bool> operator!=(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2820 | { |
| 2821 | return RValue<Bool>(Nucleus::createICmpNE(lhs.value, rhs.value)); |
| 2822 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2823 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2824 | RValue<Bool> operator==(RValue<UInt> lhs, RValue<UInt> rhs) |
| 2825 | { |
| 2826 | return RValue<Bool>(Nucleus::createICmpEQ(lhs.value, rhs.value)); |
| 2827 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2828 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2829 | Int2::Int2(RValue<Int4> cast) |
| 2830 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2831 | storeValue(Nucleus::createBitCast(cast.value, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2832 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2833 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2834 | Int2::Int2(int x, int y) |
| 2835 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2836 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2837 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2838 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2839 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2840 | Int2::Int2(RValue<Int2> rhs) |
| 2841 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2842 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2843 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2844 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2845 | Int2::Int2(const Int2 &rhs) |
| 2846 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2847 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2848 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2849 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2850 | Int2::Int2(const Reference<Int2> &rhs) |
| 2851 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2852 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2853 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2854 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2855 | Int2::Int2(RValue<Int> lo, RValue<Int> hi) |
| 2856 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2857 | int shuffle[4] = { 0, 4, 1, 5 }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2858 | Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2859 | |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 2860 | storeValue(Nucleus::createBitCast(packed, Int2::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2861 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2862 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2863 | RValue<Int2> Int2::operator=(RValue<Int2> rhs) |
| 2864 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2865 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2866 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2867 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2868 | RValue<Int2> Int2::operator=(const Int2 &rhs) |
| 2869 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2870 | return RValue<Int2>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2871 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2872 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2873 | RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) |
| 2874 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 2875 | return RValue<Int2>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2876 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2877 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2878 | RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2879 | { |
| 2880 | return RValue<Int2>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 2881 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2882 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2883 | RValue<Int2> operator-(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2884 | { |
| 2885 | return RValue<Int2>(Nucleus::createSub(lhs.value, rhs.value)); |
| 2886 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2887 | |
| 2888 | // RValue<Int2> operator*(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2889 | // { |
| 2890 | // return RValue<Int2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 2891 | // } |
| 2892 | |
| 2893 | // RValue<Int2> operator/(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2894 | // { |
| 2895 | // return RValue<Int2>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 2896 | // } |
| 2897 | |
| 2898 | // RValue<Int2> operator%(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2899 | // { |
| 2900 | // return RValue<Int2>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 2901 | // } |
| 2902 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2903 | RValue<Int2> operator&(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2904 | { |
| 2905 | return RValue<Int2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 2906 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2907 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2908 | RValue<Int2> operator|(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2909 | { |
| 2910 | return RValue<Int2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 2911 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2912 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2913 | RValue<Int2> operator^(RValue<Int2> lhs, RValue<Int2> rhs) |
| 2914 | { |
| 2915 | return RValue<Int2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 2916 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2917 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2918 | RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs) |
| 2919 | { |
| 2920 | return lhs = lhs + rhs; |
| 2921 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2922 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2923 | RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs) |
| 2924 | { |
| 2925 | return lhs = lhs - rhs; |
| 2926 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2927 | |
| 2928 | // RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs) |
| 2929 | // { |
| 2930 | // return lhs = lhs * rhs; |
| 2931 | // } |
| 2932 | |
| 2933 | // RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs) |
| 2934 | // { |
| 2935 | // return lhs = lhs / rhs; |
| 2936 | // } |
| 2937 | |
| 2938 | // RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs) |
| 2939 | // { |
| 2940 | // return lhs = lhs % rhs; |
| 2941 | // } |
| 2942 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2943 | RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs) |
| 2944 | { |
| 2945 | return lhs = lhs & rhs; |
| 2946 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2947 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2948 | RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs) |
| 2949 | { |
| 2950 | return lhs = lhs | rhs; |
| 2951 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2952 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2953 | RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs) |
| 2954 | { |
| 2955 | return lhs = lhs ^ rhs; |
| 2956 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2957 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2958 | RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs) |
| 2959 | { |
| 2960 | return lhs = lhs << rhs; |
| 2961 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2962 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2963 | RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs) |
| 2964 | { |
| 2965 | return lhs = lhs >> rhs; |
| 2966 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2967 | |
| 2968 | // RValue<Int2> operator+(RValue<Int2> val) |
| 2969 | // { |
| 2970 | // return val; |
| 2971 | // } |
| 2972 | |
| 2973 | // RValue<Int2> operator-(RValue<Int2> val) |
| 2974 | // { |
| 2975 | // return RValue<Int2>(Nucleus::createNeg(val.value)); |
| 2976 | // } |
| 2977 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2978 | RValue<Int2> operator~(RValue<Int2> val) |
| 2979 | { |
| 2980 | return RValue<Int2>(Nucleus::createNot(val.value)); |
| 2981 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2982 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2983 | RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y) |
| 2984 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2985 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2986 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2987 | return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 2988 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2989 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2990 | RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y) |
| 2991 | { |
Nicolas Capens | 133b87d | 2020-01-25 16:26:28 -0500 | [diff] [blame] | 2992 | // TODO(b/148379603): Optimize narrowing swizzle. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 2993 | int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2994 | auto lowHigh = RValue<Int4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 2995 | return As<Short4>(Swizzle(lowHigh, 0x2323)); |
| 2996 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 2997 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 2998 | RValue<Int> Extract(RValue<Int2> val, int i) |
| 2999 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3000 | return RValue<Int>(Nucleus::createExtractElement(val.value, Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3001 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3002 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3003 | RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) |
| 3004 | { |
| 3005 | return RValue<Int2>(Nucleus::createInsertElement(val.value, element.value, i)); |
| 3006 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3007 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3008 | UInt2::UInt2(unsigned int x, unsigned int y) |
| 3009 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3010 | int64_t constantVector[2] = { x, y }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3011 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3012 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3013 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3014 | UInt2::UInt2(RValue<UInt2> rhs) |
| 3015 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3016 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3017 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3018 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3019 | UInt2::UInt2(const UInt2 &rhs) |
| 3020 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3021 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3022 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3023 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3024 | UInt2::UInt2(const Reference<UInt2> &rhs) |
| 3025 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3026 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3027 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3028 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3029 | RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) |
| 3030 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3031 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3032 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3033 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3034 | RValue<UInt2> UInt2::operator=(const UInt2 &rhs) |
| 3035 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3036 | return RValue<UInt2>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3037 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3038 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3039 | RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) |
| 3040 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3041 | return RValue<UInt2>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3042 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3043 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3044 | RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3045 | { |
| 3046 | return RValue<UInt2>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3047 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3048 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3049 | RValue<UInt2> operator-(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3050 | { |
| 3051 | return RValue<UInt2>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3052 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3053 | |
| 3054 | // RValue<UInt2> operator*(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3055 | // { |
| 3056 | // return RValue<UInt2>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3057 | // } |
| 3058 | |
| 3059 | // RValue<UInt2> operator/(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3060 | // { |
| 3061 | // return RValue<UInt2>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 3062 | // } |
| 3063 | |
| 3064 | // RValue<UInt2> operator%(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3065 | // { |
| 3066 | // return RValue<UInt2>(Nucleus::createURem(lhs.value, rhs.value)); |
| 3067 | // } |
| 3068 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3069 | RValue<UInt2> operator&(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3070 | { |
| 3071 | return RValue<UInt2>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3072 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3073 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3074 | RValue<UInt2> operator|(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3075 | { |
| 3076 | return RValue<UInt2>(Nucleus::createOr(lhs.value, rhs.value)); |
| 3077 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3078 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3079 | RValue<UInt2> operator^(RValue<UInt2> lhs, RValue<UInt2> rhs) |
| 3080 | { |
| 3081 | return RValue<UInt2>(Nucleus::createXor(lhs.value, rhs.value)); |
| 3082 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3083 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3084 | RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3085 | { |
| 3086 | return lhs = lhs + rhs; |
| 3087 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3088 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3089 | RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3090 | { |
| 3091 | return lhs = lhs - rhs; |
| 3092 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3093 | |
| 3094 | // RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3095 | // { |
| 3096 | // return lhs = lhs * rhs; |
| 3097 | // } |
| 3098 | |
| 3099 | // RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3100 | // { |
| 3101 | // return lhs = lhs / rhs; |
| 3102 | // } |
| 3103 | |
| 3104 | // RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3105 | // { |
| 3106 | // return lhs = lhs % rhs; |
| 3107 | // } |
| 3108 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3109 | RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3110 | { |
| 3111 | return lhs = lhs & rhs; |
| 3112 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3113 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3114 | RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3115 | { |
| 3116 | return lhs = lhs | rhs; |
| 3117 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3118 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3119 | RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs) |
| 3120 | { |
| 3121 | return lhs = lhs ^ rhs; |
| 3122 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3123 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3124 | RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs) |
| 3125 | { |
| 3126 | return lhs = lhs << rhs; |
| 3127 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3128 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3129 | RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs) |
| 3130 | { |
| 3131 | return lhs = lhs >> rhs; |
| 3132 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3133 | |
| 3134 | // RValue<UInt2> operator+(RValue<UInt2> val) |
| 3135 | // { |
| 3136 | // return val; |
| 3137 | // } |
| 3138 | |
| 3139 | // RValue<UInt2> operator-(RValue<UInt2> val) |
| 3140 | // { |
| 3141 | // return RValue<UInt2>(Nucleus::createNeg(val.value)); |
| 3142 | // } |
| 3143 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3144 | RValue<UInt2> operator~(RValue<UInt2> val) |
| 3145 | { |
| 3146 | return RValue<UInt2>(Nucleus::createNot(val.value)); |
| 3147 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3148 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3149 | RValue<UInt> Extract(RValue<UInt2> val, int i) |
| 3150 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3151 | return RValue<UInt>(Nucleus::createExtractElement(val.value, UInt::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3152 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3153 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3154 | RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i) |
| 3155 | { |
| 3156 | return RValue<UInt2>(Nucleus::createInsertElement(val.value, element.value, i)); |
| 3157 | } |
Ben Clayton | 8ab4053 | 2019-05-10 16:23:13 +0100 | [diff] [blame] | 3158 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3159 | Int4::Int4() |
| 3160 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3161 | { |
| 3162 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3163 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3164 | Int4::Int4(RValue<Float4> cast) |
| 3165 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3166 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3167 | Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::type()); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3168 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3169 | storeValue(xyzw); |
| 3170 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3171 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3172 | Int4::Int4(int xyzw) |
| 3173 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3174 | { |
| 3175 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3176 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3177 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3178 | Int4::Int4(int x, int yzw) |
| 3179 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3180 | { |
| 3181 | constant(x, yzw, yzw, yzw); |
| 3182 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3183 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3184 | Int4::Int4(int x, int y, int zw) |
| 3185 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3186 | { |
| 3187 | constant(x, y, zw, zw); |
| 3188 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3189 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3190 | Int4::Int4(int x, int y, int z, int w) |
| 3191 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3192 | { |
| 3193 | constant(x, y, z, w); |
| 3194 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3195 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3196 | void Int4::constant(int x, int y, int z, int w) |
| 3197 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3198 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3199 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3200 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3201 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3202 | Int4::Int4(RValue<Int4> rhs) |
| 3203 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3204 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3205 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3206 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3207 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3208 | Int4::Int4(const Int4 &rhs) |
| 3209 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3210 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3211 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3212 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3213 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3214 | Int4::Int4(const Reference<Int4> &rhs) |
| 3215 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3216 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3217 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3218 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3219 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3220 | Int4::Int4(RValue<UInt4> rhs) |
| 3221 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3222 | { |
| 3223 | storeValue(rhs.value); |
| 3224 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3225 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3226 | Int4::Int4(const UInt4 &rhs) |
| 3227 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3228 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3229 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3230 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3231 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3232 | Int4::Int4(const Reference<UInt4> &rhs) |
| 3233 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3234 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3235 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3236 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3237 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3238 | Int4::Int4(RValue<Int2> lo, RValue<Int2> hi) |
| 3239 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3240 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3241 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3242 | Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3243 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3244 | storeValue(packed); |
| 3245 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3246 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3247 | Int4::Int4(const Int &rhs) |
| 3248 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3249 | { |
| 3250 | *this = RValue<Int>(rhs.loadValue()); |
| 3251 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3252 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3253 | Int4::Int4(const Reference<Int> &rhs) |
| 3254 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3255 | { |
| 3256 | *this = RValue<Int>(rhs.loadValue()); |
| 3257 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3258 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3259 | RValue<Int4> Int4::operator=(RValue<Int4> rhs) |
| 3260 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3261 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3262 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3263 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3264 | RValue<Int4> Int4::operator=(const Int4 &rhs) |
| 3265 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3266 | return RValue<Int4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3267 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3268 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3269 | RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) |
| 3270 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3271 | return RValue<Int4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3272 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3273 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3274 | RValue<Int4> operator+(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3275 | { |
| 3276 | return RValue<Int4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3277 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3278 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3279 | RValue<Int4> operator-(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3280 | { |
| 3281 | return RValue<Int4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3282 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3283 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3284 | RValue<Int4> operator*(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3285 | { |
| 3286 | return RValue<Int4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3287 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3288 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3289 | RValue<Int4> operator/(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3290 | { |
| 3291 | return RValue<Int4>(Nucleus::createSDiv(lhs.value, rhs.value)); |
| 3292 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3293 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3294 | RValue<Int4> operator%(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3295 | { |
| 3296 | return RValue<Int4>(Nucleus::createSRem(lhs.value, rhs.value)); |
| 3297 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3298 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3299 | RValue<Int4> operator&(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3300 | { |
| 3301 | return RValue<Int4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3302 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3303 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3304 | RValue<Int4> operator|(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3305 | { |
| 3306 | return RValue<Int4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 3307 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3308 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3309 | RValue<Int4> operator^(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3310 | { |
| 3311 | return RValue<Int4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 3312 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3313 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3314 | RValue<Int4> operator<<(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3315 | { |
| 3316 | return RValue<Int4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3317 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3318 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3319 | RValue<Int4> operator>>(RValue<Int4> lhs, RValue<Int4> rhs) |
| 3320 | { |
| 3321 | return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value)); |
| 3322 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3323 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3324 | RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs) |
| 3325 | { |
| 3326 | return lhs = lhs + rhs; |
| 3327 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3328 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3329 | RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs) |
| 3330 | { |
| 3331 | return lhs = lhs - rhs; |
| 3332 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3333 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3334 | RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs) |
| 3335 | { |
| 3336 | return lhs = lhs * rhs; |
| 3337 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3338 | |
| 3339 | // RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs) |
| 3340 | // { |
| 3341 | // return lhs = lhs / rhs; |
| 3342 | // } |
| 3343 | |
| 3344 | // RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs) |
| 3345 | // { |
| 3346 | // return lhs = lhs % rhs; |
| 3347 | // } |
| 3348 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3349 | RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs) |
| 3350 | { |
| 3351 | return lhs = lhs & rhs; |
| 3352 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3353 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3354 | RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs) |
| 3355 | { |
| 3356 | return lhs = lhs | rhs; |
| 3357 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3358 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3359 | RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs) |
| 3360 | { |
| 3361 | return lhs = lhs ^ rhs; |
| 3362 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3363 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3364 | RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs) |
| 3365 | { |
| 3366 | return lhs = lhs << rhs; |
| 3367 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3368 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3369 | RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs) |
| 3370 | { |
| 3371 | return lhs = lhs >> rhs; |
| 3372 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3373 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3374 | RValue<Int4> operator+(RValue<Int4> val) |
| 3375 | { |
| 3376 | return val; |
| 3377 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3378 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3379 | RValue<Int4> operator-(RValue<Int4> val) |
| 3380 | { |
| 3381 | return RValue<Int4>(Nucleus::createNeg(val.value)); |
| 3382 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3383 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3384 | RValue<Int4> operator~(RValue<Int4> val) |
| 3385 | { |
| 3386 | return RValue<Int4>(Nucleus::createNot(val.value)); |
| 3387 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3388 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3389 | RValue<Int> Extract(RValue<Int4> x, int i) |
| 3390 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3391 | return RValue<Int>(Nucleus::createExtractElement(x.value, Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3392 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3393 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3394 | RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i) |
| 3395 | { |
| 3396 | return RValue<Int4>(Nucleus::createInsertElement(x.value, element.value, i)); |
| 3397 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3398 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3399 | RValue<Int4> Swizzle(RValue<Int4> x, uint16_t select) |
| 3400 | { |
| 3401 | return RValue<Int4>(createSwizzle4(x.value, select)); |
| 3402 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3403 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3404 | RValue<Int4> Shuffle(RValue<Int4> x, RValue<Int4> y, unsigned short select) |
| 3405 | { |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 3406 | return RValue<Int4>(createShuffle4(x.value, y.value, select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3407 | } |
David 'Digit' Turner | b9f03f4 | 2019-12-04 19:32:34 +0100 | [diff] [blame] | 3408 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3409 | UInt4::UInt4() |
| 3410 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3411 | { |
| 3412 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3413 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3414 | UInt4::UInt4(int xyzw) |
| 3415 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3416 | { |
| 3417 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3418 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3419 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3420 | UInt4::UInt4(int x, int yzw) |
| 3421 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3422 | { |
| 3423 | constant(x, yzw, yzw, yzw); |
| 3424 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3425 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3426 | UInt4::UInt4(int x, int y, int zw) |
| 3427 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3428 | { |
| 3429 | constant(x, y, zw, zw); |
| 3430 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3431 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3432 | UInt4::UInt4(int x, int y, int z, int w) |
| 3433 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3434 | { |
| 3435 | constant(x, y, z, w); |
| 3436 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3437 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3438 | void UInt4::constant(int x, int y, int z, int w) |
| 3439 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3440 | int64_t constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3441 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3442 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3443 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3444 | UInt4::UInt4(RValue<UInt4> rhs) |
| 3445 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3446 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3447 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3448 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3449 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3450 | UInt4::UInt4(const UInt4 &rhs) |
| 3451 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3452 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3453 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3454 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3455 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3456 | UInt4::UInt4(const Reference<UInt4> &rhs) |
| 3457 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3458 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3459 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3460 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3461 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3462 | UInt4::UInt4(RValue<Int4> rhs) |
| 3463 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3464 | { |
| 3465 | storeValue(rhs.value); |
| 3466 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3467 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3468 | UInt4::UInt4(const Int4 &rhs) |
| 3469 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3470 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3471 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3472 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3473 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3474 | UInt4::UInt4(const Reference<Int4> &rhs) |
| 3475 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3476 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3477 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3478 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3479 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3480 | UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi) |
| 3481 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3482 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3483 | int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32 |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3484 | Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle); |
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 | storeValue(packed); |
| 3487 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3488 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3489 | UInt4::UInt4(const UInt &rhs) |
| 3490 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3491 | { |
| 3492 | *this = RValue<UInt>(rhs.loadValue()); |
| 3493 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3494 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3495 | UInt4::UInt4(const Reference<UInt> &rhs) |
| 3496 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3497 | { |
| 3498 | *this = RValue<UInt>(rhs.loadValue()); |
| 3499 | } |
Ben Clayton | 88816fa | 2019-05-15 17:08:14 +0100 | [diff] [blame] | 3500 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3501 | RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) |
| 3502 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3503 | return store(rhs); |
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<UInt4> UInt4::operator=(const UInt4 &rhs) |
| 3507 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3508 | return RValue<UInt4>(storeValue(rhs.loadValue())); |
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<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) |
| 3512 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3513 | return RValue<UInt4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3514 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3515 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3516 | RValue<UInt4> operator+(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3517 | { |
| 3518 | return RValue<UInt4>(Nucleus::createAdd(lhs.value, rhs.value)); |
| 3519 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3520 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3521 | RValue<UInt4> operator-(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3522 | { |
| 3523 | return RValue<UInt4>(Nucleus::createSub(lhs.value, rhs.value)); |
| 3524 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3525 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3526 | RValue<UInt4> operator*(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3527 | { |
| 3528 | return RValue<UInt4>(Nucleus::createMul(lhs.value, rhs.value)); |
| 3529 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3530 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3531 | RValue<UInt4> operator/(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3532 | { |
| 3533 | return RValue<UInt4>(Nucleus::createUDiv(lhs.value, rhs.value)); |
| 3534 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3535 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3536 | RValue<UInt4> operator%(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3537 | { |
| 3538 | return RValue<UInt4>(Nucleus::createURem(lhs.value, rhs.value)); |
| 3539 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3540 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3541 | RValue<UInt4> operator&(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3542 | { |
| 3543 | return RValue<UInt4>(Nucleus::createAnd(lhs.value, rhs.value)); |
| 3544 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3545 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3546 | RValue<UInt4> operator|(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3547 | { |
| 3548 | return RValue<UInt4>(Nucleus::createOr(lhs.value, rhs.value)); |
| 3549 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3550 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3551 | RValue<UInt4> operator^(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3552 | { |
| 3553 | return RValue<UInt4>(Nucleus::createXor(lhs.value, rhs.value)); |
| 3554 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3555 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3556 | RValue<UInt4> operator<<(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3557 | { |
| 3558 | return RValue<UInt4>(Nucleus::createShl(lhs.value, rhs.value)); |
| 3559 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3560 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3561 | RValue<UInt4> operator>>(RValue<UInt4> lhs, RValue<UInt4> rhs) |
| 3562 | { |
| 3563 | return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value)); |
| 3564 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3565 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3566 | RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3567 | { |
| 3568 | return lhs = lhs + rhs; |
| 3569 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3570 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3571 | RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3572 | { |
| 3573 | return lhs = lhs - rhs; |
| 3574 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3575 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3576 | RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3577 | { |
| 3578 | return lhs = lhs * rhs; |
| 3579 | } |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3580 | |
| 3581 | // RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3582 | // { |
| 3583 | // return lhs = lhs / rhs; |
| 3584 | // } |
| 3585 | |
| 3586 | // RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3587 | // { |
| 3588 | // return lhs = lhs % rhs; |
| 3589 | // } |
| 3590 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3591 | RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3592 | { |
| 3593 | return lhs = lhs & rhs; |
Nicolas Capens | b6d4ce3 | 2019-03-12 23:00:24 -0400 | [diff] [blame] | 3594 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3595 | |
| 3596 | RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3597 | { |
| 3598 | return lhs = lhs | rhs; |
| 3599 | } |
| 3600 | |
| 3601 | RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs) |
| 3602 | { |
| 3603 | return lhs = lhs ^ rhs; |
| 3604 | } |
| 3605 | |
| 3606 | RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs) |
| 3607 | { |
| 3608 | return lhs = lhs << rhs; |
| 3609 | } |
| 3610 | |
| 3611 | RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs) |
| 3612 | { |
| 3613 | return lhs = lhs >> rhs; |
| 3614 | } |
| 3615 | |
| 3616 | RValue<UInt4> operator+(RValue<UInt4> val) |
| 3617 | { |
| 3618 | return val; |
| 3619 | } |
| 3620 | |
| 3621 | RValue<UInt4> operator-(RValue<UInt4> val) |
| 3622 | { |
| 3623 | return RValue<UInt4>(Nucleus::createNeg(val.value)); |
| 3624 | } |
| 3625 | |
| 3626 | RValue<UInt4> operator~(RValue<UInt4> val) |
| 3627 | { |
| 3628 | return RValue<UInt4>(Nucleus::createNot(val.value)); |
| 3629 | } |
| 3630 | |
| 3631 | RValue<UInt> Extract(RValue<UInt4> x, int i) |
| 3632 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3633 | return RValue<UInt>(Nucleus::createExtractElement(x.value, Int::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3634 | } |
| 3635 | |
| 3636 | RValue<UInt4> Insert(RValue<UInt4> x, RValue<UInt> element, int i) |
| 3637 | { |
| 3638 | return RValue<UInt4>(Nucleus::createInsertElement(x.value, element.value, i)); |
| 3639 | } |
| 3640 | |
| 3641 | RValue<UInt4> Swizzle(RValue<UInt4> x, uint16_t select) |
| 3642 | { |
| 3643 | return RValue<UInt4>(createSwizzle4(x.value, select)); |
| 3644 | } |
| 3645 | |
| 3646 | RValue<UInt4> Shuffle(RValue<UInt4> x, RValue<UInt4> y, unsigned short select) |
| 3647 | { |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 3648 | return RValue<UInt4>(createShuffle4(x.value, y.value, select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3649 | } |
| 3650 | |
| 3651 | Half::Half(RValue<Float> cast) |
| 3652 | { |
| 3653 | UInt fp32i = As<UInt>(cast); |
| 3654 | UInt abs = fp32i & 0x7FFFFFFF; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3655 | UShort fp16i((fp32i & 0x80000000) >> 16); // sign |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3656 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3657 | If(abs > 0x47FFEFFF) // Infinity |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3658 | { |
| 3659 | fp16i |= UShort(0x7FFF); |
| 3660 | } |
| 3661 | Else |
| 3662 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3663 | If(abs < 0x38800000) // Denormal |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3664 | { |
| 3665 | Int mantissa = (abs & 0x007FFFFF) | 0x00800000; |
| 3666 | Int e = 113 - (abs >> 23); |
Nicolas Capens | 60f8c2e | 2019-12-12 13:40:15 -0500 | [diff] [blame] | 3667 | abs = IfThenElse(e < 24, (mantissa >> e), Int(0)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3668 | fp16i |= UShort((abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3669 | } |
| 3670 | Else |
| 3671 | { |
| 3672 | fp16i |= UShort((abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13); |
| 3673 | } |
| 3674 | } |
| 3675 | |
| 3676 | storeValue(fp16i.loadValue()); |
| 3677 | } |
| 3678 | |
| 3679 | Float::Float(RValue<Int> cast) |
| 3680 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3681 | Value *integer = Nucleus::createSIToFP(cast.value, Float::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3682 | |
| 3683 | storeValue(integer); |
| 3684 | } |
| 3685 | |
| 3686 | Float::Float(RValue<UInt> cast) |
| 3687 | { |
| 3688 | RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) + |
| 3689 | As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u))); |
| 3690 | |
| 3691 | storeValue(result.value); |
| 3692 | } |
| 3693 | |
| 3694 | Float::Float(RValue<Half> cast) |
| 3695 | { |
| 3696 | Int fp16i(As<UShort>(cast)); |
| 3697 | |
| 3698 | Int s = (fp16i >> 15) & 0x00000001; |
| 3699 | Int e = (fp16i >> 10) & 0x0000001F; |
| 3700 | Int m = fp16i & 0x000003FF; |
| 3701 | |
| 3702 | UInt fp32i(s << 31); |
| 3703 | If(e == 0) |
| 3704 | { |
| 3705 | If(m != 0) |
| 3706 | { |
| 3707 | While((m & 0x00000400) == 0) |
| 3708 | { |
| 3709 | m <<= 1; |
| 3710 | e -= 1; |
| 3711 | } |
| 3712 | |
| 3713 | fp32i |= As<UInt>(((e + (127 - 15) + 1) << 23) | ((m & ~0x00000400) << 13)); |
| 3714 | } |
| 3715 | } |
| 3716 | Else |
| 3717 | { |
| 3718 | fp32i |= As<UInt>(((e + (127 - 15)) << 23) | (m << 13)); |
| 3719 | } |
| 3720 | |
| 3721 | storeValue(As<Float>(fp32i).value); |
| 3722 | } |
| 3723 | |
| 3724 | Float::Float(float x) |
| 3725 | { |
| 3726 | // C++ does not have a way to write an infinite or NaN literal, |
| 3727 | // nor does it allow division by zero as a constant expression. |
| 3728 | // Thus we should not accept inf or NaN as a Reactor Float constant, |
| 3729 | // as this would typically idicate a bug, and avoids undefined |
| 3730 | // behavior. |
| 3731 | // |
| 3732 | // This also prevents the issue of the LLVM JIT only taking double |
| 3733 | // values for constructing floating-point constants. During the |
| 3734 | // conversion from single-precision to double, a signaling NaN can |
| 3735 | // become a quiet NaN, thus altering its bit pattern. Hence this |
| 3736 | // assert is also helpful for detecting cases where integers are |
| 3737 | // being reinterpreted as float and then bitcast to integer again, |
| 3738 | // which does not guarantee preserving the integer value. |
| 3739 | // |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3740 | // The inifinity() method can be used to obtain positive infinity. |
| 3741 | // Should NaN constants be required, methods like quiet_NaN() and |
| 3742 | // signaling_NaN() should be added (matching std::numeric_limits). |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3743 | ASSERT(std::isfinite(x)); |
| 3744 | |
| 3745 | storeValue(Nucleus::createConstantFloat(x)); |
| 3746 | } |
| 3747 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3748 | // TODO(b/140302841): Negative infinity can be obtained by using '-infinity()'. |
| 3749 | // This comes at a minor run-time JIT cost, and the backend may or may not |
| 3750 | // perform constant folding. This can be optimized by having Reactor perform |
| 3751 | // the folding, which would still be cheaper than having a capable backend do it. |
| 3752 | Float Float::infinity() |
| 3753 | { |
| 3754 | Float result; |
| 3755 | |
| 3756 | constexpr double inf = std::numeric_limits<double>::infinity(); |
| 3757 | result.storeValue(Nucleus::createConstantFloat(inf)); |
| 3758 | |
| 3759 | return result; |
| 3760 | } |
| 3761 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3762 | Float::Float(RValue<Float> rhs) |
| 3763 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3764 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3765 | } |
| 3766 | |
| 3767 | Float::Float(const Float &rhs) |
| 3768 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3769 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3770 | } |
| 3771 | |
| 3772 | Float::Float(const Reference<Float> &rhs) |
| 3773 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3774 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3775 | } |
| 3776 | |
| 3777 | Float::Float(Argument<Float> argument) |
| 3778 | { |
| 3779 | storeValue(argument.value); |
| 3780 | } |
| 3781 | |
| 3782 | RValue<Float> Float::operator=(RValue<Float> rhs) |
| 3783 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3784 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3785 | } |
| 3786 | |
| 3787 | RValue<Float> Float::operator=(const Float &rhs) |
| 3788 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3789 | return RValue<Float>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3790 | } |
| 3791 | |
| 3792 | RValue<Float> Float::operator=(const Reference<Float> &rhs) |
| 3793 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3794 | return RValue<Float>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3795 | } |
| 3796 | |
| 3797 | RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs) |
| 3798 | { |
| 3799 | return RValue<Float>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 3800 | } |
| 3801 | |
| 3802 | RValue<Float> operator-(RValue<Float> lhs, RValue<Float> rhs) |
| 3803 | { |
| 3804 | return RValue<Float>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 3805 | } |
| 3806 | |
| 3807 | RValue<Float> operator*(RValue<Float> lhs, RValue<Float> rhs) |
| 3808 | { |
| 3809 | return RValue<Float>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 3810 | } |
| 3811 | |
| 3812 | RValue<Float> operator/(RValue<Float> lhs, RValue<Float> rhs) |
| 3813 | { |
| 3814 | return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 3815 | } |
| 3816 | |
| 3817 | RValue<Float> operator+=(Float &lhs, RValue<Float> rhs) |
| 3818 | { |
| 3819 | return lhs = lhs + rhs; |
| 3820 | } |
| 3821 | |
| 3822 | RValue<Float> operator-=(Float &lhs, RValue<Float> rhs) |
| 3823 | { |
| 3824 | return lhs = lhs - rhs; |
| 3825 | } |
| 3826 | |
| 3827 | RValue<Float> operator*=(Float &lhs, RValue<Float> rhs) |
| 3828 | { |
| 3829 | return lhs = lhs * rhs; |
| 3830 | } |
| 3831 | |
| 3832 | RValue<Float> operator/=(Float &lhs, RValue<Float> rhs) |
| 3833 | { |
| 3834 | return lhs = lhs / rhs; |
| 3835 | } |
| 3836 | |
| 3837 | RValue<Float> operator+(RValue<Float> val) |
| 3838 | { |
| 3839 | return val; |
| 3840 | } |
| 3841 | |
| 3842 | RValue<Float> operator-(RValue<Float> val) |
| 3843 | { |
| 3844 | return RValue<Float>(Nucleus::createFNeg(val.value)); |
| 3845 | } |
| 3846 | |
| 3847 | RValue<Bool> operator<(RValue<Float> lhs, RValue<Float> rhs) |
| 3848 | { |
| 3849 | return RValue<Bool>(Nucleus::createFCmpOLT(lhs.value, rhs.value)); |
| 3850 | } |
| 3851 | |
| 3852 | RValue<Bool> operator<=(RValue<Float> lhs, RValue<Float> rhs) |
| 3853 | { |
| 3854 | return RValue<Bool>(Nucleus::createFCmpOLE(lhs.value, rhs.value)); |
| 3855 | } |
| 3856 | |
| 3857 | RValue<Bool> operator>(RValue<Float> lhs, RValue<Float> rhs) |
| 3858 | { |
| 3859 | return RValue<Bool>(Nucleus::createFCmpOGT(lhs.value, rhs.value)); |
| 3860 | } |
| 3861 | |
| 3862 | RValue<Bool> operator>=(RValue<Float> lhs, RValue<Float> rhs) |
| 3863 | { |
| 3864 | return RValue<Bool>(Nucleus::createFCmpOGE(lhs.value, rhs.value)); |
| 3865 | } |
| 3866 | |
| 3867 | RValue<Bool> operator!=(RValue<Float> lhs, RValue<Float> rhs) |
| 3868 | { |
| 3869 | return RValue<Bool>(Nucleus::createFCmpONE(lhs.value, rhs.value)); |
| 3870 | } |
| 3871 | |
| 3872 | RValue<Bool> operator==(RValue<Float> lhs, RValue<Float> rhs) |
| 3873 | { |
| 3874 | return RValue<Bool>(Nucleus::createFCmpOEQ(lhs.value, rhs.value)); |
| 3875 | } |
| 3876 | |
| 3877 | RValue<Float> Abs(RValue<Float> x) |
| 3878 | { |
| 3879 | return IfThenElse(x > 0.0f, x, -x); |
| 3880 | } |
| 3881 | |
| 3882 | RValue<Float> Max(RValue<Float> x, RValue<Float> y) |
| 3883 | { |
| 3884 | return IfThenElse(x > y, x, y); |
| 3885 | } |
| 3886 | |
| 3887 | RValue<Float> Min(RValue<Float> x, RValue<Float> y) |
| 3888 | { |
| 3889 | return IfThenElse(x < y, x, y); |
| 3890 | } |
| 3891 | |
| 3892 | Float2::Float2(RValue<Float4> cast) |
| 3893 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3894 | storeValue(Nucleus::createBitCast(cast.value, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3895 | } |
| 3896 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3897 | Float4::Float4(RValue<Byte4> cast) |
| 3898 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3899 | { |
| 3900 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3901 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3902 | |
| 3903 | storeValue(xyzw); |
| 3904 | } |
| 3905 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3906 | Float4::Float4(RValue<SByte4> cast) |
| 3907 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3908 | { |
| 3909 | Value *a = Int4(cast).loadValue(); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3910 | Value *xyzw = Nucleus::createSIToFP(a, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3911 | |
| 3912 | storeValue(xyzw); |
| 3913 | } |
| 3914 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3915 | Float4::Float4(RValue<Short4> cast) |
| 3916 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3917 | { |
| 3918 | Int4 c(cast); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3919 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3920 | } |
| 3921 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3922 | Float4::Float4(RValue<UShort4> cast) |
| 3923 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3924 | { |
| 3925 | Int4 c(cast); |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3926 | storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3927 | } |
| 3928 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3929 | Float4::Float4(RValue<Int4> cast) |
| 3930 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3931 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3932 | Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::type()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3933 | |
| 3934 | storeValue(xyzw); |
| 3935 | } |
| 3936 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3937 | Float4::Float4(RValue<UInt4> cast) |
| 3938 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3939 | { |
| 3940 | RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) + |
| 3941 | As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u))); |
| 3942 | |
| 3943 | storeValue(result.value); |
| 3944 | } |
| 3945 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3946 | Float4::Float4() |
| 3947 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3948 | { |
| 3949 | } |
| 3950 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3951 | Float4::Float4(float xyzw) |
| 3952 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3953 | { |
| 3954 | constant(xyzw, xyzw, xyzw, xyzw); |
| 3955 | } |
| 3956 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3957 | Float4::Float4(float x, float yzw) |
| 3958 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3959 | { |
| 3960 | constant(x, yzw, yzw, yzw); |
| 3961 | } |
| 3962 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3963 | Float4::Float4(float x, float y, float zw) |
| 3964 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3965 | { |
| 3966 | constant(x, y, zw, zw); |
| 3967 | } |
| 3968 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3969 | Float4::Float4(float x, float y, float z, float w) |
| 3970 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3971 | { |
| 3972 | constant(x, y, z, w); |
| 3973 | } |
| 3974 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3975 | Float4 Float4::infinity() |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3976 | { |
| 3977 | Float4 result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3978 | |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3979 | constexpr double inf = std::numeric_limits<double>::infinity(); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3980 | double constantVector[4] = { inf, inf, inf, inf }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3981 | result.storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | e572088 | 2020-01-13 14:10:04 -0500 | [diff] [blame] | 3982 | |
| 3983 | return result; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3984 | } |
| 3985 | |
| 3986 | void Float4::constant(float x, float y, float z, float w) |
| 3987 | { |
| 3988 | // See Float(float) constructor for the rationale behind this assert. |
| 3989 | ASSERT(std::isfinite(x) && std::isfinite(y) && std::isfinite(z) && std::isfinite(w)); |
| 3990 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3991 | double constantVector[4] = { x, y, z, w }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 3992 | storeValue(Nucleus::createConstantVector(constantVector, type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3993 | } |
| 3994 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 3995 | Float4::Float4(RValue<Float4> rhs) |
| 3996 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3997 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 3998 | store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 3999 | } |
| 4000 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4001 | Float4::Float4(const Float4 &rhs) |
| 4002 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4003 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 4004 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4005 | } |
| 4006 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4007 | Float4::Float4(const Reference<Float4> &rhs) |
| 4008 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4009 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 4010 | storeValue(rhs.loadValue()); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4011 | } |
| 4012 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4013 | Float4::Float4(const Float &rhs) |
| 4014 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4015 | { |
| 4016 | *this = RValue<Float>(rhs.loadValue()); |
| 4017 | } |
| 4018 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4019 | Float4::Float4(const Reference<Float> &rhs) |
| 4020 | : XYZW(this) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4021 | { |
| 4022 | *this = RValue<Float>(rhs.loadValue()); |
| 4023 | } |
| 4024 | |
| 4025 | RValue<Float4> Float4::operator=(float x) |
| 4026 | { |
| 4027 | return *this = Float4(x, x, x, x); |
| 4028 | } |
| 4029 | |
| 4030 | RValue<Float4> Float4::operator=(RValue<Float4> rhs) |
| 4031 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 4032 | return store(rhs); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4033 | } |
| 4034 | |
| 4035 | RValue<Float4> Float4::operator=(const Float4 &rhs) |
| 4036 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 4037 | return RValue<Float4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4038 | } |
| 4039 | |
| 4040 | RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) |
| 4041 | { |
Nicolas Capens | 5f77c5e | 2020-05-01 22:51:11 -0400 | [diff] [blame^] | 4042 | return RValue<Float4>(storeValue(rhs.loadValue())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4043 | } |
| 4044 | |
| 4045 | RValue<Float4> Float4::operator=(RValue<Float> rhs) |
| 4046 | { |
| 4047 | return *this = Float4(rhs); |
| 4048 | } |
| 4049 | |
| 4050 | RValue<Float4> Float4::operator=(const Float &rhs) |
| 4051 | { |
| 4052 | return *this = Float4(rhs); |
| 4053 | } |
| 4054 | |
| 4055 | RValue<Float4> Float4::operator=(const Reference<Float> &rhs) |
| 4056 | { |
| 4057 | return *this = Float4(rhs); |
| 4058 | } |
| 4059 | |
| 4060 | RValue<Float4> operator+(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4061 | { |
| 4062 | return RValue<Float4>(Nucleus::createFAdd(lhs.value, rhs.value)); |
| 4063 | } |
| 4064 | |
| 4065 | RValue<Float4> operator-(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4066 | { |
| 4067 | return RValue<Float4>(Nucleus::createFSub(lhs.value, rhs.value)); |
| 4068 | } |
| 4069 | |
| 4070 | RValue<Float4> operator*(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4071 | { |
| 4072 | return RValue<Float4>(Nucleus::createFMul(lhs.value, rhs.value)); |
| 4073 | } |
| 4074 | |
| 4075 | RValue<Float4> operator/(RValue<Float4> lhs, RValue<Float4> rhs) |
| 4076 | { |
| 4077 | return RValue<Float4>(Nucleus::createFDiv(lhs.value, rhs.value)); |
| 4078 | } |
| 4079 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4080 | RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs) |
| 4081 | { |
| 4082 | return lhs = lhs + rhs; |
| 4083 | } |
| 4084 | |
| 4085 | RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs) |
| 4086 | { |
| 4087 | return lhs = lhs - rhs; |
| 4088 | } |
| 4089 | |
| 4090 | RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs) |
| 4091 | { |
| 4092 | return lhs = lhs * rhs; |
| 4093 | } |
| 4094 | |
| 4095 | RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs) |
| 4096 | { |
| 4097 | return lhs = lhs / rhs; |
| 4098 | } |
| 4099 | |
| 4100 | RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs) |
| 4101 | { |
| 4102 | return lhs = lhs % rhs; |
| 4103 | } |
| 4104 | |
| 4105 | RValue<Float4> operator+(RValue<Float4> val) |
| 4106 | { |
| 4107 | return val; |
| 4108 | } |
| 4109 | |
| 4110 | RValue<Float4> operator-(RValue<Float4> val) |
| 4111 | { |
| 4112 | return RValue<Float4>(Nucleus::createFNeg(val.value)); |
| 4113 | } |
| 4114 | |
| 4115 | RValue<Float4> Abs(RValue<Float4> x) |
| 4116 | { |
| 4117 | // TODO: Optimize. |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4118 | Value *vector = Nucleus::createBitCast(x.value, Int4::type()); |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4119 | int64_t constantVector[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4120 | Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, Int4::type())); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4121 | |
| 4122 | return As<Float4>(result); |
| 4123 | } |
| 4124 | |
| 4125 | RValue<Float4> Insert(RValue<Float4> x, RValue<Float> element, int i) |
| 4126 | { |
| 4127 | return RValue<Float4>(Nucleus::createInsertElement(x.value, element.value, i)); |
| 4128 | } |
| 4129 | |
| 4130 | RValue<Float> Extract(RValue<Float4> x, int i) |
| 4131 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4132 | return RValue<Float>(Nucleus::createExtractElement(x.value, Float::type(), i)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4133 | } |
| 4134 | |
| 4135 | RValue<Float4> Swizzle(RValue<Float4> x, uint16_t select) |
| 4136 | { |
| 4137 | return RValue<Float4>(createSwizzle4(x.value, select)); |
| 4138 | } |
| 4139 | |
| 4140 | RValue<Float4> Shuffle(RValue<Float4> x, RValue<Float4> y, uint16_t select) |
| 4141 | { |
Nicolas Capens | d95467e | 2020-01-16 01:44:39 -0500 | [diff] [blame] | 4142 | return RValue<Float4>(createShuffle4(x.value, y.value, select)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4143 | } |
| 4144 | |
| 4145 | RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, uint16_t imm) |
| 4146 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4147 | int shuffle[4] = { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4148 | ((imm >> 12) & 0x03) + 0, |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4149 | ((imm >> 8) & 0x03) + 0, |
| 4150 | ((imm >> 4) & 0x03) + 4, |
| 4151 | ((imm >> 0) & 0x03) + 4, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4152 | }; |
| 4153 | |
| 4154 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 4155 | } |
| 4156 | |
| 4157 | RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y) |
| 4158 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4159 | int shuffle[4] = { 0, 4, 1, 5 }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4160 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 4161 | } |
| 4162 | |
| 4163 | RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y) |
| 4164 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4165 | int shuffle[4] = { 2, 6, 3, 7 }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4166 | return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle)); |
| 4167 | } |
| 4168 | |
| 4169 | RValue<Float4> Mask(Float4 &lhs, RValue<Float4> rhs, uint16_t select) |
| 4170 | { |
| 4171 | Value *vector = lhs.loadValue(); |
| 4172 | Value *result = createMask4(vector, rhs.value, select); |
| 4173 | lhs.storeValue(result); |
| 4174 | |
| 4175 | return RValue<Float4>(result); |
| 4176 | } |
| 4177 | |
| 4178 | RValue<Int4> IsInf(RValue<Float4> x) |
| 4179 | { |
| 4180 | return CmpEQ(As<Int4>(x) & Int4(0x7FFFFFFF), Int4(0x7F800000)); |
| 4181 | } |
| 4182 | |
| 4183 | RValue<Int4> IsNan(RValue<Float4> x) |
| 4184 | { |
| 4185 | return ~CmpEQ(x, x); |
| 4186 | } |
| 4187 | |
| 4188 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset) |
| 4189 | { |
| 4190 | return lhs + RValue<Int>(Nucleus::createConstantInt(offset)); |
| 4191 | } |
| 4192 | |
| 4193 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4194 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4195 | 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] | 4196 | } |
| 4197 | |
| 4198 | RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4199 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4200 | 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] | 4201 | } |
| 4202 | |
| 4203 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset) |
| 4204 | { |
| 4205 | return lhs = lhs + offset; |
| 4206 | } |
| 4207 | |
| 4208 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4209 | { |
| 4210 | return lhs = lhs + offset; |
| 4211 | } |
| 4212 | |
| 4213 | RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4214 | { |
| 4215 | return lhs = lhs + offset; |
| 4216 | } |
| 4217 | |
| 4218 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset) |
| 4219 | { |
| 4220 | return lhs + -offset; |
| 4221 | } |
| 4222 | |
| 4223 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset) |
| 4224 | { |
| 4225 | return lhs + -offset; |
| 4226 | } |
| 4227 | |
| 4228 | RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset) |
| 4229 | { |
| 4230 | return lhs + -offset; |
| 4231 | } |
| 4232 | |
| 4233 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset) |
| 4234 | { |
| 4235 | return lhs = lhs - offset; |
| 4236 | } |
| 4237 | |
| 4238 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset) |
| 4239 | { |
| 4240 | return lhs = lhs - offset; |
| 4241 | } |
| 4242 | |
| 4243 | RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset) |
| 4244 | { |
| 4245 | return lhs = lhs - offset; |
| 4246 | } |
| 4247 | |
| 4248 | void Return() |
| 4249 | { |
| 4250 | Nucleus::createRetVoid(); |
| 4251 | // Place any unreachable instructions in an unreferenced block. |
| 4252 | Nucleus::setInsertBlock(Nucleus::createBasicBlock()); |
| 4253 | } |
| 4254 | |
| 4255 | void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB) |
| 4256 | { |
| 4257 | Nucleus::createCondBr(cmp.value, bodyBB, endBB); |
| 4258 | Nucleus::setInsertBlock(bodyBB); |
| 4259 | } |
| 4260 | |
| 4261 | RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4262 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4263 | 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] | 4264 | } |
| 4265 | |
| 4266 | RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */) |
| 4267 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4268 | 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] | 4269 | } |
| 4270 | |
| 4271 | void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment) |
| 4272 | { |
| 4273 | Nucleus::createMaskedStore(base.value, val.value, mask.value, alignment); |
| 4274 | } |
| 4275 | |
| 4276 | void MaskedStore(RValue<Pointer<Int4>> base, RValue<Int4> val, RValue<Int4> mask, unsigned int alignment) |
| 4277 | { |
| 4278 | Nucleus::createMaskedStore(base.value, val.value, mask.value, alignment); |
| 4279 | } |
| 4280 | |
| 4281 | void Fence(std::memory_order memoryOrder) |
| 4282 | { |
| 4283 | ASSERT_MSG(memoryOrder == std::memory_order_acquire || |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4284 | memoryOrder == std::memory_order_release || |
| 4285 | memoryOrder == std::memory_order_acq_rel || |
| 4286 | memoryOrder == std::memory_order_seq_cst, |
| 4287 | "Unsupported memoryOrder: %d", int(memoryOrder)); |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4288 | Nucleus::createFence(memoryOrder); |
| 4289 | } |
| 4290 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 4291 | Bool CToReactor<bool>::cast(bool v) |
| 4292 | { |
| 4293 | return type(v); |
| 4294 | } |
| 4295 | Byte CToReactor<uint8_t>::cast(uint8_t v) |
| 4296 | { |
| 4297 | return type(v); |
| 4298 | } |
| 4299 | SByte CToReactor<int8_t>::cast(int8_t v) |
| 4300 | { |
| 4301 | return type(v); |
| 4302 | } |
| 4303 | Short CToReactor<int16_t>::cast(int16_t v) |
| 4304 | { |
| 4305 | return type(v); |
| 4306 | } |
| 4307 | UShort CToReactor<uint16_t>::cast(uint16_t v) |
| 4308 | { |
| 4309 | return type(v); |
| 4310 | } |
| 4311 | Int CToReactor<int32_t>::cast(int32_t v) |
| 4312 | { |
| 4313 | return type(v); |
| 4314 | } |
| 4315 | UInt CToReactor<uint32_t>::cast(uint32_t v) |
| 4316 | { |
| 4317 | return type(v); |
| 4318 | } |
| 4319 | Float CToReactor<float>::cast(float v) |
| 4320 | { |
| 4321 | return type(v); |
| 4322 | } |
| 4323 | Float4 CToReactor<float[4]>::cast(float v[4]) |
| 4324 | { |
| 4325 | return type(v[0], v[1], v[2], v[3]); |
| 4326 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4327 | |
| 4328 | // TODO: Long has no constructor that takes a uint64_t |
| 4329 | // Long CToReactor<uint64_t>::cast(uint64_t v) { return type(v); } |
| 4330 | |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4331 | #ifdef ENABLE_RR_PRINT |
| 4332 | static std::string replaceAll(std::string str, const std::string &substr, const std::string &replacement) |
| 4333 | { |
| 4334 | size_t pos = 0; |
| 4335 | while((pos = str.find(substr, pos)) != std::string::npos) |
| 4336 | { |
| 4337 | str.replace(pos, substr.length(), replacement); |
| 4338 | pos += replacement.length(); |
| 4339 | } |
| 4340 | return str; |
| 4341 | } |
| 4342 | |
| 4343 | // extractAll returns a vector containing the extracted n scalar value of |
| 4344 | // the vector vec. |
| 4345 | // TODO: Move to Reactor.cpp (LLVMReactor can use this too) |
| 4346 | static std::vector<Value *> extractAll(Value *vec, int n) |
| 4347 | { |
| 4348 | Type *elemTy = Nucleus::getContainedType(Nucleus::getType(vec)); |
| 4349 | std::vector<Value *> elements; |
| 4350 | elements.reserve(n); |
| 4351 | for(int i = 0; i < n; i++) |
| 4352 | { |
| 4353 | auto el = Nucleus::createExtractElement(vec, elemTy, i); |
| 4354 | elements.push_back(el); |
| 4355 | } |
| 4356 | return elements; |
| 4357 | } |
| 4358 | |
| 4359 | // toInt returns all the integer values in vals extended to a printf-required storage value |
| 4360 | static std::vector<Value *> toInt(const std::vector<Value *> &vals, bool isSigned) |
| 4361 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4362 | auto storageTy = Nucleus::getPrintfStorageType(Int::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4363 | std::vector<Value *> elements; |
| 4364 | elements.reserve(vals.size()); |
| 4365 | for(auto v : vals) |
| 4366 | { |
| 4367 | if(isSigned) |
| 4368 | { |
| 4369 | elements.push_back(Nucleus::createSExt(v, storageTy)); |
| 4370 | } |
| 4371 | else |
| 4372 | { |
| 4373 | elements.push_back(Nucleus::createZExt(v, storageTy)); |
| 4374 | } |
| 4375 | } |
| 4376 | return elements; |
| 4377 | } |
| 4378 | |
| 4379 | // toFloat returns all the float values in vals extended to extended to a printf-required storage value |
| 4380 | static std::vector<Value *> toFloat(const std::vector<Value *> &vals) |
| 4381 | { |
Nicolas Capens | 519cf22 | 2020-05-08 15:27:19 -0400 | [diff] [blame] | 4382 | auto storageTy = Nucleus::getPrintfStorageType(Float::type()); |
Antonio Maiorano | 62427e0 | 2020-02-13 09:18:05 -0500 | [diff] [blame] | 4383 | std::vector<Value *> elements; |
| 4384 | elements.reserve(vals.size()); |
| 4385 | for(auto v : vals) |
| 4386 | { |
| 4387 | elements.push_back(Nucleus::createFPExt(v, storageTy)); |
| 4388 | } |
| 4389 | return elements; |
| 4390 | } |
| 4391 | |
| 4392 | std::vector<Value *> PrintValue::Ty<Bool>::val(const RValue<Bool> &v) |
| 4393 | { |
| 4394 | auto t = Nucleus::createConstantString("true"); |
| 4395 | auto f = Nucleus::createConstantString("false"); |
| 4396 | return { Nucleus::createSelect(v.value, t, f) }; |
| 4397 | } |
| 4398 | |
| 4399 | std::vector<Value *> PrintValue::Ty<Byte>::val(const RValue<Byte> &v) |
| 4400 | { |
| 4401 | return toInt({ v.value }, false); |
| 4402 | } |
| 4403 | |
| 4404 | std::vector<Value *> PrintValue::Ty<Byte4>::val(const RValue<Byte4> &v) |
| 4405 | { |
| 4406 | return toInt(extractAll(v.value, 4), false); |
| 4407 | } |
| 4408 | |
| 4409 | std::vector<Value *> PrintValue::Ty<Int>::val(const RValue<Int> &v) |
| 4410 | { |
| 4411 | return toInt({ v.value }, true); |
| 4412 | } |
| 4413 | |
| 4414 | std::vector<Value *> PrintValue::Ty<Int2>::val(const RValue<Int2> &v) |
| 4415 | { |
| 4416 | return toInt(extractAll(v.value, 2), true); |
| 4417 | } |
| 4418 | |
| 4419 | std::vector<Value *> PrintValue::Ty<Int4>::val(const RValue<Int4> &v) |
| 4420 | { |
| 4421 | return toInt(extractAll(v.value, 4), true); |
| 4422 | } |
| 4423 | |
| 4424 | std::vector<Value *> PrintValue::Ty<UInt>::val(const RValue<UInt> &v) |
| 4425 | { |
| 4426 | return toInt({ v.value }, false); |
| 4427 | } |
| 4428 | |
| 4429 | std::vector<Value *> PrintValue::Ty<UInt2>::val(const RValue<UInt2> &v) |
| 4430 | { |
| 4431 | return toInt(extractAll(v.value, 2), false); |
| 4432 | } |
| 4433 | |
| 4434 | std::vector<Value *> PrintValue::Ty<UInt4>::val(const RValue<UInt4> &v) |
| 4435 | { |
| 4436 | return toInt(extractAll(v.value, 4), false); |
| 4437 | } |
| 4438 | |
| 4439 | std::vector<Value *> PrintValue::Ty<Short>::val(const RValue<Short> &v) |
| 4440 | { |
| 4441 | return toInt({ v.value }, true); |
| 4442 | } |
| 4443 | |
| 4444 | std::vector<Value *> PrintValue::Ty<Short4>::val(const RValue<Short4> &v) |
| 4445 | { |
| 4446 | return toInt(extractAll(v.value, 4), true); |
| 4447 | } |
| 4448 | |
| 4449 | std::vector<Value *> PrintValue::Ty<UShort>::val(const RValue<UShort> &v) |
| 4450 | { |
| 4451 | return toInt({ v.value }, false); |
| 4452 | } |
| 4453 | |
| 4454 | std::vector<Value *> PrintValue::Ty<UShort4>::val(const RValue<UShort4> &v) |
| 4455 | { |
| 4456 | return toInt(extractAll(v.value, 4), false); |
| 4457 | } |
| 4458 | |
| 4459 | std::vector<Value *> PrintValue::Ty<Float>::val(const RValue<Float> &v) |
| 4460 | { |
| 4461 | return toFloat({ v.value }); |
| 4462 | } |
| 4463 | |
| 4464 | std::vector<Value *> PrintValue::Ty<Float4>::val(const RValue<Float4> &v) |
| 4465 | { |
| 4466 | return toFloat(extractAll(v.value, 4)); |
| 4467 | } |
| 4468 | |
| 4469 | std::vector<Value *> PrintValue::Ty<const char *>::val(const char *v) |
| 4470 | { |
| 4471 | return { Nucleus::createConstantString(v) }; |
| 4472 | } |
| 4473 | |
| 4474 | void Printv(const char *function, const char *file, int line, const char *fmt, std::initializer_list<PrintValue> args) |
| 4475 | { |
| 4476 | // Build the printf format message string. |
| 4477 | std::string str; |
| 4478 | if(file != nullptr) { str += (line > 0) ? "%s:%d " : "%s "; } |
| 4479 | if(function != nullptr) { str += "%s "; } |
| 4480 | str += fmt; |
| 4481 | |
| 4482 | // Perform substitution on all '{n}' bracketed indices in the format |
| 4483 | // message. |
| 4484 | int i = 0; |
| 4485 | for(const PrintValue &arg : args) |
| 4486 | { |
| 4487 | str = replaceAll(str, "{" + std::to_string(i++) + "}", arg.format); |
| 4488 | } |
| 4489 | |
| 4490 | std::vector<Value *> vals; |
| 4491 | vals.reserve(8); |
| 4492 | |
| 4493 | // The format message is always the first argument. |
| 4494 | vals.push_back(Nucleus::createConstantString(str)); |
| 4495 | |
| 4496 | // Add optional file, line and function info if provided. |
| 4497 | if(file != nullptr) |
| 4498 | { |
| 4499 | vals.push_back(Nucleus::createConstantString(file)); |
| 4500 | if(line > 0) |
| 4501 | { |
| 4502 | vals.push_back(Nucleus::createConstantInt(line)); |
| 4503 | } |
| 4504 | } |
| 4505 | if(function != nullptr) |
| 4506 | { |
| 4507 | vals.push_back(Nucleus::createConstantString(function)); |
| 4508 | } |
| 4509 | |
| 4510 | // Add all format arguments. |
| 4511 | for(const PrintValue &arg : args) |
| 4512 | { |
| 4513 | for(auto val : arg.values) |
| 4514 | { |
| 4515 | vals.push_back(val); |
| 4516 | } |
| 4517 | } |
| 4518 | |
| 4519 | // This call is implemented by each backend |
| 4520 | VPrintf(vals); |
| 4521 | } |
| 4522 | #endif // ENABLE_RR_PRINT |
| 4523 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 4524 | } // namespace rr |