std::string IR::dump()

in src/core/ir.cpp [106:166]


std::string IR::dump(IR::NodeRef idx) const {
  const auto &n = node(idx);
  std::stringstream ss;
  ss << "%" << idx << "[";
  for (const auto &v_idx : n.vars()) {
    const auto &v = var(v_idx);
    ss << v.name();  // << ":" << v.version();
    if (&v_idx != &n.vars().back()) {
      ss << ", ";
    }
  }
  ss << "] <- ";
  if (n.op() != Operation::view) {
    ss << loop_tool::dump(n.op());
    ss << "(";
  }
  for (const auto &inp : n.inputs()) {
    ss << "%" << inp;
    if (n.constraints().size()) {
      ss << "[";
      for (const auto &v_idx : node(inp).vars()) {
        const auto &v = var(v_idx);
        ss << v.name();  // << ":" << v.version();
        if (&v_idx != &node(inp).vars().back()) {
          ss << ", ";
        }
      }
      ss << "]";
    }
    if (&inp != &n.inputs().back()) {
      ss << ", ";
    }
  }
  if (n.op() != Operation::view) {
    ss << ")";
  }
  if (n.constraints().size()) {
    auto vars = to_set(node(n.inputs().at(0)).vars());
    ss << "{";
    bool first = true;
    for (const auto &c : n.constraints()) {
      if (c.first.type() != Expr::Type::symbol) {
        continue;
      }
      if (!n.has_sym(c.first.symbol())) {
        continue;
      }
      if (!vars.count(n.var(c.first.symbol()))) {
        continue;
      }
      if (!first) {
        ss << ", ";
      } else {
        first = false;
      }
      ss << c.first.dump(true) << "=" << c.second.dump(true);
    }
    ss << "}";
  }
  return ss.str();
}