Chromium Code Reviews| Index: src/IceInstX8632.h |
| diff --git a/src/IceInstX8632.h b/src/IceInstX8632.h |
| index a2fd7dccf3d6792a312be4b2f2df490ed4cca9dd..f6e0a085709c95a135d4b01268a4675dddc092ad 100644 |
| --- a/src/IceInstX8632.h |
| +++ b/src/IceInstX8632.h |
| @@ -571,6 +571,51 @@ private: |
| static const char *Opcode; |
| }; |
| +// Base class for assignment instructions |
| +template <InstX8632::InstKindX8632 K> |
| +class InstX8632Movlike : public InstX8632 { |
| +public: |
| + static InstX8632Movlike *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| + return new (Func->allocate<InstX8632Movlike>()) |
| + InstX8632Movlike(Func, Dest, Source); |
| + } |
| + virtual bool isRedundantAssign() const { |
|
jvoung (off chromium)
2014/08/12 19:49:47
It might be good to leave this in the .cpp file in
wala
2014/08/12 20:06:56
Done.
|
| + Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); |
| + if (Src == NULL) |
| + return false; |
| + if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { |
| + // TODO: On x86-64, instructions like "mov eax, eax" are used to |
| + // clear the upper 32 bits of rax. We need to recognize and |
| + // preserve these. |
| + return true; |
| + } |
| + if (!getDest()->hasReg() && !Src->hasReg() && |
| + Dest->getStackOffset() == Src->getStackOffset()) |
| + return true; |
| + return false; |
| + } |
| + virtual void emit(const Cfg *Func) const; |
| + virtual void dump(const Cfg *Func) const { |
| + Ostream &Str = Func->getContext()->getStrDump(); |
| + Str << Opcode << "." << getDest()->getType() << " "; |
| + dumpDest(Func); |
| + Str << ", "; |
| + dumpSources(Func); |
| + } |
| + static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| + |
| +private: |
| + InstX8632Movlike(Cfg *Func, Variable *Dest, Operand *Source) |
| + : InstX8632(Func, K, 1, Dest) { |
| + addSource(Source); |
| + } |
| + InstX8632Movlike(const InstX8632Movlike &) LLVM_DELETED_FUNCTION; |
| + InstX8632Movlike &operator=(const InstX8632Movlike &) LLVM_DELETED_FUNCTION; |
| + virtual ~InstX8632Movlike() {} |
| + |
| + static const char *Opcode; |
| +}; |
| + |
| typedef InstX8632Inplaceop<InstX8632::Bswap> InstX8632Bswap; |
| typedef InstX8632Inplaceop<InstX8632::Neg> InstX8632Neg; |
| typedef InstX8632Unaryop<InstX8632::Bsf> InstX8632Bsf; |
| @@ -580,6 +625,13 @@ typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd; |
| typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss; |
| // Cbwdq instruction - wrapper for cbw, cwd, and cdq |
| typedef InstX8632Unaryop<InstX8632::Cbwdq> InstX8632Cbwdq; |
| +// Move/assignment instruction - wrapper for mov/movss/movsd. |
| +typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov; |
| +// Move packed - copy 128 bit values between XMM registers, or mem128 |
| +// and XMM registers. |
| +typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp; |
| +// Movq - copy between XMM registers, or mem64 and XMM registers. |
| +typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq; |
| typedef InstX8632Binop<InstX8632::Add> InstX8632Add; |
| typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps; |
| typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc; |
| @@ -943,45 +995,6 @@ private: |
| virtual ~InstX8632Store() {} |
| }; |
| -// Move/assignment instruction - wrapper for mov/movss/movsd. |
| -class InstX8632Mov : public InstX8632 { |
| -public: |
| - static InstX8632Mov *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| - return new (Func->allocate<InstX8632Mov>()) |
| - InstX8632Mov(Func, Dest, Source); |
| - } |
| - virtual bool isRedundantAssign() const; |
| - virtual void emit(const Cfg *Func) const; |
| - virtual void dump(const Cfg *Func) const; |
| - static bool classof(const Inst *Inst) { return isClassof(Inst, Mov); } |
| - |
| -private: |
| - InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source); |
| - InstX8632Mov(const InstX8632Mov &) LLVM_DELETED_FUNCTION; |
| - InstX8632Mov &operator=(const InstX8632Mov &) LLVM_DELETED_FUNCTION; |
| - virtual ~InstX8632Mov() {} |
| -}; |
| - |
| -// Move packed - copy 128 bit values between XMM registers or mem128 and |
| -// XMM registers |
| -class InstX8632Movp : public InstX8632 { |
| -public: |
| - static InstX8632Movp *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| - return new (Func->allocate<InstX8632Movp>()) |
| - InstX8632Movp(Func, Dest, Source); |
| - } |
| - virtual bool isRedundantAssign() const; |
| - virtual void emit(const Cfg *Func) const; |
| - virtual void dump(const Cfg *Func) const; |
| - static bool classof(const Inst *Inst) { return isClassof(Inst, Movp); } |
| - |
| -private: |
| - InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source); |
| - InstX8632Movp(const InstX8632Movp &) LLVM_DELETED_FUNCTION; |
| - InstX8632Movp &operator=(const InstX8632Movp &) LLVM_DELETED_FUNCTION; |
| - virtual ~InstX8632Movp() {} |
| -}; |
| - |
| class InstX8632StoreP : public InstX8632 { |
| public: |
| static InstX8632StoreP *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) { |
| @@ -1019,25 +1032,6 @@ private: |
| virtual ~InstX8632StoreQ() {} |
| }; |
| -// Movq - copy between XMM registers, or mem64 and XMM registers. |
| -class InstX8632Movq : public InstX8632 { |
| -public: |
| - static InstX8632Movq *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| - return new (Func->allocate<InstX8632Movq>()) |
| - InstX8632Movq(Func, Dest, Source); |
| - } |
| - virtual bool isRedundantAssign() const; |
| - virtual void emit(const Cfg *Func) const; |
| - virtual void dump(const Cfg *Func) const; |
| - static bool classof(const Inst *Inst) { return isClassof(Inst, Movq); } |
| - |
| -private: |
| - InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source); |
| - InstX8632Movq(const InstX8632Movq &) LLVM_DELETED_FUNCTION; |
| - InstX8632Movq &operator=(const InstX8632Movq &) LLVM_DELETED_FUNCTION; |
| - virtual ~InstX8632Movq() {} |
| -}; |
| - |
| // Movsx - copy from a narrower integer type to a wider integer |
| // type, with sign extension. |
| class InstX8632Movsx : public InstX8632 { |