| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return; | 78 return; |
| 79 assert(Func); | 79 assert(Func); |
| 80 dump(Func, Func->getContext()->getStrDump()); | 80 dump(Func, Func->getContext()->getStrDump()); |
| 81 } | 81 } |
| 82 void dump(Ostream &Str) const { | 82 void dump(Ostream &Str) const { |
| 83 if (BuildDefs::dump()) | 83 if (BuildDefs::dump()) |
| 84 dump(nullptr, Str); | 84 dump(nullptr, Str); |
| 85 } | 85 } |
| 86 /// @} | 86 /// @} |
| 87 | 87 |
| 88 ~Operand() = default; |
| 89 |
| 88 protected: | 90 protected: |
| 89 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { | 91 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { |
| 90 // It is undefined behavior to have a larger value in the enum | 92 // It is undefined behavior to have a larger value in the enum |
| 91 assert(Kind <= kTarget_Max); | 93 assert(Kind <= kTarget_Max); |
| 92 } | 94 } |
| 93 virtual ~Operand() = default; | |
| 94 | 95 |
| 95 const Type Ty; | 96 const Type Ty; |
| 96 const OperandKind Kind; | 97 const OperandKind Kind; |
| 97 /// Vars and NumVars are initialized by the derived class. | 98 /// Vars and NumVars are initialized by the derived class. |
| 98 SizeT NumVars = 0; | 99 SizeT NumVars = 0; |
| 99 Variable **Vars = nullptr; | 100 Variable **Vars = nullptr; |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 template <class StreamType> | 103 template <class StreamType> |
| 103 inline StreamType &operator<<(StreamType &Str, const Operand &Op) { | 104 inline StreamType &operator<<(StreamType &Str, const Operand &Op) { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 348 |
| 348 /// LiveRange is a set of instruction number intervals representing a variable's | 349 /// LiveRange is a set of instruction number intervals representing a variable's |
| 349 /// live range. Generally there is one interval per basic block where the | 350 /// live range. Generally there is one interval per basic block where the |
| 350 /// variable is live, but adjacent intervals get coalesced into a single | 351 /// variable is live, but adjacent intervals get coalesced into a single |
| 351 /// interval. | 352 /// interval. |
| 352 class LiveRange { | 353 class LiveRange { |
| 353 public: | 354 public: |
| 354 LiveRange() = default; | 355 LiveRange() = default; |
| 355 /// Special constructor for building a kill set. The advantage is that we can | 356 /// Special constructor for building a kill set. The advantage is that we can |
| 356 /// reserve the right amount of space in advance. | 357 /// reserve the right amount of space in advance. |
| 357 explicit LiveRange(const std::vector<InstNumberT> &Kills) { | 358 explicit LiveRange(const CfgVector<InstNumberT> &Kills) { |
| 358 Range.reserve(Kills.size()); | 359 Range.reserve(Kills.size()); |
| 359 for (InstNumberT I : Kills) | 360 for (InstNumberT I : Kills) |
| 360 addSegment(I, I); | 361 addSegment(I, I); |
| 361 } | 362 } |
| 362 LiveRange(const LiveRange &) = default; | 363 LiveRange(const LiveRange &) = default; |
| 363 LiveRange &operator=(const LiveRange &) = default; | 364 LiveRange &operator=(const LiveRange &) = default; |
| 364 | 365 |
| 365 void reset() { | 366 void reset() { |
| 366 Range.clear(); | 367 Range.clear(); |
| 367 untrim(); | 368 untrim(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 381 } | 382 } |
| 382 | 383 |
| 383 void untrim() { TrimmedBegin = Range.begin(); } | 384 void untrim() { TrimmedBegin = Range.begin(); } |
| 384 void trim(InstNumberT Lower); | 385 void trim(InstNumberT Lower); |
| 385 | 386 |
| 386 void dump(Ostream &Str) const; | 387 void dump(Ostream &Str) const; |
| 387 | 388 |
| 388 private: | 389 private: |
| 389 using RangeElementType = std::pair<InstNumberT, InstNumberT>; | 390 using RangeElementType = std::pair<InstNumberT, InstNumberT>; |
| 390 /// RangeType is arena-allocated from the Cfg's allocator. | 391 /// RangeType is arena-allocated from the Cfg's allocator. |
| 391 using RangeType = | 392 using RangeType = CfgVector<RangeElementType>; |
| 392 std::vector<RangeElementType, CfgLocalAllocator<RangeElementType>>; | |
| 393 RangeType Range; | 393 RangeType Range; |
| 394 /// TrimmedBegin is an optimization for the overlaps() computation. Since the | 394 /// TrimmedBegin is an optimization for the overlaps() computation. Since the |
| 395 /// linear-scan algorithm always calls it as overlaps(Cur) and Cur advances | 395 /// linear-scan algorithm always calls it as overlaps(Cur) and Cur advances |
| 396 /// monotonically according to live range start, we can optimize overlaps() by | 396 /// monotonically according to live range start, we can optimize overlaps() by |
| 397 /// ignoring all segments that end before the start of Cur's range. The | 397 /// ignoring all segments that end before the start of Cur's range. The |
| 398 /// linear-scan code enables this by calling trim() on the ranges of interest | 398 /// linear-scan code enables this by calling trim() on the ranges of interest |
| 399 /// as Cur advances. Note that linear-scan also has to initialize TrimmedBegin | 399 /// as Cur advances. Note that linear-scan also has to initialize TrimmedBegin |
| 400 /// at the beginning by calling untrim(). | 400 /// at the beginning by calling untrim(). |
| 401 RangeType::const_iterator TrimmedBegin; | 401 RangeType::const_iterator TrimmedBegin; |
| 402 }; | 402 }; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 Variable *HiVar = nullptr; | 549 Variable *HiVar = nullptr; |
| 550 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. | 550 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. |
| 551 Variable *VarsReal[1]; | 551 Variable *VarsReal[1]; |
| 552 }; | 552 }; |
| 553 | 553 |
| 554 enum MetadataKind { | 554 enum MetadataKind { |
| 555 VMK_Uses, /// Track only uses, not defs | 555 VMK_Uses, /// Track only uses, not defs |
| 556 VMK_SingleDefs, /// Track uses+defs, but only record single def | 556 VMK_SingleDefs, /// Track uses+defs, but only record single def |
| 557 VMK_All /// Track uses+defs, including full def list | 557 VMK_All /// Track uses+defs, including full def list |
| 558 }; | 558 }; |
| 559 using InstDefList = std::vector<const Inst *, CfgLocalAllocator<const Inst *>>; | 559 using InstDefList = CfgVector<const Inst *>; |
| 560 | 560 |
| 561 /// VariableTracking tracks the metadata for a single variable. It is | 561 /// VariableTracking tracks the metadata for a single variable. It is |
| 562 /// only meant to be used internally by VariablesMetadata. | 562 /// only meant to be used internally by VariablesMetadata. |
| 563 class VariableTracking { | 563 class VariableTracking { |
| 564 VariableTracking &operator=(const VariableTracking &) = delete; | 564 VariableTracking &operator=(const VariableTracking &) = delete; |
| 565 | 565 |
| 566 public: | 566 public: |
| 567 enum MultiDefState { | 567 enum MultiDefState { |
| 568 // TODO(stichnot): Consider using just a simple counter. | 568 // TODO(stichnot): Consider using just a simple counter. |
| 569 MDS_Unknown, | 569 MDS_Unknown, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 /// isMultiBlock() returns false. Otherwise, nullptr is returned. | 645 /// isMultiBlock() returns false. Otherwise, nullptr is returned. |
| 646 CfgNode *getLocalUseNode(const Variable *Var) const; | 646 CfgNode *getLocalUseNode(const Variable *Var) const; |
| 647 | 647 |
| 648 /// Returns the total use weight computed as the sum of uses multiplied by a | 648 /// Returns the total use weight computed as the sum of uses multiplied by a |
| 649 /// loop nest depth factor for each use. | 649 /// loop nest depth factor for each use. |
| 650 RegWeight getUseWeight(const Variable *Var) const; | 650 RegWeight getUseWeight(const Variable *Var) const; |
| 651 | 651 |
| 652 private: | 652 private: |
| 653 const Cfg *Func; | 653 const Cfg *Func; |
| 654 MetadataKind Kind; | 654 MetadataKind Kind; |
| 655 std::vector<VariableTracking> Metadata; | 655 CfgVector<VariableTracking> Metadata; |
| 656 const static InstDefList NoDefinitions; | 656 const static InstDefList NoDefinitions; |
| 657 }; | 657 }; |
| 658 | 658 |
| 659 } // end of namespace Ice | 659 } // end of namespace Ice |
| 660 | 660 |
| 661 #endif // SUBZERO_SRC_ICEOPERAND_H | 661 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |