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 // This file implements the LinearScan class, which performs the | 10 // This file implements the LinearScan class, which performs the |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 std::vector<RegWeight> Weights(RegMask.size()); | 487 std::vector<RegWeight> Weights(RegMask.size()); |
488 | 488 |
489 // Remove registers from the Free[] list where an Unhandled | 489 // Remove registers from the Free[] list where an Unhandled |
490 // precolored range overlaps with the current range, and set those | 490 // precolored range overlaps with the current range, and set those |
491 // registers to infinite weight so that they aren't candidates for | 491 // registers to infinite weight so that they aren't candidates for |
492 // eviction. Cur->rangeEndsBefore(Item) is an early exit check | 492 // eviction. Cur->rangeEndsBefore(Item) is an early exit check |
493 // that turns a guaranteed O(N^2) algorithm into expected linear | 493 // that turns a guaranteed O(N^2) algorithm into expected linear |
494 // complexity. | 494 // complexity. |
495 llvm::SmallBitVector PrecoloredUnhandledMask(RegMask.size()); | 495 llvm::SmallBitVector PrecoloredUnhandledMask(RegMask.size()); |
496 // Note: PrecoloredUnhandledMask is only used for dumping. | 496 // Note: PrecoloredUnhandledMask is only used for dumping. |
497 for (auto I = UnhandledPrecolored.rbegin(), E = UnhandledPrecolored.rend(); | 497 for (Variable *Item : reverse_range(UnhandledPrecolored)) { |
498 I != E; ++I) { | |
499 Variable *Item = *I; | |
500 assert(Item->hasReg()); | 498 assert(Item->hasReg()); |
501 if (Cur->rangeEndsBefore(Item)) | 499 if (Cur->rangeEndsBefore(Item)) |
502 break; | 500 break; |
503 if (Item->rangeOverlaps(Cur)) { | 501 if (Item->rangeOverlaps(Cur)) { |
504 int32_t ItemReg = Item->getRegNum(); // Note: not getRegNumTmp() | 502 int32_t ItemReg = Item->getRegNum(); // Note: not getRegNumTmp() |
505 Weights[ItemReg].setWeight(RegWeight::Inf); | 503 Weights[ItemReg].setWeight(RegWeight::Inf); |
506 Free[ItemReg] = false; | 504 Free[ItemReg] = false; |
507 PrecoloredUnhandledMask[ItemReg] = true; | 505 PrecoloredUnhandledMask[ItemReg] = true; |
508 // Disable AllowOverlap if the preferred register is one of | 506 // Disable AllowOverlap if the preferred register is one of |
509 // these precolored unhandled overlapping ranges. | 507 // these precolored unhandled overlapping ranges. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 if (!Func->getContext()->isVerbose(IceV_LinearScan)) | 722 if (!Func->getContext()->isVerbose(IceV_LinearScan)) |
725 return; | 723 return; |
726 Func->resetCurrentNode(); | 724 Func->resetCurrentNode(); |
727 Str << "**** Current regalloc state:\n"; | 725 Str << "**** Current regalloc state:\n"; |
728 Str << "++++++ Handled:\n"; | 726 Str << "++++++ Handled:\n"; |
729 for (const Variable *Item : Handled) { | 727 for (const Variable *Item : Handled) { |
730 dumpLiveRange(Item, Func); | 728 dumpLiveRange(Item, Func); |
731 Str << "\n"; | 729 Str << "\n"; |
732 } | 730 } |
733 Str << "++++++ Unhandled:\n"; | 731 Str << "++++++ Unhandled:\n"; |
734 for (auto I = Unhandled.rbegin(), E = Unhandled.rend(); I != E; ++I) { | 732 for (const Variable *Item : reverse_range(Unhandled)) { |
735 dumpLiveRange(*I, Func); | 733 dumpLiveRange(Item, Func); |
736 Str << "\n"; | 734 Str << "\n"; |
737 } | 735 } |
738 Str << "++++++ Active:\n"; | 736 Str << "++++++ Active:\n"; |
739 for (const Variable *Item : Active) { | 737 for (const Variable *Item : Active) { |
740 dumpLiveRange(Item, Func); | 738 dumpLiveRange(Item, Func); |
741 Str << "\n"; | 739 Str << "\n"; |
742 } | 740 } |
743 Str << "++++++ Inactive:\n"; | 741 Str << "++++++ Inactive:\n"; |
744 for (const Variable *Item : Inactive) { | 742 for (const Variable *Item : Inactive) { |
745 dumpLiveRange(Item, Func); | 743 dumpLiveRange(Item, Func); |
746 Str << "\n"; | 744 Str << "\n"; |
747 } | 745 } |
748 } | 746 } |
749 | 747 |
750 } // end of namespace Ice | 748 } // end of namespace Ice |
OLD | NEW |