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

Side by Side Diff: src/x64/assembler-x64.h

Issue 205343013: Introduce andp, notp, orp and xorp for x64 port (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased with bleeding_edge Created 6 years, 9 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 | « no previous file | src/x64/assembler-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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 static uint64_t cross_compile_; 504 static uint64_t cross_compile_;
505 505
506 friend class ExternalReference; 506 friend class ExternalReference;
507 friend class PlatformFeatureScope; 507 friend class PlatformFeatureScope;
508 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); 508 DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
509 }; 509 };
510 510
511 511
512 #define ASSEMBLER_INSTRUCTION_LIST(V) \ 512 #define ASSEMBLER_INSTRUCTION_LIST(V) \
513 V(add) \ 513 V(add) \
514 V(and) \
514 V(cmp) \ 515 V(cmp) \
515 V(dec) \ 516 V(dec) \
516 V(idiv) \ 517 V(idiv) \
517 V(imul) \ 518 V(imul) \
518 V(inc) \ 519 V(inc) \
519 V(lea) \ 520 V(lea) \
520 V(mov) \ 521 V(mov) \
521 V(movzxb) \ 522 V(movzxb) \
522 V(movzxw) \ 523 V(movzxw) \
523 V(neg) \ 524 V(neg) \
525 V(not) \
526 V(or) \
524 V(repmovs) \ 527 V(repmovs) \
525 V(sbb) \ 528 V(sbb) \
526 V(sub) \ 529 V(sub) \
527 V(test) \ 530 V(test) \
528 V(xchg) 531 V(xchg) \
532 V(xor)
529 533
530 534
531 class Assembler : public AssemblerBase { 535 class Assembler : public AssemblerBase {
532 private: 536 private:
533 // We check before assembling an instruction that there is sufficient 537 // We check before assembling an instruction that there is sufficient
534 // space to write an instruction and its relocation information. 538 // space to write an instruction and its relocation information.
535 // The relocation writer's position must be kGap bytes above the end of 539 // The relocation writer's position must be kGap bytes above the end of
536 // the generated instructions. This leaves enough space for the 540 // the generated instructions. This leaves enough space for the
537 // longest possible x64 instruction, 15 bytes, and the longest possible 541 // longest possible x64 instruction, 15 bytes, and the longest possible
538 // relocation information encoding, RelocInfoWriter::kMaxLength == 16. 542 // relocation information encoding, RelocInfoWriter::kMaxLength == 16.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 // 671 //
668 // If we need versions of an assembly instruction that operate on different 672 // If we need versions of an assembly instruction that operate on different
669 // width arguments, we add a single-letter suffix specifying the width. 673 // width arguments, we add a single-letter suffix specifying the width.
670 // This is done for the following instructions: mov, cmp, inc, dec, 674 // This is done for the following instructions: mov, cmp, inc, dec,
671 // add, sub, and test. 675 // add, sub, and test.
672 // There are no versions of these instructions without the suffix. 676 // There are no versions of these instructions without the suffix.
673 // - Instructions on 8-bit (byte) operands/registers have a trailing 'b'. 677 // - Instructions on 8-bit (byte) operands/registers have a trailing 'b'.
674 // - Instructions on 16-bit (word) operands/registers have a trailing 'w'. 678 // - Instructions on 16-bit (word) operands/registers have a trailing 'w'.
675 // - Instructions on 32-bit (doubleword) operands/registers use 'l'. 679 // - Instructions on 32-bit (doubleword) operands/registers use 'l'.
676 // - Instructions on 64-bit (quadword) operands/registers use 'q'. 680 // - Instructions on 64-bit (quadword) operands/registers use 'q'.
677 // 681 // - Instructions on operands/registers with pointer size use 'p'.
678 // Some mnemonics, such as "and", are the same as C++ keywords.
679 // Naming conflicts with C++ keywords are resolved by adding a trailing '_'.
680 682
681 #define DECLARE_INSTRUCTION(instruction) \ 683 #define DECLARE_INSTRUCTION(instruction) \
682 template<class P1> \ 684 template<class P1> \
683 void instruction##p(P1 p1) { \ 685 void instruction##p(P1 p1) { \
684 emit_##instruction(p1, kPointerSize); \ 686 emit_##instruction(p1, kPointerSize); \
685 } \ 687 } \
686 \ 688 \
687 template<class P1> \ 689 template<class P1> \
688 void instruction##l(P1 p1) { \ 690 void instruction##l(P1 p1) { \
689 emit_##instruction(p1, kInt32Size); \ 691 emit_##instruction(p1, kInt32Size); \
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } 834 }
833 835
834 void cmpw(Register dst, Register src) { 836 void cmpw(Register dst, Register src) {
835 arithmetic_op_16(0x3B, dst, src); 837 arithmetic_op_16(0x3B, dst, src);
836 } 838 }
837 839
838 void cmpw(const Operand& dst, Register src) { 840 void cmpw(const Operand& dst, Register src) {
839 arithmetic_op_16(0x39, src, dst); 841 arithmetic_op_16(0x39, src, dst);
840 } 842 }
841 843
842 void and_(Register dst, Register src) {
843 arithmetic_op(0x23, dst, src);
844 }
845
846 void and_(Register dst, const Operand& src) {
847 arithmetic_op(0x23, dst, src);
848 }
849
850 void and_(const Operand& dst, Register src) {
851 arithmetic_op(0x21, src, dst);
852 }
853
854 void and_(Register dst, Immediate src) {
855 immediate_arithmetic_op(0x4, dst, src);
856 }
857
858 void and_(const Operand& dst, Immediate src) {
859 immediate_arithmetic_op(0x4, dst, src);
860 }
861
862 void andl(Register dst, Immediate src) {
863 immediate_arithmetic_op_32(0x4, dst, src);
864 }
865
866 void andl(Register dst, Register src) {
867 arithmetic_op_32(0x23, dst, src);
868 }
869
870 void andl(Register dst, const Operand& src) {
871 arithmetic_op_32(0x23, dst, src);
872 }
873
874 void andb(Register dst, Immediate src) { 844 void andb(Register dst, Immediate src) {
875 immediate_arithmetic_op_8(0x4, dst, src); 845 immediate_arithmetic_op_8(0x4, dst, src);
876 } 846 }
877 847
878 void decb(Register dst); 848 void decb(Register dst);
879 void decb(const Operand& dst); 849 void decb(const Operand& dst);
880 850
881 // Sign-extends rax into rdx:rax. 851 // Sign-extends rax into rdx:rax.
882 void cqo(); 852 void cqo();
883 // Sign-extends eax into edx:eax. 853 // Sign-extends eax into edx:eax.
884 void cdq(); 854 void cdq();
885 855
886 // Multiply rax by src, put the result in rdx:rax. 856 // Multiply rax by src, put the result in rdx:rax.
887 void mul(Register src); 857 void mul(Register src);
888 858
889 void not_(Register dst);
890 void not_(const Operand& dst);
891 void notl(Register dst);
892
893 void or_(Register dst, Register src) {
894 arithmetic_op(0x0B, dst, src);
895 }
896
897 void orl(Register dst, Register src) {
898 arithmetic_op_32(0x0B, dst, src);
899 }
900
901 void or_(Register dst, const Operand& src) {
902 arithmetic_op(0x0B, dst, src);
903 }
904
905 void orl(Register dst, const Operand& src) {
906 arithmetic_op_32(0x0B, dst, src);
907 }
908
909 void or_(const Operand& dst, Register src) {
910 arithmetic_op(0x09, src, dst);
911 }
912
913 void orl(const Operand& dst, Register src) {
914 arithmetic_op_32(0x09, src, dst);
915 }
916
917 void or_(Register dst, Immediate src) {
918 immediate_arithmetic_op(0x1, dst, src);
919 }
920
921 void orl(Register dst, Immediate src) {
922 immediate_arithmetic_op_32(0x1, dst, src);
923 }
924
925 void or_(const Operand& dst, Immediate src) {
926 immediate_arithmetic_op(0x1, dst, src);
927 }
928
929 void orl(const Operand& dst, Immediate src) {
930 immediate_arithmetic_op_32(0x1, dst, src);
931 }
932
933 void rcl(Register dst, Immediate imm8) { 859 void rcl(Register dst, Immediate imm8) {
934 shift(dst, imm8, 0x2); 860 shift(dst, imm8, 0x2);
935 } 861 }
936 862
937 void rol(Register dst, Immediate imm8) { 863 void rol(Register dst, Immediate imm8) {
938 shift(dst, imm8, 0x0); 864 shift(dst, imm8, 0x0);
939 } 865 }
940 866
941 void roll(Register dst, Immediate imm8) { 867 void roll(Register dst, Immediate imm8) {
942 shift_32(dst, imm8, 0x0); 868 shift_32(dst, imm8, 0x0);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 949
1024 void subb(Register dst, Immediate src) { 950 void subb(Register dst, Immediate src) {
1025 immediate_arithmetic_op_8(0x5, dst, src); 951 immediate_arithmetic_op_8(0x5, dst, src);
1026 } 952 }
1027 953
1028 void testb(Register dst, Register src); 954 void testb(Register dst, Register src);
1029 void testb(Register reg, Immediate mask); 955 void testb(Register reg, Immediate mask);
1030 void testb(const Operand& op, Immediate mask); 956 void testb(const Operand& op, Immediate mask);
1031 void testb(const Operand& op, Register reg); 957 void testb(const Operand& op, Register reg);
1032 958
1033 void xor_(Register dst, Register src) {
1034 if (dst.code() == src.code()) {
1035 arithmetic_op_32(0x33, dst, src);
1036 } else {
1037 arithmetic_op(0x33, dst, src);
1038 }
1039 }
1040
1041 void xorl(Register dst, Register src) {
1042 arithmetic_op_32(0x33, dst, src);
1043 }
1044
1045 void xorl(Register dst, const Operand& src) {
1046 arithmetic_op_32(0x33, dst, src);
1047 }
1048
1049 void xorl(Register dst, Immediate src) {
1050 immediate_arithmetic_op_32(0x6, dst, src);
1051 }
1052
1053 void xorl(const Operand& dst, Register src) {
1054 arithmetic_op_32(0x31, src, dst);
1055 }
1056
1057 void xorl(const Operand& dst, Immediate src) {
1058 immediate_arithmetic_op_32(0x6, dst, src);
1059 }
1060
1061 void xor_(Register dst, const Operand& src) {
1062 arithmetic_op(0x33, dst, src);
1063 }
1064
1065 void xor_(const Operand& dst, Register src) {
1066 arithmetic_op(0x31, src, dst);
1067 }
1068
1069 void xor_(Register dst, Immediate src) {
1070 immediate_arithmetic_op(0x6, dst, src);
1071 }
1072
1073 void xor_(const Operand& dst, Immediate src) {
1074 immediate_arithmetic_op(0x6, dst, src);
1075 }
1076
1077 // Bit operations. 959 // Bit operations.
1078 void bt(const Operand& dst, Register src); 960 void bt(const Operand& dst, Register src);
1079 void bts(const Operand& dst, Register src); 961 void bts(const Operand& dst, Register src);
1080 void bsrl(Register dst, Register src); 962 void bsrl(Register dst, Register src);
1081 963
1082 // Miscellaneous 964 // Miscellaneous
1083 void clc(); 965 void clc();
1084 void cld(); 966 void cld();
1085 void cpuid(); 967 void cpuid();
1086 void hlt(); 968 void hlt();
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 1510
1629 void emit_add(const Operand& dst, Immediate src, int size) { 1511 void emit_add(const Operand& dst, Immediate src, int size) {
1630 if (size == kInt64Size) { 1512 if (size == kInt64Size) {
1631 immediate_arithmetic_op(0x0, dst, src); 1513 immediate_arithmetic_op(0x0, dst, src);
1632 } else { 1514 } else {
1633 ASSERT(size == kInt32Size); 1515 ASSERT(size == kInt32Size);
1634 immediate_arithmetic_op_32(0x0, dst, src); 1516 immediate_arithmetic_op_32(0x0, dst, src);
1635 } 1517 }
1636 } 1518 }
1637 1519
1520 void emit_and(Register dst, Register src, int size) {
1521 if (size == kInt64Size) {
1522 arithmetic_op(0x23, dst, src);
1523 } else {
1524 ASSERT(size == kInt32Size);
1525 arithmetic_op_32(0x23, dst, src);
1526 }
1527 }
1528
1529 void emit_and(Register dst, const Operand& src, int size) {
1530 if (size == kInt64Size) {
1531 arithmetic_op(0x23, dst, src);
1532 } else {
1533 ASSERT(size == kInt32Size);
1534 arithmetic_op_32(0x23, dst, src);
1535 }
1536 }
1537
1538 void emit_and(const Operand& dst, Register src, int size) {
1539 if (size == kInt64Size) {
1540 arithmetic_op(0x21, src, dst);
1541 } else {
1542 ASSERT(size == kInt32Size);
1543 arithmetic_op_32(0x21, src, dst);
1544 }
1545 }
1546
1547 void emit_and(Register dst, Immediate src, int size) {
1548 if (size == kInt64Size) {
1549 immediate_arithmetic_op(0x4, dst, src);
1550 } else {
1551 ASSERT(size == kInt32Size);
1552 immediate_arithmetic_op_32(0x4, dst, src);
1553 }
1554 }
1555
1556 void emit_and(const Operand& dst, Immediate src, int size) {
1557 if (size == kInt64Size) {
1558 immediate_arithmetic_op(0x4, dst, src);
1559 } else {
1560 ASSERT(size == kInt32Size);
1561 immediate_arithmetic_op_32(0x4, dst, src);
1562 }
1563 }
1564
1638 void emit_cmp(Register dst, Register src, int size) { 1565 void emit_cmp(Register dst, Register src, int size) {
1639 if (size == kInt64Size) { 1566 if (size == kInt64Size) {
1640 arithmetic_op(0x3B, dst, src); 1567 arithmetic_op(0x3B, dst, src);
1641 } else { 1568 } else {
1642 ASSERT(size == kInt32Size); 1569 ASSERT(size == kInt32Size);
1643 arithmetic_op_32(0x3B, dst, src); 1570 arithmetic_op_32(0x3B, dst, src);
1644 } 1571 }
1645 } 1572 }
1646 1573
1647 void emit_cmp(Register dst, const Operand& src, int size) { 1574 void emit_cmp(Register dst, const Operand& src, int size) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 void emit_mov(Register dst, Immediate value, int size); 1633 void emit_mov(Register dst, Immediate value, int size);
1707 void emit_mov(const Operand& dst, Immediate value, int size); 1634 void emit_mov(const Operand& dst, Immediate value, int size);
1708 1635
1709 void emit_movzxb(Register dst, const Operand& src, int size); 1636 void emit_movzxb(Register dst, const Operand& src, int size);
1710 void emit_movzxw(Register dst, const Operand& src, int size); 1637 void emit_movzxw(Register dst, const Operand& src, int size);
1711 void emit_movzxw(Register dst, Register src, int size); 1638 void emit_movzxw(Register dst, Register src, int size);
1712 1639
1713 void emit_neg(Register dst, int size); 1640 void emit_neg(Register dst, int size);
1714 void emit_neg(const Operand& dst, int size); 1641 void emit_neg(const Operand& dst, int size);
1715 1642
1643 void emit_not(Register dst, int size);
1644 void emit_not(const Operand& dst, int size);
1645
1646 void emit_or(Register dst, Register src, int size) {
1647 if (size == kInt64Size) {
1648 arithmetic_op(0x0B, dst, src);
1649 } else {
1650 arithmetic_op_32(0x0B, dst, src);
1651 }
1652 }
1653
1654 void emit_or(Register dst, const Operand& src, int size) {
1655 if (size == kInt64Size) {
1656 arithmetic_op(0x0B, dst, src);
1657 } else {
1658 arithmetic_op_32(0x0B, dst, src);
1659 }
1660 }
1661
1662 void emit_or(const Operand& dst, Register src, int size) {
1663 if (size == kInt64Size) {
1664 arithmetic_op(0x9, src, dst);
1665 } else {
1666 arithmetic_op_32(0x9, src, dst);
1667 }
1668 }
1669
1670 void emit_or(Register dst, Immediate src, int size) {
1671 if (size == kInt64Size) {
1672 immediate_arithmetic_op(0x1, dst, src);
1673 } else {
1674 immediate_arithmetic_op_32(0x1, dst, src);
1675 }
1676 }
1677
1678 void emit_or(const Operand& dst, Immediate src, int size) {
1679 if (size == kInt64Size) {
1680 immediate_arithmetic_op(0x1, dst, src);
1681 } else {
1682 immediate_arithmetic_op_32(0x1, dst, src);
1683 }
1684 }
1685
1716 void emit_repmovs(int size); 1686 void emit_repmovs(int size);
1717 1687
1718 void emit_sbb(Register dst, Register src, int size) { 1688 void emit_sbb(Register dst, Register src, int size) {
1719 if (size == kInt64Size) { 1689 if (size == kInt64Size) {
1720 arithmetic_op(0x1b, dst, src); 1690 arithmetic_op(0x1b, dst, src);
1721 } else { 1691 } else {
1722 ASSERT(size == kInt32Size); 1692 ASSERT(size == kInt32Size);
1723 arithmetic_op_32(0x1b, dst, src); 1693 arithmetic_op_32(0x1b, dst, src);
1724 } 1694 }
1725 } 1695 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 } 1740 }
1771 1741
1772 void emit_test(Register dst, Register src, int size); 1742 void emit_test(Register dst, Register src, int size);
1773 void emit_test(Register reg, Immediate mask, int size); 1743 void emit_test(Register reg, Immediate mask, int size);
1774 void emit_test(const Operand& op, Register reg, int size); 1744 void emit_test(const Operand& op, Register reg, int size);
1775 void emit_test(const Operand& op, Immediate mask, int size); 1745 void emit_test(const Operand& op, Immediate mask, int size);
1776 1746
1777 // Exchange two registers 1747 // Exchange two registers
1778 void emit_xchg(Register dst, Register src, int size); 1748 void emit_xchg(Register dst, Register src, int size);
1779 1749
1750 void emit_xor(Register dst, Register src, int size) {
1751 if (size == kInt64Size) {
1752 if (dst.code() == src.code()) {
1753 arithmetic_op_32(0x33, dst, src);
1754 } else {
1755 arithmetic_op(0x33, dst, src);
1756 }
1757 } else {
1758 ASSERT(size == kInt32Size);
1759 arithmetic_op_32(0x33, dst, src);
1760 }
1761 }
1762
1763 void emit_xor(Register dst, const Operand& src, int size) {
1764 if (size == kInt64Size) {
1765 arithmetic_op(0x33, dst, src);
1766 } else {
1767 ASSERT(size == kInt32Size);
1768 arithmetic_op_32(0x33, dst, src);
1769 }
1770 }
1771
1772 void emit_xor(Register dst, Immediate src, int size) {
1773 if (size == kInt64Size) {
1774 immediate_arithmetic_op(0x6, dst, src);
1775 } else {
1776 ASSERT(size == kInt32Size);
1777 immediate_arithmetic_op_32(0x6, dst, src);
1778 }
1779 }
1780
1781 void emit_xor(const Operand& dst, Immediate src, int size) {
1782 if (size == kInt64Size) {
1783 immediate_arithmetic_op(0x6, dst, src);
1784 } else {
1785 ASSERT(size == kInt32Size);
1786 immediate_arithmetic_op_32(0x6, dst, src);
1787 }
1788 }
1789
1790 void emit_xor(const Operand& dst, Register src, int size) {
1791 if (size == kInt64Size) {
1792 arithmetic_op(0x31, src, dst);
1793 } else {
1794 ASSERT(size == kInt32Size);
1795 arithmetic_op_32(0x31, src, dst);
1796 }
1797 }
1798
1780 friend class CodePatcher; 1799 friend class CodePatcher;
1781 friend class EnsureSpace; 1800 friend class EnsureSpace;
1782 friend class RegExpMacroAssemblerX64; 1801 friend class RegExpMacroAssemblerX64;
1783 1802
1784 // code generation 1803 // code generation
1785 RelocInfoWriter reloc_info_writer; 1804 RelocInfoWriter reloc_info_writer;
1786 1805
1787 List< Handle<Code> > code_targets_; 1806 List< Handle<Code> > code_targets_;
1788 1807
1789 PositionsRecorder positions_recorder_; 1808 PositionsRecorder positions_recorder_;
(...skipping 24 matching lines...) Expand all
1814 private: 1833 private:
1815 Assembler* assembler_; 1834 Assembler* assembler_;
1816 #ifdef DEBUG 1835 #ifdef DEBUG
1817 int space_before_; 1836 int space_before_;
1818 #endif 1837 #endif
1819 }; 1838 };
1820 1839
1821 } } // namespace v8::internal 1840 } } // namespace v8::internal
1822 1841
1823 #endif // V8_X64_ASSEMBLER_X64_H_ 1842 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « no previous file | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698