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

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

Issue 130803013: IA32 and X64 assembler Float64x2 additions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 } 1492 }
1493 1493
1494 1494
1495 ASSEMBLER_TEST_RUN(PackedUnpackHighPair, test) { 1495 ASSEMBLER_TEST_RUN(PackedUnpackHighPair, test) {
1496 typedef float (*PackedUnpackHighPair)(); 1496 typedef float (*PackedUnpackHighPair)();
1497 float res = reinterpret_cast<PackedUnpackHighPair>(test->entry())(); 1497 float res = reinterpret_cast<PackedUnpackHighPair>(test->entry())();
1498 EXPECT_FLOAT_EQ(12.0f, res, 0.001f); 1498 EXPECT_FLOAT_EQ(12.0f, res, 0.001f);
1499 } 1499 }
1500 1500
1501 1501
1502 ASSEMBLER_TEST_GENERATE(PackedDoubleAdd, assembler) {
1503 static const struct ALIGN16 {
1504 double a;
1505 double b;
1506 } constant0 = { 1.0, 2.0 };
1507 static const struct ALIGN16 {
1508 double a;
1509 double b;
1510 } constant1 = { 3.0, 4.0 };
1511 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1512 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1513 __ addpd(XMM0, XMM1);
1514 __ pushl(EAX);
1515 __ pushl(EAX);
1516 __ movsd(Address(ESP, 0), XMM0);
1517 __ fldl(Address(ESP, 0));
1518 __ popl(EAX);
1519 __ popl(EAX);
1520 __ ret();
1521 }
1522
1523
1524 ASSEMBLER_TEST_RUN(PackedDoubleAdd, test) {
1525 typedef double (*PackedDoubleAdd)();
1526 double res = reinterpret_cast<PackedDoubleAdd>(test->entry())();
1527 EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
1528 }
1529
1530
1531 ASSEMBLER_TEST_GENERATE(PackedDoubleSub, assembler) {
1532 static const struct ALIGN16 {
1533 double a;
1534 double b;
1535 } constant0 = { 1.0, 2.0 };
1536 static const struct ALIGN16 {
1537 double a;
1538 double b;
1539 } constant1 = { 3.0, 4.0 };
1540 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1541 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1542 __ subpd(XMM0, XMM1);
1543 __ pushl(EAX);
1544 __ pushl(EAX);
1545 __ movsd(Address(ESP, 0), XMM0);
1546 __ fldl(Address(ESP, 0));
1547 __ popl(EAX);
1548 __ popl(EAX);
1549 __ ret();
1550 }
1551
1552
1553 ASSEMBLER_TEST_RUN(PackedDoubleSub, test) {
1554 typedef double (*PackedDoubleSub)();
1555 double res = reinterpret_cast<PackedDoubleSub>(test->entry())();
1556 EXPECT_FLOAT_EQ(-2.0, res, 0.000001f);
1557 }
1558
1559
1560 ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) {
1561 static const struct ALIGN16 {
1562 double a;
1563 double b;
1564 } constant0 = { 1.0, 2.0 };
1565 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1566 __ negatepd(XMM0);
1567 __ pushl(EAX);
1568 __ pushl(EAX);
1569 __ movsd(Address(ESP, 0), XMM0);
1570 __ fldl(Address(ESP, 0));
1571 __ popl(EAX);
1572 __ popl(EAX);
1573 __ ret();
1574 }
1575
1576
1577 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) {
1578 typedef double (*PackedDoubleNegate)();
1579 double res = reinterpret_cast<PackedDoubleNegate>(test->entry())();
1580 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f);
1581 }
1582
1583
1584 ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) {
1585 static const struct ALIGN16 {
1586 double a;
1587 double b;
1588 } constant0 = { -1.0, 2.0 };
1589 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1590 __ abspd(XMM0);
1591 __ pushl(EAX);
1592 __ pushl(EAX);
1593 __ movsd(Address(ESP, 0), XMM0);
1594 __ fldl(Address(ESP, 0));
1595 __ popl(EAX);
1596 __ popl(EAX);
1597 __ ret();
1598 }
1599
1600
1601 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) {
1602 typedef double (*PackedDoubleAbsolute)();
1603 double res = reinterpret_cast<PackedDoubleAbsolute>(test->entry())();
1604 EXPECT_FLOAT_EQ(1.0, res, 0.000001f);
1605 }
1606
1607
1608 ASSEMBLER_TEST_GENERATE(PackedDoubleMul, assembler) {
1609 static const struct ALIGN16 {
1610 double a;
1611 double b;
1612 } constant0 = { 3.0, 2.0 };
1613 static const struct ALIGN16 {
1614 double a;
1615 double b;
1616 } constant1 = { 3.0, 4.0 };
1617 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1618 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1619 __ mulpd(XMM0, XMM1);
1620 __ pushl(EAX);
1621 __ pushl(EAX);
1622 __ movsd(Address(ESP, 0), XMM0);
1623 __ fldl(Address(ESP, 0));
1624 __ popl(EAX);
1625 __ popl(EAX);
1626 __ ret();
1627 }
1628
1629
1630 ASSEMBLER_TEST_RUN(PackedDoubleMul, test) {
1631 typedef double (*PackedDoubleMul)();
1632 double res = reinterpret_cast<PackedDoubleMul>(test->entry())();
1633 EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
1634 }
1635
1636
1637 ASSEMBLER_TEST_GENERATE(PackedDoubleDiv, assembler) {
1638 static const struct ALIGN16 {
1639 double a;
1640 double b;
1641 } constant0 = { 9.0, 2.0 };
1642 static const struct ALIGN16 {
1643 double a;
1644 double b;
1645 } constant1 = { 3.0, 4.0 };
1646 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1647 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1648 __ divpd(XMM0, XMM1);
1649 __ pushl(EAX);
1650 __ pushl(EAX);
1651 __ movsd(Address(ESP, 0), XMM0);
1652 __ fldl(Address(ESP, 0));
1653 __ popl(EAX);
1654 __ popl(EAX);
1655 __ ret();
1656 }
1657
1658
1659 ASSEMBLER_TEST_RUN(PackedDoubleDiv, test) {
1660 typedef double (*PackedDoubleDiv)();
1661 double res = reinterpret_cast<PackedDoubleDiv>(test->entry())();
1662 EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
1663 }
1664
1665
1666 ASSEMBLER_TEST_GENERATE(PackedDoubleSqrt, assembler) {
1667 static const struct ALIGN16 {
1668 double a;
1669 double b;
1670 } constant0 = { 16.0, 2.0 };
1671 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1672 __ sqrtpd(XMM0);
1673 __ pushl(EAX);
1674 __ pushl(EAX);
1675 __ movsd(Address(ESP, 0), XMM0);
1676 __ fldl(Address(ESP, 0));
1677 __ popl(EAX);
1678 __ popl(EAX);
1679 __ ret();
1680 }
1681
1682
1683 ASSEMBLER_TEST_RUN(PackedDoubleSqrt, test) {
1684 typedef double (*PackedDoubleSqrt)();
1685 double res = reinterpret_cast<PackedDoubleSqrt>(test->entry())();
1686 EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
1687 }
1688
1689
1690 ASSEMBLER_TEST_GENERATE(PackedDoubleMin, assembler) {
1691 static const struct ALIGN16 {
1692 double a;
1693 double b;
1694 } constant0 = { 9.0, 2.0 };
1695 static const struct ALIGN16 {
1696 double a;
1697 double b;
1698 } constant1 = { 3.0, 4.0 };
1699 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1700 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1701 __ minpd(XMM0, XMM1);
1702 __ pushl(EAX);
1703 __ pushl(EAX);
1704 __ movsd(Address(ESP, 0), XMM0);
1705 __ fldl(Address(ESP, 0));
1706 __ popl(EAX);
1707 __ popl(EAX);
1708 __ ret();
1709 }
1710
1711
1712 ASSEMBLER_TEST_RUN(PackedDoubleMin, test) {
1713 typedef double (*PackedDoubleMin)();
1714 double res = reinterpret_cast<PackedDoubleMin>(test->entry())();
1715 EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
1716 }
1717
1718
1719 ASSEMBLER_TEST_GENERATE(PackedDoubleMax, assembler) {
1720 static const struct ALIGN16 {
1721 double a;
1722 double b;
1723 } constant0 = { 9.0, 2.0 };
1724 static const struct ALIGN16 {
1725 double a;
1726 double b;
1727 } constant1 = { 3.0, 4.0 };
1728 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1729 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1730 __ maxpd(XMM0, XMM1);
1731 __ pushl(EAX);
1732 __ pushl(EAX);
1733 __ movsd(Address(ESP, 0), XMM0);
1734 __ fldl(Address(ESP, 0));
1735 __ popl(EAX);
1736 __ popl(EAX);
1737 __ ret();
1738 }
1739
1740
1741 ASSEMBLER_TEST_RUN(PackedDoubleMax, test) {
1742 typedef double (*PackedDoubleMax)();
1743 double res = reinterpret_cast<PackedDoubleMax>(test->entry())();
1744 EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
1745 }
1746
1747
1748 ASSEMBLER_TEST_GENERATE(PackedDoubleToSingle, assembler) {
1749 static const struct ALIGN16 {
1750 double a;
1751 double b;
1752 } constant0 = { 9.0, 2.0 };
1753 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1754 __ cvtpd2ps(XMM0, XMM1);
1755 __ pushl(EAX);
1756 __ movss(Address(ESP, 0), XMM0);
1757 __ flds(Address(ESP, 0));
1758 __ popl(EAX);
1759 __ ret();
1760 }
1761
1762
1763 ASSEMBLER_TEST_RUN(PackedDoubleToSingle, test) {
1764 typedef float (*PackedDoubleToSingle)();
1765 float res = reinterpret_cast<PackedDoubleToSingle>(test->entry())();
1766 EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
1767 }
1768
1769
1770 ASSEMBLER_TEST_GENERATE(PackedSingleToDouble, assembler) {
1771 static const struct ALIGN16 {
1772 float a;
1773 float b;
1774 float c;
1775 float d;
1776 } constant0 = { 9.0f, 2.0f, 3.0f, 4.0f };
1777 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1778 __ cvtps2pd(XMM0, XMM1);
1779 __ pushl(EAX);
1780 __ pushl(EAX);
1781 __ movsd(Address(ESP, 0), XMM0);
1782 __ fldl(Address(ESP, 0));
1783 __ popl(EAX);
1784 __ popl(EAX);
1785 __ ret();
1786 }
1787
1788
1789 ASSEMBLER_TEST_RUN(PackedSingleToDouble, test) {
1790 typedef double (*PackedSingleToDouble)();
1791 double res = reinterpret_cast<PackedSingleToDouble>(test->entry())();
1792 EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
1793 }
1794
1795
1502 ASSEMBLER_TEST_GENERATE(SingleFPOperationsStack, assembler) { 1796 ASSEMBLER_TEST_GENERATE(SingleFPOperationsStack, assembler) {
1503 __ movl(EAX, Immediate(bit_cast<int32_t, float>(12.3f))); 1797 __ movl(EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1504 __ movd(XMM0, EAX); 1798 __ movd(XMM0, EAX);
1505 __ addss(XMM0, Address(ESP, kWordSize)); // 15.7f 1799 __ addss(XMM0, Address(ESP, kWordSize)); // 15.7f
1506 __ mulss(XMM0, Address(ESP, kWordSize)); // 53.38f 1800 __ mulss(XMM0, Address(ESP, kWordSize)); // 53.38f
1507 __ subss(XMM0, Address(ESP, kWordSize)); // 49.98f 1801 __ subss(XMM0, Address(ESP, kWordSize)); // 49.98f
1508 __ divss(XMM0, Address(ESP, kWordSize)); // 14.7f 1802 __ divss(XMM0, Address(ESP, kWordSize)); // 14.7f
1509 __ pushl(EAX); 1803 __ pushl(EAX);
1510 __ movss(Address(ESP, 0), XMM0); 1804 __ movss(Address(ESP, 0), XMM0);
1511 __ flds(Address(ESP, 0)); 1805 __ flds(Address(ESP, 0));
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 FieldAddress(ECX, GrowableObjectArray::data_offset()), 3192 FieldAddress(ECX, GrowableObjectArray::data_offset()),
2899 EAX); 3193 EAX);
2900 __ popl(EAX); 3194 __ popl(EAX);
2901 __ popl(CTX); 3195 __ popl(CTX);
2902 __ ret(); 3196 __ ret();
2903 } 3197 }
2904 3198
2905 } // namespace dart 3199 } // namespace dart
2906 3200
2907 #endif // defined TARGET_ARCH_IA32 3201 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698