Chromium Code Reviews| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 | 220 |
| 221 // The set of translation passes and their order are determined by the | 221 // The set of translation passes and their order are determined by the |
| 222 // target. | 222 // target. |
| 223 getTarget()->translate(); | 223 getTarget()->translate(); |
| 224 | 224 |
| 225 dump("Final output"); | 225 dump("Final output"); |
| 226 if (getFocusedTiming()) | 226 if (getFocusedTiming()) |
| 227 getContext()->dumpTimers(); | 227 getContext()->dumpTimers(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void Cfg::fixPhiNodes() { | |
| 231 for (auto *Node : Nodes) { | |
| 232 // Fix all the phi edges since WASM can't tell how to make them correctly at | |
| 233 // the beginning. | |
| 234 assert(Node); | |
| 235 const auto InEdges = Node->getInEdges(); | |
|
Jim Stichnoth
2016/03/29 17:49:57
Should this be "const auto &" ? I don't know. ge
Eric Holk
2016/03/29 22:58:07
Done.
| |
| 236 for (auto &Inst : Node->getPhis()) { | |
| 237 auto Phi = llvm::cast<InstPhi>(&Inst); | |
|
Jim Stichnoth
2016/03/29 17:49:57
auto *
Eric Holk
2016/03/29 22:58:07
Done.
| |
| 238 assert(Phi); | |
| 239 for (SizeT i = 0; i < InEdges.size(); ++i) { | |
| 240 Phi->setLabel(i, InEdges[i]); | |
| 241 } | |
| 242 } | |
| 243 } | |
| 244 } | |
| 245 | |
| 230 void Cfg::computeInOutEdges() { | 246 void Cfg::computeInOutEdges() { |
| 231 // Compute the out-edges. | 247 // Compute the out-edges. |
| 232 for (CfgNode *Node : Nodes) | 248 for (CfgNode *Node : Nodes) |
| 233 Node->computeSuccessors(); | 249 Node->computeSuccessors(); |
| 234 | 250 |
| 235 // Prune any unreachable nodes before computing in-edges. | 251 // Prune any unreachable nodes before computing in-edges. |
| 236 SizeT NumNodes = getNumNodes(); | 252 SizeT NumNodes = getNumNodes(); |
| 237 BitVector Reachable(NumNodes); | 253 BitVector Reachable(NumNodes); |
| 238 BitVector Pending(NumNodes); | 254 BitVector Pending(NumNodes); |
| 239 Pending.set(getEntryNode()->getIndex()); | 255 Pending.set(getEntryNode()->getIndex()); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 Placed.push_back(Node); | 393 Placed.push_back(Node); |
| 378 PlaceIndex[Node->getIndex()] = Placed.end(); | 394 PlaceIndex[Node->getIndex()] = Placed.end(); |
| 379 continue; | 395 continue; |
| 380 } | 396 } |
| 381 Node->setNeedsPlacement(false); | 397 Node->setNeedsPlacement(false); |
| 382 // Assume for now that the unplaced node is from edge-splitting and | 398 // Assume for now that the unplaced node is from edge-splitting and |
| 383 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1 | 399 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1 |
| 384 // in-edge if the predecessor node was contracted). If this changes in | 400 // in-edge if the predecessor node was contracted). If this changes in |
| 385 // the future, rethink the strategy. | 401 // the future, rethink the strategy. |
| 386 assert(Node->getInEdges().size() >= 1); | 402 assert(Node->getInEdges().size() >= 1); |
| 387 assert(Node->getOutEdges().size() == 1); | 403 assert(Node->getOutEdges().size() == 1 || |
| 404 Node->getOutEdges()[0] == Node->getOutEdges()[1]); | |
| 388 | 405 |
| 389 // If it's a (non-critical) edge where the successor has a single | 406 // If it's a (non-critical) edge where the successor has a single |
| 390 // in-edge, then place it before the successor. | 407 // in-edge, then place it before the successor. |
| 391 CfgNode *Succ = Node->getOutEdges().front(); | 408 CfgNode *Succ = Node->getOutEdges().front(); |
| 392 if (Succ->getInEdges().size() == 1 && | 409 if (Succ->getInEdges().size() == 1 && |
| 393 PlaceIndex[Succ->getIndex()] != NoPlace) { | 410 PlaceIndex[Succ->getIndex()] != NoPlace) { |
| 394 Placed.insert(PlaceIndex[Succ->getIndex()], Node); | 411 Placed.insert(PlaceIndex[Succ->getIndex()], Node); |
| 395 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()]; | 412 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()]; |
| 396 continue; | 413 continue; |
| 397 } | 414 } |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 } | 1152 } |
| 1136 } | 1153 } |
| 1137 // Print each basic block | 1154 // Print each basic block |
| 1138 for (CfgNode *Node : Nodes) | 1155 for (CfgNode *Node : Nodes) |
| 1139 Node->dump(this); | 1156 Node->dump(this); |
| 1140 if (isVerbose(IceV_Instructions)) | 1157 if (isVerbose(IceV_Instructions)) |
| 1141 Str << "}\n"; | 1158 Str << "}\n"; |
| 1142 } | 1159 } |
| 1143 | 1160 |
| 1144 } // end of namespace Ice | 1161 } // end of namespace Ice |
| OLD | NEW |