| OLD | NEW |
| 1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// | 1 //===- subzero/src/IceInstX8632.h - Low-level 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 // This file declares the InstX8632 and OperandX8632 classes and | 10 // This file declares the InstX8632 and OperandX8632 classes and |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 addSource(Source1); | 564 addSource(Source1); |
| 565 } | 565 } |
| 566 InstX8632ThreeAddressop(const InstX8632ThreeAddressop &) | 566 InstX8632ThreeAddressop(const InstX8632ThreeAddressop &) |
| 567 LLVM_DELETED_FUNCTION; | 567 LLVM_DELETED_FUNCTION; |
| 568 InstX8632ThreeAddressop & | 568 InstX8632ThreeAddressop & |
| 569 operator=(const InstX8632ThreeAddressop &) LLVM_DELETED_FUNCTION; | 569 operator=(const InstX8632ThreeAddressop &) LLVM_DELETED_FUNCTION; |
| 570 virtual ~InstX8632ThreeAddressop() {} | 570 virtual ~InstX8632ThreeAddressop() {} |
| 571 static const char *Opcode; | 571 static const char *Opcode; |
| 572 }; | 572 }; |
| 573 | 573 |
| 574 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source); |
| 575 |
| 576 // Base class for assignment instructions |
| 577 template <InstX8632::InstKindX8632 K> |
| 578 class InstX8632Movlike : public InstX8632 { |
| 579 public: |
| 580 static InstX8632Movlike *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 581 return new (Func->allocate<InstX8632Movlike>()) |
| 582 InstX8632Movlike(Func, Dest, Source); |
| 583 } |
| 584 virtual bool isRedundantAssign() const { |
| 585 return checkForRedundantAssign(getDest(), getSrc(0)); |
| 586 } |
| 587 virtual void emit(const Cfg *Func) const; |
| 588 virtual void dump(const Cfg *Func) const { |
| 589 Ostream &Str = Func->getContext()->getStrDump(); |
| 590 Str << Opcode << "." << getDest()->getType() << " "; |
| 591 dumpDest(Func); |
| 592 Str << ", "; |
| 593 dumpSources(Func); |
| 594 } |
| 595 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 596 |
| 597 private: |
| 598 InstX8632Movlike(Cfg *Func, Variable *Dest, Operand *Source) |
| 599 : InstX8632(Func, K, 1, Dest) { |
| 600 addSource(Source); |
| 601 } |
| 602 InstX8632Movlike(const InstX8632Movlike &) LLVM_DELETED_FUNCTION; |
| 603 InstX8632Movlike &operator=(const InstX8632Movlike &) LLVM_DELETED_FUNCTION; |
| 604 virtual ~InstX8632Movlike() {} |
| 605 |
| 606 static const char *Opcode; |
| 607 }; |
| 608 |
| 574 typedef InstX8632Inplaceop<InstX8632::Bswap> InstX8632Bswap; | 609 typedef InstX8632Inplaceop<InstX8632::Bswap> InstX8632Bswap; |
| 575 typedef InstX8632Inplaceop<InstX8632::Neg> InstX8632Neg; | 610 typedef InstX8632Inplaceop<InstX8632::Neg> InstX8632Neg; |
| 576 typedef InstX8632Unaryop<InstX8632::Bsf> InstX8632Bsf; | 611 typedef InstX8632Unaryop<InstX8632::Bsf> InstX8632Bsf; |
| 577 typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr; | 612 typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr; |
| 578 typedef InstX8632Unaryop<InstX8632::Lea> InstX8632Lea; | 613 typedef InstX8632Unaryop<InstX8632::Lea> InstX8632Lea; |
| 579 typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd; | 614 typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd; |
| 580 typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss; | 615 typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss; |
| 581 // Cbwdq instruction - wrapper for cbw, cwd, and cdq | 616 // Cbwdq instruction - wrapper for cbw, cwd, and cdq |
| 582 typedef InstX8632Unaryop<InstX8632::Cbwdq> InstX8632Cbwdq; | 617 typedef InstX8632Unaryop<InstX8632::Cbwdq> InstX8632Cbwdq; |
| 618 // Move/assignment instruction - wrapper for mov/movss/movsd. |
| 619 typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov; |
| 620 // Move packed - copy 128 bit values between XMM registers, or mem128 |
| 621 // and XMM registers. |
| 622 typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp; |
| 623 // Movq - copy between XMM registers, or mem64 and XMM registers. |
| 624 typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq; |
| 583 typedef InstX8632Binop<InstX8632::Add> InstX8632Add; | 625 typedef InstX8632Binop<InstX8632::Add> InstX8632Add; |
| 584 typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps; | 626 typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps; |
| 585 typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc; | 627 typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc; |
| 586 typedef InstX8632Binop<InstX8632::Addss> InstX8632Addss; | 628 typedef InstX8632Binop<InstX8632::Addss> InstX8632Addss; |
| 587 typedef InstX8632Binop<InstX8632::Padd> InstX8632Padd; | 629 typedef InstX8632Binop<InstX8632::Padd> InstX8632Padd; |
| 588 typedef InstX8632Binop<InstX8632::Sub> InstX8632Sub; | 630 typedef InstX8632Binop<InstX8632::Sub> InstX8632Sub; |
| 589 typedef InstX8632Binop<InstX8632::Subps> InstX8632Subps; | 631 typedef InstX8632Binop<InstX8632::Subps> InstX8632Subps; |
| 590 typedef InstX8632Binop<InstX8632::Subss> InstX8632Subss; | 632 typedef InstX8632Binop<InstX8632::Subss> InstX8632Subss; |
| 591 typedef InstX8632Binop<InstX8632::Sbb> InstX8632Sbb; | 633 typedef InstX8632Binop<InstX8632::Sbb> InstX8632Sbb; |
| 592 typedef InstX8632Binop<InstX8632::Psub> InstX8632Psub; | 634 typedef InstX8632Binop<InstX8632::Psub> InstX8632Psub; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 virtual void dump(const Cfg *Func) const; | 978 virtual void dump(const Cfg *Func) const; |
| 937 static bool classof(const Inst *Inst) { return isClassof(Inst, Store); } | 979 static bool classof(const Inst *Inst) { return isClassof(Inst, Store); } |
| 938 | 980 |
| 939 private: | 981 private: |
| 940 InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem); | 982 InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem); |
| 941 InstX8632Store(const InstX8632Store &) LLVM_DELETED_FUNCTION; | 983 InstX8632Store(const InstX8632Store &) LLVM_DELETED_FUNCTION; |
| 942 InstX8632Store &operator=(const InstX8632Store &) LLVM_DELETED_FUNCTION; | 984 InstX8632Store &operator=(const InstX8632Store &) LLVM_DELETED_FUNCTION; |
| 943 virtual ~InstX8632Store() {} | 985 virtual ~InstX8632Store() {} |
| 944 }; | 986 }; |
| 945 | 987 |
| 946 // Move/assignment instruction - wrapper for mov/movss/movsd. | |
| 947 class InstX8632Mov : public InstX8632 { | |
| 948 public: | |
| 949 static InstX8632Mov *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 950 return new (Func->allocate<InstX8632Mov>()) | |
| 951 InstX8632Mov(Func, Dest, Source); | |
| 952 } | |
| 953 virtual bool isRedundantAssign() const; | |
| 954 virtual void emit(const Cfg *Func) const; | |
| 955 virtual void dump(const Cfg *Func) const; | |
| 956 static bool classof(const Inst *Inst) { return isClassof(Inst, Mov); } | |
| 957 | |
| 958 private: | |
| 959 InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source); | |
| 960 InstX8632Mov(const InstX8632Mov &) LLVM_DELETED_FUNCTION; | |
| 961 InstX8632Mov &operator=(const InstX8632Mov &) LLVM_DELETED_FUNCTION; | |
| 962 virtual ~InstX8632Mov() {} | |
| 963 }; | |
| 964 | |
| 965 // Move packed - copy 128 bit values between XMM registers or mem128 and | |
| 966 // XMM registers | |
| 967 class InstX8632Movp : public InstX8632 { | |
| 968 public: | |
| 969 static InstX8632Movp *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 970 return new (Func->allocate<InstX8632Movp>()) | |
| 971 InstX8632Movp(Func, Dest, Source); | |
| 972 } | |
| 973 virtual bool isRedundantAssign() const; | |
| 974 virtual void emit(const Cfg *Func) const; | |
| 975 virtual void dump(const Cfg *Func) const; | |
| 976 static bool classof(const Inst *Inst) { return isClassof(Inst, Movp); } | |
| 977 | |
| 978 private: | |
| 979 InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source); | |
| 980 InstX8632Movp(const InstX8632Movp &) LLVM_DELETED_FUNCTION; | |
| 981 InstX8632Movp &operator=(const InstX8632Movp &) LLVM_DELETED_FUNCTION; | |
| 982 virtual ~InstX8632Movp() {} | |
| 983 }; | |
| 984 | |
| 985 class InstX8632StoreP : public InstX8632 { | 988 class InstX8632StoreP : public InstX8632 { |
| 986 public: | 989 public: |
| 987 static InstX8632StoreP *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) { | 990 static InstX8632StoreP *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) { |
| 988 return new (Func->allocate<InstX8632StoreP>()) | 991 return new (Func->allocate<InstX8632StoreP>()) |
| 989 InstX8632StoreP(Func, Value, Mem); | 992 InstX8632StoreP(Func, Value, Mem); |
| 990 } | 993 } |
| 991 virtual void emit(const Cfg *Func) const; | 994 virtual void emit(const Cfg *Func) const; |
| 992 virtual void dump(const Cfg *Func) const; | 995 virtual void dump(const Cfg *Func) const; |
| 993 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreP); } | 996 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreP); } |
| 994 | 997 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1012 virtual void dump(const Cfg *Func) const; | 1015 virtual void dump(const Cfg *Func) const; |
| 1013 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); } | 1016 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); } |
| 1014 | 1017 |
| 1015 private: | 1018 private: |
| 1016 InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem); | 1019 InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem); |
| 1017 InstX8632StoreQ(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION; | 1020 InstX8632StoreQ(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION; |
| 1018 InstX8632StoreQ &operator=(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION; | 1021 InstX8632StoreQ &operator=(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION; |
| 1019 virtual ~InstX8632StoreQ() {} | 1022 virtual ~InstX8632StoreQ() {} |
| 1020 }; | 1023 }; |
| 1021 | 1024 |
| 1022 // Movq - copy between XMM registers, or mem64 and XMM registers. | |
| 1023 class InstX8632Movq : public InstX8632 { | |
| 1024 public: | |
| 1025 static InstX8632Movq *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 1026 return new (Func->allocate<InstX8632Movq>()) | |
| 1027 InstX8632Movq(Func, Dest, Source); | |
| 1028 } | |
| 1029 virtual bool isRedundantAssign() const; | |
| 1030 virtual void emit(const Cfg *Func) const; | |
| 1031 virtual void dump(const Cfg *Func) const; | |
| 1032 static bool classof(const Inst *Inst) { return isClassof(Inst, Movq); } | |
| 1033 | |
| 1034 private: | |
| 1035 InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source); | |
| 1036 InstX8632Movq(const InstX8632Movq &) LLVM_DELETED_FUNCTION; | |
| 1037 InstX8632Movq &operator=(const InstX8632Movq &) LLVM_DELETED_FUNCTION; | |
| 1038 virtual ~InstX8632Movq() {} | |
| 1039 }; | |
| 1040 | |
| 1041 // Movsx - copy from a narrower integer type to a wider integer | 1025 // Movsx - copy from a narrower integer type to a wider integer |
| 1042 // type, with sign extension. | 1026 // type, with sign extension. |
| 1043 class InstX8632Movsx : public InstX8632 { | 1027 class InstX8632Movsx : public InstX8632 { |
| 1044 public: | 1028 public: |
| 1045 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) { | 1029 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 1046 return new (Func->allocate<InstX8632Movsx>()) | 1030 return new (Func->allocate<InstX8632Movsx>()) |
| 1047 InstX8632Movsx(Func, Dest, Source); | 1031 InstX8632Movsx(Func, Dest, Source); |
| 1048 } | 1032 } |
| 1049 virtual void emit(const Cfg *Func) const; | 1033 virtual void emit(const Cfg *Func) const; |
| 1050 virtual void dump(const Cfg *Func) const; | 1034 virtual void dump(const Cfg *Func) const; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; | 1219 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; |
| 1236 template <> void InstX8632Psll::emit(const Cfg *Func) const; | 1220 template <> void InstX8632Psll::emit(const Cfg *Func) const; |
| 1237 template <> void InstX8632Psra::emit(const Cfg *Func) const; | 1221 template <> void InstX8632Psra::emit(const Cfg *Func) const; |
| 1238 template <> void InstX8632Psub::emit(const Cfg *Func) const; | 1222 template <> void InstX8632Psub::emit(const Cfg *Func) const; |
| 1239 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; | 1223 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; |
| 1240 template <> void InstX8632Subss::emit(const Cfg *Func) const; | 1224 template <> void InstX8632Subss::emit(const Cfg *Func) const; |
| 1241 | 1225 |
| 1242 } // end of namespace Ice | 1226 } // end of namespace Ice |
| 1243 | 1227 |
| 1244 #endif // SUBZERO_SRC_ICEINSTX8632_H | 1228 #endif // SUBZERO_SRC_ICEINSTX8632_H |
| OLD | NEW |