3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-06 19:21:23 +00:00

Make log() use the FmtString infrastructure.

Now `log()` supports `std::string`.

We have to fix a few places where the format parameter was not a compile time constant.
This is mostly trivial.
This commit is contained in:
Robert O'Callahan 2025-07-10 05:24:59 +00:00
parent 422ec05322
commit 2e28feed94
9 changed files with 67 additions and 38 deletions

View file

@ -97,13 +97,13 @@ struct LogPass : public Pass {
text += args[argidx] + ' ';
if (!text.empty()) text.resize(text.size()-1);
const char *fmtline = newline ? "%s\n" : "%s";
const char *line_end = newline ? "\n" : "";
if (to_stdout) fprintf(stdout, fmtline, text.c_str());
if (to_stderr) fprintf(stderr, fmtline, text.c_str());
if (to_stdout) fprintf(stdout, "%s%s", text.c_str(), line_end);
if (to_stderr) fprintf(stderr, "%s%s", text.c_str(), line_end);
if (to_log) {
if (!header) log(fmtline, text.c_str());
else log_header(design, fmtline, text.c_str());
if (!header) log("%s%s", text.c_str(), line_end);
else log_header(design, "%s%s", text.c_str(), line_end);
}
}
} LogPass;

View file

@ -474,7 +474,7 @@ struct StatPass : public Pass {
if (json_mode) {
log("\n");
log(top_mod == nullptr ? " }\n" : " },\n");
log("%s", top_mod == nullptr ? " }\n" : " },\n");
}
if (top_mod != nullptr)

View file

@ -202,7 +202,7 @@ struct EquivSimpleWorker
log(" Problem size at t=%d: %d literals, %d clauses\n", step, ez->numCnfVariables(), ez->numCnfClauses());
if (!ez->solve(ez_context)) {
log(verbose ? " Proved equivalence! Marking $equiv cell as proven.\n" : " success!\n");
log("%s", verbose ? " Proved equivalence! Marking $equiv cell as proven.\n" : " success!\n");
equiv_cell->setPort(ID::B, equiv_cell->getPort(ID::A));
ez->assume(ez->NOT(ez_context));
return true;

View file

@ -639,10 +639,10 @@ struct SatHelper
"---------------------------------------------------------------------------------------------------"
"---------------------------------------------------------------------------------------------------";
if (last_timestep == -2) {
log(max_timestep > 0 ? " Time " : " ");
log("%s", max_timestep > 0 ? " Time " : " ");
log("%-*s %11s %9s %*s\n", maxModelName+5, "Signal Name", "Dec", "Hex", maxModelWidth+3, "Bin");
}
log(max_timestep > 0 ? " ---- " : " ");
log("%s", max_timestep > 0 ? " ---- " : " ");
log("%*.*s %11.11s %9.9s %*.*s\n", maxModelName+5, maxModelName+5,
hline, hline, hline, maxModelWidth+3, maxModelWidth+3, hline);
last_timestep = info.timestep;

View file

@ -553,11 +553,11 @@ static void dfflibmap(RTLIL::Design *design, RTLIL::Module *module)
new_cell->setPort("\\" + port.first, sig);
}
stats[stringf(" mapped %%d %s cells to %s cells.\n", cell_type.c_str(), new_cell->type.c_str())]++;
stats[stringf("%s cells to %s cells", cell_type.c_str(), new_cell->type.c_str())]++;
}
for (auto &stat: stats)
log(stat.first.c_str(), stat.second);
log(" mapped %d %s.\n", stat.second, stat.first);
}
struct DfflibmapPass : public Pass {

View file

@ -522,7 +522,7 @@ static void run_eval_test(RTLIL::Design *design, bool verbose, bool nosat, std::
for (int i = 0; i < 64; i++)
{
log(verbose ? "\n" : ".");
log("%s", verbose ? "\n" : ".");
gold_ce.clear();
gate_ce.clear();