Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 dump(Func, Func->getContext()->getStrDump()); | 87 dump(Func, Func->getContext()->getStrDump()); |
| 88 } | 88 } |
| 89 void dump(Ostream &Str) const { | 89 void dump(Ostream &Str) const { |
| 90 if (BuildDefs::dump()) | 90 if (BuildDefs::dump()) |
| 91 dump(nullptr, Str); | 91 dump(nullptr, Str); |
| 92 } | 92 } |
| 93 /// @} | 93 /// @} |
| 94 | 94 |
| 95 virtual ~Operand() = default; | 95 virtual ~Operand() = default; |
| 96 | 96 |
| 97 CfgNode *getDefNode() const { return DefNode; } | |
| 98 | |
| 99 void setDefNode(CfgNode *node) { this->DefNode = node; } | |
| 100 | |
| 97 protected: | 101 protected: |
| 98 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { | 102 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { |
| 99 // It is undefined behavior to have a larger value in the enum | 103 // It is undefined behavior to have a larger value in the enum |
| 100 assert(Kind <= kTarget_Max); | 104 assert(Kind <= kTarget_Max); |
| 101 } | 105 } |
| 102 | 106 |
| 103 const Type Ty; | 107 const Type Ty; |
| 104 const OperandKind Kind; | 108 const OperandKind Kind; |
| 105 /// Vars and NumVars are initialized by the derived class. | 109 /// Vars and NumVars are initialized by the derived class. |
| 106 SizeT NumVars = 0; | 110 SizeT NumVars = 0; |
| 107 Variable **Vars = nullptr; | 111 Variable **Vars = nullptr; |
| 112 | |
| 113 CfgNode *DefNode = nullptr; | |
| 108 }; | 114 }; |
| 109 | 115 |
| 110 template <class StreamType> | 116 template <class StreamType> |
| 111 inline StreamType &operator<<(StreamType &Str, const Operand &Op) { | 117 inline StreamType &operator<<(StreamType &Str, const Operand &Op) { |
| 112 Op.dump(Str); | 118 Op.dump(Str); |
| 113 return Str; | 119 return Str; |
| 114 } | 120 } |
| 115 | 121 |
| 116 /// Constant is the abstract base class for constants. All constants are | 122 /// Constant is the abstract base class for constants. All constants are |
| 117 /// allocated from a global arena and are pooled. | 123 /// allocated from a global arena and are pooled. |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 732 void dump(const Cfg *Func, Ostream &Str) const override; | 738 void dump(const Cfg *Func, Ostream &Str) const override; |
| 733 | 739 |
| 734 /// Return reg num of base register, if different from stack/frame register. | 740 /// Return reg num of base register, if different from stack/frame register. |
| 735 virtual RegNumT getBaseRegNum() const { return RegNumT(); } | 741 virtual RegNumT getBaseRegNum() const { return RegNumT(); } |
| 736 | 742 |
| 737 static bool classof(const Operand *Operand) { | 743 static bool classof(const Operand *Operand) { |
| 738 OperandKind Kind = Operand->getKind(); | 744 OperandKind Kind = Operand->getKind(); |
| 739 return Kind >= kVariable && Kind <= kVariable_Max; | 745 return Kind >= kVariable && Kind <= kVariable_Max; |
| 740 } | 746 } |
| 741 | 747 |
| 748 void setDefiningInst(Inst *I) { DefiningInst = I; } | |
| 749 Inst *getDefiningInst() const { return DefiningInst; } | |
| 750 | |
| 742 protected: | 751 protected: |
| 743 Variable(OperandKind K, Type Ty, SizeT Index) | 752 Variable(OperandKind K, Type Ty, SizeT Index) |
| 744 : Operand(K, Ty), Number(Index), | 753 : Operand(K, Ty), Number(Index), |
| 745 RegisterClass(static_cast<RegClass>(Ty)) { | 754 RegisterClass(static_cast<RegClass>(Ty)) { |
| 746 Vars = VarsReal; | 755 Vars = VarsReal; |
| 747 Vars[0] = this; | 756 Vars[0] = this; |
| 748 NumVars = 1; | 757 NumVars = 1; |
| 749 } | 758 } |
| 750 /// Number is unique across all variables, and is used as a (bit)vector index | 759 /// Number is unique across all variables, and is used as a (bit)vector index |
| 751 /// for liveness analysis. | 760 /// for liveness analysis. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 765 /// RegNum is the allocated register, (as long as RegNum.hasValue() is true). | 774 /// RegNum is the allocated register, (as long as RegNum.hasValue() is true). |
| 766 RegNumT RegNum; | 775 RegNumT RegNum; |
| 767 /// RegNumTmp is the tentative assignment during register allocation. | 776 /// RegNumTmp is the tentative assignment during register allocation. |
| 768 RegNumT RegNumTmp; | 777 RegNumT RegNumTmp; |
| 769 /// StackOffset is the canonical location on stack (only if | 778 /// StackOffset is the canonical location on stack (only if |
| 770 /// RegNum.hasNoValue() || IsArgument). | 779 /// RegNum.hasNoValue() || IsArgument). |
| 771 int32_t StackOffset = 0; | 780 int32_t StackOffset = 0; |
| 772 LiveRange Live; | 781 LiveRange Live; |
| 773 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. | 782 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. |
| 774 Variable *VarsReal[1]; | 783 Variable *VarsReal[1]; |
| 784 /// A pointer to the instruction of which this is the destination. | |
| 785 Inst *DefiningInst = nullptr; | |
|
Jim Stichnoth
2016/03/29 17:49:57
I'm not super excited about increasing the size of
Eric Holk
2016/03/29 22:58:07
I added a couple unordered_maps and removed the ex
| |
| 775 }; | 786 }; |
| 776 | 787 |
| 777 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In | 788 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In |
| 778 // this situation the variable must be split into a low and a high word. | 789 // this situation the variable must be split into a low and a high word. |
| 779 class Variable64On32 : public Variable { | 790 class Variable64On32 : public Variable { |
| 780 Variable64On32() = delete; | 791 Variable64On32() = delete; |
| 781 Variable64On32(const Variable64On32 &) = delete; | 792 Variable64On32(const Variable64On32 &) = delete; |
| 782 Variable64On32 &operator=(const Variable64On32 &) = delete; | 793 Variable64On32 &operator=(const Variable64On32 &) = delete; |
| 783 | 794 |
| 784 public: | 795 public: |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 943 private: | 954 private: |
| 944 const Cfg *Func; | 955 const Cfg *Func; |
| 945 MetadataKind Kind; | 956 MetadataKind Kind; |
| 946 CfgVector<VariableTracking> Metadata; | 957 CfgVector<VariableTracking> Metadata; |
| 947 const static InstDefList NoDefinitions; | 958 const static InstDefList NoDefinitions; |
| 948 }; | 959 }; |
| 949 | 960 |
| 950 } // end of namespace Ice | 961 } // end of namespace Ice |
| 951 | 962 |
| 952 #endif // SUBZERO_SRC_ICEOPERAND_H | 963 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |