Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// | 1 //===- subzero/src/IceInst.h - High-level 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 Inst class and its target-independent | 10 // This file declares the Inst class and its target-independent |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 // dest wouldn't be properly initialized. | 723 // dest wouldn't be properly initialized. |
| 724 class InstFakeDef : public InstHighLevel { | 724 class InstFakeDef : public InstHighLevel { |
| 725 InstFakeDef(const InstFakeDef &) = delete; | 725 InstFakeDef(const InstFakeDef &) = delete; |
| 726 InstFakeDef &operator=(const InstFakeDef &) = delete; | 726 InstFakeDef &operator=(const InstFakeDef &) = delete; |
| 727 | 727 |
| 728 public: | 728 public: |
| 729 static InstFakeDef *create(Cfg *Func, Variable *Dest, Variable *Src = NULL) { | 729 static InstFakeDef *create(Cfg *Func, Variable *Dest, Variable *Src = NULL) { |
| 730 return new (Func->allocateInst<InstFakeDef>()) InstFakeDef(Func, Dest, Src); | 730 return new (Func->allocateInst<InstFakeDef>()) InstFakeDef(Func, Dest, Src); |
| 731 } | 731 } |
| 732 void emit(const Cfg *Func) const override; | 732 void emit(const Cfg *Func) const override; |
| 733 void emitIAS(const Cfg *Func) const override { emit(Func); } | 733 void emitIAS(const Cfg * /* Func */) const override {} |
| 734 void dump(const Cfg *Func) const override; | 734 void dump(const Cfg *Func) const override; |
| 735 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; } | 735 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; } |
| 736 | 736 |
| 737 private: | 737 private: |
| 738 InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src); | 738 InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src); |
| 739 ~InstFakeDef() override {} | 739 ~InstFakeDef() override {} |
| 740 }; | 740 }; |
| 741 | 741 |
| 742 // FakeUse instruction. This creates a fake use of a variable, to | 742 // FakeUse instruction. This creates a fake use of a variable, to |
| 743 // keep the instruction that produces that variable from being | 743 // keep the instruction that produces that variable from being |
| 744 // dead-code eliminated. This is useful in a variety of lowering | 744 // dead-code eliminated. This is useful in a variety of lowering |
| 745 // situations. The FakeUse instruction has no dest, so it can itself | 745 // situations. The FakeUse instruction has no dest, so it can itself |
| 746 // never be dead-code eliminated. | 746 // never be dead-code eliminated. |
| 747 class InstFakeUse : public InstHighLevel { | 747 class InstFakeUse : public InstHighLevel { |
| 748 InstFakeUse(const InstFakeUse &) = delete; | 748 InstFakeUse(const InstFakeUse &) = delete; |
| 749 InstFakeUse &operator=(const InstFakeUse &) = delete; | 749 InstFakeUse &operator=(const InstFakeUse &) = delete; |
| 750 | 750 |
| 751 public: | 751 public: |
| 752 static InstFakeUse *create(Cfg *Func, Variable *Src) { | 752 static InstFakeUse *create(Cfg *Func, Variable *Src) { |
| 753 return new (Func->allocateInst<InstFakeUse>()) InstFakeUse(Func, Src); | 753 return new (Func->allocateInst<InstFakeUse>()) InstFakeUse(Func, Src); |
| 754 } | 754 } |
| 755 void emit(const Cfg *Func) const override; | 755 void emit(const Cfg *Func) const override; |
| 756 void emitIAS(const Cfg *Func) const override { emit(Func); } | 756 void emitIAS(const Cfg * /* Func */) const override {} |
| 757 void dump(const Cfg *Func) const override; | 757 void dump(const Cfg *Func) const override; |
| 758 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeUse; } | 758 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeUse; } |
| 759 | 759 |
| 760 private: | 760 private: |
| 761 InstFakeUse(Cfg *Func, Variable *Src); | 761 InstFakeUse(Cfg *Func, Variable *Src); |
| 762 ~InstFakeUse() override {} | 762 ~InstFakeUse() override {} |
| 763 }; | 763 }; |
| 764 | 764 |
| 765 // FakeKill instruction. This "kills" a set of variables by adding a | 765 // FakeKill instruction. This "kills" a set of variables by adding a |
| 766 // trivial live range at this instruction to each variable. The | 766 // trivial live range at this instruction to each variable. The |
| 767 // primary use is to indicate that scratch registers are killed after | 767 // primary use is to indicate that scratch registers are killed after |
| 768 // a call, so that the register allocator won't assign a scratch | 768 // a call, so that the register allocator won't assign a scratch |
| 769 // register to a variable whose live range spans a call. | 769 // register to a variable whose live range spans a call. |
| 770 // | 770 // |
| 771 // The FakeKill instruction also holds a pointer to the instruction | 771 // The FakeKill instruction also holds a pointer to the instruction |
| 772 // that kills the set of variables, so that if that linked instruction | 772 // that kills the set of variables, so that if that linked instruction |
| 773 // gets dead-code eliminated, the FakeKill instruction will as well. | 773 // gets dead-code eliminated, the FakeKill instruction will as well. |
| 774 class InstFakeKill : public InstHighLevel { | 774 class InstFakeKill : public InstHighLevel { |
| 775 InstFakeKill(const InstFakeKill &) = delete; | 775 InstFakeKill(const InstFakeKill &) = delete; |
| 776 InstFakeKill &operator=(const InstFakeKill &) = delete; | 776 InstFakeKill &operator=(const InstFakeKill &) = delete; |
| 777 | 777 |
| 778 public: | 778 public: |
| 779 static InstFakeKill *create(Cfg *Func, const VarList &KilledRegs, | 779 static InstFakeKill *create(Cfg *Func, const VarList &KilledRegs, |
| 780 const Inst *Linked) { | 780 const Inst *Linked) { |
| 781 return new (Func->allocateInst<InstFakeKill>()) | 781 return new (Func->allocateInst<InstFakeKill>()) |
| 782 InstFakeKill(Func, KilledRegs, Linked); | 782 InstFakeKill(Func, KilledRegs, Linked); |
| 783 } | 783 } |
| 784 const Inst *getLinked() const { return Linked; } | 784 const Inst *getLinked() const { return Linked; } |
| 785 void emit(const Cfg *Func) const override; | 785 void emit(const Cfg *Func) const override; |
| 786 void emitIAS(const Cfg *Func) const override { emit(Func); } | 786 void emitIAS(const Cfg * /* Func */) const override {} |
| 787 void dump(const Cfg *Func) const override; | 787 void dump(const Cfg *Func) const override; |
| 788 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeKill; } | 788 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeKill; } |
| 789 | 789 |
| 790 private: | 790 private: |
| 791 InstFakeKill(Cfg *Func, const VarList &KilledRegs, const Inst *Linked); | 791 InstFakeKill(Cfg *Func, const VarList &KilledRegs, const Inst *Linked); |
| 792 ~InstFakeKill() override {} | 792 ~InstFakeKill() override {} |
| 793 | 793 |
| 794 // This instruction is ignored if Linked->isDeleted() is true. | 794 // This instruction is ignored if Linked->isDeleted() is true. |
| 795 const Inst *Linked; | 795 const Inst *Linked; |
| 796 }; | 796 }; |
| 797 | 797 |
| 798 // The Target instruction is the base class for all target-specific | 798 // The Target instruction is the base class for all target-specific |
| 799 // instructions. | 799 // instructions. |
| 800 class InstTarget : public Inst { | 800 class InstTarget : public Inst { |
| 801 InstTarget(const InstTarget &) = delete; | 801 InstTarget(const InstTarget &) = delete; |
| 802 InstTarget &operator=(const InstTarget &) = delete; | 802 InstTarget &operator=(const InstTarget &) = delete; |
| 803 | 803 |
| 804 public: | 804 public: |
| 805 uint32_t getEmitInstCount() const override { return 1; } | 805 uint32_t getEmitInstCount() const override { return 1; } |
| 806 void dump(const Cfg *Func) const override; | 806 void dump(const Cfg *Func) const override; |
| 807 static bool classof(const Inst *Inst) { return Inst->getKind() >= Target; } | 807 static bool classof(const Inst *Inst) { return Inst->getKind() >= Target; } |
| 808 | 808 |
| 809 protected: | 809 protected: |
| 810 InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) | 810 InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) |
| 811 : Inst(Func, Kind, MaxSrcs, Dest) { | 811 : Inst(Func, Kind, MaxSrcs, Dest) { |
| 812 assert(Kind >= Target); | 812 assert(Kind >= Target); |
| 813 } | 813 } |
| 814 void emitIAS(const Cfg *Func) const override { emit(Func); } | |
|
Jim Stichnoth
2014/10/16 02:48:16
Cool!
| |
| 815 ~InstTarget() override {} | 814 ~InstTarget() override {} |
| 816 }; | 815 }; |
| 817 | 816 |
| 818 } // end of namespace Ice | 817 } // end of namespace Ice |
| 819 | 818 |
| 820 #endif // SUBZERO_SRC_ICEINST_H | 819 #endif // SUBZERO_SRC_ICEINST_H |
| OLD | NEW |