| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // Constraints" by Hanspeter Mössenböck and Michael Pfeiffer, | 57 // Constraints" by Hanspeter Mössenböck and Michael Pfeiffer, |
| 58 // ftp://ftp.ssw.uni-linz.ac.at/pub/Papers/Moe02.PDF . This | 58 // ftp://ftp.ssw.uni-linz.ac.at/pub/Papers/Moe02.PDF . This |
| 59 // implementation is modified to take affinity into account and allow | 59 // implementation is modified to take affinity into account and allow |
| 60 // two interfering variables to share the same register in certain | 60 // two interfering variables to share the same register in certain |
| 61 // cases. | 61 // cases. |
| 62 // | 62 // |
| 63 // Requires running Cfg::liveness(Liveness_Intervals) in | 63 // Requires running Cfg::liveness(Liveness_Intervals) in |
| 64 // preparation. Results are assigned to Variable::RegNum for each | 64 // preparation. Results are assigned to Variable::RegNum for each |
| 65 // Variable. | 65 // Variable. |
| 66 void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) { | 66 void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) { |
| 67 static TimerIdT IDscan = GlobalContext::getTimerID("linearScan"); | 67 TimerMarker T(TimerStack::TT_linearScan, Func); |
| 68 TimerMarker T(IDscan, Func->getContext()); | |
| 69 assert(RegMaskFull.any()); // Sanity check | 68 assert(RegMaskFull.any()); // Sanity check |
| 70 Unhandled.clear(); | 69 Unhandled.clear(); |
| 71 UnhandledPrecolored.clear(); | 70 UnhandledPrecolored.clear(); |
| 72 Handled.clear(); | 71 Handled.clear(); |
| 73 Inactive.clear(); | 72 Inactive.clear(); |
| 74 Active.clear(); | 73 Active.clear(); |
| 75 Ostream &Str = Func->getContext()->getStrDump(); | 74 Ostream &Str = Func->getContext()->getStrDump(); |
| 76 bool Verbose = Func->getContext()->isVerbose(IceV_LinearScan); | 75 bool Verbose = Func->getContext()->isVerbose(IceV_LinearScan); |
| 77 Func->resetCurrentNode(); | 76 Func->resetCurrentNode(); |
| 78 VariablesMetadata *VMetadata = Func->getVMetadata(); | 77 VariablesMetadata *VMetadata = Func->getVMetadata(); |
| 79 | 78 |
| 80 // Gather the live ranges of all variables and add them to the | 79 // Gather the live ranges of all variables and add them to the |
| 81 // Unhandled set. TODO: Unhandled is a set<> which is based on a | 80 // Unhandled set. TODO: Unhandled is a set<> which is based on a |
| 82 // balanced binary tree, so inserting live ranges for N variables is | 81 // balanced binary tree, so inserting live ranges for N variables is |
| 83 // O(N log N) complexity. N may be proportional to the number of | 82 // O(N log N) complexity. N may be proportional to the number of |
| 84 // instructions, thanks to temporary generation during lowering. As | 83 // instructions, thanks to temporary generation during lowering. As |
| 85 // a result, it may be useful to design a better data structure for | 84 // a result, it may be useful to design a better data structure for |
| 86 // storing Func->getVariables(). | 85 // storing Func->getVariables(). |
| 87 const VarList &Vars = Func->getVariables(); | 86 const VarList &Vars = Func->getVariables(); |
| 88 { | 87 { |
| 89 static TimerIdT IDinitUnhandled = | 88 TimerMarker T(TimerStack::TT_initUnhandled, Func); |
| 90 GlobalContext::getTimerID("initUnhandled"); | |
| 91 TimerMarker T(IDinitUnhandled, Func->getContext()); | |
| 92 for (Variable *Var : Vars) { | 89 for (Variable *Var : Vars) { |
| 93 // Explicitly don't consider zero-weight variables, which are | 90 // Explicitly don't consider zero-weight variables, which are |
| 94 // meant to be spill slots. | 91 // meant to be spill slots. |
| 95 if (Var->getWeight() == RegWeight::Zero) | 92 if (Var->getWeight() == RegWeight::Zero) |
| 96 continue; | 93 continue; |
| 97 // Don't bother if the variable has a null live range, which means | 94 // Don't bother if the variable has a null live range, which means |
| 98 // it was never referenced. | 95 // it was never referenced. |
| 99 if (Var->getLiveRange().isEmpty()) | 96 if (Var->getLiveRange().isEmpty()) |
| 100 continue; | 97 continue; |
| 101 LiveRangeWrapper R(Var); | 98 LiveRangeWrapper R(Var); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 Str << "\n"; | 547 Str << "\n"; |
| 551 } | 548 } |
| 552 Str << "++++++ Inactive:\n"; | 549 Str << "++++++ Inactive:\n"; |
| 553 for (const LiveRangeWrapper &Item : Inactive) { | 550 for (const LiveRangeWrapper &Item : Inactive) { |
| 554 Item.dump(Func); | 551 Item.dump(Func); |
| 555 Str << "\n"; | 552 Str << "\n"; |
| 556 } | 553 } |
| 557 } | 554 } |
| 558 | 555 |
| 559 } // end of namespace Ice | 556 } // end of namespace Ice |
| OLD | NEW |