From c0be8bcefb1605cbef1a15ea34556bfeb7e25168 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 29 May 2019 23:18:47 -0400 Subject: [PATCH] Internals: Remove some pointless V3Number temporaries. No functional change intended. --- src/V3CCtors.cpp | 4 ++-- src/V3Delayed.cpp | 3 +-- src/V3Expand.cpp | 9 +++++---- src/V3LinkJump.cpp | 3 +-- src/V3Param.cpp | 3 ++- src/V3Premit.cpp | 8 ++++---- src/V3Table.cpp | 2 +- src/V3Tristate.cpp | 8 ++++---- src/V3Unknown.cpp | 20 +++++++++++--------- 9 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index ac86f06cc..9cc44741b 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -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()+"\");")); diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 52829304c..2bfd5c66d 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -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 diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index d98afbde0..c9566a7da 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -223,8 +223,9 @@ private: rhsp->v3error("Unsupported: 4-state numbers in this context"); } for (int w=0; wwidthWords(); 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 "<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); } diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index a63067b78..8436f646b 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -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); diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 61633dc1a..e14b22176 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -599,7 +599,8 @@ void ParamVisitor::visitCell(AstCell* nodep) { pinp->v3error("Can't convert defparam value to constant: Param " <name()<<" of "<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 diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index bbc884e22..33c91910c 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -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(), diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 3ed436ded..210939638 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -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 "<name()<<" = "<<*outnump<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 "<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 diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 1edb50510..f261cb7b2 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -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 "<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 "<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);