OLD | NEW |
1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// | 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the InstX8632 and OperandX8632 classes, | 10 // This file implements the InstX8632 and OperandX8632 classes, |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 template <> | 713 template <> |
714 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Padd::Emitter = { | 714 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Padd::Emitter = { |
715 &x86::AssemblerX86::padd, &x86::AssemblerX86::padd, NULL}; | 715 &x86::AssemblerX86::padd, &x86::AssemblerX86::padd, NULL}; |
716 template <> | 716 template <> |
717 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pand::Emitter = { | 717 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pand::Emitter = { |
718 &x86::AssemblerX86::pand, &x86::AssemblerX86::pand, NULL}; | 718 &x86::AssemblerX86::pand, &x86::AssemblerX86::pand, NULL}; |
719 template <> | 719 template <> |
720 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pandn::Emitter = { | 720 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pandn::Emitter = { |
721 &x86::AssemblerX86::pandn, &x86::AssemblerX86::pandn, NULL}; | 721 &x86::AssemblerX86::pandn, &x86::AssemblerX86::pandn, NULL}; |
722 template <> | 722 template <> |
| 723 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pcmpeq::Emitter = { |
| 724 &x86::AssemblerX86::pcmpeq, &x86::AssemblerX86::pcmpeq, NULL}; |
| 725 template <> |
| 726 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pcmpgt::Emitter = { |
| 727 &x86::AssemblerX86::pcmpgt, &x86::AssemblerX86::pcmpgt, NULL}; |
| 728 template <> |
723 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pmuludq::Emitter = { | 729 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pmuludq::Emitter = { |
724 &x86::AssemblerX86::pmuludq, &x86::AssemblerX86::pmuludq, NULL}; | 730 &x86::AssemblerX86::pmuludq, &x86::AssemblerX86::pmuludq, NULL}; |
725 template <> | 731 template <> |
726 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Por::Emitter = { | 732 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Por::Emitter = { |
727 &x86::AssemblerX86::por, &x86::AssemblerX86::por, NULL}; | 733 &x86::AssemblerX86::por, &x86::AssemblerX86::por, NULL}; |
728 template <> | 734 template <> |
729 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Psub::Emitter = { | 735 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Psub::Emitter = { |
730 &x86::AssemblerX86::psub, &x86::AssemblerX86::psub, NULL}; | 736 &x86::AssemblerX86::psub, &x86::AssemblerX86::psub, NULL}; |
731 template <> | 737 template <> |
732 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pxor::Emitter = { | 738 const x86::AssemblerX86::XmmEmitterTwoOps InstX8632Pxor::Emitter = { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 Str << ", "; | 903 Str << ", "; |
898 getSrc(0)->emit(Func); | 904 getSrc(0)->emit(Func); |
899 Str << ", "; | 905 Str << ", "; |
900 getSrc(1)->emit(Func); | 906 getSrc(1)->emit(Func); |
901 Str << "\n"; | 907 Str << "\n"; |
902 } else { | 908 } else { |
903 emitTwoAddress("imul", this, Func); | 909 emitTwoAddress("imul", this, Func); |
904 } | 910 } |
905 } | 911 } |
906 | 912 |
| 913 template <> void InstX8632Imul::emitIAS(const Cfg *Func) const { |
| 914 assert(getSrcSize() == 2); |
| 915 const Variable *Var = getDest(); |
| 916 Type Ty = Var->getType(); |
| 917 const Operand *Src = getSrc(1); |
| 918 if (isByteSizedArithType(Ty)) { |
| 919 // The 8-bit version of imul only allows the form "imul r/m8". |
| 920 Variable *Src0 = llvm::dyn_cast<Variable>(getSrc(0)); |
| 921 (void)Src0; |
| 922 assert(Src0 && Src0->getRegNum() == RegX8632::Reg_eax); |
| 923 const x86::AssemblerX86::GPREmitterOneOp Emitter = { |
| 924 &x86::AssemblerX86::imul, &x86::AssemblerX86::imul}; |
| 925 emitIASOpTyGPR(Func, Ty, getSrc(1), Emitter); |
| 926 } else { |
| 927 // We only use imul as a two-address instruction even though |
| 928 // there is a 3 operand version when one of the operands is a constant. |
| 929 assert(Var == getSrc(0)); |
| 930 const x86::AssemblerX86::GPREmitterRegOp Emitter = { |
| 931 &x86::AssemblerX86::imul, &x86::AssemblerX86::imul, |
| 932 &x86::AssemblerX86::imul}; |
| 933 emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); |
| 934 } |
| 935 } |
| 936 |
907 template <> void InstX8632Cbwdq::emit(const Cfg *Func) const { | 937 template <> void InstX8632Cbwdq::emit(const Cfg *Func) const { |
908 Ostream &Str = Func->getContext()->getStrEmit(); | 938 Ostream &Str = Func->getContext()->getStrEmit(); |
909 assert(getSrcSize() == 1); | 939 assert(getSrcSize() == 1); |
910 Operand *Src0 = getSrc(0); | 940 Operand *Src0 = getSrc(0); |
911 assert(llvm::isa<Variable>(Src0)); | 941 assert(llvm::isa<Variable>(Src0)); |
912 assert(llvm::cast<Variable>(Src0)->getRegNum() == RegX8632::Reg_eax); | 942 assert(llvm::cast<Variable>(Src0)->getRegNum() == RegX8632::Reg_eax); |
913 switch (Src0->getType()) { | 943 switch (Src0->getType()) { |
914 default: | 944 default: |
915 llvm_unreachable("unexpected source type!"); | 945 llvm_unreachable("unexpected source type!"); |
916 break; | 946 break; |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 } | 2082 } |
2053 Str << "("; | 2083 Str << "("; |
2054 if (Func) | 2084 if (Func) |
2055 Var->dump(Func); | 2085 Var->dump(Func); |
2056 else | 2086 else |
2057 Var->dump(Str); | 2087 Var->dump(Str); |
2058 Str << ")"; | 2088 Str << ")"; |
2059 } | 2089 } |
2060 | 2090 |
2061 } // end of namespace Ice | 2091 } // end of namespace Ice |
OLD | NEW |