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