| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 getVMetadata()->init(VMK_All); | 307 getVMetadata()->init(VMK_All); |
| 308 } | 308 } |
| 309 Target->regAlloc(RAK_Phi); | 309 Target->regAlloc(RAK_Phi); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // Find a reasonable placement for nodes that have not yet been placed, while | 312 // Find a reasonable placement for nodes that have not yet been placed, while |
| 313 // maintaining the same relative ordering among already placed nodes. | 313 // maintaining the same relative ordering among already placed nodes. |
| 314 void Cfg::reorderNodes() { | 314 void Cfg::reorderNodes() { |
| 315 // TODO(ascull): it would be nice if the switch tests were always followed by | 315 // TODO(ascull): it would be nice if the switch tests were always followed by |
| 316 // the default case to allow for fall through. | 316 // the default case to allow for fall through. |
| 317 using PlacedList = std::list<CfgNode *>; | 317 using PlacedList = CfgList<CfgNode *>; |
| 318 PlacedList Placed; // Nodes with relative placement locked down | 318 PlacedList Placed; // Nodes with relative placement locked down |
| 319 PlacedList Unreachable; // Unreachable nodes | 319 PlacedList Unreachable; // Unreachable nodes |
| 320 PlacedList::iterator NoPlace = Placed.end(); | 320 PlacedList::iterator NoPlace = Placed.end(); |
| 321 // Keep track of where each node has been tentatively placed so that we can | 321 // Keep track of where each node has been tentatively placed so that we can |
| 322 // manage insertions into the middle. | 322 // manage insertions into the middle. |
| 323 std::vector<PlacedList::iterator> PlaceIndex(Nodes.size(), NoPlace); | 323 CfgVector<PlacedList::iterator> PlaceIndex(Nodes.size(), NoPlace); |
| 324 for (CfgNode *Node : Nodes) { | 324 for (CfgNode *Node : Nodes) { |
| 325 // The "do ... while(0);" construct is to factor out the --PlaceIndex and | 325 // The "do ... while(0);" construct is to factor out the --PlaceIndex and |
| 326 // assert() statements before moving to the next node. | 326 // assert() statements before moving to the next node. |
| 327 do { | 327 do { |
| 328 if (Node != getEntryNode() && Node->getInEdges().empty()) { | 328 if (Node != getEntryNode() && Node->getInEdges().empty()) { |
| 329 // The node has essentially been deleted since it is not a successor of | 329 // The node has essentially been deleted since it is not a successor of |
| 330 // any other node. | 330 // any other node. |
| 331 Unreachable.push_back(Node); | 331 Unreachable.push_back(Node); |
| 332 PlaceIndex[Node->getIndex()] = Unreachable.end(); | 332 PlaceIndex[Node->getIndex()] = Unreachable.end(); |
| 333 Node->setNeedsPlacement(false); | 333 Node->setNeedsPlacement(false); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 } | 773 } |
| 774 } | 774 } |
| 775 // Print each basic block | 775 // Print each basic block |
| 776 for (CfgNode *Node : Nodes) | 776 for (CfgNode *Node : Nodes) |
| 777 Node->dump(this); | 777 Node->dump(this); |
| 778 if (isVerbose(IceV_Instructions)) | 778 if (isVerbose(IceV_Instructions)) |
| 779 Str << "}\n"; | 779 Str << "}\n"; |
| 780 } | 780 } |
| 781 | 781 |
| 782 } // end of namespace Ice | 782 } // end of namespace Ice |
| OLD | NEW |