| 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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 | 1618 |
| 1619 | 1619 |
| 1620 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { | 1620 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { |
| 1621 typedef uint32_t (*PackedCompareNLECode)(); | 1621 typedef uint32_t (*PackedCompareNLECode)(); |
| 1622 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); | 1622 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); |
| 1623 EXPECT_EQ(static_cast<uword>(0x0), res); | 1623 EXPECT_EQ(static_cast<uword>(0x0), res); |
| 1624 } | 1624 } |
| 1625 | 1625 |
| 1626 | 1626 |
| 1627 ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) { | 1627 ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) { |
| 1628 __ EnterDartFrame(0); |
| 1628 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 1629 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
| 1629 __ movd(XMM0, RAX); | 1630 __ movd(XMM0, RAX); |
| 1630 __ shufps(XMM0, XMM0, Immediate(0x0)); | 1631 __ shufps(XMM0, XMM0, Immediate(0x0)); |
| 1631 __ negateps(XMM0); | 1632 __ negateps(XMM0); |
| 1632 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. | 1633 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. |
| 1634 __ LeaveFrameWithPP(); |
| 1633 __ ret(); | 1635 __ ret(); |
| 1634 } | 1636 } |
| 1635 | 1637 |
| 1636 | 1638 |
| 1637 ASSEMBLER_TEST_RUN(PackedNegate, test) { | 1639 ASSEMBLER_TEST_RUN(PackedNegate, test) { |
| 1638 typedef float (*PackedNegateCode)(); | 1640 typedef float (*PackedNegateCode)(); |
| 1639 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); | 1641 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); |
| 1640 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); | 1642 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); |
| 1641 } | 1643 } |
| 1642 | 1644 |
| 1643 | 1645 |
| 1644 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { | 1646 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { |
| 1647 __ EnterDartFrame(0); |
| 1645 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); | 1648 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); |
| 1646 __ movd(XMM0, RAX); | 1649 __ movd(XMM0, RAX); |
| 1647 __ shufps(XMM0, XMM0, Immediate(0x0)); | 1650 __ shufps(XMM0, XMM0, Immediate(0x0)); |
| 1648 __ absps(XMM0); | 1651 __ absps(XMM0); |
| 1649 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. | 1652 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. |
| 1653 __ LeaveFrameWithPP(); |
| 1650 __ ret(); | 1654 __ ret(); |
| 1651 } | 1655 } |
| 1652 | 1656 |
| 1653 | 1657 |
| 1654 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { | 1658 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { |
| 1655 typedef float (*PackedAbsoluteCode)(); | 1659 typedef float (*PackedAbsoluteCode)(); |
| 1656 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); | 1660 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); |
| 1657 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); | 1661 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); |
| 1658 } | 1662 } |
| 1659 | 1663 |
| 1660 | 1664 |
| 1661 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { | 1665 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { |
| 1666 __ EnterDartFrame(0); |
| 1662 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 1667 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
| 1663 __ zerowps(XMM0); | 1668 __ zerowps(XMM0); |
| 1664 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. | 1669 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. |
| 1670 __ LeaveFrameWithPP(); |
| 1665 __ ret(); | 1671 __ ret(); |
| 1666 } | 1672 } |
| 1667 | 1673 |
| 1668 | 1674 |
| 1669 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { | 1675 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { |
| 1670 typedef float (*PackedSetWZeroCode)(); | 1676 typedef float (*PackedSetWZeroCode)(); |
| 1671 float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())(); | 1677 float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())(); |
| 1672 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); | 1678 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); |
| 1673 } | 1679 } |
| 1674 | 1680 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 | 1777 |
| 1772 | 1778 |
| 1773 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { | 1779 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { |
| 1774 static const struct ALIGN16 { | 1780 static const struct ALIGN16 { |
| 1775 uint32_t a; | 1781 uint32_t a; |
| 1776 uint32_t b; | 1782 uint32_t b; |
| 1777 uint32_t c; | 1783 uint32_t c; |
| 1778 uint32_t d; | 1784 uint32_t d; |
| 1779 } constant1 = | 1785 } constant1 = |
| 1780 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; | 1786 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; |
| 1781 __ movq(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); | 1787 __ EnterDartFrame(0); |
| 1788 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP); |
| 1782 __ movups(XMM9, Address(RAX, 0)); | 1789 __ movups(XMM9, Address(RAX, 0)); |
| 1783 __ notps(XMM9); | 1790 __ notps(XMM9); |
| 1784 __ movaps(XMM0, XMM9); | 1791 __ movaps(XMM0, XMM9); |
| 1785 __ pushq(RAX); | 1792 __ pushq(RAX); |
| 1786 __ movss(Address(RSP, 0), XMM0); | 1793 __ movss(Address(RSP, 0), XMM0); |
| 1787 __ popq(RAX); | 1794 __ popq(RAX); |
| 1795 __ LeaveFrameWithPP(); |
| 1788 __ ret(); | 1796 __ ret(); |
| 1789 } | 1797 } |
| 1790 | 1798 |
| 1791 | 1799 |
| 1792 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { | 1800 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { |
| 1793 typedef uint32_t (*PackedLogicalNotCode)(); | 1801 typedef uint32_t (*PackedLogicalNotCode)(); |
| 1794 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); | 1802 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); |
| 1795 EXPECT_EQ(static_cast<uword>(0x0), res); | 1803 EXPECT_EQ(static_cast<uword>(0x0), res); |
| 1796 } | 1804 } |
| 1797 | 1805 |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8); | 2540 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8); |
| 2533 EXPECT_EQ(12.0, res); | 2541 EXPECT_EQ(12.0, res); |
| 2534 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); | 2542 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); |
| 2535 EXPECT_EQ(-12.0, res); | 2543 EXPECT_EQ(-12.0, res); |
| 2536 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); | 2544 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); |
| 2537 EXPECT_EQ(-12.0, res); | 2545 EXPECT_EQ(-12.0, res); |
| 2538 } | 2546 } |
| 2539 | 2547 |
| 2540 | 2548 |
| 2541 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { | 2549 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { |
| 2550 __ EnterDartFrame(0); |
| 2542 __ DoubleAbs(XMM0); | 2551 __ DoubleAbs(XMM0); |
| 2552 __ LeaveFrameWithPP(); |
| 2543 __ ret(); | 2553 __ ret(); |
| 2544 } | 2554 } |
| 2545 | 2555 |
| 2546 | 2556 |
| 2547 ASSEMBLER_TEST_RUN(DoubleAbs, test) { | 2557 ASSEMBLER_TEST_RUN(DoubleAbs, test) { |
| 2548 typedef double (*DoubleAbsCode)(double d); | 2558 typedef double (*DoubleAbsCode)(double d); |
| 2549 double val = -12.45; | 2559 double val = -12.45; |
| 2550 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); | 2560 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); |
| 2551 EXPECT_FLOAT_EQ(-val, res, 0.001); | 2561 EXPECT_FLOAT_EQ(-val, res, 0.001); |
| 2552 val = 12.45; | 2562 val = 12.45; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 EXPECT_EQ(1, res); // Greater equal. | 2646 EXPECT_EQ(1, res); // Greater equal. |
| 2637 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); | 2647 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); |
| 2638 EXPECT_EQ(1, res); // Greater equal. | 2648 EXPECT_EQ(1, res); // Greater equal. |
| 2639 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); | 2649 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); |
| 2640 EXPECT_EQ(-1, res); // Less. | 2650 EXPECT_EQ(-1, res); // Less. |
| 2641 } | 2651 } |
| 2642 | 2652 |
| 2643 } // namespace dart | 2653 } // namespace dart |
| 2644 | 2654 |
| 2645 #endif // defined TARGET_ARCH_X64 | 2655 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |