| OLD | NEW |
| 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 241 } |
| 242 | 242 |
| 243 void Cfg::deletePhis() { | 243 void Cfg::deletePhis() { |
| 244 TimerMarker T(TimerStack::TT_deletePhis, this); | 244 TimerMarker T(TimerStack::TT_deletePhis, this); |
| 245 for (CfgNode *Node : Nodes) | 245 for (CfgNode *Node : Nodes) |
| 246 Node->deletePhis(); | 246 Node->deletePhis(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void Cfg::advancedPhiLowering() { | 249 void Cfg::advancedPhiLowering() { |
| 250 TimerMarker T(TimerStack::TT_advancedPhiLowering, this); | 250 TimerMarker T(TimerStack::TT_advancedPhiLowering, this); |
| 251 // Clear all previously computed live ranges (but not live-in/live-out bit |
| 252 // vectors or last-use markers), because the follow-on register allocation is |
| 253 // only concerned with live ranges across the newly created blocks. |
| 254 for (Variable *Var : Variables) { |
| 255 Var->getLiveRange().reset(); |
| 256 } |
| 251 // This splits edges and appends new nodes to the end of the node | 257 // This splits edges and appends new nodes to the end of the node |
| 252 // list. This can invalidate iterators, so don't use an iterator. | 258 // list. This can invalidate iterators, so don't use an iterator. |
| 253 SizeT NumNodes = getNumNodes(); | 259 SizeT NumNodes = getNumNodes(); |
| 260 SizeT NumVars = getNumVariables(); |
| 254 for (SizeT I = 0; I < NumNodes; ++I) | 261 for (SizeT I = 0; I < NumNodes; ++I) |
| 255 Nodes[I]->advancedPhiLowering(); | 262 Nodes[I]->advancedPhiLowering(); |
| 263 |
| 264 TimerMarker TT(TimerStack::TT_lowerPhiAssignments, this); |
| 265 if (true) { |
| 266 // The following code does an in-place update of liveness and live ranges as |
| 267 // a result of adding the new phi edge split nodes. |
| 268 getLiveness()->initPhiEdgeSplits(Nodes.begin() + NumNodes, |
| 269 Variables.begin() + NumVars); |
| 270 TimerMarker TTT(TimerStack::TT_liveness, this); |
| 271 // Iterate over the newly added nodes to add their liveness info. |
| 272 for (auto I = Nodes.begin() + NumNodes, E = Nodes.end(); I != E; ++I) { |
| 273 InstNumberT FirstInstNum = getNextInstNumber(); |
| 274 (*I)->renumberInstructions(); |
| 275 InstNumberT LastInstNum = getNextInstNumber() - 1; |
| 276 // TODO(stichnot): May be able to speed up liveness and live range |
| 277 // calculation by having it consider only pre-colored or infinite-weight |
| 278 // variables. Could also simplify LinearScan::initForInfOnly() that way. |
| 279 (*I)->liveness(getLiveness()); |
| 280 (*I)->livenessAddIntervals(getLiveness(), FirstInstNum, LastInstNum); |
| 281 } |
| 282 } else { |
| 283 // The following code does a brute-force recalculation of live ranges as a |
| 284 // result of adding the new phi edge split nodes. The liveness calculation |
| 285 // is particularly expensive because the new nodes are not yet in a proper |
| 286 // topological order and so convergence is slower. |
| 287 // |
| 288 // This code is kept here for reference and can be temporarily enabled in |
| 289 // case the incremental code is under suspicion. |
| 290 renumberInstructions(); |
| 291 liveness(Liveness_Intervals); |
| 292 getVMetadata()->init(VMK_All); |
| 293 } |
| 294 Target->regAlloc(RAK_Phi); |
| 256 } | 295 } |
| 257 | 296 |
| 258 // Find a reasonable placement for nodes that have not yet been | 297 // Find a reasonable placement for nodes that have not yet been |
| 259 // placed, while maintaining the same relative ordering among already | 298 // placed, while maintaining the same relative ordering among already |
| 260 // placed nodes. | 299 // placed nodes. |
| 261 void Cfg::reorderNodes() { | 300 void Cfg::reorderNodes() { |
| 262 // TODO(ascull): it would be nice if the switch tests were always followed | 301 // TODO(ascull): it would be nice if the switch tests were always followed |
| 263 // by the default case to allow for fall through. | 302 // by the default case to allow for fall through. |
| 264 typedef std::list<CfgNode *> PlacedList; | 303 typedef std::list<CfgNode *> PlacedList; |
| 265 PlacedList Placed; // Nodes with relative placement locked down | 304 PlacedList Placed; // Nodes with relative placement locked down |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 } | 660 } |
| 622 } | 661 } |
| 623 // Print each basic block | 662 // Print each basic block |
| 624 for (CfgNode *Node : Nodes) | 663 for (CfgNode *Node : Nodes) |
| 625 Node->dump(this); | 664 Node->dump(this); |
| 626 if (isVerbose(IceV_Instructions)) | 665 if (isVerbose(IceV_Instructions)) |
| 627 Str << "}\n"; | 666 Str << "}\n"; |
| 628 } | 667 } |
| 629 | 668 |
| 630 } // end of namespace Ice | 669 } // end of namespace Ice |
| OLD | NEW |