| 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 // This file implements the Cfg class, including constant pool | 10 // This file implements the Cfg class, including constant pool |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 // The set of translation passes and their order are determined by | 102 // The set of translation passes and their order are determined by |
| 103 // the target. | 103 // the target. |
| 104 getTarget()->translate(); | 104 getTarget()->translate(); |
| 105 | 105 |
| 106 dump("Final output"); | 106 dump("Final output"); |
| 107 if (getFocusedTiming()) | 107 if (getFocusedTiming()) |
| 108 getContext()->dumpTimers(); | 108 getContext()->dumpTimers(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void Cfg::computePredecessors() { | 111 void Cfg::computeInOutEdges() { |
| 112 // Compute the out-edges. |
| 112 for (CfgNode *Node : Nodes) | 113 for (CfgNode *Node : Nodes) |
| 113 Node->computePredecessors(); | 114 Node->computeSuccessors(); |
| 115 |
| 116 // Prune any unreachable nodes before computing in-edges. |
| 117 SizeT NumNodes = getNumNodes(); |
| 118 llvm::BitVector Reachable(NumNodes); |
| 119 llvm::BitVector Pending(NumNodes); |
| 120 Pending.set(getEntryNode()->getIndex()); |
| 121 while (true) { |
| 122 int Index = Pending.find_first(); |
| 123 if (Index == -1) |
| 124 break; |
| 125 Pending.reset(Index); |
| 126 Reachable.set(Index); |
| 127 CfgNode *Node = Nodes[Index]; |
| 128 assert(Node->getIndex() == (SizeT)Index); |
| 129 for (CfgNode *Succ : Node->getOutEdges()) { |
| 130 SizeT SuccIndex = Succ->getIndex(); |
| 131 if (!Reachable.test(SuccIndex)) |
| 132 Pending.set(SuccIndex); |
| 133 } |
| 134 } |
| 135 SizeT Dest = 0; |
| 136 for (SizeT Source = 0; Source < NumNodes; ++Source) { |
| 137 if (Reachable.test(Source)) { |
| 138 Nodes[Dest] = Nodes[Source]; |
| 139 Nodes[Dest]->resetIndex(Dest); |
| 140 // Compute the in-edges. |
| 141 Nodes[Dest]->computePredecessors(); |
| 142 ++Dest; |
| 143 } |
| 144 } |
| 145 Nodes.resize(Dest); |
| 114 } | 146 } |
| 115 | 147 |
| 116 void Cfg::renumberInstructions() { | 148 void Cfg::renumberInstructions() { |
| 117 TimerMarker T(TimerStack::TT_renumberInstructions, this); | 149 TimerMarker T(TimerStack::TT_renumberInstructions, this); |
| 118 NextInstNumber = Inst::NumberInitial; | 150 NextInstNumber = Inst::NumberInitial; |
| 119 for (CfgNode *Node : Nodes) | 151 for (CfgNode *Node : Nodes) |
| 120 Node->renumberInstructions(); | 152 Node->renumberInstructions(); |
| 121 } | 153 } |
| 122 | 154 |
| 123 // placePhiLoads() must be called before placePhiStores(). | 155 // placePhiLoads() must be called before placePhiStores(). |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 541 } |
| 510 } | 542 } |
| 511 // Print each basic block | 543 // Print each basic block |
| 512 for (CfgNode *Node : Nodes) | 544 for (CfgNode *Node : Nodes) |
| 513 Node->dump(this); | 545 Node->dump(this); |
| 514 if (isVerbose(IceV_Instructions)) | 546 if (isVerbose(IceV_Instructions)) |
| 515 Str << "}\n"; | 547 Str << "}\n"; |
| 516 } | 548 } |
| 517 | 549 |
| 518 } // end of namespace Ice | 550 } // end of namespace Ice |
| OLD | NEW |