diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 1537a14ee..d2cf2e666 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -176,10 +176,10 @@ private: if (neverItem(nodep, iconstp)) { // X in casez can't ever be executed } else { - V3Number nummask(itemp, iconstp->width()); + V3Number nummask{itemp, iconstp->width()}; nummask.opBitsNonX(iconstp->num()); const uint32_t mask = nummask.toUInt(); - V3Number numval(itemp, iconstp->width()); + V3Number numval{itemp, iconstp->width()}; numval.opBitsOne(iconstp->num()); const uint32_t val = numval.toUInt(); @@ -291,10 +291,10 @@ private: // AstNode* and1p = new AstAnd(cexprp->fileline(), cexprp->cloneTree(false), // new AstConst(cexprp->fileline(), nummask)); AstNodeExpr* const and1p - = new AstSel(cexprp->fileline(), cexprp->cloneTree(false), msb, 1); + = new AstSel{cexprp->fileline(), cexprp->cloneTree(false), msb, 1}; AstNodeExpr* const eqp - = new AstNeq(cexprp->fileline(), new AstConst(cexprp->fileline(), 0), and1p); - AstIf* const ifp = new AstIf(cexprp->fileline(), eqp, tree1p, tree0p); + = new AstNeq{cexprp->fileline(), new AstConst{cexprp->fileline(), 0}, and1p}; + AstIf* const ifp = new AstIf{cexprp->fileline(), eqp, tree1p, tree0p}; ifp->user3(1); // So we don't bother to clone it return ifp; } @@ -346,7 +346,7 @@ private: itemp = VN_AS(itemp->nextp(), CaseItem)) { if (!itemp->condsp()) { // Default clause. Just make true, we'll optimize it away later - itemp->addCondsp(new AstConst(itemp->fileline(), AstConst::BitTrue())); + itemp->addCondsp(new AstConst{itemp->fileline(), AstConst::BitTrue{}}); hadDefault = true; } else { // Expressioned clause @@ -364,23 +364,23 @@ private: VL_DANGLING(iconstp); // For simplicity, make expression that is not equal, and let later // optimizations remove it - condp = new AstConst(itemp->fileline(), AstConst::BitFalse()); + condp = new AstConst{itemp->fileline(), AstConst::BitFalse{}}; } else if (AstInsideRange* const irangep = VN_CAST(icondp, InsideRange)) { // Similar logic in V3Width::visit(AstInside) condp = irangep->newAndFromInside(cexprp, irangep->lhsp()->unlinkFrBack(), irangep->rhsp()->unlinkFrBack()); } else if (iconstp && iconstp->num().isFourState() && (nodep->casex() || nodep->casez() || nodep->caseInside())) { - V3Number nummask(itemp, iconstp->width()); + V3Number nummask{itemp, iconstp->width()}; nummask.opBitsNonX(iconstp->num()); - V3Number numval(itemp, iconstp->width()); + V3Number numval{itemp, iconstp->width()}; numval.opBitsOne(iconstp->num()); AstNodeExpr* const and1p - = new AstAnd(itemp->fileline(), cexprp->cloneTree(false), - new AstConst(itemp->fileline(), nummask)); - AstNodeExpr* const and2p = new AstAnd( - itemp->fileline(), new AstConst(itemp->fileline(), numval), - new AstConst(itemp->fileline(), nummask)); + = new AstAnd{itemp->fileline(), cexprp->cloneTree(false), + new AstConst{itemp->fileline(), nummask}}; + AstNodeExpr* const and2p = new AstAnd{ + itemp->fileline(), new AstConst{itemp->fileline(), numval}, + new AstConst{itemp->fileline(), nummask}}; VL_DO_DANGLING(icondp->deleteTree(), icondp); VL_DANGLING(iconstp); condp = AstEq::newTyped(itemp->fileline(), and1p, and2p); @@ -393,7 +393,7 @@ private: if (!ifexprp) { ifexprp = condp; } else { - ifexprp = new AstLogOr(itemp->fileline(), ifexprp, condp); + ifexprp = new AstLogOr{itemp->fileline(), ifexprp, condp}; } } // Replace expression in tree @@ -404,8 +404,8 @@ private: if (!hadDefault) { // If there was no default, add a empty one, this greatly simplifies below code // and constant propagation will just eliminate it for us later. - nodep->addItemsp(new AstCaseItem( - nodep->fileline(), new AstConst(nodep->fileline(), AstConst::BitTrue()), nullptr)); + nodep->addItemsp(new AstCaseItem{ + nodep->fileline(), new AstConst{nodep->fileline(), AstConst::BitTrue{}}, nullptr}); } if (debug() >= 9) nodep->dumpTree(cout, " _comp_COND: "); // Now build the IF statement tree @@ -428,7 +428,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)); + AstIf* const newp = new AstIf{itemp->fileline(), ifexprp->cloneTree(true)}; if (groupnextp) { groupnextp->addElsesp(newp); } else { @@ -438,7 +438,7 @@ private: } else { // Continue group, modify if condition to OR in this new condition AstNodeExpr* const condp = groupnextp->condp()->unlinkFrBack(); groupnextp->condp( - new AstOr(ifexprp->fileline(), condp, ifexprp->cloneTree(true))); + new AstOr{ifexprp->fileline(), condp, ifexprp->cloneTree(true)}); } } { // Make the new lower IF and attach in the tree @@ -446,9 +446,9 @@ private: VL_DANGLING(ifexprp); if (depth == CASE_ENCODER_GROUP_DEPTH) { // End of group - can skip the condition VL_DO_DANGLING(itemexprp->deleteTree(), itemexprp); - itemexprp = new AstConst(itemp->fileline(), AstConst::BitTrue()); + itemexprp = new AstConst{itemp->fileline(), AstConst::BitTrue{}}; } - AstIf* const newp = new AstIf(itemp->fileline(), itemexprp, istmtsp); + AstIf* const newp = new AstIf{itemp->fileline(), itemexprp, istmtsp}; if (itemnextp) { itemnextp->addElsesp(newp); } else { diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 6418f7f20..ee78c41c5 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -156,28 +156,28 @@ private: varp = it->second; } else { if (newdtypep) { - varp = new AstVar(oldvarscp->fileline(), VVarType::BLOCKTEMP, name, newdtypep); + varp = new AstVar{oldvarscp->fileline(), VVarType::BLOCKTEMP, name, newdtypep}; } else if (width == 0) { - varp = new AstVar(oldvarscp->fileline(), VVarType::BLOCKTEMP, name, - oldvarscp->varp()); + varp = new AstVar{oldvarscp->fileline(), VVarType::BLOCKTEMP, name, + oldvarscp->varp()}; varp->dtypeFrom(oldvarscp); } else { // Used for vset and dimensions, so can zero init - varp = new AstVar(oldvarscp->fileline(), VVarType::BLOCKTEMP, name, - VFlagBitPacked(), width); + varp = new AstVar{oldvarscp->fileline(), VVarType::BLOCKTEMP, name, + VFlagBitPacked{}, width}; } addmodp->addStmtsp(varp); m_modVarMap.emplace(std::make_pair(addmodp, name), varp); } AstVarScope* const varscp - = new AstVarScope(oldvarscp->fileline(), oldvarscp->scopep(), varp); + = new AstVarScope{oldvarscp->fileline(), oldvarscp->scopep(), varp}; oldvarscp->scopep()->addVarsp(varscp); return varscp; } AstActive* createActive(AstNode* varrefp) { AstActive* const newactp - = new AstActive(varrefp->fileline(), "sequentdly", m_activep->sensesp()); + = new AstActive{varrefp->fileline(), "sequentdly", m_activep->sensesp()}; // Was addNext(), but addNextHere() avoids a linear search. m_activep->addNextHere(newactp); return newactp; @@ -204,7 +204,7 @@ private: // Make a new sensitivity list, which is the combination of both blocks AstSenItem* const sena = m_activep->sensesp()->sensesp()->cloneTree(true); AstSenItem* const senb = oldactivep->sensesp()->sensesp()->cloneTree(true); - AstSenTree* const treep = new AstSenTree(m_activep->fileline(), sena); + AstSenTree* const treep = new AstSenTree{m_activep->fileline(), sena}; if (senb) treep->addSensesp(senb); if (AstSenTree* const storep = oldactivep->sensesStorep()) { storep->unlinkFrBack(); @@ -265,11 +265,11 @@ private: + oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); AstVarScope* const bitvscp = createVarSc(varrefp->varScopep(), bitvarname, dimp->width(), nullptr); - AstAssign* const bitassignp = new AstAssign( - nodep->fileline(), new AstVarRef(nodep->fileline(), bitvscp, VAccess::WRITE), - dimp); + AstAssign* const bitassignp = new AstAssign{ + nodep->fileline(), new AstVarRef{nodep->fileline(), bitvscp, VAccess::WRITE}, + dimp}; nodep->addNextHere(bitassignp); - dimreadps.push_front(new AstVarRef(nodep->fileline(), bitvscp, VAccess::READ)); + dimreadps.push_front(new AstVarRef{nodep->fileline(), bitvscp, VAccess::READ}); } } // @@ -285,11 +285,11 @@ private: + cvtToStr(modVecNum)); AstVarScope* const bitvscp = createVarSc(varrefp->varScopep(), bitvarname, lsbvaluep->width(), nullptr); - AstAssign* const bitassignp = new AstAssign( - nodep->fileline(), new AstVarRef(nodep->fileline(), bitvscp, VAccess::WRITE), - lsbvaluep); + AstAssign* const bitassignp = new AstAssign{ + nodep->fileline(), new AstVarRef{nodep->fileline(), bitvscp, VAccess::WRITE}, + lsbvaluep}; nodep->addNextHere(bitassignp); - bitreadp = new AstVarRef(nodep->fileline(), bitvscp, VAccess::READ); + bitreadp = new AstVarRef{nodep->fileline(), bitvscp, VAccess::READ}; } } // @@ -303,8 +303,8 @@ private: = (string("__Vdlyvval__") + oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); AstVarScope* const valvscp = createVarSc(varrefp->varScopep(), valvarname, 0, nodep->rhsp()->dtypep()); - newlhsp = new AstVarRef(nodep->fileline(), valvscp, VAccess::WRITE); - valreadp = new AstVarRef(nodep->fileline(), valvscp, VAccess::READ); + newlhsp = new AstVarRef{nodep->fileline(), valvscp, VAccess::WRITE}; + valreadp = new AstVarRef{nodep->fileline(), valvscp, VAccess::READ}; } // //=== Setting/not setting boolean: __Vdlyvset__ @@ -328,9 +328,9 @@ private: nodep->fileline(), new AstVarRef{nodep->fileline(), setvscp, VAccess::WRITE}, new AstConst{nodep->fileline(), 0}}; } - AstAssign* const setassignp = new AstAssign( - nodep->fileline(), new AstVarRef(nodep->fileline(), setvscp, VAccess::WRITE), - new AstConst(nodep->fileline(), AstConst::BitTrue())); + AstAssign* const setassignp = new AstAssign{ + nodep->fileline(), new AstVarRef{nodep->fileline(), setvscp, VAccess::WRITE}, + new AstConst{nodep->fileline(), AstConst::BitTrue{}}}; nodep->addNextHere(setassignp); } if (m_nextDlyp) { // Tell next assigndly it can share the variable @@ -344,11 +344,11 @@ private: // It also has the nice side effect of assisting cache locality. AstNodeExpr* selectsp = varrefp; for (int dimension = int(dimreadps.size()) - 1; dimension >= 0; --dimension) { - selectsp = new AstArraySel(nodep->fileline(), selectsp, dimreadps[dimension]); + selectsp = new AstArraySel{nodep->fileline(), selectsp, dimreadps[dimension]}; } if (bitselp) { - selectsp = new AstSel(nodep->fileline(), selectsp, bitreadp, - bitselp->widthp()->cloneTree(false)); + selectsp = new AstSel{nodep->fileline(), selectsp, bitreadp, + bitselp->widthp()->cloneTree(false)}; } // Build "IF (changeit) ... UINFO(9, " For " << setvscp << endl); @@ -392,14 +392,14 @@ private: UASSERT_OBJ(postLogicp, nodep, "Delayed assignment misoptimized; prev var found w/o associated IF"); } else { - postLogicp = new AstIf(nodep->fileline(), - new AstVarRef(nodep->fileline(), setvscp, VAccess::READ)); + postLogicp = new AstIf{nodep->fileline(), + new AstVarRef{nodep->fileline(), setvscp, VAccess::READ}}; UINFO(9, " Created " << postLogicp << endl); finalp->addStmtsp(postLogicp); finalp->user3p(setvscp); // Remember IF's vset variable finalp->user4p(postLogicp); // and the associated IF, as we may be able to reuse it } - postLogicp->addThensp(new AstAssign(nodep->fileline(), selectsp, valreadp)); + postLogicp->addThensp(new AstAssign{nodep->fileline(), selectsp, valreadp}); if (m_procp->isSuspendable()) { FileLine* const flp = nodep->fileline(); postLogicp->addThensp(new AstAssign{flp, new AstVarRef{flp, setvscp, VAccess::WRITE}, @@ -579,7 +579,7 @@ private: newactp->addStmtsp(postp); } AstVarRef* const newrefp - = new AstVarRef(nodep->fileline(), dlyvscp, VAccess::WRITE); + = new AstVarRef{nodep->fileline(), dlyvscp, VAccess::WRITE}; newrefp->user2(true); // No reason to do it again nodep->replaceWith(newrefp); VL_DO_DANGLING(pushDeletep(nodep), nodep); diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 628465602..618c6ed3b 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -349,7 +349,7 @@ private: if (m_scopep) { UINFO(5, " STMT " << nodep << endl); // m_activep is null under AstCFunc's, that's ok. - m_logicVertexp = new GateLogicVertex(&m_graph, m_scopep, nodep, m_activep, m_inSlow); + m_logicVertexp = new GateLogicVertex{&m_graph, m_scopep, nodep, m_activep, m_inSlow}; if (nonReducibleReason) { m_logicVertexp->clearReducibleAndDedupable(nonReducibleReason); } else if (!m_activeReducible) { @@ -368,7 +368,7 @@ private: GateVarVertex* vertexp = reinterpret_cast(varscp->user1p()); if (!vertexp) { UINFO(6, "New vertex " << varscp << endl); - vertexp = new GateVarVertex(&m_graph, m_scopep, varscp); + vertexp = new GateVarVertex{&m_graph, m_scopep, varscp}; varscp->user1p(vertexp); if (varscp->varp()->isSigPublic()) { // Public signals shouldn't be changed, pli code might be messing with them @@ -493,10 +493,10 @@ private: // We use weight of one; if we ref the var more than once, when we simplify, // the weight will increase if (nodep->access().isWriteOrRW()) { - new V3GraphEdge(&m_graph, m_logicVertexp, vvertexp, 1); + new V3GraphEdge{&m_graph, m_logicVertexp, vvertexp, 1}; } if (nodep->access().isReadOrRW()) { - new V3GraphEdge(&m_graph, vvertexp, m_logicVertexp, 1); + new V3GraphEdge{&m_graph, vvertexp, m_logicVertexp, 1}; } } } @@ -638,7 +638,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { for (AstNodeVarRef* const refp : rhsVarRefs) { AstVarScope* const newvarscp = refp->varScopep(); GateVarVertex* const varvertexp = makeVarVertex(newvarscp); - new V3GraphEdge(&m_graph, varvertexp, consumeVertexp, 1); + new V3GraphEdge{&m_graph, varvertexp, consumeVertexp, 1}; // Propagate clock attribute onto generating node varvertexp->propagateAttrClocksFrom(vvertexp); } @@ -1177,8 +1177,8 @@ private: const AstConst* const cwidth = VN_CAST(cur->widthp(), Const); if (!pstart || !pwidth || !cstart || !cwidth) return nullptr; // too complicated if (cur->lsbConst() + cur->widthConst() == pre->lsbConst()) { - return new AstSel(curVarRefp->fileline(), curVarRefp->cloneTree(false), - cur->lsbConst(), pre->widthConst() + cur->widthConst()); + return new AstSel{curVarRefp->fileline(), curVarRefp->cloneTree(false), + cur->lsbConst(), pre->widthConst() + cur->widthConst()}; } else { return nullptr; } @@ -1218,9 +1218,9 @@ private: preselp->replaceWith(newselp); VL_DO_DANGLING(preselp->deleteTree(), preselp); // create new rhs for pre assignment - AstNode* const newrhsp = new AstConcat( + AstNode* const newrhsp = new AstConcat{ m_assignp->rhsp()->fileline(), m_assignp->rhsp()->cloneTree(false), - assignp->rhsp()->cloneTree(false)); + assignp->rhsp()->cloneTree(false)}; AstNode* const oldrhsp = m_assignp->rhsp(); oldrhsp->replaceWith(newrhsp); VL_DO_DANGLING(oldrhsp->deleteTree(), oldrhsp); @@ -1240,7 +1240,7 @@ private: ledgep = ledgep->inNextp(); GateEitherVertex* const fromvp = static_cast(oedgep->fromp()); - new V3GraphEdge(m_graphp, fromvp, m_logicvp, 1); + new V3GraphEdge{m_graphp, fromvp, m_logicvp, 1}; VL_DO_DANGLING(oedgep->unlinkDelete(), oedgep); } } @@ -1369,7 +1369,7 @@ private: m_total_seen_clk_vectors++; } const GateClkDecompState* const currState = reinterpret_cast(vu.c()); - GateClkDecompState nextState(currState->m_offset, vsp); + GateClkDecompState nextState{currState->m_offset, vsp}; vvertexp->iterateCurrentOutEdges(*this, VNUser{&nextState}); if (vsp->varp()->width() > 1) --m_seen_clk_vectors; vsp->user2(false); @@ -1424,17 +1424,17 @@ private: UINFO(9, "CLK DECOMP Connecting - " << assignp->lhsp() << endl); UINFO(9, " to - " << m_clk_vsp << endl); AstNode* const rhsp = assignp->rhsp(); - rhsp->replaceWith(new AstVarRef(rhsp->fileline(), m_clk_vsp, VAccess::READ)); + rhsp->replaceWith(new AstVarRef{rhsp->fileline(), m_clk_vsp, VAccess::READ}); while (V3GraphEdge* const edgep = lvertexp->inBeginp()) { VL_DO_DANGLING(edgep->unlinkDelete(), edgep); } - new V3GraphEdge(m_graphp, m_clk_vvertexp, lvertexp, 1); + new V3GraphEdge{m_graphp, m_clk_vvertexp, lvertexp, 1}; m_total_decomposed_clk_vectors++; } } else { return VNUser{0}; } - GateClkDecompState nextState(clk_offset, currState->m_last_vsp); + GateClkDecompState nextState{clk_offset, currState->m_last_vsp}; return lvertexp->iterateCurrentOutEdges(*this, VNUser{&nextState}); } return VNUser{0}; @@ -1453,7 +1453,7 @@ public: m_seen_clk_vectors = 0; m_clk_vsp = vvertexp->varScp(); m_clk_vvertexp = vvertexp; - GateClkDecompState nextState(0, m_clk_vsp); + GateClkDecompState nextState{0, m_clk_vsp}; vvertexp->accept(*this, VNUser{&nextState}); } }; diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 47ca87e48..11ceaec21 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -76,18 +76,18 @@ private: if (nodep->modVarp()->isInoutish()) { nodep->v3fatalSrc("Unsupported: Verilator is a 2-state simulator"); } else if (nodep->modVarp()->isWritable()) { - AstNodeExpr* const rhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(), - m_cellp->name(), VAccess::READ); - AstAssignW* const assp = new AstAssignW(exprp->fileline(), exprp, rhsp); + AstNodeExpr* const rhsp = new AstVarXRef{exprp->fileline(), nodep->modVarp(), + m_cellp->name(), VAccess::READ}; + AstAssignW* const assp = new AstAssignW{exprp->fileline(), exprp, rhsp}; m_cellp->addNextHere(assp); } else if (nodep->modVarp()->isNonOutput()) { // Don't bother moving constants now, // we'll be pushing the const down to the cell soon enough. AstNode* const assp - = new AstAssignW(exprp->fileline(), - new AstVarXRef(exprp->fileline(), nodep->modVarp(), - m_cellp->name(), VAccess::WRITE), - exprp); + = new AstAssignW{exprp->fileline(), + new AstVarXRef{exprp->fileline(), nodep->modVarp(), + m_cellp->name(), VAccess::WRITE}, + exprp}; m_cellp->addNextHere(assp); if (debug() >= 9) assp->dumpTree(cout, " _new: "); } else if (nodep->modVarp()->isIfaceRef() @@ -97,14 +97,14 @@ private: IfaceRefDType))) { // Create an AstAssignVarScope for Vars to Cells so we can // link with their scope later - AstNodeExpr* const lhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(), - m_cellp->name(), VAccess::READ); + AstNodeExpr* const lhsp = new AstVarXRef{exprp->fileline(), nodep->modVarp(), + m_cellp->name(), VAccess::READ}; const AstVarRef* const refp = VN_CAST(exprp, VarRef); const AstVarXRef* const xrefp = VN_CAST(exprp, VarXRef); UASSERT_OBJ(refp || xrefp, exprp, "Interfaces: Pin is not connected to a VarRef or VarXRef"); AstAssignVarScope* const assp - = new AstAssignVarScope(exprp->fileline(), lhsp, exprp); + = new AstAssignVarScope{exprp->fileline(), lhsp, exprp}; m_cellp->addNextHere(assp); } else { nodep->v3error("Assigned pin is neither input nor output"); @@ -335,7 +335,7 @@ private: ? (rangep->elementsConst() - 1 - m_instSelNum) : m_instSelNum; AstNodeExpr* exprp = VN_AS(nodep->exprp(), NodeExpr)->unlinkFrBack(); - exprp = new AstArraySel(exprp->fileline(), exprp, arraySelNum); + exprp = new AstArraySel{exprp->fileline(), exprp, arraySelNum}; nodep->exprp(exprp); } else if (expwidth == modwidth) { // NOP: Arrayed instants: widths match so connect to each instance @@ -358,7 +358,7 @@ private: "with output connections to non-wires."); // Note spec allows more complicated matches such as slices and such } - exprp = new AstSel(exprp->fileline(), exprp, modwidth * m_instSelNum, modwidth); + exprp = new AstSel{exprp->fileline(), exprp, modwidth * m_instSelNum, modwidth}; nodep->exprp(exprp); } else { nodep->v3fatalSrc("Width mismatch; V3Width should have errored out."); @@ -382,9 +382,9 @@ private: arrselp->lhsp()->v3error("Unsupported: interface slices"); const AstVarRef* const varrefp = VN_CAST(arrselp->lhsp(), VarRef); UASSERT_OBJ(varrefp, arrselp, "No interface varref under array"); - AstVarXRef* const newp = new AstVarXRef( + AstVarXRef* const newp = new AstVarXRef{ nodep->fileline(), varrefp->name() + "__BRA__" + index + "__KET__", "", - VAccess::WRITE); + VAccess::WRITE}; newp->dtypep(nodep->modVarp()->dtypep()); newp->classOrPackagep(varrefp->classOrPackagep()); arrselp->addNextHere(newp); @@ -453,7 +453,7 @@ private: const string newname = varrefp->name() + "__BRA__" + cvtToStr(expr_i) + "__KET__"; AstVarXRef* const newVarXRefp - = new AstVarXRef(nodep->fileline(), newname, "", VAccess::WRITE); + = new AstVarXRef{nodep->fileline(), newname, "", VAccess::WRITE}; newVarXRefp->varp(newp->modVarp()); newp->exprp()->unlinkFrBack()->deleteTree(); newp->exprp(newVarXRefp); @@ -517,10 +517,10 @@ public: // otherwise done if (pinVarp->direction() == VDirection::INPUT && cellp->modp()->unconnectedDrive().isSetTrue()) { - pinp->exprp(new AstConst(pinp->fileline(), AstConst::StringToParse(), "'1")); + pinp->exprp(new AstConst{pinp->fileline(), AstConst::StringToParse{}, "'1"}); } else if (pinVarp->direction() == VDirection::INPUT && cellp->modp()->unconnectedDrive().isSetFalse()) { - pinp->exprp(new AstConst(pinp->fileline(), AstConst::StringToParse(), "'0")); + pinp->exprp(new AstConst{pinp->fileline(), AstConst::StringToParse{}, "'0"}); } else { return nullptr; } @@ -559,7 +559,7 @@ public: // Prevent name conflict if both tri & non-tri add signals + (forTristate ? "t" : "") + "__" + cellp->name() + "__" + pinp->name()); AstVar* const newvarp - = new AstVar(pinVarp->fileline(), VVarType::MODULETEMP, newvarname, pinVarp); + = new AstVar{pinVarp->fileline(), VVarType::MODULETEMP, newvarname, pinVarp}; // Important to add statement next to cell, in case there is a // generate with same named cell cellp->addNextHere(newvarp); @@ -568,19 +568,19 @@ public: " direct one-to-one connection (without any expression)"); } else if (pinVarp->isWritable()) { // See also V3Inst - AstNodeExpr* rhsp = new AstVarRef(pinp->fileline(), newvarp, VAccess::READ); + AstNodeExpr* rhsp = new AstVarRef{pinp->fileline(), newvarp, VAccess::READ}; UINFO(5, "pinRecon width " << pinVarp->width() << " >? " << rhsp->width() << " >? " << pinexprp->width() << endl); rhsp = extendOrSel(pinp->fileline(), rhsp, pinVarp); - pinp->exprp(new AstVarRef(newvarp->fileline(), newvarp, VAccess::WRITE)); + pinp->exprp(new AstVarRef{newvarp->fileline(), newvarp, VAccess::WRITE}); AstNodeExpr* const rhsSelp = extendOrSel(pinp->fileline(), rhsp, pinexprp); - assignp = new AstAssignW(pinp->fileline(), pinexprp, rhsSelp); + assignp = new AstAssignW{pinp->fileline(), pinexprp, rhsSelp}; } else { // V3 width should have range/extended to make the widths correct - assignp = new AstAssignW(pinp->fileline(), - new AstVarRef(pinp->fileline(), newvarp, VAccess::WRITE), - pinexprp); - pinp->exprp(new AstVarRef(pinexprp->fileline(), newvarp, VAccess::READ)); + assignp = new AstAssignW{pinp->fileline(), + new AstVarRef{pinp->fileline(), newvarp, VAccess::WRITE}, + pinexprp}; + pinp->exprp(new AstVarRef{pinexprp->fileline(), newvarp, VAccess::READ}); } if (assignp) cellp->addNextHere(assignp); // if (debug()) pinp->dumpTree(cout, "- out:"); diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index bfc1c33e8..8bfa0fae8 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -289,7 +289,7 @@ public: } void insertDUnit(AstNetlist* nodep) { // $unit on top scope - VSymEnt* const symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; UINFO(9, " INSERTdunit se" << cvtToHex(symp) << endl); symp->parentp(rootEntp()); // Needed so backward search can find name of top module symp->fallbackp(nullptr); @@ -300,7 +300,7 @@ public: } VSymEnt* insertTopCell(AstNodeModule* nodep, const string& scopename) { // Only called on the module at the very top of the hierarchy - VSymEnt* const symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; UINFO(9, " INSERTtop se" << cvtToHex(symp) << " " << scopename << " " << nodep << endl); symp->parentp(rootEntp()); // Needed so backward search can find name of top module @@ -327,7 +327,7 @@ public: VSymEnt* insertCell(VSymEnt* abovep, VSymEnt* modSymp, AstCell* nodep, const string& scopename) { UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* const symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; UINFO(9, " INSERTcel se" << cvtToHex(symp) << " " << scopename << " above=se" << cvtToHex(abovep) << " mods=se" << cvtToHex(modSymp) << " node=" << nodep << endl); @@ -355,7 +355,7 @@ public: // A fake point in the hierarchy, corresponding to an inlined module // This references to another Sym, and eventually resolves to a module with a prefix UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* const symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; UINFO(9, " INSERTinl se" << cvtToHex(symp) << " " << basename << " above=se" << cvtToHex(abovep) << " mods=se" << cvtToHex(modSymp) << " node=" << nodep << endl); @@ -378,7 +378,7 @@ public: // Note we fallback to the symbol table of the parent, as we want to find variables there // However, cells walk the graph, so cells will appear under the begin/ftask itself UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* const symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; UINFO(9, " INSERTblk se" << cvtToHex(symp) << " above=se" << cvtToHex(abovep) << " pkg=" << cvtToHex(classOrPackagep) << " node=" << nodep << endl); @@ -394,7 +394,7 @@ public: VSymEnt* insertSym(VSymEnt* abovep, const string& name, AstNode* nodep, AstNodeModule* classOrPackagep) { UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* const symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; UINFO(9, " INSERTsym se" << cvtToHex(symp) << " name='" << name << "' above=se" << cvtToHex(abovep) << " pkg=" << cvtToHex(classOrPackagep) << " node=" << nodep << endl); @@ -503,7 +503,7 @@ public: } if (!ok) { const string suggest = suggestSymFallback(ifaceSymp, ifacerefp->modportName(), - LinkNodeMatcherModport()); + LinkNodeMatcherModport{}); ifacerefp->modportFileline()->v3error( "Modport not found under interface " << ifacerefp->prettyNameQ(ifacerefp->ifaceName()) << ": " @@ -753,7 +753,7 @@ class LinkDotFindVisitor final : public VNVisitor { // METHODS void makeImplicitNew(AstClass* nodep) { - AstFunc* const newp = new AstFunc(nodep->fileline(), "new", nullptr, nullptr); + AstFunc* const newp = new AstFunc{nodep->fileline(), "new", nullptr, nullptr}; newp->isConstructor(true); nodep->addMembersp(newp); UINFO(8, "Made implicit new for " << nodep->name() << ": " << nodep << endl); @@ -1103,11 +1103,11 @@ class LinkDotFindVisitor final : public VNVisitor { if (dtypep) { dtypep->unlinkFrBack(); } else { - dtypep = new AstBasicDType(nodep->fileline(), VBasicDTypeKwd::LOGIC); + dtypep = new AstBasicDType{nodep->fileline(), VBasicDTypeKwd::LOGIC}; } AstVar* const newvarp - = new AstVar(nodep->fileline(), VVarType::VAR, nodep->name(), - VFlagChildDType{}, dtypep); // Not dtype resolved yet + = new AstVar{nodep->fileline(), VVarType::VAR, nodep->name(), + VFlagChildDType{}, dtypep}; // Not dtype resolved yet newvarp->direction(VDirection::OUTPUT); newvarp->lifetime(VLifetime::AUTOMATIC); newvarp->funcReturn(true); @@ -1180,7 +1180,7 @@ class LinkDotFindVisitor final : public VNVisitor { findvarp->fileline()->modifyStateInherit(nodep->fileline()); if (nodep->getChildDTypep()->numeric().isSigned() && !findvarp->getChildDTypep()->numeric().isSigned()) { - findvarp->getChildDTypep()->numeric(VSigning(true)); + findvarp->getChildDTypep()->numeric(VSigning{true}); } AstBasicDType* const bdtypep = VN_CAST(findvarp->childDTypep(), BasicDType); @@ -1424,10 +1424,10 @@ class LinkDotFindVisitor final : public VNVisitor { } // Type depends on the method used, let V3Width figure it out later if (nodep->exprp()) { // Else empty expression and pretend no "with" - const auto indexArgRefp = new AstLambdaArgRef(argFl, name + "__DOT__index", true); - const auto valueArgRefp = new AstLambdaArgRef(argFl, name, false); - const auto newp = new AstWith(nodep->fileline(), indexArgRefp, valueArgRefp, - nodep->exprp()->unlinkFrBackWithNext()); + const auto indexArgRefp = new AstLambdaArgRef{argFl, name + "__DOT__index", true}; + const auto valueArgRefp = new AstLambdaArgRef{argFl, name, false}; + const auto newp = new AstWith{nodep->fileline(), indexArgRefp, valueArgRefp, + nodep->exprp()->unlinkFrBackWithNext()}; funcrefp->addPinsp(newp); } nodep->replaceWith(funcrefp->unlinkFrBack()); @@ -1544,9 +1544,9 @@ private: UINFO(9, "Defparam cell " << nodep->path() << "." << nodep->name() << " attach-to " << cellp << " <= " << exprp << endl); // Don't need to check the name of the defparam exists. V3Param does. - AstPin* const pinp = new AstPin(nodep->fileline(), + AstPin* const pinp = new AstPin{nodep->fileline(), -1, // Pin# not relevant - nodep->name(), exprp); + nodep->name(), exprp}; cellp->addParamsp(pinp); } VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); @@ -1985,7 +1985,7 @@ private: if (!noWarn) { if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) { const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), - LinkNodeMatcherVar()); + LinkNodeMatcherVar{}); nodep->v3error("Signal definition not found, and implicit disabled with " "`default_nettype: " << nodep->prettyNameQ() << '\n' @@ -1996,15 +1996,15 @@ private: // as there could be thousands of these suppressed in large netlists else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) { const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), - LinkNodeMatcherVar()); + LinkNodeMatcherVar{}); nodep->v3warn(IMPLICIT, "Signal definition not found, creating implicitly: " << nodep->prettyNameQ() << '\n' << (suggest.empty() ? "" : nodep->warnMore() + suggest)); } } - AstVar* const newp = new AstVar(nodep->fileline(), VVarType::WIRE, nodep->name(), - VFlagLogicPacked{}, 1); + AstVar* const newp = new AstVar{nodep->fileline(), VVarType::WIRE, nodep->name(), + VFlagLogicPacked{}, 1}; newp->trace(modp->modTrace()); nodep->varp(newp); modp->addStmtsp(newp); @@ -2184,9 +2184,9 @@ private: } const string suggest = (nodep->param() ? m_statep->suggestSymFlat(m_pinSymp, nodep->name(), - LinkNodeMatcherVarParam()) + LinkNodeMatcherVarParam{}) : m_statep->suggestSymFlat(m_pinSymp, nodep->name(), - LinkNodeMatcherVarIO())); + LinkNodeMatcherVarIO{})); nodep->v3warn(PINNOTFOUND, ucfirst(whatp) << " not found: " << nodep->prettyNameQ() << '\n' @@ -2286,7 +2286,7 @@ private: if (start) { AstNode* newp; if (m_ds.m_dotErr) { - newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); + newp = new AstConst{nodep->fileline(), AstConst::BitFalse{}}; } else { // RHS is what we're left with newp = nodep->rhsp()->unlinkFrBack(); @@ -2297,8 +2297,8 @@ private: } else { // Dot midpoint AstNodeExpr* newp = nodep->rhsp()->unlinkFrBack(); if (m_ds.m_unresolved) { - AstCellRef* const crp = new AstCellRef(nodep->fileline(), nodep->name(), - nodep->lhsp()->unlinkFrBack(), newp); + AstCellRef* const crp = new AstCellRef{nodep->fileline(), nodep->name(), + nodep->lhsp()->unlinkFrBack(), newp}; newp = crp; } nodep->replaceWith(newp); @@ -2351,8 +2351,8 @@ private: && nodep->name() == "index") { // 'with' statement's 'item.index' iterateChildren(nodep); - const auto newp = new AstLambdaArgRef( - nodep->fileline(), m_ds.m_unlinkedScopep->name() + "__DOT__index", true); + const auto newp = new AstLambdaArgRef{ + nodep->fileline(), m_ds.m_unlinkedScopep->name() + "__DOT__index", true}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; @@ -2360,7 +2360,7 @@ private: // Found a Var, everything following is membership. {scope}.{var}.HERE {member} AstNodeExpr* const varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); AstNodeExpr* const newp - = new AstMemberSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name()); + = new AstMemberSel{nodep->fileline(), varEtcp, VFlagChildDType{}, nodep->name()}; if (m_ds.m_dotErr) { nodep->unlinkFrBack(); // Avoid circular node loop on errors } else { @@ -2462,15 +2462,15 @@ private: m_ds.m_dotSymp = m_statep->getNodeSym(ifacerefp->ifaceViaCellp()); m_ds.m_dotPos = DP_SCOPE; ok = true; - AstNode* const newp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); + AstNode* const newp = new AstVarRef{nodep->fileline(), varp, VAccess::READ}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (allowVar) { AstNode* newp; if (m_ds.m_dotText != "") { AstVarXRef* const refp - = new AstVarXRef(nodep->fileline(), nodep->name(), m_ds.m_dotText, - VAccess::READ); // lvalue'ness computed later + = new AstVarXRef{nodep->fileline(), nodep->name(), m_ds.m_dotText, + VAccess::READ}; // lvalue'ness computed later refp->varp(varp); if (varp->attrSplitVar()) { refp->v3warn( @@ -2490,8 +2490,8 @@ private: refp->dotted(dotted.substr(0, pos)); newp = refp; } else { - newp = new AstUnlinkedRef(nodep->fileline(), refp, refp->name(), - m_ds.m_unlinkedScopep->unlinkFrBack()); + newp = new AstUnlinkedRef{nodep->fileline(), refp, refp->name(), + m_ds.m_unlinkedScopep->unlinkFrBack()}; m_ds.m_unlinkedScopep = nullptr; m_ds.m_unresolved = false; } @@ -2499,9 +2499,8 @@ private: newp = refp; } } else { - AstVarRef* const refp - = new AstVarRef(nodep->fileline(), varp, - VAccess::READ); // lvalue'ness computed later + AstVarRef* const refp = new AstVarRef{ + nodep->fileline(), varp, VAccess::READ}; // lvalue'ness computed later refp->classOrPackagep(foundp->classOrPackagep()); newp = refp; } @@ -2552,8 +2551,8 @@ private: // iface[vec].modport became CellArrayRef(iface, lsb) // Convert back to SelBit(iface, lsb) UINFO(9, " Array modport to SelBit " << cellarrayrefp << endl); - newp = new AstSelBit(cellarrayrefp->fileline(), newp, - cellarrayrefp->selp()->unlinkFrBack()); + newp = new AstSelBit{cellarrayrefp->fileline(), newp, + cellarrayrefp->selp()->unlinkFrBack()}; newp->user3(true); // Don't process again VL_DO_DANGLING(cellarrayrefp->unlinkFrBack(), cellarrayrefp); m_ds.m_unlinkedScopep = nullptr; @@ -2564,7 +2563,7 @@ private: } else if (AstEnumItem* const valuep = VN_CAST(foundp->nodep(), EnumItem)) { if (allowVar) { AstNode* const newp - = new AstEnumItemRef(nodep->fileline(), valuep, foundp->classOrPackagep()); + = new AstEnumItemRef{nodep->fileline(), valuep, foundp->classOrPackagep()}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); ok = true; @@ -2574,7 +2573,7 @@ private: = VN_CAST(foundp->nodep(), LambdaArgRef)) { if (allowVar) { AstNode* const newp - = new AstLambdaArgRef(nodep->fileline(), argrefp->name(), false); + = new AstLambdaArgRef{nodep->fileline(), argrefp->name(), false}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); ok = true; @@ -2618,7 +2617,7 @@ private: // Create if implicit, and also if error (so only complain once) // Else if a scope is allowed, making a signal won't help error cascade AstVarRef* const newp - = new AstVarRef(nodep->fileline(), nodep->name(), VAccess::READ); + = new AstVarRef{nodep->fileline(), nodep->name(), VAccess::READ}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); createImplicitVar(m_curSymp, newp, m_modp, m_modSymp, err); @@ -2718,7 +2717,7 @@ private: if (!m_statep->forPrearray() && !m_statep->forScopeCreation()) { if (VN_IS(nodep->dtypep(), IfaceRefDType)) { AstVarRef* const newrefp - = new AstVarRef(nodep->fileline(), nodep->varp(), nodep->access()); + = new AstVarRef{nodep->fileline(), nodep->varp(), nodep->access()}; nodep->replaceWith(newrefp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -2743,7 +2742,7 @@ private: nodep->varScopep(vscp); UINFO(7, " Resolved " << nodep << endl); // Also prints taskp AstVarRef* const newvscp - = new AstVarRef(nodep->fileline(), vscp, nodep->access()); + = new AstVarRef{nodep->fileline(), vscp, nodep->access()}; nodep->replaceWith(newvscp); VL_DO_DANGLING(nodep->deleteTree(), nodep); UINFO(9, " new " << newvscp << endl); // Also prints taskp @@ -2800,8 +2799,8 @@ private: AstNodeFTaskRef* const newftaskp = nodep->cloneTree(false); newftaskp->dotted(m_ds.m_dotText); AstNode* const newp - = new AstUnlinkedRef(nodep->fileline(), newftaskp, nodep->name(), - m_ds.m_unlinkedScopep->unlinkFrBack()); + = new AstUnlinkedRef{nodep->fileline(), newftaskp, nodep->name(), + m_ds.m_unlinkedScopep->unlinkFrBack()}; m_ds.m_unlinkedScopep = nullptr; m_ds.m_unresolved = false; nodep->replaceWith(newp); @@ -2815,8 +2814,8 @@ private: AstNodeExpr* const varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); AstNodeExpr* argsp = nullptr; if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext(); - AstNode* const newp = new AstMethodCall(nodep->fileline(), varEtcp, VFlagChildDType(), - nodep->name(), argsp); + AstNode* const newp = new AstMethodCall{nodep->fileline(), varEtcp, VFlagChildDType{}, + nodep->name(), argsp}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; @@ -2897,8 +2896,8 @@ private: if (v3Global.opt.bboxSys()) { AstNode* newp; if (VN_IS(nodep, FuncRef)) { - newp = new AstConst(nodep->fileline(), AstConst::StringToParse(), - "'0"); + newp = new AstConst{nodep->fileline(), AstConst::StringToParse{}, + "'0"}; } else { AstNode* outp = nullptr; while (nodep->pinsp()) { @@ -2910,7 +2909,7 @@ private: } outp = AstNode::addNext(outp, addp); } - newp = new AstSysIgnore(nodep->fileline(), outp); + newp = new AstSysIgnore{nodep->fileline(), outp}; newp->dtypep(nodep->dtypep()); } nodep->replaceWith(newp); @@ -2922,14 +2921,14 @@ private: } } else { const string suggest = m_statep->suggestSymFallback( - dotSymp, nodep->name(), LinkNodeMatcherFTask()); + dotSymp, nodep->name(), LinkNodeMatcherFTask{}); nodep->v3error("Can't find definition of task/function: " << nodep->prettyNameQ() << '\n' << (suggest.empty() ? "" : nodep->warnMore() + suggest)); } } else { const string suggest = m_statep->suggestSymFallback(dotSymp, nodep->name(), - LinkNodeMatcherFTask()); + LinkNodeMatcherFTask{}); nodep->v3error("Can't find definition of " << AstNode::prettyNameQ(baddot) << " in dotted task/function: '" << nodep->dotted() + "." + nodep->prettyName() << "'\n" @@ -2968,7 +2967,7 @@ private: if (m_ds.m_unresolved && m_ds.m_dotPos == DP_SCOPE) { AstNodeExpr* const exprp = nodep->bitp()->unlinkFrBack(); AstCellArrayRef* const newp - = new AstCellArrayRef(nodep->fileline(), nodep->fromp()->name(), exprp); + = new AstCellArrayRef{nodep->fileline(), nodep->fromp()->name(), exprp}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } @@ -3123,8 +3122,8 @@ private: AstNode* const itemp = it->second->nodep(); if (!nodep->findMember(it->first)) { if (AstEnumItem* const aitemp = VN_CAST(itemp, EnumItem)) { - AstEnumItemRef* const newp = new AstEnumItemRef( - aitemp->fileline(), aitemp, it->second->classOrPackagep()); + AstEnumItemRef* const newp = new AstEnumItemRef{ + aitemp->fileline(), aitemp, it->second->classOrPackagep()}; UINFO(8, "Class import noderef '" << it->first << "' " << newp << endl); nodep->addMembersp(newp); } diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 18744fffc..a49b98f7f 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -769,7 +769,7 @@ public: // For each node, record the critical path cost from the start // of the graph through the end of the node. std::unordered_map critPaths; - GraphStreamUnordered serialize(m_graphp); + GraphStreamUnordered serialize{m_graphp}; for (const V3GraphVertex* vertexp; (vertexp = serialize.nextp());) { ++m_vertexCount; uint32_t cpCostToHere = 0; @@ -1110,7 +1110,7 @@ private: } public: - static void selfTest() { PartPropagateCpSelfTest().go(); } + static void selfTest() { PartPropagateCpSelfTest{}.go(); } }; // Merge edges from a LogicMtask. @@ -1731,9 +1731,9 @@ private: V3Graph mtasks; LogicMTask* lastp = nullptr; for (unsigned i = 0; i < chain_len; ++i) { - LogicMTask* const mtp = new LogicMTask(&mtasks, nullptr); + LogicMTask* const mtp = new LogicMTask{&mtasks, nullptr}; mtp->setCost(1); - if (lastp) new MTaskEdge(&mtasks, lastp, mtp, 1); + if (lastp) new MTaskEdge{&mtasks, lastp, mtp, 1}; lastp = mtp; } partInitCriticalPaths(&mtasks); @@ -1741,12 +1741,12 @@ private: // Since slowAsserts mode is *expected* to cause N^2 runtime, and the // intent of this test is to demonstrate better-than-N^2 runtime, disable // slowAsserts. - PartContraction ec(&mtasks, + PartContraction ec{&mtasks, // Any CP limit >chain_len should work: - chain_len * 2, false /* slowAsserts */); + chain_len * 2, false /* slowAsserts */}; ec.go(); - PartParallelismEst check(&mtasks); + PartParallelismEst check{&mtasks}; check.traverse(); const uint64_t endUsecs = V3Os::timeUsecs(); @@ -1780,26 +1780,26 @@ private: static void selfTestX() { // NOTE: To get a dot file run with --debugi-V3Partition 4 or more. V3Graph mtasks; - LogicMTask* const centerp = new LogicMTask(&mtasks, nullptr); + LogicMTask* const centerp = new LogicMTask{&mtasks, nullptr}; centerp->setCost(1); unsigned i; for (i = 0; i < 50; ++i) { - LogicMTask* const mtp = new LogicMTask(&mtasks, nullptr); + LogicMTask* const mtp = new LogicMTask{&mtasks, nullptr}; mtp->setCost(1); // Edge from every input -> centerp - new MTaskEdge(&mtasks, mtp, centerp, 1); + new MTaskEdge{&mtasks, mtp, centerp, 1}; } for (i = 0; i < 50; ++i) { - LogicMTask* const mtp = new LogicMTask(&mtasks, nullptr); + LogicMTask* const mtp = new LogicMTask{&mtasks, nullptr}; mtp->setCost(1); // Edge from centerp -> every output - new MTaskEdge(&mtasks, centerp, mtp, 1); + new MTaskEdge{&mtasks, centerp, mtp, 1}; } partInitCriticalPaths(&mtasks); - PartContraction(&mtasks, 20, true).go(); + PartContraction{&mtasks, 20, true}.go(); - PartParallelismEst check(&mtasks); + PartParallelismEst check{&mtasks}; check.traverse(); // Checking exact values here is maybe overly precise. What we're @@ -2033,7 +2033,7 @@ public: // Rank the graph. DGS is faster than V3GraphAlg's recursive rank, and also allows us to // set up the OrderLogicVertex -> LogicMTask map at the same time. { - GraphStreamUnordered serialize(m_mtasksp); + GraphStreamUnordered serialize{m_mtasksp}; while (LogicMTask* const mtaskp = const_cast(static_cast(serialize.nextp()))) { // Compute and assign rank @@ -2382,7 +2382,7 @@ public: // Pack an MTasks from given graph into m_nThreads threads, return the schedule. const ThreadSchedule pack(const V3Graph& mtaskGraph) { // The result - ThreadSchedule schedule(m_nThreads); + ThreadSchedule schedule{m_nThreads}; // Time each thread is occupied until std::vector busyUntil(m_nThreads, 0); @@ -2475,22 +2475,22 @@ public: // SELF TEST static void selfTest() { V3Graph graph; - ExecMTask* const t0 = new ExecMTask(&graph, nullptr, 0); + ExecMTask* const t0 = new ExecMTask{&graph, nullptr, 0}; t0->cost(1000); t0->priority(1100); - ExecMTask* const t1 = new ExecMTask(&graph, nullptr, 1); + ExecMTask* const t1 = new ExecMTask{&graph, nullptr, 1}; t1->cost(100); t1->priority(100); - ExecMTask* const t2 = new ExecMTask(&graph, nullptr, 2); + ExecMTask* const t2 = new ExecMTask{&graph, nullptr, 2}; t2->cost(100); t2->priority(100); - new V3GraphEdge(&graph, t0, t1, 1); - new V3GraphEdge(&graph, t0, t2, 1); + new V3GraphEdge{&graph, t0, t1, 1}; + new V3GraphEdge{&graph, t0, t2, 1}; - PartPackMTasks packer(2, // Threads + PartPackMTasks packer{2, // Threads 3, // Sandbag numerator - 10); // Sandbag denom + 10}; // Sandbag denom const ThreadSchedule& schedule = packer.pack(graph); UASSERT_SELFTEST(size_t, schedule.threads.size(), 2); @@ -2748,7 +2748,7 @@ void V3Partition::go(V3Graph* mtasksp) { // Merge nodes that could present data hazards; see comment within. { - PartFixDataHazards(m_orderGraphp, mtasksp).go(); + PartFixDataHazards{m_orderGraphp, mtasksp}.go(); V3Partition::debugMTaskGraphStats(mtasksp, "hazards"); hashGraphDebug(mtasksp, "mtasksp after fixDataHazards()"); } @@ -2791,10 +2791,10 @@ void V3Partition::go(V3Graph* mtasksp) { // Some tests disable this, hence the test on threadsCoarsen(). // Coarsening is always enabled in production. if (v3Global.opt.threadsCoarsen()) { - PartContraction(mtasksp, cpLimit, + PartContraction{mtasksp, cpLimit, // --debugPartition is used by tests // to enable slow assertions. - v3Global.opt.debugPartition()) + v3Global.opt.debugPartition()} .go(); V3Partition::debugMTaskGraphStats(mtasksp, "contraction"); } @@ -3011,7 +3011,7 @@ static void finalizeCosts(V3Graph* execMTaskGraphp) { UINFO(6, "Removing zero-cost " << mtp->name() << endl); for (V3GraphEdge* inp = mtp->inBeginp(); inp; inp = inp->inNextp()) { for (V3GraphEdge* outp = mtp->outBeginp(); outp; outp = outp->outNextp()) { - new V3GraphEdge(execMTaskGraphp, inp->fromp(), outp->top(), 1); + new V3GraphEdge{execMTaskGraphp, inp->fromp(), outp->top(), 1}; } } VL_DO_DANGLING(mtp->unlinkDelete(execMTaskGraphp), mtp); @@ -3052,7 +3052,7 @@ static void addMTaskToFunction(const ThreadSchedule& schedule, const uint32_t th // Helper function to make the code a bit more legible const auto addStrStmt = [=](const string& stmt) -> void { // - funcp->addStmtsp(new AstCStmt(fl, stmt)); + funcp->addStmtsp(new AstCStmt{fl, stmt}); }; if (const uint32_t nDependencies = schedule.crossThreadDependencies(mtaskp)) { @@ -3061,8 +3061,8 @@ static void addMTaskToFunction(const ThreadSchedule& schedule, const uint32_t th const string name = "__Vm_mtaskstate_" + cvtToStr(mtaskp->id()); AstBasicDType* const mtaskStateDtypep = v3Global.rootp()->typeTablep()->findBasicDType(fl, VBasicDTypeKwd::MTASKSTATE); - AstVar* const varp = new AstVar(fl, VVarType::MODULETEMP, name, mtaskStateDtypep); - varp->valuep(new AstConst(fl, nDependencies)); + AstVar* const varp = new AstVar{fl, VVarType::MODULETEMP, name, mtaskStateDtypep}; + varp->valuep(new AstConst{fl, nDependencies}); varp->protect(false); // Do not protect as we still have references in AstText modp->addStmtsp(varp); // For now, reference is still via text bashing @@ -3124,7 +3124,7 @@ static const std::vector createThreadFunctions(const ThreadSchedule& if (thread.empty()) continue; const uint32_t threadId = schedule.threadId(thread.front()); const string name{"__Vthread__" + tag + "__" + cvtToStr(threadId)}; - AstCFunc* const funcp = new AstCFunc(fl, name, nullptr, "void"); + AstCFunc* const funcp = new AstCFunc{fl, name, nullptr, "void"}; modp->addStmtsp(funcp); funcps.push_back(funcp); funcp->isStatic(true); // Uses void self pointer, so static and hand rolled @@ -3166,10 +3166,10 @@ static void addThreadStartToExecGraph(AstExecGraph* const execGraphp, // Add thread function invocations to execGraph const auto addStrStmt = [=](const string& stmt) -> void { // - execGraphp->addStmtsp(new AstCStmt(fl, stmt)); + execGraphp->addStmtsp(new AstCStmt{fl, stmt}); }; const auto addTextStmt = [=](const string& text) -> void { - execGraphp->addStmtsp(new AstText(fl, text, /* tracking: */ true)); + execGraphp->addStmtsp(new AstText{fl, text, /* tracking: */ true}); }; addStrStmt("vlSymsp->__Vm_even_cycle__" + tag + " = !vlSymsp->__Vm_even_cycle__" + tag @@ -3181,11 +3181,11 @@ static void addThreadStartToExecGraph(AstExecGraph* const execGraphp, if (i != last) { // The first N-1 will run on the thread pool. addTextStmt("vlSymsp->__Vm_threadPoolp->workerp(" + cvtToStr(i) + ")->addTask("); - execGraphp->addStmtsp(new AstAddrOfCFunc(fl, funcp)); + execGraphp->addStmtsp(new AstAddrOfCFunc{fl, funcp}); addTextStmt(", vlSelf, vlSymsp->__Vm_even_cycle__" + tag + ");\n"); } else { // The last will run on the main thread. - AstCCall* const callp = new AstCCall(fl, funcp); + AstCCall* const callp = new AstCCall{fl, funcp}; callp->dtypeSetVoid(); callp->argTypes("vlSelf, vlSymsp->__Vm_even_cycle__" + tag); execGraphp->addStmtsp(callp->makeStmt()); @@ -3203,7 +3203,7 @@ static void implementExecGraph(AstExecGraph* const execGraphp) { // Schedule the mtasks: statically associate each mtask with a thread, // and determine the order in which each thread will runs its mtasks. - const ThreadSchedule& schedule = PartPackMTasks().pack(*execGraphp->depGraphp()); + const ThreadSchedule& schedule = PartPackMTasks{}.pack(*execGraphp->depGraphp()); // Create a function to be run by each thread. Note this moves all AstMTaskBody nodes form the // AstExecGrap into the AstCFunc created diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 3c30da6d7..c8d0ef3fb 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -163,7 +163,7 @@ private: } } TaskFTaskVertex* getFTaskVertex(AstNodeFTask* nodep) { - if (!nodep->user4p()) nodep->user4p(new TaskFTaskVertex(&m_callGraph, nodep)); + if (!nodep->user4p()) nodep->user4p(new TaskFTaskVertex{&m_callGraph, nodep}); return static_cast(nodep->user4u().toGraphVertex()); } @@ -204,7 +204,7 @@ private: } // We make multiple edges if a task is called multiple times from another task. UASSERT_OBJ(nodep->taskp(), nodep, "Unlinked task"); - new TaskEdge(&m_callGraph, m_curVxp, getFTaskVertex(nodep->taskp())); + new TaskEdge{&m_callGraph, m_curVxp, getFTaskVertex(nodep->taskp())}; } void visit(AstNodeFTask* nodep) override { UINFO(9, " TASK " << nodep << endl); @@ -276,7 +276,7 @@ private: public: // CONSTRUCTORS explicit TaskStateVisitor(AstNetlist* nodep) { - m_curVxp = new TaskCodeVertex(&m_callGraph); + m_curVxp = new TaskCodeVertex{&m_callGraph}; AstNode::user3ClearTree(); AstNode::user4ClearTree(); // @@ -369,20 +369,20 @@ private: // METHODS AstVarScope* createFuncVar(AstCFunc* funcp, const string& name, AstVar* examplep) { - AstVar* const newvarp = new AstVar(funcp->fileline(), VVarType::BLOCKTEMP, name, examplep); + AstVar* const newvarp = new AstVar{funcp->fileline(), VVarType::BLOCKTEMP, name, examplep}; newvarp->funcLocal(true); funcp->addInitsp(newvarp); - AstVarScope* const newvscp = new AstVarScope(funcp->fileline(), m_scopep, newvarp); + AstVarScope* const newvscp = new AstVarScope{funcp->fileline(), m_scopep, newvarp}; m_scopep->addVarsp(newvscp); return newvscp; } AstVarScope* createInputVar(AstCFunc* funcp, const string& name, VBasicDTypeKwd kwd) { AstVar* const newvarp - = new AstVar(funcp->fileline(), VVarType::BLOCKTEMP, name, funcp->findBasicDType(kwd)); + = new AstVar{funcp->fileline(), VVarType::BLOCKTEMP, name, funcp->findBasicDType(kwd)}; newvarp->funcLocal(true); newvarp->direction(VDirection::INPUT); funcp->addArgsp(newvarp); - AstVarScope* const newvscp = new AstVarScope(funcp->fileline(), m_scopep, newvarp); + AstVarScope* const newvscp = new AstVarScope{funcp->fileline(), m_scopep, newvarp}; m_scopep->addVarsp(newvscp); return newvscp; } @@ -425,7 +425,7 @@ private: AstNode* const newbodysp = AstNode::cloneTreeNull(refp->taskp()->stmtsp(), true); // Maybe nullptr AstNode* const beginp - = new AstComment(refp->fileline(), string("Function: ") + refp->name(), true); + = new AstComment{refp->fileline(), string("Function: ") + refp->name(), true}; if (newbodysp) beginp->addNext(newbodysp); if (debug() >= 9) beginp->dumpTreeAndNext(cout, "-newbegi:"); // @@ -478,9 +478,9 @@ private: AstVarScope* const tempvscp = createVarScope(portp, namePrefix + "__" + portp->shortName()); portp->user2p(tempvscp); - AstAssign* const assp = new AstAssign( + AstAssign* const assp = new AstAssign{ pinp->fileline(), pinp, - new AstVarRef(tempvscp->fileline(), tempvscp, VAccess::READ)); + new AstVarRef{tempvscp->fileline(), tempvscp, VAccess::READ}}; assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true); // Ok if in <= block // Put assignment BEHIND of all other statements @@ -490,9 +490,9 @@ private: AstVarScope* const inVscp = createVarScope(portp, namePrefix + "__" + portp->shortName()); portp->user2p(inVscp); - AstAssign* const assp = new AstAssign( + AstAssign* const assp = new AstAssign{ pinp->fileline(), - new AstVarRef(inVscp->fileline(), inVscp, VAccess::WRITE), pinp); + new AstVarRef{inVscp->fileline(), inVscp, VAccess::WRITE}, pinp}; assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true); // Ok if in <= block // Put assignment in FRONT of all other statements @@ -542,20 +542,20 @@ private: UASSERT_OBJ(cfuncp, refp, "No non-inline task associated with this task call?"); // AstNode* const beginp - = new AstComment(refp->fileline(), string("Function: ") + refp->name(), true); + = new AstComment{refp->fileline(), string("Function: ") + refp->name(), true}; AstNodeCCall* ccallp; if (VN_IS(refp, New)) { - AstCNew* const cnewp = new AstCNew(refp->fileline(), cfuncp); + AstCNew* const cnewp = new AstCNew{refp->fileline(), cfuncp}; cnewp->dtypep(refp->dtypep()); ccallp = cnewp; // Parent AstNew will replace with this CNew cnewpr = cnewp; } else if (const AstMethodCall* const mrefp = VN_CAST(refp, MethodCall)) { - ccallp = new AstCMethodCall(refp->fileline(), mrefp->fromp()->unlinkFrBack(), cfuncp); + ccallp = new AstCMethodCall{refp->fileline(), mrefp->fromp()->unlinkFrBack(), cfuncp}; ccallp->dtypeSetVoid(); beginp->addNext(ccallp->makeStmt()); } else { - ccallp = new AstCCall(refp->fileline(), cfuncp); + ccallp = new AstCCall{refp->fileline(), cfuncp}; ccallp->dtypeSetVoid(); beginp->addNext(ccallp->makeStmt()); } @@ -598,10 +598,10 @@ private: AstVarScope* const newvscp = createVarScope(portp, namePrefix + "__" + portp->shortName()); portp->user2p(newvscp); - pinp->replaceWith(new AstVarRef(newvscp->fileline(), newvscp, VAccess::WRITE)); - AstAssign* const assp = new AstAssign( + pinp->replaceWith(new AstVarRef{newvscp->fileline(), newvscp, VAccess::WRITE}); + AstAssign* const assp = new AstAssign{ pinp->fileline(), pinp, - new AstVarRef(newvscp->fileline(), newvscp, VAccess::READ)); + new AstVarRef{newvscp->fileline(), newvscp, VAccess::READ}}; assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true); // Ok if in <= block // Put assignment BEHIND of all other statements @@ -619,8 +619,8 @@ private: UASSERT_OBJ(snp, refp, "Missing scoping context"); ccallp->addArgsp(snp); // __Vfilenamep - ccallp->addArgsp(new AstCExpr(refp->fileline(), - "\"" + refp->fileline()->filename() + "\"", 64, true)); + ccallp->addArgsp(new AstCExpr{refp->fileline(), + "\"" + refp->fileline()->filename() + "\"", 64, true}); // __Vlineno ccallp->addArgsp(new AstConst(refp->fileline(), refp->fileline()->lineno())); } @@ -635,7 +635,7 @@ private: ccallp->addArgsp(exprp); } - if (outvscp) ccallp->addArgsp(new AstVarRef(refp->fileline(), outvscp, VAccess::WRITE)); + if (outvscp) ccallp->addArgsp(new AstVarRef{refp->fileline(), outvscp, VAccess::WRITE}); if (debug() >= 9) beginp->dumpTreeAndNext(cout, "-nitask: "); return beginp; @@ -668,7 +668,7 @@ private: static AstNode* createDpiTemp(AstVar* portp, const string& suffix) { const string stmt = portp->dpiTmpVarType(portp->name() + suffix) + ";\n"; - return new AstCStmt(portp->fileline(), stmt); + return new AstCStmt{portp->fileline(), stmt}; } void unlinkAndClone(AstNodeFTask* funcp, AstNode* nodep, bool withNext) { @@ -692,7 +692,7 @@ private: static AstNode* createAssignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix, const string& toSuffix) { const string stmt = V3Task::assignInternalToDpi(portp, isPtr, frSuffix, toSuffix); - return new AstCStmt(portp->fileline(), stmt); + return new AstCStmt{portp->fileline(), stmt}; } AstNode* createAssignDpiToInternal(AstVarScope* portvscp, const string& frName) { @@ -721,7 +721,7 @@ private: AstNode* newp = nullptr; const int widthWords = portp->basicp()->widthWords(); for (int i = 0; i < total; ++i) { - AstNodeExpr* srcp = new AstVarRef(portvscp->fileline(), portvscp, VAccess::WRITE); + AstNodeExpr* srcp = new AstVarRef{portvscp->fileline(), portvscp, VAccess::WRITE}; // extract a scalar from multi-dimensional array (internal format) for (auto&& dimStride : dimStrides) { const size_t dimIdx = (i / dimStride.second) % dimStride.first->elementsConst(); @@ -730,12 +730,12 @@ private: AstNode* stmtp = nullptr; // extract a scalar from DPI temporary var that is scalar or 1D array if (useSetWSvlv) { - AstNode* const linesp = new AstText(portvscp->fileline(), frstmt + ket); + AstNode* const linesp = new AstText{portvscp->fileline(), frstmt + ket}; linesp->addNext(srcp); linesp->addNext( - new AstText(portvscp->fileline(), - "," + frName + " + " + cvtToStr(i * widthWords) + ");\n")); - stmtp = new AstCStmt(portvscp->fileline(), linesp); + new AstText{portvscp->fileline(), + "," + frName + " + " + cvtToStr(i * widthWords) + ");\n"}); + stmtp = new AstCStmt{portvscp->fileline(), linesp}; } else { string from = frstmt; if (!dimStrides.empty()) { @@ -744,10 +744,10 @@ private: from += "[" + cvtToStr(i * coef) + "]"; } from += ket; - AstNodeExpr* const rhsp = new AstSel( - portp->fileline(), new AstCExpr(portp->fileline(), from, cwidth, false), 0, - portp->width()); - stmtp = new AstAssign(portp->fileline(), srcp, rhsp); + AstNodeExpr* const rhsp = new AstSel{ + portp->fileline(), new AstCExpr{portp->fileline(), from, cwidth, false}, 0, + portp->width()}; + stmtp = new AstAssign{portp->fileline(), srcp, rhsp}; } if (i > 0) { newp->addNext(stmtp); @@ -760,8 +760,8 @@ private: AstCFunc* makeDpiExportDispatcher(AstNodeFTask* nodep, AstVar* rtnvarp) { const char* const tmpSuffixp = V3Task::dpiTemporaryVarSuffix(); - AstCFunc* const funcp = new AstCFunc(nodep->fileline(), nodep->cname(), m_scopep, - (rtnvarp ? rtnvarp->dpiArgType(true, true) : "")); + AstCFunc* const funcp = new AstCFunc{nodep->fileline(), nodep->cname(), m_scopep, + (rtnvarp ? rtnvarp->dpiArgType(true, true) : "")}; funcp->dpiExportDispatcher(true); funcp->dpiContext(nodep->dpiContext()); funcp->dontCombine(true); @@ -797,7 +797,7 @@ private: + ")(VerilatedScope::exportFind(__Vscopep, __Vfuncnum));\n"; // Can't use // static_cast // If __Vcb is null the exportFind function throws and error - funcp->addStmtsp(new AstCStmt(nodep->fileline(), stmt)); + funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt}); } // Convert input/inout DPI arguments to Internal types @@ -812,7 +812,7 @@ private: // SAME CODE BELOW args += ", "; if (args != "") { - argnodesp = argnodesp->addNext(new AstText(portp->fileline(), args, true)); + argnodesp = argnodesp->addNext(new AstText{portp->fileline(), args, true}); args = ""; } AstVarScope* const outvscp @@ -821,8 +821,8 @@ private: outvscp->varp()->protect(false); portp->protect(false); AstVarRef* const refp - = new AstVarRef(portp->fileline(), outvscp, - portp->isWritable() ? VAccess::WRITE : VAccess::READ); + = new AstVarRef{portp->fileline(), outvscp, + portp->isWritable() ? VAccess::WRITE : VAccess::READ}; argnodesp = argnodesp->addNext(refp); if (portp->isNonOutput()) { @@ -843,14 +843,14 @@ private: // SAME CODE ABOVE args += ", "; if (args != "") { - argnodesp = argnodesp->addNext(new AstText(portp->fileline(), args, true)); + argnodesp = argnodesp->addNext(new AstText{portp->fileline(), args, true}); args = ""; } AstVarScope* const outvscp = createFuncVar(funcp, portp->name() + tmpSuffixp, portp); // No information exposure; is already visible in import/export func template outvscp->varp()->protect(false); - AstVarRef* const refp = new AstVarRef( - portp->fileline(), outvscp, portp->isWritable() ? VAccess::WRITE : VAccess::READ); + AstVarRef* const refp = new AstVarRef{ + portp->fileline(), outvscp, portp->isWritable() ? VAccess::WRITE : VAccess::READ}; argnodesp = argnodesp->addNext(refp); } @@ -858,10 +858,10 @@ private: // Add the variables referenced as VarRef's so that lifetime analysis // doesn't rip up the variables on us args += ");\n"; - AstCStmt* const newp = new AstCStmt(nodep->fileline(), "(*__Vcb)("); + AstCStmt* const newp = new AstCStmt{nodep->fileline(), "(*__Vcb)("}; newp->addExprsp(argnodesp); VL_DANGLING(argnodesp); - newp->addExprsp(new AstText(nodep->fileline(), args, true)); + newp->addExprsp(new AstText{nodep->fileline(), args, true}); funcp->addStmtsp(newp); } @@ -879,7 +879,7 @@ private: funcp->addStmtsp(createAssignInternalToDpi(rtnvarp, false, tmpSuffixp, "")); string stmt = "return " + rtnvarp->name(); stmt += rtnvarp->basicp()->isDpiPrimitive() ? ";\n" : "[0];\n"; - funcp->addStmtsp(new AstCStmt(nodep->fileline(), stmt)); + funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt}); } makePortList(nodep, funcp); return funcp; @@ -894,7 +894,7 @@ private: const string rtnType = rtnvarp ? rtnvarp->dpiArgType(true, true) : nodep->dpiTask() ? "int" : ""; - AstCFunc* const funcp = new AstCFunc(nodep->fileline(), nodep->cname(), m_scopep, rtnType); + AstCFunc* const funcp = new AstCFunc{nodep->fileline(), nodep->cname(), m_scopep, rtnType}; funcp->dpiContext(nodep->dpiContext()); funcp->dpiImportPrototype(true); funcp->dontCombine(true); @@ -997,7 +997,7 @@ private: // At least put them into the module's CTOR as static? const string propName = portp->name() + "__Vopenprops"; const string propCode = portp->vlPropDecl(propName); - cfuncp->addStmtsp(new AstCStmt(portp->fileline(), propCode)); + cfuncp->addStmtsp(new AstCStmt{portp->fileline(), propCode}); // // At runtime we need the svOpenArrayHandle to // point to this task & thread's data, in addition @@ -1007,7 +1007,7 @@ private: = ("VerilatedDpiOpenVar " // NOLINTNEXTLINE(performance-inefficient-string-concatenation) + name + " (&" + propName + ", &" + portp->name() + ");\n"); - cfuncp->addStmtsp(new AstCStmt(portp->fileline(), varCode)); + cfuncp->addStmtsp(new AstCStmt{portp->fileline(), varCode}); args += "&" + name; } else { if (portp->isWritable() && portp->basicp()->isDpiPrimitive()) { @@ -1029,7 +1029,7 @@ private: // Store context, if needed if (nodep->dpiContext()) { const string stmt = "Verilated::dpiContext(__Vscopep, __Vfilenamep, __Vlineno);\n"; - cfuncp->addStmtsp(new AstCStmt(nodep->fileline(), stmt)); + cfuncp->addStmtsp(new AstCStmt{nodep->fileline(), stmt}); } { // Call the imported function @@ -1038,9 +1038,9 @@ private: string stmt = rtnvscp->varp()->name(); stmt += tmpSuffixp; stmt += rtnvscp->varp()->basicp()->isDpiPrimitive() ? " = " : "[0] = "; - cfuncp->addStmtsp(new AstText(nodep->fileline(), stmt, /* tracking: */ true)); + cfuncp->addStmtsp(new AstText{nodep->fileline(), stmt, /* tracking: */ true}); } - AstCCall* const callp = new AstCCall(nodep->fileline(), dpiFuncp); + AstCCall* const callp = new AstCCall{nodep->fileline(), dpiFuncp}; callp->dtypeSetVoid(); callp->argTypes(args); cfuncp->addStmtsp(callp->makeStmt()); @@ -1139,7 +1139,7 @@ private: AstVarScope* rtnvscp = nullptr; if (rtnvarp) { - rtnvscp = new AstVarScope(rtnvarp->fileline(), m_scopep, rtnvarp); + rtnvscp = new AstVarScope{rtnvarp->fileline(), m_scopep, rtnvarp}; m_scopep->addVarsp(rtnvscp); rtnvarp->user2p(rtnvscp); } @@ -1157,9 +1157,9 @@ private: string suffix; // So, make them unique if (!nodep->taskPublic() && !nodep->classMethod()) suffix = "_" + m_scopep->nameDotless(); const string name = ((nodep->name() == "new") ? "new" : prefix + nodep->name() + suffix); - AstCFunc* const cfuncp = new AstCFunc( + AstCFunc* const cfuncp = new AstCFunc{ nodep->fileline(), name, m_scopep, - ((nodep->taskPublic() && rtnvarp) ? rtnvarp->cPubArgType(true, true) : "")); + ((nodep->taskPublic() && rtnvarp) ? rtnvarp->cPubArgType(true, true) : "")}; // It's ok to combine imports because this is just a wrapper; // duplicate wrappers can get merged. cfuncp->dontCombine(!nodep->dpiImport()); @@ -1192,7 +1192,7 @@ private: cfuncp->argTypes(EmitCBaseVisitor::symClassVar()); if (cfuncp->name() == "new") { const string stmt = VIdProtect::protect("_ctor_var_reset") + "(vlSymsp);\n"; - cfuncp->addInitsp(new AstCStmt(nodep->fileline(), stmt)); + cfuncp->addInitsp(new AstCStmt{nodep->fileline(), stmt}); } } if (nodep->dpiContext()) { @@ -1267,8 +1267,8 @@ private: // Return statement if (rtnvscp && nodep->taskPublic()) { - cfuncp->addFinalsp(new AstCReturn( - rtnvscp->fileline(), new AstVarRef(rtnvscp->fileline(), rtnvscp, VAccess::READ))); + cfuncp->addFinalsp(new AstCReturn{ + rtnvscp->fileline(), new AstVarRef{rtnvscp->fileline(), rtnvscp, VAccess::READ}}); } // Replace variable refs relink(cfuncp); @@ -1412,7 +1412,7 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (!VN_IS(nodep->backp(), StmtExpr)) { UASSERT_OBJ(nodep->taskp()->isFunction(), nodep, "func reference to non-function"); - AstVarRef* const outrefp = new AstVarRef(nodep->fileline(), outvscp, VAccess::READ); + AstVarRef* const outrefp = new AstVarRef{nodep->fileline(), outvscp, VAccess::READ}; nodep->replaceWith(outrefp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else { @@ -1634,7 +1634,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) nodep->v3error("Missing argument on non-defaulted argument " << portp->prettyNameQ() << " in function call to " << nodep->taskp()->prettyTypeName()); - newvaluep = new AstConst(nodep->fileline(), AstConst::Unsized32(), 0); + newvaluep = new AstConst{nodep->fileline(), AstConst::Unsized32{}, 0}; } else if (!VN_IS(portp->valuep(), Const)) { // The default value for this port might be a constant // expression that hasn't been folded yet. Try folding it @@ -1648,7 +1648,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) "Unsupported: Non-constant default value in missing argument " << portp->prettyNameQ() << " in function call to " << nodep->taskp()->prettyTypeName()); - newvaluep = new AstConst(nodep->fileline(), AstConst::Unsized32(), 0); + newvaluep = new AstConst{nodep->fileline(), AstConst::Unsized32{}, 0}; } else { newvaluep = newvaluep->cloneTree(true); } @@ -1658,7 +1658,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) // To avoid problems with callee needing to know to deleteTree // or not, we make this into a pin UINFO(9, "Default pin for " << portp << endl); - AstArg* const newp = new AstArg(nodep->fileline(), portp->name(), newvaluep); + AstArg* const newp = new AstArg{nodep->fileline(), portp->name(), newvaluep}; if (tconnects[i].second) { // Have a "nullptr" pin already defined for it VL_DO_CLEAR(tconnects[i].second->unlinkFrBack()->deleteTree(), tconnects[i].second = nullptr); diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index d1f5353d9..ec9d3fa6a 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -413,7 +413,7 @@ private: // equation is heuristic. if (complexity <= actSet.size() * 2) { for (; head != it; ++head) { - new V3GraphEdge(&m_graph, m_alwaysVtxp, head->second, 1); + new V3GraphEdge{&m_graph, m_alwaysVtxp, head->second, 1}; } } } @@ -422,13 +422,13 @@ private: } AstNodeExpr* selectActivity(FileLine* flp, uint32_t acode, const VAccess& access) { - return new AstArraySel(flp, new AstVarRef(flp, m_activityVscp, access), acode); + return new AstArraySel(flp, new AstVarRef{flp, m_activityVscp, access}, acode); } void addActivitySetter(AstNode* insertp, uint32_t code) { FileLine* const fl = insertp->fileline(); - AstAssign* const setterp = new AstAssign(fl, selectActivity(fl, code, VAccess::WRITE), - new AstConst(fl, AstConst::BitTrue())); + AstAssign* const setterp = new AstAssign{fl, selectActivity(fl, code, VAccess::WRITE), + new AstConst{fl, AstConst::BitTrue{}}}; if (AstStmtExpr* const stmtp = VN_CAST(insertp, StmtExpr)) { stmtp->addNextHere(setterp); } else if (AstCFunc* const funcp = VN_CAST(insertp, CFunc)) { @@ -459,12 +459,12 @@ private: v3Global.rootp()->typeTablep()->addTypesp(newScalarDtp); AstRange* const newArange = new AstRange{flp, VNumRange{static_cast(m_activityNumber) - 1, 0}}; - AstNodeDType* const newArrDtp = new AstUnpackArrayDType(flp, newScalarDtp, newArange); + AstNodeDType* const newArrDtp = new AstUnpackArrayDType{flp, newScalarDtp, newArange}; v3Global.rootp()->typeTablep()->addTypesp(newArrDtp); AstVar* const newvarp - = new AstVar(flp, VVarType::MODULETEMP, "__Vm_traceActivity", newArrDtp); + = new AstVar{flp, VVarType::MODULETEMP, "__Vm_traceActivity", newArrDtp}; m_topModp->addStmtsp(newvarp); - AstVarScope* const newvscp = new AstVarScope(flp, m_topScopep, newvarp); + AstVarScope* const newvscp = new AstVarScope{flp, m_topScopep, newvarp}; m_topScopep->addVarsp(newvscp); m_activityVscp = newvscp; @@ -495,7 +495,7 @@ private: : "trace_chg_sub_"; FileLine* const flp = m_topScopep->fileline(); - AstCFunc* const funcp = new AstCFunc(flp, baseName + cvtToStr(funcNump++), m_topScopep); + AstCFunc* const funcp = new AstCFunc{flp, baseName + cvtToStr(funcNump++), m_topScopep}; funcp->isTrace(true); funcp->dontCombine(true); funcp->isLoose(true); @@ -504,7 +504,7 @@ private: // Add it to top scope m_topScopep->addBlocksp(funcp); const auto addInitStr = [funcp, flp](const string& str) -> void { - funcp->addInitsp(new AstCStmt(flp, str)); + funcp->addInitsp(new AstCStmt{flp, str}); }; if (isTopFunc) { // Top functions @@ -519,13 +519,13 @@ private: } // Register function if (full) { - m_regFuncp->addStmtsp(new AstText(flp, "tracep->addFullCb(", true)); + m_regFuncp->addStmtsp(new AstText{flp, "tracep->addFullCb(", true}); } else { - m_regFuncp->addStmtsp(new AstText(flp, "tracep->addChgCb(", true)); + m_regFuncp->addStmtsp(new AstText{flp, "tracep->addChgCb(", true}); } - m_regFuncp->addStmtsp(new AstAddrOfCFunc(flp, funcp)); - m_regFuncp->addStmtsp(new AstText(flp, ", vlSelf", true)); - m_regFuncp->addStmtsp(new AstText(flp, ");\n", true)); + m_regFuncp->addStmtsp(new AstAddrOfCFunc{flp, funcp}); + m_regFuncp->addStmtsp(new AstText{flp, ", vlSelf", true}); + m_regFuncp->addStmtsp(new AstText{flp, ");\n", true}); } else { // Sub functions funcp->argTypes(v3Global.opt.traceClassBase() @@ -551,7 +551,7 @@ private: } } // Add call to top function - AstCCall* const callp = new AstCCall(funcp->fileline(), funcp); + AstCCall* const callp = new AstCCall{funcp->fileline(), funcp}; callp->dtypeSetVoid(); callp->argTypes("bufp"); topFuncp->addStmtsp(callp->makeStmt()); @@ -609,7 +609,7 @@ private: // Add TraceInc node AstTraceInc* const incp - = new AstTraceInc(declp->fileline(), declp, /* full: */ true); + = new AstTraceInc{declp->fileline(), declp, /* full: */ true}; subFuncp->addStmtsp(incp); subStmts += incp->nodeCount(); @@ -669,14 +669,14 @@ private: const bool always = actSet.count(TraceActivityVertex::ACTIVITY_ALWAYS) != 0; AstNodeExpr* condp = nullptr; if (always) { - condp = new AstConst(flp, 1); // Always true, will be folded later + condp = new AstConst{flp, 1}; // Always true, will be folded later } else { for (const uint32_t actCode : actSet) { AstNodeExpr* const selp = selectActivity(flp, actCode, VAccess::READ); - condp = condp ? new AstOr(flp, condp, selp) : selp; + condp = condp ? new AstOr{flp, condp, selp} : selp; } } - ifp = new AstIf(flp, condp); + ifp = new AstIf{flp, condp}; if (!always) ifp->branchPred(VBranchPred::BP_UNLIKELY); subFuncp->addStmtsp(ifp); subStmts += ifp->nodeCount(); @@ -685,7 +685,7 @@ private: // Add TraceInc node AstTraceInc* const incp - = new AstTraceInc(declp->fileline(), declp, /* full: */ false, baseCode); + = new AstTraceInc{declp->fileline(), declp, /* full: */ false, baseCode}; ifp->addThensp(incp); subStmts += incp->nodeCount(); @@ -701,7 +701,7 @@ private: void createCleanupFunction() { FileLine* const fl = m_topScopep->fileline(); - AstCFunc* const cleanupFuncp = new AstCFunc(fl, "trace_cleanup", m_topScopep); + AstCFunc* const cleanupFuncp = new AstCFunc{fl, "trace_cleanup", m_topScopep}; cleanupFuncp->argTypes("void* voidSelf, " + v3Global.opt.traceClassBase() + "* /*unused*/"); cleanupFuncp->isTrace(true); @@ -709,22 +709,22 @@ private: cleanupFuncp->isStatic(true); cleanupFuncp->isLoose(true); m_topScopep->addBlocksp(cleanupFuncp); - cleanupFuncp->addInitsp(new AstCStmt(fl, voidSelfAssign(m_topModp))); - cleanupFuncp->addInitsp(new AstCStmt(fl, symClassAssign())); + cleanupFuncp->addInitsp(new AstCStmt{fl, voidSelfAssign(m_topModp)}); + cleanupFuncp->addInitsp(new AstCStmt{fl, symClassAssign()}); // Register it - m_regFuncp->addStmtsp(new AstText(fl, "tracep->addCleanupCb(", true)); - m_regFuncp->addStmtsp(new AstAddrOfCFunc(fl, cleanupFuncp)); - m_regFuncp->addStmtsp(new AstText(fl, ", vlSelf);\n", true)); + m_regFuncp->addStmtsp(new AstText{fl, "tracep->addCleanupCb(", true}); + m_regFuncp->addStmtsp(new AstAddrOfCFunc{fl, cleanupFuncp}); + m_regFuncp->addStmtsp(new AstText{fl, ", vlSelf);\n", true}); // Clear global activity flag - cleanupFuncp->addStmtsp( - new AstCStmt(m_topScopep->fileline(), string("vlSymsp->__Vm_activity = false;\n"))); + cleanupFuncp->addStmtsp(new AstCStmt{m_topScopep->fileline(), + std::string{"vlSymsp->__Vm_activity = false;\n"}}); // Clear fine grained activity flags for (uint32_t i = 0; i < m_activityNumber; ++i) { - AstNode* const clrp = new AstAssign(fl, selectActivity(fl, i, VAccess::WRITE), - new AstConst(fl, AstConst::BitFalse())); + AstNode* const clrp = new AstAssign{fl, selectActivity(fl, i, VAccess::WRITE), + new AstConst{fl, AstConst::BitFalse{}}}; cleanupFuncp->addStmtsp(clrp); } } @@ -759,7 +759,7 @@ private: // last value vector is more compact // Create the trace registration function - m_regFuncp = new AstCFunc(m_topScopep->fileline(), "trace_register", m_topScopep); + m_regFuncp = new AstCFunc{m_topScopep->fileline(), "trace_register", m_topScopep}; m_regFuncp->argTypes(v3Global.opt.traceClassBase() + "* tracep"); m_regFuncp->isTrace(true); m_regFuncp->slow(true); @@ -789,7 +789,7 @@ private: TraceCFuncVertex* vertexp = dynamic_cast(nodep->user1u().toGraphVertex()); if (!vertexp) { - vertexp = new TraceCFuncVertex(&m_graph, nodep); + vertexp = new TraceCFuncVertex{&m_graph, nodep}; nodep->user1p(vertexp); } return vertexp; @@ -798,7 +798,7 @@ private: TraceActivityVertex* vertexp = dynamic_cast(nodep->user3u().toGraphVertex()); if (!vertexp) { - vertexp = new TraceActivityVertex(&m_graph, nodep, slow); + vertexp = new TraceActivityVertex{&m_graph, nodep, slow}; nodep->user3p(vertexp); } vertexp->slow(slow); @@ -840,7 +840,7 @@ private: UINFO(8, " SubCCALL " << ccallp << endl); V3GraphVertex* const ccallFuncVtxp = getCFuncVertexp(ccallp->funcp()); activityVtxp->slow(ccallp->funcp()->slow()); - new V3GraphEdge(&m_graph, activityVtxp, ccallFuncVtxp, 1); + new V3GraphEdge{&m_graph, activityVtxp, ccallFuncVtxp, 1}; } } } @@ -858,7 +858,7 @@ private: // Cannot treat a coroutine as slow, it may be resumed later const bool slow = nodep->slow() && !nodep->isCoroutine(); V3GraphVertex* const activityVtxp = getActivityVertexp(nodep, slow); - new V3GraphEdge(&m_graph, activityVtxp, funcVtxp, 1); + new V3GraphEdge{&m_graph, activityVtxp, funcVtxp, 1}; } } VL_RESTORER(m_cfuncp); @@ -870,7 +870,7 @@ private: void visit(AstTraceDecl* nodep) override { UINFO(8, " TRACE " << nodep << endl); if (!m_finding) { - V3GraphVertex* const vertexp = new TraceTraceVertex(&m_graph, nodep); + V3GraphVertex* const vertexp = new TraceTraceVertex{&m_graph, nodep}; nodep->user1p(vertexp); UASSERT_OBJ(m_cfuncp, nodep, "Trace not under func"); @@ -885,21 +885,21 @@ private: UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Lvalue in trace? Should be const."); V3GraphVertex* varVtxp = nodep->varScopep()->user1u().toGraphVertex(); if (!varVtxp) { - varVtxp = new TraceVarVertex(&m_graph, nodep->varScopep()); + varVtxp = new TraceVarVertex{&m_graph, nodep->varScopep()}; nodep->varScopep()->user1p(varVtxp); } V3GraphVertex* const traceVtxp = m_tracep->user1u().toGraphVertex(); - new V3GraphEdge(&m_graph, varVtxp, traceVtxp, 1); + new V3GraphEdge{&m_graph, varVtxp, traceVtxp, 1}; if (nodep->varp()->isPrimaryInish() // Always need to trace primary inputs || nodep->varp()->isSigPublic()) { // Or ones user can change - new V3GraphEdge(&m_graph, m_alwaysVtxp, traceVtxp, 1); + new V3GraphEdge{&m_graph, m_alwaysVtxp, traceVtxp, 1}; } } else if (m_cfuncp && m_finding && nodep->access().isWriteOrRW()) { UASSERT_OBJ(nodep->varScopep(), nodep, "No var scope?"); V3GraphVertex* const funcVtxp = getCFuncVertexp(m_cfuncp); V3GraphVertex* const varVtxp = nodep->varScopep()->user1u().toGraphVertex(); if (varVtxp) { // else we're not tracing this signal - new V3GraphEdge(&m_graph, funcVtxp, varVtxp, 1); + new V3GraphEdge{&m_graph, funcVtxp, varVtxp, 1}; } } } diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 3c1b9e255..be5db5f0a 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -205,7 +205,7 @@ private: TristateVertex* vertexp = reinterpret_cast(nodep->user5p()); if (!vertexp) { UINFO(6, " New vertex " << nodep << endl); - vertexp = new TristateVertex(&m_graph, nodep); + vertexp = new TristateVertex{&m_graph, nodep}; nodep->user5p(vertexp); } return vertexp; @@ -297,7 +297,7 @@ public: if (dumpGraph() >= 9) m_graph.dumpDotFilePrefixed("tri_pos__" + nodep->name()); } void associate(AstNode* fromp, AstNode* top) { - new V3GraphEdge(&m_graph, makeVertex(fromp), makeVertex(top), 1); + new V3GraphEdge{&m_graph, makeVertex(fromp), makeVertex(top), 1}; } void deleteVerticesFromSubtreeRecurse(AstNode* nodep) { if (!nodep) return; @@ -485,8 +485,8 @@ class TristateVisitor final : public TristateBaseVisitor { AstVar* getCreateEnVarp(AstVar* invarp) { // Return the master __en for the specified input variable if (!invarp->user1p()) { - AstVar* const newp = new AstVar(invarp->fileline(), VVarType::MODULETEMP, - invarp->name() + "__en", invarp); + AstVar* const newp = new AstVar{invarp->fileline(), VVarType::MODULETEMP, + invarp->name() + "__en", invarp}; UINFO(9, " newenv " << newp << endl); modAddStmtp(invarp, newp); invarp->user1p(newp); // find envar given invarp @@ -537,8 +537,8 @@ class TristateVisitor final : public TristateBaseVisitor { AstVar* getCreateOutVarp(AstVar* invarp) { // Return the master __out for the specified input variable if (!invarp->user4p()) { - AstVar* const newp = new AstVar(invarp->fileline(), VVarType::MODULETEMP, - invarp->name() + "__out", invarp); + AstVar* const newp = new AstVar{invarp->fileline(), VVarType::MODULETEMP, + invarp->name() + "__out", invarp}; UINFO(9, " newout " << newp << endl); modAddStmtp(invarp, newp); invarp->user4p(newp); // find outvar given invarp @@ -546,8 +546,8 @@ class TristateVisitor final : public TristateBaseVisitor { return VN_AS(invarp->user4p(), Var); } AstVar* getCreateUnconnVarp(AstNode* fromp, AstNodeDType* dtypep) { - AstVar* const newp = new AstVar(fromp->fileline(), VVarType::MODULETEMP, - "__Vtriunconn" + cvtToStr(m_unique++), dtypep); + AstVar* const newp = new AstVar{fromp->fileline(), VVarType::MODULETEMP, + "__Vtriunconn" + cvtToStr(m_unique++), dtypep}; UINFO(9, " newunc " << newp << endl); modAddStmtp(newp, newp); return newp; @@ -569,9 +569,9 @@ class TristateVisitor final : public TristateBaseVisitor { AstNodeExpr* newEnableDeposit(AstSel* selp, AstNodeExpr* enp) { // Form a "deposit" instruction for given enable, using existing select as a template. // Would be nicer if we made this a new AST type - AstNodeExpr* const newp = new AstShiftL( - selp->fileline(), new AstExtend(selp->fileline(), enp, selp->fromp()->width()), - selp->lsbp()->cloneTree(false), selp->fromp()->width()); + AstNodeExpr* const newp = new AstShiftL{ + selp->fileline(), new AstExtend{selp->fileline(), enp, selp->fromp()->width()}, + selp->lsbp()->cloneTree(false), selp->fromp()->width()}; return newp; } @@ -622,8 +622,8 @@ class TristateVisitor final : public TristateBaseVisitor { UINFO(8, " Adding driver to var " << varp << endl); AstConst* const constp = newAllZerosOrOnes(varp, false); AstVarRef* const varrefp - = new AstVarRef(varp->fileline(), varp, VAccess::WRITE); - AstNode* const newp = new AstAssignW(varp->fileline(), varrefp, constp); + = new AstVarRef{varp->fileline(), varp, VAccess::WRITE}; + AstNode* const newp = new AstAssignW{varp->fileline(), varrefp, constp}; UINFO(9, " newoev " << newp << endl); varrefp->user1p(newAllZerosOrOnes(varp, false)); nodep->addStmtsp(newp); @@ -993,7 +993,7 @@ class TristateVisitor final : public TristateBaseVisitor { // due to the pinReconnectSimple call in visit AstPin. // We can ignore the output override by making a temporary AstVar* const varp = getCreateUnconnVarp(nodep, nodep->dtypep()); - AstNode* const newp = new AstVarRef(nodep->fileline(), varp, VAccess::WRITE); + AstNode* const newp = new AstVarRef{nodep->fileline(), varp, VAccess::WRITE}; UINFO(9, " const->" << newp << endl); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -1047,7 +1047,7 @@ class TristateVisitor final : public TristateBaseVisitor { // The output enable of a cond is a cond of the output enable of the // two expressions with the same conditional. AstNodeExpr* const enp - = new AstCond(nodep->fileline(), condp->cloneTree(false), en1p, en2p); + = new AstCond{nodep->fileline(), condp->cloneTree(false), en1p, en2p}; UINFO(9, " newcond " << enp << endl); nodep->user1p(enp); // propagate up COND(lhsp->enable, rhsp->enable) thenp->user1p(nullptr); @@ -1086,8 +1086,8 @@ class TristateVisitor final : public TristateBaseVisitor { if (nodep->fromp()->user1p()) { // SEL(VARREF, lsb) AstNodeExpr* const en1p = getEnp(nodep->fromp()); AstNodeExpr* const enp - = new AstSel(nodep->fileline(), en1p, nodep->lsbp()->cloneTree(true), - nodep->widthp()->cloneTree(true)); + = new AstSel{nodep->fileline(), en1p, nodep->lsbp()->cloneTree(true), + nodep->widthp()->cloneTree(true)}; UINFO(9, " newsel " << enp << endl); nodep->user1p(enp); // propagate up SEL(fromp->enable, value) m_tgraph.didProcess(nodep); @@ -1113,11 +1113,11 @@ class TristateVisitor final : public TristateBaseVisitor { // Each half of the concat gets a select of the enable expression AstNodeExpr* const enp = VN_AS(nodep->user1p(), NodeExpr); nodep->user1p(nullptr); - nodep->lhsp()->user1p(new AstSel(nodep->fileline(), enp->cloneTree(true), + nodep->lhsp()->user1p(new AstSel{nodep->fileline(), enp->cloneTree(true), nodep->rhsp()->width(), - nodep->lhsp()->width())); + nodep->lhsp()->width()}); nodep->rhsp()->user1p( - new AstSel(nodep->fileline(), enp, 0, nodep->rhsp()->width())); + new AstSel{nodep->fileline(), enp, 0, nodep->rhsp()->width()}); m_tgraph.didProcess(nodep); } iterateChildren(nodep); @@ -1132,7 +1132,7 @@ class TristateVisitor final : public TristateBaseVisitor { m_tgraph.didProcess(nodep); AstNodeExpr* const en1p = getEnp(expr1p); AstNodeExpr* const en2p = getEnp(expr2p); - AstNodeExpr* const enp = new AstConcat(nodep->fileline(), en1p, en2p); + AstNodeExpr* const enp = new AstConcat{nodep->fileline(), en1p, en2p}; UINFO(9, " newconc " << enp << endl); nodep->user1p(enp); // propagate up CONCAT(lhsp->enable, rhsp->enable) expr1p->user1p(nullptr); @@ -1161,7 +1161,7 @@ class TristateVisitor final : public TristateBaseVisitor { AstNodeExpr* const expr2p = nodep->rhsp()->unlinkFrBack(); AstNodeExpr* enp; if (AstNodeExpr* const en2p = VN_AS(expr2p->user1p(), NodeExpr)) { - enp = new AstAnd(nodep->fileline(), expr1p, en2p); + enp = new AstAnd{nodep->fileline(), expr1p, en2p}; } else { enp = expr1p; } @@ -1211,15 +1211,15 @@ class TristateVisitor final : public TristateBaseVisitor { AstNodeExpr* subexpr1p = expr1p->cloneTree(false); AstNodeExpr* subexpr2p = expr2p->cloneTree(false); if (isAnd) { - subexpr1p = new AstNot(nodep->fileline(), subexpr1p); - subexpr2p = new AstNot(nodep->fileline(), subexpr2p); + subexpr1p = new AstNot{nodep->fileline(), subexpr1p}; + subexpr2p = new AstNot{nodep->fileline(), subexpr2p}; } // calc new output enable - AstNodeExpr* const enp = new AstOr( - nodep->fileline(), new AstAnd(nodep->fileline(), en1p, en2p), - new AstOr(nodep->fileline(), - new AstAnd(nodep->fileline(), en1p->cloneTree(false), subexpr1p), - new AstAnd(nodep->fileline(), en2p->cloneTree(false), subexpr2p))); + AstNodeExpr* const enp = new AstOr{ + nodep->fileline(), new AstAnd{nodep->fileline(), en1p, en2p}, + new AstOr{nodep->fileline(), + new AstAnd{nodep->fileline(), en1p->cloneTree(false), subexpr1p}, + new AstAnd{nodep->fileline(), en2p->cloneTree(false), subexpr2p}}}; UINFO(9, " neweqn " << enp << endl); nodep->user1p(enp); expr1p->user1p(nullptr); @@ -1402,8 +1402,8 @@ class TristateVisitor final : public TristateBaseVisitor { UINFO(4, " COUNTBITS('z)-> " << nodep << endl); VNRelinker relinkHandle; nodep->unlinkFrBack(&relinkHandle); - AstNodeExpr* newp = new AstCountOnes( - nodep->fileline(), new AstVarRef(nodep->fileline(), envarp, VAccess::READ)); + AstNodeExpr* newp = new AstCountOnes{ + nodep->fileline(), new AstVarRef{nodep->fileline(), envarp, VAccess::READ}}; if (nonXp) { // Need to still count '0 or '1 or 'x's if (dropop[0]) { nodep->rhsp()->unlinkFrBack()->deleteTree(); @@ -1417,7 +1417,7 @@ class TristateVisitor final : public TristateBaseVisitor { nodep->fhsp()->unlinkFrBack()->deleteTree(); nodep->fhsp(nonXp->cloneTree(true)); } - newp = new AstAdd(nodep->fileline(), nodep, newp); + newp = new AstAdd{nodep->fileline(), nodep, newp}; } if (debug() >= 9) newp->dumpTree(cout, "-countout: "); relinkHandle.relink(newp); @@ -1527,11 +1527,11 @@ class TristateVisitor final : public TristateBaseVisitor { if (!nodep->exprp()) { // No-connect; covert to empty connection UINFO(5, "Unconnected pin terminate " << nodep << endl); AstVar* const ucVarp = getCreateUnconnVarp(nodep, nodep->modVarp()->dtypep()); - nodep->exprp(new AstVarRef(nodep->fileline(), ucVarp, + nodep->exprp(new AstVarRef{nodep->fileline(), ucVarp, // We converted, so use declaration output state nodep->modVarp()->declDirection().isWritable() ? VAccess::WRITE - : VAccess::READ)); + : VAccess::READ}); m_tgraph.setTristate(ucVarp); // We don't need a driver on the wire; the lack of one will default to tristate } else if (inDeclProcessing) { // Not an input that was a converted tristate @@ -1549,9 +1549,9 @@ class TristateVisitor final : public TristateBaseVisitor { // Create the output enable pin, connect to new signal AstNodeExpr* enrefp; { - AstVar* const enVarp = new AstVar(nodep->fileline(), VVarType::MODULETEMP, + AstVar* const enVarp = new AstVar{nodep->fileline(), VVarType::MODULETEMP, nodep->name() + "__en" + cvtToStr(m_unique++), - VFlagBitPacked(), enModVarp->width()); + VFlagBitPacked{}, enModVarp->width()}; if (inDeclProcessing) { // __en(from-resolver-const) or __en(from-resolver-wire) enModVarp->varType2In(); } else { @@ -1559,15 +1559,15 @@ class TristateVisitor final : public TristateBaseVisitor { } UINFO(9, " newenv " << enVarp << endl); AstPin* const enpinp - = new AstPin(nodep->fileline(), nodep->pinNum(), + = new AstPin{nodep->fileline(), nodep->pinNum(), enModVarp->name(), // should be {var}"__en" - new AstVarRef(nodep->fileline(), enVarp, VAccess::WRITE)); + new AstVarRef{nodep->fileline(), enVarp, VAccess::WRITE}}; enpinp->modVarp(enModVarp); UINFO(9, " newpin " << enpinp << endl); enpinp->user2(U2_BOTH); // don't iterate the pin later nodep->addNextHere(enpinp); m_modp->addStmtsp(enVarp); - enrefp = new AstVarRef(nodep->fileline(), enVarp, VAccess::READ); + enrefp = new AstVarRef{nodep->fileline(), enVarp, VAccess::READ}; UINFO(9, " newvrf " << enrefp << endl); if (debug() >= 9) enpinp->dumpTree(cout, "-pin-ena: "); } @@ -1584,9 +1584,9 @@ class TristateVisitor final : public TristateBaseVisitor { } else { AstNodeExpr* const outexprp = VN_AS(nodep->exprp(), NodeExpr)->cloneTree(false); // Note has lvalue() set - outpinp = new AstPin(nodep->fileline(), nodep->pinNum(), + outpinp = new AstPin{nodep->fileline(), nodep->pinNum(), outModVarp->name(), // should be {var}"__out" - outexprp); + outexprp}; outpinp->modVarp(outModVarp); UINFO(9, " newpin " << outpinp << endl); outpinp->user2(U2_BOTH); // don't iterate the pin later @@ -1695,7 +1695,7 @@ class TristateVisitor final : public TristateBaseVisitor { // Then propagate the enable from the original variable UINFO(9, " Ref-to-tri " << nodep << endl); AstVar* const enVarp = getCreateEnVarp(nodep->varp()); - nodep->user1p(new AstVarRef(nodep->fileline(), enVarp, VAccess::READ)); + nodep->user1p(new AstVarRef{nodep->fileline(), enVarp, VAccess::READ}); } if (m_alhs) {} // NOP; user1() already passed down from assignment } @@ -1709,9 +1709,9 @@ class TristateVisitor final : public TristateBaseVisitor { if (nodep->user2() & U2_GRAPHING) return; // Already processed nodep->user2(U2_GRAPHING); if (nodep->isPulldown() || nodep->isPullup()) { - AstNode* const newp = new AstPull( - nodep->fileline(), new AstVarRef(nodep->fileline(), nodep, VAccess::WRITE), - nodep->isPullup()); + AstNode* const newp = new AstPull{ + nodep->fileline(), new AstVarRef{nodep->fileline(), nodep, VAccess::WRITE}, + nodep->isPullup()}; UINFO(9, " newpul " << newp << endl); nodep->addNextHere(newp); // We'll iterate on the new AstPull later diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 8d768dedb..55d7e63ab 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -95,9 +95,9 @@ private: if (m_assigndlyp) { // Delayed assignments become normal assignments, // then the temp created becomes the delayed assignment - AstNode* const newp = new AstAssign(m_assigndlyp->fileline(), + AstNode* const newp = new AstAssign{m_assigndlyp->fileline(), m_assigndlyp->lhsp()->unlinkFrBackWithNext(), - m_assigndlyp->rhsp()->unlinkFrBackWithNext()); + m_assigndlyp->rhsp()->unlinkFrBackWithNext()}; m_assigndlyp->replaceWith(newp); VL_DO_CLEAR(pushDeletep(m_assigndlyp), m_assigndlyp = nullptr); } @@ -116,23 +116,23 @@ private: UASSERT_OBJ(!needDly, prep, "Should have already converted to non-delay"); VNRelinker replaceHandle; AstNodeExpr* const earliercondp = ifp->condp()->unlinkFrBack(&replaceHandle); - AstNodeExpr* const newp = new AstLogAnd(condp->fileline(), condp, earliercondp); + AstNodeExpr* const newp = new AstLogAnd{condp->fileline(), condp, earliercondp}; UINFO(4, "Edit BOUNDLVALUE " << newp << endl); replaceHandle.relink(newp); } else { AstVar* const varp - = new AstVar(fl, VVarType::MODULETEMP, m_lvboundNames.get(prep), prep->dtypep()); + = new AstVar{fl, VVarType::MODULETEMP, m_lvboundNames.get(prep), prep->dtypep()}; m_modp->addStmtsp(varp); AstNode* const abovep = prep->backp(); // Grab above point before we replace 'prep' - prep->replaceWith(new AstVarRef(fl, varp, VAccess::WRITE)); + prep->replaceWith(new AstVarRef{fl, varp, VAccess::WRITE}); if (m_timingControlp) m_timingControlp->unlinkFrBack(); - AstIf* const newp = new AstIf( + AstIf* const newp = new AstIf{ fl, condp, (needDly ? static_cast(new AstAssignDly{ fl, prep, new AstVarRef{fl, varp, VAccess::READ}, m_timingControlp}) : static_cast(new AstAssign{ - fl, prep, new AstVarRef{fl, varp, VAccess::READ}, m_timingControlp}))); + fl, prep, new AstVarRef{fl, varp, VAccess::READ}, m_timingControlp}))}; newp->branchPred(VBranchPred::BP_LIKELY); newp->isBoundsCheck(true); if (debug() >= 9) newp->dumpTree(cout, " _new: "); @@ -213,15 +213,15 @@ private: // If we got ==1'bx it can never be true (but 1'bx==1'bx can be!) if (((VN_IS(lhsp, Const) && VN_AS(lhsp, Const)->num().isFourState()) || (VN_IS(rhsp, Const) && VN_AS(rhsp, Const)->num().isFourState()))) { - newp = new AstConst(nodep->fileline(), AstConst::WidthedValue(), 1, + newp = new AstConst(nodep->fileline(), AstConst::WidthedValue{}, 1, (VN_IS(nodep, EqCase) ? 0 : 1)); VL_DO_DANGLING(lhsp->deleteTree(), lhsp); VL_DO_DANGLING(rhsp->deleteTree(), rhsp); } else { if (VN_IS(nodep, EqCase)) { - newp = new AstEq(nodep->fileline(), lhsp, rhsp); + newp = new AstEq{nodep->fileline(), lhsp, rhsp}; } else { - newp = new AstNeq(nodep->fileline(), lhsp, rhsp); + newp = new AstNeq{nodep->fileline(), lhsp, rhsp}; } } nodep->replaceWith(newp); @@ -246,20 +246,20 @@ private: nodep->v3warn(E_UNSUPPORTED, "Unsupported: RHS of ==? or !=? must be " "constant to be synthesizable"); // Says spec. // Replace with anything that won't cause more errors - newp = new AstEq(nodep->fileline(), lhsp, rhsp); + newp = new AstEq{nodep->fileline(), lhsp, rhsp}; } else { // X or Z's become mask, ala case statements. - V3Number nummask(rhsp, rhsp->width()); + V3Number nummask{rhsp, rhsp->width()}; nummask.opBitsNonX(VN_AS(rhsp, Const)->num()); - V3Number numval(rhsp, rhsp->width()); + V3Number numval{rhsp, rhsp->width()}; numval.opBitsOne(VN_AS(rhsp, Const)->num()); - AstNodeExpr* const and1p = new AstAnd(nodep->fileline(), lhsp, - new AstConst(nodep->fileline(), nummask)); - AstNodeExpr* const and2p = new AstConst(nodep->fileline(), numval); + AstNodeExpr* const and1p = new AstAnd{nodep->fileline(), lhsp, + new AstConst{nodep->fileline(), nummask}}; + AstNodeExpr* const and2p = new AstConst{nodep->fileline(), numval}; if (VN_IS(nodep, EqWild)) { - newp = new AstEq(nodep->fileline(), and1p, and2p); + newp = new AstEq{nodep->fileline(), and1p, and2p}; } else { - newp = new AstNeq(nodep->fileline(), and1p, and2p); + newp = new AstNeq{nodep->fileline(), and1p, and2p}; } VL_DO_DANGLING(rhsp->deleteTree(), rhsp); } @@ -278,7 +278,7 @@ private: iterateChildren(nodep); // Ahh, we're two state, so this is easy UINFO(4, " ISUNKNOWN->0 " << nodep << endl); - AstConst* const newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); + AstConst* const newp = new AstConst{nodep->fileline(), AstConst::BitFalse{}}; nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -299,7 +299,7 @@ private: nonXp = nodep->fhsp(); } else { // Was all X-s UINFO(4, " COUNTBITS('x)->0 " << nodep << endl); - AstConst* const newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); + AstConst* const newp = new AstConst{nodep->fileline(), AstConst::BitFalse{}}; nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); return; @@ -325,19 +325,19 @@ private: // CONST(num) -> VARREF(newvarp) // -> VAR(newvarp) // -> INITIAL(VARREF(newvarp, OR(num_No_Xs,AND(random,num_1s_Where_X)) - V3Number numb1(nodep, nodep->width()); + V3Number numb1{nodep, nodep->width()}; numb1.opBitsOne(nodep->num()); - V3Number numbx(nodep, nodep->width()); + V3Number numbx{nodep, nodep->width()}; numbx.opBitsXZ(nodep->num()); if (!m_allowXUnique || v3Global.opt.xAssign() != "unique") { // All X bits just become 0; fastest simulation, but not nice - V3Number numnew(nodep, numb1.width()); + V3Number numnew{nodep, numb1.width()}; if (v3Global.opt.xAssign() == "1") { numnew.opOr(numb1, numbx); } else { numnew.opAssign(numb1); } - AstConst* const newp = new AstConst(nodep->fileline(), numnew); + AstConst* const newp = new AstConst{nodep->fileline(), numnew}; nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); UINFO(4, " -> " << newp << endl); @@ -353,18 +353,18 @@ private: VNRelinker replaceHandle; nodep->unlinkFrBack(&replaceHandle); AstNodeVarRef* const newref1p - = new AstVarRef(nodep->fileline(), newvarp, VAccess::READ); + = new AstVarRef{nodep->fileline(), newvarp, VAccess::READ}; replaceHandle.relink(newref1p); // Replace const with varref - AstInitial* const newinitp = new AstInitial( + AstInitial* const newinitp = new AstInitial{ nodep->fileline(), - new AstAssign( + new AstAssign{ nodep->fileline(), - new AstVarRef(nodep->fileline(), newvarp, VAccess::WRITE), - new AstOr(nodep->fileline(), new AstConst(nodep->fileline(), numb1), - new AstAnd(nodep->fileline(), - new AstConst(nodep->fileline(), numbx), - new AstRand(nodep->fileline(), AstRand::Reset{}, - nodep->dtypep(), true))))); + new AstVarRef{nodep->fileline(), newvarp, VAccess::WRITE}, + new AstOr{nodep->fileline(), new AstConst{nodep->fileline(), numb1}, + new AstAnd{nodep->fileline(), + new AstConst{nodep->fileline(), numbx}, + new AstRand{nodep->fileline(), AstRand::Reset{}, + nodep->dtypep(), true}}}}}; // Add inits in front of other statement. // In the future, we should stuff the initp into the module's constructor. AstNode* const afterp = m_modp->stmtsp()->unlinkFrBackWithNext(); @@ -395,10 +395,10 @@ private: // If (maxmsb >= selected), we're in bound AstNodeExpr* condp - = new AstGte(nodep->fileline(), + = new AstGte{nodep->fileline(), 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) // Note below has null backp(); the Edit function knows how to deal with that. condp = V3Const::constifyEdit(condp); @@ -409,10 +409,10 @@ private: // SEL(...) -> COND(LTE(bit<=maxmsb), ARRAYSEL(...), {width{1'bx}}) VNRelinker replaceHandle; nodep->unlinkFrBack(&replaceHandle); - V3Number xnum(nodep, nodep->width()); + V3Number xnum{nodep, nodep->width()}; xnum.setAllBitsX(); - AstNode* const newp = new AstCondBound(nodep->fileline(), condp, nodep, - new AstConst(nodep->fileline(), xnum)); + AstNode* const newp = new AstCondBound{nodep->fileline(), condp, nodep, + new AstConst{nodep->fileline(), xnum}}; if (debug() >= 9) newp->dumpTree(cout, " _new: "); // Link in conditional replaceHandle.relink(newp); @@ -454,10 +454,10 @@ private: // See if the condition is constant true AstNodeExpr* condp - = new AstGte(nodep->fileline(), - new AstConst(nodep->fileline(), AstConst::WidthedValue(), + = new AstGte{nodep->fileline(), + 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. condp = V3Const::constifyEdit(condp); if (condp->isOne()) { @@ -469,14 +469,14 @@ private: // ARRAYSEL(...) -> COND(LT(bitunlinkFrBack(&replaceHandle); - V3Number xnum(nodep, nodep->width()); + V3Number xnum{nodep, nodep->width()}; if (nodep->isString()) { xnum = V3Number{V3Number::String{}, nodep, ""}; } else { xnum.setAllBitsX(); } - AstNode* const newp = new AstCondBound(nodep->fileline(), condp, nodep, - new AstConst(nodep->fileline(), xnum)); + AstNode* const newp = new AstCondBound{nodep->fileline(), condp, nodep, + new AstConst{nodep->fileline(), xnum}}; if (debug() >= 9) newp->dumpTree(cout, " _new: "); // Link in conditional, can blow away temp xor replaceHandle.relink(newp); @@ -486,9 +486,9 @@ private: // ARRAYSEL(...) -> ARRAYSEL(COND(LT(bitbitp()->unlinkFrBack(&replaceHandle); - AstNodeExpr* const newp = new AstCondBound( + AstNodeExpr* const newp = new AstCondBound{ bitp->fileline(), condp, bitp, - new AstConst(bitp->fileline(), AstConst::WidthedValue(), bitp->width(), 0)); + 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);