OLD | NEW |
---|---|
1 //===- subzero/src/IceInstX86Base.h - Generic x86 instructions -*- C++ -*--===// | 1 //===- subzero/src/IceInstX86Base.h - Generic x86 instructions -*- C++ -*--===// |
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 /// \file | 10 /// \file |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 InstX86BaseBinopXmm(const InstX86BaseBinopXmm &) = delete; | 816 InstX86BaseBinopXmm(const InstX86BaseBinopXmm &) = delete; |
817 InstX86BaseBinopXmm &operator=(const InstX86BaseBinopXmm &) = delete; | 817 InstX86BaseBinopXmm &operator=(const InstX86BaseBinopXmm &) = delete; |
818 | 818 |
819 public: | 819 public: |
820 using Base = InstX86BaseBinopXmm<K, NeedsElementType, Suffix>; | 820 using Base = InstX86BaseBinopXmm<K, NeedsElementType, Suffix>; |
821 | 821 |
822 void emit(const Cfg *Func) const override { | 822 void emit(const Cfg *Func) const override { |
823 if (!BuildDefs::dump()) | 823 if (!BuildDefs::dump()) |
824 return; | 824 return; |
825 this->validateVectorAddrMode(); | 825 this->validateVectorAddrMode(); |
826 Type DestTy = ArithmeticTypeOverride == IceType_void | |
Jim Stichnoth
2016/01/12 14:54:02
const
sehr
2016/01/12 19:01:19
Done.
| |
827 ? this->getDest()->getType() | |
828 : ArithmeticTypeOverride; | |
829 const char *SuffixString = ""; | |
826 switch (Suffix) { | 830 switch (Suffix) { |
827 case InstX86Base::SseSuffix::None: | 831 case InstX86Base::SseSuffix::None: |
828 this->emitTwoAddress(Func, Opcode); | |
829 break; | 832 break; |
830 case InstX86Base::SseSuffix::Packed: { | 833 case InstX86Base::SseSuffix::Packed: |
831 const Type DestTy = this->getDest()->getType(); | 834 SuffixString = Traits::TypeAttributes[DestTy].PdPsString; |
832 this->emitTwoAddress(Func, this->Opcode, | 835 break; |
833 Traits::TypeAttributes[DestTy].PdPsString); | 836 case InstX86Base::SseSuffix::Scalar: |
834 } break; | 837 SuffixString = Traits::TypeAttributes[DestTy].SdSsString; |
835 case InstX86Base::SseSuffix::Scalar: { | 838 break; |
836 const Type DestTy = this->getDest()->getType(); | 839 case InstX86Base::SseSuffix::Integral: |
837 this->emitTwoAddress(Func, this->Opcode, | 840 SuffixString = Traits::TypeAttributes[DestTy].PackString; |
838 Traits::TypeAttributes[DestTy].SdSsString); | 841 break; |
839 } break; | |
840 case InstX86Base::SseSuffix::Integral: { | |
841 const Type DestTy = this->getDest()->getType(); | |
842 this->emitTwoAddress(Func, this->Opcode, | |
843 Traits::TypeAttributes[DestTy].PackString); | |
844 } break; | |
845 } | 842 } |
843 this->emitTwoAddress(Func, Opcode, SuffixString); | |
846 } | 844 } |
847 void emitIAS(const Cfg *Func) const override { | 845 void emitIAS(const Cfg *Func) const override { |
848 this->validateVectorAddrMode(); | 846 this->validateVectorAddrMode(); |
849 Type Ty = this->getDest()->getType(); | 847 Type Ty = this->getDest()->getType(); |
850 if (NeedsElementType) | 848 if (NeedsElementType) |
851 Ty = typeElementType(Ty); | 849 Ty = typeElementType(Ty); |
852 assert(this->getSrcSize() == 2); | 850 assert(this->getSrcSize() == 2); |
853 emitIASRegOpTyXMM(Func, Ty, this->getDest(), this->getSrc(1), Emitter); | 851 emitIASRegOpTyXMM(Func, Ty, this->getDest(), this->getSrc(1), Emitter); |
854 } | 852 } |
855 void dump(const Cfg *Func) const override { | 853 void dump(const Cfg *Func) const override { |
856 if (!BuildDefs::dump()) | 854 if (!BuildDefs::dump()) |
857 return; | 855 return; |
858 Ostream &Str = Func->getContext()->getStrDump(); | 856 Ostream &Str = Func->getContext()->getStrDump(); |
859 this->dumpDest(Func); | 857 this->dumpDest(Func); |
860 Str << " = " << Opcode << "." << this->getDest()->getType() << " "; | 858 Str << " = " << Opcode << "." << this->getDest()->getType() << " "; |
861 this->dumpSources(Func); | 859 this->dumpSources(Func); |
862 } | 860 } |
863 static bool classof(const Inst *Inst) { | 861 static bool classof(const Inst *Inst) { |
864 return InstX86Base::isClassof(Inst, InstX86Base::K); | 862 return InstX86Base::isClassof(Inst, InstX86Base::K); |
865 } | 863 } |
866 | 864 |
867 protected: | 865 protected: |
868 InstX86BaseBinopXmm(Cfg *Func, Variable *Dest, Operand *Source) | 866 InstX86BaseBinopXmm(Cfg *Func, Variable *Dest, Operand *Source, |
869 : InstX86Base(Func, K, 2, Dest) { | 867 Type ArithmeticTypeOverride = IceType_void) |
868 : InstX86Base(Func, K, 2, Dest), | |
869 ArithmeticTypeOverride(ArithmeticTypeOverride) { | |
870 this->addSource(Dest); | 870 this->addSource(Dest); |
871 this->addSource(Source); | 871 this->addSource(Source); |
872 } | 872 } |
873 | 873 |
874 const Type ArithmeticTypeOverride; | |
874 static const char *Opcode; | 875 static const char *Opcode; |
875 static const XmmEmitterRegOp Emitter; | 876 static const XmmEmitterRegOp Emitter; |
876 }; | 877 }; |
877 | 878 |
878 template <typename InstX86Base::InstKindX86 K, bool AllowAllTypes = false> | 879 template <typename InstX86Base::InstKindX86 K, bool AllowAllTypes = false> |
879 class InstX86BaseBinopXmmShift : public InstX86Base { | 880 class InstX86BaseBinopXmmShift : public InstX86Base { |
880 InstX86BaseBinopXmmShift() = delete; | 881 InstX86BaseBinopXmmShift() = delete; |
881 InstX86BaseBinopXmmShift(const InstX86BaseBinopXmmShift &) = delete; | 882 InstX86BaseBinopXmmShift(const InstX86BaseBinopXmmShift &) = delete; |
882 InstX86BaseBinopXmmShift & | 883 InstX86BaseBinopXmmShift & |
883 operator=(const InstX86BaseBinopXmmShift &) = delete; | 884 operator=(const InstX86BaseBinopXmmShift &) = delete; |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1907 | 1908 |
1908 private: | 1909 private: |
1909 InstX86Psra(Cfg *Func, Variable *Dest, Operand *Source) | 1910 InstX86Psra(Cfg *Func, Variable *Dest, Operand *Source) |
1910 : InstX86BaseBinopXmmShift<InstX86Base::Psra>(Func, Dest, Source) {} | 1911 : InstX86BaseBinopXmmShift<InstX86Base::Psra>(Func, Dest, Source) {} |
1911 }; | 1912 }; |
1912 | 1913 |
1913 class InstX86Pcmpeq | 1914 class InstX86Pcmpeq |
1914 : public InstX86BaseBinopXmm<InstX86Base::Pcmpeq, true, | 1915 : public InstX86BaseBinopXmm<InstX86Base::Pcmpeq, true, |
1915 InstX86Base::SseSuffix::Integral> { | 1916 InstX86Base::SseSuffix::Integral> { |
1916 public: | 1917 public: |
1917 static InstX86Pcmpeq *create(Cfg *Func, Variable *Dest, Operand *Source) { | 1918 static InstX86Pcmpeq *create(Cfg *Func, Variable *Dest, Operand *Source, |
1919 Type ArithmeticTypeOverride = IceType_void) { | |
1920 Type Ty = ArithmeticTypeOverride == IceType_void ? Dest->getType() | |
Jim Stichnoth
2016/01/12 14:54:02
const
sehr
2016/01/12 19:01:19
Done.
| |
1921 : ArithmeticTypeOverride; | |
1922 (void)Ty; | |
1923 assert((Ty != IceType_f64 && Ty != IceType_i64) || | |
1924 InstX86Base::getTarget(Func)->getInstructionSet() >= | |
1925 Traits::SSE4_1); | |
1918 return new (Func->allocate<InstX86Pcmpeq>()) | 1926 return new (Func->allocate<InstX86Pcmpeq>()) |
1919 InstX86Pcmpeq(Func, Dest, Source); | 1927 InstX86Pcmpeq(Func, Dest, Source, ArithmeticTypeOverride); |
1920 } | 1928 } |
1921 | 1929 |
1922 private: | 1930 private: |
1923 InstX86Pcmpeq(Cfg *Func, Variable *Dest, Operand *Source) | 1931 InstX86Pcmpeq(Cfg *Func, Variable *Dest, Operand *Source, |
1932 Type ArithmeticTypeOverride) | |
1924 : InstX86BaseBinopXmm<InstX86Base::Pcmpeq, true, | 1933 : InstX86BaseBinopXmm<InstX86Base::Pcmpeq, true, |
1925 InstX86Base::SseSuffix::Integral>(Func, Dest, | 1934 InstX86Base::SseSuffix::Integral>( |
1926 Source) {} | 1935 Func, Dest, Source, ArithmeticTypeOverride) {} |
1927 }; | 1936 }; |
1928 | 1937 |
1929 class InstX86Pcmpgt | 1938 class InstX86Pcmpgt |
1930 : public InstX86BaseBinopXmm<InstX86Base::Pcmpgt, true, | 1939 : public InstX86BaseBinopXmm<InstX86Base::Pcmpgt, true, |
1931 InstX86Base::SseSuffix::Integral> { | 1940 InstX86Base::SseSuffix::Integral> { |
1932 public: | 1941 public: |
1933 static InstX86Pcmpgt *create(Cfg *Func, Variable *Dest, Operand *Source) { | 1942 static InstX86Pcmpgt *create(Cfg *Func, Variable *Dest, Operand *Source) { |
1943 assert(Dest->getType() != IceType_f64 || | |
1944 InstX86Base::getTarget(Func)->getInstructionSet() >= | |
1945 Traits::SSE4_1); | |
1934 return new (Func->allocate<InstX86Pcmpgt>()) | 1946 return new (Func->allocate<InstX86Pcmpgt>()) |
1935 InstX86Pcmpgt(Func, Dest, Source); | 1947 InstX86Pcmpgt(Func, Dest, Source); |
1936 } | 1948 } |
1937 | 1949 |
1938 private: | 1950 private: |
1939 InstX86Pcmpgt(Cfg *Func, Variable *Dest, Operand *Source) | 1951 InstX86Pcmpgt(Cfg *Func, Variable *Dest, Operand *Source) |
1940 : InstX86BaseBinopXmm<InstX86Base::Pcmpgt, true, | 1952 : InstX86BaseBinopXmm<InstX86Base::Pcmpgt, true, |
1941 InstX86Base::SseSuffix::Integral>(Func, Dest, | 1953 InstX86Base::SseSuffix::Integral>(Func, Dest, |
1942 Source) {} | 1954 Source) {} |
1943 }; | 1955 }; |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3497 &InstImpl<TraitsType>::Assembler::psrl}; \ | 3509 &InstImpl<TraitsType>::Assembler::psrl}; \ |
3498 } \ | 3510 } \ |
3499 } | 3511 } |
3500 | 3512 |
3501 } // end of namespace X86NAMESPACE | 3513 } // end of namespace X86NAMESPACE |
3502 } // end of namespace Ice | 3514 } // end of namespace Ice |
3503 | 3515 |
3504 #include "IceInstX86BaseImpl.h" | 3516 #include "IceInstX86BaseImpl.h" |
3505 | 3517 |
3506 #endif // SUBZERO_SRC_ICEINSTX86BASE_H | 3518 #endif // SUBZERO_SRC_ICEINSTX86BASE_H |
OLD | NEW |