| OLD | NEW |
| 1 //===- subzero/unittest/AssemblerX8664/XmmArith.cpp -----------------------===// | 1 //===- subzero/unittest/AssemblerX8664/XmmArith.cpp -----------------------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 #include "AssemblerX8664/TestUtil.h" | 9 #include "AssemblerX8664/TestUtil.h" |
| 10 | 10 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 #undef TestPArith | 388 #undef TestPArith |
| 389 #undef TestPArithSize | 389 #undef TestPArithSize |
| 390 #undef TestPAndnXmmAddr | 390 #undef TestPAndnXmmAddr |
| 391 #undef TestPAndnXmmXmm | 391 #undef TestPAndnXmmXmm |
| 392 #undef TestPArithXmmImm | 392 #undef TestPArithXmmImm |
| 393 #undef TestPArithXmmAddr | 393 #undef TestPArithXmmAddr |
| 394 #undef TestPArithXmmXmm | 394 #undef TestPArithXmmXmm |
| 395 } | 395 } |
| 396 | 396 |
| 397 TEST_F(AssemblerX8664Test, ArithPS) { | 397 TEST_F(AssemblerX8664Test, ArithPS) { |
| 398 #define TestArithPSXmmXmm(Dst, Value0, Src, Value1, Inst, Op, Type) \ | 398 #define TestArithPSXmmXmm(FloatSize, Dst, Value0, Src, Value1, Inst, Op, Type) \ |
| 399 do { \ | 399 do { \ |
| 400 static constexpr char TestString[] = \ | 400 static constexpr char TestString[] = \ |
| 401 "(" #Dst ", " #Value0 ", " #Src ", " #Value1 ", " #Inst ", " #Op \ | 401 "(" #Dst ", " #Value0 ", " #Src ", " #Value1 ", " #Inst ", " #Op \ |
| 402 ", " #Type ")"; \ | 402 ", " #Type ")"; \ |
| 403 const uint32_t T0 = allocateDqword(); \ | 403 const uint32_t T0 = allocateDqword(); \ |
| 404 const Dqword V0 Value0; \ | 404 const Dqword V0 Value0; \ |
| 405 const uint32_t T1 = allocateDqword(); \ | 405 const uint32_t T1 = allocateDqword(); \ |
| 406 const Dqword V1 Value1; \ | 406 const Dqword V1 Value1; \ |
| 407 \ | 407 \ |
| 408 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ | 408 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 AssembledTest test = assemble(); \ | 459 AssembledTest test = assemble(); \ |
| 460 test.setDqwordTo(T0, V0); \ | 460 test.setDqwordTo(T0, V0); \ |
| 461 test.setDqwordTo(T1, V1); \ | 461 test.setDqwordTo(T1, V1); \ |
| 462 test.run(); \ | 462 test.run(); \ |
| 463 \ | 463 \ |
| 464 ASSERT_EQ(packedAs<Type>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ | 464 ASSERT_EQ(packedAs<Type>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ |
| 465 \ | 465 \ |
| 466 reset(); \ | 466 reset(); \ |
| 467 } while (0) | 467 } while (0) |
| 468 | 468 |
| 469 #define TestMinMaxPS(Dst, Value0, Src, Value1, Inst, Type) \ | 469 #define TestMinMaxPS(FloatSize, Dst, Value0, Src, Value1, Inst, Type) \ |
| 470 do { \ | 470 do { \ |
| 471 static constexpr char TestString[] = \ | 471 static constexpr char TestString[] = \ |
| 472 "(" #Dst ", " #Value0 ", " #Src ", " #Value1 ", " #Inst ", " #Type \ | 472 "(" #Dst ", " #Value0 ", " #Src ", " #Value1 ", " #Inst ", " #Type \ |
| 473 ")"; \ | 473 ")"; \ |
| 474 const uint32_t T0 = allocateDqword(); \ | 474 const uint32_t T0 = allocateDqword(); \ |
| 475 const Dqword V0 Value0; \ | 475 const Dqword V0 Value0; \ |
| 476 const uint32_t T1 = allocateDqword(); \ | 476 const uint32_t T1 = allocateDqword(); \ |
| 477 const Dqword V1 Value1; \ | 477 const Dqword V1 Value1; \ |
| 478 \ | 478 \ |
| 479 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ | 479 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ |
| 480 __ movups(Encoded_Xmm_##Src(), dwordAddress(T1)); \ | 480 __ movups(Encoded_Xmm_##Src(), dwordAddress(T1)); \ |
| 481 __ Inst(Encoded_Xmm_##Dst(), Encoded_Xmm_##Src()); \ | 481 __ Inst(IceType_f##FloatSize, Encoded_Xmm_##Dst(), Encoded_Xmm_##Src()); \ |
| 482 \ | 482 \ |
| 483 AssembledTest test = assemble(); \ | 483 AssembledTest test = assemble(); \ |
| 484 test.setDqwordTo(T0, V0); \ | 484 test.setDqwordTo(T0, V0); \ |
| 485 test.setDqwordTo(T1, V1); \ | 485 test.setDqwordTo(T1, V1); \ |
| 486 test.run(); \ | 486 test.run(); \ |
| 487 \ | 487 \ |
| 488 ASSERT_EQ(packedAs<Type>(V0).Inst(V1), test.Dst<Dqword>()) << TestString; \ | 488 ASSERT_EQ(packedAs<Type>(V0).Inst(V1), test.Dst<Dqword>()) << TestString; \ |
| 489 \ | 489 \ |
| 490 reset(); \ | 490 reset(); \ |
| 491 } while (0) | 491 } while (0) |
| 492 | 492 |
| 493 #define TestArithPSXmmAddr(Dst, Value0, Value1, Inst, Op, Type) \ | 493 #define TestArithPSXmmAddr(FloatSize, Dst, Value0, Value1, Inst, Op, Type) \ |
| 494 do { \ | 494 do { \ |
| 495 static constexpr char TestString[] = \ | 495 static constexpr char TestString[] = \ |
| 496 "(" #Dst ", " #Value0 ", Addr, " #Value1 ", " #Inst ", " #Op \ | 496 "(" #Dst ", " #Value0 ", Addr, " #Value1 ", " #Inst ", " #Op \ |
| 497 ", " #Type ")"; \ | 497 ", " #Type ")"; \ |
| 498 const uint32_t T0 = allocateDqword(); \ | 498 const uint32_t T0 = allocateDqword(); \ |
| 499 const Dqword V0 Value0; \ | 499 const Dqword V0 Value0; \ |
| 500 const uint32_t T1 = allocateDqword(); \ | 500 const uint32_t T1 = allocateDqword(); \ |
| 501 const Dqword V1 Value1; \ | 501 const Dqword V1 Value1; \ |
| 502 \ | 502 \ |
| 503 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ | 503 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ |
| 504 __ Inst(IceType_f32, Encoded_Xmm_##Dst(), dwordAddress(T1)); \ | 504 __ Inst(IceType_f##FloatSize, Encoded_Xmm_##Dst(), dwordAddress(T1)); \ |
| 505 \ | 505 \ |
| 506 AssembledTest test = assemble(); \ | 506 AssembledTest test = assemble(); \ |
| 507 test.setDqwordTo(T0, V0); \ | 507 test.setDqwordTo(T0, V0); \ |
| 508 test.setDqwordTo(T1, V1); \ | 508 test.setDqwordTo(T1, V1); \ |
| 509 test.run(); \ | 509 test.run(); \ |
| 510 \ | 510 \ |
| 511 ASSERT_EQ(packedAs<Type>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ | 511 ASSERT_EQ(packedAs<Type>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ |
| 512 \ | 512 \ |
| 513 reset(); \ | 513 reset(); \ |
| 514 } while (0) | 514 } while (0) |
| 515 | 515 |
| 516 #define TestArithPS(Dst, Src) \ | 516 #define TestArithPS(Dst, Src) \ |
| 517 do { \ | 517 do { \ |
| 518 TestArithPSXmmXmm(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 518 TestArithPSXmmXmm(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 519 (0.55, 0.43, 0.23, 1.21), addps, +, float); \ | 519 (0.55, 0.43, 0.23, 1.21), addps, +, float); \ |
| 520 TestArithPSXmmAddr(Dst, (1.0, 100.0, -1000.0, 20.0), \ | 520 TestArithPSXmmAddr(32, Dst, (1.0, 100.0, -1000.0, 20.0), \ |
| 521 (0.55, 0.43, 0.23, 1.21), addps, +, float); \ | 521 (0.55, 0.43, 0.23, 1.21), addps, +, float); \ |
| 522 TestArithPSXmmXmm(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 522 TestArithPSXmmXmm(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 523 (0.55, 0.43, 0.23, 1.21), subps, -, float); \ | 523 (0.55, 0.43, 0.23, 1.21), subps, -, float); \ |
| 524 TestArithPSXmmAddr(Dst, (1.0, 100.0, -1000.0, 20.0), \ | 524 TestArithPSXmmAddr(32, Dst, (1.0, 100.0, -1000.0, 20.0), \ |
| 525 (0.55, 0.43, 0.23, 1.21), subps, -, float); \ | 525 (0.55, 0.43, 0.23, 1.21), subps, -, float); \ |
| 526 TestArithPSXmmXmm(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 526 TestArithPSXmmXmm(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 527 (0.55, 0.43, 0.23, 1.21), mulps, *, float); \ | 527 (0.55, 0.43, 0.23, 1.21), mulps, *, float); \ |
| 528 TestArithPSXmmAddr(Dst, (1.0, 100.0, -1000.0, 20.0), \ | 528 TestArithPSXmmAddr(32, Dst, (1.0, 100.0, -1000.0, 20.0), \ |
| 529 (0.55, 0.43, 0.23, 1.21), mulps, *, float); \ | 529 (0.55, 0.43, 0.23, 1.21), mulps, *, float); \ |
| 530 TestArithPSXmmXmm(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 530 TestArithPSXmmXmm(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 531 (0.55, 0.43, 0.23, 1.21), divps, /, float); \ | 531 (0.55, 0.43, 0.23, 1.21), divps, /, float); \ |
| 532 TestArithPSXmmAddr(Dst, (1.0, 100.0, -1000.0, 20.0), \ | 532 TestArithPSXmmAddr(32, Dst, (1.0, 100.0, -1000.0, 20.0), \ |
| 533 (0.55, 0.43, 0.23, 1.21), divps, /, float); \ | 533 (0.55, 0.43, 0.23, 1.21), divps, /, float); \ |
| 534 TestArithPSXmmXmmUntyped(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 534 TestArithPSXmmXmm(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 535 (0.55, 0.43, 0.23, 1.21), andps, &, float); \ | 535 (0.55, 0.43, 0.23, 1.21), andps, &, float); \ |
| 536 TestArithPSXmmAddrUntyped(Dst, (1.0, 100.0, -1000.0, 20.0), \ | 536 TestArithPSXmmAddr(32, Dst, (1.0, 100.0, -1000.0, 20.0), \ |
| 537 (0.55, 0.43, 0.23, 1.21), andps, &, float); \ | 537 (0.55, 0.43, 0.23, 1.21), andps, &, float); \ |
| 538 TestArithPSXmmXmmUntyped(Dst, (1.0, -1000.0), Src, (0.55, 1.21), andpd, &, \ | 538 TestArithPSXmmXmm(64, Dst, (1.0, -1000.0), Src, (0.55, 1.21), andps, &, \ |
| 539 double); \ | 539 double); \ |
| 540 TestArithPSXmmAddrUntyped(Dst, (1.0, -1000.0), (0.55, 1.21), andpd, &, \ | 540 TestArithPSXmmAddr(64, Dst, (1.0, -1000.0), (0.55, 1.21), andps, &, \ |
| 541 double); \ | 541 double); \ |
| 542 TestArithPSXmmXmmUntyped(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 542 TestArithPSXmmXmm(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 543 (0.55, 0.43, 0.23, 1.21), orps, |, float); \ | 543 (0.55, 0.43, 0.23, 1.21), orps, |, float); \ |
| 544 TestArithPSXmmXmmUntyped(Dst, (1.0, -1000.0), Src, (0.55, 1.21), orpd, |, \ | 544 TestArithPSXmmXmm(64, Dst, (1.0, -1000.0), Src, (0.55, 1.21), orps, |, \ |
| 545 double); \ | 545 double); \ |
| 546 TestMinMaxPS(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 546 TestMinMaxPS(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 547 (0.55, 0.43, 0.23, 1.21), minps, float); \ | 547 (0.55, 0.43, 0.23, 1.21), minps, float); \ |
| 548 TestMinMaxPS(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 548 TestMinMaxPS(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 549 (0.55, 0.43, 0.23, 1.21), maxps, float); \ | 549 (0.55, 0.43, 0.23, 1.21), maxps, float); \ |
| 550 TestMinMaxPS(Dst, (1.0, -1000.0), Src, (0.55, 1.21), minpd, double); \ | 550 TestMinMaxPS(64, Dst, (1.0, -1000.0), Src, (0.55, 1.21), minps, double); \ |
| 551 TestMinMaxPS(Dst, (1.0, -1000.0), Src, (0.55, 1.21), maxpd, double); \ | 551 TestMinMaxPS(64, Dst, (1.0, -1000.0), Src, (0.55, 1.21), maxps, double); \ |
| 552 TestArithPSXmmXmmUntyped(Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ | 552 TestArithPSXmmXmm(32, Dst, (1.0, 100.0, -1000.0, 20.0), Src, \ |
| 553 (0.55, 0.43, 0.23, 1.21), xorps, ^, float); \ | 553 (0.55, 0.43, 0.23, 1.21), xorps, ^, float); \ |
| 554 TestArithPSXmmAddrUntyped(Dst, (1.0, 100.0, -1000.0, 20.0), \ | 554 TestArithPSXmmAddr(32, Dst, (1.0, 100.0, -1000.0, 20.0), \ |
| 555 (0.55, 0.43, 0.23, 1.21), xorps, ^, float); \ | 555 (0.55, 0.43, 0.23, 1.21), xorps, ^, float); \ |
| 556 TestArithPSXmmXmmUntyped(Dst, (1.0, -1000.0), Src, (0.55, 1.21), xorpd, ^, \ | 556 TestArithPSXmmXmm(64, Dst, (1.0, -1000.0), Src, (0.55, 1.21), xorps, ^, \ |
| 557 double); \ | 557 double); \ |
| 558 TestArithPSXmmAddrUntyped(Dst, (1.0, -1000.0), (0.55, 1.21), xorpd, ^, \ | 558 TestArithPSXmmAddr(64, Dst, (1.0, -1000.0), (0.55, 1.21), xorps, ^, \ |
| 559 double); \ | 559 double); \ |
| 560 } while (0) | 560 } while (0) |
| 561 | 561 |
| 562 TestArithPS(xmm0, xmm1); | 562 TestArithPS(xmm0, xmm1); |
| 563 TestArithPS(xmm1, xmm2); | 563 TestArithPS(xmm1, xmm2); |
| 564 TestArithPS(xmm2, xmm3); | 564 TestArithPS(xmm2, xmm3); |
| 565 TestArithPS(xmm3, xmm4); | 565 TestArithPS(xmm3, xmm4); |
| 566 TestArithPS(xmm4, xmm5); | 566 TestArithPS(xmm4, xmm5); |
| 567 TestArithPS(xmm5, xmm6); | 567 TestArithPS(xmm5, xmm6); |
| 568 TestArithPS(xmm6, xmm7); | 568 TestArithPS(xmm6, xmm7); |
| 569 TestArithPS(xmm7, xmm8); | 569 TestArithPS(xmm7, xmm8); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 TestBlending(xmm13, xmm14); | 683 TestBlending(xmm13, xmm14); |
| 684 TestBlending(xmm14, xmm15); | 684 TestBlending(xmm14, xmm15); |
| 685 TestBlending(xmm15, xmm1); | 685 TestBlending(xmm15, xmm1); |
| 686 | 686 |
| 687 #undef TestBlending | 687 #undef TestBlending |
| 688 #undef TestBlendingXmmAddr | 688 #undef TestBlendingXmmAddr |
| 689 #undef TestBlendingXmmXmm | 689 #undef TestBlendingXmmXmm |
| 690 } | 690 } |
| 691 | 691 |
| 692 TEST_F(AssemblerX8664Test, Cmpps) { | 692 TEST_F(AssemblerX8664Test, Cmpps) { |
| 693 #define TestCmppsXmmXmm(Dst, Src, C, Op) \ | 693 #define TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, C, Op, Type) \ |
| 694 do { \ | 694 do { \ |
| 695 static constexpr char TestString[] = \ | 695 static constexpr char TestString[] = \ |
| 696 "(" #Src ", " #Dst ", " #C ", " #Op ")"; \ | 696 "(" #Src ", " #Dst ", " #C ", " #Op ")"; \ |
| 697 const uint32_t T0 = allocateDqword(); \ | 697 const uint32_t T0 = allocateDqword(); \ |
| 698 const Dqword V0(-1.0, 1.0, 3.14, 1024.5); \ | 698 const Dqword V0 Value0; \ |
| 699 const uint32_t T1 = allocateDqword(); \ | 699 const uint32_t T1 = allocateDqword(); \ |
| 700 const Dqword V1(-1.0, 1.0, 3.14, 1024.5); \ | 700 const Dqword V1 Value1; \ |
| 701 \ | 701 \ |
| 702 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ | 702 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ |
| 703 __ movups(Encoded_Xmm_##Src(), dwordAddress(T1)); \ | 703 __ movups(Encoded_Xmm_##Src(), dwordAddress(T1)); \ |
| 704 __ cmpps(Encoded_Xmm_##Dst(), Encoded_Xmm_##Src(), Cond::Cmpps_##C); \ | 704 __ cmpps(IceType_f##FloatSize, Encoded_Xmm_##Dst(), Encoded_Xmm_##Src(), \ |
| 705 Cond::Cmpps_##C); \ |
| 705 \ | 706 \ |
| 706 AssembledTest test = assemble(); \ | 707 AssembledTest test = assemble(); \ |
| 707 test.setDqwordTo(T0, V0); \ | 708 test.setDqwordTo(T0, V0); \ |
| 708 test.setDqwordTo(T1, V1); \ | 709 test.setDqwordTo(T1, V1); \ |
| 709 test.run(); \ | 710 test.run(); \ |
| 710 \ | 711 \ |
| 711 ASSERT_EQ(packedAs<float>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ | 712 ASSERT_EQ(packedAs<Type>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ |
| 712 ; \ | 713 ; \ |
| 713 reset(); \ | 714 reset(); \ |
| 714 } while (0) | 715 } while (0) |
| 715 | 716 |
| 716 #define TestCmppsXmmAddr(Dst, C, Op) \ | 717 #define TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, C, Op, Type) \ |
| 717 do { \ | 718 do { \ |
| 718 static constexpr char TestString[] = "(" #Dst ", Addr, " #C ", " #Op ")"; \ | 719 static constexpr char TestString[] = "(" #Dst ", Addr, " #C ", " #Op ")"; \ |
| 719 const uint32_t T0 = allocateDqword(); \ | 720 const uint32_t T0 = allocateDqword(); \ |
| 720 const Dqword V0(-1.0, 1.0, 3.14, 1024.5); \ | 721 const Dqword V0 Value0; \ |
| 721 const uint32_t T1 = allocateDqword(); \ | 722 const uint32_t T1 = allocateDqword(); \ |
| 722 const Dqword V1(-1.0, 1.0, 3.14, 1024.5); \ | 723 const Dqword V1 Value1; \ |
| 723 \ | 724 \ |
| 724 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ | 725 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ |
| 725 __ cmpps(Encoded_Xmm_##Dst(), dwordAddress(T1), Cond::Cmpps_##C); \ | 726 __ cmpps(IceType_f##FloatSize, Encoded_Xmm_##Dst(), dwordAddress(T1), \ |
| 727 Cond::Cmpps_##C); \ |
| 726 \ | 728 \ |
| 727 AssembledTest test = assemble(); \ | 729 AssembledTest test = assemble(); \ |
| 728 test.setDqwordTo(T0, V0); \ | 730 test.setDqwordTo(T0, V0); \ |
| 729 test.setDqwordTo(T1, V1); \ | 731 test.setDqwordTo(T1, V1); \ |
| 730 test.run(); \ | 732 test.run(); \ |
| 731 \ | 733 \ |
| 732 ASSERT_EQ(packedAs<float>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ | 734 ASSERT_EQ(packedAs<Type>(V0) Op V1, test.Dst<Dqword>()) << TestString; \ |
| 733 ; \ | 735 ; \ |
| 734 reset(); \ | 736 reset(); \ |
| 735 } while (0) | 737 } while (0) |
| 736 | 738 |
| 737 #define TestCmppsOrdUnordXmmXmm(Dst, Src, C) \ | 739 #define TestCmppsOrdUnordXmmXmm(FloatSize, Dst, Value0, Src, Value1, C, Type) \ |
| 738 do { \ | 740 do { \ |
| 739 static constexpr char TestString[] = "(" #Src ", " #Dst ", " #C ")"; \ | 741 static constexpr char TestString[] = "(" #Src ", " #Dst ", " #C ")"; \ |
| 740 const uint32_t T0 = allocateDqword(); \ | 742 const uint32_t T0 = allocateDqword(); \ |
| 741 const Dqword V0(1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \ | 743 const Dqword V0(1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \ |
| 742 std::numeric_limits<float>::quiet_NaN()); \ | 744 std::numeric_limits<float>::quiet_NaN()); \ |
| 743 const uint32_t T1 = allocateDqword(); \ | 745 const uint32_t T1 = allocateDqword(); \ |
| 744 const Dqword V1(1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \ | 746 const Dqword V1(1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \ |
| 745 std::numeric_limits<float>::quiet_NaN()); \ | 747 std::numeric_limits<float>::quiet_NaN()); \ |
| 746 \ | 748 \ |
| 747 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ | 749 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ |
| 748 __ movups(Encoded_Xmm_##Src(), dwordAddress(T1)); \ | 750 __ movups(Encoded_Xmm_##Src(), dwordAddress(T1)); \ |
| 749 __ cmpps(Encoded_Xmm_##Dst(), Encoded_Xmm_##Src(), Cond::Cmpps_##C); \ | 751 __ cmpps(IceType_f##FloatSize, Encoded_Xmm_##Dst(), Encoded_Xmm_##Src(), \ |
| 752 Cond::Cmpps_##C); \ |
| 750 \ | 753 \ |
| 751 AssembledTest test = assemble(); \ | 754 AssembledTest test = assemble(); \ |
| 752 test.setDqwordTo(T0, V0); \ | 755 test.setDqwordTo(T0, V0); \ |
| 753 test.setDqwordTo(T1, V1); \ | 756 test.setDqwordTo(T1, V1); \ |
| 754 test.run(); \ | 757 test.run(); \ |
| 755 \ | 758 \ |
| 756 ASSERT_EQ(packedAs<float>(V0).C(V1), test.Dst<Dqword>()) << TestString; \ | 759 ASSERT_EQ(packedAs<Type>(V0).C(V1), test.Dst<Dqword>()) << TestString; \ |
| 757 ; \ | 760 ; \ |
| 758 reset(); \ | 761 reset(); \ |
| 759 } while (0) | 762 } while (0) |
| 760 | 763 |
| 761 #define TestCmppsOrdUnordXmmAddr(Dst, C) \ | 764 #define TestCmppsOrdUnordXmmAddr(FloatSize, Dst, Value0, Value1, C, Type) \ |
| 762 do { \ | 765 do { \ |
| 763 static constexpr char TestString[] = "(" #Dst ", " #C ")"; \ | 766 static constexpr char TestString[] = "(" #Dst ", " #C ")"; \ |
| 764 const uint32_t T0 = allocateDqword(); \ | 767 const uint32_t T0 = allocateDqword(); \ |
| 765 const Dqword V0(1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \ | 768 const Dqword V0(1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \ |
| 766 std::numeric_limits<float>::quiet_NaN()); \ | 769 std::numeric_limits<float>::quiet_NaN()); \ |
| 767 const uint32_t T1 = allocateDqword(); \ | 770 const uint32_t T1 = allocateDqword(); \ |
| 768 const Dqword V1(1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \ | 771 const Dqword V1(1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \ |
| 769 std::numeric_limits<float>::quiet_NaN()); \ | 772 std::numeric_limits<float>::quiet_NaN()); \ |
| 770 \ | 773 \ |
| 771 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ | 774 __ movups(Encoded_Xmm_##Dst(), dwordAddress(T0)); \ |
| 772 __ cmpps(Encoded_Xmm_##Dst(), dwordAddress(T1), Cond::Cmpps_##C); \ | 775 __ cmpps(IceType_f##FloatSize, Encoded_Xmm_##Dst(), dwordAddress(T1), \ |
| 776 Cond::Cmpps_##C); \ |
| 773 \ | 777 \ |
| 774 AssembledTest test = assemble(); \ | 778 AssembledTest test = assemble(); \ |
| 775 test.setDqwordTo(T0, V0); \ | 779 test.setDqwordTo(T0, V0); \ |
| 776 test.setDqwordTo(T1, V1); \ | 780 test.setDqwordTo(T1, V1); \ |
| 777 test.run(); \ | 781 test.run(); \ |
| 778 \ | 782 \ |
| 779 ASSERT_EQ(packedAs<float>(V0).C(V1), test.Dst<Dqword>()) << TestString; \ | 783 ASSERT_EQ(packedAs<Type>(V0).C(V1), test.Dst<Dqword>()) << TestString; \ |
| 780 ; \ | 784 ; \ |
| 781 reset(); \ | 785 reset(); \ |
| 782 } while (0) | 786 } while (0) |
| 783 | 787 |
| 784 #define TestCmpps(Dst, Src) \ | 788 #define TestCmpps(FloatSize, Dst, Value0, Src, Value1, Type) \ |
| 785 do { \ | 789 do { \ |
| 786 TestCmppsXmmXmm(Dst, Src, eq, == ); \ | 790 TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \ |
| 787 TestCmppsXmmAddr(Dst, eq, == ); \ | 791 TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \ |
| 788 TestCmppsXmmXmm(Dst, Src, eq, == ); \ | 792 TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \ |
| 789 TestCmppsXmmAddr(Dst, eq, == ); \ | 793 TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \ |
| 790 TestCmppsXmmXmm(Dst, Src, eq, == ); \ | 794 TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \ |
| 791 TestCmppsXmmAddr(Dst, eq, == ); \ | 795 TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \ |
| 792 TestCmppsOrdUnordXmmXmm(Dst, Src, unord); \ | 796 TestCmppsOrdUnordXmmXmm(FloatSize, Dst, Value0, Src, Value1, unord, Type); \ |
| 793 TestCmppsOrdUnordXmmAddr(Dst, unord); \ | 797 TestCmppsOrdUnordXmmAddr(FloatSize, Dst, Value0, Value1, unord, Type); \ |
| 794 TestCmppsXmmXmm(Dst, Src, eq, == ); \ | 798 TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \ |
| 795 TestCmppsXmmAddr(Dst, eq, == ); \ | 799 TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \ |
| 796 TestCmppsXmmXmm(Dst, Src, eq, == ); \ | 800 TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \ |
| 797 TestCmppsXmmAddr(Dst, eq, == ); \ | 801 TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \ |
| 798 TestCmppsXmmXmm(Dst, Src, eq, == ); \ | 802 TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \ |
| 799 TestCmppsXmmAddr(Dst, eq, == ); \ | 803 TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \ |
| 800 TestCmppsOrdUnordXmmXmm(Dst, Src, unord); \ | 804 if (FloatSize == 32) { \ |
| 801 TestCmppsOrdUnordXmmAddr(Dst, unord); \ | 805 TestCmppsOrdUnordXmmXmm( \ |
| 806 32, Dst, (1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \ |
| 807 std::numeric_limits<float>::quiet_NaN()), \ |
| 808 Src, (1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \ |
| 809 std::numeric_limits<float>::quiet_NaN()), \ |
| 810 unord, Type); \ |
| 811 TestCmppsOrdUnordXmmAddr( \ |
| 812 32, Dst, (1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \ |
| 813 std::numeric_limits<float>::quiet_NaN()), \ |
| 814 (1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \ |
| 815 std::numeric_limits<float>::quiet_NaN()), \ |
| 816 unord, Type); \ |
| 817 } else { \ |
| 818 TestCmppsOrdUnordXmmXmm(64, Dst, \ |
| 819 (1.0, std::numeric_limits<double>::quiet_NaN()), \ |
| 820 Src, (std::numeric_limits<double>::quiet_NaN(), \ |
| 821 std::numeric_limits<double>::quiet_NaN()), \ |
| 822 unord, Type); \ |
| 823 TestCmppsOrdUnordXmmXmm(64, Dst, (1.0, 1.0), Src, \ |
| 824 (1.0, std::numeric_limits<double>::quiet_NaN()), \ |
| 825 unord, Type); \ |
| 826 TestCmppsOrdUnordXmmAddr( \ |
| 827 64, Dst, (1.0, std::numeric_limits<double>::quiet_NaN()), \ |
| 828 (std::numeric_limits<double>::quiet_NaN(), \ |
| 829 std::numeric_limits<double>::quiet_NaN()), \ |
| 830 unord, Type); \ |
| 831 TestCmppsOrdUnordXmmAddr( \ |
| 832 64, Dst, (1.0, 1.0), \ |
| 833 (1.0, std::numeric_limits<double>::quiet_NaN()), unord, Type); \ |
| 834 } \ |
| 802 } while (0) | 835 } while (0) |
| 803 | 836 |
| 804 TestCmpps(xmm0, xmm1); | 837 #define TestCmppsSize(FloatSize, Value0, Value1, Type) \ |
| 805 TestCmpps(xmm1, xmm2); | 838 do { \ |
| 806 TestCmpps(xmm2, xmm3); | 839 TestCmpps(FloatSize, xmm0, Value0, xmm1, Value1, Type); \ |
| 807 TestCmpps(xmm3, xmm4); | 840 TestCmpps(FloatSize, xmm1, Value0, xmm2, Value1, Type); \ |
| 808 TestCmpps(xmm4, xmm5); | 841 TestCmpps(FloatSize, xmm2, Value0, xmm3, Value1, Type); \ |
| 809 TestCmpps(xmm5, xmm6); | 842 TestCmpps(FloatSize, xmm3, Value0, xmm4, Value1, Type); \ |
| 810 TestCmpps(xmm6, xmm7); | 843 TestCmpps(FloatSize, xmm4, Value0, xmm5, Value1, Type); \ |
| 811 TestCmpps(xmm7, xmm8); | 844 TestCmpps(FloatSize, xmm5, Value0, xmm6, Value1, Type); \ |
| 812 TestCmpps(xmm8, xmm9); | 845 TestCmpps(FloatSize, xmm6, Value0, xmm7, Value1, Type); \ |
| 813 TestCmpps(xmm9, xmm10); | 846 TestCmpps(FloatSize, xmm7, Value0, xmm8, Value1, Type); \ |
| 814 TestCmpps(xmm10, xmm11); | 847 TestCmpps(FloatSize, xmm8, Value0, xmm9, Value1, Type); \ |
| 815 TestCmpps(xmm11, xmm12); | 848 TestCmpps(FloatSize, xmm9, Value0, xmm10, Value1, Type); \ |
| 816 TestCmpps(xmm12, xmm13); | 849 TestCmpps(FloatSize, xmm10, Value0, xmm11, Value1, Type); \ |
| 817 TestCmpps(xmm13, xmm14); | 850 TestCmpps(FloatSize, xmm11, Value0, xmm12, Value1, Type); \ |
| 818 TestCmpps(xmm14, xmm15); | 851 TestCmpps(FloatSize, xmm12, Value0, xmm13, Value1, Type); \ |
| 819 TestCmpps(xmm15, xmm0); | 852 TestCmpps(FloatSize, xmm13, Value0, xmm14, Value1, Type); \ |
| 853 TestCmpps(FloatSize, xmm14, Value0, xmm15, Value1, Type); \ |
| 854 TestCmpps(FloatSize, xmm15, Value0, xmm0, Value1, Type); \ |
| 855 } while (0) |
| 856 |
| 857 TestCmppsSize(32, (-1.0, 1.0, 3.14, 1024.5), (-1.0, 1.0, 3.14, 1024.5), |
| 858 float); |
| 859 TestCmppsSize(64, (1.0, -1000.0), (1.0, -1000.0), double); |
| 820 | 860 |
| 821 #undef TestCmpps | 861 #undef TestCmpps |
| 822 #undef TestCmppsOrdUnordXmmAddr | 862 #undef TestCmppsOrdUnordXmmAddr |
| 823 #undef TestCmppsOrdUnordXmmXmm | 863 #undef TestCmppsOrdUnordXmmXmm |
| 824 #undef TestCmppsXmmAddr | 864 #undef TestCmppsXmmAddr |
| 825 #undef TestCmppsXmmXmm | 865 #undef TestCmppsXmmXmm |
| 826 } | 866 } |
| 827 | 867 |
| 828 TEST_F(AssemblerX8664Test, Sqrtps_Rsqrtps_Reciprocalps_Sqrtpd) { | 868 TEST_F(AssemblerX8664Test, Sqrtps_Rsqrtps_Reciprocalps_Sqrtpd) { |
| 829 #define TestImplSingle(Dst, Inst, Expect) \ | 869 #define TestImplSingle(Dst, Inst, Expect) \ |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 TestImpl(xmm14, r1, 101); | 1955 TestImpl(xmm14, r1, 101); |
| 1916 TestImpl(xmm15, r2, 166); | 1956 TestImpl(xmm15, r2, 166); |
| 1917 | 1957 |
| 1918 #undef TestImpl | 1958 #undef TestImpl |
| 1919 } | 1959 } |
| 1920 | 1960 |
| 1921 } // end of anonymous namespace | 1961 } // end of anonymous namespace |
| 1922 } // end of namespace Test | 1962 } // end of namespace Test |
| 1923 } // end of namespace X8664 | 1963 } // end of namespace X8664 |
| 1924 } // end of namespace Ice | 1964 } // end of namespace Ice |
| OLD | NEW |