Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1605)

Side by Side Diff: src/IceCfg.cpp

Issue 1253833002: Subzero: Cleanly implement register allocation after phi lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceCfgNode.cpp » ('j') | src/IceClFlags.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // This splits edges and appends new nodes to the end of the node 251 // 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. 252 // list. This can invalidate iterators, so don't use an iterator.
253 SizeT NumNodes = getNumNodes(); 253 SizeT NumNodes = getNumNodes();
254 SizeT NumVars = getNumVariables();
254 for (SizeT I = 0; I < NumNodes; ++I) 255 for (SizeT I = 0; I < NumNodes; ++I)
255 Nodes[I]->advancedPhiLowering(); 256 Nodes[I]->advancedPhiLowering();
257
258 if (true) {
259 // The following code does an in-place update of liveness and live ranges as
260 // a result of adding the new phi edge split nodes.
261 getLiveness()->initPhiEdgeSplits(Nodes.begin() + NumNodes,
262 Variables.begin() + NumVars);
263 // Iterate over the newly added nodes to add their liveness info.
264 for (auto I = Nodes.begin() + NumNodes, E = Nodes.end(); I != E; ++I) {
265 InstNumberT FirstInstNum = getNextInstNumber();
266 (*I)->renumberInstructions();
267 InstNumberT LastInstNum = getNextInstNumber() - 1;
268 // TODO(stichnot): May be able to speed up liveness and live range
269 // calculation by having it consider only pre-colored or infinite-weight
270 // variables. Could also simplify LinearScan::initForInfOnly() that way.
271 (*I)->liveness(getLiveness());
272 (*I)->livenessAddIntervals(getLiveness(), FirstInstNum, LastInstNum);
273 }
274 } else {
275 // The following code does a brute-force recalculation of live ranges as a
276 // result of adding the new phi edge split nodes. The liveness calculation
277 // is particularly expensive because the new nodes are not yet in a proper
278 // topological order and so convergence is slower.
279 //
280 // This code is kept here for reference and can be temporarily enabled in
281 // case the incremental code is under suspicion.
282 renumberInstructions();
283 liveness(Liveness_Intervals);
284 getVMetadata()->init(VMK_All);
285 }
286 Target->regAlloc(RAK_Phi);
256 } 287 }
257 288
258 // Find a reasonable placement for nodes that have not yet been 289 // Find a reasonable placement for nodes that have not yet been
259 // placed, while maintaining the same relative ordering among already 290 // placed, while maintaining the same relative ordering among already
260 // placed nodes. 291 // placed nodes.
261 void Cfg::reorderNodes() { 292 void Cfg::reorderNodes() {
262 // TODO(ascull): it would be nice if the switch tests were always followed 293 // TODO(ascull): it would be nice if the switch tests were always followed
263 // by the default case to allow for fall through. 294 // by the default case to allow for fall through.
264 typedef std::list<CfgNode *> PlacedList; 295 typedef std::list<CfgNode *> PlacedList;
265 PlacedList Placed; // Nodes with relative placement locked down 296 PlacedList Placed; // Nodes with relative placement locked down
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 652 }
622 } 653 }
623 // Print each basic block 654 // Print each basic block
624 for (CfgNode *Node : Nodes) 655 for (CfgNode *Node : Nodes)
625 Node->dump(this); 656 Node->dump(this);
626 if (isVerbose(IceV_Instructions)) 657 if (isVerbose(IceV_Instructions))
627 Str << "}\n"; 658 Str << "}\n";
628 } 659 }
629 660
630 } // end of namespace Ice 661 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceCfgNode.cpp » ('j') | src/IceClFlags.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698