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.
(cherry picked from commit 9a94d55738)
This commit is contained in:
Cary R 2010-03-21 22:00:44 -07:00 committed by Stephen Williams
parent 53c206f2c5
commit 059068f070
2 changed files with 21 additions and 6 deletions

View File

@ -1686,11 +1686,9 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope,
repeat = rep;
}
/* Make the empty concat expression. */
NetEConcat*tmp = new NetEConcat(parms_.count(), repeat);
tmp->set_line(*this);
unsigned wid_sum = 0;
unsigned parm_cnt = 0;
svector<NetExpr*> parms(parms_.count());
/* Elaborate all the parameters and attach them to the concat node. */
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
@ -1724,8 +1722,25 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope,
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();
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());

View File

@ -2955,7 +2955,7 @@ static void draw_eval_expr_dest(ivl_expr_t exp, struct vector_info dest,
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. */
tmp = draw_eval_expr_wid(exp, dest.wid, stuff_ok_flag);
assert(tmp.wid == dest.wid);