mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-16 06:31:29 +00:00
Merge pull request #2168 from whitequark/assert-unused-exprs
Use (and ignore) the expression provided to log_assert in NDEBUG builds
This commit is contained in:
commit
c7d71f436d
13 changed files with 46 additions and 43 deletions
|
@ -117,7 +117,7 @@ void replace_undriven(RTLIL::Module *module, const CellTypes &ct)
|
|||
}
|
||||
|
||||
void replace_cell(SigMap &assign_map, RTLIL::Module *module, RTLIL::Cell *cell,
|
||||
const std::string &info YS_ATTRIBUTE(unused), IdString out_port, RTLIL::SigSpec out_val)
|
||||
const std::string &info, IdString out_port, RTLIL::SigSpec out_val)
|
||||
{
|
||||
RTLIL::SigSpec Y = cell->getPort(out_port);
|
||||
out_val.extend_u0(Y.size(), false);
|
||||
|
|
|
@ -589,7 +589,7 @@ with open(outfile, "w") as f:
|
|||
if block["type"] in ("match", "code"):
|
||||
print(" // {}".format(block["src"]), file=f)
|
||||
|
||||
print(" void block_{}(int recursion YS_ATTRIBUTE(unused)) {{".format(index), file=f)
|
||||
print(" void block_{}(int recursion YS_MAYBE_UNUSED) {{".format(index), file=f)
|
||||
current_pattern, current_subpattern = block["pattern"]
|
||||
|
||||
if block["type"] == "final":
|
||||
|
@ -636,17 +636,17 @@ with open(outfile, "w") as f:
|
|||
for s in sorted(const_st):
|
||||
t = state_types[current_pattern][s]
|
||||
if t.endswith("*"):
|
||||
print(" {} const &{} YS_ATTRIBUTE(unused) = st_{}.{};".format(t, s, current_pattern, s), file=f)
|
||||
print(" {} const &{} YS_MAYBE_UNUSED = st_{}.{};".format(t, s, current_pattern, s), file=f)
|
||||
else:
|
||||
print(" const {} &{} YS_ATTRIBUTE(unused) = st_{}.{};".format(t, s, current_pattern, s), file=f)
|
||||
print(" const {} &{} YS_MAYBE_UNUSED = st_{}.{};".format(t, s, current_pattern, s), file=f)
|
||||
|
||||
for s in sorted(nonconst_st):
|
||||
t = state_types[current_pattern][s]
|
||||
print(" {} &{} YS_ATTRIBUTE(unused) = st_{}.{};".format(t, s, current_pattern, s), file=f)
|
||||
print(" {} &{} YS_MAYBE_UNUSED = st_{}.{};".format(t, s, current_pattern, s), file=f)
|
||||
|
||||
for u in sorted(udata_types[current_pattern].keys()):
|
||||
t = udata_types[current_pattern][u]
|
||||
print(" {} &{} YS_ATTRIBUTE(unused) = ud_{}.{};".format(t, u, current_pattern, u), file=f)
|
||||
print(" {} &{} YS_MAYBE_UNUSED = ud_{}.{};".format(t, u, current_pattern, u), file=f)
|
||||
|
||||
if len(restore_st):
|
||||
print("", file=f)
|
||||
|
@ -676,7 +676,7 @@ with open(outfile, "w") as f:
|
|||
|
||||
print("", file=f)
|
||||
print("rollback_label:", file=f)
|
||||
print(" YS_ATTRIBUTE(unused);", file=f)
|
||||
print(" YS_MAYBE_UNUSED;", file=f)
|
||||
|
||||
if len(block["fcode"]):
|
||||
print("#define accept do { accept_cnt++; on_accept(); } while(0)", file=f)
|
||||
|
@ -684,7 +684,7 @@ with open(outfile, "w") as f:
|
|||
for line in block["fcode"]:
|
||||
print(" " + line, file=f)
|
||||
print("finish_label:", file=f)
|
||||
print(" YS_ATTRIBUTE(unused);", file=f)
|
||||
print(" YS_MAYBE_UNUSED;", file=f)
|
||||
print("#undef accept", file=f)
|
||||
print("#undef finish", file=f)
|
||||
|
||||
|
@ -733,13 +733,13 @@ with open(outfile, "w") as f:
|
|||
valueidx = 1
|
||||
for item in block["setup"]:
|
||||
if item[0] == "slice":
|
||||
print(" const int &{} YS_ATTRIBUTE(unused) = std::get<{}>(cells[_pmg_idx]);".format(item[1], valueidx), file=f)
|
||||
print(" const int &{} YS_MAYBE_UNUSED = std::get<{}>(cells[_pmg_idx]);".format(item[1], valueidx), file=f)
|
||||
valueidx += 1
|
||||
if item[0] == "choice":
|
||||
print(" const {} &{} YS_ATTRIBUTE(unused) = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f)
|
||||
print(" const {} &{} YS_MAYBE_UNUSED = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f)
|
||||
valueidx += 1
|
||||
if item[0] == "define":
|
||||
print(" const {} &{} YS_ATTRIBUTE(unused) = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f)
|
||||
print(" const {} &{} YS_MAYBE_UNUSED = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f)
|
||||
valueidx += 1
|
||||
print(" if (blacklist_cells.count({})) continue;".format(block["cell"]), file=f)
|
||||
for expr in block["filter"]:
|
||||
|
|
|
@ -741,7 +741,7 @@ void prep_xaiger(RTLIL::Module *module, bool dff)
|
|||
if (ys_debug(1))
|
||||
toposort.analyze_loops = true;
|
||||
|
||||
bool no_loops YS_ATTRIBUTE(unused) = toposort.sort();
|
||||
bool no_loops = toposort.sort();
|
||||
|
||||
if (ys_debug(1)) {
|
||||
unsigned i = 0;
|
||||
|
@ -1453,7 +1453,7 @@ void reintegrate(RTLIL::Module *module, bool dff_mode)
|
|||
for (auto driver_cell : bit_drivers.at(it.first))
|
||||
for (auto user_cell : it.second)
|
||||
toposort.edge(driver_cell, user_cell);
|
||||
bool no_loops YS_ATTRIBUTE(unused) = toposort.sort();
|
||||
bool no_loops = toposort.sort();
|
||||
log_assert(no_loops);
|
||||
|
||||
for (auto ii = toposort.sorted.rbegin(); ii != toposort.sorted.rend(); ii++) {
|
||||
|
|
|
@ -409,11 +409,11 @@ static void map_sr_to_arst(IdString from, IdString to)
|
|||
if (!cell_mappings.count(from) || cell_mappings.count(to) > 0)
|
||||
return;
|
||||
|
||||
char from_clk_pol YS_ATTRIBUTE(unused) = from[8];
|
||||
char from_clk_pol = from[8];
|
||||
char from_set_pol = from[9];
|
||||
char from_clr_pol = from[10];
|
||||
char to_clk_pol YS_ATTRIBUTE(unused) = to[6];
|
||||
char to_rst_pol YS_ATTRIBUTE(unused) = to[7];
|
||||
char to_clk_pol = to[6];
|
||||
char to_rst_pol = to[7];
|
||||
char to_rst_val = to[8];
|
||||
|
||||
log_assert(from_clk_pol == to_clk_pol);
|
||||
|
@ -455,9 +455,9 @@ static void map_adff_to_dff(IdString from, IdString to)
|
|||
if (!cell_mappings.count(from) || cell_mappings.count(to) > 0)
|
||||
return;
|
||||
|
||||
char from_clk_pol YS_ATTRIBUTE(unused) = from[6];
|
||||
char from_clk_pol = from[6];
|
||||
char from_rst_pol = from[7];
|
||||
char to_clk_pol YS_ATTRIBUTE(unused) = to[6];
|
||||
char to_clk_pol = to[6];
|
||||
|
||||
log_assert(from_clk_pol == to_clk_pol);
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ static void test_abcloop()
|
|||
SatGen satgen(ez.get(), &sigmap);
|
||||
|
||||
for (auto c : module->cells()) {
|
||||
bool ok YS_ATTRIBUTE(unused) = satgen.importCell(c);
|
||||
bool ok = satgen.importCell(c);
|
||||
log_assert(ok);
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ static void test_abcloop()
|
|||
SatGen satgen(ez.get(), &sigmap);
|
||||
|
||||
for (auto c : module->cells()) {
|
||||
bool ok YS_ATTRIBUTE(unused) = satgen.importCell(c);
|
||||
bool ok = satgen.importCell(c);
|
||||
log_assert(ok);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue