| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 Operand(OperandKind Kind, Type Ty) | 81 Operand(OperandKind Kind, Type Ty) |
| 82 : Ty(Ty), Kind(Kind), NumVars(0), Vars(nullptr) {} | 82 : Ty(Ty), Kind(Kind), NumVars(0), Vars(nullptr) {} |
| 83 | 83 |
| 84 const Type Ty; | 84 const Type Ty; |
| 85 const OperandKind Kind; | 85 const OperandKind Kind; |
| 86 // Vars and NumVars are initialized by the derived class. | 86 // Vars and NumVars are initialized by the derived class. |
| 87 SizeT NumVars; | 87 SizeT NumVars; |
| 88 Variable **Vars; | 88 Variable **Vars; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 template<class StreamType> | 91 template <class StreamType> |
| 92 inline StreamType &operator<<(StreamType &Str, const Operand &Op) { | 92 inline StreamType &operator<<(StreamType &Str, const Operand &Op) { |
| 93 Op.dump(Str); | 93 Op.dump(Str); |
| 94 return Str; | 94 return Str; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Constant is the abstract base class for constants. All | 97 // Constant is the abstract base class for constants. All |
| 98 // constants are allocated from a global arena and are pooled. | 98 // constants are allocated from a global arena and are pooled. |
| 99 class Constant : public Operand { | 99 class Constant : public Operand { |
| 100 Constant(const Constant &) = delete; | 100 Constant(const Constant &) = delete; |
| 101 Constant &operator=(const Constant &) = delete; | 101 Constant &operator=(const Constant &) = delete; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 163 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
| 164 ~ConstantPrimitive() override {} | 164 ~ConstantPrimitive() override {} |
| 165 const PrimType Value; | 165 const PrimType Value; |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; | 168 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; |
| 169 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; | 169 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; |
| 170 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 170 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; |
| 171 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 171 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; |
| 172 | 172 |
| 173 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const
{ | 173 template <> |
| 174 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { |
| 174 if (!ALLOW_DUMP) | 175 if (!ALLOW_DUMP) |
| 175 return; | 176 return; |
| 176 if (getType() == IceType_i1) | 177 if (getType() == IceType_i1) |
| 177 Str << (getValue() ? "true" : "false"); | 178 Str << (getValue() ? "true" : "false"); |
| 178 else | 179 else |
| 179 Str << static_cast<int32_t>(getValue()); | 180 Str << static_cast<int32_t>(getValue()); |
| 180 } | 181 } |
| 181 | 182 |
| 182 template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const
{ | 183 template <> |
| 184 inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { |
| 183 if (!ALLOW_DUMP) | 185 if (!ALLOW_DUMP) |
| 184 return; | 186 return; |
| 185 assert(getType() == IceType_i64); | 187 assert(getType() == IceType_i64); |
| 186 Str << static_cast<int64_t>(getValue()); | 188 Str << static_cast<int64_t>(getValue()); |
| 187 } | 189 } |
| 188 | 190 |
| 189 // RelocatableTuple bundles the parameters that are used to | 191 // RelocatableTuple bundles the parameters that are used to |
| 190 // construct an ConstantRelocatable. It is done this way so that | 192 // construct an ConstantRelocatable. It is done this way so that |
| 191 // ConstantRelocatable can fit into the global constant pool | 193 // ConstantRelocatable can fit into the global constant pool |
| 192 // template mechanism. | 194 // template mechanism. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return Kind == kConstRelocatable; | 239 return Kind == kConstRelocatable; |
| 238 } | 240 } |
| 239 | 241 |
| 240 private: | 242 private: |
| 241 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, | 243 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, |
| 242 bool SuppressMangling, uint32_t PoolEntryID) | 244 bool SuppressMangling, uint32_t PoolEntryID) |
| 243 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), | 245 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), |
| 244 Name(Name), SuppressMangling(SuppressMangling) {} | 246 Name(Name), SuppressMangling(SuppressMangling) {} |
| 245 ~ConstantRelocatable() override {} | 247 ~ConstantRelocatable() override {} |
| 246 const RelocOffsetT Offset; // fixed offset to add | 248 const RelocOffsetT Offset; // fixed offset to add |
| 247 const IceString Name; // optional for debug/dump | 249 const IceString Name; // optional for debug/dump |
| 248 bool SuppressMangling; | 250 bool SuppressMangling; |
| 249 }; | 251 }; |
| 250 | 252 |
| 251 // ConstantUndef represents an unspecified bit pattern. Although it is | 253 // ConstantUndef represents an unspecified bit pattern. Although it is |
| 252 // legal to lower ConstantUndef to any value, backends should try to | 254 // legal to lower ConstantUndef to any value, backends should try to |
| 253 // make code generation deterministic by lowering ConstantUndefs to 0. | 255 // make code generation deterministic by lowering ConstantUndefs to 0. |
| 254 class ConstantUndef : public Constant { | 256 class ConstantUndef : public Constant { |
| 255 ConstantUndef(const ConstantUndef &) = delete; | 257 ConstantUndef(const ConstantUndef &) = delete; |
| 256 ConstantUndef &operator=(const ConstantUndef &) = delete; | 258 ConstantUndef &operator=(const ConstantUndef &) = delete; |
| 257 | 259 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 355 |
| 354 RegWeight getWeight() const { return Weight; } | 356 RegWeight getWeight() const { return Weight; } |
| 355 void setWeight(const RegWeight &NewWeight) { Weight = NewWeight; } | 357 void setWeight(const RegWeight &NewWeight) { Weight = NewWeight; } |
| 356 void addWeight(uint32_t Delta) { Weight.addWeight(Delta); } | 358 void addWeight(uint32_t Delta) { Weight.addWeight(Delta); } |
| 357 void dump(Ostream &Str) const; | 359 void dump(Ostream &Str) const; |
| 358 | 360 |
| 359 private: | 361 private: |
| 360 typedef std::pair<InstNumberT, InstNumberT> RangeElementType; | 362 typedef std::pair<InstNumberT, InstNumberT> RangeElementType; |
| 361 // RangeType is arena-allocated from the Cfg's allocator. | 363 // RangeType is arena-allocated from the Cfg's allocator. |
| 362 typedef std::vector<RangeElementType, CfgLocalAllocator<RangeElementType>> | 364 typedef std::vector<RangeElementType, CfgLocalAllocator<RangeElementType>> |
| 363 RangeType; | 365 RangeType; |
| 364 RangeType Range; | 366 RangeType Range; |
| 365 RegWeight Weight; | 367 RegWeight Weight; |
| 366 // TrimmedBegin is an optimization for the overlaps() computation. | 368 // TrimmedBegin is an optimization for the overlaps() computation. |
| 367 // Since the linear-scan algorithm always calls it as overlaps(Cur) | 369 // Since the linear-scan algorithm always calls it as overlaps(Cur) |
| 368 // and Cur advances monotonically according to live range start, we | 370 // and Cur advances monotonically according to live range start, we |
| 369 // can optimize overlaps() by ignoring all segments that end before | 371 // can optimize overlaps() by ignoring all segments that end before |
| 370 // the start of Cur's range. The linear-scan code enables this by | 372 // the start of Cur's range. The linear-scan code enables this by |
| 371 // calling trim() on the ranges of interest as Cur advances. Note | 373 // calling trim() on the ranges of interest as Cur advances. Note |
| 372 // that linear-scan also has to initialize TrimmedBegin at the | 374 // that linear-scan also has to initialize TrimmedBegin at the |
| 373 // beginning by calling untrim(). | 375 // beginning by calling untrim(). |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 VariableTracking &operator=(const VariableTracking &) = delete; | 535 VariableTracking &operator=(const VariableTracking &) = delete; |
| 534 | 536 |
| 535 public: | 537 public: |
| 536 enum MultiDefState { | 538 enum MultiDefState { |
| 537 // TODO(stichnot): Consider using just a simple counter. | 539 // TODO(stichnot): Consider using just a simple counter. |
| 538 MDS_Unknown, | 540 MDS_Unknown, |
| 539 MDS_SingleDef, | 541 MDS_SingleDef, |
| 540 MDS_MultiDefSingleBlock, | 542 MDS_MultiDefSingleBlock, |
| 541 MDS_MultiDefMultiBlock | 543 MDS_MultiDefMultiBlock |
| 542 }; | 544 }; |
| 543 enum MultiBlockState { | 545 enum MultiBlockState { MBS_Unknown, MBS_SingleBlock, MBS_MultiBlock }; |
| 544 MBS_Unknown, | |
| 545 MBS_SingleBlock, | |
| 546 MBS_MultiBlock | |
| 547 }; | |
| 548 VariableTracking() | 546 VariableTracking() |
| 549 : MultiDef(MDS_Unknown), MultiBlock(MBS_Unknown), SingleUseNode(nullptr), | 547 : MultiDef(MDS_Unknown), MultiBlock(MBS_Unknown), SingleUseNode(nullptr), |
| 550 SingleDefNode(nullptr), FirstOrSingleDefinition(nullptr) {} | 548 SingleDefNode(nullptr), FirstOrSingleDefinition(nullptr) {} |
| 551 VariableTracking(const VariableTracking &) = default; | 549 VariableTracking(const VariableTracking &) = default; |
| 552 MultiDefState getMultiDef() const { return MultiDef; } | 550 MultiDefState getMultiDef() const { return MultiDef; } |
| 553 MultiBlockState getMultiBlock() const { return MultiBlock; } | 551 MultiBlockState getMultiBlock() const { return MultiBlock; } |
| 554 const Inst *getFirstDefinition() const; | 552 const Inst *getFirstDefinition() const; |
| 555 const Inst *getSingleDefinition() const; | 553 const Inst *getSingleDefinition() const; |
| 556 const InstDefList &getLatterDefinitions() const { return Definitions; } | 554 const InstDefList &getLatterDefinitions() const { return Definitions; } |
| 557 const CfgNode *getNode() const { return SingleUseNode; } | 555 const CfgNode *getNode() const { return SingleUseNode; } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 private: | 623 private: |
| 626 const Cfg *Func; | 624 const Cfg *Func; |
| 627 MetadataKind Kind; | 625 MetadataKind Kind; |
| 628 std::vector<VariableTracking> Metadata; | 626 std::vector<VariableTracking> Metadata; |
| 629 const static InstDefList NoDefinitions; | 627 const static InstDefList NoDefinitions; |
| 630 }; | 628 }; |
| 631 | 629 |
| 632 } // end of namespace Ice | 630 } // end of namespace Ice |
| 633 | 631 |
| 634 #endif // SUBZERO_SRC_ICEOPERAND_H | 632 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |