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

Side by Side Diff: test/cctest/test-assembler-x64.cc

Issue 1040603002: [x64] Introduce BMI instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix previous Patch Set Created 5 years, 8 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
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/test-disasm-x64.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 code->Print(os); 1404 code->Print(os);
1405 #endif 1405 #endif
1406 1406
1407 F7 f = FUNCTION_CAST<F7>(code->entry()); 1407 F7 f = FUNCTION_CAST<F7>(code->entry());
1408 int res = f(1.0, 2.0, 3.0); 1408 int res = f(1.0, 2.0, 3.0);
1409 PrintF("f(1,2,3) = %d\n", res); 1409 PrintF("f(1,2,3) = %d\n", res);
1410 CHECK_EQ(6, res); 1410 CHECK_EQ(6, res);
1411 } 1411 }
1412 1412
1413 1413
1414 TEST(AssemblerX64BMI1) {
1415 CcTest::InitializeVM();
1416 if (!CpuFeatures::IsSupported(BMI1)) return;
1417
1418 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1419 HandleScope scope(isolate);
1420 v8::internal::byte buffer[1024];
1421 MacroAssembler assm(isolate, buffer, sizeof buffer);
1422 {
1423 CpuFeatureScope fscope(&assm, BMI1);
1424 Label exit;
1425
1426 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand
1427 __ pushq(rcx); // For memory operand
1428
1429 // andn
1430 __ movq(rdx, V8_UINT64_C(0x1000000020000000));
1431
1432 __ movl(rax, Immediate(1)); // Test number
1433 __ andnq(r8, rdx, rcx);
1434 __ movq(r9, V8_UINT64_C(0x0122334455667788)); // expected result
1435 __ cmpq(r8, r9);
1436 __ j(not_equal, &exit);
1437
1438 __ incq(rax);
1439 __ andnq(r8, rdx, Operand(rsp, 0));
1440 __ movq(r9, V8_UINT64_C(0x0122334455667788)); // expected result
1441 __ cmpq(r8, r9);
1442 __ j(not_equal, &exit);
1443
1444 __ incq(rax);
1445 __ andnl(r8, rdx, rcx);
1446 __ movq(r9, V8_UINT64_C(0x0000000055667788)); // expected result
1447 __ cmpq(r8, r9);
1448 __ j(not_equal, &exit);
1449
1450 __ incq(rax);
1451 __ andnl(r8, rdx, Operand(rsp, 0));
1452 __ movq(r9, V8_UINT64_C(0x0000000055667788)); // expected result
1453 __ cmpq(r8, r9);
1454 __ j(not_equal, &exit);
1455
1456 // bextr
1457 __ movq(rdx, V8_UINT64_C(0x0000000000002808));
1458
1459 __ incq(rax);
1460 __ bextrq(r8, rcx, rdx);
1461 __ movq(r9, V8_UINT64_C(0x0000003344556677)); // expected result
1462 __ cmpq(r8, r9);
1463 __ j(not_equal, &exit);
1464
1465 __ incq(rax);
1466 __ bextrq(r8, Operand(rsp, 0), rdx);
1467 __ movq(r9, V8_UINT64_C(0x0000003344556677)); // expected result
1468 __ cmpq(r8, r9);
1469 __ j(not_equal, &exit);
1470
1471 __ incq(rax);
1472 __ bextrl(r8, rcx, rdx);
1473 __ movq(r9, V8_UINT64_C(0x0000000000556677)); // expected result
1474 __ cmpq(r8, r9);
1475 __ j(not_equal, &exit);
1476
1477 __ incq(rax);
1478 __ bextrl(r8, Operand(rsp, 0), rdx);
1479 __ movq(r9, V8_UINT64_C(0x0000000000556677)); // expected result
1480 __ cmpq(r8, r9);
1481 __ j(not_equal, &exit);
1482
1483 // blsi
1484 __ incq(rax);
1485 __ blsiq(r8, rcx);
1486 __ movq(r9, V8_UINT64_C(0x0000000000000008)); // expected result
1487 __ cmpq(r8, r9);
1488 __ j(not_equal, &exit);
1489
1490 __ incq(rax);
1491 __ blsiq(r8, Operand(rsp, 0));
1492 __ movq(r9, V8_UINT64_C(0x0000000000000008)); // expected result
1493 __ cmpq(r8, r9);
1494 __ j(not_equal, &exit);
1495
1496 __ incq(rax);
1497 __ blsil(r8, rcx);
1498 __ movq(r9, V8_UINT64_C(0x0000000000000008)); // expected result
1499 __ cmpq(r8, r9);
1500 __ j(not_equal, &exit);
1501
1502 __ incq(rax);
1503 __ blsil(r8, Operand(rsp, 0));
1504 __ movq(r9, V8_UINT64_C(0x0000000000000008)); // expected result
1505 __ cmpq(r8, r9);
1506 __ j(not_equal, &exit);
1507
1508 // blsmsk
1509 __ incq(rax);
1510 __ blsmskq(r8, rcx);
1511 __ movq(r9, V8_UINT64_C(0x000000000000000f)); // expected result
1512 __ cmpq(r8, r9);
1513 __ j(not_equal, &exit);
1514
1515 __ incq(rax);
1516 __ blsmskq(r8, Operand(rsp, 0));
1517 __ movq(r9, V8_UINT64_C(0x000000000000000f)); // expected result
1518 __ cmpq(r8, r9);
1519 __ j(not_equal, &exit);
1520
1521 __ incq(rax);
1522 __ blsmskl(r8, rcx);
1523 __ movq(r9, V8_UINT64_C(0x000000000000000f)); // expected result
1524 __ cmpq(r8, r9);
1525 __ j(not_equal, &exit);
1526
1527 __ incq(rax);
1528 __ blsmskl(r8, Operand(rsp, 0));
1529 __ movq(r9, V8_UINT64_C(0x000000000000000f)); // expected result
1530 __ cmpq(r8, r9);
1531 __ j(not_equal, &exit);
1532
1533 // blsr
1534 __ incq(rax);
1535 __ blsrq(r8, rcx);
1536 __ movq(r9, V8_UINT64_C(0x1122334455667780)); // expected result
1537 __ cmpq(r8, r9);
1538 __ j(not_equal, &exit);
1539
1540 __ incq(rax);
1541 __ blsrq(r8, Operand(rsp, 0));
1542 __ movq(r9, V8_UINT64_C(0x1122334455667780)); // expected result
1543 __ cmpq(r8, r9);
1544 __ j(not_equal, &exit);
1545
1546 __ incq(rax);
1547 __ blsrl(r8, rcx);
1548 __ movq(r9, V8_UINT64_C(0x0000000055667780)); // expected result
1549 __ cmpq(r8, r9);
1550 __ j(not_equal, &exit);
1551
1552 __ incq(rax);
1553 __ blsrl(r8, Operand(rsp, 0));
1554 __ movq(r9, V8_UINT64_C(0x0000000055667780)); // expected result
1555 __ cmpq(r8, r9);
1556 __ j(not_equal, &exit);
1557
1558 // tzcnt
1559 __ incq(rax);
1560 __ tzcntq(r8, rcx);
1561 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result
1562 __ cmpq(r8, r9);
1563 __ j(not_equal, &exit);
1564
1565 __ incq(rax);
1566 __ tzcntq(r8, Operand(rsp, 0));
1567 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result
1568 __ cmpq(r8, r9);
1569 __ j(not_equal, &exit);
1570
1571 __ incq(rax);
1572 __ tzcntl(r8, rcx);
1573 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result
1574 __ cmpq(r8, r9);
1575 __ j(not_equal, &exit);
1576
1577 __ incq(rax);
1578 __ tzcntl(r8, Operand(rsp, 0));
1579 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result
1580 __ cmpq(r8, r9);
1581 __ j(not_equal, &exit);
1582
1583 __ xorl(rax, rax);
1584 __ bind(&exit);
1585 __ popq(rcx);
1586 __ ret(0);
1587 }
1588
1589 CodeDesc desc;
1590 assm.GetCode(&desc);
1591 Handle<Code> code = isolate->factory()->NewCode(
1592 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1593 #ifdef OBJECT_PRINT
1594 OFStream os(stdout);
1595 code->Print(os);
1596 #endif
1597
1598 F0 f = FUNCTION_CAST<F0>(code->entry());
1599 CHECK_EQ(0, f());
1600 }
1601
1602
1603 TEST(AssemblerX64LZCNT) {
1604 CcTest::InitializeVM();
1605 if (!CpuFeatures::IsSupported(LZCNT)) return;
1606
1607 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1608 HandleScope scope(isolate);
1609 v8::internal::byte buffer[256];
1610 MacroAssembler assm(isolate, buffer, sizeof buffer);
1611 {
1612 CpuFeatureScope fscope(&assm, LZCNT);
1613 Label exit;
1614
1615 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand
1616 __ pushq(rcx); // For memory operand
1617
1618 __ movl(rax, Immediate(1)); // Test number
1619 __ lzcntq(r8, rcx);
1620 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result
1621 __ cmpq(r8, r9);
1622 __ j(not_equal, &exit);
1623
1624 __ incq(rax);
1625 __ lzcntq(r8, Operand(rsp, 0));
1626 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result
1627 __ cmpq(r8, r9);
1628 __ j(not_equal, &exit);
1629
1630 __ incq(rax);
1631 __ lzcntl(r8, rcx);
1632 __ movq(r9, V8_UINT64_C(0x0000000000000001)); // expected result
1633 __ cmpq(r8, r9);
1634 __ j(not_equal, &exit);
1635
1636 __ incq(rax);
1637 __ lzcntl(r8, Operand(rsp, 0));
1638 __ movq(r9, V8_UINT64_C(0x0000000000000001)); // expected result
1639 __ cmpq(r8, r9);
1640 __ j(not_equal, &exit);
1641
1642 __ xorl(rax, rax);
1643 __ bind(&exit);
1644 __ popq(rcx);
1645 __ ret(0);
1646 }
1647
1648 CodeDesc desc;
1649 assm.GetCode(&desc);
1650 Handle<Code> code = isolate->factory()->NewCode(
1651 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1652 #ifdef OBJECT_PRINT
1653 OFStream os(stdout);
1654 code->Print(os);
1655 #endif
1656
1657 F0 f = FUNCTION_CAST<F0>(code->entry());
1658 CHECK_EQ(0, f());
1659 }
1660
1661
1662 TEST(AssemblerX64POPCNT) {
1663 CcTest::InitializeVM();
1664 if (!CpuFeatures::IsSupported(POPCNT)) return;
1665
1666 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1667 HandleScope scope(isolate);
1668 v8::internal::byte buffer[256];
1669 MacroAssembler assm(isolate, buffer, sizeof buffer);
1670 {
1671 CpuFeatureScope fscope(&assm, POPCNT);
1672 Label exit;
1673
1674 __ movq(rcx, V8_UINT64_C(0x1111111111111100)); // source operand
1675 __ pushq(rcx); // For memory operand
1676
1677 __ movl(rax, Immediate(1)); // Test number
1678 __ popcntq(r8, rcx);
1679 __ movq(r9, V8_UINT64_C(0x000000000000000e)); // expected result
1680 __ cmpq(r8, r9);
1681 __ j(not_equal, &exit);
1682
1683 __ incq(rax);
1684 __ popcntq(r8, Operand(rsp, 0));
1685 __ movq(r9, V8_UINT64_C(0x000000000000000e)); // expected result
1686 __ cmpq(r8, r9);
1687 __ j(not_equal, &exit);
1688
1689 __ incq(rax);
1690 __ popcntl(r8, rcx);
1691 __ movq(r9, V8_UINT64_C(0x0000000000000006)); // expected result
1692 __ cmpq(r8, r9);
1693 __ j(not_equal, &exit);
1694
1695 __ incq(rax);
1696 __ popcntl(r8, Operand(rsp, 0));
1697 __ movq(r9, V8_UINT64_C(0x0000000000000006)); // expected result
1698 __ cmpq(r8, r9);
1699 __ j(not_equal, &exit);
1700
1701 __ xorl(rax, rax);
1702 __ bind(&exit);
1703 __ popq(rcx);
1704 __ ret(0);
1705 }
1706
1707 CodeDesc desc;
1708 assm.GetCode(&desc);
1709 Handle<Code> code = isolate->factory()->NewCode(
1710 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1711 #ifdef OBJECT_PRINT
1712 OFStream os(stdout);
1713 code->Print(os);
1714 #endif
1715
1716 F0 f = FUNCTION_CAST<F0>(code->entry());
1717 CHECK_EQ(0, f());
1718 }
1719
1720
1721 TEST(AssemblerX64BMI2) {
1722 CcTest::InitializeVM();
1723 if (!CpuFeatures::IsSupported(BMI2)) return;
1724
1725 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1726 HandleScope scope(isolate);
1727 v8::internal::byte buffer[2048];
1728 MacroAssembler assm(isolate, buffer, sizeof buffer);
1729 {
1730 CpuFeatureScope fscope(&assm, BMI2);
1731 Label exit;
1732 __ pushq(rbx); // save rbx
1733 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand
1734 __ pushq(rcx); // For memory operand
1735
1736 // bzhi
1737 __ movq(rdx, V8_UINT64_C(0x0000000000000009));
1738
1739 __ movl(rax, Immediate(1)); // Test number
1740 __ bzhiq(r8, rcx, rdx);
1741 __ movq(r9, V8_UINT64_C(0x0000000000000188)); // expected result
1742 __ cmpq(r8, r9);
1743 __ j(not_equal, &exit);
1744
1745 __ incq(rax);
1746 __ bzhiq(r8, Operand(rsp, 0), rdx);
1747 __ movq(r9, V8_UINT64_C(0x0000000000000188)); // expected result
1748 __ cmpq(r8, r9);
1749 __ j(not_equal, &exit);
1750
1751 __ incq(rax);
1752 __ bzhil(r8, rcx, rdx);
1753 __ movq(r9, V8_UINT64_C(0x0000000000000188)); // expected result
1754 __ cmpq(r8, r9);
1755 __ j(not_equal, &exit);
1756
1757 __ incq(rax);
1758 __ bzhil(r8, Operand(rsp, 0), rdx);
1759 __ movq(r9, V8_UINT64_C(0x0000000000000188)); // expected result
1760 __ cmpq(r8, r9);
1761 __ j(not_equal, &exit);
1762
1763 // mulx
1764 __ movq(rdx, V8_UINT64_C(0x0000000000001000));
1765
1766 __ incq(rax);
1767 __ mulxq(r8, r9, rcx);
1768 __ movq(rbx, V8_UINT64_C(0x0000000000000112)); // expected result
1769 __ cmpq(r8, rbx);
1770 __ j(not_equal, &exit);
1771 __ movq(rbx, V8_UINT64_C(0x2334455667788000)); // expected result
1772 __ cmpq(r9, rbx);
1773 __ j(not_equal, &exit);
1774
1775 __ incq(rax);
1776 __ mulxq(r8, r9, Operand(rsp, 0));
1777 __ movq(rbx, V8_UINT64_C(0x0000000000000112)); // expected result
1778 __ cmpq(r8, rbx);
1779 __ j(not_equal, &exit);
1780 __ movq(rbx, V8_UINT64_C(0x2334455667788000)); // expected result
1781 __ cmpq(r9, rbx);
1782 __ j(not_equal, &exit);
1783
1784 __ incq(rax);
1785 __ mulxl(r8, r9, rcx);
1786 __ movq(rbx, V8_UINT64_C(0x0000000000000556)); // expected result
1787 __ cmpq(r8, rbx);
1788 __ j(not_equal, &exit);
1789 __ movq(rbx, V8_UINT64_C(0x0000000067788000)); // expected result
1790 __ cmpq(r9, rbx);
1791 __ j(not_equal, &exit);
1792
1793 __ incq(rax);
1794 __ mulxl(r8, r9, Operand(rsp, 0));
1795 __ movq(rbx, V8_UINT64_C(0x0000000000000556)); // expected result
1796 __ cmpq(r8, rbx);
1797 __ j(not_equal, &exit);
1798 __ movq(rbx, V8_UINT64_C(0x0000000067788000)); // expected result
1799 __ cmpq(r9, rbx);
1800 __ j(not_equal, &exit);
1801
1802 // pdep
1803 __ movq(rdx, V8_UINT64_C(0xfffffffffffffff0));
1804
1805 __ incq(rax);
1806 __ pdepq(r8, rdx, rcx);
1807 __ movq(r9, V8_UINT64_C(0x1122334455667400)); // expected result
1808 __ cmpq(r8, r9);
1809 __ j(not_equal, &exit);
1810
1811 __ incq(rax);
1812 __ pdepq(r8, rdx, Operand(rsp, 0));
1813 __ movq(r9, V8_UINT64_C(0x1122334455667400)); // expected result
1814 __ cmpq(r8, r9);
1815 __ j(not_equal, &exit);
1816
1817 __ incq(rax);
1818 __ pdepl(r8, rdx, rcx);
1819 __ movq(r9, V8_UINT64_C(0x0000000055667400)); // expected result
1820 __ cmpq(r8, r9);
1821 __ j(not_equal, &exit);
1822
1823 __ incq(rax);
1824 __ pdepl(r8, rdx, Operand(rsp, 0));
1825 __ movq(r9, V8_UINT64_C(0x0000000055667400)); // expected result
1826 __ cmpq(r8, r9);
1827 __ j(not_equal, &exit);
1828
1829 // pext
1830 __ movq(rdx, V8_UINT64_C(0xfffffffffffffff0));
1831
1832 __ incq(rax);
1833 __ pextq(r8, rdx, rcx);
1834 __ movq(r9, V8_UINT64_C(0x0000000003fffffe)); // expected result
1835 __ cmpq(r8, r9);
1836 __ j(not_equal, &exit);
1837
1838 __ incq(rax);
1839 __ pextq(r8, rdx, Operand(rsp, 0));
1840 __ movq(r9, V8_UINT64_C(0x0000000003fffffe)); // expected result
1841 __ cmpq(r8, r9);
1842 __ j(not_equal, &exit);
1843
1844 __ incq(rax);
1845 __ pextl(r8, rdx, rcx);
1846 __ movq(r9, V8_UINT64_C(0x000000000000fffe)); // expected result
1847 __ cmpq(r8, r9);
1848 __ j(not_equal, &exit);
1849
1850 __ incq(rax);
1851 __ pextl(r8, rdx, Operand(rsp, 0));
1852 __ movq(r9, V8_UINT64_C(0x000000000000fffe)); // expected result
1853 __ cmpq(r8, r9);
1854 __ j(not_equal, &exit);
1855
1856 // sarx
1857 __ movq(rdx, V8_UINT64_C(0x0000000000000004));
1858
1859 __ incq(rax);
1860 __ sarxq(r8, rcx, rdx);
1861 __ movq(r9, V8_UINT64_C(0x0112233445566778)); // expected result
1862 __ cmpq(r8, r9);
1863 __ j(not_equal, &exit);
1864
1865 __ incq(rax);
1866 __ sarxq(r8, Operand(rsp, 0), rdx);
1867 __ movq(r9, V8_UINT64_C(0x0112233445566778)); // expected result
1868 __ cmpq(r8, r9);
1869 __ j(not_equal, &exit);
1870
1871 __ incq(rax);
1872 __ sarxl(r8, rcx, rdx);
1873 __ movq(r9, V8_UINT64_C(0x0000000005566778)); // expected result
1874 __ cmpq(r8, r9);
1875 __ j(not_equal, &exit);
1876
1877 __ incq(rax);
1878 __ sarxl(r8, Operand(rsp, 0), rdx);
1879 __ movq(r9, V8_UINT64_C(0x0000000005566778)); // expected result
1880 __ cmpq(r8, r9);
1881 __ j(not_equal, &exit);
1882
1883 // shlx
1884 __ movq(rdx, V8_UINT64_C(0x0000000000000004));
1885
1886 __ incq(rax);
1887 __ shlxq(r8, rcx, rdx);
1888 __ movq(r9, V8_UINT64_C(0x1223344556677880)); // expected result
1889 __ cmpq(r8, r9);
1890 __ j(not_equal, &exit);
1891
1892 __ incq(rax);
1893 __ shlxq(r8, Operand(rsp, 0), rdx);
1894 __ movq(r9, V8_UINT64_C(0x1223344556677880)); // expected result
1895 __ cmpq(r8, r9);
1896 __ j(not_equal, &exit);
1897
1898 __ incq(rax);
1899 __ shlxl(r8, rcx, rdx);
1900 __ movq(r9, V8_UINT64_C(0x0000000056677880)); // expected result
1901 __ cmpq(r8, r9);
1902 __ j(not_equal, &exit);
1903
1904 __ incq(rax);
1905 __ shlxl(r8, Operand(rsp, 0), rdx);
1906 __ movq(r9, V8_UINT64_C(0x0000000056677880)); // expected result
1907 __ cmpq(r8, r9);
1908 __ j(not_equal, &exit);
1909
1910 // shrx
1911 __ movq(rdx, V8_UINT64_C(0x0000000000000004));
1912
1913 __ incq(rax);
1914 __ shrxq(r8, rcx, rdx);
1915 __ movq(r9, V8_UINT64_C(0x0112233445566778)); // expected result
1916 __ cmpq(r8, r9);
1917 __ j(not_equal, &exit);
1918
1919 __ incq(rax);
1920 __ shrxq(r8, Operand(rsp, 0), rdx);
1921 __ movq(r9, V8_UINT64_C(0x0112233445566778)); // expected result
1922 __ cmpq(r8, r9);
1923 __ j(not_equal, &exit);
1924
1925 __ incq(rax);
1926 __ shrxl(r8, rcx, rdx);
1927 __ movq(r9, V8_UINT64_C(0x0000000005566778)); // expected result
1928 __ cmpq(r8, r9);
1929 __ j(not_equal, &exit);
1930
1931 __ incq(rax);
1932 __ shrxl(r8, Operand(rsp, 0), rdx);
1933 __ movq(r9, V8_UINT64_C(0x0000000005566778)); // expected result
1934 __ cmpq(r8, r9);
1935 __ j(not_equal, &exit);
1936
1937 // rorx
1938 __ incq(rax);
1939 __ rorxq(r8, rcx, 0x4);
1940 __ movq(r9, V8_UINT64_C(0x8112233445566778)); // expected result
1941 __ cmpq(r8, r9);
1942 __ j(not_equal, &exit);
1943
1944 __ incq(rax);
1945 __ rorxq(r8, Operand(rsp, 0), 0x4);
1946 __ movq(r9, V8_UINT64_C(0x8112233445566778)); // expected result
1947 __ cmpq(r8, r9);
1948 __ j(not_equal, &exit);
1949
1950 __ incq(rax);
1951 __ rorxl(r8, rcx, 0x4);
1952 __ movq(r9, V8_UINT64_C(0x0000000085566778)); // expected result
1953 __ cmpq(r8, r9);
1954 __ j(not_equal, &exit);
1955
1956 __ incq(rax);
1957 __ rorxl(r8, Operand(rsp, 0), 0x4);
1958 __ movq(r9, V8_UINT64_C(0x0000000085566778)); // expected result
1959 __ cmpq(r8, r9);
1960 __ j(not_equal, &exit);
1961
1962 __ xorl(rax, rax);
1963 __ bind(&exit);
1964 __ popq(rcx);
1965 __ popq(rbx);
1966 __ ret(0);
1967 }
1968
1969 CodeDesc desc;
1970 assm.GetCode(&desc);
1971 Handle<Code> code = isolate->factory()->NewCode(
1972 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1973 #ifdef OBJECT_PRINT
1974 OFStream os(stdout);
1975 code->Print(os);
1976 #endif
1977
1978 F0 f = FUNCTION_CAST<F0>(code->entry());
1979 CHECK_EQ(0, f());
1980 }
1981
1982
1414 TEST(AssemblerX64JumpTables1) { 1983 TEST(AssemblerX64JumpTables1) {
1415 // Test jump tables with forward jumps. 1984 // Test jump tables with forward jumps.
1416 CcTest::InitializeVM(); 1985 CcTest::InitializeVM();
1417 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 1986 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1418 HandleScope scope(isolate); 1987 HandleScope scope(isolate);
1419 MacroAssembler assm(isolate, nullptr, 0); 1988 MacroAssembler assm(isolate, nullptr, 0);
1420 1989
1421 const int kNumCases = 512; 1990 const int kNumCases = 512;
1422 int values[kNumCases]; 1991 int values[kNumCases];
1423 isolate->random_number_generator()->NextBytes(values, sizeof(values)); 1992 isolate->random_number_generator()->NextBytes(values, sizeof(values));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 2068
1500 F1 f = FUNCTION_CAST<F1>(code->entry()); 2069 F1 f = FUNCTION_CAST<F1>(code->entry());
1501 for (int i = 0; i < kNumCases; ++i) { 2070 for (int i = 0; i < kNumCases; ++i) {
1502 int res = f(i); 2071 int res = f(i);
1503 PrintF("f(%d) = %d\n", i, res); 2072 PrintF("f(%d) = %d\n", i, res);
1504 CHECK_EQ(values[i], res); 2073 CHECK_EQ(values[i], res);
1505 } 2074 }
1506 } 2075 }
1507 2076
1508 #undef __ 2077 #undef __
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/test-disasm-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698