OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/stack_frame.h" | 9 #include "vm/stack_frame.h" |
10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 __ IfNeNull(0); | 1785 __ IfNeNull(0); |
1786 __ LoadConstant(1, Smi::Handle(Smi::New(42))); | 1786 __ LoadConstant(1, Smi::Handle(Smi::New(42))); |
1787 __ Return(1); | 1787 __ Return(1); |
1788 } | 1788 } |
1789 | 1789 |
1790 | 1790 |
1791 ASSEMBLER_TEST_RUN(IfNeNullNotNull, test) { | 1791 ASSEMBLER_TEST_RUN(IfNeNullNotNull, test) { |
1792 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 1792 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
1793 } | 1793 } |
1794 | 1794 |
| 1795 // - If<Cond> rA, rD |
| 1796 // |
| 1797 // Cond is Le, Lt, Ge, Gt, or unsigned variants ULe, ULt, UGe, UGt. |
| 1798 // Skips the next instruction unless FP[rA] <Cond> FP[rD]. Assumes that |
| 1799 // FP[rA] and FP[rD] are Smis. |
| 1800 ASSEMBLER_TEST_GENERATE(IfLeTrue, assembler) { |
| 1801 __ Frame(3); |
| 1802 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1803 __ LoadConstant(1, Smi::Handle(Smi::New(-5))); |
| 1804 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 1805 __ IfLe(1, 2); |
| 1806 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1807 __ Return(0); |
| 1808 } |
| 1809 |
| 1810 |
| 1811 ASSEMBLER_TEST_RUN(IfLeTrue, test) { |
| 1812 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1813 } |
| 1814 |
| 1815 |
| 1816 ASSEMBLER_TEST_GENERATE(IfLeFalse, assembler) { |
| 1817 __ Frame(3); |
| 1818 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1819 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 1820 __ LoadConstant(2, Smi::Handle(Smi::New(-5))); |
| 1821 __ IfLe(1, 2); |
| 1822 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1823 __ Return(0); |
| 1824 } |
| 1825 |
| 1826 |
| 1827 ASSEMBLER_TEST_RUN(IfLeFalse, test) { |
| 1828 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1829 } |
| 1830 |
| 1831 |
| 1832 ASSEMBLER_TEST_GENERATE(IfLtTrue, assembler) { |
| 1833 __ Frame(3); |
| 1834 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1835 __ LoadConstant(1, Smi::Handle(Smi::New(-5))); |
| 1836 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 1837 __ IfLt(1, 2); |
| 1838 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1839 __ Return(0); |
| 1840 } |
| 1841 |
| 1842 |
| 1843 ASSEMBLER_TEST_RUN(IfLtTrue, test) { |
| 1844 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1845 } |
| 1846 |
| 1847 |
| 1848 ASSEMBLER_TEST_GENERATE(IfLtFalse, assembler) { |
| 1849 __ Frame(3); |
| 1850 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1851 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 1852 __ LoadConstant(2, Smi::Handle(Smi::New(-5))); |
| 1853 __ IfLt(1, 2); |
| 1854 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1855 __ Return(0); |
| 1856 } |
| 1857 |
| 1858 |
| 1859 ASSEMBLER_TEST_RUN(IfLtFalse, test) { |
| 1860 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1861 } |
| 1862 |
| 1863 |
| 1864 ASSEMBLER_TEST_GENERATE(IfGeTrue, assembler) { |
| 1865 __ Frame(3); |
| 1866 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1867 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 1868 __ LoadConstant(2, Smi::Handle(Smi::New(-5))); |
| 1869 __ IfGe(1, 2); |
| 1870 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1871 __ Return(0); |
| 1872 } |
| 1873 |
| 1874 |
| 1875 ASSEMBLER_TEST_RUN(IfGeTrue, test) { |
| 1876 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1877 } |
| 1878 |
| 1879 |
| 1880 ASSEMBLER_TEST_GENERATE(IfGeFalse, assembler) { |
| 1881 __ Frame(3); |
| 1882 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1883 __ LoadConstant(1, Smi::Handle(Smi::New(-5))); |
| 1884 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 1885 __ IfGe(1, 2); |
| 1886 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1887 __ Return(0); |
| 1888 } |
| 1889 |
| 1890 |
| 1891 ASSEMBLER_TEST_RUN(IfGeFalse, test) { |
| 1892 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1893 } |
| 1894 |
| 1895 |
| 1896 ASSEMBLER_TEST_GENERATE(IfGtTrue, assembler) { |
| 1897 __ Frame(3); |
| 1898 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1899 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 1900 __ LoadConstant(2, Smi::Handle(Smi::New(-5))); |
| 1901 __ IfGt(1, 2); |
| 1902 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1903 __ Return(0); |
| 1904 } |
| 1905 |
| 1906 |
| 1907 ASSEMBLER_TEST_RUN(IfGtTrue, test) { |
| 1908 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1909 } |
| 1910 |
| 1911 |
| 1912 ASSEMBLER_TEST_GENERATE(IfGtFalse, assembler) { |
| 1913 __ Frame(3); |
| 1914 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1915 __ LoadConstant(1, Smi::Handle(Smi::New(-5))); |
| 1916 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 1917 __ IfGt(1, 2); |
| 1918 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1919 __ Return(0); |
| 1920 } |
| 1921 |
| 1922 |
| 1923 ASSEMBLER_TEST_RUN(IfGtFalse, test) { |
| 1924 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1925 } |
| 1926 |
| 1927 |
| 1928 |
| 1929 |
| 1930 |
| 1931 ASSEMBLER_TEST_GENERATE(IfULeTrue, assembler) { |
| 1932 __ Frame(3); |
| 1933 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1934 __ LoadConstant(1, Smi::Handle(Smi::New(5))); |
| 1935 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 1936 __ IfULe(1, 2); |
| 1937 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1938 __ Return(0); |
| 1939 } |
| 1940 |
| 1941 |
| 1942 ASSEMBLER_TEST_RUN(IfULeTrue, test) { |
| 1943 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1944 } |
| 1945 |
| 1946 |
| 1947 ASSEMBLER_TEST_GENERATE(IfULeFalse, assembler) { |
| 1948 __ Frame(3); |
| 1949 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1950 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 1951 __ LoadConstant(2, Smi::Handle(Smi::New(5))); |
| 1952 __ IfULe(1, 2); |
| 1953 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1954 __ Return(0); |
| 1955 } |
| 1956 |
| 1957 |
| 1958 ASSEMBLER_TEST_RUN(IfULeFalse, test) { |
| 1959 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1960 } |
| 1961 |
| 1962 |
| 1963 ASSEMBLER_TEST_GENERATE(IfULeNegTrue, assembler) { |
| 1964 __ Frame(3); |
| 1965 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1966 __ LoadConstant(1, Smi::Handle(Smi::New(5))); |
| 1967 __ LoadConstant(2, Smi::Handle(Smi::New(-5))); |
| 1968 __ IfULe(1, 2); |
| 1969 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1970 __ Return(0); |
| 1971 } |
| 1972 |
| 1973 |
| 1974 ASSEMBLER_TEST_RUN(IfULeNegTrue, test) { |
| 1975 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1976 } |
| 1977 |
| 1978 |
| 1979 ASSEMBLER_TEST_GENERATE(IfULtTrue, assembler) { |
| 1980 __ Frame(3); |
| 1981 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1982 __ LoadConstant(1, Smi::Handle(Smi::New(5))); |
| 1983 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 1984 __ IfULt(1, 2); |
| 1985 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1986 __ Return(0); |
| 1987 } |
| 1988 |
| 1989 |
| 1990 ASSEMBLER_TEST_RUN(IfULtTrue, test) { |
| 1991 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1992 } |
| 1993 |
| 1994 |
| 1995 ASSEMBLER_TEST_GENERATE(IfULtFalse, assembler) { |
| 1996 __ Frame(3); |
| 1997 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1998 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 1999 __ LoadConstant(2, Smi::Handle(Smi::New(5))); |
| 2000 __ IfULt(1, 2); |
| 2001 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2002 __ Return(0); |
| 2003 } |
| 2004 |
| 2005 |
| 2006 ASSEMBLER_TEST_RUN(IfULtFalse, test) { |
| 2007 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2008 } |
| 2009 |
| 2010 |
| 2011 ASSEMBLER_TEST_GENERATE(IfUGeTrue, assembler) { |
| 2012 __ Frame(3); |
| 2013 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2014 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 2015 __ LoadConstant(2, Smi::Handle(Smi::New(5))); |
| 2016 __ IfUGe(1, 2); |
| 2017 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2018 __ Return(0); |
| 2019 } |
| 2020 |
| 2021 |
| 2022 ASSEMBLER_TEST_RUN(IfUGeTrue, test) { |
| 2023 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2024 } |
| 2025 |
| 2026 |
| 2027 ASSEMBLER_TEST_GENERATE(IfUGeFalse, assembler) { |
| 2028 __ Frame(3); |
| 2029 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2030 __ LoadConstant(1, Smi::Handle(Smi::New(5))); |
| 2031 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 2032 __ IfUGe(1, 2); |
| 2033 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2034 __ Return(0); |
| 2035 } |
| 2036 |
| 2037 |
| 2038 ASSEMBLER_TEST_RUN(IfUGeFalse, test) { |
| 2039 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2040 } |
| 2041 |
| 2042 |
| 2043 ASSEMBLER_TEST_GENERATE(IfUGtTrue, assembler) { |
| 2044 __ Frame(3); |
| 2045 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2046 __ LoadConstant(1, Smi::Handle(Smi::New(100))); |
| 2047 __ LoadConstant(2, Smi::Handle(Smi::New(5))); |
| 2048 __ IfUGt(1, 2); |
| 2049 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2050 __ Return(0); |
| 2051 } |
| 2052 |
| 2053 |
| 2054 ASSEMBLER_TEST_RUN(IfUGtTrue, test) { |
| 2055 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2056 } |
| 2057 |
| 2058 |
| 2059 ASSEMBLER_TEST_GENERATE(IfUGtFalse, assembler) { |
| 2060 __ Frame(3); |
| 2061 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2062 __ LoadConstant(1, Smi::Handle(Smi::New(5))); |
| 2063 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
| 2064 __ IfUGt(1, 2); |
| 2065 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2066 __ Return(0); |
| 2067 } |
| 2068 |
| 2069 |
| 2070 ASSEMBLER_TEST_RUN(IfUGtFalse, test) { |
| 2071 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2072 } |
| 2073 |
1795 } // namespace dart | 2074 } // namespace dart |
1796 | 2075 |
1797 #endif // defined(TARGET_ARCH_DBC) | 2076 #endif // defined(TARGET_ARCH_DBC) |
OLD | NEW |