| OLD | NEW |
| 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- C++ -*-===// | 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 bool getIsArg() const { return IsArgument; } | 689 bool getIsArg() const { return IsArgument; } |
| 690 virtual void setIsArg(bool Val = true) { IsArgument = Val; } | 690 virtual void setIsArg(bool Val = true) { IsArgument = Val; } |
| 691 bool getIsImplicitArg() const { return IsImplicitArgument; } | 691 bool getIsImplicitArg() const { return IsImplicitArgument; } |
| 692 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } | 692 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } |
| 693 | 693 |
| 694 void setIgnoreLiveness() { IgnoreLiveness = true; } | 694 void setIgnoreLiveness() { IgnoreLiveness = true; } |
| 695 bool getIgnoreLiveness() const { | 695 bool getIgnoreLiveness() const { |
| 696 return IgnoreLiveness || IsRematerializable; | 696 return IgnoreLiveness || IsRematerializable; |
| 697 } | 697 } |
| 698 | 698 |
| 699 int32_t getStackOffset() const { return StackOffset; } | 699 bool hasStackOffset() const { return StackOffset != InvalidStackOffset; } |
| 700 int32_t getStackOffset() const { |
| 701 assert(hasStackOffset()); |
| 702 return StackOffset; |
| 703 } |
| 700 void setStackOffset(int32_t Offset) { StackOffset = Offset; } | 704 void setStackOffset(int32_t Offset) { StackOffset = Offset; } |
| 701 /// Returns the variable's stack offset in symbolic form, to improve | 705 /// Returns the variable's stack offset in symbolic form, to improve |
| 702 /// readability in DecorateAsm mode. | 706 /// readability in DecorateAsm mode. |
| 703 std::string getSymbolicStackOffset() const { | 707 std::string getSymbolicStackOffset() const { |
| 704 if (!BuildDefs::dump()) | 708 if (!BuildDefs::dump()) |
| 705 return ""; | 709 return ""; |
| 706 return ".L$lv$" + getName(); | 710 return ".L$lv$" + getName(); |
| 707 } | 711 } |
| 708 | 712 |
| 709 bool hasReg() const { return getRegNum().hasValue(); } | 713 bool hasReg() const { return getRegNum().hasValue(); } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 /// instead of copying the existing assignment. | 770 /// instead of copying the existing assignment. |
| 767 const Variable *asType(const Cfg *Func, Type Ty, RegNumT NewRegNum) const; | 771 const Variable *asType(const Cfg *Func, Type Ty, RegNumT NewRegNum) const; |
| 768 | 772 |
| 769 void emit(const Cfg *Func) const override; | 773 void emit(const Cfg *Func) const override; |
| 770 using Operand::dump; | 774 using Operand::dump; |
| 771 void dump(const Cfg *Func, Ostream &Str) const override; | 775 void dump(const Cfg *Func, Ostream &Str) const override; |
| 772 | 776 |
| 773 /// Return reg num of base register, if different from stack/frame register. | 777 /// Return reg num of base register, if different from stack/frame register. |
| 774 virtual RegNumT getBaseRegNum() const { return RegNumT(); } | 778 virtual RegNumT getBaseRegNum() const { return RegNumT(); } |
| 775 | 779 |
| 776 void setLinkedTo(const Variable *Var) { | 780 /// Access the LinkedTo field. |
| 777 // If B is linked to A, and we now want to link C to B, we instead link C to | 781 void setLinkedTo(Variable *Var) { LinkedTo = Var; } |
| 778 // A so that we have one root (A) and all leaves (B, C) link directly to the | 782 Variable *getLinkedTo() const { return LinkedTo; } |
| 779 // root. | 783 /// Follow the LinkedTo chain up to the furthest ancestor. |
| 780 if (Var->getLinkedTo() != nullptr) { | 784 Variable *getLinkedToRoot() const { |
| 781 Var = Var->LinkedTo; | 785 Variable *Root = LinkedTo; |
| 782 assert(Var->LinkedTo == nullptr); | 786 if (Root == nullptr) |
| 783 } | 787 return nullptr; |
| 784 LinkedTo = Var; | 788 while (Root->LinkedTo != nullptr) |
| 785 } | 789 Root = Root->LinkedTo; |
| 786 const Variable *getLinkedTo() const { | 790 return Root; |
| 787 // Make sure a leaf links directly to the root. | |
| 788 if (LinkedTo != nullptr) | |
| 789 assert(LinkedTo->LinkedTo == nullptr); | |
| 790 return LinkedTo; | |
| 791 } | 791 } |
| 792 | 792 |
| 793 static bool classof(const Operand *Operand) { | 793 static bool classof(const Operand *Operand) { |
| 794 OperandKind Kind = Operand->getKind(); | 794 OperandKind Kind = Operand->getKind(); |
| 795 return Kind >= kVariable && Kind <= kVariable_Max; | 795 return Kind >= kVariable && Kind <= kVariable_Max; |
| 796 } | 796 } |
| 797 | 797 |
| 798 SizeT hashValue() const override { return std::hash<SizeT>()(getIndex()); } | 798 SizeT hashValue() const override { return std::hash<SizeT>()(getIndex()); } |
| 799 | 799 |
| 800 protected: | 800 protected: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 818 bool IgnoreLiveness = false; | 818 bool IgnoreLiveness = false; |
| 819 // If IsRematerializable, RegNum keeps track of which register (stack or frame | 819 // If IsRematerializable, RegNum keeps track of which register (stack or frame |
| 820 // pointer), and StackOffset is the known offset from that register. | 820 // pointer), and StackOffset is the known offset from that register. |
| 821 bool IsRematerializable = false; | 821 bool IsRematerializable = false; |
| 822 RegRequirement RegRequirement = RR_MayHaveRegister; | 822 RegRequirement RegRequirement = RR_MayHaveRegister; |
| 823 RegClass RegisterClass; | 823 RegClass RegisterClass; |
| 824 /// RegNum is the allocated register, (as long as RegNum.hasValue() is true). | 824 /// RegNum is the allocated register, (as long as RegNum.hasValue() is true). |
| 825 RegNumT RegNum; | 825 RegNumT RegNum; |
| 826 /// RegNumTmp is the tentative assignment during register allocation. | 826 /// RegNumTmp is the tentative assignment during register allocation. |
| 827 RegNumT RegNumTmp; | 827 RegNumT RegNumTmp; |
| 828 static constexpr int32_t InvalidStackOffset = -1; |
| 828 /// StackOffset is the canonical location on stack (only if | 829 /// StackOffset is the canonical location on stack (only if |
| 829 /// RegNum.hasNoValue() || IsArgument). | 830 /// RegNum.hasNoValue() || IsArgument). |
| 830 int32_t StackOffset = 0; | 831 int32_t StackOffset = InvalidStackOffset; |
| 831 LiveRange Live; | 832 LiveRange Live; |
| 832 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. | 833 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. |
| 833 Variable *VarsReal[1]; | 834 Variable *VarsReal[1]; |
| 834 /// This Variable may be "linked" to another Variable, such that if neither | 835 /// This Variable may be "linked" to another Variable, such that if neither |
| 835 /// Variable gets a register, they are guaranteed to share a stack location. | 836 /// Variable gets a register, they are guaranteed to share a stack location. |
| 836 const Variable *LinkedTo = nullptr; | 837 Variable *LinkedTo = nullptr; |
| 837 }; | 838 }; |
| 838 | 839 |
| 839 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In | 840 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In |
| 840 // this situation the variable must be split into a low and a high word. | 841 // this situation the variable must be split into a low and a high word. |
| 841 class Variable64On32 : public Variable { | 842 class Variable64On32 : public Variable { |
| 842 Variable64On32() = delete; | 843 Variable64On32() = delete; |
| 843 Variable64On32(const Variable64On32 &) = delete; | 844 Variable64On32(const Variable64On32 &) = delete; |
| 844 Variable64On32 &operator=(const Variable64On32 &) = delete; | 845 Variable64On32 &operator=(const Variable64On32 &) = delete; |
| 845 | 846 |
| 846 public: | 847 public: |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 return Operand->getKind() == kVariableBoolean; | 1044 return Operand->getKind() == kVariableBoolean; |
| 1044 } | 1045 } |
| 1045 | 1046 |
| 1046 private: | 1047 private: |
| 1047 Variable *BoolSource = nullptr; | 1048 Variable *BoolSource = nullptr; |
| 1048 }; | 1049 }; |
| 1049 | 1050 |
| 1050 } // end of namespace Ice | 1051 } // end of namespace Ice |
| 1051 | 1052 |
| 1052 #endif // SUBZERO_SRC_ICEOPERAND_H | 1053 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |