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