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

Side by Side Diff: src/IceCfg.cpp

Issue 1837663002: Initial Subzero WASM prototype. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review feedback and merging master Created 4 years, 8 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 | « src/IceCfg.h ('k') | src/IceCfgNode.h » ('j') | no next file with comments »
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // target. 238 // target.
239 getTarget()->translate(); 239 getTarget()->translate();
240 240
241 dump("Final output"); 241 dump("Final output");
242 if (getFocusedTiming()) { 242 if (getFocusedTiming()) {
243 getContext()->mergeTimersFromTLS(); 243 getContext()->mergeTimersFromTLS();
244 getContext()->dumpTimers(); 244 getContext()->dumpTimers();
245 } 245 }
246 } 246 }
247 247
248 void Cfg::fixPhiNodes() {
249 for (auto *Node : Nodes) {
250 // Fix all the phi edges since WASM can't tell how to make them correctly at
251 // the beginning.
252 assert(Node);
253 const auto &InEdges = Node->getInEdges();
254 for (auto &Instr : Node->getPhis()) {
255 auto *Phi = llvm::cast<InstPhi>(&Instr);
256 assert(Phi);
257 for (SizeT i = 0; i < InEdges.size(); ++i) {
258 Phi->setLabel(i, InEdges[i]);
259 }
260 }
261 }
262 }
263
248 void Cfg::computeInOutEdges() { 264 void Cfg::computeInOutEdges() {
249 // Compute the out-edges. 265 // Compute the out-edges.
250 for (CfgNode *Node : Nodes) 266 for (CfgNode *Node : Nodes)
251 Node->computeSuccessors(); 267 Node->computeSuccessors();
252 268
253 // Prune any unreachable nodes before computing in-edges. 269 // Prune any unreachable nodes before computing in-edges.
254 SizeT NumNodes = getNumNodes(); 270 SizeT NumNodes = getNumNodes();
255 BitVector Reachable(NumNodes); 271 BitVector Reachable(NumNodes);
256 BitVector Pending(NumNodes); 272 BitVector Pending(NumNodes);
257 Pending.set(getEntryNode()->getIndex()); 273 Pending.set(getEntryNode()->getIndex());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 Placed.push_back(Node); 411 Placed.push_back(Node);
396 PlaceIndex[Node->getIndex()] = Placed.end(); 412 PlaceIndex[Node->getIndex()] = Placed.end();
397 continue; 413 continue;
398 } 414 }
399 Node->setNeedsPlacement(false); 415 Node->setNeedsPlacement(false);
400 // Assume for now that the unplaced node is from edge-splitting and 416 // Assume for now that the unplaced node is from edge-splitting and
401 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1 417 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1
402 // in-edge if the predecessor node was contracted). If this changes in 418 // in-edge if the predecessor node was contracted). If this changes in
403 // the future, rethink the strategy. 419 // the future, rethink the strategy.
404 assert(Node->getInEdges().size() >= 1); 420 assert(Node->getInEdges().size() >= 1);
405 assert(Node->getOutEdges().size() == 1); 421 assert(Node->hasSingleOutEdge());
406 422
407 // If it's a (non-critical) edge where the successor has a single 423 // If it's a (non-critical) edge where the successor has a single
408 // in-edge, then place it before the successor. 424 // in-edge, then place it before the successor.
409 CfgNode *Succ = Node->getOutEdges().front(); 425 CfgNode *Succ = Node->getOutEdges().front();
410 if (Succ->getInEdges().size() == 1 && 426 if (Succ->getInEdges().size() == 1 &&
411 PlaceIndex[Succ->getIndex()] != NoPlace) { 427 PlaceIndex[Succ->getIndex()] != NoPlace) {
412 Placed.insert(PlaceIndex[Succ->getIndex()], Node); 428 Placed.insert(PlaceIndex[Succ->getIndex()], Node);
413 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()]; 429 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()];
414 continue; 430 continue;
415 } 431 }
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 } 1181 }
1166 } 1182 }
1167 // Print each basic block 1183 // Print each basic block
1168 for (CfgNode *Node : Nodes) 1184 for (CfgNode *Node : Nodes)
1169 Node->dump(this); 1185 Node->dump(this);
1170 if (isVerbose(IceV_Instructions)) 1186 if (isVerbose(IceV_Instructions))
1171 Str << "}\n"; 1187 Str << "}\n";
1172 } 1188 }
1173 1189
1174 } // end of namespace Ice 1190 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCfgNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698