diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 11d43284a..94dc72306 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -177,8 +177,7 @@ private: // VISITORS //========== Case assertions virtual void visit(AstCase* nodep, AstNUser*) { nodep->iterateChildren(*this); - if (!nodep->user1()) { - nodep->user1(true); + if (!nodep->user1Inc()) { bool has_default=false; for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) { if (itemp->isDefault()) has_default=true; diff --git a/src/V3Ast.h b/src/V3Ast.h index 8b1f3bf6a..5daaa9177 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -822,6 +822,7 @@ public: void user1p(void* userp) { m_user1p=(AstNUser*)(userp); m_user1Cnt=AstUser1InUse::s_userCntGbl; } int user1() const { return user1p()->castInt(); } void user1(int val) { user1p(AstNUser::fromInt(val)); } + int user1Inc() { int v=user1(); user1(v+1); return v; } static void user1ClearTree() { AstUser1InUse::clear(); } // Clear userp()'s across the entire tree AstNUser* user2p() const { @@ -830,6 +831,7 @@ public: void user2p(void* userp) { m_user2p=(AstNUser*)(userp); m_user2Cnt=AstUser2InUse::s_userCntGbl; } int user2() const { return user2p()->castInt(); } void user2(int val) { user2p(AstNUser::fromInt(val)); } + int user2Inc() { int v=user2(); user2(v+1); return v; } static void user2ClearTree() { AstUser2InUse::clear(); } AstNUser* user3p() const { @@ -838,6 +840,7 @@ public: void user3p(void* userp) { m_user3p=(AstNUser*)(userp); m_user3Cnt=AstUser3InUse::s_userCntGbl; } int user3() const { return user3p()->castInt(); } void user3(int val) { user3p(AstNUser::fromInt(val)); } + int user3Inc() { int v=user3(); user3(v+1); return v; } static void user3ClearTree() { AstUser3InUse::clear(); } AstNUser* user4p() const { @@ -846,6 +849,7 @@ public: void user4p(void* userp) { m_user4p=(AstNUser*)(userp); m_user4Cnt=AstUser4InUse::s_userCntGbl; } int user4() const { return user4p()->castInt(); } void user4(int val) { user4p(AstNUser::fromInt(val)); } + int user4Inc() { int v=user4(); user4(v+1); return v; } static void user4ClearTree() { AstUser4InUse::clear(); } AstNUser* user5p() const { @@ -854,6 +858,7 @@ public: void user5p(void* userp) { m_user5p=(AstNUser*)(userp); m_user5Cnt=AstUser5InUse::s_userCntGbl; } int user5() const { return user5p()->castInt(); } void user5(int val) { user5p(AstNUser::fromInt(val)); } + int user5Inc() { int v=user5(); user5(v+1); return v; } static void user5ClearTree() { AstUser5InUse::clear(); } vluint64_t editCount() const { return m_editCount; } diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index 8bf0b224b..a2f5eaadf 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -128,8 +128,7 @@ private: virtual void visit(AstVarScope* nodep, AstNUser*) { if (nodep->isCircular()) { UINFO(8," CIRC "<user1()) { - nodep->user1(true); + if (!nodep->user1Inc()) { genChangeDet(nodep); } } diff --git a/src/V3ClkGater.cpp b/src/V3ClkGater.cpp index 936bfc25a..6704b4acc 100644 --- a/src/V3ClkGater.cpp +++ b/src/V3ClkGater.cpp @@ -704,8 +704,7 @@ class GaterVisitor : public GaterBaseVisitor { virtual void visit(AstAlways* nodep, AstNUser*) { if (debug()>=9) cout<user4()) return; - nodep->user4(1); + if (nodep->user4Inc()) return; clear(); diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 7b03442b4..f9195747b 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -95,31 +95,31 @@ private: // VISITORS virtual void visit(AstCell* nodep, AstNUser*) { nodep->iterateChildren(*this); - nodep->modp()->user1(nodep->modp()->user1() + 1); + nodep->modp()->user1Inc(); } virtual void visit(AstNodeVarRef* nodep, AstNUser*) { nodep->iterateChildren(*this); if (nodep->varScopep()) { - nodep->varScopep()->user1(nodep->varScopep()->user1() + 1); - nodep->varScopep()->varp()->user1(nodep->varScopep()->varp()->user1() + 1); + nodep->varScopep()->user1Inc(); + nodep->varScopep()->varp()->user1Inc(); } if (nodep->varp()) { - nodep->varp()->user1(nodep->varp()->user1() + 1); + nodep->varp()->user1Inc(); } if (nodep->packagep()) { - nodep->packagep()->user1(nodep->packagep()->user1() + 1); + nodep->packagep()->user1Inc(); } } virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) { nodep->iterateChildren(*this); if (nodep->packagep()) { - nodep->packagep()->user1(nodep->packagep()->user1() + 1); + nodep->packagep()->user1Inc(); } } virtual void visit(AstRefDType* nodep, AstNUser*) { nodep->iterateChildren(*this); if (nodep->packagep()) { - nodep->packagep()->user1(nodep->packagep()->user1() + 1); + nodep->packagep()->user1Inc(); } } virtual void visit(AstVarScope* nodep, AstNUser*) { diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index c027bc64a..5de6cba11 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -371,7 +371,7 @@ private: m_modp = NULL; } virtual void visit(AstCell* nodep, AstNUser*) { - nodep->modp()->user3( nodep->modp()->user3() + 1); + nodep->modp()->user3Inc(); nodep->iterateChildren(*this); } virtual void visit(AstPragma* nodep, AstNUser*) { diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 2645ab4a8..fd9932d36 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -89,8 +89,7 @@ private: if (nodep->modVarp()->isOutOnly() && nodep->exprp()->castConst()) nodep->v3error("Output port is connected to a constant pin, electrical short"); // Use user1p on the PIN to indicate we created an assign for this pin - if (!nodep->user1()) { - nodep->user1(1); + if (!nodep->user1Inc()) { // Simplify it V3Inst::pinReconnectSimple(nodep, m_cellp, m_modp); // Make a ASSIGNW (expr, pin) diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 533117fbb..e24a53124 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -77,8 +77,7 @@ private: // VISITs virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) { - if (!nodep->user1()) { - nodep->user1(true); // Process only once. + if (!nodep->user1Inc()) { // Process only once. UINFO(5," "<user1()) { - nodep->user1(true); // Process only once. + if (!nodep->user1Inc()) { // Process only once. if (m_inModDot) { // Already under dot, so this is {modulepart} DOT {modulepart} m_dotText = ""; nodep->lhsp()->iterateAndNext(*this); @@ -194,8 +192,7 @@ private: } virtual void visit(AstNodePreSel* nodep, AstNUser*) { // Excludes simple AstSel, see above - if (!nodep->user1()) { - nodep->user1(true); // Process only once. + if (!nodep->user1Inc()) { // Process only once. if (m_inModDot) { // Already under dot, so this is {modulepart} DOT {modulepart} nodep->v3error("Syntax Error: Range ':', '+:' etc are not allowed in the cell part of a dotted reference"); } else if (m_exp==AstParseRefExp::PX_FUNC) { @@ -217,8 +214,7 @@ private: } } virtual void visit(AstText* nodep, AstNUser*) { - if (!nodep->user1()) { - nodep->user1(true); // Process only once. + if (!nodep->user1Inc()) { // Process only once. if (m_exp != AstParseRefExp::PX_NONE) { UINFO(7," "<user1()) { - nodep->user1(1); + if (!nodep->user1Inc()) { if (nodep->aboveScopep()) nodep->aboveScopep()->iterate(*this); if (nodep->aboveCellp()) nodep->aboveCellp()->iterate(*this); // Always recompute name (as many level above scope may have changed) diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 0923c1689..b41620ecd 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -375,7 +375,7 @@ private: OrderLoopId processMoveLoopCurrent(); string cfuncName(AstNodeModule* modp, AstSenTree* domainp, AstScope* scopep, AstNode* forWhatp) { - modp->user3(1+modp->user3()); + modp->user3Inc(); int funcnum = modp->user3(); string name = (domainp->hasCombo() ? "_combo" : (domainp->hasInitial() ? "_initial" diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 399233e90..3d7937b5f 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -196,9 +196,8 @@ private: } void visitShift (AstNodeBiop* nodep) { // Shifts of > 32/64 bits in C++ will wrap-around and generate non-0s - if (!nodep->user2()) { + if (!nodep->user2Inc()) { UINFO(4," ShiftFix "<user2(true); if (nodep->widthMin()<=64 // Else we'll use large operators which work right // C operator's width must be < maximum shift which is based on Verilog width && nodep->width() < (1LL<rhsp()->widthMin())) { diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 4c80fc67a..7c8fe291e 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -1066,10 +1066,8 @@ private: AstNode* prevInsStmtp = m_insStmtp; m_insMode = IM_BEFORE; m_insStmtp = nodep->stmtsp(); // Might be null if no statements, but we won't use it - if (!nodep->user1()) { // Just one creation needed per function + if (!nodep->user1Inc()) { // Just one creation needed per function // Expand functions in it - nodep->user1(true); - int modes = 0; if (nodep->dpiImport()) modes++; if (nodep->dpiExport()) modes++; diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 65df598e0..21297e31c 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -322,8 +322,7 @@ private: void visit(AstSel* nodep, AstNUser*) { nodep->iterateChildren(*this); - if (!nodep->user1()) { - nodep->user1(1); + if (!nodep->user1Inc()) { // Guard against reading/writing past end of bit vector array int maxmsb = 0; bool lvalue = false; @@ -373,8 +372,7 @@ private: virtual void visit(AstArraySel* nodep, AstNUser*) { nodep->iterateChildren(*this); - if (!nodep->user1()) { - nodep->user1(1); + if (!nodep->user1Inc()) { if (debug()==9) nodep->dumpTree(cout,"-in: "); // Guard against reading/writing past end of arrays AstNode* basefromp = AstArraySel::baseFromp(nodep->fromp());