Ignore zero replication constants.
This patch enhances elaboration to drop/ignore zero replication count constants. Not doing this was causing problems later in the compiler. We still pass non-constant expressions since both user and system functions must be run for their possible side effects. Constants can never have a side effect so just dropping them is acceptable.
This commit is contained in:
parent
6a7675c812
commit
9a94d55738
25
elab_expr.cc
25
elab_expr.cc
|
|
@ -1686,11 +1686,9 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope,
|
||||||
repeat = rep;
|
repeat = rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make the empty concat expression. */
|
|
||||||
NetEConcat*tmp = new NetEConcat(parms_.count(), repeat);
|
|
||||||
tmp->set_line(*this);
|
|
||||||
|
|
||||||
unsigned wid_sum = 0;
|
unsigned wid_sum = 0;
|
||||||
|
unsigned parm_cnt = 0;
|
||||||
|
svector<NetExpr*> parms(parms_.count());
|
||||||
|
|
||||||
/* Elaborate all the parameters and attach them to the concat node. */
|
/* Elaborate all the parameters and attach them to the concat node. */
|
||||||
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
|
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
|
||||||
|
|
@ -1724,8 +1722,25 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We are going to ignore zero width constants. */
|
||||||
|
if ((ex->expr_width() == 0) && dynamic_cast<NetEConst*>(ex)) {
|
||||||
|
parms[idx] = 0;
|
||||||
|
} else {
|
||||||
|
parms[idx] = ex;
|
||||||
|
parm_cnt += 1;
|
||||||
|
}
|
||||||
wid_sum += ex->expr_width();
|
wid_sum += ex->expr_width();
|
||||||
tmp->set(idx, ex);
|
}
|
||||||
|
|
||||||
|
/* Make the empty concat expression. */
|
||||||
|
NetEConcat*tmp = new NetEConcat(parm_cnt, repeat);
|
||||||
|
tmp->set_line(*this);
|
||||||
|
|
||||||
|
/* Remove any zero width constants. */
|
||||||
|
unsigned off = 0;
|
||||||
|
for (unsigned idx = 0 ; idx < parm_cnt ; idx += 1) {
|
||||||
|
while (parms[off+idx] == 0) off += 1;
|
||||||
|
tmp->set(idx, parms[off+idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp->set_width(wid_sum * tmp->repeat());
|
tmp->set_width(wid_sum * tmp->repeat());
|
||||||
|
|
|
||||||
|
|
@ -3134,7 +3134,7 @@ static void draw_eval_expr_dest(ivl_expr_t exp, struct vector_info dest,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fallback, is to draw the expression by width, and mov it to
|
/* Fallback, is to draw the expression by width, and move it to
|
||||||
the required dest. */
|
the required dest. */
|
||||||
tmp = draw_eval_expr_wid(exp, dest.wid, stuff_ok_flag);
|
tmp = draw_eval_expr_wid(exp, dest.wid, stuff_ok_flag);
|
||||||
assert(tmp.wid == dest.wid);
|
assert(tmp.wid == dest.wid);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue