| OLD | NEW |
| 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===// | 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===// |
| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 break; | 242 break; |
| 243 case RAK_Global: | 243 case RAK_Global: |
| 244 case RAK_Phi: | 244 case RAK_Phi: |
| 245 initForGlobal(); | 245 initForGlobal(); |
| 246 break; | 246 break; |
| 247 case RAK_InfOnly: | 247 case RAK_InfOnly: |
| 248 initForInfOnly(); | 248 initForInfOnly(); |
| 249 break; | 249 break; |
| 250 } | 250 } |
| 251 | 251 |
| 252 struct CompareRanges { | 252 auto CompareRanges = [](const Variable *L, const Variable *R) { |
| 253 bool operator()(const Variable *L, const Variable *R) { | |
| 254 InstNumberT Lstart = L->getLiveRange().getStart(); | 253 InstNumberT Lstart = L->getLiveRange().getStart(); |
| 255 InstNumberT Rstart = R->getLiveRange().getStart(); | 254 InstNumberT Rstart = R->getLiveRange().getStart(); |
| 256 if (Lstart == Rstart) | 255 if (Lstart == Rstart) |
| 257 return L->getIndex() < R->getIndex(); | 256 return L->getIndex() < R->getIndex(); |
| 258 return Lstart < Rstart; | 257 return Lstart < Rstart; |
| 259 } | |
| 260 }; | 258 }; |
| 261 // Do a reverse sort so that erasing elements (from the end) is fast. | 259 // Do a reverse sort so that erasing elements (from the end) is fast. |
| 262 std::sort(Unhandled.rbegin(), Unhandled.rend(), CompareRanges()); | 260 std::sort(Unhandled.rbegin(), Unhandled.rend(), CompareRanges); |
| 263 std::sort(UnhandledPrecolored.rbegin(), UnhandledPrecolored.rend(), | 261 std::sort(UnhandledPrecolored.rbegin(), UnhandledPrecolored.rend(), |
| 264 CompareRanges()); | 262 CompareRanges); |
| 265 | 263 |
| 266 Handled.reserve(Unhandled.size()); | 264 Handled.reserve(Unhandled.size()); |
| 267 Inactive.reserve(Unhandled.size()); | 265 Inactive.reserve(Unhandled.size()); |
| 268 Active.reserve(Unhandled.size()); | 266 Active.reserve(Unhandled.size()); |
| 269 } | 267 } |
| 270 | 268 |
| 271 // This is called when Cur must be allocated a register but no registers are | 269 // This is called when Cur must be allocated a register but no registers are |
| 272 // available across Cur's live range. To handle this, we find a register that | 270 // available across Cur's live range. To handle this, we find a register that |
| 273 // is not explicitly used during Cur's live range, spill that register to a | 271 // is not explicitly used during Cur's live range, spill that register to a |
| 274 // stack location right before Cur's live range begins, and fill (reload) the | 272 // stack location right before Cur's live range begins, and fill (reload) the |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 Str << "\n"; | 848 Str << "\n"; |
| 851 } | 849 } |
| 852 Str << "++++++ Inactive:\n"; | 850 Str << "++++++ Inactive:\n"; |
| 853 for (const Variable *Item : Inactive) { | 851 for (const Variable *Item : Inactive) { |
| 854 dumpLiveRange(Item, Func); | 852 dumpLiveRange(Item, Func); |
| 855 Str << "\n"; | 853 Str << "\n"; |
| 856 } | 854 } |
| 857 } | 855 } |
| 858 | 856 |
| 859 } // end of namespace Ice | 857 } // end of namespace Ice |
| OLD | NEW |