| 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 // This file declares the Operand class and its target-independent | 10 // This file declares the Operand class and its target-independent |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 if (!ALLOW_DUMP) | 72 if (!ALLOW_DUMP) |
| 73 return; | 73 return; |
| 74 assert(Func); | 74 assert(Func); |
| 75 dump(Func, Func->getContext()->getStrDump()); | 75 dump(Func, Func->getContext()->getStrDump()); |
| 76 } | 76 } |
| 77 void dump(Ostream &Str) const { | 77 void dump(Ostream &Str) const { |
| 78 if (ALLOW_DUMP) | 78 if (ALLOW_DUMP) |
| 79 dump(nullptr, Str); | 79 dump(nullptr, Str); |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual ~Operand() {} | |
| 83 | |
| 84 protected: | 82 protected: |
| 85 Operand(OperandKind Kind, Type Ty) | 83 Operand(OperandKind Kind, Type Ty) |
| 86 : Ty(Ty), Kind(Kind), NumVars(0), Vars(nullptr) {} | 84 : Ty(Ty), Kind(Kind), NumVars(0), Vars(nullptr) {} |
| 87 | 85 |
| 88 const Type Ty; | 86 const Type Ty; |
| 89 const OperandKind Kind; | 87 const OperandKind Kind; |
| 90 // Vars and NumVars are initialized by the derived class. | 88 // Vars and NumVars are initialized by the derived class. |
| 91 SizeT NumVars; | 89 SizeT NumVars; |
| 92 Variable **Vars; | 90 Variable **Vars; |
| 93 }; | 91 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 116 OperandKind Kind = Operand->getKind(); | 114 OperandKind Kind = Operand->getKind(); |
| 117 return Kind >= kConst_Base && Kind <= kConst_Num; | 115 return Kind >= kConst_Base && Kind <= kConst_Num; |
| 118 } | 116 } |
| 119 | 117 |
| 120 protected: | 118 protected: |
| 121 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) | 119 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) |
| 122 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { | 120 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { |
| 123 Vars = nullptr; | 121 Vars = nullptr; |
| 124 NumVars = 0; | 122 NumVars = 0; |
| 125 } | 123 } |
| 126 ~Constant() override {} | |
| 127 // PoolEntryID is an integer that uniquely identifies the constant | 124 // PoolEntryID is an integer that uniquely identifies the constant |
| 128 // within its constant pool. It is used for building the constant | 125 // within its constant pool. It is used for building the constant |
| 129 // pool in the object code and for referencing its entries. | 126 // pool in the object code and for referencing its entries. |
| 130 const uint32_t PoolEntryID; | 127 const uint32_t PoolEntryID; |
| 131 }; | 128 }; |
| 132 | 129 |
| 133 // ConstantPrimitive<> wraps a primitive type. | 130 // ConstantPrimitive<> wraps a primitive type. |
| 134 template <typename T, Operand::OperandKind K> | 131 template <typename T, Operand::OperandKind K> |
| 135 class ConstantPrimitive : public Constant { | 132 class ConstantPrimitive : public Constant { |
| 136 ConstantPrimitive() = delete; | 133 ConstantPrimitive() = delete; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 156 Str << getValue(); | 153 Str << getValue(); |
| 157 } | 154 } |
| 158 | 155 |
| 159 static bool classof(const Operand *Operand) { | 156 static bool classof(const Operand *Operand) { |
| 160 return Operand->getKind() == K; | 157 return Operand->getKind() == K; |
| 161 } | 158 } |
| 162 | 159 |
| 163 private: | 160 private: |
| 164 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) | 161 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) |
| 165 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 162 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 166 ~ConstantPrimitive() override {} | |
| 167 const PrimType Value; | 163 const PrimType Value; |
| 168 }; | 164 }; |
| 169 | 165 |
| 170 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; | 166 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; |
| 171 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; | 167 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; |
| 172 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 168 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
| 173 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 169 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
| 174 | 170 |
| 175 template <> | 171 template <> |
| 176 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { | 172 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 static bool classof(const Operand *Operand) { | 237 static bool classof(const Operand *Operand) { |
| 242 OperandKind Kind = Operand->getKind(); | 238 OperandKind Kind = Operand->getKind(); |
| 243 return Kind == kConstRelocatable; | 239 return Kind == kConstRelocatable; |
| 244 } | 240 } |
| 245 | 241 |
| 246 private: | 242 private: |
| 247 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, | 243 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, |
| 248 bool SuppressMangling, uint32_t PoolEntryID) | 244 bool SuppressMangling, uint32_t PoolEntryID) |
| 249 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), | 245 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), |
| 250 Name(Name), SuppressMangling(SuppressMangling) {} | 246 Name(Name), SuppressMangling(SuppressMangling) {} |
| 251 ~ConstantRelocatable() override {} | |
| 252 const RelocOffsetT Offset; // fixed offset to add | 247 const RelocOffsetT Offset; // fixed offset to add |
| 253 const IceString Name; // optional for debug/dump | 248 const IceString Name; // optional for debug/dump |
| 254 bool SuppressMangling; | 249 bool SuppressMangling; |
| 255 }; | 250 }; |
| 256 | 251 |
| 257 // ConstantUndef represents an unspecified bit pattern. Although it is | 252 // ConstantUndef represents an unspecified bit pattern. Although it is |
| 258 // legal to lower ConstantUndef to any value, backends should try to | 253 // legal to lower ConstantUndef to any value, backends should try to |
| 259 // make code generation deterministic by lowering ConstantUndefs to 0. | 254 // make code generation deterministic by lowering ConstantUndefs to 0. |
| 260 class ConstantUndef : public Constant { | 255 class ConstantUndef : public Constant { |
| 261 ConstantUndef() = delete; | 256 ConstantUndef() = delete; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 278 Str << "undef"; | 273 Str << "undef"; |
| 279 } | 274 } |
| 280 | 275 |
| 281 static bool classof(const Operand *Operand) { | 276 static bool classof(const Operand *Operand) { |
| 282 return Operand->getKind() == kConstUndef; | 277 return Operand->getKind() == kConstUndef; |
| 283 } | 278 } |
| 284 | 279 |
| 285 private: | 280 private: |
| 286 ConstantUndef(Type Ty, uint32_t PoolEntryID) | 281 ConstantUndef(Type Ty, uint32_t PoolEntryID) |
| 287 : Constant(kConstUndef, Ty, PoolEntryID) {} | 282 : Constant(kConstUndef, Ty, PoolEntryID) {} |
| 288 ~ConstantUndef() override {} | |
| 289 }; | 283 }; |
| 290 | 284 |
| 291 // RegWeight is a wrapper for a uint32_t weight value, with a | 285 // RegWeight is a wrapper for a uint32_t weight value, with a |
| 292 // special value that represents infinite weight, and an addWeight() | 286 // special value that represents infinite weight, and an addWeight() |
| 293 // method that ensures that W+infinity=infinity. | 287 // method that ensures that W+infinity=infinity. |
| 294 class RegWeight { | 288 class RegWeight { |
| 295 public: | 289 public: |
| 296 RegWeight() : Weight(0) {} | 290 RegWeight() : Weight(0) {} |
| 297 explicit RegWeight(uint32_t Weight) : Weight(Weight) {} | 291 explicit RegWeight(uint32_t Weight) : Weight(Weight) {} |
| 298 RegWeight(const RegWeight &) = default; | 292 RegWeight(const RegWeight &) = default; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 protected: | 481 protected: |
| 488 Variable(OperandKind K, Type Ty, SizeT Index) | 482 Variable(OperandKind K, Type Ty, SizeT Index) |
| 489 : Operand(K, Ty), Number(Index), NameIndex(Cfg::IdentifierIndexInvalid), | 483 : Operand(K, Ty), Number(Index), NameIndex(Cfg::IdentifierIndexInvalid), |
| 490 IsArgument(false), IsImplicitArgument(false), IgnoreLiveness(false), | 484 IsArgument(false), IsImplicitArgument(false), IgnoreLiveness(false), |
| 491 StackOffset(0), RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1), | 485 StackOffset(0), RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1), |
| 492 LoVar(nullptr), HiVar(nullptr) { | 486 LoVar(nullptr), HiVar(nullptr) { |
| 493 Vars = VarsReal; | 487 Vars = VarsReal; |
| 494 Vars[0] = this; | 488 Vars[0] = this; |
| 495 NumVars = 1; | 489 NumVars = 1; |
| 496 } | 490 } |
| 497 ~Variable() override {} | |
| 498 // Number is unique across all variables, and is used as a | 491 // Number is unique across all variables, and is used as a |
| 499 // (bit)vector index for liveness analysis. | 492 // (bit)vector index for liveness analysis. |
| 500 const SizeT Number; | 493 const SizeT Number; |
| 501 Cfg::IdentifierIndexType NameIndex; | 494 Cfg::IdentifierIndexType NameIndex; |
| 502 bool IsArgument; | 495 bool IsArgument; |
| 503 bool IsImplicitArgument; | 496 bool IsImplicitArgument; |
| 504 // IgnoreLiveness means that the variable should be ignored when | 497 // IgnoreLiveness means that the variable should be ignored when |
| 505 // constructing and validating live ranges. This is usually | 498 // constructing and validating live ranges. This is usually |
| 506 // reserved for the stack pointer. | 499 // reserved for the stack pointer. |
| 507 bool IgnoreLiveness; | 500 bool IgnoreLiveness; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 private: | 624 private: |
| 632 const Cfg *Func; | 625 const Cfg *Func; |
| 633 MetadataKind Kind; | 626 MetadataKind Kind; |
| 634 std::vector<VariableTracking> Metadata; | 627 std::vector<VariableTracking> Metadata; |
| 635 const static InstDefList NoDefinitions; | 628 const static InstDefList NoDefinitions; |
| 636 }; | 629 }; |
| 637 | 630 |
| 638 } // end of namespace Ice | 631 } // end of namespace Ice |
| 639 | 632 |
| 640 #endif // SUBZERO_SRC_ICEOPERAND_H | 633 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |