Commit b6a15350 authored by bgeron's avatar bgeron Committed by Commit bot

[turbofan] add more comments to compiler/graph-visualizer.cc.

BUG=

Review-Url: https://codereview.chromium.org/2040243002
Cr-Commit-Position: refs/heads/master@{#36824}
parent cec0ed0f
......@@ -618,6 +618,20 @@ const int kVisited = 2;
std::ostream& operator<<(std::ostream& os, const AsRPO& ar) {
base::AccountingAllocator allocator;
Zone local_zone(&allocator);
// Do a post-order depth-first search on the RPO graph. For every node,
// print:
//
// - the node id
// - the operator mnemonic
// - in square brackets its parameter (if present)
// - in parentheses the list of argument ids and their mnemonics
// - the node type (if it is typed)
// Post-order guarantees that all inputs of a node will be printed before
// the node itself, if there are no cycles. Any cycles are broken
// arbitrarily.
ZoneVector<byte> state(ar.graph.NodeCount(), kUnvisited, &local_zone);
ZoneStack<Node*> stack(&local_zone);
......@@ -638,12 +652,14 @@ std::ostream& operator<<(std::ostream& os, const AsRPO& ar) {
state[n->id()] = kVisited;
stack.pop();
os << "#" << n->id() << ":" << *n->op() << "(";
// Print the inputs.
int j = 0;
for (Node* const i : n->inputs()) {
if (j++ > 0) os << ", ";
os << "#" << SafeId(i) << ":" << SafeMnemonic(i);
}
os << ")";
// Print the node type, if any.
if (NodeProperties::IsTyped(n)) {
os << " [Type: ";
NodeProperties::GetType(n)->PrintTo(os);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment