| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 __ ret(); | 1743 __ ret(); |
| 1744 } | 1744 } |
| 1745 | 1745 |
| 1746 | 1746 |
| 1747 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { | 1747 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { |
| 1748 typedef uint32_t (*PackedLogicalNotCode)(); | 1748 typedef uint32_t (*PackedLogicalNotCode)(); |
| 1749 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); | 1749 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); |
| 1750 EXPECT_EQ(static_cast<uword>(0x0), res); | 1750 EXPECT_EQ(static_cast<uword>(0x0), res); |
| 1751 } | 1751 } |
| 1752 | 1752 |
| 1753 |
| 1754 ASSEMBLER_TEST_GENERATE(PackedMoveHighLow, assembler) { |
| 1755 static const struct ALIGN16 { |
| 1756 float a; |
| 1757 float b; |
| 1758 float c; |
| 1759 float d; |
| 1760 } constant0 = { 1.0, 2.0, 3.0, 4.0 }; |
| 1761 static const struct ALIGN16 { |
| 1762 float a; |
| 1763 float b; |
| 1764 float c; |
| 1765 float d; |
| 1766 } constant1 = { 5.0, 6.0, 7.0, 8.0 }; |
| 1767 // XMM9 = 1.0f, 2.0f, 3.0f, 4.0f. |
| 1768 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant0))); |
| 1769 __ movups(XMM9, Address(RAX, 0)); |
| 1770 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f. |
| 1771 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); |
| 1772 __ movups(XMM1, Address(RAX, 0)); |
| 1773 // XMM9 = 7.0f, 8.0f, 3.0f, 4.0f. |
| 1774 __ movhlps(XMM9, XMM1); |
| 1775 __ xorps(XMM1, XMM1); |
| 1776 // XMM1 = 7.0f, 8.0f, 3.0f, 4.0f. |
| 1777 __ movaps(XMM1, XMM9); |
| 1778 __ shufps(XMM9, XMM9, Immediate(0x00)); // 7.0f. |
| 1779 __ shufps(XMM1, XMM1, Immediate(0x55)); // 8.0f. |
| 1780 __ addss(XMM9, XMM1); // 15.0f. |
| 1781 __ movaps(XMM0, XMM9); |
| 1782 __ ret(); |
| 1783 } |
| 1784 |
| 1785 |
| 1786 ASSEMBLER_TEST_RUN(PackedMoveHighLow, test) { |
| 1787 typedef float (*PackedMoveHighLow)(); |
| 1788 float res = reinterpret_cast<PackedMoveHighLow>(test->entry())(); |
| 1789 EXPECT_FLOAT_EQ(15.0f, res, 0.001f); |
| 1790 } |
| 1791 |
| 1792 |
| 1793 ASSEMBLER_TEST_GENERATE(PackedMoveLowHigh, assembler) { |
| 1794 static const struct ALIGN16 { |
| 1795 float a; |
| 1796 float b; |
| 1797 float c; |
| 1798 float d; |
| 1799 } constant0 = { 1.0, 2.0, 3.0, 4.0 }; |
| 1800 static const struct ALIGN16 { |
| 1801 float a; |
| 1802 float b; |
| 1803 float c; |
| 1804 float d; |
| 1805 } constant1 = { 5.0, 6.0, 7.0, 8.0 }; |
| 1806 // XMM9 = 1.0f, 2.0f, 3.0f, 4.0f. |
| 1807 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant0))); |
| 1808 __ movups(XMM9, Address(RAX, 0)); |
| 1809 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f. |
| 1810 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); |
| 1811 __ movups(XMM1, Address(RAX, 0)); |
| 1812 // XMM9 = 1.0f, 2.0f, 5.0f, 6.0f |
| 1813 __ movlhps(XMM9, XMM1); |
| 1814 __ xorps(XMM1, XMM1); |
| 1815 // XMM1 = 1.0f, 2.0f, 5.0f, 6.0f |
| 1816 __ movaps(XMM1, XMM9); |
| 1817 __ shufps(XMM9, XMM9, Immediate(0xAA)); // 5.0f. |
| 1818 __ shufps(XMM1, XMM1, Immediate(0xFF)); // 6.0f. |
| 1819 __ addss(XMM9, XMM1); // 11.0f. |
| 1820 __ movaps(XMM0, XMM9); |
| 1821 __ ret(); |
| 1822 } |
| 1823 |
| 1824 |
| 1825 ASSEMBLER_TEST_RUN(PackedMoveLowHigh, test) { |
| 1826 typedef float (*PackedMoveLowHigh)(); |
| 1827 float res = reinterpret_cast<PackedMoveLowHigh>(test->entry())(); |
| 1828 EXPECT_FLOAT_EQ(11.0f, res, 0.001f); |
| 1829 } |
| 1830 |
| 1831 |
| 1832 ASSEMBLER_TEST_GENERATE(PackedUnpackLow, assembler) { |
| 1833 static const struct ALIGN16 { |
| 1834 float a; |
| 1835 float b; |
| 1836 float c; |
| 1837 float d; |
| 1838 } constant0 = { 1.0, 2.0, 3.0, 4.0 }; |
| 1839 static const struct ALIGN16 { |
| 1840 float a; |
| 1841 float b; |
| 1842 float c; |
| 1843 float d; |
| 1844 } constant1 = { 5.0, 6.0, 7.0, 8.0 }; |
| 1845 // XMM9 = 1.0f, 2.0f, 3.0f, 4.0f. |
| 1846 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant0))); |
| 1847 __ movups(XMM9, Address(RAX, 0)); |
| 1848 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f. |
| 1849 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); |
| 1850 __ movups(XMM1, Address(RAX, 0)); |
| 1851 // XMM9 = 1.0f, 5.0f, 2.0f, 6.0f. |
| 1852 __ unpcklps(XMM9, XMM1); |
| 1853 // XMM1 = 1.0f, 5.0f, 2.0f, 6.0f. |
| 1854 __ movaps(XMM1, XMM9); |
| 1855 __ shufps(XMM9, XMM9, Immediate(0x55)); |
| 1856 __ shufps(XMM1, XMM1, Immediate(0xFF)); |
| 1857 __ addss(XMM9, XMM1); // 11.0f. |
| 1858 __ movaps(XMM0, XMM9); |
| 1859 __ ret(); |
| 1860 } |
| 1861 |
| 1862 |
| 1863 ASSEMBLER_TEST_RUN(PackedUnpackLow, test) { |
| 1864 typedef float (*PackedUnpackLow)(); |
| 1865 float res = reinterpret_cast<PackedUnpackLow>(test->entry())(); |
| 1866 EXPECT_FLOAT_EQ(11.0f, res, 0.001f); |
| 1867 } |
| 1868 |
| 1869 |
| 1870 ASSEMBLER_TEST_GENERATE(PackedUnpackHigh, assembler) { |
| 1871 static const struct ALIGN16 { |
| 1872 float a; |
| 1873 float b; |
| 1874 float c; |
| 1875 float d; |
| 1876 } constant0 = { 1.0, 2.0, 3.0, 4.0 }; |
| 1877 static const struct ALIGN16 { |
| 1878 float a; |
| 1879 float b; |
| 1880 float c; |
| 1881 float d; |
| 1882 } constant1 = { 5.0, 6.0, 7.0, 8.0 }; |
| 1883 // XMM9 = 1.0f, 2.0f, 3.0f, 4.0f. |
| 1884 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant0))); |
| 1885 __ movups(XMM9, Address(RAX, 0)); |
| 1886 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f. |
| 1887 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); |
| 1888 __ movups(XMM1, Address(RAX, 0)); |
| 1889 // XMM9 = 3.0f, 7.0f, 4.0f, 8.0f. |
| 1890 __ unpckhps(XMM9, XMM1); |
| 1891 // XMM1 = 3.0f, 7.0f, 4.0f, 8.0f. |
| 1892 __ movaps(XMM1, XMM9); |
| 1893 __ shufps(XMM9, XMM9, Immediate(0x00)); |
| 1894 __ shufps(XMM1, XMM1, Immediate(0xAA)); |
| 1895 __ addss(XMM9, XMM1); // 7.0f. |
| 1896 __ movaps(XMM0, XMM9); |
| 1897 __ ret(); |
| 1898 } |
| 1899 |
| 1900 |
| 1901 ASSEMBLER_TEST_RUN(PackedUnpackHigh, test) { |
| 1902 typedef float (*PackedUnpackHigh)(); |
| 1903 float res = reinterpret_cast<PackedUnpackHigh>(test->entry())(); |
| 1904 EXPECT_FLOAT_EQ(7.0f, res, 0.001f); |
| 1905 } |
| 1906 |
| 1907 |
| 1908 ASSEMBLER_TEST_GENERATE(PackedUnpackLowPair, assembler) { |
| 1909 static const struct ALIGN16 { |
| 1910 float a; |
| 1911 float b; |
| 1912 float c; |
| 1913 float d; |
| 1914 } constant0 = { 1.0, 2.0, 3.0, 4.0 }; |
| 1915 static const struct ALIGN16 { |
| 1916 float a; |
| 1917 float b; |
| 1918 float c; |
| 1919 float d; |
| 1920 } constant1 = { 5.0, 6.0, 7.0, 8.0 }; |
| 1921 // XMM9 = 1.0f, 2.0f, 3.0f, 4.0f. |
| 1922 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant0))); |
| 1923 __ movups(XMM9, Address(RAX, 0)); |
| 1924 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f. |
| 1925 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); |
| 1926 __ movups(XMM1, Address(RAX, 0)); |
| 1927 // XMM9 = 1.0f, 2.0f, 5.0f, 6.0f. |
| 1928 __ unpcklpd(XMM9, XMM1); |
| 1929 // XMM1 = 1.0f, 2.0f, 5.0f, 6.0f. |
| 1930 __ movaps(XMM1, XMM9); |
| 1931 __ shufps(XMM9, XMM9, Immediate(0x00)); |
| 1932 __ shufps(XMM1, XMM1, Immediate(0xAA)); |
| 1933 __ addss(XMM9, XMM1); // 6.0f. |
| 1934 __ movaps(XMM0, XMM9); |
| 1935 __ ret(); |
| 1936 } |
| 1937 |
| 1938 |
| 1939 ASSEMBLER_TEST_RUN(PackedUnpackLowPair, test) { |
| 1940 typedef float (*PackedUnpackLowPair)(); |
| 1941 float res = reinterpret_cast<PackedUnpackLowPair>(test->entry())(); |
| 1942 EXPECT_FLOAT_EQ(6.0f, res, 0.001f); |
| 1943 } |
| 1944 |
| 1945 |
| 1946 ASSEMBLER_TEST_GENERATE(PackedUnpackHighPair, assembler) { |
| 1947 static const struct ALIGN16 { |
| 1948 float a; |
| 1949 float b; |
| 1950 float c; |
| 1951 float d; |
| 1952 } constant0 = { 1.0, 2.0, 3.0, 4.0 }; |
| 1953 static const struct ALIGN16 { |
| 1954 float a; |
| 1955 float b; |
| 1956 float c; |
| 1957 float d; |
| 1958 } constant1 = { 5.0, 6.0, 7.0, 8.0 }; |
| 1959 // XMM9 = 1.0f, 2.0f, 3.0f, 4.0f. |
| 1960 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant0))); |
| 1961 __ movups(XMM9, Address(RAX, 0)); |
| 1962 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f. |
| 1963 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); |
| 1964 __ movups(XMM1, Address(RAX, 0)); |
| 1965 // XMM9 = 3.0f, 4.0f, 7.0f, 8.0f. |
| 1966 __ unpckhpd(XMM9, XMM1); |
| 1967 // XMM1 = 3.0f, 4.0f, 7.0f, 8.0f. |
| 1968 __ movaps(XMM1, XMM9); |
| 1969 __ shufps(XMM9, XMM9, Immediate(0x55)); |
| 1970 __ shufps(XMM1, XMM1, Immediate(0xFF)); |
| 1971 __ addss(XMM9, XMM1); // 12.0f. |
| 1972 __ movaps(XMM0, XMM9); |
| 1973 __ ret(); |
| 1974 } |
| 1975 |
| 1976 |
| 1977 ASSEMBLER_TEST_RUN(PackedUnpackHighPair, test) { |
| 1978 typedef float (*PackedUnpackHighPair)(); |
| 1979 float res = reinterpret_cast<PackedUnpackHighPair>(test->entry())(); |
| 1980 EXPECT_FLOAT_EQ(12.0f, res, 0.001f); |
| 1981 } |
| 1982 |
| 1983 |
| 1753 ASSEMBLER_TEST_GENERATE(DoubleFPMoves, assembler) { | 1984 ASSEMBLER_TEST_GENERATE(DoubleFPMoves, assembler) { |
| 1754 __ movq(RAX, Immediate(bit_cast<int64_t, double>(1024.67))); | 1985 __ movq(RAX, Immediate(bit_cast<int64_t, double>(1024.67))); |
| 1755 __ pushq(R15); // Callee saved. | 1986 __ pushq(R15); // Callee saved. |
| 1756 __ pushq(RAX); | 1987 __ pushq(RAX); |
| 1757 __ movsd(XMM0, Address(RSP, 0)); | 1988 __ movsd(XMM0, Address(RSP, 0)); |
| 1758 __ movsd(XMM1, XMM0); | 1989 __ movsd(XMM1, XMM0); |
| 1759 __ movsd(XMM2, XMM1); | 1990 __ movsd(XMM2, XMM1); |
| 1760 __ movsd(XMM3, XMM2); | 1991 __ movsd(XMM3, XMM2); |
| 1761 __ movsd(XMM4, XMM3); | 1992 __ movsd(XMM4, XMM3); |
| 1762 __ movsd(XMM5, XMM4); | 1993 __ movsd(XMM5, XMM4); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 EXPECT_EQ(to[0], '0'); | 2563 EXPECT_EQ(to[0], '0'); |
| 2333 for (int i = 0; i < 10; i++) { | 2564 for (int i = 0; i < 10; i++) { |
| 2334 EXPECT_EQ(from[i], to[i]); | 2565 EXPECT_EQ(from[i], to[i]); |
| 2335 } | 2566 } |
| 2336 delete [] to; | 2567 delete [] to; |
| 2337 } | 2568 } |
| 2338 | 2569 |
| 2339 } // namespace dart | 2570 } // namespace dart |
| 2340 | 2571 |
| 2341 #endif // defined TARGET_ARCH_X64 | 2572 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |