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

Side by Side Diff: src/IceAssemblerX86BaseImpl.h

Issue 1224173006: Adds the x86-64 assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Introduces the X8664 assembler and tests. No REX support yet. Created 5 years, 5 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
OLDNEW
1 //===- subzero/src/IceAssemblerX86BaseImpl.h - base x86 assembler -*- C++ -*-=// 1 //===- subzero/src/IceAssemblerX86BaseImpl.h - base x86 assembler -*- C++ -*-=//
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 // 5 //
6 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // The Subzero Code Generator 10 // The Subzero Code Generator
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 emitUint8(0x58 + reg); 141 emitUint8(0x58 + reg);
142 } 142 }
143 143
144 template <class Machine> 144 template <class Machine>
145 void AssemblerX86Base<Machine>::popl(const typename Traits::Address &address) { 145 void AssemblerX86Base<Machine>::popl(const typename Traits::Address &address) {
146 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 146 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
147 emitUint8(0x8F); 147 emitUint8(0x8F);
148 emitOperand(0, address); 148 emitOperand(0, address);
149 } 149 }
150 150
151 template <class Machine> void AssemblerX86Base<Machine>::pushal() { 151 template <class Machine>
152 template <typename, typename>
153 void AssemblerX86Base<Machine>::pushal() {
152 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 154 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
153 emitUint8(0x60); 155 emitUint8(0x60);
154 } 156 }
155 157
156 template <class Machine> void AssemblerX86Base<Machine>::popal() { 158 template <class Machine>
159 template <typename, typename>
160 void AssemblerX86Base<Machine>::popal() {
157 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 161 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
158 emitUint8(0x61); 162 emitUint8(0x61);
159 } 163 }
160 164
161 template <class Machine> 165 template <class Machine>
162 void AssemblerX86Base<Machine>::setcc(typename Traits::Cond::BrCond condition, 166 void AssemblerX86Base<Machine>::setcc(typename Traits::Cond::BrCond condition,
163 typename Traits::ByteRegister dst) { 167 typename Traits::ByteRegister dst) {
164 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 168 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
165 emitUint8(0x0F); 169 emitUint8(0x0F);
166 emitUint8(0x90 + condition); 170 emitUint8(0x90 + condition);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 void AssemblerX86Base<Machine>::divss(Type Ty, typename Traits::XmmRegister dst, 526 void AssemblerX86Base<Machine>::divss(Type Ty, typename Traits::XmmRegister dst,
523 const typename Traits::Address &src) { 527 const typename Traits::Address &src) {
524 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 528 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
525 emitUint8(isFloat32Asserting32Or64(Ty) ? 0xF3 : 0xF2); 529 emitUint8(isFloat32Asserting32Or64(Ty) ? 0xF3 : 0xF2);
526 emitUint8(0x0F); 530 emitUint8(0x0F);
527 emitUint8(0x5E); 531 emitUint8(0x5E);
528 emitOperand(dst, src); 532 emitOperand(dst, src);
529 } 533 }
530 534
531 template <class Machine> 535 template <class Machine>
532 void AssemblerX86Base<Machine>::fld(Type Ty, 536 template <typename T, typename>
533 const typename Traits::Address &src) { 537 void AssemblerX86Base<Machine>::fld(Type Ty, const typename T::Address &src) {
534 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 538 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
535 emitUint8(isFloat32Asserting32Or64(Ty) ? 0xD9 : 0xDD); 539 emitUint8(isFloat32Asserting32Or64(Ty) ? 0xD9 : 0xDD);
536 emitOperand(0, src); 540 emitOperand(0, src);
537 } 541 }
538 542
539 template <class Machine> 543 template <class Machine>
540 void AssemblerX86Base<Machine>::fstp(Type Ty, 544 template <typename T, typename>
541 const typename Traits::Address &dst) { 545 void AssemblerX86Base<Machine>::fstp(Type Ty, const typename T::Address &dst) {
542 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 546 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
543 emitUint8(isFloat32Asserting32Or64(Ty) ? 0xD9 : 0xDD); 547 emitUint8(isFloat32Asserting32Or64(Ty) ? 0xD9 : 0xDD);
544 emitOperand(3, dst); 548 emitOperand(3, dst);
545 } 549 }
546 550
547 template <class Machine> 551 template <class Machine>
548 void AssemblerX86Base<Machine>::fstp(typename Traits::X87STRegister st) { 552 template <typename T, typename>
553 void AssemblerX86Base<Machine>::fstp(typename T::X87STRegister st) {
549 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 554 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
550 emitUint8(0xDD); 555 emitUint8(0xDD);
551 emitUint8(0xD8 + st); 556 emitUint8(0xD8 + st);
552 } 557 }
553 558
554 template <class Machine> 559 template <class Machine>
555 void AssemblerX86Base<Machine>::movaps(typename Traits::XmmRegister dst, 560 void AssemblerX86Base<Machine>::movaps(typename Traits::XmmRegister dst,
556 typename Traits::XmmRegister src) { 561 typename Traits::XmmRegister src) {
557 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 562 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
558 emitUint8(0x0F); 563 emitUint8(0x0F);
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 emitUint8(0x66); 1773 emitUint8(0x66);
1769 emitUint8(0x0F); 1774 emitUint8(0x0F);
1770 emitUint8(0x3A); 1775 emitUint8(0x3A);
1771 emitUint8(0x0B); 1776 emitUint8(0x0B);
1772 emitXmmRegisterOperand(dst, src); 1777 emitXmmRegisterOperand(dst, src);
1773 // Mask precision exeption. 1778 // Mask precision exeption.
1774 emitUint8(static_cast<uint8_t>(mode) | 0x8); 1779 emitUint8(static_cast<uint8_t>(mode) | 0x8);
1775 } 1780 }
1776 1781
1777 template <class Machine> 1782 template <class Machine>
1778 void AssemblerX86Base<Machine>::fnstcw(const typename Traits::Address &dst) { 1783 template <typename T, typename>
1784 void AssemblerX86Base<Machine>::fnstcw(const typename T::Address &dst) {
1779 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 1785 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1780 emitUint8(0xD9); 1786 emitUint8(0xD9);
1781 emitOperand(7, dst); 1787 emitOperand(7, dst);
1782 } 1788 }
1783 1789
1784 template <class Machine> 1790 template <class Machine>
1785 void AssemblerX86Base<Machine>::fldcw(const typename Traits::Address &src) { 1791 template <typename T, typename>
1792 void AssemblerX86Base<Machine>::fldcw(const typename T::Address &src) {
1786 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 1793 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1787 emitUint8(0xD9); 1794 emitUint8(0xD9);
1788 emitOperand(5, src); 1795 emitOperand(5, src);
1789 } 1796 }
1790 1797
1791 template <class Machine> 1798 template <class Machine>
1792 void AssemblerX86Base<Machine>::fistpl(const typename Traits::Address &dst) { 1799 template <typename T, typename>
1800 void AssemblerX86Base<Machine>::fistpl(const typename T::Address &dst) {
1793 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 1801 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1794 emitUint8(0xDF); 1802 emitUint8(0xDF);
1795 emitOperand(7, dst); 1803 emitOperand(7, dst);
1796 } 1804 }
1797 1805
1798 template <class Machine> 1806 template <class Machine>
1799 void AssemblerX86Base<Machine>::fistps(const typename Traits::Address &dst) { 1807 template <typename T, typename>
1808 void AssemblerX86Base<Machine>::fistps(const typename T::Address &dst) {
1800 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 1809 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1801 emitUint8(0xDB); 1810 emitUint8(0xDB);
1802 emitOperand(3, dst); 1811 emitOperand(3, dst);
1803 } 1812 }
1804 1813
1805 template <class Machine> 1814 template <class Machine>
1806 void AssemblerX86Base<Machine>::fildl(const typename Traits::Address &src) { 1815 template <typename T, typename>
1816 void AssemblerX86Base<Machine>::fildl(const typename T::Address &src) {
1807 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 1817 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1808 emitUint8(0xDF); 1818 emitUint8(0xDF);
1809 emitOperand(5, src); 1819 emitOperand(5, src);
1810 } 1820 }
1811 1821
1812 template <class Machine> 1822 template <class Machine>
1813 void AssemblerX86Base<Machine>::filds(const typename Traits::Address &src) { 1823 template <typename T, typename>
1824 void AssemblerX86Base<Machine>::filds(const typename T::Address &src) {
1814 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 1825 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1815 emitUint8(0xDB); 1826 emitUint8(0xDB);
1816 emitOperand(0, src); 1827 emitOperand(0, src);
1817 } 1828 }
1818 1829
1819 template <class Machine> void AssemblerX86Base<Machine>::fincstp() { 1830 template <class Machine>
1831 template <typename, typename>
1832 void AssemblerX86Base<Machine>::fincstp() {
1820 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 1833 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1821 emitUint8(0xD9); 1834 emitUint8(0xD9);
1822 emitUint8(0xF7); 1835 emitUint8(0xF7);
1823 } 1836 }
1824 1837
1825 template <class Machine> 1838 template <class Machine>
1826 template <uint32_t Tag> 1839 template <uint32_t Tag>
1827 void AssemblerX86Base<Machine>::arith_int(Type Ty, 1840 void AssemblerX86Base<Machine>::arith_int(Type Ty,
1828 typename Traits::GPRRegister reg, 1841 typename Traits::GPRRegister reg,
1829 const Immediate &imm) { 1842 const Immediate &imm) {
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 if (Ty == IceType_i16) 2406 if (Ty == IceType_i16)
2394 emitOperandSizeOverride(); 2407 emitOperandSizeOverride();
2395 if (isByteSizedArithType(Ty)) 2408 if (isByteSizedArithType(Ty))
2396 emitUint8(0xF6); 2409 emitUint8(0xF6);
2397 else 2410 else
2398 emitUint8(0xF7); 2411 emitUint8(0xF7);
2399 emitOperand(4, address); 2412 emitOperand(4, address);
2400 } 2413 }
2401 2414
2402 template <class Machine> 2415 template <class Machine>
2416 template <typename, typename>
2403 void AssemblerX86Base<Machine>::incl(typename Traits::GPRRegister reg) { 2417 void AssemblerX86Base<Machine>::incl(typename Traits::GPRRegister reg) {
2404 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 2418 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2405 emitUint8(0x40 + reg); 2419 emitUint8(0x40 + reg);
2406 } 2420 }
2407 2421
2408 template <class Machine> 2422 template <class Machine>
2409 void AssemblerX86Base<Machine>::incl(const typename Traits::Address &address) { 2423 void AssemblerX86Base<Machine>::incl(const typename Traits::Address &address) {
2410 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 2424 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2411 emitUint8(0xFF); 2425 emitUint8(0xFF);
2412 emitOperand(0, address); 2426 emitOperand(0, address);
2413 } 2427 }
2414 2428
2415 template <class Machine> 2429 template <class Machine>
2430 template <typename, typename>
2416 void AssemblerX86Base<Machine>::decl(typename Traits::GPRRegister reg) { 2431 void AssemblerX86Base<Machine>::decl(typename Traits::GPRRegister reg) {
2417 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 2432 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2418 emitUint8(0x48 + reg); 2433 emitUint8(0x48 + reg);
2419 } 2434 }
2420 2435
2421 template <class Machine> 2436 template <class Machine>
2422 void AssemblerX86Base<Machine>::decl(const typename Traits::Address &address) { 2437 void AssemblerX86Base<Machine>::decl(const typename Traits::Address &address) {
2423 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 2438 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2424 emitUint8(0xFF); 2439 emitUint8(0xFF);
2425 emitOperand(1, address); 2440 emitOperand(1, address);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 assert(shifter == Traits::Encoded_Reg_Counter); 3115 assert(shifter == Traits::Encoded_Reg_Counter);
3101 (void)shifter; 3116 (void)shifter;
3102 if (Ty == IceType_i16) 3117 if (Ty == IceType_i16)
3103 emitOperandSizeOverride(); 3118 emitOperandSizeOverride();
3104 emitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3); 3119 emitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3);
3105 emitOperand(rm, operand); 3120 emitOperand(rm, operand);
3106 } 3121 }
3107 3122
3108 } // end of namespace X86Internal 3123 } // end of namespace X86Internal
3109 } // end of namespace Ice 3124 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698