From eaaf91c82b9aa3874be75cd0ce24546af988d3cf Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 4 Nov 2024 23:55:39 -0500 Subject: [PATCH] Internals: Cleanup VL_RESTORER format in V3LinkLValue. No functional change. --- src/V3LinkLValue.cpp | 175 ++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 104 deletions(-) diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index e0d14cdfb..ceb7acf8c 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -32,13 +32,15 @@ VL_DEFINE_DEBUG_FUNCTIONS; class LinkLValueVisitor final : public VNVisitor { // NODE STATE - // STATE + // STATE - for current visit position (use VL_RESTORER) bool m_setContinuously = false; // Set that var has some continuous assignment - bool m_setStrengthSpecified = false; // Set that var has assignment with strength specified. bool m_setForcedByCode = false; // Set that var is the target of an AstAssignForce/AstRelease bool m_setIfRand = false; // Update VarRefs if var declared as rand bool m_inInitialStatic = false; // Set if inside AstInitialStatic bool m_inFunc = false; // Set if inside AstNodeFTask + + // STATE - TODO + bool m_setStrengthSpecified = false; // Set that var has assignment with strength specified. VAccess m_setRefLvalue; // Set VarRefs to lvalues for pin assignments // VISITs @@ -137,75 +139,57 @@ class LinkLValueVisitor final : public VNVisitor { VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setContinuously); VL_RESTORER(m_setForcedByCode); - { - m_setRefLvalue = VAccess::WRITE; - m_setContinuously = false; - m_setForcedByCode = true; - iterateAndNextNull(nodep->lhsp()); - } + m_setRefLvalue = VAccess::WRITE; + m_setContinuously = false; + m_setForcedByCode = true; + iterateAndNextNull(nodep->lhsp()); } void visit(AstFireEvent* nodep) override { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->operandp()); - } + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->operandp()); } void visit(AstCastDynamic* nodep) override { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->fromp()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->top()); - } + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->fromp()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->top()); } void visit(AstFError* nodep) override { VL_RESTORER(m_setRefLvalue); - { - iterateAndNextNull(nodep->filep()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->strp()); - } + iterateAndNextNull(nodep->filep()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->strp()); } void visit(AstFGetS* nodep) override { VL_RESTORER(m_setRefLvalue); - { - iterateAndNextNull(nodep->filep()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->strgp()); - } + iterateAndNextNull(nodep->filep()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->strgp()); } void visit(AstFRead* nodep) override { VL_RESTORER(m_setRefLvalue); - { - iterateAndNextNull(nodep->filep()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->memp()); - } + iterateAndNextNull(nodep->filep()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->memp()); } void visit(AstFScanF* nodep) override { VL_RESTORER(m_setRefLvalue); - { - iterateAndNextNull(nodep->filep()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->exprsp()); - } + iterateAndNextNull(nodep->filep()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->exprsp()); } void visit(AstFUngetC* nodep) override { VL_RESTORER(m_setRefLvalue); - { - iterateAndNextNull(nodep->filep()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->rhsp()); - } + iterateAndNextNull(nodep->filep()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->rhsp()); } void visit(AstSScanF* nodep) override { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->exprsp()); - } + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->exprsp()); } void visit(AstSysIgnore* nodep) override { // Can't know if lvalue or not; presume not @@ -213,46 +197,36 @@ class LinkLValueVisitor final : public VNVisitor { } void visit(AstRand* nodep) override { VL_RESTORER(m_setRefLvalue); - { - if (!nodep->urandom()) m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->seedp()); - } + if (!nodep->urandom()) m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->seedp()); } void visit(AstReadMem* nodep) override { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->memp()); - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->filenamep()); - iterateAndNextNull(nodep->lsbp()); - iterateAndNextNull(nodep->msbp()); - } + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->memp()); + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->filenamep()); + iterateAndNextNull(nodep->lsbp()); + iterateAndNextNull(nodep->msbp()); } void visit(AstTestPlusArgs* nodep) override { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->searchp()); - } + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->searchp()); } void visit(AstValuePlusArgs* nodep) override { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->searchp()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->outp()); - } + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->searchp()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->outp()); } void visit(AstSFormat* nodep) override { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->lhsp()); - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->fmtp()); - } + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->lhsp()); + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->fmtp()); } void visit(AstNodeDistBiop* nodep) override { VL_RESTORER(m_setRefLvalue); @@ -271,13 +245,11 @@ class LinkLValueVisitor final : public VNVisitor { } void prepost_visit(AstNodeTriop* nodep) { VL_RESTORER(m_setRefLvalue); - { - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->lhsp()); - iterateAndNextNull(nodep->rhsp()); - m_setRefLvalue = VAccess::WRITE; - iterateAndNextNull(nodep->thsp()); - } + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->lhsp()); + iterateAndNextNull(nodep->rhsp()); + m_setRefLvalue = VAccess::WRITE; + iterateAndNextNull(nodep->thsp()); } void visit(AstPreAdd* nodep) override { prepost_visit(nodep); } void visit(AstPostAdd* nodep) override { prepost_visit(nodep); } @@ -287,38 +259,33 @@ class LinkLValueVisitor final : public VNVisitor { // Nodes that change LValue state void visit(AstSel* nodep) override { VL_RESTORER(m_setRefLvalue); - { - iterateAndNextNull(nodep->fromp()); - // Only set lvalues on the from - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->lsbp()); - iterateAndNextNull(nodep->widthp()); - } + iterateAndNextNull(nodep->fromp()); + // Only set lvalues on the from + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->lsbp()); + iterateAndNextNull(nodep->widthp()); } void visit(AstNodeSel* nodep) override { VL_RESTORER(m_setRefLvalue); - { // Only set lvalues on the from - iterateAndNextNull(nodep->fromp()); - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->bitp()); - } + // Only set lvalues on the from + iterateAndNextNull(nodep->fromp()); + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->bitp()); } void visit(AstCellArrayRef* nodep) override { VL_RESTORER(m_setRefLvalue); - { // selp is not an lvalue - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->selp()); - } + // selp is not an lvalue + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->selp()); } void visit(AstNodePreSel* nodep) override { if (AstSelBit* const selbitp = VN_CAST(nodep, SelBit)) selbitp->access(m_setRefLvalue); VL_RESTORER(m_setRefLvalue); - { // Only set lvalues on the from - iterateAndNextNull(nodep->fromp()); - m_setRefLvalue = VAccess::NOCHANGE; - iterateAndNextNull(nodep->rhsp()); - iterateAndNextNull(nodep->thsp()); - } + // Only set lvalues on the from + iterateAndNextNull(nodep->fromp()); + m_setRefLvalue = VAccess::NOCHANGE; + iterateAndNextNull(nodep->rhsp()); + iterateAndNextNull(nodep->thsp()); } void visit(AstMemberSel* nodep) override { if (m_setRefLvalue != VAccess::NOCHANGE) {