| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 void dump(Ostream &Str) const { | 91 void dump(Ostream &Str) const { |
| 92 if (BuildDefs::dump()) | 92 if (BuildDefs::dump()) |
| 93 dump(nullptr, Str); | 93 dump(nullptr, Str); |
| 94 } | 94 } |
| 95 /// @} | 95 /// @} |
| 96 | 96 |
| 97 virtual ~Operand() = default; | 97 virtual ~Operand() = default; |
| 98 | 98 |
| 99 virtual Variable *asBoolean() { return nullptr; } | 99 virtual Variable *asBoolean() { return nullptr; } |
| 100 | 100 |
| 101 virtual SizeT hashValue() const { |
| 102 llvm::report_fatal_error("Tried to hash unsupported operand type : " + |
| 103 std::to_string(Kind)); |
| 104 return 0; |
| 105 } |
| 106 |
| 101 protected: | 107 protected: |
| 102 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { | 108 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { |
| 103 // It is undefined behavior to have a larger value in the enum | 109 // It is undefined behavior to have a larger value in the enum |
| 104 assert(Kind <= kTarget_Max); | 110 assert(Kind <= kTarget_Max); |
| 105 } | 111 } |
| 106 | 112 |
| 107 const Type Ty; | 113 const Type Ty; |
| 108 const OperandKind Kind; | 114 const OperandKind Kind; |
| 109 /// Vars and NumVars are initialized by the derived class. | 115 /// Vars and NumVars are initialized by the derived class. |
| 110 SizeT NumVars = 0; | 116 SizeT NumVars = 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 bool getShouldBePooled() const { return ShouldBePooled; } | 152 bool getShouldBePooled() const { return ShouldBePooled; } |
| 147 | 153 |
| 148 // This should be thread-safe because the constant pool lock is acquired | 154 // This should be thread-safe because the constant pool lock is acquired |
| 149 // before the method is invoked. | 155 // before the method is invoked. |
| 150 void updateLookupCount() { | 156 void updateLookupCount() { |
| 151 if (!BuildDefs::dump()) | 157 if (!BuildDefs::dump()) |
| 152 return; | 158 return; |
| 153 ++LookupCount; | 159 ++LookupCount; |
| 154 } | 160 } |
| 155 CounterType getLookupCount() const { return LookupCount; } | 161 CounterType getLookupCount() const { return LookupCount; } |
| 162 SizeT hashValue() const override { return 0; } |
| 156 | 163 |
| 157 protected: | 164 protected: |
| 158 Constant(OperandKind Kind, Type Ty) : Operand(Kind, Ty) { | 165 Constant(OperandKind Kind, Type Ty) : Operand(Kind, Ty) { |
| 159 Vars = nullptr; | 166 Vars = nullptr; |
| 160 NumVars = 0; | 167 NumVars = 0; |
| 161 } | 168 } |
| 162 /// Set the ShouldBePooled field to the proper value after the object is fully | 169 /// Set the ShouldBePooled field to the proper value after the object is fully |
| 163 /// initialized. | 170 /// initialized. |
| 164 void initShouldBePooled(); | 171 void initShouldBePooled(); |
| 165 GlobalString LabelName; | 172 GlobalString LabelName; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 using Constant::dump; | 204 using Constant::dump; |
| 198 void dump(const Cfg *, Ostream &Str) const override { | 205 void dump(const Cfg *, Ostream &Str) const override { |
| 199 if (BuildDefs::dump()) | 206 if (BuildDefs::dump()) |
| 200 Str << getValue(); | 207 Str << getValue(); |
| 201 } | 208 } |
| 202 | 209 |
| 203 static bool classof(const Operand *Operand) { | 210 static bool classof(const Operand *Operand) { |
| 204 return Operand->getKind() == K; | 211 return Operand->getKind() == K; |
| 205 } | 212 } |
| 206 | 213 |
| 214 SizeT hashValue() const override { |
| 215 return std::hash<PrimType>()(Value); |
| 216 } |
| 217 |
| 207 virtual bool shouldBeRandomizedOrPooled() const override { return false; } | 218 virtual bool shouldBeRandomizedOrPooled() const override { return false; } |
| 208 | 219 |
| 209 private: | 220 private: |
| 210 ConstantPrimitive(Type Ty, PrimType Value) : Constant(K, Ty), Value(Value) {} | 221 ConstantPrimitive(Type Ty, PrimType Value) : Constant(K, Ty), Value(Value) {} |
| 211 | 222 |
| 212 void initName(GlobalContext *Ctx) { | 223 void initName(GlobalContext *Ctx) { |
| 213 std::string Buffer; | 224 std::string Buffer; |
| 214 llvm::raw_string_ostream Str(Buffer); | 225 llvm::raw_string_ostream Str(Buffer); |
| 215 constexpr bool IsCompact = !BuildDefs::dump(); | 226 constexpr bool IsCompact = !BuildDefs::dump(); |
| 216 if (IsCompact) { | 227 if (IsCompact) { |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 void dump(const Cfg *Func, Ostream &Str) const override; | 773 void dump(const Cfg *Func, Ostream &Str) const override; |
| 763 | 774 |
| 764 /// Return reg num of base register, if different from stack/frame register. | 775 /// Return reg num of base register, if different from stack/frame register. |
| 765 virtual RegNumT getBaseRegNum() const { return RegNumT(); } | 776 virtual RegNumT getBaseRegNum() const { return RegNumT(); } |
| 766 | 777 |
| 767 static bool classof(const Operand *Operand) { | 778 static bool classof(const Operand *Operand) { |
| 768 OperandKind Kind = Operand->getKind(); | 779 OperandKind Kind = Operand->getKind(); |
| 769 return Kind >= kVariable && Kind <= kVariable_Max; | 780 return Kind >= kVariable && Kind <= kVariable_Max; |
| 770 } | 781 } |
| 771 | 782 |
| 783 SizeT hashValue() const override { |
| 784 return std::hash<SizeT>()(getIndex()); |
| 785 } |
| 786 |
| 772 protected: | 787 protected: |
| 773 Variable(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) | 788 Variable(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) |
| 774 : Operand(K, Ty), Number(Index), | 789 : Operand(K, Ty), Number(Index), |
| 775 Name(VariableString::createWithoutString(Func)), | 790 Name(VariableString::createWithoutString(Func)), |
| 776 RegisterClass(static_cast<RegClass>(Ty)) { | 791 RegisterClass(static_cast<RegClass>(Ty)) { |
| 777 Vars = VarsReal; | 792 Vars = VarsReal; |
| 778 Vars[0] = this; | 793 Vars[0] = this; |
| 779 NumVars = 1; | 794 NumVars = 1; |
| 780 } | 795 } |
| 781 /// Number is unique across all variables, and is used as a (bit)vector index | 796 /// Number is unique across all variables, and is used as a (bit)vector index |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 return Operand->getKind() == kVariableBoolean; | 1027 return Operand->getKind() == kVariableBoolean; |
| 1013 } | 1028 } |
| 1014 | 1029 |
| 1015 private: | 1030 private: |
| 1016 Variable *BoolSource = nullptr; | 1031 Variable *BoolSource = nullptr; |
| 1017 }; | 1032 }; |
| 1018 | 1033 |
| 1019 } // end of namespace Ice | 1034 } // end of namespace Ice |
| 1020 | 1035 |
| 1021 #endif // SUBZERO_SRC_ICEOPERAND_H | 1036 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |