Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: runtime/vm/assembler_x64_test.cc

Issue 11573044: Inline Doubles truncate and round. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 } 1689 }
1690 1690
1691 1691
1692 ASSEMBLER_TEST_RUN(XorpdZeroing2, entry) { 1692 ASSEMBLER_TEST_RUN(XorpdZeroing2, entry) {
1693 typedef double (*XorpdZeroing2Code)(double d); 1693 typedef double (*XorpdZeroing2Code)(double d);
1694 double res = reinterpret_cast<XorpdZeroing2Code>(entry)(12.56e3); 1694 double res = reinterpret_cast<XorpdZeroing2Code>(entry)(12.56e3);
1695 EXPECT_FLOAT_EQ(0.0, res, 0.0001); 1695 EXPECT_FLOAT_EQ(0.0, res, 0.0001);
1696 } 1696 }
1697 1697
1698 1698
1699 ASSEMBLER_TEST_GENERATE(Pxor, assembler) {
1700 __ pxor(XMM0, XMM0);
1701 __ ret();
1702 }
1703
1704
1705 ASSEMBLER_TEST_RUN(Pxor, entry) {
1706 typedef double (*PxorCode)(double d);
1707 double res = reinterpret_cast<PxorCode>(entry)(12.3456e3);
1708 EXPECT_FLOAT_EQ(0.0, res, 0.0);
1709 }
1710
1711
1699 ASSEMBLER_TEST_GENERATE(SquareRootDouble, assembler) { 1712 ASSEMBLER_TEST_GENERATE(SquareRootDouble, assembler) {
1700 __ sqrtsd(XMM0, XMM0); 1713 __ sqrtsd(XMM0, XMM0);
1701 __ ret(); 1714 __ ret();
1702 } 1715 }
1703 1716
1704 1717
1705 ASSEMBLER_TEST_RUN(SquareRootDouble, entry) { 1718 ASSEMBLER_TEST_RUN(SquareRootDouble, entry) {
1706 typedef double (*SquareRootDoubleCode)(double d); 1719 typedef double (*SquareRootDoubleCode)(double d);
1707 const double kDoubleConst = .7; 1720 const double kDoubleConst = .7;
1708 double res = reinterpret_cast<SquareRootDoubleCode>(entry)(kDoubleConst); 1721 double res = reinterpret_cast<SquareRootDoubleCode>(entry)(kDoubleConst);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 __ ret(); 1817 __ ret();
1805 } 1818 }
1806 1819
1807 1820
1808 ASSEMBLER_TEST_RUN(IntToDoubleConversion2, entry) { 1821 ASSEMBLER_TEST_RUN(IntToDoubleConversion2, entry) {
1809 typedef double (*IntToDoubleConversion2Code)(int i); 1822 typedef double (*IntToDoubleConversion2Code)(int i);
1810 double res = reinterpret_cast<IntToDoubleConversion2Code>(entry)(3); 1823 double res = reinterpret_cast<IntToDoubleConversion2Code>(entry)(3);
1811 EXPECT_FLOAT_EQ(3.0, res, 0.001); 1824 EXPECT_FLOAT_EQ(3.0, res, 0.001);
1812 } 1825 }
1813 1826
1827 ASSEMBLER_TEST_GENERATE(DoubleToDoubleTrunc, assembler) {
1828 __ roundsd(XMM0, XMM0, Assembler::kRoundToZero);
1829 __ ret();
1830 }
1831
1832
1833 ASSEMBLER_TEST_RUN(DoubleToDoubleTrunc, entry) {
1834 typedef double (*DoubleToDoubleTruncCode)(double d);
1835 double res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(12.3);
1836 EXPECT_EQ(12.0, res);
1837 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(12.8);
1838 EXPECT_EQ(12.0, res);
1839 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(-12.3);
1840 EXPECT_EQ(-12.0, res);
1841 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(-12.8);
1842 EXPECT_EQ(-12.0, res);
1843 }
1844
1845
1846 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) {
1847 __ DoubleAbs(XMM0);
1848 __ ret();
1849 }
1850
1851
1852 ASSEMBLER_TEST_RUN(DoubleAbs, entry) {
1853 typedef double (*DoubleAbsCode)(double d);
1854 double val = -12.45;
1855 double res = reinterpret_cast<DoubleAbsCode>(entry)(val);
1856 EXPECT_FLOAT_EQ(-val, res, 0.001);
1857 val = 12.45;
1858 res = reinterpret_cast<DoubleAbsCode>(entry)(val);
1859 EXPECT_FLOAT_EQ(val, res, 0.001);
1860 }
1861
1862
1863 ASSEMBLER_TEST_GENERATE(DoubleToDoubleRound, assembler) {
1864 __ DoubleRound(XMM0, XMM0, XMM1);
1865 __ ret();
1866 }
1867
1868
1869 ASSEMBLER_TEST_RUN(DoubleToDoubleRound, entry) {
1870 typedef double (*DoubleToDoubleRoundCode)(double d);
1871 double res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(12.3);
1872 EXPECT_EQ(12.0, res);
1873 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(12.8);
1874 EXPECT_EQ(13.0, res);
1875 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(0.5);
1876 EXPECT_EQ(1.0, res);
1877 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-12.3);
1878 EXPECT_EQ(-12.0, res);
1879 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-12.8);
1880 EXPECT_EQ(-13.0, res);
1881 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-0.5);
1882 EXPECT_EQ(-1.0, res);
Florian Schneider 2013/01/11 09:49:30 Add the same test cases as on ia32 here as well.
srdjan 2013/01/11 19:48:21 Done.
1883 }
1884
1814 1885
1815 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { 1886 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) {
1816 __ movmskpd(RAX, XMM0); 1887 __ movmskpd(RAX, XMM0);
1817 __ andq(RAX, Immediate(0x1)); 1888 __ andq(RAX, Immediate(0x1));
1818 __ ret(); 1889 __ ret();
1819 } 1890 }
1820 1891
1821 1892
1822 ASSEMBLER_TEST_RUN(ExtractSignBits, entry) { 1893 ASSEMBLER_TEST_RUN(ExtractSignBits, entry) {
1823 typedef int (*ExtractSignBits)(double d); 1894 typedef int (*ExtractSignBits)(double d);
1824 int res = reinterpret_cast<ExtractSignBits>(entry)(1.0); 1895 int res = reinterpret_cast<ExtractSignBits>(entry)(1.0);
1825 EXPECT_EQ(0, res); 1896 EXPECT_EQ(0, res);
1826 res = reinterpret_cast<ExtractSignBits>(entry)(-1.0); 1897 res = reinterpret_cast<ExtractSignBits>(entry)(-1.0);
1827 EXPECT_EQ(1, res); 1898 EXPECT_EQ(1, res);
1828 res = reinterpret_cast<ExtractSignBits>(entry)(-0.0); 1899 res = reinterpret_cast<ExtractSignBits>(entry)(-0.0);
1829 EXPECT_EQ(1, res); 1900 EXPECT_EQ(1, res);
1830 } 1901 }
1831 1902
1832 } // namespace dart 1903 } // namespace dart
1833 1904
1834 #endif // defined TARGET_ARCH_X64 1905 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698