Internals: Remove some pointless V3Number temporaries. No functional change intended.

This commit is contained in:
Wilson Snyder 2019-05-29 23:18:47 -04:00
parent 8846b365f4
commit c0be8bcefb
9 changed files with 31 additions and 29 deletions

View File

@ -128,9 +128,9 @@ void V3CCtors::evalAsserts() {
new AstConst(varp->fileline(), varp->widthWords()-1));
}
uint64_t value = VL_MASK_Q(storedWidth) & ~VL_MASK_Q(lastWordWidth);
V3Number num (varp, storedWidth, value);
newp = new AstAnd(varp->fileline(), newp,
new AstConst(varp->fileline(), num));
new AstConst(varp->fileline(), AstConst::WidthedValue(),
storedWidth, value));
AstNodeIf* ifp = new AstIf(varp->fileline(), newp,
new AstCStmt(varp->fileline(),
"Verilated::overWidthError(\""+varp->prettyName()+"\");"));

View File

@ -288,8 +288,7 @@ private:
AstAssign* setassignp
= new AstAssign(nodep->fileline(),
new AstVarRef(nodep->fileline(), setvscp, true),
new AstConst(nodep->fileline(),
V3Number(nodep, 1, true)));
new AstConst(nodep->fileline(), AstConst::LogicTrue()));
nodep->addNextHere(setassignp);
}
if (m_nextDlyp) { // Tell next assigndly it can share the variable

View File

@ -223,8 +223,9 @@ private:
rhsp->v3error("Unsupported: 4-state numbers in this context");
}
for (int w=0; w<nodep->widthWords(); w++) {
V3Number num (nodep, VL_WORDSIZE, rhsp->num().dataWord(w));
addWordAssign(nodep, w, new AstConst(nodep->fileline(), num));
addWordAssign(nodep, w, new AstConst(nodep->fileline(),
AstConst::WidthedValue(),
VL_WORDSIZE, rhsp->num().dataWord(w)));
}
return true;
}
@ -834,9 +835,9 @@ private:
} else {
UINFO(8," REDOR->EQ "<<nodep<<endl);
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
V3Number zero (nodep, longOrQuadWidth(nodep));
AstNode* newp = new AstNeq(nodep->fileline(),
new AstConst(nodep->fileline(), zero),
new AstConst(nodep->fileline(), AstConst::WidthedValue(),
longOrQuadWidth(nodep), 0),
lhsp);
replaceWithDelete(nodep, newp); VL_DANGLING(nodep);
}

View File

@ -146,8 +146,7 @@ private:
new AstSub(nodep->fileline(),
new AstVarRef(nodep->fileline(), varp, false),
new AstConst(nodep->fileline(), 1)));
V3Number zero (nodep, 32, 0); zero.isSigned(true);
AstNode* zerosp = new AstConst(nodep->fileline(), zero);
AstNode* zerosp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0);
AstNode* condp = new AstGtS(nodep->fileline(),
new AstVarRef(nodep->fileline(), varp, false),
zerosp);

View File

@ -599,7 +599,8 @@ void ParamVisitor::visitCell(AstCell* nodep) {
pinp->v3error("Can't convert defparam value to constant: Param "
<<pinp->name()<<" of "<<nodep->prettyName());
pinp->exprp()->replaceWith(
new AstConst(pinp->fileline(), V3Number(pinp, modvarp->width(), 0)));
new AstConst(pinp->fileline(),
AstConst::WidthedValue(), modvarp->width(), 0));
} else if (origp && exprp->sameTree(origp)) {
// Setting parameter to its default value. Just ignore it.
// This prevents making additional modules, and makes coverage more

View File

@ -286,13 +286,13 @@ private:
m1value),
nodep->width()));
} else {
V3Number zeronum (nodep, nodep->width(), 0);
constzerop = new AstConst(nodep->fileline(), zeronum);
constzerop = new AstConst(nodep->fileline(), AstConst::WidthedValue(),
nodep->width(), 0);
}
constzerop->dtypeFrom(nodep); // unsigned
V3Number widthnum (nodep, nodep->rhsp()->widthMin(), m1value);
AstNode* constwidthp = new AstConst(nodep->fileline(), widthnum);
AstNode* constwidthp = new AstConst(nodep->fileline(), AstConst::WidthedValue(),
nodep->rhsp()->widthMin(), m1value);
constwidthp->dtypeFrom(nodep->rhsp()); // unsigned
AstCond* newp =
new AstCond(nodep->fileline(),

View File

@ -334,7 +334,7 @@ private:
m_outNotSet[outnum] = true;
// Value in table is arbitrary, but we need something
setp = new AstConst(outvscp->fileline(),
V3Number(outvscp, outvscp->width(), 0));
AstConst::WidthedValue(), outvscp->width(), 0);
} else {
UINFO(8," Output "<<outvscp->name()<<" = "<<*outnump<<endl);
// m_tableVarps[inValue] = num;

View File

@ -490,13 +490,13 @@ class TristateVisitor : public TristateBaseVisitor {
// set output enable to always be off on this assign
// statement so that this var is floating
UINFO(8," Adding driver to var "<<varp<<endl);
V3Number zeros (varp, varp->width());
zeros.setAllBits0();
AstConst* constp = new AstConst(varp->fileline(), zeros);
AstConst* constp = new AstConst(varp->fileline(),
AstConst::WidthedValue(), varp->width(), 0);
AstVarRef* varrefp = new AstVarRef(varp->fileline(), varp, true);
AstNode* newp = new AstAssignW(varp->fileline(), varrefp, constp);
UINFO(9," newoev "<<newp<<endl);
varrefp->user1p(new AstConst(varp->fileline(), zeros));
varrefp->user1p(new AstConst(varp->fileline(),
AstConst::WidthedValue(), varp->width(), 0));
nodep->addStmtp(newp);
mapInsertLhsVarRef(varrefp); // insertTristates will convert
// // to a varref to the __out# variable

View File

@ -186,8 +186,8 @@ private:
// If we got ==1'bx it can never be true (but 1'bx==1'bx can be!)
if (((VN_IS(lhsp, Const) && VN_CAST(lhsp, Const)->num().isFourState())
|| (VN_IS(rhsp, Const) && VN_CAST(rhsp, Const)->num().isFourState()))) {
V3Number num(nodep, 1, (VN_IS(nodep, EqCase) ? 0:1));
newp = new AstConst(nodep->fileline(), num);
newp = new AstConst(nodep->fileline(), AstConst::WidthedValue(),
1, (VN_IS(nodep, EqCase) ? 0 : 1));
lhsp->deleteTree(); VL_DANGLING(lhsp);
rhsp->deleteTree(); VL_DANGLING(rhsp);
} else {
@ -254,8 +254,7 @@ private:
iterateChildren(nodep);
// Ahh, we're two state, so this is easy
UINFO(4," ISUNKNOWN->0 "<<nodep<<endl);
V3Number zero (nodep, 1, 0);
AstConst* newp = new AstConst(nodep->fileline(), zero);
AstConst* newp = new AstConst(nodep->fileline(), AstConst::LogicFalse());
nodep->replaceWith(newp);
nodep->deleteTree(); VL_DANGLING(nodep);
}
@ -336,11 +335,12 @@ private:
// Similar code in V3Const::warnSelect
int maxmsb = nodep->fromp()->dtypep()->width()-1;
if (debug()>=9) nodep->dumpTree(cout, "sel_old: ");
V3Number maxmsbnum (nodep, nodep->lsbp()->width(), maxmsb);
// If (maxmsb >= selected), we're in bound
AstNode* condp = new AstGte(nodep->fileline(),
new AstConst(nodep->fileline(), maxmsbnum),
new AstConst(nodep->fileline(),
AstConst::WidthedValue(),
nodep->lsbp()->width(), maxmsb),
nodep->lsbp()->cloneTree(false));
// See if the condition is constant true (e.g. always in bound due to constant select)
// Note below has null backp(); the Edit function knows how to deal with that.
@ -398,11 +398,11 @@ private:
nodep->v3error("Select from non-array "<<dtypep->prettyTypeName());
}
if (debug()>=9) nodep->dumpTree(cout, "arraysel_old: ");
V3Number widthnum (nodep, nodep->bitp()->width(), declElements-1);
// See if the condition is constant true
AstNode* condp = new AstGte(nodep->fileline(),
new AstConst(nodep->fileline(), widthnum),
new AstConst(nodep->fileline(), AstConst::WidthedValue(),
nodep->bitp()->width(), declElements-1),
nodep->bitp()->cloneTree(false));
// Note below has null backp(); the Edit function knows how to deal with that.
condp = V3Const::constifyEdit(condp);
@ -437,7 +437,9 @@ private:
V3Number zeronum (nodep, bitp->width(), 0);
AstNode* newp = new AstCondBound(bitp->fileline(),
condp, bitp,
new AstConst(bitp->fileline(), zeronum));
new AstConst(bitp->fileline(),
AstConst::WidthedValue(),
bitp->width(), 0));
// Added X's, tristate them too
if (debug()>=9) newp->dumpTree(cout, " _new: ");
replaceHandle.relink(newp);