Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: src/IceInstX8632.h

Issue 466733005: Subzero: Factor our commonalities between mov-like instructions. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceInstX8632.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Base class for assignment instructions
575 template <InstX8632::InstKindX8632 K>
576 class InstX8632Movlike : public InstX8632 {
577 public:
578 static InstX8632Movlike *create(Cfg *Func, Variable *Dest, Operand *Source) {
579 return new (Func->allocate<InstX8632Movlike>())
580 InstX8632Movlike(Func, Dest, Source);
581 }
582 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.
583 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0));
584 if (Src == NULL)
585 return false;
586 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) {
587 // TODO: On x86-64, instructions like "mov eax, eax" are used to
588 // clear the upper 32 bits of rax. We need to recognize and
589 // preserve these.
590 return true;
591 }
592 if (!getDest()->hasReg() && !Src->hasReg() &&
593 Dest->getStackOffset() == Src->getStackOffset())
594 return true;
595 return false;
596 }
597 virtual void emit(const Cfg *Func) const;
598 virtual void dump(const Cfg *Func) const {
599 Ostream &Str = Func->getContext()->getStrDump();
600 Str << Opcode << "." << getDest()->getType() << " ";
601 dumpDest(Func);
602 Str << ", ";
603 dumpSources(Func);
604 }
605 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
606
607 private:
608 InstX8632Movlike(Cfg *Func, Variable *Dest, Operand *Source)
609 : InstX8632(Func, K, 1, Dest) {
610 addSource(Source);
611 }
612 InstX8632Movlike(const InstX8632Movlike &) LLVM_DELETED_FUNCTION;
613 InstX8632Movlike &operator=(const InstX8632Movlike &) LLVM_DELETED_FUNCTION;
614 virtual ~InstX8632Movlike() {}
615
616 static const char *Opcode;
617 };
618
574 typedef InstX8632Inplaceop<InstX8632::Bswap> InstX8632Bswap; 619 typedef InstX8632Inplaceop<InstX8632::Bswap> InstX8632Bswap;
575 typedef InstX8632Inplaceop<InstX8632::Neg> InstX8632Neg; 620 typedef InstX8632Inplaceop<InstX8632::Neg> InstX8632Neg;
576 typedef InstX8632Unaryop<InstX8632::Bsf> InstX8632Bsf; 621 typedef InstX8632Unaryop<InstX8632::Bsf> InstX8632Bsf;
577 typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr; 622 typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr;
578 typedef InstX8632Unaryop<InstX8632::Lea> InstX8632Lea; 623 typedef InstX8632Unaryop<InstX8632::Lea> InstX8632Lea;
579 typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd; 624 typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd;
580 typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss; 625 typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss;
581 // Cbwdq instruction - wrapper for cbw, cwd, and cdq 626 // Cbwdq instruction - wrapper for cbw, cwd, and cdq
582 typedef InstX8632Unaryop<InstX8632::Cbwdq> InstX8632Cbwdq; 627 typedef InstX8632Unaryop<InstX8632::Cbwdq> InstX8632Cbwdq;
628 // Move/assignment instruction - wrapper for mov/movss/movsd.
629 typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov;
630 // Move packed - copy 128 bit values between XMM registers, or mem128
631 // and XMM registers.
632 typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp;
633 // Movq - copy between XMM registers, or mem64 and XMM registers.
634 typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq;
583 typedef InstX8632Binop<InstX8632::Add> InstX8632Add; 635 typedef InstX8632Binop<InstX8632::Add> InstX8632Add;
584 typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps; 636 typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps;
585 typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc; 637 typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc;
586 typedef InstX8632Binop<InstX8632::Addss> InstX8632Addss; 638 typedef InstX8632Binop<InstX8632::Addss> InstX8632Addss;
587 typedef InstX8632Binop<InstX8632::Padd> InstX8632Padd; 639 typedef InstX8632Binop<InstX8632::Padd> InstX8632Padd;
588 typedef InstX8632Binop<InstX8632::Sub> InstX8632Sub; 640 typedef InstX8632Binop<InstX8632::Sub> InstX8632Sub;
589 typedef InstX8632Binop<InstX8632::Subps> InstX8632Subps; 641 typedef InstX8632Binop<InstX8632::Subps> InstX8632Subps;
590 typedef InstX8632Binop<InstX8632::Subss> InstX8632Subss; 642 typedef InstX8632Binop<InstX8632::Subss> InstX8632Subss;
591 typedef InstX8632Binop<InstX8632::Sbb> InstX8632Sbb; 643 typedef InstX8632Binop<InstX8632::Sbb> InstX8632Sbb;
592 typedef InstX8632Binop<InstX8632::Psub> InstX8632Psub; 644 typedef InstX8632Binop<InstX8632::Psub> InstX8632Psub;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 virtual void dump(const Cfg *Func) const; 988 virtual void dump(const Cfg *Func) const;
937 static bool classof(const Inst *Inst) { return isClassof(Inst, Store); } 989 static bool classof(const Inst *Inst) { return isClassof(Inst, Store); }
938 990
939 private: 991 private:
940 InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem); 992 InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem);
941 InstX8632Store(const InstX8632Store &) LLVM_DELETED_FUNCTION; 993 InstX8632Store(const InstX8632Store &) LLVM_DELETED_FUNCTION;
942 InstX8632Store &operator=(const InstX8632Store &) LLVM_DELETED_FUNCTION; 994 InstX8632Store &operator=(const InstX8632Store &) LLVM_DELETED_FUNCTION;
943 virtual ~InstX8632Store() {} 995 virtual ~InstX8632Store() {}
944 }; 996 };
945 997
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 { 998 class InstX8632StoreP : public InstX8632 {
986 public: 999 public:
987 static InstX8632StoreP *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) { 1000 static InstX8632StoreP *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) {
988 return new (Func->allocate<InstX8632StoreP>()) 1001 return new (Func->allocate<InstX8632StoreP>())
989 InstX8632StoreP(Func, Value, Mem); 1002 InstX8632StoreP(Func, Value, Mem);
990 } 1003 }
991 virtual void emit(const Cfg *Func) const; 1004 virtual void emit(const Cfg *Func) const;
992 virtual void dump(const Cfg *Func) const; 1005 virtual void dump(const Cfg *Func) const;
993 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreP); } 1006 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreP); }
994 1007
(...skipping 17 matching lines...) Expand all
1012 virtual void dump(const Cfg *Func) const; 1025 virtual void dump(const Cfg *Func) const;
1013 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); } 1026 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); }
1014 1027
1015 private: 1028 private:
1016 InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem); 1029 InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem);
1017 InstX8632StoreQ(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION; 1030 InstX8632StoreQ(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION;
1018 InstX8632StoreQ &operator=(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION; 1031 InstX8632StoreQ &operator=(const InstX8632StoreQ &) LLVM_DELETED_FUNCTION;
1019 virtual ~InstX8632StoreQ() {} 1032 virtual ~InstX8632StoreQ() {}
1020 }; 1033 };
1021 1034
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 1035 // Movsx - copy from a narrower integer type to a wider integer
1042 // type, with sign extension. 1036 // type, with sign extension.
1043 class InstX8632Movsx : public InstX8632 { 1037 class InstX8632Movsx : public InstX8632 {
1044 public: 1038 public:
1045 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) { 1039 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) {
1046 return new (Func->allocate<InstX8632Movsx>()) 1040 return new (Func->allocate<InstX8632Movsx>())
1047 InstX8632Movsx(Func, Dest, Source); 1041 InstX8632Movsx(Func, Dest, Source);
1048 } 1042 }
1049 virtual void emit(const Cfg *Func) const; 1043 virtual void emit(const Cfg *Func) const;
1050 virtual void dump(const Cfg *Func) const; 1044 virtual void dump(const Cfg *Func) const;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; 1229 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const;
1236 template <> void InstX8632Psll::emit(const Cfg *Func) const; 1230 template <> void InstX8632Psll::emit(const Cfg *Func) const;
1237 template <> void InstX8632Psra::emit(const Cfg *Func) const; 1231 template <> void InstX8632Psra::emit(const Cfg *Func) const;
1238 template <> void InstX8632Psub::emit(const Cfg *Func) const; 1232 template <> void InstX8632Psub::emit(const Cfg *Func) const;
1239 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; 1233 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const;
1240 template <> void InstX8632Subss::emit(const Cfg *Func) const; 1234 template <> void InstX8632Subss::emit(const Cfg *Func) const;
1241 1235
1242 } // end of namespace Ice 1236 } // end of namespace Ice
1243 1237
1244 #endif // SUBZERO_SRC_ICEINSTX8632_H 1238 #endif // SUBZERO_SRC_ICEINSTX8632_H
OLDNEW
« no previous file with comments | « no previous file | src/IceInstX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698