Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceAssemblerX86Base.h - base x86 assembler -*- C++ -*---===// | 1 //===- subzero/src/IceAssemblerX86Base.h - base x86 assembler -*- C++ -*---===// |
| 2 // | 2 // |
| 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
| 5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
| 6 // | 6 // |
| 7 // Modified by the Subzero authors. | 7 // Modified by the Subzero authors. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 // | 10 // |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 | 307 |
| 308 TypedEmitRegRegImm RegRegImm; | 308 TypedEmitRegRegImm RegRegImm; |
| 309 TypedEmitRegAddrImm RegAddrImm; | 309 TypedEmitRegAddrImm RegAddrImm; |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 /* | 312 /* |
| 313 * Emit Machine Instructions. | 313 * Emit Machine Instructions. |
| 314 */ | 314 */ |
| 315 void call(typename Traits::GPRRegister reg); | 315 void call(typename Traits::GPRRegister reg); |
| 316 void call(const typename Traits::Address &address); | 316 void call(const typename Traits::Address &address); |
| 317 void call(const ConstantRelocatable *label); | 317 void call(const ConstantRelocatable *label); // not testable. |
| 318 void call(const Immediate &abs_address); | 318 void call(const Immediate &abs_address); |
| 319 | 319 |
| 320 static const intptr_t kCallExternalLabelSize = 5; | 320 static const intptr_t kCallExternalLabelSize = 5; |
| 321 | 321 |
| 322 void pushl(typename Traits::GPRRegister reg); | 322 void pushl(typename Traits::GPRRegister reg); |
| 323 | 323 |
| 324 void popl(typename Traits::GPRRegister reg); | 324 void popl(typename Traits::GPRRegister reg); |
| 325 void popl(const typename Traits::Address &address); | 325 void popl(const typename Traits::Address &address); |
| 326 | 326 |
| 327 template <typename T = Traits, | |
| 328 typename = typename std::enable_if<T::HasPusha>::type> | |
| 327 void pushal(); | 329 void pushal(); |
| 330 template <typename T = Traits, | |
| 331 typename = typename std::enable_if<T::HasPopa>::type> | |
| 328 void popal(); | 332 void popal(); |
| 329 | 333 |
| 330 void setcc(typename Traits::Cond::BrCond condition, | 334 void setcc(typename Traits::Cond::BrCond condition, |
| 331 typename Traits::ByteRegister dst); | 335 typename Traits::ByteRegister dst); |
| 332 void setcc(typename Traits::Cond::BrCond condition, | 336 void setcc(typename Traits::Cond::BrCond condition, |
| 333 const typename Traits::Address &address); | 337 const typename Traits::Address &address); |
| 334 | 338 |
| 335 // All mov() overloads are tested. | |
| 336 void mov(Type Ty, typename Traits::GPRRegister dst, const Immediate &src); | 339 void mov(Type Ty, typename Traits::GPRRegister dst, const Immediate &src); |
| 337 void mov(Type Ty, typename Traits::GPRRegister dst, | 340 void mov(Type Ty, typename Traits::GPRRegister dst, |
| 338 typename Traits::GPRRegister src); | 341 typename Traits::GPRRegister src); |
| 339 void mov(Type Ty, typename Traits::GPRRegister dst, | 342 void mov(Type Ty, typename Traits::GPRRegister dst, |
| 340 const typename Traits::Address &src); | 343 const typename Traits::Address &src); |
| 341 void mov(Type Ty, const typename Traits::Address &dst, | 344 void mov(Type Ty, const typename Traits::Address &dst, |
| 342 typename Traits::GPRRegister src); | 345 typename Traits::GPRRegister src); |
| 343 void mov(Type Ty, const typename Traits::Address &dst, const Immediate &imm); | 346 void mov(Type Ty, const typename Traits::Address &dst, const Immediate &imm); |
| 344 | 347 |
| 345 void movzx(Type Ty, typename Traits::GPRRegister dst, | 348 void movzx(Type Ty, typename Traits::GPRRegister dst, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 | 499 |
| 497 void cmpps(typename Traits::XmmRegister dst, typename Traits::XmmRegister src, | 500 void cmpps(typename Traits::XmmRegister dst, typename Traits::XmmRegister src, |
| 498 typename Traits::Cond::CmppsCond CmpCondition); | 501 typename Traits::Cond::CmppsCond CmpCondition); |
| 499 void cmpps(typename Traits::XmmRegister dst, | 502 void cmpps(typename Traits::XmmRegister dst, |
| 500 const typename Traits::Address &src, | 503 const typename Traits::Address &src, |
| 501 typename Traits::Cond::CmppsCond CmpCondition); | 504 typename Traits::Cond::CmppsCond CmpCondition); |
| 502 | 505 |
| 503 void sqrtps(typename Traits::XmmRegister dst); | 506 void sqrtps(typename Traits::XmmRegister dst); |
| 504 void rsqrtps(typename Traits::XmmRegister dst); | 507 void rsqrtps(typename Traits::XmmRegister dst); |
| 505 void reciprocalps(typename Traits::XmmRegister dst); | 508 void reciprocalps(typename Traits::XmmRegister dst); |
| 509 | |
| 506 void movhlps(typename Traits::XmmRegister dst, | 510 void movhlps(typename Traits::XmmRegister dst, |
| 507 typename Traits::XmmRegister src); | 511 typename Traits::XmmRegister src); |
| 508 void movlhps(typename Traits::XmmRegister dst, | 512 void movlhps(typename Traits::XmmRegister dst, |
| 509 typename Traits::XmmRegister src); | 513 typename Traits::XmmRegister src); |
| 510 void unpcklps(typename Traits::XmmRegister dst, | 514 void unpcklps(typename Traits::XmmRegister dst, |
| 511 typename Traits::XmmRegister src); | 515 typename Traits::XmmRegister src); |
| 512 void unpckhps(typename Traits::XmmRegister dst, | 516 void unpckhps(typename Traits::XmmRegister dst, |
| 513 typename Traits::XmmRegister src); | 517 typename Traits::XmmRegister src); |
| 514 void unpcklpd(typename Traits::XmmRegister dst, | 518 void unpcklpd(typename Traits::XmmRegister dst, |
| 515 typename Traits::XmmRegister src); | 519 typename Traits::XmmRegister src); |
| 516 void unpckhpd(typename Traits::XmmRegister dst, | 520 void unpckhpd(typename Traits::XmmRegister dst, |
| 517 typename Traits::XmmRegister src); | 521 typename Traits::XmmRegister src); |
| 518 | 522 |
| 519 void set1ps(typename Traits::XmmRegister dst, | 523 void set1ps(typename Traits::XmmRegister dst, |
| 520 typename Traits::GPRRegister tmp, const Immediate &imm); | 524 typename Traits::GPRRegister tmp, |
| 521 void shufps(typename Traits::XmmRegister dst, | 525 const Immediate &imm); |
| 522 typename Traits::XmmRegister src, const Immediate &mask); | |
|
jvoung (off chromium)
2015/07/23 17:59:36
oops (on the weird clustering)... is this one even
John
2015/07/27 20:35:57
Yeah, initially I thought about removing the irreg
| |
| 523 | 526 |
| 524 void minpd(typename Traits::XmmRegister dst, | 527 void minpd(typename Traits::XmmRegister dst, |
| 525 typename Traits::XmmRegister src); | 528 typename Traits::XmmRegister src); |
| 526 void maxpd(typename Traits::XmmRegister dst, | 529 void maxpd(typename Traits::XmmRegister dst, |
| 527 typename Traits::XmmRegister src); | 530 typename Traits::XmmRegister src); |
| 528 void sqrtpd(typename Traits::XmmRegister dst); | 531 void sqrtpd(typename Traits::XmmRegister dst); |
| 532 | |
| 529 void shufpd(typename Traits::XmmRegister dst, | 533 void shufpd(typename Traits::XmmRegister dst, |
| 530 typename Traits::XmmRegister src, const Immediate &mask); | 534 typename Traits::XmmRegister src, const Immediate &mask); |
| 531 | 535 |
| 532 void pshufd(Type Ty, typename Traits::XmmRegister dst, | 536 void pshufd(Type Ty, typename Traits::XmmRegister dst, |
| 533 typename Traits::XmmRegister src, const Immediate &mask); | 537 typename Traits::XmmRegister src, const Immediate &mask); |
| 534 void pshufd(Type Ty, typename Traits::XmmRegister dst, | 538 void pshufd(Type Ty, typename Traits::XmmRegister dst, |
| 535 const typename Traits::Address &src, const Immediate &mask); | 539 const typename Traits::Address &src, const Immediate &mask); |
| 540 void shufps(typename Traits::XmmRegister dst, | |
| 541 typename Traits::XmmRegister src, const Immediate &mask); | |
| 536 void shufps(Type Ty, typename Traits::XmmRegister dst, | 542 void shufps(Type Ty, typename Traits::XmmRegister dst, |
| 537 typename Traits::XmmRegister src, const Immediate &mask); | 543 typename Traits::XmmRegister src, const Immediate &mask); |
| 538 void shufps(Type Ty, typename Traits::XmmRegister dst, | 544 void shufps(Type Ty, typename Traits::XmmRegister dst, |
| 539 const typename Traits::Address &src, const Immediate &mask); | 545 const typename Traits::Address &src, const Immediate &mask); |
| 540 | 546 |
| 541 void cvtdq2ps(Type, typename Traits::XmmRegister dst, | 547 void cvtdq2ps(Type, typename Traits::XmmRegister dst, |
| 542 typename Traits::XmmRegister src); | 548 typename Traits::XmmRegister src); |
| 543 void cvtdq2ps(Type, typename Traits::XmmRegister dst, | 549 void cvtdq2ps(Type, typename Traits::XmmRegister dst, |
| 544 const typename Traits::Address &src); | 550 const typename Traits::Address &src); |
| 545 | 551 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 void insertps(Type Ty, typename Traits::XmmRegister dst, | 605 void insertps(Type Ty, typename Traits::XmmRegister dst, |
| 600 const typename Traits::Address &src, const Immediate &imm); | 606 const typename Traits::Address &src, const Immediate &imm); |
| 601 | 607 |
| 602 void pinsr(Type Ty, typename Traits::XmmRegister dst, | 608 void pinsr(Type Ty, typename Traits::XmmRegister dst, |
| 603 typename Traits::GPRRegister src, const Immediate &imm); | 609 typename Traits::GPRRegister src, const Immediate &imm); |
| 604 void pinsr(Type Ty, typename Traits::XmmRegister dst, | 610 void pinsr(Type Ty, typename Traits::XmmRegister dst, |
| 605 const typename Traits::Address &src, const Immediate &imm); | 611 const typename Traits::Address &src, const Immediate &imm); |
| 606 | 612 |
| 607 void pextr(Type Ty, typename Traits::GPRRegister dst, | 613 void pextr(Type Ty, typename Traits::GPRRegister dst, |
| 608 typename Traits::XmmRegister src, const Immediate &imm); | 614 typename Traits::XmmRegister src, const Immediate &imm); |
| 615 // The following overload is not implemented. | |
| 609 void pextr(Type Ty, typename Traits::GPRRegister dst, | 616 void pextr(Type Ty, typename Traits::GPRRegister dst, |
|
jvoung (off chromium)
2015/07/23 17:59:35
I think just delete it then, and we can add it bac
| |
| 610 const typename Traits::Address &src, const Immediate &imm); | 617 const typename Traits::Address &src, const Immediate &imm); |
| 611 | 618 |
| 612 void pmovsxdq(typename Traits::XmmRegister dst, | 619 void pmovsxdq(typename Traits::XmmRegister dst, |
| 613 typename Traits::XmmRegister src); | 620 typename Traits::XmmRegister src); |
| 614 | 621 |
| 615 void pcmpeq(Type Ty, typename Traits::XmmRegister dst, | 622 void pcmpeq(Type Ty, typename Traits::XmmRegister dst, |
| 616 typename Traits::XmmRegister src); | 623 typename Traits::XmmRegister src); |
| 617 void pcmpeq(Type Ty, typename Traits::XmmRegister dst, | 624 void pcmpeq(Type Ty, typename Traits::XmmRegister dst, |
| 618 const typename Traits::Address &src); | 625 const typename Traits::Address &src); |
| 619 void pcmpgt(Type Ty, typename Traits::XmmRegister dst, | 626 void pcmpgt(Type Ty, typename Traits::XmmRegister dst, |
| 620 typename Traits::XmmRegister src); | 627 typename Traits::XmmRegister src); |
| 621 void pcmpgt(Type Ty, typename Traits::XmmRegister dst, | 628 void pcmpgt(Type Ty, typename Traits::XmmRegister dst, |
| 622 const typename Traits::Address &src); | 629 const typename Traits::Address &src); |
| 623 | 630 |
| 624 enum RoundingMode { | 631 enum RoundingMode { |
| 625 kRoundToNearest = 0x0, | 632 kRoundToNearest = 0x0, |
| 626 kRoundDown = 0x1, | 633 kRoundDown = 0x1, |
| 627 kRoundUp = 0x2, | 634 kRoundUp = 0x2, |
| 628 kRoundToZero = 0x3 | 635 kRoundToZero = 0x3 |
| 629 }; | 636 }; |
| 630 void roundsd(typename Traits::XmmRegister dst, | 637 void roundsd(typename Traits::XmmRegister dst, |
| 631 typename Traits::XmmRegister src, RoundingMode mode); | 638 typename Traits::XmmRegister src, RoundingMode mode); |
| 632 | 639 |
| 633 void fld(Type Ty, const typename Traits::Address &src); | 640 //---------------------------------------------------------------------------- |
| 634 void fstp(Type Ty, const typename Traits::Address &dst); | 641 // |
| 635 void fstp(typename Traits::X87STRegister st); | 642 // Begin: X87 instructions. Only available when Traits::UsesX87. |
| 643 // | |
| 644 //---------------------------------------------------------------------------- | |
| 645 template <typename T = Traits, | |
| 646 typename = typename std::enable_if<T::UsesX87>::type> | |
| 647 void fld(Type Ty, const typename T::Address &src); | |
| 648 template <typename T = Traits, | |
| 649 typename = typename std::enable_if<T::UsesX87>::type> | |
| 650 void fstp(Type Ty, const typename T::Address &dst); | |
| 651 template <typename T = Traits, | |
| 652 typename = typename std::enable_if<T::UsesX87>::type> | |
| 653 void fstp(typename T::X87STRegister st); | |
| 636 | 654 |
| 637 void fnstcw(const typename Traits::Address &dst); | 655 template <typename T = Traits, |
| 638 void fldcw(const typename Traits::Address &src); | 656 typename = typename std::enable_if<T::UsesX87>::type> |
| 657 void fnstcw(const typename T::Address &dst); | |
| 658 template <typename T = Traits, | |
| 659 typename = typename std::enable_if<T::UsesX87>::type> | |
| 660 void fldcw(const typename T::Address &src); | |
| 639 | 661 |
| 640 void fistpl(const typename Traits::Address &dst); | 662 template <typename T = Traits, |
| 641 void fistps(const typename Traits::Address &dst); | 663 typename = typename std::enable_if<T::UsesX87>::type> |
| 642 void fildl(const typename Traits::Address &src); | 664 void fistpl(const typename T::Address &dst); |
| 643 void filds(const typename Traits::Address &src); | 665 template <typename T = Traits, |
| 666 typename = typename std::enable_if<T::UsesX87>::type> | |
| 667 void fistps(const typename T::Address &dst); | |
| 668 template <typename T = Traits, | |
| 669 typename = typename std::enable_if<T::UsesX87>::type> | |
| 670 void fildl(const typename T::Address &src); | |
| 671 template <typename T = Traits, | |
| 672 typename = typename std::enable_if<T::UsesX87>::type> | |
| 673 void filds(const typename T::Address &src); | |
| 644 | 674 |
| 675 template <typename T = Traits, | |
| 676 typename = typename std::enable_if<T::UsesX87>::type> | |
| 645 void fincstp(); | 677 void fincstp(); |
| 678 //---------------------------------------------------------------------------- | |
| 679 // | |
| 680 // End: X87 instructions. | |
| 681 // | |
| 682 //---------------------------------------------------------------------------- | |
| 646 | 683 |
| 647 void cmp(Type Ty, typename Traits::GPRRegister reg0, | 684 void cmp(Type Ty, typename Traits::GPRRegister reg0, |
| 648 typename Traits::GPRRegister reg1); | 685 typename Traits::GPRRegister reg1); |
| 649 void cmp(Type Ty, typename Traits::GPRRegister reg, | 686 void cmp(Type Ty, typename Traits::GPRRegister reg, |
| 650 const typename Traits::Address &address); | 687 const typename Traits::Address &address); |
| 651 void cmp(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); | 688 void cmp(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); |
| 652 void cmp(Type Ty, const typename Traits::Address &address, | 689 void cmp(Type Ty, const typename Traits::Address &address, |
| 653 typename Traits::GPRRegister reg); | 690 typename Traits::GPRRegister reg); |
| 654 void cmp(Type Ty, const typename Traits::Address &address, | 691 void cmp(Type Ty, const typename Traits::Address &address, |
| 655 const Immediate &imm); | 692 const Immediate &imm); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 void imul(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); | 784 void imul(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); |
| 748 void imul(Type Ty, typename Traits::GPRRegister reg, | 785 void imul(Type Ty, typename Traits::GPRRegister reg, |
| 749 const typename Traits::Address &address); | 786 const typename Traits::Address &address); |
| 750 | 787 |
| 751 void imul(Type Ty, typename Traits::GPRRegister reg); | 788 void imul(Type Ty, typename Traits::GPRRegister reg); |
| 752 void imul(Type Ty, const typename Traits::Address &address); | 789 void imul(Type Ty, const typename Traits::Address &address); |
| 753 | 790 |
| 754 void mul(Type Ty, typename Traits::GPRRegister reg); | 791 void mul(Type Ty, typename Traits::GPRRegister reg); |
| 755 void mul(Type Ty, const typename Traits::Address &address); | 792 void mul(Type Ty, const typename Traits::Address &address); |
| 756 | 793 |
| 794 template <class T = Traits, typename = typename std::enable_if<!T::Is64Bit>::t ype> | |
|
jvoung (off chromium)
2015/07/23 17:59:35
80 col
John
2015/07/27 20:35:57
Done.
| |
| 757 void incl(typename Traits::GPRRegister reg); | 795 void incl(typename Traits::GPRRegister reg); |
| 758 void incl(const typename Traits::Address &address); | 796 void incl(const typename Traits::Address &address); |
| 759 | 797 |
| 798 template <class T = Traits, typename = typename std::enable_if<!T::Is64Bit>::t ype> | |
| 760 void decl(typename Traits::GPRRegister reg); | 799 void decl(typename Traits::GPRRegister reg); |
| 761 void decl(const typename Traits::Address &address); | 800 void decl(const typename Traits::Address &address); |
| 762 | 801 |
| 763 void rol(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); | 802 void rol(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); |
| 764 void rol(Type Ty, typename Traits::GPRRegister operand, | 803 void rol(Type Ty, typename Traits::GPRRegister operand, |
| 765 typename Traits::GPRRegister shifter); | 804 typename Traits::GPRRegister shifter); |
| 766 void rol(Type Ty, const typename Traits::Address &operand, | 805 void rol(Type Ty, const typename Traits::Address &operand, |
| 767 typename Traits::GPRRegister shifter); | 806 typename Traits::GPRRegister shifter); |
| 768 | 807 |
| 769 void shl(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); | 808 void shl(Type Ty, typename Traits::GPRRegister reg, const Immediate &imm); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 void ret(); | 857 void ret(); |
| 819 void ret(const Immediate &imm); | 858 void ret(const Immediate &imm); |
| 820 | 859 |
| 821 // 'size' indicates size in bytes and must be in the range 1..8. | 860 // 'size' indicates size in bytes and must be in the range 1..8. |
| 822 void nop(int size = 1); | 861 void nop(int size = 1); |
| 823 void int3(); | 862 void int3(); |
| 824 void hlt(); | 863 void hlt(); |
| 825 void ud2(); | 864 void ud2(); |
| 826 | 865 |
| 827 // j(Label) is fully tested. | 866 // j(Label) is fully tested. |
| 828 // j(ConstantRelocatable) is not tested as the test can not easily create such | |
| 829 // an argument. | |
| 830 void j(typename Traits::Cond::BrCond condition, Label *label, | 867 void j(typename Traits::Cond::BrCond condition, Label *label, |
| 831 bool near = kFarJump); | 868 bool near = kFarJump); |
| 832 void j(typename Traits::Cond::BrCond condition, | 869 void j(typename Traits::Cond::BrCond condition, |
| 833 const ConstantRelocatable *label); | 870 const ConstantRelocatable *label); // not testable. |
| 834 | 871 |
| 835 void jmp(typename Traits::GPRRegister reg); | 872 void jmp(typename Traits::GPRRegister reg); |
| 836 void jmp(Label *label, bool near = kFarJump); | 873 void jmp(Label *label, bool near = kFarJump); |
| 837 void jmp(const ConstantRelocatable *label); | 874 void jmp(const ConstantRelocatable *label); // not testable. |
| 838 | 875 |
| 839 void mfence(); | 876 void mfence(); |
| 840 | 877 |
| 841 void lock(); | 878 void lock(); |
| 842 void cmpxchg(Type Ty, const typename Traits::Address &address, | 879 void cmpxchg(Type Ty, const typename Traits::Address &address, |
| 843 typename Traits::GPRRegister reg, bool Locked); | 880 typename Traits::GPRRegister reg, bool Locked); |
| 844 void cmpxchg8b(const typename Traits::Address &address, bool Locked); | 881 void cmpxchg8b(const typename Traits::Address &address, bool Locked); |
| 845 void xadd(Type Ty, const typename Traits::Address &address, | 882 void xadd(Type Ty, const typename Traits::Address &address, |
| 846 typename Traits::GPRRegister reg, bool Locked); | 883 typename Traits::GPRRegister reg, bool Locked); |
| 847 void xchg(Type Ty, const typename Traits::Address &address, | 884 void xchg(Type Ty, const typename Traits::Address &address, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 949 emitUint8(0x66); | 986 emitUint8(0x66); |
| 950 } | 987 } |
| 951 | 988 |
| 952 } // end of namespace X86Internal | 989 } // end of namespace X86Internal |
| 953 | 990 |
| 954 } // end of namespace Ice | 991 } // end of namespace Ice |
| 955 | 992 |
| 956 #include "IceAssemblerX86BaseImpl.h" | 993 #include "IceAssemblerX86BaseImpl.h" |
| 957 | 994 |
| 958 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H | 995 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H |
| OLD | NEW |