| OLD | NEW |
| 1 //===- subzero/src/IceRegAlloc.h - Linear-scan reg. allocation --*- C++ -*-===// | 1 //===- subzero/src/IceRegAlloc.h - Linear-scan reg. allocation --*- 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 LinearScan data structure used during | 10 /// \file |
| 11 // linear-scan register allocation, which holds the various work | 11 /// This file declares the LinearScan data structure used during |
| 12 // queues for the linear-scan algorithm. | 12 /// linear-scan register allocation, which holds the various work |
| 13 // | 13 /// queues for the linear-scan algorithm. |
| 14 /// |
| 14 //===----------------------------------------------------------------------===// | 15 //===----------------------------------------------------------------------===// |
| 15 | 16 |
| 16 #ifndef SUBZERO_SRC_ICEREGALLOC_H | 17 #ifndef SUBZERO_SRC_ICEREGALLOC_H |
| 17 #define SUBZERO_SRC_ICEREGALLOC_H | 18 #define SUBZERO_SRC_ICEREGALLOC_H |
| 18 | 19 |
| 19 #include "IceDefs.h" | 20 #include "IceDefs.h" |
| 20 #include "IceTypes.h" | 21 #include "IceTypes.h" |
| 21 | 22 |
| 22 namespace Ice { | 23 namespace Ice { |
| 23 | 24 |
| 24 class LinearScan { | 25 class LinearScan { |
| 25 LinearScan() = delete; | 26 LinearScan() = delete; |
| 26 LinearScan(const LinearScan &) = delete; | 27 LinearScan(const LinearScan &) = delete; |
| 27 LinearScan &operator=(const LinearScan &) = delete; | 28 LinearScan &operator=(const LinearScan &) = delete; |
| 28 | 29 |
| 29 public: | 30 public: |
| 30 explicit LinearScan(Cfg *Func) : Func(Func) {} | 31 explicit LinearScan(Cfg *Func) : Func(Func) {} |
| 31 void init(RegAllocKind Kind); | 32 void init(RegAllocKind Kind); |
| 32 void scan(const llvm::SmallBitVector &RegMask, bool Randomized); | 33 void scan(const llvm::SmallBitVector &RegMask, bool Randomized); |
| 33 void dump(Cfg *Func) const; | 34 void dump(Cfg *Func) const; |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 typedef std::vector<Variable *> OrderedRanges; | 37 typedef std::vector<Variable *> OrderedRanges; |
| 37 typedef std::vector<Variable *> UnorderedRanges; | 38 typedef std::vector<Variable *> UnorderedRanges; |
| 38 | 39 |
| 39 void initForGlobal(); | 40 void initForGlobal(); |
| 40 void initForInfOnly(); | 41 void initForInfOnly(); |
| 41 // Move an item from the From set to the To set. From[Index] is | 42 /// Move an item from the From set to the To set. From[Index] is |
| 42 // pushed onto the end of To[], then the item is efficiently removed | 43 /// pushed onto the end of To[], then the item is efficiently removed |
| 43 // from From[] by effectively swapping it with the last item in | 44 /// from From[] by effectively swapping it with the last item in |
| 44 // From[] and then popping it from the back. As such, the caller is | 45 /// From[] and then popping it from the back. As such, the caller is |
| 45 // best off iterating over From[] in reverse order to avoid the need | 46 /// best off iterating over From[] in reverse order to avoid the need |
| 46 // for special handling of the iterator. | 47 /// for special handling of the iterator. |
| 47 void moveItem(UnorderedRanges &From, SizeT Index, UnorderedRanges &To) { | 48 void moveItem(UnorderedRanges &From, SizeT Index, UnorderedRanges &To) { |
| 48 To.push_back(From[Index]); | 49 To.push_back(From[Index]); |
| 49 From[Index] = From.back(); | 50 From[Index] = From.back(); |
| 50 From.pop_back(); | 51 From.pop_back(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 Cfg *const Func; | 54 Cfg *const Func; |
| 54 OrderedRanges Unhandled; | 55 OrderedRanges Unhandled; |
| 55 // UnhandledPrecolored is a subset of Unhandled, specially collected | 56 /// UnhandledPrecolored is a subset of Unhandled, specially collected |
| 56 // for faster processing. | 57 /// for faster processing. |
| 57 OrderedRanges UnhandledPrecolored; | 58 OrderedRanges UnhandledPrecolored; |
| 58 UnorderedRanges Active, Inactive, Handled; | 59 UnorderedRanges Active, Inactive, Handled; |
| 59 std::vector<InstNumberT> Kills; | 60 std::vector<InstNumberT> Kills; |
| 60 bool FindPreference = false; | 61 bool FindPreference = false; |
| 61 bool FindOverlap = false; | 62 bool FindOverlap = false; |
| 62 // TODO(stichnot): We're not really using FindOverlap yet, but we | 63 // TODO(stichnot): We're not really using FindOverlap yet, but we |
| 63 // may want a flavor of register allocation where FindPreference is | 64 // may want a flavor of register allocation where FindPreference is |
| 64 // useful but we didn't want to initialize VMetadata with VMK_All | 65 // useful but we didn't want to initialize VMetadata with VMK_All |
| 65 // and therefore we can't safely allow overlap. | 66 // and therefore we can't safely allow overlap. |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 } // end of namespace Ice | 69 } // end of namespace Ice |
| 69 | 70 |
| 70 #endif // SUBZERO_SRC_ICEREGALLOC_H | 71 #endif // SUBZERO_SRC_ICEREGALLOC_H |
| OLD | NEW |