| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 // The set of translation passes and their order are determined by the | 236 // The set of translation passes and their order are determined by the |
| 237 // target. | 237 // target. |
| 238 getTarget()->translate(); | 238 getTarget()->translate(); |
| 239 | 239 |
| 240 dump("Final output"); | 240 dump("Final output"); |
| 241 if (getFocusedTiming()) | 241 if (getFocusedTiming()) |
| 242 getContext()->dumpTimers(); | 242 getContext()->dumpTimers(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void Cfg::fixPhiNodes() { |
| 246 for (auto *Node : Nodes) { |
| 247 // Fix all the phi edges since WASM can't tell how to make them correctly at |
| 248 // the beginning. |
| 249 assert(Node); |
| 250 const auto &InEdges = Node->getInEdges(); |
| 251 for (auto &Instr : Node->getPhis()) { |
| 252 auto *Phi = llvm::cast<InstPhi>(&Instr); |
| 253 assert(Phi); |
| 254 for (SizeT i = 0; i < InEdges.size(); ++i) { |
| 255 Phi->setLabel(i, InEdges[i]); |
| 256 } |
| 257 } |
| 258 } |
| 259 } |
| 260 |
| 245 void Cfg::computeInOutEdges() { | 261 void Cfg::computeInOutEdges() { |
| 246 // Compute the out-edges. | 262 // Compute the out-edges. |
| 247 for (CfgNode *Node : Nodes) | 263 for (CfgNode *Node : Nodes) |
| 248 Node->computeSuccessors(); | 264 Node->computeSuccessors(); |
| 249 | 265 |
| 250 // Prune any unreachable nodes before computing in-edges. | 266 // Prune any unreachable nodes before computing in-edges. |
| 251 SizeT NumNodes = getNumNodes(); | 267 SizeT NumNodes = getNumNodes(); |
| 252 BitVector Reachable(NumNodes); | 268 BitVector Reachable(NumNodes); |
| 253 BitVector Pending(NumNodes); | 269 BitVector Pending(NumNodes); |
| 254 Pending.set(getEntryNode()->getIndex()); | 270 Pending.set(getEntryNode()->getIndex()); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 Placed.push_back(Node); | 408 Placed.push_back(Node); |
| 393 PlaceIndex[Node->getIndex()] = Placed.end(); | 409 PlaceIndex[Node->getIndex()] = Placed.end(); |
| 394 continue; | 410 continue; |
| 395 } | 411 } |
| 396 Node->setNeedsPlacement(false); | 412 Node->setNeedsPlacement(false); |
| 397 // Assume for now that the unplaced node is from edge-splitting and | 413 // Assume for now that the unplaced node is from edge-splitting and |
| 398 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1 | 414 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1 |
| 399 // in-edge if the predecessor node was contracted). If this changes in | 415 // in-edge if the predecessor node was contracted). If this changes in |
| 400 // the future, rethink the strategy. | 416 // the future, rethink the strategy. |
| 401 assert(Node->getInEdges().size() >= 1); | 417 assert(Node->getInEdges().size() >= 1); |
| 402 assert(Node->getOutEdges().size() == 1); | 418 assert(Node->hasSingleOutEdge()); |
| 403 | 419 |
| 404 // If it's a (non-critical) edge where the successor has a single | 420 // If it's a (non-critical) edge where the successor has a single |
| 405 // in-edge, then place it before the successor. | 421 // in-edge, then place it before the successor. |
| 406 CfgNode *Succ = Node->getOutEdges().front(); | 422 CfgNode *Succ = Node->getOutEdges().front(); |
| 407 if (Succ->getInEdges().size() == 1 && | 423 if (Succ->getInEdges().size() == 1 && |
| 408 PlaceIndex[Succ->getIndex()] != NoPlace) { | 424 PlaceIndex[Succ->getIndex()] != NoPlace) { |
| 409 Placed.insert(PlaceIndex[Succ->getIndex()], Node); | 425 Placed.insert(PlaceIndex[Succ->getIndex()], Node); |
| 410 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()]; | 426 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()]; |
| 411 continue; | 427 continue; |
| 412 } | 428 } |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 } | 1178 } |
| 1163 } | 1179 } |
| 1164 // Print each basic block | 1180 // Print each basic block |
| 1165 for (CfgNode *Node : Nodes) | 1181 for (CfgNode *Node : Nodes) |
| 1166 Node->dump(this); | 1182 Node->dump(this); |
| 1167 if (isVerbose(IceV_Instructions)) | 1183 if (isVerbose(IceV_Instructions)) |
| 1168 Str << "}\n"; | 1184 Str << "}\n"; |
| 1169 } | 1185 } |
| 1170 | 1186 |
| 1171 } // end of namespace Ice | 1187 } // end of namespace Ice |
| OLD | NEW |