| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 if (Item->getLiveRange().overlapsInst(Defs[i]->getNumber(), UseTrimmed)) | 45 if (Item->getLiveRange().overlapsInst(Defs[i]->getNumber(), UseTrimmed)) |
| 46 return true; | 46 return true; |
| 47 } | 47 } |
| 48 return false; | 48 return false; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void dumpDisableOverlap(const Cfg *Func, const Variable *Var, | 51 void dumpDisableOverlap(const Cfg *Func, const Variable *Var, |
| 52 const char *Reason) { | 52 const char *Reason) { |
| 53 if (!ALLOW_DUMP) | 53 if (!ALLOW_DUMP) |
| 54 return; | 54 return; |
| 55 if (Func->getContext()->isVerbose(IceV_LinearScan)) { | 55 if (Func->isVerbose(IceV_LinearScan)) { |
| 56 VariablesMetadata *VMetadata = Func->getVMetadata(); | 56 VariablesMetadata *VMetadata = Func->getVMetadata(); |
| 57 Ostream &Str = Func->getContext()->getStrDump(); | 57 Ostream &Str = Func->getContext()->getStrDump(); |
| 58 Str << "Disabling Overlap due to " << Reason << " " << *Var | 58 Str << "Disabling Overlap due to " << Reason << " " << *Var |
| 59 << " LIVE=" << Var->getLiveRange() << " Defs="; | 59 << " LIVE=" << Var->getLiveRange() << " Defs="; |
| 60 if (const Inst *FirstDef = VMetadata->getFirstDefinition(Var)) | 60 if (const Inst *FirstDef = VMetadata->getFirstDefinition(Var)) |
| 61 Str << FirstDef->getNumber(); | 61 Str << FirstDef->getNumber(); |
| 62 const InstDefList &Defs = VMetadata->getLatterDefinitions(Var); | 62 const InstDefList &Defs = VMetadata->getLatterDefinitions(Var); |
| 63 for (size_t i = 0; i < Defs.size(); ++i) { | 63 for (size_t i = 0; i < Defs.size(); ++i) { |
| 64 Str << "," << Defs[i]->getNumber(); | 64 Str << "," << Defs[i]->getNumber(); |
| 65 } | 65 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // cases. | 258 // cases. |
| 259 // | 259 // |
| 260 // Requires running Cfg::liveness(Liveness_Intervals) in | 260 // Requires running Cfg::liveness(Liveness_Intervals) in |
| 261 // preparation. Results are assigned to Variable::RegNum for each | 261 // preparation. Results are assigned to Variable::RegNum for each |
| 262 // Variable. | 262 // Variable. |
| 263 void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull, | 263 void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull, |
| 264 bool Randomized) { | 264 bool Randomized) { |
| 265 TimerMarker T(TimerStack::TT_linearScan, Func); | 265 TimerMarker T(TimerStack::TT_linearScan, Func); |
| 266 assert(RegMaskFull.any()); // Sanity check | 266 assert(RegMaskFull.any()); // Sanity check |
| 267 GlobalContext *Ctx = Func->getContext(); | 267 GlobalContext *Ctx = Func->getContext(); |
| 268 const bool Verbose = | 268 const bool Verbose = ALLOW_DUMP && Func->isVerbose(IceV_LinearScan); |
| 269 ALLOW_DUMP && Ctx->isVerbose(IceV_LinearScan); | |
| 270 if (Verbose) | 269 if (Verbose) |
| 271 Ctx->lockStr(); | 270 Ctx->lockStr(); |
| 272 Func->resetCurrentNode(); | 271 Func->resetCurrentNode(); |
| 273 VariablesMetadata *VMetadata = Func->getVMetadata(); | 272 VariablesMetadata *VMetadata = Func->getVMetadata(); |
| 274 const size_t NumRegisters = RegMaskFull.size(); | 273 const size_t NumRegisters = RegMaskFull.size(); |
| 275 llvm::SmallBitVector PreDefinedRegisters(NumRegisters); | 274 llvm::SmallBitVector PreDefinedRegisters(NumRegisters); |
| 276 if (Randomized) { | 275 if (Randomized) { |
| 277 for (Variable *Var : UnhandledPrecolored) { | 276 for (Variable *Var : UnhandledPrecolored) { |
| 278 PreDefinedRegisters[Var->getRegNum()] = true; | 277 PreDefinedRegisters[Var->getRegNum()] = true; |
| 279 } | 278 } |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 730 |
| 732 if (Verbose) | 731 if (Verbose) |
| 733 Ctx->unlockStr(); | 732 Ctx->unlockStr(); |
| 734 } | 733 } |
| 735 | 734 |
| 736 // ======================== Dump routines ======================== // | 735 // ======================== Dump routines ======================== // |
| 737 | 736 |
| 738 void LinearScan::dump(Cfg *Func) const { | 737 void LinearScan::dump(Cfg *Func) const { |
| 739 if (!ALLOW_DUMP) | 738 if (!ALLOW_DUMP) |
| 740 return; | 739 return; |
| 741 if (!Func->getContext()->isVerbose(IceV_LinearScan)) | 740 if (!Func->isVerbose(IceV_LinearScan)) |
| 742 return; | 741 return; |
| 743 Ostream &Str = Func->getContext()->getStrDump(); | 742 Ostream &Str = Func->getContext()->getStrDump(); |
| 744 Func->resetCurrentNode(); | 743 Func->resetCurrentNode(); |
| 745 Str << "**** Current regalloc state:\n"; | 744 Str << "**** Current regalloc state:\n"; |
| 746 Str << "++++++ Handled:\n"; | 745 Str << "++++++ Handled:\n"; |
| 747 for (const Variable *Item : Handled) { | 746 for (const Variable *Item : Handled) { |
| 748 dumpLiveRange(Item, Func); | 747 dumpLiveRange(Item, Func); |
| 749 Str << "\n"; | 748 Str << "\n"; |
| 750 } | 749 } |
| 751 Str << "++++++ Unhandled:\n"; | 750 Str << "++++++ Unhandled:\n"; |
| 752 for (const Variable *Item : reverse_range(Unhandled)) { | 751 for (const Variable *Item : reverse_range(Unhandled)) { |
| 753 dumpLiveRange(Item, Func); | 752 dumpLiveRange(Item, Func); |
| 754 Str << "\n"; | 753 Str << "\n"; |
| 755 } | 754 } |
| 756 Str << "++++++ Active:\n"; | 755 Str << "++++++ Active:\n"; |
| 757 for (const Variable *Item : Active) { | 756 for (const Variable *Item : Active) { |
| 758 dumpLiveRange(Item, Func); | 757 dumpLiveRange(Item, Func); |
| 759 Str << "\n"; | 758 Str << "\n"; |
| 760 } | 759 } |
| 761 Str << "++++++ Inactive:\n"; | 760 Str << "++++++ Inactive:\n"; |
| 762 for (const Variable *Item : Inactive) { | 761 for (const Variable *Item : Inactive) { |
| 763 dumpLiveRange(Item, Func); | 762 dumpLiveRange(Item, Func); |
| 764 Str << "\n"; | 763 Str << "\n"; |
| 765 } | 764 } |
| 766 } | 765 } |
| 767 | 766 |
| 768 } // end of namespace Ice | 767 } // end of namespace Ice |
| OLD | NEW |