Internals: Create user1SetOnce(). No functional change.

This commit is contained in:
Wilson Snyder 2012-04-29 08:55:33 -04:00
parent 91e4010039
commit a4ddc5b3ac
13 changed files with 34 additions and 29 deletions

View File

@ -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;

View File

@ -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; }

View File

@ -160,7 +160,7 @@ private:
virtual void visit(AstVarScope* nodep, AstNUser*) {
if (nodep->isCircular()) {
UINFO(8," CIRC "<<nodep<<endl);
if (!nodep->user1Inc()) {
if (!nodep->user1SetOnce()) {
genChangeDet(nodep);
}
}

View File

@ -705,7 +705,7 @@ class GaterVisitor : public GaterBaseVisitor {
virtual void visit(AstAlways* nodep, AstNUser*) {
if (debug()>=9) cout<<endl<<endl<<endl;
UINFO(5, "Gater: ALWAYS: "<<nodep<<endl);
if (nodep->user4Inc()) return;
if (nodep->user4SetOnce()) return;
clear();

View File

@ -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 "<<nodep<<endl);
// -> (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 "<<nodep<<endl);
@ -789,7 +789,7 @@ private:
virtual void visit(AstNeq* nodep, AstNUser*) { visitEqNeq (nodep); }
virtual void visit(AstRedOr* nodep, AstNUser*) {
if (nodep->user1Inc()) return; // Process once
if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this);
if (nodep->lhsp()->isWide()) {
UINFO(8," Wordize REDOR "<<nodep<<endl);
@ -813,7 +813,7 @@ private:
}
}
virtual void visit(AstRedAnd* nodep, AstNUser*) {
if (nodep->user1Inc()) return; // Process once
if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this);
if (nodep->lhsp()->isWide()) {
UINFO(8," Wordize REDAND "<<nodep<<endl);
@ -842,7 +842,7 @@ private:
}
}
virtual void visit(AstRedXor* nodep, AstNUser*) {
if (nodep->user1Inc()) return; // Process once
if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this);
if (nodep->lhsp()->isWide()) {
UINFO(8," Wordize REDXOR "<<nodep<<endl);
@ -861,13 +861,13 @@ private:
}
virtual void visit(AstNodeStmt* nodep, AstNUser*) {
if (nodep->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;

View File

@ -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)

View File

@ -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," "<<nodep<<endl);
checkExpected(nodep);
@ -187,7 +187,7 @@ private:
}
}
virtual void visit(AstSelBit* nodep, AstNUser*) {
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}
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," "<<nodep<<endl);

View File

@ -110,7 +110,7 @@ private:
}
}
virtual void visit(AstScope* nodep, AstNUser*) {
if (!nodep->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)

View File

@ -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 "<<nodep<<endl);
nodep->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)));

View File

@ -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 "<<nodep<<endl);
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

View File

@ -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++;

View File

@ -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," "<<nodep<<endl);
// Adds all vars to the m_varvec list so that we can detect undriven
// inouts and output and make them drive Z.

View File

@ -323,7 +323,7 @@ private:
void visit(AstSel* nodep, AstNUser*) {
nodep->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());