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 /// \file | 10 /// \file |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 namespace Ice { | 26 namespace Ice { |
27 | 27 |
28 class LinearScan { | 28 class LinearScan { |
29 LinearScan() = delete; | 29 LinearScan() = delete; |
30 LinearScan(const LinearScan &) = delete; | 30 LinearScan(const LinearScan &) = delete; |
31 LinearScan &operator=(const LinearScan &) = delete; | 31 LinearScan &operator=(const LinearScan &) = delete; |
32 | 32 |
33 public: | 33 public: |
34 explicit LinearScan(Cfg *Func); | 34 explicit LinearScan(Cfg *Func); |
35 void init(RegAllocKind Kind); | 35 void init(RegAllocKind Kind, CfgSet<Variable *> ExtraVars = {}, |
| 36 CfgSet<Variable *> ExcludeVars = {}); |
36 void scan(const SmallBitVector &RegMask, bool Randomized); | 37 void scan(const SmallBitVector &RegMask, bool Randomized); |
37 // Returns the number of times some variable has been assigned a register but | 38 // Returns the number of times some variable has been assigned a register but |
38 // later evicted because of a higher-priority allocation. The idea is that we | 39 // later evicted because of a higher-priority allocation. The idea is that we |
39 // can implement "second-chance bin-packing" by rerunning register allocation | 40 // can implement "second-chance bin-packing" by rerunning register allocation |
40 // until there are no more evictions. | 41 // until there are no more evictions. |
41 SizeT getNumEvictions() const { return Evicted.size(); } | 42 SizeT getNumEvictions() const { return Evicted.size(); } |
42 bool hasEvictions() const { return !Evicted.empty(); } | 43 bool hasEvictions() const { return !Evicted.empty(); } |
| 44 void setSplittingMode() { SplittingMode = true; } |
43 void dump(Cfg *Func) const; | 45 void dump(Cfg *Func) const; |
44 | 46 |
45 // TODO(stichnot): Statically choose the size based on the target being | 47 // TODO(stichnot): Statically choose the size based on the target being |
46 // compiled. For now, choose a value large enough to fit into the | 48 // compiled. For now, choose a value large enough to fit into the |
47 // SmallVector's fixed portion, which is 32 for x86-32, 84 for x86-64, and 102 | 49 // SmallVector's fixed portion, which is 32 for x86-32, 84 for x86-64, and 102 |
48 // for ARM32. | 50 // for ARM32. |
49 static constexpr size_t REGS_SIZE = 128; | 51 static constexpr size_t REGS_SIZE = 128; |
50 | 52 |
51 private: | 53 private: |
52 using OrderedRanges = CfgVector<Variable *>; | 54 using OrderedRanges = CfgVector<Variable *>; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 UnorderedRanges Evicted; | 126 UnorderedRanges Evicted; |
125 CfgVector<InstNumberT> Kills; | 127 CfgVector<InstNumberT> Kills; |
126 RegAllocKind Kind = RAK_Unknown; | 128 RegAllocKind Kind = RAK_Unknown; |
127 /// RegUses[I] is the number of live ranges (variables) that register I is | 129 /// RegUses[I] is the number of live ranges (variables) that register I is |
128 /// currently assigned to. It can be greater than 1 as a result of | 130 /// currently assigned to. It can be greater than 1 as a result of |
129 /// AllowOverlap inference. | 131 /// AllowOverlap inference. |
130 llvm::SmallVector<int32_t, REGS_SIZE> RegUses; | 132 llvm::SmallVector<int32_t, REGS_SIZE> RegUses; |
131 llvm::SmallVector<const SmallBitVector *, REGS_SIZE> RegAliases; | 133 llvm::SmallVector<const SmallBitVector *, REGS_SIZE> RegAliases; |
132 bool FindPreference = false; | 134 bool FindPreference = false; |
133 bool FindOverlap = false; | 135 bool FindOverlap = false; |
134 | |
135 const bool Verbose; | 136 const bool Verbose; |
136 const bool UseReserve; | 137 const bool UseReserve; |
| 138 bool SplittingMode = false; |
| 139 CfgVector<Variable *> Vars; |
137 }; | 140 }; |
138 | 141 |
139 } // end of namespace Ice | 142 } // end of namespace Ice |
140 | 143 |
141 #endif // SUBZERO_SRC_ICEREGALLOC_H | 144 #endif // SUBZERO_SRC_ICEREGALLOC_H |
OLD | NEW |