From a4ddc5b3acfa0ab5c3b882aa9d237217f738c92a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 29 Apr 2012 08:55:33 -0400 Subject: [PATCH] Internals: Create user1SetOnce(). No functional change. --- src/V3Assert.cpp | 2 +- src/V3Ast.h | 5 +++++ src/V3Changed.cpp | 2 +- src/V3ClkGater.cpp | 2 +- src/V3Expand.cpp | 22 +++++++++++----------- src/V3Inst.cpp | 2 +- src/V3LinkParse.cpp | 10 +++++----- src/V3Name.cpp | 2 +- src/V3Param.cpp | 6 +++--- src/V3Premit.cpp | 2 +- src/V3Task.cpp | 2 +- src/V3Tristate.cpp | 2 +- src/V3Unknown.cpp | 4 ++-- 13 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 34333848b..4265f1146 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -178,7 +178,7 @@ private: // VISITORS //========== Case assertions virtual void visit(AstCase* nodep, AstNUser*) { nodep->iterateChildren(*this); - if (!nodep->user1Inc()) { + if (!nodep->user1SetOnce()) { 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 ccd353e35..0fde13f57 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -906,6 +906,7 @@ public: int user1() const { return user1p()->castInt(); } void user1(int val) { user1p(AstNUser::fromInt(val)); } int user1Inc() { int v=user1(); user1(v+1); return v; } + int user1SetOnce() { int v=user1(); if (!v) user1(1); return v; } // Better for cache than user1Inc() static void user1ClearTree() { AstUser1InUse::clear(); } // Clear userp()'s across the entire tree AstNUser* user2p() const { @@ -915,6 +916,7 @@ public: int user2() const { return user2p()->castInt(); } void user2(int val) { user2p(AstNUser::fromInt(val)); } int user2Inc() { int v=user2(); user2(v+1); return v; } + int user2SetOnce() { int v=user2(); if (!v) user2(1); return v; } static void user2ClearTree() { AstUser2InUse::clear(); } AstNUser* user3p() const { @@ -924,6 +926,7 @@ public: int user3() const { return user3p()->castInt(); } void user3(int val) { user3p(AstNUser::fromInt(val)); } int user3Inc() { int v=user3(); user3(v+1); return v; } + int user3SetOnce() { int v=user3(); if (!v) user3(1); return v; } static void user3ClearTree() { AstUser3InUse::clear(); } AstNUser* user4p() const { @@ -933,6 +936,7 @@ public: int user4() const { return user4p()->castInt(); } void user4(int val) { user4p(AstNUser::fromInt(val)); } int user4Inc() { int v=user4(); user4(v+1); return v; } + int user4SetOnce() { int v=user4(); if (!v) user4(1); return v; } static void user4ClearTree() { AstUser4InUse::clear(); } AstNUser* user5p() const { @@ -942,6 +946,7 @@ public: int user5() const { return user5p()->castInt(); } void user5(int val) { user5p(AstNUser::fromInt(val)); } int user5Inc() { int v=user5(); user5(v+1); return v; } + int user5SetOnce() { int v=user5(); if (!v) user5(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 ae3581637..e3ae73d7c 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -160,7 +160,7 @@ private: virtual void visit(AstVarScope* nodep, AstNUser*) { if (nodep->isCircular()) { UINFO(8," CIRC "<user1Inc()) { + if (!nodep->user1SetOnce()) { genChangeDet(nodep); } } diff --git a/src/V3ClkGater.cpp b/src/V3ClkGater.cpp index 3881ac8d5..64c46319a 100644 --- a/src/V3ClkGater.cpp +++ b/src/V3ClkGater.cpp @@ -705,7 +705,7 @@ class GaterVisitor : public GaterBaseVisitor { virtual void visit(AstAlways* nodep, AstNUser*) { if (debug()>=9) cout<user4Inc()) return; + if (nodep->user4SetOnce()) return; clear(); diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 487affbc4..6a2baa0f3 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -311,7 +311,7 @@ private: // VISITORS virtual void visit(AstExtend* nodep, AstNUser*) { - if (nodep->user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); if (nodep->isWide()) { // See under ASSIGN(EXTEND) @@ -350,7 +350,7 @@ private: } virtual void visit(AstSel* nodep, AstNUser*) { - if (nodep->user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); // Remember, Sel's may have non-integer rhs, so need to optimize for that! if (nodep->widthMin()!=(int)nodep->widthConst()) nodep->v3fatalSrc("Width mismatch"); @@ -647,7 +647,7 @@ private: } virtual void visit(AstConcat* nodep, AstNUser*) { - if (nodep->user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); if (nodep->isWide()) { // See under ASSIGN(WIDE) @@ -687,7 +687,7 @@ private: } virtual void visit(AstReplicate* nodep, AstNUser*) { - if (nodep->user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); if (nodep->isWide()) { // See under ASSIGN(WIDE) @@ -748,7 +748,7 @@ private: } virtual void visit(AstChangeXor* nodep, AstNUser*) { - if (nodep->user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); UINFO(8," Wordize ChangeXor "< (0=={or{for each_word{WORDSEL(lhs,#)^WORDSEL(rhs,#)}}} @@ -763,7 +763,7 @@ private: } void visitEqNeq(AstNodeBiop* nodep) { - if (nodep->user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); if (nodep->lhsp()->isWide()) { UINFO(8," Wordize EQ/NEQ "<user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); if (nodep->lhsp()->isWide()) { UINFO(8," Wordize REDOR "<user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); if (nodep->lhsp()->isWide()) { UINFO(8," Wordize REDAND "<user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once nodep->iterateChildren(*this); if (nodep->lhsp()->isWide()) { UINFO(8," Wordize REDXOR "<user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once m_stmtp = nodep; nodep->iterateChildren(*this); m_stmtp = NULL; } virtual void visit(AstNodeAssign* nodep, AstNUser*) { - if (nodep->user1Inc()) return; // Process once + if (nodep->user1SetOnce()) return; // Process once m_stmtp = nodep; nodep->iterateChildren(*this); bool did = false; diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 932d3d6af..d8eb60c4b 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -85,7 +85,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->user1Inc()) { + if (!nodep->user1SetOnce()) { // Simplify it V3Inst::pinReconnectSimple(nodep, m_cellp, m_modp, false); // Make a ASSIGNW (expr, pin) diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index ae3bef99e..f588757a1 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -75,7 +75,7 @@ private: } void cleanFileline(AstNode* nodep) { - if (!nodep->user2Inc()) { // Process once + if (!nodep->user2SetOnce()) { // Process once // We make all filelines unique per AstNode. This allows us to // later turn off messages on a fileline when an issue is found // so that messages on replicated blocks occur only once, @@ -98,7 +98,7 @@ private: // VISITs virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) { - if (!nodep->user1Inc()) { // Process only once. + if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); UINFO(5," "<user1Inc()) { // Process only once. + if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); if (m_inModDot) { // Already under dot, so this is {modulepart} DOT {modulepart} m_dotText = ""; @@ -216,7 +216,7 @@ private: } virtual void visit(AstNodePreSel* nodep, AstNUser*) { // Excludes simple AstSel, see above - if (!nodep->user1Inc()) { // Process only once. + if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); 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"); @@ -239,7 +239,7 @@ private: } } virtual void visit(AstText* nodep, AstNUser*) { - if (!nodep->user1Inc()) { // Process only once. + if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); if (m_exp != AstParseRefExp::PX_NONE) { UINFO(7," "<user1Inc()) { + if (!nodep->user1SetOnce()) { 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/V3Param.cpp b/src/V3Param.cpp index f75edffcc..ae13d4298 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -130,7 +130,7 @@ private: // we process in top->bottom order too. while (!m_todoModps.empty()) { AstNodeModule* nodep = m_todoModps.front(); m_todoModps.pop_front(); - if (!nodep->user5Inc()) { // Process once; note clone() must clear so we do it again + if (!nodep->user5SetOnce()) { // Process once; note clone() must clear so we do it again UINFO(4," MOD "<iterateChildren(*this); // Note this may add to m_todoModps @@ -158,7 +158,7 @@ private: // Make sure all parameters are constantified virtual void visit(AstVar* nodep, AstNUser*) { - if (!nodep->user5Inc()) { // Process once + if (!nodep->user5SetOnce()) { // Process once nodep->iterateChildren(*this); if (nodep->isParam()) { if (!nodep->hasSimpleInit()) { nodep->v3fatalSrc("Parameter without initial value"); } @@ -364,7 +364,7 @@ void ParamVisitor::visit(AstCell* nodep, AstNUser*) { // However links outside the module (like on the upper cells) will not. modp = nodep->modp()->cloneTree(false); modp->name(newname); - modp->user5(0); // We need to re-recurse this module once changed + modp->user5(false); // We need to re-recurse this module once changed nodep->modp()->addNextHere(modp); // Keep tree sorted by cell occurrences m_modNameMap.insert(make_pair(modp->name(), ModInfo(modp))); diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index e700d1776..2997f8bb0 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -197,7 +197,7 @@ private: } void visitShift (AstNodeBiop* nodep) { // Shifts of > 32/64 bits in C++ will wrap-around and generate non-0s - if (!nodep->user2Inc()) { + if (!nodep->user2SetOnce()) { UINFO(4," ShiftFix "<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 diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 901abf63a..9b95a902b 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -1075,7 +1075,7 @@ 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->user1Inc()) { // Just one creation needed per function + if (!nodep->user1SetOnce()) { // Just one creation needed per function // Expand functions in it int modes = 0; if (nodep->dpiImport()) modes++; diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 1cc1afcce..153b75e7a 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -627,7 +627,7 @@ class TristateVisitor : public TristateBaseVisitor { } virtual void visit(AstVar* nodep, AstNUser*) { - if (nodep->user2Inc()) return; // Already processed + if (nodep->user2SetOnce()) return; // Already processed UINFO(9," "<iterateChildren(*this); - if (!nodep->user1Inc()) { + if (!nodep->user1SetOnce()) { // Guard against reading/writing past end of bit vector array int maxmsb = 0; bool lvalue = false; @@ -373,7 +373,7 @@ private: virtual void visit(AstArraySel* nodep, AstNUser*) { nodep->iterateChildren(*this); - if (!nodep->user1Inc()) { + if (!nodep->user1SetOnce()) { if (debug()==9) nodep->dumpTree(cout,"-in: "); // Guard against reading/writing past end of arrays AstNode* basefromp = AstArraySel::baseFromp(nodep->fromp());