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