dump_twines: fix

This commit is contained in:
Emil J. Tywoniak 2026-06-16 13:15:20 +02:00
parent 6f1ca02a90
commit ec3e62cdfc
1 changed files with 16 additions and 22 deletions

View File

@ -40,36 +40,30 @@ struct DumpTwinesPass : public Pass {
extra_args(args, argidx, design); extra_args(args, argidx, design);
const TwinePool &pool = design->twines; const TwinePool &pool = design->twines;
log("twine pool: %zu nodes (%zu leaves, %zu suffixes, %zu concats)\n", log("twine pool: %zu local nodes\n", pool.size());
pool.size(), pool.leaf_count(), pool.suffix_count(), pool.concat_count()); for (auto it = pool.backing.begin(); it != pool.backing.end(); ++it) {
pool.for_each_live([&](TwineRef id, const Twine &n) { TwineRef id = STATIC_TWINE_END + pool.backing.get_index(it);
const Twine &n = *it;
if (n.is_leaf()) { if (n.is_leaf()) {
log(" @%u leaf rc=%u %s\n", id, pool.refcount(id), n.leaf().c_str()); log(" @%zu leaf \"%s\"", (size_t)id, n.leaf().c_str());
} else if (n.is_suffix()) { } else if (n.is_suffix()) {
if (flat) { log(" @%zu suffix @%zu + \"%s\"", (size_t)id,
log(" @%u suffix rc=%u @%u + %s -> %s\n", id, pool.refcount(id), (size_t)n.suffix().prefix, n.suffix().tail.c_str());
n.suffix().parent, n.suffix().tail.c_str(), } else if (n.is_concat()) {
pool.flat_string(id).c_str());
} else {
log(" @%u suffix rc=%u @%u + %s\n", id, pool.refcount(id),
n.suffix().parent, n.suffix().tail.c_str());
}
} else {
std::string children; std::string children;
for (TwineRef c : n.children()) { for (TwineRef c : n.children()) {
if (!children.empty()) if (!children.empty())
children += ", "; children += ", ";
children += "@" + std::to_string(c); children += "@" + std::to_string((size_t)c);
}
if (flat) {
log(" @%u concat rc=%u [%s] -> %s\n", id, pool.refcount(id),
children.c_str(), pool.flatten(id).c_str());
} else {
log(" @%u concat rc=%u [%s]\n", id, pool.refcount(id),
children.c_str());
} }
log(" @%zu concat [%s]", (size_t)id, children.c_str());
} else {
log(" @%zu dead", (size_t)id);
} }
}); if (flat)
log(" -> \"%s\"", pool.str(id).c_str());
log("\n");
}
} }
} DumpTwinesPass; } DumpTwinesPass;