OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); | 688 F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); |
689 | 689 |
690 return reinterpret_cast<RET_TYPE>( | 690 return reinterpret_cast<RET_TYPE>( |
691 CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0)); | 691 CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0)); |
692 } | 692 } |
693 | 693 |
694 TEST(Cvt_s_uw_Trunc_uw_s) { | 694 TEST(Cvt_s_uw_Trunc_uw_s) { |
695 CcTest::InitializeVM(); | 695 CcTest::InitializeVM(); |
696 FOR_UINT32_INPUTS(i, cvt_trunc_uint32_test_values) { | 696 FOR_UINT32_INPUTS(i, cvt_trunc_uint32_test_values) { |
697 uint32_t input = *i; | 697 uint32_t input = *i; |
698 CHECK_EQ(static_cast<float>(input), | 698 auto fn = [](MacroAssembler* masm) { |
699 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) { | 699 __ Cvt_s_uw(f0, a0); |
700 __ Cvt_s_uw(f0, a0); | 700 __ mthc1(zero_reg, f2); |
701 __ mthc1(zero_reg, f2); | 701 __ Trunc_uw_s(f2, f0, f1); |
702 __ Trunc_uw_s(f2, f0, f1); | 702 }; |
703 })); | 703 CHECK_EQ(static_cast<float>(input), run_Cvt<uint64_t>(input, fn)); |
704 } | 704 } |
705 } | 705 } |
706 | 706 |
707 TEST(Cvt_s_ul_Trunc_ul_s) { | 707 TEST(Cvt_s_ul_Trunc_ul_s) { |
708 CcTest::InitializeVM(); | 708 CcTest::InitializeVM(); |
709 FOR_UINT64_INPUTS(i, cvt_trunc_uint64_test_values) { | 709 FOR_UINT64_INPUTS(i, cvt_trunc_uint64_test_values) { |
710 uint64_t input = *i; | 710 uint64_t input = *i; |
711 CHECK_EQ(static_cast<float>(input), | 711 auto fn = [](MacroAssembler* masm) { |
712 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) { | 712 __ Cvt_s_ul(f0, a0); |
713 __ Cvt_s_ul(f0, a0); | 713 __ Trunc_ul_s(f2, f0, f1, v0); |
714 __ Trunc_ul_s(f2, f0, f1, v0); | 714 }; |
715 })); | 715 CHECK_EQ(static_cast<float>(input), run_Cvt<uint64_t>(input, fn)); |
716 } | 716 } |
717 } | 717 } |
718 | 718 |
719 TEST(Cvt_d_ul_Trunc_ul_d) { | 719 TEST(Cvt_d_ul_Trunc_ul_d) { |
720 CcTest::InitializeVM(); | 720 CcTest::InitializeVM(); |
721 FOR_UINT64_INPUTS(i, cvt_trunc_uint64_test_values) { | 721 FOR_UINT64_INPUTS(i, cvt_trunc_uint64_test_values) { |
722 uint64_t input = *i; | 722 uint64_t input = *i; |
723 CHECK_EQ(static_cast<double>(input), | 723 auto fn = [](MacroAssembler* masm) { |
724 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) { | 724 __ Cvt_d_ul(f0, a0); |
725 __ Cvt_d_ul(f0, a0); | 725 __ Trunc_ul_d(f2, f0, f1, v0); |
726 __ Trunc_ul_d(f2, f0, f1, v0); | 726 }; |
727 })); | 727 CHECK_EQ(static_cast<double>(input), run_Cvt<uint64_t>(input, fn)); |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 TEST(cvt_d_l_Trunc_l_d) { | 731 TEST(cvt_d_l_Trunc_l_d) { |
732 CcTest::InitializeVM(); | 732 CcTest::InitializeVM(); |
733 FOR_INT64_INPUTS(i, cvt_trunc_int64_test_values) { | 733 FOR_INT64_INPUTS(i, cvt_trunc_int64_test_values) { |
734 int64_t input = *i; | 734 int64_t input = *i; |
735 CHECK_EQ(static_cast<double>(input), | 735 auto fn = [](MacroAssembler* masm) { |
736 run_Cvt<int64_t>(input, [](MacroAssembler* masm) { | 736 __ dmtc1(a0, f4); |
737 __ dmtc1(a0, f4); | 737 __ cvt_d_l(f0, f4); |
738 __ cvt_d_l(f0, f4); | 738 __ Trunc_l_d(f2, f0); |
739 __ Trunc_l_d(f2, f0); | 739 }; |
740 })); | 740 CHECK_EQ(static_cast<double>(input), run_Cvt<int64_t>(input, fn)); |
741 } | 741 } |
742 } | 742 } |
743 | 743 |
744 TEST(cvt_d_l_Trunc_l_ud) { | 744 TEST(cvt_d_l_Trunc_l_ud) { |
745 CcTest::InitializeVM(); | 745 CcTest::InitializeVM(); |
746 FOR_INT64_INPUTS(i, cvt_trunc_int64_test_values) { | 746 FOR_INT64_INPUTS(i, cvt_trunc_int64_test_values) { |
747 int64_t input = *i; | 747 int64_t input = *i; |
748 uint64_t abs_input = (input < 0) ? -input : input; | 748 uint64_t abs_input = (input < 0) ? -input : input; |
749 CHECK_EQ(static_cast<double>(abs_input), | 749 auto fn = [](MacroAssembler* masm) { |
750 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) { | 750 __ dmtc1(a0, f4); |
751 __ dmtc1(a0, f4); | 751 __ cvt_d_l(f0, f4); |
752 __ cvt_d_l(f0, f4); | 752 __ Trunc_l_ud(f2, f0, f6); |
753 __ Trunc_l_ud(f2, f0, f6); | 753 }; |
754 })); | 754 CHECK_EQ(static_cast<double>(abs_input), run_Cvt<uint64_t>(input, fn)); |
755 } | 755 } |
756 } | 756 } |
757 | 757 |
758 TEST(cvt_d_w_Trunc_w_d) { | 758 TEST(cvt_d_w_Trunc_w_d) { |
759 CcTest::InitializeVM(); | 759 CcTest::InitializeVM(); |
760 FOR_INT32_INPUTS(i, cvt_trunc_int32_test_values) { | 760 FOR_INT32_INPUTS(i, cvt_trunc_int32_test_values) { |
761 int32_t input = *i; | 761 int32_t input = *i; |
762 CHECK_EQ(static_cast<double>(input), | 762 auto fn = [](MacroAssembler* masm) { |
763 run_Cvt<int64_t>(input, [](MacroAssembler* masm) { | 763 __ mtc1(a0, f4); |
764 __ mtc1(a0, f4); | 764 __ cvt_d_w(f0, f4); |
765 __ cvt_d_w(f0, f4); | 765 __ Trunc_w_d(f2, f0); |
766 __ Trunc_w_d(f2, f0); | 766 __ mfc1(v1, f2); |
767 __ mfc1(v1, f2); | 767 __ dmtc1(v1, f2); |
768 __ dmtc1(v1, f2); | 768 }; |
769 })); | 769 CHECK_EQ(static_cast<double>(input), run_Cvt<int64_t>(input, fn)); |
770 } | 770 } |
771 } | 771 } |
772 | 772 |
773 static const std::vector<int32_t> overflow_int32_test_values() { | 773 static const std::vector<int32_t> overflow_int32_test_values() { |
774 static const int32_t kValues[] = { | 774 static const int32_t kValues[] = { |
775 static_cast<int32_t>(0xf0000000), static_cast<int32_t>(0x00000001), | 775 static_cast<int32_t>(0xf0000000), static_cast<int32_t>(0x00000001), |
776 static_cast<int32_t>(0xff000000), static_cast<int32_t>(0x0000f000), | 776 static_cast<int32_t>(0xff000000), static_cast<int32_t>(0x0000f000), |
777 static_cast<int32_t>(0x0f000000), static_cast<int32_t>(0x991234ab), | 777 static_cast<int32_t>(0x0f000000), static_cast<int32_t>(0x991234ab), |
778 static_cast<int32_t>(0xb0ffff01), static_cast<int32_t>(0x00006fff), | 778 static_cast<int32_t>(0xb0ffff01), static_cast<int32_t>(0x00006fff), |
779 static_cast<int32_t>(0xffffffff)}; | 779 static_cast<int32_t>(0xffffffff)}; |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 char memory_buffer[kBufferSize]; | 1610 char memory_buffer[kBufferSize]; |
1611 char* buffer_middle = memory_buffer + (kBufferSize / 2); | 1611 char* buffer_middle = memory_buffer + (kBufferSize / 2); |
1612 | 1612 |
1613 FOR_UINT64_INPUTS(i, unsigned_test_values) { | 1613 FOR_UINT64_INPUTS(i, unsigned_test_values) { |
1614 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { | 1614 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { |
1615 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { | 1615 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { |
1616 uint16_t value = static_cast<uint64_t>(*i & 0xFFFF); | 1616 uint16_t value = static_cast<uint64_t>(*i & 0xFFFF); |
1617 int32_t in_offset = *j1 + *k1; | 1617 int32_t in_offset = *j1 + *k1; |
1618 int32_t out_offset = *j2 + *k2; | 1618 int32_t out_offset = *j2 + *k2; |
1619 | 1619 |
1620 CHECK_EQ(true, run_Unaligned<uint16_t>( | 1620 auto fn_1 = [](MacroAssembler* masm, int32_t in_offset, |
1621 buffer_middle, in_offset, out_offset, value, | 1621 int32_t out_offset) { |
1622 [](MacroAssembler* masm, int32_t in_offset, | 1622 __ Ulh(v0, MemOperand(a0, in_offset)); |
1623 int32_t out_offset) { | 1623 __ Ush(v0, MemOperand(a0, out_offset), v0); |
1624 __ Ulh(v0, MemOperand(a0, in_offset)); | 1624 }; |
1625 __ Ush(v0, MemOperand(a0, out_offset), v0); | 1625 CHECK_EQ(true, run_Unaligned<uint16_t>(buffer_middle, in_offset, |
1626 })); | 1626 out_offset, value, fn_1)); |
1627 CHECK_EQ(true, run_Unaligned<uint16_t>( | 1627 |
1628 buffer_middle, in_offset, out_offset, value, | 1628 auto fn_2 = [](MacroAssembler* masm, int32_t in_offset, |
1629 [](MacroAssembler* masm, int32_t in_offset, | 1629 int32_t out_offset) { |
1630 int32_t out_offset) { | 1630 __ mov(t0, a0); |
1631 __ mov(t0, a0); | 1631 __ Ulh(a0, MemOperand(a0, in_offset)); |
1632 __ Ulh(a0, MemOperand(a0, in_offset)); | 1632 __ Ush(a0, MemOperand(t0, out_offset), v0); |
1633 __ Ush(a0, MemOperand(t0, out_offset), v0); | 1633 }; |
1634 })); | 1634 CHECK_EQ(true, run_Unaligned<uint16_t>(buffer_middle, in_offset, |
1635 CHECK_EQ(true, run_Unaligned<uint16_t>( | 1635 out_offset, value, fn_2)); |
1636 buffer_middle, in_offset, out_offset, value, | 1636 |
1637 [](MacroAssembler* masm, int32_t in_offset, | 1637 auto fn_3 = [](MacroAssembler* masm, int32_t in_offset, |
1638 int32_t out_offset) { | 1638 int32_t out_offset) { |
1639 __ mov(t0, a0); | 1639 __ mov(t0, a0); |
1640 __ Ulhu(a0, MemOperand(a0, in_offset)); | 1640 __ Ulhu(a0, MemOperand(a0, in_offset)); |
1641 __ Ush(a0, MemOperand(t0, out_offset), t1); | 1641 __ Ush(a0, MemOperand(t0, out_offset), t1); |
1642 })); | 1642 }; |
1643 CHECK_EQ(true, run_Unaligned<uint16_t>( | 1643 CHECK_EQ(true, run_Unaligned<uint16_t>(buffer_middle, in_offset, |
1644 buffer_middle, in_offset, out_offset, value, | 1644 out_offset, value, fn_3)); |
1645 [](MacroAssembler* masm, int32_t in_offset, | 1645 |
1646 int32_t out_offset) { | 1646 auto fn_4 = [](MacroAssembler* masm, int32_t in_offset, |
1647 __ Ulhu(v0, MemOperand(a0, in_offset)); | 1647 int32_t out_offset) { |
1648 __ Ush(v0, MemOperand(a0, out_offset), t1); | 1648 __ Ulhu(v0, MemOperand(a0, in_offset)); |
1649 })); | 1649 __ Ush(v0, MemOperand(a0, out_offset), t1); |
| 1650 }; |
| 1651 CHECK_EQ(true, run_Unaligned<uint16_t>(buffer_middle, in_offset, |
| 1652 out_offset, value, fn_4)); |
1650 } | 1653 } |
1651 } | 1654 } |
1652 } | 1655 } |
1653 } | 1656 } |
1654 | 1657 |
1655 TEST(Ulh_bitextension) { | 1658 TEST(Ulh_bitextension) { |
1656 CcTest::InitializeVM(); | 1659 CcTest::InitializeVM(); |
1657 | 1660 |
1658 static const int kBufferSize = 300 * KB; | 1661 static const int kBufferSize = 300 * KB; |
1659 char memory_buffer[kBufferSize]; | 1662 char memory_buffer[kBufferSize]; |
1660 char* buffer_middle = memory_buffer + (kBufferSize / 2); | 1663 char* buffer_middle = memory_buffer + (kBufferSize / 2); |
1661 | 1664 |
1662 FOR_UINT64_INPUTS(i, unsigned_test_values) { | 1665 FOR_UINT64_INPUTS(i, unsigned_test_values) { |
1663 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { | 1666 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { |
1664 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { | 1667 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { |
1665 uint16_t value = static_cast<uint64_t>(*i & 0xFFFF); | 1668 uint16_t value = static_cast<uint64_t>(*i & 0xFFFF); |
1666 int32_t in_offset = *j1 + *k1; | 1669 int32_t in_offset = *j1 + *k1; |
1667 int32_t out_offset = *j2 + *k2; | 1670 int32_t out_offset = *j2 + *k2; |
1668 | 1671 |
1669 CHECK_EQ(true, run_Unaligned<uint16_t>( | 1672 auto fn = [](MacroAssembler* masm, int32_t in_offset, |
1670 buffer_middle, in_offset, out_offset, value, | 1673 int32_t out_offset) { |
1671 [](MacroAssembler* masm, int32_t in_offset, | 1674 Label success, fail, end, different; |
1672 int32_t out_offset) { | 1675 __ Ulh(t0, MemOperand(a0, in_offset)); |
1673 Label success, fail, end, different; | 1676 __ Ulhu(t1, MemOperand(a0, in_offset)); |
1674 __ Ulh(t0, MemOperand(a0, in_offset)); | 1677 __ Branch(&different, ne, t0, Operand(t1)); |
1675 __ Ulhu(t1, MemOperand(a0, in_offset)); | |
1676 __ Branch(&different, ne, t0, Operand(t1)); | |
1677 | 1678 |
1678 // If signed and unsigned values are same, check | 1679 // If signed and unsigned values are same, check |
1679 // the upper bits to see if they are zero | 1680 // the upper bits to see if they are zero |
1680 __ sra(t0, t0, 15); | 1681 __ sra(t0, t0, 15); |
1681 __ Branch(&success, eq, t0, Operand(zero_reg)); | 1682 __ Branch(&success, eq, t0, Operand(zero_reg)); |
1682 __ Branch(&fail); | 1683 __ Branch(&fail); |
1683 | 1684 |
1684 // If signed and unsigned values are different, | 1685 // If signed and unsigned values are different, |
1685 // check that the upper bits are complementary | 1686 // check that the upper bits are complementary |
1686 __ bind(&different); | 1687 __ bind(&different); |
1687 __ sra(t1, t1, 15); | 1688 __ sra(t1, t1, 15); |
1688 __ Branch(&fail, ne, t1, Operand(1)); | 1689 __ Branch(&fail, ne, t1, Operand(1)); |
1689 __ sra(t0, t0, 15); | 1690 __ sra(t0, t0, 15); |
1690 __ addiu(t0, t0, 1); | 1691 __ addiu(t0, t0, 1); |
1691 __ Branch(&fail, ne, t0, Operand(zero_reg)); | 1692 __ Branch(&fail, ne, t0, Operand(zero_reg)); |
1692 // Fall through to success | 1693 // Fall through to success |
1693 | 1694 |
1694 __ bind(&success); | 1695 __ bind(&success); |
1695 __ Ulh(t0, MemOperand(a0, in_offset)); | 1696 __ Ulh(t0, MemOperand(a0, in_offset)); |
1696 __ Ush(t0, MemOperand(a0, out_offset), v0); | 1697 __ Ush(t0, MemOperand(a0, out_offset), v0); |
1697 __ Branch(&end); | 1698 __ Branch(&end); |
1698 __ bind(&fail); | 1699 __ bind(&fail); |
1699 __ Ush(zero_reg, MemOperand(a0, out_offset), v0); | 1700 __ Ush(zero_reg, MemOperand(a0, out_offset), v0); |
1700 __ bind(&end); | 1701 __ bind(&end); |
1701 })); | 1702 }; |
| 1703 CHECK_EQ(true, run_Unaligned<uint16_t>(buffer_middle, in_offset, |
| 1704 out_offset, value, fn)); |
1702 } | 1705 } |
1703 } | 1706 } |
1704 } | 1707 } |
1705 } | 1708 } |
1706 | 1709 |
1707 TEST(Ulw) { | 1710 TEST(Ulw) { |
1708 CcTest::InitializeVM(); | 1711 CcTest::InitializeVM(); |
1709 | 1712 |
1710 static const int kBufferSize = 300 * KB; | 1713 static const int kBufferSize = 300 * KB; |
1711 char memory_buffer[kBufferSize]; | 1714 char memory_buffer[kBufferSize]; |
1712 char* buffer_middle = memory_buffer + (kBufferSize / 2); | 1715 char* buffer_middle = memory_buffer + (kBufferSize / 2); |
1713 | 1716 |
1714 FOR_UINT64_INPUTS(i, unsigned_test_values) { | 1717 FOR_UINT64_INPUTS(i, unsigned_test_values) { |
1715 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { | 1718 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { |
1716 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { | 1719 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { |
1717 uint32_t value = static_cast<uint32_t>(*i & 0xFFFFFFFF); | 1720 uint32_t value = static_cast<uint32_t>(*i & 0xFFFFFFFF); |
1718 int32_t in_offset = *j1 + *k1; | 1721 int32_t in_offset = *j1 + *k1; |
1719 int32_t out_offset = *j2 + *k2; | 1722 int32_t out_offset = *j2 + *k2; |
1720 | 1723 |
1721 CHECK_EQ(true, run_Unaligned<uint32_t>( | 1724 auto fn_1 = [](MacroAssembler* masm, int32_t in_offset, |
1722 buffer_middle, in_offset, out_offset, value, | 1725 int32_t out_offset) { |
1723 [](MacroAssembler* masm, int32_t in_offset, | 1726 __ Ulw(v0, MemOperand(a0, in_offset)); |
1724 int32_t out_offset) { | 1727 __ Usw(v0, MemOperand(a0, out_offset)); |
1725 __ Ulw(v0, MemOperand(a0, in_offset)); | 1728 }; |
1726 __ Usw(v0, MemOperand(a0, out_offset)); | 1729 CHECK_EQ(true, run_Unaligned<uint32_t>(buffer_middle, in_offset, |
1727 })); | 1730 out_offset, value, fn_1)); |
| 1731 |
| 1732 auto fn_2 = [](MacroAssembler* masm, int32_t in_offset, |
| 1733 int32_t out_offset) { |
| 1734 __ mov(t0, a0); |
| 1735 __ Ulw(a0, MemOperand(a0, in_offset)); |
| 1736 __ Usw(a0, MemOperand(t0, out_offset)); |
| 1737 }; |
1728 CHECK_EQ(true, | 1738 CHECK_EQ(true, |
1729 run_Unaligned<uint32_t>( | 1739 run_Unaligned<uint32_t>(buffer_middle, in_offset, out_offset, |
1730 buffer_middle, in_offset, out_offset, (uint32_t)value, | 1740 (uint32_t)value, fn_2)); |
1731 [](MacroAssembler* masm, int32_t in_offset, | 1741 |
1732 int32_t out_offset) { | 1742 auto fn_3 = [](MacroAssembler* masm, int32_t in_offset, |
1733 __ mov(t0, a0); | 1743 int32_t out_offset) { |
1734 __ Ulw(a0, MemOperand(a0, in_offset)); | 1744 __ Ulwu(v0, MemOperand(a0, in_offset)); |
1735 __ Usw(a0, MemOperand(t0, out_offset)); | 1745 __ Usw(v0, MemOperand(a0, out_offset)); |
1736 })); | 1746 }; |
1737 CHECK_EQ(true, run_Unaligned<uint32_t>( | 1747 CHECK_EQ(true, run_Unaligned<uint32_t>(buffer_middle, in_offset, |
1738 buffer_middle, in_offset, out_offset, value, | 1748 out_offset, value, fn_3)); |
1739 [](MacroAssembler* masm, int32_t in_offset, | 1749 |
1740 int32_t out_offset) { | 1750 auto fn_4 = [](MacroAssembler* masm, int32_t in_offset, |
1741 __ Ulwu(v0, MemOperand(a0, in_offset)); | 1751 int32_t out_offset) { |
1742 __ Usw(v0, MemOperand(a0, out_offset)); | 1752 __ mov(t0, a0); |
1743 })); | 1753 __ Ulwu(a0, MemOperand(a0, in_offset)); |
| 1754 __ Usw(a0, MemOperand(t0, out_offset)); |
| 1755 }; |
1744 CHECK_EQ(true, | 1756 CHECK_EQ(true, |
1745 run_Unaligned<uint32_t>( | 1757 run_Unaligned<uint32_t>(buffer_middle, in_offset, out_offset, |
1746 buffer_middle, in_offset, out_offset, (uint32_t)value, | 1758 (uint32_t)value, fn_4)); |
1747 [](MacroAssembler* masm, int32_t in_offset, | |
1748 int32_t out_offset) { | |
1749 __ mov(t0, a0); | |
1750 __ Ulwu(a0, MemOperand(a0, in_offset)); | |
1751 __ Usw(a0, MemOperand(t0, out_offset)); | |
1752 })); | |
1753 } | 1759 } |
1754 } | 1760 } |
1755 } | 1761 } |
1756 } | 1762 } |
1757 | 1763 |
1758 TEST(Ulw_extension) { | 1764 TEST(Ulw_extension) { |
1759 CcTest::InitializeVM(); | 1765 CcTest::InitializeVM(); |
1760 | 1766 |
1761 static const int kBufferSize = 300 * KB; | 1767 static const int kBufferSize = 300 * KB; |
1762 char memory_buffer[kBufferSize]; | 1768 char memory_buffer[kBufferSize]; |
1763 char* buffer_middle = memory_buffer + (kBufferSize / 2); | 1769 char* buffer_middle = memory_buffer + (kBufferSize / 2); |
1764 | 1770 |
1765 FOR_UINT64_INPUTS(i, unsigned_test_values) { | 1771 FOR_UINT64_INPUTS(i, unsigned_test_values) { |
1766 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { | 1772 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { |
1767 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { | 1773 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { |
1768 uint32_t value = static_cast<uint32_t>(*i & 0xFFFFFFFF); | 1774 uint32_t value = static_cast<uint32_t>(*i & 0xFFFFFFFF); |
1769 int32_t in_offset = *j1 + *k1; | 1775 int32_t in_offset = *j1 + *k1; |
1770 int32_t out_offset = *j2 + *k2; | 1776 int32_t out_offset = *j2 + *k2; |
1771 | 1777 |
1772 CHECK_EQ(true, run_Unaligned<uint32_t>( | 1778 auto fn = [](MacroAssembler* masm, int32_t in_offset, |
1773 buffer_middle, in_offset, out_offset, value, | 1779 int32_t out_offset) { |
1774 [](MacroAssembler* masm, int32_t in_offset, | 1780 Label success, fail, end, different; |
1775 int32_t out_offset) { | 1781 __ Ulw(t0, MemOperand(a0, in_offset)); |
1776 Label success, fail, end, different; | 1782 __ Ulwu(t1, MemOperand(a0, in_offset)); |
1777 __ Ulw(t0, MemOperand(a0, in_offset)); | 1783 __ Branch(&different, ne, t0, Operand(t1)); |
1778 __ Ulwu(t1, MemOperand(a0, in_offset)); | |
1779 __ Branch(&different, ne, t0, Operand(t1)); | |
1780 | 1784 |
1781 // If signed and unsigned values are same, check | 1785 // If signed and unsigned values are same, check |
1782 // the upper bits to see if they are zero | 1786 // the upper bits to see if they are zero |
1783 __ dsra(t0, t0, 31); | 1787 __ dsra(t0, t0, 31); |
1784 __ Branch(&success, eq, t0, Operand(zero_reg)); | 1788 __ Branch(&success, eq, t0, Operand(zero_reg)); |
1785 __ Branch(&fail); | 1789 __ Branch(&fail); |
1786 | 1790 |
1787 // If signed and unsigned values are different, | 1791 // If signed and unsigned values are different, |
1788 // check that the upper bits are complementary | 1792 // check that the upper bits are complementary |
1789 __ bind(&different); | 1793 __ bind(&different); |
1790 __ dsra(t1, t1, 31); | 1794 __ dsra(t1, t1, 31); |
1791 __ Branch(&fail, ne, t1, Operand(1)); | 1795 __ Branch(&fail, ne, t1, Operand(1)); |
1792 __ dsra(t0, t0, 31); | 1796 __ dsra(t0, t0, 31); |
1793 __ daddiu(t0, t0, 1); | 1797 __ daddiu(t0, t0, 1); |
1794 __ Branch(&fail, ne, t0, Operand(zero_reg)); | 1798 __ Branch(&fail, ne, t0, Operand(zero_reg)); |
1795 // Fall through to success | 1799 // Fall through to success |
1796 | 1800 |
1797 __ bind(&success); | 1801 __ bind(&success); |
1798 __ Ulw(t0, MemOperand(a0, in_offset)); | 1802 __ Ulw(t0, MemOperand(a0, in_offset)); |
1799 __ Usw(t0, MemOperand(a0, out_offset)); | 1803 __ Usw(t0, MemOperand(a0, out_offset)); |
1800 __ Branch(&end); | 1804 __ Branch(&end); |
1801 __ bind(&fail); | 1805 __ bind(&fail); |
1802 __ Usw(zero_reg, MemOperand(a0, out_offset)); | 1806 __ Usw(zero_reg, MemOperand(a0, out_offset)); |
1803 __ bind(&end); | 1807 __ bind(&end); |
1804 })); | 1808 }; |
| 1809 CHECK_EQ(true, run_Unaligned<uint32_t>(buffer_middle, in_offset, |
| 1810 out_offset, value, fn)); |
1805 } | 1811 } |
1806 } | 1812 } |
1807 } | 1813 } |
1808 } | 1814 } |
1809 | 1815 |
1810 TEST(Uld) { | 1816 TEST(Uld) { |
1811 CcTest::InitializeVM(); | 1817 CcTest::InitializeVM(); |
1812 | 1818 |
1813 static const int kBufferSize = 300 * KB; | 1819 static const int kBufferSize = 300 * KB; |
1814 char memory_buffer[kBufferSize]; | 1820 char memory_buffer[kBufferSize]; |
1815 char* buffer_middle = memory_buffer + (kBufferSize / 2); | 1821 char* buffer_middle = memory_buffer + (kBufferSize / 2); |
1816 | 1822 |
1817 FOR_UINT64_INPUTS(i, unsigned_test_values) { | 1823 FOR_UINT64_INPUTS(i, unsigned_test_values) { |
1818 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { | 1824 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { |
1819 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { | 1825 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { |
1820 uint64_t value = *i; | 1826 uint64_t value = *i; |
1821 int32_t in_offset = *j1 + *k1; | 1827 int32_t in_offset = *j1 + *k1; |
1822 int32_t out_offset = *j2 + *k2; | 1828 int32_t out_offset = *j2 + *k2; |
1823 | 1829 |
1824 CHECK_EQ(true, run_Unaligned<uint64_t>( | 1830 auto fn_1 = [](MacroAssembler* masm, int32_t in_offset, |
1825 buffer_middle, in_offset, out_offset, value, | 1831 int32_t out_offset) { |
1826 [](MacroAssembler* masm, int32_t in_offset, | 1832 __ Uld(v0, MemOperand(a0, in_offset)); |
1827 int32_t out_offset) { | 1833 __ Usd(v0, MemOperand(a0, out_offset)); |
1828 __ Uld(v0, MemOperand(a0, in_offset)); | 1834 }; |
1829 __ Usd(v0, MemOperand(a0, out_offset)); | 1835 CHECK_EQ(true, run_Unaligned<uint64_t>(buffer_middle, in_offset, |
1830 })); | 1836 out_offset, value, fn_1)); |
| 1837 |
| 1838 auto fn_2 = [](MacroAssembler* masm, int32_t in_offset, |
| 1839 int32_t out_offset) { |
| 1840 __ mov(t0, a0); |
| 1841 __ Uld(a0, MemOperand(a0, in_offset)); |
| 1842 __ Usd(a0, MemOperand(t0, out_offset)); |
| 1843 }; |
1831 CHECK_EQ(true, | 1844 CHECK_EQ(true, |
1832 run_Unaligned<uint64_t>( | 1845 run_Unaligned<uint64_t>(buffer_middle, in_offset, out_offset, |
1833 buffer_middle, in_offset, out_offset, (uint32_t)value, | 1846 (uint32_t)value, fn_2)); |
1834 [](MacroAssembler* masm, int32_t in_offset, | |
1835 int32_t out_offset) { | |
1836 __ mov(t0, a0); | |
1837 __ Uld(a0, MemOperand(a0, in_offset)); | |
1838 __ Usd(a0, MemOperand(t0, out_offset)); | |
1839 })); | |
1840 } | 1847 } |
1841 } | 1848 } |
1842 } | 1849 } |
1843 } | 1850 } |
1844 | 1851 |
1845 TEST(Ulwc1) { | 1852 TEST(Ulwc1) { |
1846 CcTest::InitializeVM(); | 1853 CcTest::InitializeVM(); |
1847 | 1854 |
1848 static const int kBufferSize = 300 * KB; | 1855 static const int kBufferSize = 300 * KB; |
1849 char memory_buffer[kBufferSize]; | 1856 char memory_buffer[kBufferSize]; |
1850 char* buffer_middle = memory_buffer + (kBufferSize / 2); | 1857 char* buffer_middle = memory_buffer + (kBufferSize / 2); |
1851 | 1858 |
1852 FOR_UINT64_INPUTS(i, unsigned_test_values) { | 1859 FOR_UINT64_INPUTS(i, unsigned_test_values) { |
1853 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { | 1860 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { |
1854 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { | 1861 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { |
1855 float value = static_cast<float>(*i & 0xFFFFFFFF); | 1862 float value = static_cast<float>(*i & 0xFFFFFFFF); |
1856 int32_t in_offset = *j1 + *k1; | 1863 int32_t in_offset = *j1 + *k1; |
1857 int32_t out_offset = *j2 + *k2; | 1864 int32_t out_offset = *j2 + *k2; |
1858 | 1865 |
1859 CHECK_EQ(true, run_Unaligned<float>( | 1866 auto fn = [](MacroAssembler* masm, int32_t in_offset, |
1860 buffer_middle, in_offset, out_offset, value, | 1867 int32_t out_offset) { |
1861 [](MacroAssembler* masm, int32_t in_offset, | 1868 __ Ulwc1(f0, MemOperand(a0, in_offset), t0); |
1862 int32_t out_offset) { | 1869 __ Uswc1(f0, MemOperand(a0, out_offset), t0); |
1863 __ Ulwc1(f0, MemOperand(a0, in_offset), t0); | 1870 }; |
1864 __ Uswc1(f0, MemOperand(a0, out_offset), t0); | 1871 CHECK_EQ(true, run_Unaligned<float>(buffer_middle, in_offset, |
1865 })); | 1872 out_offset, value, fn)); |
1866 } | 1873 } |
1867 } | 1874 } |
1868 } | 1875 } |
1869 } | 1876 } |
1870 | 1877 |
1871 TEST(Uldc1) { | 1878 TEST(Uldc1) { |
1872 CcTest::InitializeVM(); | 1879 CcTest::InitializeVM(); |
1873 | 1880 |
1874 static const int kBufferSize = 300 * KB; | 1881 static const int kBufferSize = 300 * KB; |
1875 char memory_buffer[kBufferSize]; | 1882 char memory_buffer[kBufferSize]; |
1876 char* buffer_middle = memory_buffer + (kBufferSize / 2); | 1883 char* buffer_middle = memory_buffer + (kBufferSize / 2); |
1877 | 1884 |
1878 FOR_UINT64_INPUTS(i, unsigned_test_values) { | 1885 FOR_UINT64_INPUTS(i, unsigned_test_values) { |
1879 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { | 1886 FOR_INT32_INPUTS2(j1, j2, unsigned_test_offset) { |
1880 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { | 1887 FOR_INT32_INPUTS2(k1, k2, unsigned_test_offset_increment) { |
1881 double value = static_cast<double>(*i); | 1888 double value = static_cast<double>(*i); |
1882 int32_t in_offset = *j1 + *k1; | 1889 int32_t in_offset = *j1 + *k1; |
1883 int32_t out_offset = *j2 + *k2; | 1890 int32_t out_offset = *j2 + *k2; |
1884 | 1891 |
1885 CHECK_EQ(true, run_Unaligned<double>( | 1892 auto fn = [](MacroAssembler* masm, int32_t in_offset, |
1886 buffer_middle, in_offset, out_offset, value, | 1893 int32_t out_offset) { |
1887 [](MacroAssembler* masm, int32_t in_offset, | 1894 __ Uldc1(f0, MemOperand(a0, in_offset), t0); |
1888 int32_t out_offset) { | 1895 __ Usdc1(f0, MemOperand(a0, out_offset), t0); |
1889 __ Uldc1(f0, MemOperand(a0, in_offset), t0); | 1896 }; |
1890 __ Usdc1(f0, MemOperand(a0, out_offset), t0); | 1897 CHECK_EQ(true, run_Unaligned<double>(buffer_middle, in_offset, |
1891 })); | 1898 out_offset, value, fn)); |
1892 } | 1899 } |
1893 } | 1900 } |
1894 } | 1901 } |
1895 } | 1902 } |
1896 | 1903 |
1897 static const std::vector<uint64_t> sltu_test_values() { | 1904 static const std::vector<uint64_t> sltu_test_values() { |
1898 static const uint64_t kValues[] = { | 1905 static const uint64_t kValues[] = { |
1899 0, | 1906 0, |
1900 1, | 1907 1, |
1901 0x7ffe, | 1908 0x7ffe, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 } | 1947 } |
1941 | 1948 |
1942 TEST(Sltu) { | 1949 TEST(Sltu) { |
1943 CcTest::InitializeVM(); | 1950 CcTest::InitializeVM(); |
1944 | 1951 |
1945 FOR_UINT64_INPUTS(i, sltu_test_values) { | 1952 FOR_UINT64_INPUTS(i, sltu_test_values) { |
1946 FOR_UINT64_INPUTS(j, sltu_test_values) { | 1953 FOR_UINT64_INPUTS(j, sltu_test_values) { |
1947 uint64_t rs = *i; | 1954 uint64_t rs = *i; |
1948 uint64_t rd = *j; | 1955 uint64_t rd = *j; |
1949 | 1956 |
1950 CHECK_EQ(rs < rd, run_Sltu(rs, rd, | 1957 auto fn_1 = [](MacroAssembler* masm, uint64_t imm) { |
1951 [](MacroAssembler* masm, uint64_t imm) { | 1958 __ Sltu(v0, a0, Operand(imm)); |
1952 __ Sltu(v0, a0, Operand(imm)); | 1959 }; |
1953 })); | 1960 CHECK_EQ(rs < rd, run_Sltu(rs, rd, fn_1)); |
1954 CHECK_EQ(rs < rd, | 1961 |
1955 run_Sltu(rs, rd, [](MacroAssembler* masm, | 1962 auto fn_2 = [](MacroAssembler* masm, uint64_t imm) { |
1956 uint64_t imm) { __ Sltu(v0, a0, a1); })); | 1963 __ Sltu(v0, a0, a1); |
| 1964 }; |
| 1965 CHECK_EQ(rs < rd, run_Sltu(rs, rd, fn_2)); |
1957 } | 1966 } |
1958 } | 1967 } |
1959 } | 1968 } |
1960 | 1969 |
1961 #undef __ | 1970 #undef __ |
OLD | NEW |