From b22e368b25c5afcb5985b84b6e3223decbf3e340 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sat, 23 Apr 2022 14:16:19 +0100 Subject: [PATCH] Add default parameters to some Ast nodes for convenience Also update usage to utilize. No functional change. --- src/V3Assert.cpp | 12 +++++------- src/V3AstNodes.h | 8 ++++---- src/V3Case.cpp | 5 ++--- src/V3Clock.cpp | 6 +++--- src/V3Delayed.cpp | 3 +-- src/V3Descope.cpp | 2 +- src/V3MergeCond.cpp | 2 +- src/V3Table.cpp | 2 +- src/V3Trace.cpp | 2 +- src/V3Unknown.cpp | 3 +-- src/V3Width.cpp | 40 +++++++++++++++++----------------------- src/verilog.y | 4 ++-- 12 files changed, 39 insertions(+), 50 deletions(-) diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index eaf8e3e71..dd58d3674 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -98,7 +98,7 @@ private: ? static_cast( new AstCMath(fl, "vlSymsp->_vm_contextp__->assertOn()", 1)) : static_cast(new AstConst(fl, AstConst::BitFalse())))), - nodep, nullptr); + nodep); newp->user1(true); // Don't assert/cover this if return newp; } @@ -154,7 +154,7 @@ private: } if (bodysp && passsp) bodysp = bodysp->addNext(passsp); - ifp = new AstIf(nodep->fileline(), propp, bodysp, nullptr); + ifp = new AstIf(nodep->fileline(), propp, bodysp); bodysp = ifp; } else if (VN_IS(nodep, Assert) || VN_IS(nodep, AssertIntrinsic)) { if (nodep->immediate()) { @@ -313,8 +313,7 @@ private: AstIf* const ifp = new AstIf( nodep->fileline(), new AstLogNot(nodep->fileline(), ohot), newFireAssert(nodep, - "synthesis parallel_case, but multiple matches found"), - nullptr); + "synthesis parallel_case, but multiple matches found")); ifp->branchPred(VBranchPred::BP_UNLIKELY); nodep->addNotParallelp(ifp); } @@ -384,7 +383,7 @@ private: new AstLogAnd{fl, new AstLogNot{fl, newMonitorOffVarRefp(nodep, VAccess::READ)}, new AstEq{fl, new AstConst{fl, monNum}, newMonitorNumVarRefp(nodep, VAccess::READ)}}, - stmtsp, nullptr}; + stmtsp}; ifp->branchPred(VBranchPred::BP_UNLIKELY); AstNode* const newp = new AstAlwaysPostponed{fl, ifp}; m_modp->addStmtp(newp); @@ -402,8 +401,7 @@ private: nodep->replaceWith(newsetp); // Add "always_comb if (__Vstrobe) begin $display(...); __Vstrobe = '0; end" AstNode* const stmtsp = nodep; - AstIf* const ifp - = new AstIf{fl, new AstVarRef{fl, varp, VAccess::READ}, stmtsp, nullptr}; + AstIf* const ifp = new AstIf{fl, new AstVarRef{fl, varp, VAccess::READ}, stmtsp}; ifp->branchPred(VBranchPred::BP_UNLIKELY); AstNode* const newp = new AstAlwaysPostponed{fl, ifp}; stmtsp->addNext(new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE}, diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index e1397b810..1c86aad29 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -1914,14 +1914,14 @@ private: bool m_pure = false; // Pure optimizable public: AstCMethodHard(FileLine* fl, AstNode* fromp, VFlagChildDType, const string& name, - AstNode* pinsp) + AstNode* pinsp = nullptr) : ASTGEN_SUPER_CMethodHard(fl, false) , m_name{name} { setOp1p(fromp); dtypep(nullptr); // V3Width will resolve addNOp2p(pinsp); } - AstCMethodHard(FileLine* fl, AstNode* fromp, const string& name, AstNode* pinsp) + AstCMethodHard(FileLine* fl, AstNode* fromp, const string& name, AstNode* pinsp = nullptr) : ASTGEN_SUPER_CMethodHard(fl, false) , m_name{name} { setOp1p(fromp); @@ -4610,7 +4610,7 @@ public: class AstWhile final : public AstNodeStmt { public: - AstWhile(FileLine* fl, AstNode* condp, AstNode* bodysp, AstNode* incsp = nullptr) + AstWhile(FileLine* fl, AstNode* condp, AstNode* bodysp = nullptr, AstNode* incsp = nullptr) : ASTGEN_SUPER_While(fl) { setOp2p(condp); addNOp3p(bodysp); @@ -4714,7 +4714,7 @@ private: bool m_unique0Pragma; // unique0 case bool m_priorityPragma; // priority case public: - AstIf(FileLine* fl, AstNode* condp, AstNode* ifsp, AstNode* elsesp = nullptr) + AstIf(FileLine* fl, AstNode* condp, AstNode* ifsp = nullptr, AstNode* elsesp = nullptr) : ASTGEN_SUPER_If(fl, condp, ifsp, elsesp) { m_uniquePragma = false; m_unique0Pragma = false; diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 403b785b0..161f7db7e 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -427,8 +427,7 @@ private: if (++depth > CASE_ENCODER_GROUP_DEPTH) depth = 1; if (depth == 1) { // First group or starting new group itemnextp = nullptr; - AstIf* const newp - = new AstIf(itemp->fileline(), ifexprp->cloneTree(true), nullptr, nullptr); + AstIf* const newp = new AstIf(itemp->fileline(), ifexprp->cloneTree(true)); if (groupnextp) { groupnextp->addElsesp(newp); } else { @@ -448,7 +447,7 @@ private: VL_DO_DANGLING(itemexprp->deleteTree(), itemexprp); itemexprp = new AstConst(itemp->fileline(), AstConst::BitTrue()); } - AstIf* const newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, nullptr); + AstIf* const newp = new AstIf(itemp->fileline(), itemexprp, istmtsp); if (itemnextp) { itemnextp->addElsesp(newp); } else { diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index a9072fe29..a8b8f7006 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -185,7 +185,7 @@ private: AstIf* makeActiveIf(AstSenTree* sensesp) { AstNode* const senEqnp = createSenseEquation(sensesp->sensesp()); UASSERT_OBJ(senEqnp, sensesp, "No sense equation, shouldn't be in sequent activation."); - AstIf* const newifp = new AstIf(sensesp->fileline(), senEqnp, nullptr, nullptr); + AstIf* const newifp = new AstIf(sensesp->fileline(), senEqnp); return newifp; } void clearLastSen() { @@ -310,8 +310,8 @@ private: AstNode* const origp = nodep->origp()->unlinkFrBack(); AstNode* const changeWrp = nodep->changep()->unlinkFrBack(); AstNode* const changeRdp = ConvertWriteRefsToRead::main(changeWrp->cloneTree(false)); - AstIf* const newp = new AstIf( - nodep->fileline(), new AstXor(nodep->fileline(), origp, changeRdp), incp, nullptr); + AstIf* const newp + = new AstIf(nodep->fileline(), new AstXor(nodep->fileline(), origp, changeRdp), incp); // We could add another IF to detect posedges, and only increment if so. // It's another whole branch though versus a potential memory miss. // We'll go with the miss. diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index f16223128..57fe02833 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -351,8 +351,7 @@ private: "Delayed assignment misoptimized; prev var found w/o associated IF"); } else { postLogicp = new AstIf(nodep->fileline(), - new AstVarRef(nodep->fileline(), setvscp, VAccess::READ), - nullptr, nullptr); + new AstVarRef(nodep->fileline(), setvscp, VAccess::READ)); UINFO(9, " Created " << postLogicp << endl); finalp->addStmtp(postLogicp); finalp->user3p(setvscp); // Remember IF's vset variable diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 3d13cdb8e..9e6aea78f 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -161,7 +161,7 @@ private: new AstCMath(funcp->fileline(), string("&(") + funcp->scopep()->nameVlSym() + ")", 64)), - returnp, nullptr); + returnp); newfuncp->addStmtsp(ifp); } else { newfuncp->addStmtsp(returnp); diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 767d7a30f..77b2ea935 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -266,7 +266,7 @@ private: // and we also need to keep track of it for comparisons later. m_mgCondp = m_mgCondp->cloneTree(false); // Create equivalent 'if' statement and insert it before the first node - AstIf* const resultp = new AstIf(m_mgCondp->fileline(), m_mgCondp, nullptr, nullptr); + AstIf* const resultp = new AstIf(m_mgCondp->fileline(), m_mgCondp); m_mgFirstp->addHereThisAsNext(resultp); // Unzip the list and insert under branches AstNode* nextp = m_mgFirstp; diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 3233e39fe..822407b4c 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -367,7 +367,7 @@ private: AstNode* const condp = new AstAnd(fl, select(fl, outputAssignedTableVscp, indexVscp), new AstConst(fl, outputChgMask)); - outsetp = new AstIf(fl, condp, outsetp, nullptr); + outsetp = new AstIf(fl, condp, outsetp); } stmtsp->addNext(outsetp); diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 82d688252..cffd498f4 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -656,7 +656,7 @@ private: condp = condp ? new AstOr(flp, condp, selp) : selp; } } - ifp = new AstIf(flp, condp, nullptr, nullptr); + ifp = new AstIf(flp, condp); if (!always) ifp->branchPred(VBranchPred::BP_UNLIKELY); subFuncp->addStmtsp(ifp); subStmts += ifp->nodeCount(); diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index d71317e58..0df1ff3a6 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -127,8 +127,7 @@ private: (needDly ? static_cast( new AstAssignDly(fl, prep, new AstVarRef(fl, varp, VAccess::READ))) : static_cast( - new AstAssign(fl, prep, new AstVarRef(fl, varp, VAccess::READ)))), - nullptr); + new AstAssign(fl, prep, new AstVarRef(fl, varp, VAccess::READ))))); newp->branchPred(VBranchPred::BP_LIKELY); newp->isBoundsCheck(true); if (debug() >= 9) newp->dumpTree(cout, " _new: "); diff --git a/src/V3Width.cpp b/src/V3Width.cpp index e968decd3..f4c350d6e 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1366,7 +1366,7 @@ private: switch (nodep->attrType()) { case VAttrType::DIM_SIZE: { AstNode* const newp = new AstCMethodHard( - nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", nullptr); + nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size"); newp->dtypeSetSigned32(); newp->didWidth(true); newp->protect(false); @@ -1384,7 +1384,7 @@ private: case VAttrType::DIM_RIGHT: case VAttrType::DIM_HIGH: { AstNode* const sizep = new AstCMethodHard( - nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", nullptr); + nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size"); sizep->dtypeSetSigned32(); sizep->didWidth(true); sizep->protect(false); @@ -2676,8 +2676,8 @@ private: if (nodep->name() == "num" // function int num() || nodep->name() == "size") { methodOkArguments(nodep, 0, 0); - newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", - nullptr); // So don't need num() + newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), + "size"); // So don't need num() newp->dtypeSetSigned32(); } else if (nodep->name() == "first" // function int first(ref index) || nodep->name() == "last" // @@ -2703,7 +2703,7 @@ private: methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); if (!nodep->pinsp()) { newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - "clear", nullptr); + "clear"); newp->makeStatement(); } else { AstNode* const index_exprp = methodCallAssocIndexExpr(nodep, adtypep); @@ -2731,7 +2731,7 @@ private: methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - nodep->name(), nullptr); + nodep->name()); if (nodep->name() == "unique_index") { newp->dtypep(queueDTypeIndexedBy(adtypep->keyDTypep())); } else { @@ -2794,19 +2794,16 @@ private: if (nodep->name() == "at") { // Created internally for [] methodOkArguments(nodep, 1, 1); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); - newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at", - nullptr); + newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at"); newp->dtypeFrom(adtypep->subDTypep()); } else if (nodep->name() == "size") { methodOkArguments(nodep, 0, 0); - newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", - nullptr); + newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size"); newp->dtypeSetSigned32(); } else if (nodep->name() == "delete") { // function void delete() methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); - newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "clear", - nullptr); + newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "clear"); newp->makeStatement(); } else if (nodep->name() == "and" || nodep->name() == "or" || nodep->name() == "xor" || nodep->name() == "sum" || nodep->name() == "product") { @@ -2837,7 +2834,7 @@ private: methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - nodep->name(), nullptr); + nodep->name()); if (nodep->name() == "unique_index") { newp->dtypep(newp->findQueueIndexDType()); } else { @@ -2883,27 +2880,25 @@ private: if (nodep->name() == "at") { // Created internally for [] methodOkArguments(nodep, 1, 1); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); - newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at", - nullptr); + newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at"); newp->dtypeFrom(adtypep->subDTypep()); } else if (nodep->name() == "num" // function int num() || nodep->name() == "size") { methodOkArguments(nodep, 0, 0); - newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", - nullptr); + newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size"); newp->dtypeSetSigned32(); } else if (nodep->name() == "delete") { // function void delete([input integer index]) methodOkArguments(nodep, 0, 1); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); if (!nodep->pinsp()) { newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - "clear", nullptr); + "clear"); newp->makeStatement(); } else { AstNode* const index_exprp = methodCallQueueIndexExpr(nodep); if (index_exprp->isZero()) { // delete(0) is a pop_front newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - "pop_front", nullptr); + "pop_front"); newp->dtypeFrom(adtypep->subDTypep()); newp->makeStatement(); } else { @@ -2933,7 +2928,7 @@ private: // Returns element, so method both consumes (reads) and modifies the queue methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READWRITE); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - nodep->name(), nullptr); + nodep->name()); newp->dtypeFrom(adtypep->subDTypep()); if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "push_back" || nodep->name() == "push_front") { @@ -2972,7 +2967,7 @@ private: methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - nodep->name(), nullptr); + nodep->name()); if (nodep->name() == "unique_index") { newp->dtypep(newp->findQueueIndexDType()); } else { @@ -3850,8 +3845,7 @@ private: } else if (VN_IS(fromDtp, DynArrayDType) || VN_IS(fromDtp, QueueDType)) { if (varp) { auto* const leftp = new AstConst{fl, AstConst::Signed32{}, 0}; - auto* const sizep - = new AstCMethodHard{fl, fromp->cloneTree(false), "size", nullptr}; + auto* const sizep = new AstCMethodHard{fl, fromp->cloneTree(false), "size"}; sizep->dtypeSetSigned32(); sizep->didWidth(true); sizep->protect(false); diff --git a/src/verilog.y b/src/verilog.y index a7230452e..7c660fc62 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3111,7 +3111,7 @@ statement_item: // IEEE: statement_item // // // IEEE: conditional_statement | unique_priorityE yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE - { AstIf* const newp = new AstIf{$2, $4, $6, nullptr}; + { AstIf* const newp = new AstIf{$2, $4, $6}; $$ = newp; if ($1 == uniq_UNIQUE) newp->uniquePragma(true); if ($1 == uniq_UNIQUE0) newp->unique0Pragma(true); @@ -3180,7 +3180,7 @@ statement_item: // IEEE: statement_item $$ = $2->cloneTree(true); $$->addNext(new AstWhile($1,$5,$2)); } - else $$ = new AstWhile($1,$5,nullptr); } + else $$ = new AstWhile($1,$5); } // // IEEE says array_identifier here, but dotted accepted in VMM and 1800-2009 | yFOREACH '(' idClassSelForeach ')' stmtBlock { $$ = new AstForeach($1, $3, $5); } //