OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 t.result = 0; | 672 t.result = 0; |
673 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | 673 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
674 USE(dummy); | 674 USE(dummy); |
675 CHECK_EQ(1.5e14, t.a); | 675 CHECK_EQ(1.5e14, t.a); |
676 CHECK_EQ(2.75e11, t.b); | 676 CHECK_EQ(2.75e11, t.b); |
677 CHECK_EQ(1, t.result); | 677 CHECK_EQ(1, t.result); |
678 } | 678 } |
679 | 679 |
680 | 680 |
681 TEST(MIPS8) { | 681 TEST(MIPS8) { |
682 // Test ROTR and ROTRV instructions. | 682 if (kArchVariant == kMips64r2) { |
683 CcTest::InitializeVM(); | 683 // Test ROTR and ROTRV instructions. |
684 Isolate* isolate = CcTest::i_isolate(); | 684 CcTest::InitializeVM(); |
685 HandleScope scope(isolate); | 685 Isolate* isolate = CcTest::i_isolate(); |
| 686 HandleScope scope(isolate); |
686 | 687 |
687 typedef struct { | 688 typedef struct { |
688 int32_t input; | 689 int32_t input; |
689 int32_t result_rotr_4; | 690 int32_t result_rotr_4; |
690 int32_t result_rotr_8; | 691 int32_t result_rotr_8; |
691 int32_t result_rotr_12; | 692 int32_t result_rotr_12; |
692 int32_t result_rotr_16; | 693 int32_t result_rotr_16; |
693 int32_t result_rotr_20; | 694 int32_t result_rotr_20; |
694 int32_t result_rotr_24; | 695 int32_t result_rotr_24; |
695 int32_t result_rotr_28; | 696 int32_t result_rotr_28; |
696 int32_t result_rotrv_4; | 697 int32_t result_rotrv_4; |
697 int32_t result_rotrv_8; | 698 int32_t result_rotrv_8; |
698 int32_t result_rotrv_12; | 699 int32_t result_rotrv_12; |
699 int32_t result_rotrv_16; | 700 int32_t result_rotrv_16; |
700 int32_t result_rotrv_20; | 701 int32_t result_rotrv_20; |
701 int32_t result_rotrv_24; | 702 int32_t result_rotrv_24; |
702 int32_t result_rotrv_28; | 703 int32_t result_rotrv_28; |
703 } T; | 704 } T; |
704 T t; | 705 T t; |
705 | 706 |
706 MacroAssembler assm(isolate, NULL, 0); | 707 MacroAssembler assm(isolate, NULL, 0); |
707 | 708 |
708 // Basic word load. | 709 // Basic word load. |
709 __ lw(a4, MemOperand(a0, OFFSET_OF(T, input)) ); | 710 __ lw(a4, MemOperand(a0, OFFSET_OF(T, input)) ); |
710 | 711 |
711 // ROTR instruction (called through the Ror macro). | 712 // ROTR instruction (called through the Ror macro). |
712 __ Ror(a5, a4, 0x0004); | 713 __ Ror(a5, a4, 0x0004); |
713 __ Ror(a6, a4, 0x0008); | 714 __ Ror(a6, a4, 0x0008); |
714 __ Ror(a7, a4, 0x000c); | 715 __ Ror(a7, a4, 0x000c); |
715 __ Ror(t0, a4, 0x0010); | 716 __ Ror(t0, a4, 0x0010); |
716 __ Ror(t1, a4, 0x0014); | 717 __ Ror(t1, a4, 0x0014); |
717 __ Ror(t2, a4, 0x0018); | 718 __ Ror(t2, a4, 0x0018); |
718 __ Ror(t3, a4, 0x001c); | 719 __ Ror(t3, a4, 0x001c); |
719 | 720 |
720 // Basic word store. | 721 // Basic word store. |
721 __ sw(a5, MemOperand(a0, OFFSET_OF(T, result_rotr_4)) ); | 722 __ sw(a5, MemOperand(a0, OFFSET_OF(T, result_rotr_4)) ); |
722 __ sw(a6, MemOperand(a0, OFFSET_OF(T, result_rotr_8)) ); | 723 __ sw(a6, MemOperand(a0, OFFSET_OF(T, result_rotr_8)) ); |
723 __ sw(a7, MemOperand(a0, OFFSET_OF(T, result_rotr_12)) ); | 724 __ sw(a7, MemOperand(a0, OFFSET_OF(T, result_rotr_12)) ); |
724 __ sw(t0, MemOperand(a0, OFFSET_OF(T, result_rotr_16)) ); | 725 __ sw(t0, MemOperand(a0, OFFSET_OF(T, result_rotr_16)) ); |
725 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotr_20)) ); | 726 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotr_20)) ); |
726 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotr_24)) ); | 727 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotr_24)) ); |
727 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotr_28)) ); | 728 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotr_28)) ); |
728 | 729 |
729 // ROTRV instruction (called through the Ror macro). | 730 // ROTRV instruction (called through the Ror macro). |
730 __ li(t3, 0x0004); | 731 __ li(t3, 0x0004); |
731 __ Ror(a5, a4, t3); | 732 __ Ror(a5, a4, t3); |
732 __ li(t3, 0x0008); | 733 __ li(t3, 0x0008); |
733 __ Ror(a6, a4, t3); | 734 __ Ror(a6, a4, t3); |
734 __ li(t3, 0x000C); | 735 __ li(t3, 0x000C); |
735 __ Ror(a7, a4, t3); | 736 __ Ror(a7, a4, t3); |
736 __ li(t3, 0x0010); | 737 __ li(t3, 0x0010); |
737 __ Ror(t0, a4, t3); | 738 __ Ror(t0, a4, t3); |
738 __ li(t3, 0x0014); | 739 __ li(t3, 0x0014); |
739 __ Ror(t1, a4, t3); | 740 __ Ror(t1, a4, t3); |
740 __ li(t3, 0x0018); | 741 __ li(t3, 0x0018); |
741 __ Ror(t2, a4, t3); | 742 __ Ror(t2, a4, t3); |
742 __ li(t3, 0x001C); | 743 __ li(t3, 0x001C); |
743 __ Ror(t3, a4, t3); | 744 __ Ror(t3, a4, t3); |
744 | 745 |
745 // Basic word store. | 746 // Basic word store. |
746 __ sw(a5, MemOperand(a0, OFFSET_OF(T, result_rotrv_4)) ); | 747 __ sw(a5, MemOperand(a0, OFFSET_OF(T, result_rotrv_4)) ); |
747 __ sw(a6, MemOperand(a0, OFFSET_OF(T, result_rotrv_8)) ); | 748 __ sw(a6, MemOperand(a0, OFFSET_OF(T, result_rotrv_8)) ); |
748 __ sw(a7, MemOperand(a0, OFFSET_OF(T, result_rotrv_12)) ); | 749 __ sw(a7, MemOperand(a0, OFFSET_OF(T, result_rotrv_12)) ); |
749 __ sw(t0, MemOperand(a0, OFFSET_OF(T, result_rotrv_16)) ); | 750 __ sw(t0, MemOperand(a0, OFFSET_OF(T, result_rotrv_16)) ); |
750 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotrv_20)) ); | 751 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotrv_20)) ); |
751 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotrv_24)) ); | 752 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotrv_24)) ); |
752 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotrv_28)) ); | 753 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotrv_28)) ); |
753 | 754 |
754 __ jr(ra); | 755 __ jr(ra); |
755 __ nop(); | 756 __ nop(); |
756 | 757 |
757 CodeDesc desc; | 758 CodeDesc desc; |
758 assm.GetCode(&desc); | 759 assm.GetCode(&desc); |
759 Handle<Code> code = isolate->factory()->NewCode( | 760 Handle<Code> code = isolate->factory()->NewCode( |
760 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 761 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
761 F3 f = FUNCTION_CAST<F3>(code->entry()); | 762 F3 f = FUNCTION_CAST<F3>(code->entry()); |
762 t.input = 0x12345678; | 763 t.input = 0x12345678; |
763 Object* dummy = CALL_GENERATED_CODE(f, &t, 0x0, 0, 0, 0); | 764 Object* dummy = CALL_GENERATED_CODE(f, &t, 0x0, 0, 0, 0); |
764 USE(dummy); | 765 USE(dummy); |
765 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotr_4); | 766 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotr_4); |
766 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotr_8); | 767 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotr_8); |
767 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotr_12); | 768 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotr_12); |
768 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotr_16); | 769 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotr_16); |
769 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotr_20); | 770 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotr_20); |
770 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotr_24); | 771 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotr_24); |
771 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotr_28); | 772 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotr_28); |
772 | 773 |
773 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotrv_4); | 774 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotrv_4); |
774 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotrv_8); | 775 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotrv_8); |
775 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotrv_12); | 776 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotrv_12); |
776 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotrv_16); | 777 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotrv_16); |
777 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotrv_20); | 778 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotrv_20); |
778 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotrv_24); | 779 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotrv_24); |
779 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotrv_28); | 780 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotrv_28); |
| 781 } |
780 } | 782 } |
781 | 783 |
782 | 784 |
783 TEST(MIPS9) { | 785 TEST(MIPS9) { |
784 // Test BRANCH improvements. | 786 // Test BRANCH improvements. |
785 CcTest::InitializeVM(); | 787 CcTest::InitializeVM(); |
786 Isolate* isolate = CcTest::i_isolate(); | 788 Isolate* isolate = CcTest::i_isolate(); |
787 HandleScope scope(isolate); | 789 HandleScope scope(isolate); |
788 | 790 |
789 MacroAssembler assm(isolate, NULL, 0); | 791 MacroAssembler assm(isolate, NULL, 0); |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 double a; | 1528 double a; |
1527 double b; | 1529 double b; |
1528 double c; | 1530 double c; |
1529 double d; | 1531 double d; |
1530 } TestFloat; | 1532 } TestFloat; |
1531 | 1533 |
1532 TestFloat test; | 1534 TestFloat test; |
1533 | 1535 |
1534 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); | 1536 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); |
1535 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); | 1537 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); |
1536 __ min(D, f10, f8, f4); | 1538 __ min(D, f10, f4, f8); |
1537 __ max(D, f12, f8, f4); | 1539 __ max(D, f12, f4, f8); |
1538 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); | 1540 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); |
1539 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); | 1541 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); |
1540 __ jr(ra); | 1542 __ jr(ra); |
1541 __ nop(); | 1543 __ nop(); |
1542 | 1544 |
1543 CodeDesc desc; | 1545 CodeDesc desc; |
1544 assm.GetCode(&desc); | 1546 assm.GetCode(&desc); |
1545 Handle<Code> code = isolate->factory()->NewCode( | 1547 Handle<Code> code = isolate->factory()->NewCode( |
1546 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1548 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1547 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1549 F3 f = FUNCTION_CAST<F3>(code->entry()); |
(...skipping 23 matching lines...) Expand all Loading... |
1571 | 1573 |
1572 test.a = std::numeric_limits<double>::quiet_NaN(); | 1574 test.a = std::numeric_limits<double>::quiet_NaN(); |
1573 test.b = std::numeric_limits<double>::quiet_NaN(); | 1575 test.b = std::numeric_limits<double>::quiet_NaN(); |
1574 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1576 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1575 DCHECK(std::isnan(test.c)); | 1577 DCHECK(std::isnan(test.c)); |
1576 DCHECK(std::isnan(test.d)); | 1578 DCHECK(std::isnan(test.d)); |
1577 } | 1579 } |
1578 } | 1580 } |
1579 | 1581 |
1580 | 1582 |
| 1583 TEST(MIPS19) { |
| 1584 if (kArchVariant == kMips64r6) { |
| 1585 const int tableLength = 30; |
| 1586 CcTest::InitializeVM(); |
| 1587 Isolate* isolate = CcTest::i_isolate(); |
| 1588 HandleScope scope(isolate); |
| 1589 MacroAssembler assm(isolate, NULL, 0); |
| 1590 |
| 1591 typedef struct test_float { |
| 1592 double a; |
| 1593 double b; |
| 1594 int fcsr; |
| 1595 }TestFloat; |
| 1596 |
| 1597 TestFloat test; |
| 1598 double inputs[tableLength] = {18446744073709551617.0, |
| 1599 4503599627370496.0, -4503599627370496.0, |
| 1600 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1601 1.7976931348623157E+308, 6.27463370218383111104242366943E-307, |
| 1602 309485009821345068724781056.89, |
| 1603 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
| 1604 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
| 1605 37778931862957161709568.0, 37778931862957161709569.0, |
| 1606 37778931862957161709580.0, 37778931862957161709581.0, |
| 1607 37778931862957161709582.0, 37778931862957161709583.0, |
| 1608 37778931862957161709584.0, 37778931862957161709585.0, |
| 1609 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1610 double outputs_RN[tableLength] = {18446744073709551617.0, |
| 1611 4503599627370496.0, -4503599627370496.0, |
| 1612 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1613 1.7976931348623157E308, 0, |
| 1614 309485009821345068724781057.0, |
| 1615 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
| 1616 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
| 1617 37778931862957161709568.0, 37778931862957161709569.0, |
| 1618 37778931862957161709580.0, 37778931862957161709581.0, |
| 1619 37778931862957161709582.0, 37778931862957161709583.0, |
| 1620 37778931862957161709584.0, 37778931862957161709585.0, |
| 1621 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1622 double outputs_RZ[tableLength] = {18446744073709551617.0, |
| 1623 4503599627370496.0, -4503599627370496.0, |
| 1624 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1625 1.7976931348623157E308, 0, |
| 1626 309485009821345068724781057.0, |
| 1627 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 1628 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 1629 37778931862957161709568.0, 37778931862957161709569.0, |
| 1630 37778931862957161709580.0, 37778931862957161709581.0, |
| 1631 37778931862957161709582.0, 37778931862957161709583.0, |
| 1632 37778931862957161709584.0, 37778931862957161709585.0, |
| 1633 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1634 double outputs_RP[tableLength] = {18446744073709551617.0, |
| 1635 4503599627370496.0, -4503599627370496.0, |
| 1636 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1637 1.7976931348623157E308, 1, |
| 1638 309485009821345068724781057.0, |
| 1639 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
| 1640 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 1641 37778931862957161709568.0, 37778931862957161709569.0, |
| 1642 37778931862957161709580.0, 37778931862957161709581.0, |
| 1643 37778931862957161709582.0, 37778931862957161709583.0, |
| 1644 37778931862957161709584.0, 37778931862957161709585.0, |
| 1645 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1646 double outputs_RM[tableLength] = {18446744073709551617.0, |
| 1647 4503599627370496.0, -4503599627370496.0, |
| 1648 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1649 1.7976931348623157E308, 0, |
| 1650 309485009821345068724781057.0, |
| 1651 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 1652 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
| 1653 37778931862957161709568.0, 37778931862957161709569.0, |
| 1654 37778931862957161709580.0, 37778931862957161709581.0, |
| 1655 37778931862957161709582.0, 37778931862957161709583.0, |
| 1656 37778931862957161709584.0, 37778931862957161709585.0, |
| 1657 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1658 int fcsr_inputs[4] = |
| 1659 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; |
| 1660 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; |
| 1661 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); |
| 1662 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); |
| 1663 __ ctc1(t0, FCSR); |
| 1664 __ rint_d(f8, f4); |
| 1665 __ sdc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); |
| 1666 __ jr(ra); |
| 1667 __ nop(); |
| 1668 |
| 1669 CodeDesc desc; |
| 1670 assm.GetCode(&desc); |
| 1671 Handle<Code> code = isolate->factory()->NewCode( |
| 1672 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1673 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 1674 |
| 1675 for (int j = 0;j < 4;j++) { |
| 1676 test.fcsr = fcsr_inputs[j]; |
| 1677 for (int i = 0;i < tableLength;i++) { |
| 1678 test.a = inputs[i]; |
| 1679 std::cout << j << " " << i << "\n"; |
| 1680 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1681 CHECK_EQ(test.b, outputs[j][i]); |
| 1682 } |
| 1683 } |
| 1684 } |
| 1685 } |
| 1686 |
| 1687 |
| 1688 TEST(MIPS20) { |
| 1689 CcTest::InitializeVM(); |
| 1690 Isolate* isolate = CcTest::i_isolate(); |
| 1691 HandleScope scope(isolate); |
| 1692 MacroAssembler assm(isolate, NULL, 0); |
| 1693 |
| 1694 typedef struct test_float { |
| 1695 double a; |
| 1696 int32_t b; |
| 1697 int fcsr; |
| 1698 }Test; |
| 1699 const int tableLength = 24; |
| 1700 double inputs[tableLength] = { |
| 1701 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
| 1702 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
| 1703 2147483637.0, 2147483638.0, 2147483639.0, |
| 1704 2147483640.0, 2147483641.0, 2147483642.0, |
| 1705 2147483643.0, 2147483644.0, 2147483645.0, |
| 1706 2147483646.0, 2147483647.0, 2147483653.0 |
| 1707 }; |
| 1708 double outputs_RN[tableLength] = { |
| 1709 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
| 1710 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
| 1711 2147483637.0, 2147483638.0, 2147483639.0, |
| 1712 2147483640.0, 2147483641.0, 2147483642.0, |
| 1713 2147483643.0, 2147483644.0, 2147483645.0, |
| 1714 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
| 1715 double outputs_RZ[tableLength] = { |
| 1716 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 1717 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 1718 2147483637.0, 2147483638.0, 2147483639.0, |
| 1719 2147483640.0, 2147483641.0, 2147483642.0, |
| 1720 2147483643.0, 2147483644.0, 2147483645.0, |
| 1721 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
| 1722 double outputs_RP[tableLength] = { |
| 1723 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
| 1724 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 1725 2147483637.0, 2147483638.0, 2147483639.0, |
| 1726 2147483640.0, 2147483641.0, 2147483642.0, |
| 1727 2147483643.0, 2147483644.0, 2147483645.0, |
| 1728 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
| 1729 double outputs_RM[tableLength] = { |
| 1730 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 1731 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
| 1732 2147483637.0, 2147483638.0, 2147483639.0, |
| 1733 2147483640.0, 2147483641.0, 2147483642.0, |
| 1734 2147483643.0, 2147483644.0, 2147483645.0, |
| 1735 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
| 1736 int fcsr_inputs[4] = |
| 1737 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; |
| 1738 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; |
| 1739 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); |
| 1740 __ lw(t0, MemOperand(a0, OFFSET_OF(Test, fcsr)) ); |
| 1741 __ cfc1(t1, FCSR); |
| 1742 __ ctc1(t0, FCSR); |
| 1743 __ cvt_w_d(f8, f4); |
| 1744 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, b)) ); |
| 1745 __ ctc1(t1, FCSR); |
| 1746 __ jr(ra); |
| 1747 __ nop(); |
| 1748 Test test; |
| 1749 CodeDesc desc; |
| 1750 assm.GetCode(&desc); |
| 1751 Handle<Code> code = isolate->factory()->NewCode( |
| 1752 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1753 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 1754 for (int j = 0;j < 4;j++) { |
| 1755 test.fcsr = fcsr_inputs[j]; |
| 1756 for (int i = 0;i < tableLength;i++) { |
| 1757 test.a = inputs[i]; |
| 1758 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1759 CHECK_EQ(test.b, outputs[j][i]); |
| 1760 } |
| 1761 } |
| 1762 } |
| 1763 |
| 1764 |
| 1765 TEST(MIPS21) { |
| 1766 if (kArchVariant == kMips64r6) { |
| 1767 const int tableLength = 30; |
| 1768 CcTest::InitializeVM(); |
| 1769 Isolate* isolate = CcTest::i_isolate(); |
| 1770 HandleScope scope(isolate); |
| 1771 MacroAssembler assm(isolate, NULL, 0); |
| 1772 |
| 1773 typedef struct test_float { |
| 1774 double a; |
| 1775 double b; |
| 1776 int fcsr; |
| 1777 }TestFloat; |
| 1778 |
| 1779 TestFloat test; |
| 1780 double inputs[tableLength] = {18446744073709551617.0, |
| 1781 4503599627370496.0, -4503599627370496.0, |
| 1782 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1783 1.7976931348623157E308, 6.27463370218383111104242366943E-307, |
| 1784 309485009821345068724781056.89, |
| 1785 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
| 1786 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
| 1787 37778931862957161709568.0, 37778931862957161709569.0, |
| 1788 37778931862957161709580.0, 37778931862957161709581.0, |
| 1789 37778931862957161709582.0, 37778931862957161709583.0, |
| 1790 37778931862957161709584.0, 37778931862957161709585.0, |
| 1791 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1792 double outputs_RN[tableLength] = {18446744073709551617.0, |
| 1793 4503599627370496.0, -4503599627370496.0, |
| 1794 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1795 1.7976931348623157E308, 0, |
| 1796 309485009821345068724781057.0, |
| 1797 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
| 1798 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
| 1799 37778931862957161709568.0, 37778931862957161709569.0, |
| 1800 37778931862957161709580.0, 37778931862957161709581.0, |
| 1801 37778931862957161709582.0, 37778931862957161709583.0, |
| 1802 37778931862957161709584.0, 37778931862957161709585.0, |
| 1803 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1804 double outputs_RZ[tableLength] = {18446744073709551617.0, |
| 1805 4503599627370496.0, -4503599627370496.0, |
| 1806 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1807 1.7976931348623157E308, 0, |
| 1808 309485009821345068724781057.0, |
| 1809 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 1810 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 1811 37778931862957161709568.0, 37778931862957161709569.0, |
| 1812 37778931862957161709580.0, 37778931862957161709581.0, |
| 1813 37778931862957161709582.0, 37778931862957161709583.0, |
| 1814 37778931862957161709584.0, 37778931862957161709585.0, |
| 1815 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1816 double outputs_RP[tableLength] = {18446744073709551617.0, |
| 1817 4503599627370496.0, -4503599627370496.0, |
| 1818 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1819 1.7976931348623157E308, 1, |
| 1820 309485009821345068724781057.0, |
| 1821 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
| 1822 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 1823 37778931862957161709568.0, 37778931862957161709569.0, |
| 1824 37778931862957161709580.0, 37778931862957161709581.0, |
| 1825 37778931862957161709582.0, 37778931862957161709583.0, |
| 1826 37778931862957161709584.0, 37778931862957161709585.0, |
| 1827 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1828 double outputs_RM[tableLength] = {18446744073709551617.0, |
| 1829 4503599627370496.0, -4503599627370496.0, |
| 1830 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
| 1831 1.7976931348623157E308, 0, |
| 1832 309485009821345068724781057.0, |
| 1833 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 1834 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
| 1835 37778931862957161709568.0, 37778931862957161709569.0, |
| 1836 37778931862957161709580.0, 37778931862957161709581.0, |
| 1837 37778931862957161709582.0, 37778931862957161709583.0, |
| 1838 37778931862957161709584.0, 37778931862957161709585.0, |
| 1839 37778931862957161709586.0, 37778931862957161709587.0}; |
| 1840 int fcsr_inputs[4] = |
| 1841 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; |
| 1842 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; |
| 1843 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); |
| 1844 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); |
| 1845 __ cfc1(t1, FCSR); |
| 1846 __ ctc1(t0, FCSR); |
| 1847 __ rint_d(f8, f4); |
| 1848 __ sdc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); |
| 1849 __ ctc1(t1, FCSR); |
| 1850 __ jr(ra); |
| 1851 __ nop(); |
| 1852 |
| 1853 CodeDesc desc; |
| 1854 assm.GetCode(&desc); |
| 1855 Handle<Code> code = isolate->factory()->NewCode( |
| 1856 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1857 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 1858 for (int j = 0;j < 4;j++) { |
| 1859 test.fcsr = fcsr_inputs[j]; |
| 1860 for (int i = 0;i < tableLength;i++) { |
| 1861 test.a = inputs[i]; |
| 1862 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1863 CHECK_EQ(test.b, outputs[j][i]); |
| 1864 } |
| 1865 } |
| 1866 } |
| 1867 } |
| 1868 |
| 1869 |
| 1870 |
| 1871 |
1581 TEST(jump_tables1) { | 1872 TEST(jump_tables1) { |
1582 // Test jump tables with forward jumps. | 1873 // Test jump tables with forward jumps. |
1583 CcTest::InitializeVM(); | 1874 CcTest::InitializeVM(); |
1584 Isolate* isolate = CcTest::i_isolate(); | 1875 Isolate* isolate = CcTest::i_isolate(); |
1585 HandleScope scope(isolate); | 1876 HandleScope scope(isolate); |
1586 Assembler assm(isolate, nullptr, 0); | 1877 Assembler assm(isolate, nullptr, 0); |
1587 | 1878 |
1588 const int kNumCases = 512; | 1879 const int kNumCases = 512; |
1589 int values[kNumCases]; | 1880 int values[kNumCases]; |
1590 isolate->random_number_generator()->NextBytes(values, sizeof(values)); | 1881 isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 ::printf("f(%d) = ", i); | 2086 ::printf("f(%d) = ", i); |
1796 result->Print(std::cout); | 2087 result->Print(std::cout); |
1797 ::printf("\n"); | 2088 ::printf("\n"); |
1798 #endif | 2089 #endif |
1799 CHECK(values[i].is_identical_to(result)); | 2090 CHECK(values[i].is_identical_to(result)); |
1800 } | 2091 } |
1801 } | 2092 } |
1802 | 2093 |
1803 | 2094 |
1804 #undef __ | 2095 #undef __ |
OLD | NEW |