Internals: Remove some pointless V3Number temporaries. No functional change intended.
This commit is contained in:
parent
8846b365f4
commit
c0be8bcefb
|
|
@ -128,9 +128,9 @@ void V3CCtors::evalAsserts() {
|
||||||
new AstConst(varp->fileline(), varp->widthWords()-1));
|
new AstConst(varp->fileline(), varp->widthWords()-1));
|
||||||
}
|
}
|
||||||
uint64_t value = VL_MASK_Q(storedWidth) & ~VL_MASK_Q(lastWordWidth);
|
uint64_t value = VL_MASK_Q(storedWidth) & ~VL_MASK_Q(lastWordWidth);
|
||||||
V3Number num (varp, storedWidth, value);
|
|
||||||
newp = new AstAnd(varp->fileline(), newp,
|
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,
|
AstNodeIf* ifp = new AstIf(varp->fileline(), newp,
|
||||||
new AstCStmt(varp->fileline(),
|
new AstCStmt(varp->fileline(),
|
||||||
"Verilated::overWidthError(\""+varp->prettyName()+"\");"));
|
"Verilated::overWidthError(\""+varp->prettyName()+"\");"));
|
||||||
|
|
|
||||||
|
|
@ -288,8 +288,7 @@ private:
|
||||||
AstAssign* setassignp
|
AstAssign* setassignp
|
||||||
= new AstAssign(nodep->fileline(),
|
= new AstAssign(nodep->fileline(),
|
||||||
new AstVarRef(nodep->fileline(), setvscp, true),
|
new AstVarRef(nodep->fileline(), setvscp, true),
|
||||||
new AstConst(nodep->fileline(),
|
new AstConst(nodep->fileline(), AstConst::LogicTrue()));
|
||||||
V3Number(nodep, 1, true)));
|
|
||||||
nodep->addNextHere(setassignp);
|
nodep->addNextHere(setassignp);
|
||||||
}
|
}
|
||||||
if (m_nextDlyp) { // Tell next assigndly it can share the variable
|
if (m_nextDlyp) { // Tell next assigndly it can share the variable
|
||||||
|
|
|
||||||
|
|
@ -223,8 +223,9 @@ private:
|
||||||
rhsp->v3error("Unsupported: 4-state numbers in this context");
|
rhsp->v3error("Unsupported: 4-state numbers in this context");
|
||||||
}
|
}
|
||||||
for (int w=0; w<nodep->widthWords(); w++) {
|
for (int w=0; w<nodep->widthWords(); w++) {
|
||||||
V3Number num (nodep, VL_WORDSIZE, rhsp->num().dataWord(w));
|
addWordAssign(nodep, w, new AstConst(nodep->fileline(),
|
||||||
addWordAssign(nodep, w, new AstConst(nodep->fileline(), num));
|
AstConst::WidthedValue(),
|
||||||
|
VL_WORDSIZE, rhsp->num().dataWord(w)));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -834,9 +835,9 @@ private:
|
||||||
} else {
|
} else {
|
||||||
UINFO(8," REDOR->EQ "<<nodep<<endl);
|
UINFO(8," REDOR->EQ "<<nodep<<endl);
|
||||||
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
|
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
|
||||||
V3Number zero (nodep, longOrQuadWidth(nodep));
|
|
||||||
AstNode* newp = new AstNeq(nodep->fileline(),
|
AstNode* newp = new AstNeq(nodep->fileline(),
|
||||||
new AstConst(nodep->fileline(), zero),
|
new AstConst(nodep->fileline(), AstConst::WidthedValue(),
|
||||||
|
longOrQuadWidth(nodep), 0),
|
||||||
lhsp);
|
lhsp);
|
||||||
replaceWithDelete(nodep, newp); VL_DANGLING(nodep);
|
replaceWithDelete(nodep, newp); VL_DANGLING(nodep);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,7 @@ private:
|
||||||
new AstSub(nodep->fileline(),
|
new AstSub(nodep->fileline(),
|
||||||
new AstVarRef(nodep->fileline(), varp, false),
|
new AstVarRef(nodep->fileline(), varp, false),
|
||||||
new AstConst(nodep->fileline(), 1)));
|
new AstConst(nodep->fileline(), 1)));
|
||||||
V3Number zero (nodep, 32, 0); zero.isSigned(true);
|
AstNode* zerosp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0);
|
||||||
AstNode* zerosp = new AstConst(nodep->fileline(), zero);
|
|
||||||
AstNode* condp = new AstGtS(nodep->fileline(),
|
AstNode* condp = new AstGtS(nodep->fileline(),
|
||||||
new AstVarRef(nodep->fileline(), varp, false),
|
new AstVarRef(nodep->fileline(), varp, false),
|
||||||
zerosp);
|
zerosp);
|
||||||
|
|
|
||||||
|
|
@ -599,7 +599,8 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||||
pinp->v3error("Can't convert defparam value to constant: Param "
|
pinp->v3error("Can't convert defparam value to constant: Param "
|
||||||
<<pinp->name()<<" of "<<nodep->prettyName());
|
<<pinp->name()<<" of "<<nodep->prettyName());
|
||||||
pinp->exprp()->replaceWith(
|
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)) {
|
} else if (origp && exprp->sameTree(origp)) {
|
||||||
// Setting parameter to its default value. Just ignore it.
|
// Setting parameter to its default value. Just ignore it.
|
||||||
// This prevents making additional modules, and makes coverage more
|
// This prevents making additional modules, and makes coverage more
|
||||||
|
|
|
||||||
|
|
@ -286,13 +286,13 @@ private:
|
||||||
m1value),
|
m1value),
|
||||||
nodep->width()));
|
nodep->width()));
|
||||||
} else {
|
} else {
|
||||||
V3Number zeronum (nodep, nodep->width(), 0);
|
constzerop = new AstConst(nodep->fileline(), AstConst::WidthedValue(),
|
||||||
constzerop = new AstConst(nodep->fileline(), zeronum);
|
nodep->width(), 0);
|
||||||
}
|
}
|
||||||
constzerop->dtypeFrom(nodep); // unsigned
|
constzerop->dtypeFrom(nodep); // unsigned
|
||||||
|
|
||||||
V3Number widthnum (nodep, nodep->rhsp()->widthMin(), m1value);
|
AstNode* constwidthp = new AstConst(nodep->fileline(), AstConst::WidthedValue(),
|
||||||
AstNode* constwidthp = new AstConst(nodep->fileline(), widthnum);
|
nodep->rhsp()->widthMin(), m1value);
|
||||||
constwidthp->dtypeFrom(nodep->rhsp()); // unsigned
|
constwidthp->dtypeFrom(nodep->rhsp()); // unsigned
|
||||||
AstCond* newp =
|
AstCond* newp =
|
||||||
new AstCond(nodep->fileline(),
|
new AstCond(nodep->fileline(),
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ private:
|
||||||
m_outNotSet[outnum] = true;
|
m_outNotSet[outnum] = true;
|
||||||
// Value in table is arbitrary, but we need something
|
// Value in table is arbitrary, but we need something
|
||||||
setp = new AstConst(outvscp->fileline(),
|
setp = new AstConst(outvscp->fileline(),
|
||||||
V3Number(outvscp, outvscp->width(), 0));
|
AstConst::WidthedValue(), outvscp->width(), 0);
|
||||||
} else {
|
} else {
|
||||||
UINFO(8," Output "<<outvscp->name()<<" = "<<*outnump<<endl);
|
UINFO(8," Output "<<outvscp->name()<<" = "<<*outnump<<endl);
|
||||||
// m_tableVarps[inValue] = num;
|
// m_tableVarps[inValue] = num;
|
||||||
|
|
|
||||||
|
|
@ -490,13 +490,13 @@ class TristateVisitor : public TristateBaseVisitor {
|
||||||
// set output enable to always be off on this assign
|
// set output enable to always be off on this assign
|
||||||
// statement so that this var is floating
|
// statement so that this var is floating
|
||||||
UINFO(8," Adding driver to var "<<varp<<endl);
|
UINFO(8," Adding driver to var "<<varp<<endl);
|
||||||
V3Number zeros (varp, varp->width());
|
AstConst* constp = new AstConst(varp->fileline(),
|
||||||
zeros.setAllBits0();
|
AstConst::WidthedValue(), varp->width(), 0);
|
||||||
AstConst* constp = new AstConst(varp->fileline(), zeros);
|
|
||||||
AstVarRef* varrefp = new AstVarRef(varp->fileline(), varp, true);
|
AstVarRef* varrefp = new AstVarRef(varp->fileline(), varp, true);
|
||||||
AstNode* newp = new AstAssignW(varp->fileline(), varrefp, constp);
|
AstNode* newp = new AstAssignW(varp->fileline(), varrefp, constp);
|
||||||
UINFO(9," newoev "<<newp<<endl);
|
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);
|
nodep->addStmtp(newp);
|
||||||
mapInsertLhsVarRef(varrefp); // insertTristates will convert
|
mapInsertLhsVarRef(varrefp); // insertTristates will convert
|
||||||
// // to a varref to the __out# variable
|
// // to a varref to the __out# variable
|
||||||
|
|
|
||||||
|
|
@ -186,8 +186,8 @@ private:
|
||||||
// If we got ==1'bx it can never be true (but 1'bx==1'bx can be!)
|
// 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())
|
if (((VN_IS(lhsp, Const) && VN_CAST(lhsp, Const)->num().isFourState())
|
||||||
|| (VN_IS(rhsp, Const) && VN_CAST(rhsp, 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(), AstConst::WidthedValue(),
|
||||||
newp = new AstConst(nodep->fileline(), num);
|
1, (VN_IS(nodep, EqCase) ? 0 : 1));
|
||||||
lhsp->deleteTree(); VL_DANGLING(lhsp);
|
lhsp->deleteTree(); VL_DANGLING(lhsp);
|
||||||
rhsp->deleteTree(); VL_DANGLING(rhsp);
|
rhsp->deleteTree(); VL_DANGLING(rhsp);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -254,8 +254,7 @@ private:
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
// Ahh, we're two state, so this is easy
|
// Ahh, we're two state, so this is easy
|
||||||
UINFO(4," ISUNKNOWN->0 "<<nodep<<endl);
|
UINFO(4," ISUNKNOWN->0 "<<nodep<<endl);
|
||||||
V3Number zero (nodep, 1, 0);
|
AstConst* newp = new AstConst(nodep->fileline(), AstConst::LogicFalse());
|
||||||
AstConst* newp = new AstConst(nodep->fileline(), zero);
|
|
||||||
nodep->replaceWith(newp);
|
nodep->replaceWith(newp);
|
||||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||||
}
|
}
|
||||||
|
|
@ -336,11 +335,12 @@ private:
|
||||||
// Similar code in V3Const::warnSelect
|
// Similar code in V3Const::warnSelect
|
||||||
int maxmsb = nodep->fromp()->dtypep()->width()-1;
|
int maxmsb = nodep->fromp()->dtypep()->width()-1;
|
||||||
if (debug()>=9) nodep->dumpTree(cout, "sel_old: ");
|
if (debug()>=9) nodep->dumpTree(cout, "sel_old: ");
|
||||||
V3Number maxmsbnum (nodep, nodep->lsbp()->width(), maxmsb);
|
|
||||||
|
|
||||||
// If (maxmsb >= selected), we're in bound
|
// If (maxmsb >= selected), we're in bound
|
||||||
AstNode* condp = new AstGte(nodep->fileline(),
|
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));
|
nodep->lsbp()->cloneTree(false));
|
||||||
// See if the condition is constant true (e.g. always in bound due to constant select)
|
// 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.
|
// 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());
|
nodep->v3error("Select from non-array "<<dtypep->prettyTypeName());
|
||||||
}
|
}
|
||||||
if (debug()>=9) nodep->dumpTree(cout, "arraysel_old: ");
|
if (debug()>=9) nodep->dumpTree(cout, "arraysel_old: ");
|
||||||
V3Number widthnum (nodep, nodep->bitp()->width(), declElements-1);
|
|
||||||
|
|
||||||
// See if the condition is constant true
|
// See if the condition is constant true
|
||||||
AstNode* condp = new AstGte(nodep->fileline(),
|
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));
|
nodep->bitp()->cloneTree(false));
|
||||||
// Note below has null backp(); the Edit function knows how to deal with that.
|
// Note below has null backp(); the Edit function knows how to deal with that.
|
||||||
condp = V3Const::constifyEdit(condp);
|
condp = V3Const::constifyEdit(condp);
|
||||||
|
|
@ -437,7 +437,9 @@ private:
|
||||||
V3Number zeronum (nodep, bitp->width(), 0);
|
V3Number zeronum (nodep, bitp->width(), 0);
|
||||||
AstNode* newp = new AstCondBound(bitp->fileline(),
|
AstNode* newp = new AstCondBound(bitp->fileline(),
|
||||||
condp, bitp,
|
condp, bitp,
|
||||||
new AstConst(bitp->fileline(), zeronum));
|
new AstConst(bitp->fileline(),
|
||||||
|
AstConst::WidthedValue(),
|
||||||
|
bitp->width(), 0));
|
||||||
// Added X's, tristate them too
|
// Added X's, tristate them too
|
||||||
if (debug()>=9) newp->dumpTree(cout, " _new: ");
|
if (debug()>=9) newp->dumpTree(cout, " _new: ");
|
||||||
replaceHandle.relink(newp);
|
replaceHandle.relink(newp);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue