From 570631380be7a27416041098b157eacddfe2ea9f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 6 Dec 2020 13:49:44 -0500 Subject: [PATCH] Internal: Misc cleanups. No functional change intended. --- src/V3Active.cpp | 3 +-- src/V3Coverage.cpp | 2 +- src/V3Depth.cpp | 11 ++++++----- src/V3Inst.cpp | 2 +- src/V3LinkParse.cpp | 30 ++++++++++++++++-------------- src/V3Param.cpp | 7 ++----- src/V3Task.cpp | 23 ++++++++++++----------- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 50aa672c2..49b914e9e 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -171,10 +171,9 @@ private: } virtual void visit(AstAssign* nodep) override { if (m_check == CT_SEQ) { - AstNode* las = m_assignp; + VL_RESTORER(m_assignp); m_assignp = nodep; iterateAndNextNull(nodep->lhsp()); - m_assignp = las; } } virtual void visit(AstVarRef* nodep) override { diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 3a4c2f3d9..548d7ce43 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -210,6 +210,7 @@ private: // VISITORS - BOTH virtual void visit(AstNodeModule* nodep) override { AstNodeModule* origModp = m_modp; + VL_RESTORER(m_modp); VL_RESTORER(m_state); { createHandle(nodep); @@ -223,7 +224,6 @@ private: } iterateChildren(nodep); } - m_modp = origModp; } virtual void visit(AstNodeProcedure* nodep) override { iterateProcedure(nodep); } diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 6cc0bc5d7..54b1583ba 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -114,11 +114,12 @@ private: virtual void visit(AstNodeTermop* nodep) override {} virtual void visit(AstNodeMath* nodep) override { // We have some operator defines that use 2 parens, so += 2. - m_depth += 2; - if (m_depth > m_maxdepth) m_maxdepth = m_depth; - iterateChildren(nodep); - m_depth -= 2; - + { + VL_RESTORER(m_depth); + m_depth += 2; + if (m_depth > m_maxdepth) m_maxdepth = m_depth; + iterateChildren(nodep); + } if (m_stmtp && (v3Global.opt.compLimitParens() >= 1) // Else compiler doesn't need it && (m_maxdepth - m_depth) > v3Global.opt.compLimitParens() && !VN_IS(nodep->backp(), NodeStmt) // Not much point if we're about to use it diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index c9bb8acc8..3b1269274 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -351,7 +351,7 @@ private: if (!inputPin && !VN_IS(exprp, VarRef) // V3Const will collapse the SEL with the one we're about to make - && !VN_IS(exprp, Concat) && !VN_IS(exprp, Sel)) { + && !VN_IS(exprp, Concat) && !VN_IS(exprp, Replicate) && !VN_IS(exprp, Sel)) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Per-bit array instantiations " "with output connections to non-wires."); // Note spec allows more complicated matches such as slices and such diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index a3883b91c..ea1d7b2f5 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -96,10 +96,11 @@ private: void visitIterateNodeDType(AstNodeDType* nodep) { if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); - AstNodeDType* upperDtypep = m_dtypep; - m_dtypep = nodep; - iterateChildren(nodep); - m_dtypep = upperDtypep; + { + VL_RESTORER(m_dtypep); + m_dtypep = nodep; + iterateChildren(nodep); + } } } @@ -125,10 +126,11 @@ private: if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); UINFO(5, " " << nodep << endl); - AstNodeModule* upperValueModp = m_valueModp; - m_valueModp = nullptr; - iterateChildren(nodep); - m_valueModp = upperValueModp; + { + VL_RESTORER(m_valueModp); + m_valueModp = nullptr; + iterateChildren(nodep); + } } } virtual void visit(AstNodeDType* nodep) override { visitIterateNodeDType(nodep); } @@ -510,17 +512,17 @@ private: void visitIterateNoValueMod(AstNode* nodep) { // Iterate a node which shouldn't have any local variables moved to an Initial cleanFileline(nodep); - // - AstNodeModule* upperValueModp = m_valueModp; - m_valueModp = nullptr; - iterateChildren(nodep); - m_valueModp = upperValueModp; + { + VL_RESTORER(m_valueModp); + m_valueModp = nullptr; + iterateChildren(nodep); + } } virtual void visit(AstNodeProcedure* nodep) override { visitIterateNoValueMod(nodep); } virtual void visit(AstAlways* nodep) override { + VL_RESTORER(m_inAlways); m_inAlways = true; visitIterateNoValueMod(nodep); - m_inAlways = false; } virtual void visit(AstCover* nodep) override { visitIterateNoValueMod(nodep); } virtual void visit(AstRestrict* nodep) override { visitIterateNoValueMod(nodep); } diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 7a99de07f..f8a0302d6 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -784,12 +784,10 @@ class ParamVisitor final : public AstNVisitor { string fullName(m_modp->hierName()); if (const string* genHierNamep = (string*)cellp->user5p()) { fullName += *genHierNamep; - } - visitCellDeparam(cellp, fullName); - if (const string* genHierNamep = (string*)cellp->user5p()) { cellp->user5p(nullptr); VL_DO_DANGLING(delete genHierNamep, genHierNamep); } + VL_DO_DANGLING(visitCellDeparam(cellp, fullName), cellp); } } } @@ -1050,10 +1048,9 @@ class ParamVisitor final : public AstNVisitor { // Note this clears nodep->genforp(), so begin is no longer special } } else { - string rootHierName(m_generateHierName); + VL_RESTORER(m_generateHierName); m_generateHierName += "." + nodep->prettyName(); iterateChildren(nodep); - m_generateHierName = rootHierName; } } virtual void visit(AstGenFor* nodep) override { // LCOV_EXCL_LINE diff --git a/src/V3Task.cpp b/src/V3Task.cpp index dfd9516bc..e6d620268 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -206,18 +206,19 @@ private: } virtual void visit(AstNodeFTask* nodep) override { UINFO(9, " TASK " << nodep << endl); - TaskBaseVertex* lastVxp = m_curVxp; - m_curVxp = getFTaskVertex(nodep); - if (nodep->dpiImport()) m_curVxp->noInline(true); - if (nodep->classMethod()) m_curVxp->noInline(true); // Until V3Task supports it - if (nodep->isConstructor()) { - m_curVxp->noInline(true); - m_ctorp = nodep; - UASSERT_OBJ(m_classp, nodep, "Ctor not under class"); - m_funcToClassMap[nodep] = m_classp; + { + VL_RESTORER(m_curVxp); + m_curVxp = getFTaskVertex(nodep); + if (nodep->dpiImport()) m_curVxp->noInline(true); + if (nodep->classMethod()) m_curVxp->noInline(true); // Until V3Task supports it + if (nodep->isConstructor()) { + m_curVxp->noInline(true); + m_ctorp = nodep; + UASSERT_OBJ(m_classp, nodep, "Ctor not under class"); + m_funcToClassMap[nodep] = m_classp; + } + iterateChildren(nodep); } - iterateChildren(nodep); - m_curVxp = lastVxp; } virtual void visit(AstPragma* nodep) override { if (nodep->pragType() == AstPragmaType::NO_INLINE_TASK) {