| 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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 using Base = InstX86BaseMovlike<Machine, K>; | 955 using Base = InstX86BaseMovlike<Machine, K>; |
| 956 | 956 |
| 957 bool isRedundantAssign() const override { | 957 bool isRedundantAssign() const override { |
| 958 if (const auto *SrcVar = llvm::dyn_cast<const Variable>(this->getSrc(0))) { | 958 if (const auto *SrcVar = llvm::dyn_cast<const Variable>(this->getSrc(0))) { |
| 959 if (SrcVar->hasReg() && this->Dest->hasReg()) { | 959 if (SrcVar->hasReg() && this->Dest->hasReg()) { |
| 960 // An assignment between physical registers is considered redundant if | 960 // An assignment between physical registers is considered redundant if |
| 961 // they have the same base register and the same encoding. E.g.: | 961 // they have the same base register and the same encoding. E.g.: |
| 962 // mov cl, ecx ==> redundant | 962 // mov cl, ecx ==> redundant |
| 963 // mov ch, ecx ==> not redundant due to different encodings | 963 // mov ch, ecx ==> not redundant due to different encodings |
| 964 // mov ch, ebp ==> not redundant due to different base registers | 964 // mov ch, ebp ==> not redundant due to different base registers |
| 965 // TODO(stichnot): Don't consider "mov eax, eax" to be redundant when | 965 // mov ecx, ecx ==> redundant, and dangerous in x86-64. i64 zexting |
| 966 // used in 64-bit mode to clear the upper half of rax. | 966 // is handled by Inst86Zext. |
| 967 int32_t SrcReg = SrcVar->getRegNum(); | 967 const int32_t SrcReg = SrcVar->getRegNum(); |
| 968 int32_t DestReg = this->Dest->getRegNum(); | 968 const int32_t DestReg = this->Dest->getRegNum(); |
| 969 return (InstX86Base<Machine>::Traits::getEncoding(SrcReg) == | 969 return (InstX86Base<Machine>::Traits::getEncoding(SrcReg) == |
| 970 InstX86Base<Machine>::Traits::getEncoding(DestReg)) && | 970 InstX86Base<Machine>::Traits::getEncoding(DestReg)) && |
| 971 (InstX86Base<Machine>::Traits::getBaseReg(SrcReg) == | 971 (InstX86Base<Machine>::Traits::getBaseReg(SrcReg) == |
| 972 InstX86Base<Machine>::Traits::getBaseReg(DestReg)); | 972 InstX86Base<Machine>::Traits::getBaseReg(DestReg)); |
| 973 } | 973 } |
| 974 } | 974 } |
| 975 return checkForRedundantAssign(this->getDest(), this->getSrc(0)); | 975 return checkForRedundantAssign(this->getDest(), this->getSrc(0)); |
| 976 } | 976 } |
| 977 bool isVarAssign() const override { | 977 bool isVarAssign() const override { |
| 978 return llvm::isa<Variable>(this->getSrc(0)); | 978 return llvm::isa<Variable>(this->getSrc(0)); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 : InstX86BaseUnaryopXmm<Machine, InstX86Base<Machine>::Sqrtss>(Func, Dest, | 1162 : InstX86BaseUnaryopXmm<Machine, InstX86Base<Machine>::Sqrtss>(Func, Dest, |
| 1163 Src) {} | 1163 Src) {} |
| 1164 }; | 1164 }; |
| 1165 | 1165 |
| 1166 /// Move/assignment instruction - wrapper for mov/movss/movsd. | 1166 /// Move/assignment instruction - wrapper for mov/movss/movsd. |
| 1167 template <class Machine> | 1167 template <class Machine> |
| 1168 class InstX86Mov | 1168 class InstX86Mov |
| 1169 : public InstX86BaseMovlike<Machine, InstX86Base<Machine>::Mov> { | 1169 : public InstX86BaseMovlike<Machine, InstX86Base<Machine>::Mov> { |
| 1170 public: | 1170 public: |
| 1171 static InstX86Mov *create(Cfg *Func, Variable *Dest, Operand *Source) { | 1171 static InstX86Mov *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 1172 assert(!isScalarIntegerType(Dest->getType()) || |
| 1173 (typeWidthInBytes(Dest->getType()) <= |
| 1174 typeWidthInBytes(Source->getType()))); |
| 1172 return new (Func->allocate<InstX86Mov>()) InstX86Mov(Func, Dest, Source); | 1175 return new (Func->allocate<InstX86Mov>()) InstX86Mov(Func, Dest, Source); |
| 1173 } | 1176 } |
| 1174 | 1177 |
| 1175 void emit(const Cfg *Func) const override; | 1178 void emit(const Cfg *Func) const override; |
| 1176 void emitIAS(const Cfg *Func) const override; | 1179 void emitIAS(const Cfg *Func) const override; |
| 1177 | 1180 |
| 1178 private: | 1181 private: |
| 1179 InstX86Mov(Cfg *Func, Variable *Dest, Operand *Source) | 1182 InstX86Mov(Cfg *Func, Variable *Dest, Operand *Source) |
| 1180 : InstX86BaseMovlike<Machine, InstX86Base<Machine>::Mov>(Func, Dest, | 1183 : InstX86BaseMovlike<Machine, InstX86Base<Machine>::Mov>(Func, Dest, |
| 1181 Source) {} | 1184 Source) {} |
| (...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3365 &InstX86Base<Machine>::Traits::Assembler::psrl}; \ | 3368 &InstX86Base<Machine>::Traits::Assembler::psrl}; \ |
| 3366 } \ | 3369 } \ |
| 3367 } | 3370 } |
| 3368 | 3371 |
| 3369 } // end of namespace X86Internal | 3372 } // end of namespace X86Internal |
| 3370 } // end of namespace Ice | 3373 } // end of namespace Ice |
| 3371 | 3374 |
| 3372 #include "IceInstX86BaseImpl.h" | 3375 #include "IceInstX86BaseImpl.h" |
| 3373 | 3376 |
| 3374 #endif // SUBZERO_SRC_ICEINSTX86BASE_H | 3377 #endif // SUBZERO_SRC_ICEINSTX86BASE_H |
| OLD | NEW |