Internals: Move iterators to AstNVisitor to avoid null this.

This commit is contained in:
Wilson Snyder 2018-05-10 20:55:37 -04:00
parent 489f58011b
commit 05db8ce6c8
71 changed files with 1145 additions and 1099 deletions

View File

@ -268,8 +268,8 @@ technique lifted from graph traversal packages).
A visitor first clears the one it wants to use by calling A visitor first clears the one it wants to use by calling
C<AstNode::user#ClearTree()>, then it can mark any node's user() with whatever C<AstNode::user#ClearTree()>, then it can mark any node's user() with whatever
data it wants. Readers just call C<< nodep->user() >>, but may need to cast data it wants. Readers just call C<< nodep->user() >>, but may need to cast
appropriately, so you'll often see C<< nodep->userp()->castSOMETYPE() >>. At appropriately, so you'll often see C<< VN_CAST(nodep->userp(), SOMETYPE) >>.
the top of each visitor are comments describing how the C<user()> stuff At the top of each visitor are comments describing how the C<user()> stuff
applies to that visitor class. For example: applies to that visitor class. For example:
// NODE STATE // NODE STATE
@ -299,16 +299,13 @@ as it slows the program down to have to pass vup everywhere.)
=head2 Iterators =head2 Iterators
C<AstNode> provides a set of iterators to facilitate walking over the C<AstNVisitor> provides a set of iterators to facilitate walking over the
tree. Each takes two arguments, a visitor, C<v>, of type C<AstNVisitor> and tree. Each operates on the current C<AstNVisitor> class (as this) and takes
an optional pointer user data, C<vup>, of type C<AstNUser*>. The second is an argument type C<AstNode*>.
one of the ways to pass parameters to visitors described in L</Visitor
Functions>, but its use is now deprecated and should I<not> be used for new
visitor classes.
=over 4 =over 4
=item C<iterate()> =item C<iterate>
This just applies the C<accept> method of the C<AstNode> to the visitor This just applies the C<accept> method of the C<AstNode> to the visitor
function. function.
@ -349,9 +346,9 @@ to be aware that calling iteration may cause the children to change. For
example: example:
// nodep->lhsp() is 0x1234000 // nodep->lhsp() is 0x1234000
nodep->lhsp()->iterateAndNext(...); // and under covers nodep->lhsp() changes iterateAndNextNull(nodep->lhsp()); // and under covers nodep->lhsp() changes
// nodep->lhsp() is 0x5678400 // nodep->lhsp() is 0x5678400
nodep->lhsp()->iterateAndNext(...); iterateAndNextNull(nodep->lhsp());
Will work fine, as even if the first iterate causes a new node to take the Will work fine, as even if the first iterate causes a new node to take the
place of the lhsp(), that edit will update nodep->lhsp() and the second place of the lhsp(), that edit will update nodep->lhsp() and the second
@ -359,9 +356,9 @@ call will correctly see the change. Alternatively:
lp = nodep->lhsp(); lp = nodep->lhsp();
// nodep->lhsp() is 0x1234000, lp is 0x1234000 // nodep->lhsp() is 0x1234000, lp is 0x1234000
lp->iterateAndNext(...); **lhsp=NULL;** // and under covers nodep->lhsp() changes iterateAndNextNull(lp); **lhsp=NULL;** // and under covers nodep->lhsp() changes
// nodep->lhsp() is 0x5678400, lp is 0x1234000 // nodep->lhsp() is 0x5678400, lp is 0x1234000
lp->iterateAndNext(...); iterateAndNextNull(lp);
This will cause bugs or a core dump, as lp is a dangling pointer. Thus it This will cause bugs or a core dump, as lp is a dangling pointer. Thus it
is advisable to set lhsp=NULL shown in the *'s above to make sure these is advisable to set lhsp=NULL shown in the *'s above to make sure these
@ -370,7 +367,7 @@ V3Width is to use acceptSubtreeReturnEdits, which operates on a single node
and returns the new pointer if any. Note acceptSubtreeReturnEdits does not and returns the new pointer if any. Note acceptSubtreeReturnEdits does not
follow nextp() links. follow nextp() links.
lp = lp->acceptSubtreeReturnEdits() lp = acceptSubtreeReturnEdits(lp)
=head2 Identifying derived classes =head2 Identifying derived classes
@ -379,16 +376,16 @@ dealing with. For example a visitor might not implement separate C<visit>
methods for C<AstIf> and C<AstGenIf>, but just a single method for the base methods for C<AstIf> and C<AstGenIf>, but just a single method for the base
class: class:
void visit (AstNodeIf* nodep, AstNUser* vup) void visit (AstNodeIf* nodep)
However that method might want to specify additional code if it is called However that method might want to specify additional code if it is called
for C<AstGenIf>. Verilator does this by providing a C<castSOMETYPE()> for C<AstGenIf>. Verilator does this by providing a C<VN_CAST>
method for each possible node type, using C++ C<dynamic_cast>. This either method for each possible node type, using C++ C<dynamic_cast>. This either
returns a pointer to the object cast to that type (if it is of class returns a pointer to the object cast to that type (if it is of class
C<SOMETYPE>, or a derived class of C<SOMETYPE>) or else NULL. So our C<SOMETYPE>, or a derived class of C<SOMETYPE>) or else NULL. So our
C<visit> method could use: C<visit> method could use:
if (nodep->castAstGenIf()) { if (VN_CAST(nodep, AstGenIf) {
<code specific to AstGenIf> <code specific to AstGenIf>
} }

View File

@ -78,7 +78,7 @@ private:
m_iActivep = NULL; m_iActivep = NULL;
m_cActivep = NULL; m_cActivep = NULL;
m_activeVec.clear(); m_activeVec.clear();
nodep->iterateChildren(*this); iterateChildren(nodep);
// Don't clear scopep, the namer persists beyond this visit // Don't clear scopep, the namer persists beyond this visit
} }
virtual void visit(AstSenTree* nodep) { virtual void visit(AstSenTree* nodep) {
@ -91,7 +91,7 @@ private:
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// METHODS // METHODS
public: public:
@ -154,7 +154,7 @@ public:
} }
virtual ~ActiveNamer() {} virtual ~ActiveNamer() {}
void main(AstScope* nodep) { void main(AstScope* nodep) {
nodep->accept(*this); iterate(nodep);
} }
}; };
@ -193,7 +193,7 @@ private:
if (m_check == CT_SEQ) { if (m_check == CT_SEQ) {
AstNode* las = m_assignp; AstNode* las = m_assignp;
m_assignp = nodep; m_assignp = nodep;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_assignp = las; m_assignp = las;
} }
} }
@ -217,7 +217,7 @@ private:
} }
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -225,7 +225,7 @@ public:
m_alwaysp = nodep; m_alwaysp = nodep;
m_check = check; m_check = check;
m_assignp = NULL; m_assignp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~ActiveDlyVisitor() {} virtual ~ActiveDlyVisitor() {}
}; };
@ -252,7 +252,7 @@ private:
// Clear last scope's names, and collect this scope's existing names // Clear last scope's names, and collect this scope's existing names
m_namer.main(nodep); m_namer.main(nodep);
m_scopeFinalp = NULL; m_scopeFinalp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
// Actives are being formed, so we can ignore any already made // Actives are being formed, so we can ignore any already made
@ -325,7 +325,7 @@ private:
// Read sensitivitues // Read sensitivitues
m_itemCombo = false; m_itemCombo = false;
m_itemSequent = false; m_itemSequent = false;
if (oldsensesp) oldsensesp->iterateAndNext(*this); iterateAndNextNull(oldsensesp);
bool combo = m_itemCombo; bool combo = m_itemCombo;
bool sequent = m_itemSequent; bool sequent = m_itemSequent;
@ -399,7 +399,7 @@ private:
&& subitemp->edgeType() != AstEdgeType::ET_NEGEDGE) { && subitemp->edgeType() != AstEdgeType::ET_NEGEDGE) {
nodep->v3fatalSrc("Strange activity type under SenGate"); nodep->v3fatalSrc("Strange activity type under SenGate");
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSenItem* nodep) { virtual void visit(AstSenItem* nodep) {
if (nodep->edgeType() == AstEdgeType::ET_ANYEDGE) { if (nodep->edgeType() == AstEdgeType::ET_ANYEDGE) {
@ -421,7 +421,7 @@ private:
virtual void visit(AstVarScope* nodep) {} virtual void visit(AstVarScope* nodep) {}
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -429,7 +429,7 @@ public:
m_scopeFinalp = NULL; m_scopeFinalp = NULL;
m_itemCombo = false; m_itemCombo = false;
m_itemSequent = false; m_itemSequent = false;
nodep->accept(*this); iterate(nodep);
} }
virtual ~ActiveVisitor() {} virtual ~ActiveVisitor() {}
}; };

View File

@ -68,14 +68,14 @@ private:
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
m_topscopep = nodep; m_topscopep = nodep;
m_finder.main(m_topscopep); m_finder.main(m_topscopep);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_topscopep = NULL; m_topscopep = NULL;
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
// Create required actives and add to module // Create required actives and add to module
// We can start ordering at a module, or a scope // We can start ordering at a module, or a scope
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
UINFO(4," ACTIVE "<<nodep<<endl); UINFO(4," ACTIVE "<<nodep<<endl);
@ -118,7 +118,7 @@ private:
nodep->sensesp(wantp); nodep->sensesp(wantp);
} }
// No need to do statements under it, they're already moved. // No need to do statements under it, they're already moved.
//nodep->iterateChildren(*this); //iterateChildren(nodep);
} }
virtual void visit(AstInitial* nodep) { virtual void visit(AstInitial* nodep) {
nodep->v3fatalSrc("Node should have been under ACTIVE"); nodep->v3fatalSrc("Node should have been under ACTIVE");
@ -143,13 +143,13 @@ private:
virtual void visit(AstVarScope* nodep) {} virtual void visit(AstVarScope* nodep) {}
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit ActiveTopVisitor(AstNetlist* nodep) { explicit ActiveTopVisitor(AstNetlist* nodep) {
m_topscopep = NULL; m_topscopep = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~ActiveTopVisitor() {} virtual ~ActiveTopVisitor() {}
}; };

View File

@ -197,14 +197,14 @@ private:
// If this statement ends with 'else if', then nextIf will point to the // If this statement ends with 'else if', then nextIf will point to the
// nextIf statement. Otherwise it will be null. // nextIf statement. Otherwise it will be null.
AstNodeIf* nextifp = dynamic_cast<AstNodeIf*>(ifp->elsesp()); AstNodeIf* nextifp = dynamic_cast<AstNodeIf*>(ifp->elsesp());
ifp->condp()->iterateAndNext(*this); iterateAndNextNull(ifp->condp());
// Recurse into the true case. // Recurse into the true case.
ifp->ifsp()->iterateAndNext(*this); iterateAndNextNull(ifp->ifsp());
// If the last else is not an else if, recurse into that too. // If the last else is not an else if, recurse into that too.
if (ifp->elsesp() && !nextifp) { if (ifp->elsesp() && !nextifp) {
ifp->elsesp()->iterateAndNext(*this); iterateAndNextNull(ifp->elsesp());
} }
// Build a bitmask of the true predicates // Build a bitmask of the true predicates
@ -242,13 +242,13 @@ private:
nodep->replaceWith(checkifp); nodep->replaceWith(checkifp);
pushDeletep(nodep); pushDeletep(nodep);
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
// VISITORS //========== Case assertions // VISITORS //========== Case assertions
virtual void visit(AstCase* nodep) { virtual void visit(AstCase* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->user1SetOnce()) { if (!nodep->user1SetOnce()) {
bool has_default=false; bool has_default=false;
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) { for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) {
@ -306,7 +306,7 @@ private:
// VISITORS //========== Statements // VISITORS //========== Statements
virtual void visit(AstDisplay* nodep) { virtual void visit(AstDisplay* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Replace the special types with standard text // Replace the special types with standard text
if (nodep->displayType()==AstDisplayType::DT_INFO) { if (nodep->displayType()==AstDisplayType::DT_INFO) {
replaceDisplay(nodep, "-Info"); replaceDisplay(nodep, "-Info");
@ -319,13 +319,13 @@ private:
} }
virtual void visit(AstNodePslCoverOrAssert* nodep) { virtual void visit(AstNodePslCoverOrAssert* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name()); if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name());
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(), newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
nodep->stmtsp(), nodep->name()); VL_DANGLING(nodep); nodep->stmtsp(), nodep->name()); VL_DANGLING(nodep);
} }
virtual void visit(AstVAssert* nodep) { virtual void visit(AstVAssert* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
newVAssertion(nodep, nodep->propp()); VL_DANGLING(nodep); newVAssertion(nodep, nodep->propp()); VL_DANGLING(nodep);
++m_statAsSV; ++m_statAsSV;
} }
@ -333,7 +333,7 @@ private:
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
// //
nodep->iterateChildren(*this); iterateChildren(nodep);
// Reset defaults // Reset defaults
m_modp = NULL; m_modp = NULL;
} }
@ -343,13 +343,13 @@ private:
AstBegin* lastp = m_beginp; AstBegin* lastp = m_beginp;
{ {
m_beginp = nodep; m_beginp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_beginp = lastp; m_beginp = lastp;
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -357,7 +357,7 @@ public:
m_beginp = NULL; m_beginp = NULL;
m_modp = NULL; m_modp = NULL;
// Process // Process
nodep->accept(*this); iterate(nodep);
} }
virtual ~AssertVisitor() { virtual ~AssertVisitor() {
V3Stats::addStat("Assertions, PSL asserts", m_statAsPsl); V3Stats::addStat("Assertions, PSL asserts", m_statAsPsl);

View File

@ -89,12 +89,12 @@ private:
virtual void visit(AstNodePslCoverOrAssert* nodep) { virtual void visit(AstNodePslCoverOrAssert* nodep) {
if (nodep->sentreep()) return; // Already processed if (nodep->sentreep()) return; // Already processed
clearAssertInfo(); clearAssertInfo();
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->sentreep(newSenTree(nodep)); nodep->sentreep(newSenTree(nodep));
clearAssertInfo(); clearAssertInfo();
} }
virtual void visit(AstPslClocked* nodep) { virtual void visit(AstPslClocked* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_senip) { if (m_senip) {
nodep->v3error("Unsupported: Only one PSL clock allowed per assertion"); nodep->v3error("Unsupported: Only one PSL clock allowed per assertion");
} }
@ -112,12 +112,12 @@ private:
pushDeletep(nodep); VL_DANGLING(nodep); pushDeletep(nodep); VL_DANGLING(nodep);
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Reset defaults // Reset defaults
m_seniDefaultp = NULL; m_seniDefaultp = NULL;
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -126,7 +126,7 @@ public:
m_seniDefaultp = NULL; m_seniDefaultp = NULL;
clearAssertInfo(); clearAssertInfo();
// Process // Process
nodep->accept(*this); iterate(nodep);
} }
virtual ~AssertPreVisitor() {} virtual ~AssertPreVisitor() {}
}; };

View File

@ -290,7 +290,7 @@ void AstNode::addNextHere(AstNode* newp) {
// Add to m_nextp on exact node passed, not at the end. // Add to m_nextp on exact node passed, not at the end.
// This could be at head, tail, or both (single) // This could be at head, tail, or both (single)
// New could be head of single node, or list // New could be head of single node, or list
UDEBUGONLY(UASSERT(dynamic_cast<AstNode*>(this),"this should not be NULL");); UDEBUGONLY(UASSERT(dynamic_cast<const AstNode*>(this),"this should not be NULL"););
UASSERT(newp,"Null item passed to addNext"); UASSERT(newp,"Null item passed to addNext");
UASSERT(newp->backp()==NULL,"New node (back) already assigned?"); UASSERT(newp->backp()==NULL,"New node (back) already assigned?");
this->debugTreeChange("-addHereThs: ", __LINE__, false); this->debugTreeChange("-addHereThs: ", __LINE__, false);
@ -646,7 +646,7 @@ AstNode* AstNode::cloneTreeIterList() {
} }
AstNode* AstNode::cloneTree(bool cloneNextLink) { AstNode* AstNode::cloneTree(bool cloneNextLink) {
UDEBUGONLY(UASSERT(dynamic_cast<AstNode*>(this),"this should not be NULL");); UDEBUGONLY(UASSERT(dynamic_cast<const AstNode*>(this),"this should not be NULL"););
this->debugTreeChange("-cloneThs: ", __LINE__, cloneNextLink); this->debugTreeChange("-cloneThs: ", __LINE__, cloneNextLink);
cloneClearTree(); cloneClearTree();
AstNode* newp; AstNode* newp;
@ -802,7 +802,7 @@ void AstNode::iterateAndNext(AstNVisitor& v) {
} }
void AstNode::iterateListBackwards(AstNVisitor& v) { void AstNode::iterateListBackwards(AstNVisitor& v) {
UDEBUGONLY(UASSERT(dynamic_cast<AstNode*>(this),"this should not be NULL");); UDEBUGONLY(UASSERT(dynamic_cast<const AstNode*>(this),"this should not be NULL"););
AstNode* nodep=this; AstNode* nodep=this;
while (nodep->m_nextp) nodep=nodep->m_nextp; while (nodep->m_nextp) nodep=nodep->m_nextp;
while (nodep) { while (nodep) {
@ -822,8 +822,8 @@ void AstNode::iterateChildrenBackwards(AstNVisitor& v) {
void AstNode::iterateAndNextConst(AstNVisitor& v) { void AstNode::iterateAndNextConst(AstNVisitor& v) {
// Keep following the current list even if edits change it // Keep following the current list even if edits change it
if (!this) return; // A few cases could be cleaned up, but want symmetry with iterateAndNext UDEBUGONLY(UASSERT(dynamic_cast<const AstNode*>(this),"this should not be NULL"););
for (AstNode* nodep=this; nodep; ) { // effectively: if (!this) return; // Callers rely on this for (AstNode* nodep=this; nodep; ) {
AstNode* nnextp = nodep->m_nextp; AstNode* nnextp = nodep->m_nextp;
ASTNODE_PREFETCH(nnextp); ASTNODE_PREFETCH(nnextp);
nodep->accept(v); nodep->accept(v);
@ -871,6 +871,7 @@ AstNode* AstNode::iterateSubtreeReturnEdits(AstNVisitor& v) {
void AstNode::cloneRelinkTree() { void AstNode::cloneRelinkTree() {
// private: Cleanup clone() operation on whole tree. Publicly call cloneTree() instead. // private: Cleanup clone() operation on whole tree. Publicly call cloneTree() instead.
UDEBUGONLY(UASSERT(dynamic_cast<const AstNode*>(this),"this should not be NULL"););
for (AstNode* nodep=this; nodep; nodep=nodep->m_nextp) { for (AstNode* nodep=this; nodep; nodep=nodep->m_nextp) {
if (m_dtypep && m_dtypep->clonep()) { if (m_dtypep && m_dtypep->clonep()) {
m_dtypep = m_dtypep->clonep(); m_dtypep = m_dtypep->clonep();
@ -896,7 +897,7 @@ bool AstNode::gateTreeIter() const {
return true; return true;
} }
bool AstNode::sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ignNext, bool gateOnly) const { bool AstNode::sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ignNext, bool gateOnly) {
// private: Return true if the two trees are identical // private: Return true if the two trees are identical
if (!node1p && !node2p) return true; if (!node1p && !node2p) return true;
if (!node1p || !node2p) return false; if (!node1p || !node2p) return false;

View File

@ -917,6 +917,21 @@ public:
virtual ~AstNVisitor() { virtual ~AstNVisitor() {
doDeletes(); doDeletes();
} }
/// Call visit()s on nodep
void iterate(AstNode* nodep);
/// Call visit()s on nodep's children
void iterateChildren(AstNode* nodep);
/// Call visit()s on nodep's children in backp() order
void iterateChildrenBackwards(AstNode* nodep);
/// Call visit()s on const nodep's children
void iterateChildrenConst(AstNode* nodep);
/// Call visit()s on nodep (maybe NULL) and nodep's nextp() list
void iterateAndNextNull(AstNode* nodep);
/// Call visit()s on const nodep (maybe NULL) and nodep's nextp() list
void iterateAndNextConstNull(AstNode* nodep);
/// Return edited nodep; see comments in V3Ast.cpp
AstNode* iterateSubtreeReturnEdits(AstNode* nodep);
#include "V3Ast__gen_visitor.h" // From ./astgen #include "V3Ast__gen_visitor.h" // From ./astgen
// Things like: // Things like:
// virtual void visit(AstBreak* nodep) { visit((AstNodeStmt*)(nodep)); } // virtual void visit(AstBreak* nodep) { visit((AstNodeStmt*)(nodep)); }
@ -1051,14 +1066,13 @@ class AstNode {
void op4p(AstNode* nodep) { m_op4p = nodep; if (nodep) nodep->m_backp = this; } void op4p(AstNode* nodep) { m_op4p = nodep; if (nodep) nodep->m_backp = this; }
void init(); // initialize value of AstNode void init(); // initialize value of AstNode
void iterateListBackwards(AstNVisitor& v);
private: private:
AstNode* cloneTreeIter(); AstNode* cloneTreeIter();
AstNode* cloneTreeIterList(); AstNode* cloneTreeIterList();
void checkTreeIter(AstNode* backp); void checkTreeIter(AstNode* backp);
void checkTreeIterList(AstNode* backp); void checkTreeIterList(AstNode* backp);
bool gateTreeIter() const; bool gateTreeIter() const;
bool sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ignNext, bool gateOnly) const; static bool sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ignNext, bool gateOnly);
void deleteTreeIter(); void deleteTreeIter();
void deleteNode(); void deleteNode();
public: public:
@ -1352,15 +1366,21 @@ public:
// INVOKERS // INVOKERS
virtual void accept(AstNVisitor& v) = 0; virtual void accept(AstNVisitor& v) = 0;
void iterate(AstNVisitor& v) { this->accept(v); } // Does this; excludes following this->next
void iterateAndNext(AstNVisitor& v); protected:
void iterateAndNextConst(AstNVisitor& v); // All AstNVisitor related functions are called as methods off the visitor
void iterateChildren(AstNVisitor& v); // Excludes following this->next friend class AstNVisitor;
void iterateChildrenBackwards(AstNVisitor& v); // Excludes following this->next void iterateChildren(AstNVisitor& v); // Use instead AstNVisitor::iterateChildren
void iterateChildrenConst(AstNVisitor& v); // Excludes following this->next void iterateChildrenBackwards(AstNVisitor& v); // Use instead AstNVisitor::iterateChildrenBackwards
AstNode* iterateSubtreeReturnEdits(AstNVisitor& v); // Return edited nodep; see comments in V3Ast.cpp void iterateChildrenConst(AstNVisitor& v); // Use instead AstNVisitor::iterateChildrenConst
void iterateAndNext(AstNVisitor& v); // Use instead AstNVisitor::iterateAndNextNull
void iterateAndNextConst(AstNVisitor& v); // Use instead AstNVisitor::iterateAndNextConstNull
AstNode* iterateSubtreeReturnEdits(AstNVisitor& v); // Use instead AstNVisitor::iterateSubtreeReturnEdits
private:
void iterateListBackwards(AstNVisitor& v);
// CONVERSION // CONVERSION
public:
#include "V3Ast__gen_interface.h" // From ./astgen #include "V3Ast__gen_interface.h" // From ./astgen
// Things like: // Things like:
// AstAlways* castAlways(); // AstAlways* castAlways();
@ -2096,6 +2116,31 @@ public:
// inline AstAlways* AstNode::castAlways() { return dynamic_cast<AstAlways*>(this);} // inline AstAlways* AstNode::castAlways() { return dynamic_cast<AstAlways*>(this);}
// inline bool AstNode::privateIsaAlways(const AstNode* nodep) { return nodep && nodep->type() == AstType::atAlways; } // inline bool AstNode::privateIsaAlways(const AstNode* nodep) { return nodep && nodep->type() == AstType::atAlways; }
//######################################################################
// Inline AstNVisitor METHODS
inline void AstNVisitor::iterate(AstNode* nodep) {
nodep->accept(*this);
}
inline void AstNVisitor::iterateChildren(AstNode* nodep) {
nodep->iterateChildren(*this);
}
inline void AstNVisitor::iterateChildrenBackwards(AstNode* nodep) {
nodep->iterateChildrenBackwards(*this);
}
inline void AstNVisitor::iterateChildrenConst(AstNode* nodep) {
nodep->iterateChildrenConst(*this);
}
inline void AstNVisitor::iterateAndNextNull(AstNode* nodep) {
if (VL_LIKELY(nodep)) nodep->iterateAndNext(*this);
}
inline void AstNVisitor::iterateAndNextConstNull(AstNode* nodep) {
if (VL_LIKELY(nodep)) nodep->iterateAndNextConst(*this);
}
inline AstNode* AstNVisitor::iterateSubtreeReturnEdits(AstNode* nodep) {
return nodep->iterateSubtreeReturnEdits(*this);
}
//###################################################################### //######################################################################
// Inline ACCESSORS // Inline ACCESSORS

View File

@ -87,7 +87,7 @@ private:
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
m_repeatNum = 0; m_repeatNum = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
@ -107,7 +107,7 @@ private:
m_namedScope = ""; m_namedScope = "";
m_unnamedScope = ""; m_unnamedScope = "";
m_ftaskp = nodep; m_ftaskp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ftaskp = NULL; m_ftaskp = NULL;
} }
m_namedScope = oldScope; m_namedScope = oldScope;
@ -143,7 +143,7 @@ private:
} }
// Remap var names and replace lower Begins // Remap var names and replace lower Begins
nodep->stmtsp()->iterateAndNext(*this); iterateAndNextNull(nodep->stmtsp());
if (nodep->genforp()) nodep->v3fatalSrc("GENFORs should have been expanded earlier"); if (nodep->genforp()) nodep->v3fatalSrc("GENFORs should have been expanded earlier");
} }
m_namedScope = oldScope; m_namedScope = oldScope;
@ -184,7 +184,7 @@ private:
nodep->unlinkFrBack(); nodep->unlinkFrBack();
m_modp->addStmtp(nodep); m_modp->addStmtp(nodep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVarXRef* nodep) { virtual void visit(AstVarXRef* nodep) {
UINFO(9, " VARXREF "<<nodep<<endl); UINFO(9, " VARXREF "<<nodep<<endl);
@ -204,12 +204,12 @@ private:
nodep->scopeAttrp(new AstText(nodep->fileline(), (string)"__DOT__"+m_namedScope)); nodep->scopeAttrp(new AstText(nodep->fileline(), (string)"__DOT__"+m_namedScope));
if (afterp) nodep->scopeAttrp(afterp); if (afterp) nodep->scopeAttrp(afterp);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCoverDecl* nodep) { virtual void visit(AstCoverDecl* nodep) {
// Don't need to fix path in coverage statements, they're not under // Don't need to fix path in coverage statements, they're not under
// any BEGINs, but V3Coverage adds them all under the module itself. // any BEGINs, but V3Coverage adds them all under the module itself.
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// VISITORS - LINT CHECK // VISITORS - LINT CHECK
virtual void visit(AstIf* nodep) { // Note not AstNodeIf; other types don't get covered virtual void visit(AstIf* nodep) { // Note not AstNodeIf; other types don't get covered
@ -223,11 +223,11 @@ private:
nodep->fileline()->modifyWarnOff(V3ErrorCode::IFDEPTH, true); // Warn only once nodep->fileline()->modifyWarnOff(V3ErrorCode::IFDEPTH, true); // Warn only once
m_ifDepth = -1; m_ifDepth = -1;
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ifDepth = prevIfDepth; m_ifDepth = prevIfDepth;
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -237,7 +237,7 @@ public:
m_ftaskp = NULL; m_ftaskp = NULL;
m_repeatNum = 0; m_repeatNum = 0;
m_ifDepth = 0; m_ifDepth = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~BeginVisitor() {} virtual ~BeginVisitor() {}
}; };
@ -257,14 +257,14 @@ private:
UINFO(9, " relinkFTask "<<nodep<<endl); UINFO(9, " relinkFTask "<<nodep<<endl);
nodep->name(nodep->taskp()->name()); nodep->name(nodep->taskp()->name());
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
if (nodep->varp()->user1()) { // It was converted if (nodep->varp()->user1()) { // It was converted
UINFO(9, " relinVarRef "<<nodep<<endl); UINFO(9, " relinVarRef "<<nodep<<endl);
nodep->name(nodep->varp()->name()); nodep->name(nodep->varp()->name());
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstIfaceRefDType* nodep) { virtual void visit(AstIfaceRefDType* nodep) {
// May have changed cell names // May have changed cell names
@ -272,16 +272,16 @@ private:
UINFO(8," IFACEREFDTYPE "<<nodep<<endl); UINFO(8," IFACEREFDTYPE "<<nodep<<endl);
if (nodep->cellp()) nodep->cellName(nodep->cellp()->name()); if (nodep->cellp()) nodep->cellName(nodep->cellp()->name());
UINFO(8," rename to "<<nodep<<endl); UINFO(8," rename to "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
BeginRelinkVisitor(AstNetlist* nodep, BeginState*) { BeginRelinkVisitor(AstNetlist* nodep, BeginState*) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~BeginRelinkVisitor() {} virtual ~BeginRelinkVisitor() {}
}; };

View File

@ -82,12 +82,12 @@ private:
{ {
// Do if // Do if
reset(); reset();
nodep->ifsp()->iterateAndNext(*this); iterateAndNextNull(nodep->ifsp());
int ifLikely = m_likely; int ifLikely = m_likely;
int ifUnlikely = m_unlikely; int ifUnlikely = m_unlikely;
// Do else // Do else
reset(); reset();
nodep->elsesp()->iterateAndNext(*this); iterateAndNextNull(nodep->elsesp());
int elseLikely = m_likely; int elseLikely = m_likely;
int elseUnlikely = m_unlikely; int elseUnlikely = m_unlikely;
// Compute // Compute
@ -104,16 +104,16 @@ private:
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
checkUnlikely(nodep); checkUnlikely(nodep);
nodep->funcp()->user1Inc(); nodep->funcp()->user1Inc();
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
checkUnlikely(nodep); checkUnlikely(nodep);
m_cfuncsp.push_back(nodep); m_cfuncsp.push_back(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
checkUnlikely(nodep); checkUnlikely(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// METHODS // METHODS
@ -130,7 +130,7 @@ public:
// CONSTUCTORS // CONSTUCTORS
explicit BranchVisitor(AstNetlist* nodep) { explicit BranchVisitor(AstNetlist* nodep) {
reset(); reset();
nodep->iterateChildren(*this); iterateChildren(nodep);
calc_tasks(); calc_tasks();
} }
virtual ~BranchVisitor() {} virtual ~BranchVisitor() {}

View File

@ -193,7 +193,7 @@ private:
// METHODS // METHODS
void processAndIterate(AstNode* nodep) { void processAndIterate(AstNode* nodep) {
BrokenTable::addInTree(nodep, nodep->maybePointedTo()); BrokenTable::addInTree(nodep, nodep->maybePointedTo());
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
} }
// VISITORS // VISITORS
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
@ -202,7 +202,7 @@ private:
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit BrokenMarkVisitor(AstNetlist* nodep) { explicit BrokenMarkVisitor(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~BrokenMarkVisitor() {} virtual ~BrokenMarkVisitor() {}
}; };
@ -239,7 +239,7 @@ private:
if (const AstNodeDType* dnodep = VN_CAST(nodep, NodeDType)) checkWidthMin(dnodep); if (const AstNodeDType* dnodep = VN_CAST(nodep, NodeDType)) checkWidthMin(dnodep);
} }
checkWidthMin(nodep); checkWidthMin(nodep);
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
BrokenTable::setUnder(nodep,false); BrokenTable::setUnder(nodep,false);
} }
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
@ -257,7 +257,7 @@ private:
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit BrokenCheckVisitor(AstNetlist* nodep) { explicit BrokenCheckVisitor(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~BrokenCheckVisitor() {} virtual ~BrokenCheckVisitor() {}
}; };

View File

@ -83,9 +83,9 @@ private:
// Check for X/Z in non-casex statements // Check for X/Z in non-casex statements
{ {
m_caseExprp = nodep; m_caseExprp = nodep;
nodep->exprp()->accept(*this); iterate(nodep->exprp());
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) { for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) {
itemp->condsp()->iterateAndNext(*this); iterateAndNextNull(itemp->condsp());
} }
m_caseExprp = NULL; m_caseExprp = NULL;
} }
@ -108,13 +108,13 @@ private:
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit CaseLintVisitor(AstNodeCase* nodep) { explicit CaseLintVisitor(AstNodeCase* nodep) {
m_caseExprp = NULL; m_caseExprp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~CaseLintVisitor() {} virtual ~CaseLintVisitor() {}
}; };
@ -453,7 +453,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstCase* nodep) { virtual void visit(AstCase* nodep) {
V3Case::caseLint(nodep); V3Case::caseLint(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (debug()>=9) nodep->dumpTree(cout," case_old: "); if (debug()>=9) nodep->dumpTree(cout," case_old: ");
if (isCaseTreeFast(nodep) && v3Global.opt.oCase()) { if (isCaseTreeFast(nodep) && v3Global.opt.oCase()) {
// It's a simple priority encoder or complete statement // It's a simple priority encoder or complete statement
@ -468,14 +468,14 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit CaseVisitor(AstNetlist* nodep) { explicit CaseVisitor(AstNetlist* nodep) {
m_caseNoOverlapsAllCovered = false; m_caseNoOverlapsAllCovered = false;
nodep->accept(*this); iterate(nodep);
} }
virtual ~CaseVisitor() { virtual ~CaseVisitor() {
V3Stats::addStat("Optimizations, Cases parallelized", m_statCaseFast); V3Stats::addStat("Optimizations, Cases parallelized", m_statCaseFast);

View File

@ -108,19 +108,19 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNodeUniop* nodep) { virtual void visit(AstNodeUniop* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->user1(nodep->lhsp()->user1()); nodep->user1(nodep->lhsp()->user1());
if (nodep->sizeMattersLhs()) insureCast(nodep->lhsp()); if (nodep->sizeMattersLhs()) insureCast(nodep->lhsp());
} }
virtual void visit(AstNodeBiop* nodep) { virtual void visit(AstNodeBiop* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->user1(nodep->lhsp()->user1() nodep->user1(nodep->lhsp()->user1()
| nodep->rhsp()->user1()); | nodep->rhsp()->user1());
if (nodep->sizeMattersLhs()) insureCast(nodep->lhsp()); if (nodep->sizeMattersLhs()) insureCast(nodep->lhsp());
if (nodep->sizeMattersRhs()) insureCast(nodep->rhsp()); if (nodep->sizeMattersRhs()) insureCast(nodep->rhsp());
} }
virtual void visit(AstNodeTriop* nodep) { virtual void visit(AstNodeTriop* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->user1(nodep->lhsp()->user1() nodep->user1(nodep->lhsp()->user1()
| nodep->rhsp()->user1() | nodep->rhsp()->user1()
| nodep->thsp()->user1()); | nodep->thsp()->user1());
@ -129,12 +129,12 @@ private:
if (nodep->sizeMattersThs()) insureCast(nodep->thsp()); if (nodep->sizeMattersThs()) insureCast(nodep->thsp());
} }
virtual void visit(AstCCast* nodep) { virtual void visit(AstCCast* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureLower32Cast(nodep); insureLower32Cast(nodep);
nodep->user1(1); nodep->user1(1);
} }
virtual void visit(AstNegate* nodep) { virtual void visit(AstNegate* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->user1(nodep->lhsp()->user1()); nodep->user1(nodep->lhsp()->user1());
if (nodep->lhsp()->widthMin()==1) { if (nodep->lhsp()->widthMin()==1) {
// We want to avoid a GCC "converting of negative value" warning // We want to avoid a GCC "converting of negative value" warning
@ -171,13 +171,13 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit CastVisitor(AstNetlist* nodep) { explicit CastVisitor(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~CastVisitor() {} virtual ~CastVisitor() {}
}; };

View File

@ -145,13 +145,13 @@ private:
*m_ofp<<nodep->prettyTypeName()<<" "<<endl; *m_ofp<<nodep->prettyTypeName()<<" "<<endl;
string lastPrefix = m_prefix; string lastPrefix = m_prefix;
m_prefix = lastPrefix + "1:"; m_prefix = lastPrefix + "1:";
nodep->op1p()->iterateAndNext(*this); iterateAndNextNull(nodep->op1p());
m_prefix = lastPrefix + "2:"; m_prefix = lastPrefix + "2:";
nodep->op2p()->iterateAndNext(*this); iterateAndNextNull(nodep->op2p());
m_prefix = lastPrefix + "3:"; m_prefix = lastPrefix + "3:";
nodep->op3p()->iterateAndNext(*this); iterateAndNextNull(nodep->op3p());
m_prefix = lastPrefix + "4:"; m_prefix = lastPrefix + "4:";
nodep->op4p()->iterateAndNext(*this); iterateAndNextNull(nodep->op4p());
m_prefix = lastPrefix; m_prefix = lastPrefix;
} }
@ -160,7 +160,7 @@ public:
CdcDumpVisitor(AstNode* nodep, std::ofstream* ofp, const string& prefix) { CdcDumpVisitor(AstNode* nodep, std::ofstream* ofp, const string& prefix) {
m_ofp = ofp; m_ofp = ofp;
m_prefix = prefix; m_prefix = prefix;
nodep->accept(*this); iterate(nodep);
} }
virtual ~CdcDumpVisitor() {} virtual ~CdcDumpVisitor() {}
}; };
@ -173,7 +173,7 @@ private:
size_t m_maxFilenameLen; size_t m_maxFilenameLen;
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Keeping line+filename lengths separate is much faster than calling ascii().length() // Keeping line+filename lengths separate is much faster than calling ascii().length()
if (nodep->fileline()->lineno() >= m_maxLineno) { if (nodep->fileline()->lineno() >= m_maxLineno) {
m_maxLineno = nodep->fileline()->lineno()+1; m_maxLineno = nodep->fileline()->lineno()+1;
@ -187,7 +187,7 @@ public:
explicit CdcWidthVisitor(AstNode* nodep) { explicit CdcWidthVisitor(AstNode* nodep) {
m_maxLineno = 0; m_maxLineno = 0;
m_maxFilenameLen = 0; m_maxFilenameLen = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~CdcWidthVisitor() {} virtual ~CdcWidthVisitor() {}
// ACCESSORS // ACCESSORS
@ -241,7 +241,7 @@ private:
m_logicVertexp->dstDomainp(m_domainp); m_logicVertexp->dstDomainp(m_domainp);
m_logicVertexp->dstDomainSet(true); m_logicVertexp->dstDomainSet(true);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
m_logicVertexp = NULL; m_logicVertexp = NULL;
if (0 && debug()>=9) { if (0 && debug()>=9) {
@ -606,14 +606,14 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
UINFO(4," SCOPE "<<nodep<<endl); UINFO(4," SCOPE "<<nodep<<endl);
m_scopep = nodep; m_scopep = nodep;
m_logicVertexp = NULL; m_logicVertexp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_scopep = NULL; m_scopep = NULL;
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
@ -657,14 +657,14 @@ private:
} }
virtual void visit(AstAssignDly* nodep) { virtual void visit(AstAssignDly* nodep) {
m_inDly = true; m_inDly = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inDly = false; m_inDly = false;
} }
virtual void visit(AstSenItem* nodep) { virtual void visit(AstSenItem* nodep) {
// Note we look at only AstSenItems, not AstSenGate's // Note we look at only AstSenItems, not AstSenGate's
// The gating term of a AstSenGate is normal logic // The gating term of a AstSenGate is normal logic
m_inSenItem = true; m_inSenItem = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inSenItem = false; m_inSenItem = false;
} }
virtual void visit(AstAlways* nodep) { virtual void visit(AstAlways* nodep) {
@ -691,21 +691,21 @@ private:
// Math that shouldn't cause us to clear hazard // Math that shouldn't cause us to clear hazard
virtual void visit(AstConst* nodep) { } virtual void visit(AstConst* nodep) { }
virtual void visit(AstReplicate* nodep) { virtual void visit(AstReplicate* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstConcat* nodep) { virtual void visit(AstConcat* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNot* nodep) { virtual void visit(AstNot* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
if (!VN_IS(nodep->lsbp(), Const)) setNodeHazard(nodep); if (!VN_IS(nodep->lsbp(), Const)) setNodeHazard(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeSel* nodep) { virtual void visit(AstNodeSel* nodep) {
if (!VN_IS(nodep->bitp(), Const)) setNodeHazard(nodep); if (!VN_IS(nodep->bitp(), Const)) setNodeHazard(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// Ignores // Ignores
@ -718,10 +718,10 @@ private:
// Default // Default
virtual void visit(AstNodeMath* nodep) { virtual void visit(AstNodeMath* nodep) {
setNodeHazard(nodep); setNodeHazard(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -747,7 +747,7 @@ public:
*m_ofp<<"repeating recursively forwards to the destination flop(s).\n"; *m_ofp<<"repeating recursively forwards to the destination flop(s).\n";
*m_ofp<<"%% Indicates the operator considered potentially hazardous.\n"; *m_ofp<<"%% Indicates the operator considered potentially hazardous.\n";
nodep->accept(*this); iterate(nodep);
analyze(); analyze();
if (debug()>=1) edgeReport(); // Not useful to users at the moment if (debug()>=1) edgeReport(); // Not useful to users at the moment

View File

@ -159,7 +159,7 @@ private:
m_newLvEqnp = new AstArraySel(nodep->fileline(), m_newLvEqnp->cloneTree(true), index); m_newLvEqnp = new AstArraySel(nodep->fileline(), m_newLvEqnp->cloneTree(true), index);
m_newRvEqnp = new AstArraySel(nodep->fileline(), m_newRvEqnp->cloneTree(true), index); m_newRvEqnp = new AstArraySel(nodep->fileline(), m_newRvEqnp->cloneTree(true), index);
nodep->subDTypep()->skipRefp()->accept(*this); iterate(nodep->subDTypep()->skipRefp());
m_varEqnp->deleteTree(); m_varEqnp->deleteTree();
m_newLvEqnp->deleteTree(); m_newLvEqnp->deleteTree();
@ -181,7 +181,7 @@ private:
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (debug()) nodep->dumpTree(cout,"-DETECTARRAY-general-"); if (debug()) nodep->dumpTree(cout,"-DETECTARRAY-general-");
m_vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable" m_vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable"
" (probably with UNOPTFLAT warning suppressed): " " (probably with UNOPTFLAT warning suppressed): "
@ -209,7 +209,7 @@ public:
m_newLvEqnp = new AstVarRef(m_vscp->fileline(), m_newvscp, true); m_newLvEqnp = new AstVarRef(m_vscp->fileline(), m_newvscp, true);
m_newRvEqnp = new AstVarRef(m_vscp->fileline(), m_newvscp, false); m_newRvEqnp = new AstVarRef(m_vscp->fileline(), m_newvscp, false);
} }
vscp->dtypep()->skipRefp()->accept(*this); iterate(vscp->dtypep()->skipRefp());
m_varEqnp->deleteTree(); m_varEqnp->deleteTree();
m_newLvEqnp->deleteTree(); m_newLvEqnp->deleteTree();
m_newRvEqnp->deleteTree(); m_newRvEqnp->deleteTree();
@ -248,7 +248,7 @@ private:
if (nodep->isTop()) { if (nodep->isTop()) {
m_statep->m_topModp = nodep; m_statep->m_topModp = nodep;
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
@ -271,7 +271,7 @@ private:
m_statep->maybeCreateChgFuncp(); m_statep->maybeCreateChgFuncp();
m_statep->m_chgFuncp->addStmtsp(new AstChangeDet(nodep->fileline(), NULL, NULL, false)); m_statep->m_chgFuncp->addStmtsp(new AstChangeDet(nodep->fileline(), NULL, NULL, false));
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVarScope* nodep) { virtual void visit(AstVarScope* nodep) {
if (nodep->isCircular()) { if (nodep->isCircular()) {
@ -287,14 +287,14 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
ChangedVisitor(AstNetlist* nodep, ChangedState* statep) { ChangedVisitor(AstNetlist* nodep, ChangedState* statep) {
m_statep = statep; m_statep = statep;
nodep->accept(*this); iterate(nodep);
} }
virtual ~ChangedVisitor() {} virtual ~ChangedVisitor() {}
}; };

View File

@ -148,7 +148,7 @@ private:
// Base type handling methods // Base type handling methods
void operandBiop(AstNodeBiop* nodep) { void operandBiop(AstNodeBiop* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
computeCppWidth(nodep); computeCppWidth(nodep);
if (nodep->cleanLhs()) { if (nodep->cleanLhs()) {
insureClean(nodep->lhsp()); insureClean(nodep->lhsp());
@ -159,7 +159,7 @@ private:
//no setClean.. must do it in each user routine. //no setClean.. must do it in each user routine.
} }
void operandTriop(AstNodeTriop* nodep) { void operandTriop(AstNodeTriop* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
computeCppWidth(nodep); computeCppWidth(nodep);
if (nodep->cleanLhs()) { if (nodep->cleanLhs()) {
insureClean(nodep->lhsp()); insureClean(nodep->lhsp());
@ -176,11 +176,11 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstNodeUniop* nodep) { virtual void visit(AstNodeUniop* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
computeCppWidth(nodep); computeCppWidth(nodep);
if (nodep->cleanLhs()) { if (nodep->cleanLhs()) {
insureClean(nodep->lhsp()); insureClean(nodep->lhsp());
@ -204,12 +204,12 @@ private:
setClean (nodep, isClean(nodep->lhsp()) && isClean(nodep->rhsp())); setClean (nodep, isClean(nodep->lhsp()) && isClean(nodep->rhsp()));
} }
virtual void visit(AstNodeMath* nodep) { virtual void visit(AstNodeMath* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
computeCppWidth(nodep); computeCppWidth(nodep);
setClean (nodep, nodep->cleanOut()); setClean (nodep, nodep->cleanOut());
} }
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
computeCppWidth(nodep); computeCppWidth(nodep);
if (nodep->cleanRhs()) { if (nodep->cleanRhs()) {
insureClean(nodep->rhsp()); insureClean(nodep->rhsp());
@ -226,7 +226,7 @@ private:
setClean (nodep, nodep->cleanOut()); setClean (nodep, nodep->cleanOut());
} }
virtual void visit(AstUCFunc* nodep) { virtual void visit(AstUCFunc* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
computeCppWidth(nodep); computeCppWidth(nodep);
setClean (nodep, false); setClean (nodep, false);
// We always clean, as we don't trust those pesky users. // We always clean, as we don't trust those pesky users.
@ -236,43 +236,43 @@ private:
insureCleanAndNext (nodep->bodysp()); insureCleanAndNext (nodep->bodysp());
} }
virtual void visit(AstTraceInc* nodep) { virtual void visit(AstTraceInc* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureCleanAndNext (nodep->valuep()); insureCleanAndNext (nodep->valuep());
} }
virtual void visit(AstTypedef* nodep) { virtual void visit(AstTypedef* nodep) {
// No cleaning, or would loose pointer to enum // No cleaning, or would loose pointer to enum
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstParamTypeDType* nodep) { virtual void visit(AstParamTypeDType* nodep) {
// No cleaning, or would loose pointer to enum // No cleaning, or would loose pointer to enum
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// Control flow operators // Control flow operators
virtual void visit(AstNodeCond* nodep) { virtual void visit(AstNodeCond* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureClean(nodep->condp()); insureClean(nodep->condp());
setClean(nodep, isClean(nodep->expr1p()) && isClean(nodep->expr2p())); setClean(nodep, isClean(nodep->expr1p()) && isClean(nodep->expr2p()));
} }
virtual void visit(AstWhile* nodep) { virtual void visit(AstWhile* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureClean(nodep->condp()); insureClean(nodep->condp());
} }
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureClean(nodep->condp()); insureClean(nodep->condp());
} }
virtual void visit(AstSFormatF* nodep) { virtual void visit(AstSFormatF* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureCleanAndNext (nodep->exprsp()); insureCleanAndNext (nodep->exprsp());
setClean(nodep, true); // generates a string, so not relevant setClean(nodep, true); // generates a string, so not relevant
} }
virtual void visit(AstUCStmt* nodep) { virtual void visit(AstUCStmt* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureCleanAndNext (nodep->bodysp()); insureCleanAndNext (nodep->bodysp());
} }
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
insureCleanAndNext (nodep->argsp()); insureCleanAndNext (nodep->argsp());
setClean (nodep, true); setClean (nodep, true);
} }
@ -280,14 +280,14 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
computeCppWidth(nodep); computeCppWidth(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit CleanVisitor(AstNetlist* nodep) { explicit CleanVisitor(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~CleanVisitor() {} virtual ~CleanVisitor() {}
}; };

View File

@ -196,7 +196,7 @@ private:
bool m_isSimple; // Set false when we know it isn't simple bool m_isSimple; // Set false when we know it isn't simple
// METHODS // METHODS
inline void okIterate(AstNode* nodep) { inline void okIterate(AstNode* nodep) {
if (m_isSimple) nodep->iterateChildren(*this); if (m_isSimple) iterateChildren(nodep);
} }
// VISITORS // VISITORS
virtual void visit(AstOr* nodep) { okIterate(nodep); } virtual void visit(AstOr* nodep) { okIterate(nodep); }
@ -213,13 +213,13 @@ private:
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
m_isSimple = false; m_isSimple = false;
//nodep->iterateChildren(*this); //iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit GaterCondVisitor(AstNode* nodep) { explicit GaterCondVisitor(AstNode* nodep) {
m_isSimple = true; m_isSimple = true;
nodep->accept(*this); iterate(nodep);
} }
virtual ~GaterCondVisitor() {} virtual ~GaterCondVisitor() {}
// PUBLIC METHODS // PUBLIC METHODS
@ -283,7 +283,7 @@ class GaterBodyVisitor : public GaterBaseVisitor {
uint32_t childstate; uint32_t childstate;
{ {
m_state = STATE_UNKNOWN; m_state = STATE_UNKNOWN;
nodep->iterateChildren(*this); iterateChildren(nodep);
childstate = m_state; childstate = m_state;
} }
m_state = oldstate; m_state = oldstate;
@ -305,7 +305,7 @@ class GaterBodyVisitor : public GaterBaseVisitor {
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -315,7 +315,7 @@ public:
m_state = STATE_UNKNOWN; m_state = STATE_UNKNOWN;
m_cloning = false; m_cloning = false;
if (debug()>=9) nodep->dumpTree(cout," GateBodyIn: "); if (debug()>=9) nodep->dumpTree(cout," GateBodyIn: ");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
if (debug()>=9) nodep->dumpTree(cout," GateBodyOut: "); if (debug()>=9) nodep->dumpTree(cout," GateBodyOut: ");
// If there's no statements we shouldn't have had a resulting graph // If there's no statements we shouldn't have had a resulting graph
// vertex asking for this creation // vertex asking for this creation
@ -802,17 +802,17 @@ class GaterVisitor : public GaterBaseVisitor {
GaterIfVertex* vertexp = new GaterIfVertex(&m_graph, nodep); GaterIfVertex* vertexp = new GaterIfVertex(&m_graph, nodep);
new GaterEdge(&m_graph, m_aboveVertexp, vertexp, m_aboveTrue); new GaterEdge(&m_graph, m_aboveVertexp, vertexp, m_aboveTrue);
{ {
nodep->condp()->iterateAndNext(*this); // directlyUnder stays as-is iterateAndNextNull(nodep->condp()); // directlyUnder stays as-is
} }
{ {
m_aboveVertexp = vertexp; // Vars will point at this edge m_aboveVertexp = vertexp; // Vars will point at this edge
m_aboveTrue = VU_IF; m_aboveTrue = VU_IF;
nodep->ifsp()->iterateAndNext(*this); // directlyUnder stays as-is (true) iterateAndNextNull(nodep->ifsp()); // directlyUnder stays as-is (true)
} }
{ {
m_aboveVertexp = vertexp; // Vars will point at this edge m_aboveVertexp = vertexp; // Vars will point at this edge
m_aboveTrue = VU_ELSE; m_aboveTrue = VU_ELSE;
nodep->elsesp()->iterateAndNext(*this); // directlyUnder stays as-is (true) iterateAndNextNull(nodep->elsesp()); // directlyUnder stays as-is (true)
} }
m_aboveVertexp = lastabovep; m_aboveVertexp = lastabovep;
m_aboveTrue = lasttrue; m_aboveTrue = lasttrue;
@ -868,7 +868,7 @@ class GaterVisitor : public GaterBaseVisitor {
scoreboardPli(nodep); scoreboardPli(nodep);
} }
{ {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_directlyUnderAlw = lastdua; m_directlyUnderAlw = lastdua;
if (VN_IS(nodep, NodeStmt)) { // Reset what set above; else propagate up to above statement if (VN_IS(nodep, NodeStmt)) { // Reset what set above; else propagate up to above statement
@ -882,7 +882,7 @@ public:
explicit GaterVisitor(AstNetlist* nodep) { explicit GaterVisitor(AstNetlist* nodep) {
// AstAlways visitor does the real work, so most zeroing needs to be in clear() // AstAlways visitor does the real work, so most zeroing needs to be in clear()
clear(); clear();
nodep->accept(*this); iterate(nodep);
} }
void clear() { void clear() {
m_nonopt = ""; m_nonopt = "";

View File

@ -239,7 +239,7 @@ private:
m_settleFuncp = funcp; m_settleFuncp = funcp;
} }
// Process the activates // Process the activates
nodep->iterateChildren(*this); iterateChildren(nodep);
// Done, clear so we can detect errors // Done, clear so we can detect errors
UINFO(4," TOPSCOPEDONE "<<nodep<<endl); UINFO(4," TOPSCOPEDONE "<<nodep<<endl);
clearLastSen(); clearLastSen();
@ -249,13 +249,13 @@ private:
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
//UINFO(4," MOD "<<nodep<<endl); //UINFO(4," MOD "<<nodep<<endl);
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp= NULL; m_modp= NULL;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
//UINFO(4," SCOPE "<<nodep<<endl); //UINFO(4," SCOPE "<<nodep<<endl);
m_scopep = nodep; m_scopep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
if (AstNode* movep = nodep->finalClksp()) { if (AstNode* movep = nodep->finalClksp()) {
if (!m_topScopep) nodep->v3fatalSrc("Final clocks under non-top scope"); if (!m_topScopep) nodep->v3fatalSrc("Final clocks under non-top scope");
movep->unlinkFrBackWithNext(); movep->unlinkFrBackWithNext();
@ -311,7 +311,7 @@ private:
nodep->deleteTree(); VL_DANGLING(nodep); nodep->deleteTree(); VL_DANGLING(nodep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Link to global function // Link to global function
if (nodep->formCallTree()) { if (nodep->formCallTree()) {
UINFO(4, " formCallTree "<<nodep<<endl); UINFO(4, " formCallTree "<<nodep<<endl);
@ -380,7 +380,7 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -393,7 +393,7 @@ public:
m_lastIfp = NULL; m_lastIfp = NULL;
m_scopep = NULL; m_scopep = NULL;
// //
nodep->accept(*this); iterate(nodep);
// Allow downstream modules to find _eval() // Allow downstream modules to find _eval()
// easily without iterating through the tree. // easily without iterating through the tree.
nodep->evalp(m_evalFuncp); nodep->evalp(m_evalFuncp);

View File

@ -141,7 +141,7 @@ private:
virtual void visit(AstNodeAssign* nodep) {} virtual void visit(AstNodeAssign* nodep) {}
virtual void visit(AstNodeMath* nodep) {} virtual void visit(AstNodeMath* nodep) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -150,7 +150,7 @@ public:
} }
virtual ~CombCallVisitor() {} virtual ~CombCallVisitor() {}
void main(AstNetlist* nodep) { void main(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
}; };
@ -165,12 +165,12 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->user3(true); nodep->user3(true);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit CombMarkVisitor(AstNode* nodep) { explicit CombMarkVisitor(AstNode* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~CombMarkVisitor() {} virtual ~CombMarkVisitor() {}
}; };
@ -214,7 +214,7 @@ private:
CombineState oldState = m_state; CombineState oldState = m_state;
{ {
m_state = STATE_HASH; m_state = STATE_HASH;
nodep->accept(*this); iterate(nodep);
} }
m_state = oldState; m_state = oldState;
} }
@ -396,7 +396,7 @@ private:
//In V3Hashed AstNode::user4ClearTree(); // user4p() used on entire tree //In V3Hashed AstNode::user4ClearTree(); // user4p() used on entire tree
// Iterate modules backwards, in bottom-up order. // Iterate modules backwards, in bottom-up order.
// Required so that a module instantiating another can benefit from collapsing. // Required so that a module instantiating another can benefit from collapsing.
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
@ -405,7 +405,7 @@ private:
m_hashed.clear(); m_hashed.clear();
// Compute hash of all statement trees in the function // Compute hash of all statement trees in the function
m_state = STATE_HASH; m_state = STATE_HASH;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_state = STATE_IDLE; m_state = STATE_IDLE;
if (debug()>=9) { if (debug()>=9) {
m_hashed.dumpFilePrefixed("combine"); m_hashed.dumpFilePrefixed("combine");
@ -421,7 +421,7 @@ private:
// Walk the statements looking for large replicated code sections // Walk the statements looking for large replicated code sections
if (statementCombine()) { if (statementCombine()) {
m_state = STATE_DUP; m_state = STATE_DUP;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_state = STATE_IDLE; m_state = STATE_IDLE;
} }
m_modp = NULL; m_modp = NULL;
@ -432,7 +432,7 @@ private:
if (m_state == STATE_HASH) { if (m_state == STATE_HASH) {
hashStatement(nodep); // Hash the entire function - it might be identical hashStatement(nodep); // Hash the entire function - it might be identical
} else if (m_state == STATE_DUP) { } else if (m_state == STATE_DUP) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
m_funcp = NULL; m_funcp = NULL;
@ -452,7 +452,7 @@ private:
virtual void visit(AstTraceDecl*) {} virtual void visit(AstTraceDecl*) {}
virtual void visit(AstTraceInc*) {} virtual void visit(AstTraceInc*) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -461,7 +461,7 @@ public:
m_modp=NULL; m_modp=NULL;
m_funcp = NULL; m_funcp = NULL;
m_state = STATE_IDLE; m_state = STATE_IDLE;
nodep->accept(*this); iterate(nodep);
} }
virtual ~CombineVisitor() { virtual ~CombineVisitor() {
V3Stats::addStat("Optimizations, Combined CFuncs", m_statCombs); V3Stats::addStat("Optimizations, Combined CFuncs", m_statCombs);

View File

@ -51,13 +51,13 @@ private:
if (nodep->varp()) nodep->varp()->user4(1); if (nodep->varp()) nodep->varp()->user4(1);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit ConstVarMarkVisitor(AstNode* nodep) { explicit ConstVarMarkVisitor(AstNode* nodep) {
AstNode::user4ClearTree(); // Check marked InUse before we're called AstNode::user4ClearTree(); // Check marked InUse before we're called
nodep->accept(*this); iterate(nodep);
} }
virtual ~ConstVarMarkVisitor() {} virtual ~ConstVarMarkVisitor() {}
}; };
@ -73,13 +73,13 @@ private:
if (nodep->varp() && nodep->varp()->user4()) m_found = true; if (nodep->varp() && nodep->varp()->user4()) m_found = true;
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit ConstVarFindVisitor(AstNode* nodep) { explicit ConstVarFindVisitor(AstNode* nodep) {
m_found = false; m_found = false;
nodep->iterateAndNext(*this); iterateAndNextNull(nodep);
} }
virtual ~ConstVarFindVisitor() {} virtual ~ConstVarFindVisitor() {}
// METHODS // METHODS
@ -430,7 +430,7 @@ private:
if (m_doGenerate) { if (m_doGenerate) {
// Never checked yet // Never checked yet
V3Width::widthParamsEdit(nodep); V3Width::widthParamsEdit(nodep);
nodep->iterateChildren(*this); // May need "constifying" iterateChildren(nodep); // May need "constifying"
} }
// Find range of dtype we are selecting from // Find range of dtype we are selecting from
// Similar code in V3Unknown::AstSel // Similar code in V3Unknown::AstSel
@ -686,14 +686,14 @@ private:
//! Replace a ternary node with its RHS after iterating //! Replace a ternary node with its RHS after iterating
//! Used with short-circuting, where the RHS has not yet been iterated. //! Used with short-circuting, where the RHS has not yet been iterated.
void replaceWIteratedRhs(AstNodeTriop* nodep) { void replaceWIteratedRhs(AstNodeTriop* nodep) {
if (AstNode *rhsp = nodep->rhsp()) rhsp->iterateAndNext(*this); if (AstNode* rhsp = nodep->rhsp()) iterateAndNextNull(rhsp);
replaceWChild(nodep, nodep->rhsp()); // May have changed replaceWChild(nodep, nodep->rhsp()); // May have changed
} }
//! Replace a ternary node with its THS after iterating //! Replace a ternary node with its THS after iterating
//! Used with short-circuting, where the THS has not yet been iterated. //! Used with short-circuting, where the THS has not yet been iterated.
void replaceWIteratedThs(AstNodeTriop* nodep) { void replaceWIteratedThs(AstNodeTriop* nodep) {
if (AstNode *thsp = nodep->thsp()) thsp->iterateAndNext(*this); if (AstNode* thsp = nodep->thsp()) iterateAndNextNull(thsp);
replaceWChild(nodep, nodep->thsp()); // May have changed replaceWChild(nodep, nodep->thsp()); // May have changed
} }
void replaceWLhs(AstNodeUniop* nodep) { void replaceWLhs(AstNodeUniop* nodep) {
@ -835,8 +835,8 @@ private:
UINFO(5, "merged "<< nodep <<endl); UINFO(5, "merged "<< nodep <<endl);
rp->unlinkFrBack()->deleteTree(); VL_DANGLING(rp); rp->unlinkFrBack()->deleteTree(); VL_DANGLING(rp);
nodep->replaceWith(lp->unlinkFrBack()); nodep->deleteTree(); VL_DANGLING(nodep); nodep->replaceWith(lp->unlinkFrBack()); nodep->deleteTree(); VL_DANGLING(nodep);
lp->lhsp()->accept(*this); iterate(lp->lhsp());
lp->rhsp()->accept(*this); iterate(lp->rhsp());
} else nodep->v3fatalSrc("tried to merge two Concat which are not adjacent"); } else nodep->v3fatalSrc("tried to merge two Concat which are not adjacent");
} }
void replaceExtend (AstNode* nodep, AstNode* arg0p) { void replaceExtend (AstNode* nodep, AstNode* arg0p) {
@ -892,7 +892,7 @@ private:
AstNodeBiop* newp = lhsp; AstNodeBiop* newp = lhsp;
newp->lhsp(shift1p); newp->rhsp(shift2p); newp->lhsp(shift1p); newp->rhsp(shift2p);
handle.relink(newp); handle.relink(newp);
newp->accept(*this); // Further reduce, either node may have more reductions. iterate(newp); // Further reduce, either node may have more reductions.
} }
void replaceShiftShift (AstNodeBiop* nodep) { void replaceShiftShift (AstNodeBiop* nodep) {
UINFO(4,"SHIFT(SHIFT(a,s1),s2)->SHIFT(a,ADD(s1,s2)) "<<nodep<<endl); UINFO(4,"SHIFT(SHIFT(a,s1),s2)->SHIFT(a,ADD(s1,s2)) "<<nodep<<endl);
@ -910,7 +910,7 @@ private:
shift2p->deleteTree(); VL_DANGLING(shift2p); shift2p->deleteTree(); VL_DANGLING(shift2p);
nodep->lhsp(ap); nodep->lhsp(ap);
nodep->rhsp(new AstConst(nodep->fileline(), newshift)); nodep->rhsp(new AstConst(nodep->fileline(), newshift));
nodep->accept(*this); // Further reduce, either node may have more reductions. iterate(nodep); // Further reduce, either node may have more reductions.
} else { } else {
// We know shift amounts are constant, but might be a mixed left/right shift // We know shift amounts are constant, but might be a mixed left/right shift
int shift1 = VN_CAST(shift1p, Const)->toUInt(); if (VN_IS(lhsp, ShiftR)) shift1=-shift1; int shift1 = VN_CAST(shift1p, Const)->toUInt(); if (VN_IS(lhsp, ShiftR)) shift1=-shift1;
@ -947,7 +947,7 @@ private:
newp->dtypeFrom(nodep); newp->dtypeFrom(nodep);
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
//newp->dumpTree(cout, " repShiftShift_new: "); //newp->dumpTree(cout, " repShiftShift_new: ");
newp->accept(*this); // Further reduce, either node may have more reductions. iterate(newp); // Further reduce, either node may have more reductions.
} }
lhsp->deleteTree(); VL_DANGLING(lhsp); lhsp->deleteTree(); VL_DANGLING(lhsp);
} }
@ -1234,25 +1234,25 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Iterate modules backwards, in bottom-up order. That's faster // Iterate modules backwards, in bottom-up order. That's faster
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
// No ASSIGNW removals under funcs, we've long eliminated INITIALs // No ASSIGNW removals under funcs, we've long eliminated INITIALs
// (We should perhaps rename the assignw's to just assigns) // (We should perhaps rename the assignw's to just assigns)
m_wremove = false; m_wremove = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_wremove = true; m_wremove = true;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
// No ASSIGNW removals under scope, we've long eliminated INITIALs // No ASSIGNW removals under scope, we've long eliminated INITIALs
m_scopep = nodep; m_scopep = nodep;
m_wremove = false; m_wremove = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_wremove = true; m_wremove = true;
m_scopep = NULL; m_scopep = NULL;
} }
@ -1264,7 +1264,7 @@ private:
AstNode* rhsp = nodep->rhsp()->unlinkFrBackWithNext(); AstNode* rhsp = nodep->rhsp()->unlinkFrBackWithNext();
nodep->lhsp(rhsp); nodep->lhsp(rhsp);
nodep->rhsp(lhsp); nodep->rhsp(lhsp);
nodep->accept(*this); // Again? iterate(nodep); // Again?
} }
int operandConcatMove(AstConcat* nodep) { int operandConcatMove(AstConcat* nodep) {
@ -1325,13 +1325,13 @@ private:
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
if (m_params) { if (m_params) {
nodep->paramsp()->iterateAndNext(*this); iterateAndNextNull(nodep->paramsp());
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstPin* nodep) { virtual void visit(AstPin* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
void replaceSelSel(AstSel* nodep) { void replaceSelSel(AstSel* nodep) {
@ -1501,12 +1501,12 @@ private:
virtual void visit(AstAttrOf* nodep) { virtual void visit(AstAttrOf* nodep) {
AstAttrOf* oldAttr = m_attrp; AstAttrOf* oldAttr = m_attrp;
m_attrp = nodep; m_attrp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_attrp = oldAttr; m_attrp = oldAttr;
} }
virtual void visit(AstArraySel* nodep) { virtual void visit(AstArraySel* nodep) {
nodep->bitp()->iterateAndNext(*this); iterateAndNextNull(nodep->bitp());
if (VN_IS(nodep->bitp(), Const) if (VN_IS(nodep->bitp(), Const)
&& VN_IS(nodep->fromp(), VarRef) && VN_IS(nodep->fromp(), VarRef)
// Need to make sure it's an array object so don't mis-allow a constant (bug509.) // Need to make sure it's an array object so don't mis-allow a constant (bug509.)
@ -1514,7 +1514,7 @@ private:
&& VN_IS(VN_CAST(nodep->fromp(), VarRef)->varp()->valuep(), InitArray)) { && VN_IS(VN_CAST(nodep->fromp(), VarRef)->varp()->valuep(), InitArray)) {
m_selp = nodep; // Ask visit(AstVarRef) to replace varref with const m_selp = nodep; // Ask visit(AstVarRef) to replace varref with const
} }
nodep->fromp()->iterateAndNext(*this); iterateAndNextNull(nodep->fromp());
if (VN_IS(nodep->fromp(), Const)) { // It did. if (VN_IS(nodep->fromp(), Const)) { // It did.
if (!m_selp) { if (!m_selp) {
nodep->v3error("Illegal assignment of constant to unpacked array"); nodep->v3error("Illegal assignment of constant to unpacked array");
@ -1530,12 +1530,12 @@ private:
m_selp = NULL; m_selp = NULL;
} }
virtual void visit(AstNodeVarRef* nodep) { virtual void visit(AstNodeVarRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->varp()) nodep->v3fatalSrc("Not linked"); if (!nodep->varp()) nodep->v3fatalSrc("Not linked");
bool did=false; bool did=false;
if (m_doV && nodep->varp()->valuep() && !m_attrp) { if (m_doV && nodep->varp()->valuep() && !m_attrp) {
//if (debug()) valuep->dumpTree(cout," visitvaref: "); //if (debug()) valuep->dumpTree(cout," visitvaref: ");
nodep->varp()->valuep()->iterateAndNext(*this); // May change nodep->varp()->valuep() iterateAndNextNull(nodep->varp()->valuep()); // May change nodep->varp()->valuep()
AstNode* valuep = nodep->varp()->valuep(); AstNode* valuep = nodep->varp()->valuep();
if (!nodep->lvalue() if (!nodep->lvalue()
&& ((!m_params // Can reduce constant wires into equations && ((!m_params // Can reduce constant wires into equations
@ -1590,12 +1590,12 @@ private:
} }
} }
virtual void visit(AstEnumItemRef* nodep) { virtual void visit(AstEnumItemRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->itemp()) nodep->v3fatalSrc("Not linked"); if (!nodep->itemp()) nodep->v3fatalSrc("Not linked");
bool did=false; bool did=false;
if (nodep->itemp()->valuep()) { if (nodep->itemp()->valuep()) {
//if (debug()) nodep->varp()->valuep()->dumpTree(cout," visitvaref: "); //if (debug()) nodep->varp()->valuep()->dumpTree(cout," visitvaref: ");
nodep->itemp()->valuep()->iterateAndNext(*this); iterateAndNextNull(nodep->itemp()->valuep());
if (AstConst* valuep = VN_CAST(nodep->itemp()->valuep(), Const)) { if (AstConst* valuep = VN_CAST(nodep->itemp()->valuep(), Const)) {
const V3Number& num = valuep->num(); const V3Number& num = valuep->num();
replaceNum(nodep, num); VL_DANGLING(nodep); replaceNum(nodep, num); VL_DANGLING(nodep);
@ -1616,7 +1616,7 @@ private:
return (!nodep->nextp() && nodep->backp()->nextp() != nodep); return (!nodep->nextp() && nodep->backp()->nextp() != nodep);
} }
virtual void visit(AstSenItem* nodep) { virtual void visit(AstSenItem* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_doNConst if (m_doNConst
&& (VN_IS(nodep->sensp(), Const) && (VN_IS(nodep->sensp(), Const)
|| VN_IS(nodep->sensp(), EnumItemRef) || VN_IS(nodep->sensp(), EnumItemRef)
@ -1657,7 +1657,7 @@ private:
} }
} }
virtual void visit(AstSenGate* nodep) { virtual void visit(AstSenGate* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (AstConst* constp = VN_CAST(nodep->rhsp(), Const)) { if (AstConst* constp = VN_CAST(nodep->rhsp(), Const)) {
if (constp->isZero()) { if (constp->isZero()) {
UINFO(4,"SENGATE(...,0)->NEVER"<<endl); UINFO(4,"SENGATE(...,0)->NEVER"<<endl);
@ -1706,7 +1706,7 @@ private:
}; };
virtual void visit(AstSenTree* nodep) { virtual void visit(AstSenTree* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_doExpensive) { if (m_doExpensive) {
//cout<<endl; nodep->dumpTree(cout,"ssin: "); //cout<<endl; nodep->dumpTree(cout,"ssin: ");
// Optimize ideas for the future: // Optimize ideas for the future:
@ -1811,7 +1811,7 @@ private:
//----- //-----
// Zero elimination // Zero elimination
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_doNConst && replaceNodeAssign(nodep)) return; if (m_doNConst && replaceNodeAssign(nodep)) return;
} }
virtual void visit(AstAssignAlias* nodep) { virtual void visit(AstAssignAlias* nodep) {
@ -1821,7 +1821,7 @@ private:
// Don't perform any optimizations, the node won't be linked yet // Don't perform any optimizations, the node won't be linked yet
} }
virtual void visit(AstAssignW* nodep) { virtual void visit(AstAssignW* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_doNConst && replaceNodeAssign(nodep)) return; if (m_doNConst && replaceNodeAssign(nodep)) return;
AstNodeVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); // Not VarXRef, as different refs may set different values to each hierarchy AstNodeVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); // Not VarXRef, as different refs may set different values to each hierarchy
if (m_wremove && !m_params && m_doNConst if (m_wremove && !m_params && m_doNConst
@ -1848,7 +1848,7 @@ private:
} }
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_doNConst) { if (m_doNConst) {
if (const AstConst* constp = VN_CAST(nodep->condp(), Const)) { if (const AstConst* constp = VN_CAST(nodep->condp(), Const)) {
AstNode* keepp = NULL; AstNode* keepp = NULL;
@ -1927,7 +1927,7 @@ private:
virtual void visit(AstDisplay* nodep) { virtual void visit(AstDisplay* nodep) {
// DISPLAY(SFORMAT(text1)),DISPLAY(SFORMAT(text2)) -> DISPLAY(SFORMAT(text1+text2)) // DISPLAY(SFORMAT(text1)),DISPLAY(SFORMAT(text2)) -> DISPLAY(SFORMAT(text1+text2))
nodep->iterateChildren(*this); iterateChildren(nodep);
if (stmtDisplayDisplay(nodep)) return; if (stmtDisplayDisplay(nodep)) return;
} }
bool stmtDisplayDisplay(AstDisplay* nodep) { bool stmtDisplayDisplay(AstDisplay* nodep) {
@ -1974,7 +1974,7 @@ private:
// Substitute constants into displays. The main point of this is to // Substitute constants into displays. The main point of this is to
// simplify assertion methodologies which call functions with display's. // simplify assertion methodologies which call functions with display's.
// This eliminates a pile of wide temps, and makes the C a whole lot more readable. // This eliminates a pile of wide temps, and makes the C a whole lot more readable.
nodep->iterateChildren(*this); iterateChildren(nodep);
bool anyconst = false; bool anyconst = false;
for (AstNode* argp = nodep->exprsp(); argp; argp=argp->nextp()) { for (AstNode* argp = nodep->exprsp(); argp; argp=argp->nextp()) {
if (VN_IS(argp, Const)) { anyconst=true; break; } if (VN_IS(argp, Const)) { anyconst=true; break; }
@ -2033,20 +2033,20 @@ private:
} }
virtual void visit(AstFuncRef* nodep) { virtual void visit(AstFuncRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_params) { // Only parameters force us to do constant function call propagation if (m_params) { // Only parameters force us to do constant function call propagation
replaceWithSimulation(nodep); replaceWithSimulation(nodep);
} }
} }
virtual void visit(AstArg* nodep) { virtual void visit(AstArg* nodep) {
// replaceWithSimulation on the Arg's parent FuncRef replaces these // replaceWithSimulation on the Arg's parent FuncRef replaces these
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstWhile* nodep) { virtual void visit(AstWhile* nodep) {
bool oldHasJumpGo = m_hasJumpGo; bool oldHasJumpGo = m_hasJumpGo;
m_hasJumpGo = false; m_hasJumpGo = false;
{ {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
bool thisWhileHasJumpGo = m_hasJumpGo; bool thisWhileHasJumpGo = m_hasJumpGo;
m_hasJumpGo = thisWhileHasJumpGo || oldHasJumpGo; m_hasJumpGo = thisWhileHasJumpGo || oldHasJumpGo;
@ -2070,7 +2070,7 @@ private:
} }
virtual void visit(AstInitArray* nodep) { virtual void visit(AstInitArray* nodep) {
// Constant if all children are constant // Constant if all children are constant
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// These are converted by V3Param. Don't constify as we don't want the from() VARREF to disappear, if any // These are converted by V3Param. Don't constify as we don't want the from() VARREF to disappear, if any
@ -2079,7 +2079,7 @@ private:
// Ignored, can eliminate early // Ignored, can eliminate early
virtual void visit(AstSysIgnore* nodep) { virtual void visit(AstSysIgnore* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_doNConst) { if (m_doNConst) {
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
} }
@ -2087,7 +2087,7 @@ private:
// Simplify // Simplify
virtual void visit(AstBasicDType* nodep) { virtual void visit(AstBasicDType* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->cvtRangeConst(); nodep->cvtRangeConst();
} }
@ -2095,7 +2095,7 @@ private:
// Jump elimination // Jump elimination
virtual void visit(AstJumpGo* nodep) { virtual void visit(AstJumpGo* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
m_hasJumpGo = true; m_hasJumpGo = true;
if (m_doExpensive) { nodep->labelp()->user4(true); } if (m_doExpensive) { nodep->labelp()->user4(true); }
} }
@ -2104,7 +2104,7 @@ private:
// Because JumpLabels disable many optimizations, // Because JumpLabels disable many optimizations,
// remove JumpLabels that are not pointed to by any AstJumpGos // remove JumpLabels that are not pointed to by any AstJumpGos
// Note this assumes all AstJumpGos are underneath the given label; V3Broken asserts this // Note this assumes all AstJumpGos are underneath the given label; V3Broken asserts this
nodep->iterateChildren(*this); iterateChildren(nodep);
// AstJumpGo's below here that point to this node will set user4 // AstJumpGo's below here that point to this node will set user4
if (m_doExpensive && !nodep->user4()) { if (m_doExpensive && !nodep->user4()) {
UINFO(4,"JUMPLABEL => unused "<<nodep<<endl); UINFO(4,"JUMPLABEL => unused "<<nodep<<endl);
@ -2453,7 +2453,7 @@ private:
if (m_params && !nodep->width()) { if (m_params && !nodep->width()) {
nodep = V3Width::widthParamsEdit(nodep); nodep = V3Width::widthParamsEdit(nodep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
@ -2500,7 +2500,7 @@ public:
virtual ~ConstVisitor() {} virtual ~ConstVisitor() {}
AstNode* mainAcceptEdit(AstNode* nodep) { AstNode* mainAcceptEdit(AstNode* nodep) {
// Operate starting at a random place // Operate starting at a random place
return nodep->iterateSubtreeReturnEdits(*this); return iterateSubtreeReturnEdits(nodep);
} }
}; };

View File

@ -132,7 +132,7 @@ private:
m_modp = nodep; m_modp = nodep;
m_inModOff = nodep->isTop(); // Ignore coverage on top module; it's a shell we created m_inModOff = nodep->isTop(); // Ignore coverage on top module; it's a shell we created
m_fileps.clear(); m_fileps.clear();
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
m_inModOff = true; m_inModOff = true;
} }
@ -142,12 +142,12 @@ private:
bool oldtog = m_inToggleOff; bool oldtog = m_inToggleOff;
{ {
m_inToggleOff = true; m_inToggleOff = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_inToggleOff = oldtog; m_inToggleOff = oldtog;
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_modp && !m_inModOff && !m_inToggleOff if (m_modp && !m_inModOff && !m_inToggleOff
&& nodep->fileline()->coverageOn() && v3Global.opt.coverageToggle()) { && nodep->fileline()->coverageOn() && v3Global.opt.coverageToggle()) {
const char* disablep = varIgnoreToggle(nodep); const char* disablep = varIgnoreToggle(nodep);
@ -288,7 +288,7 @@ private:
&& !VN_CAST(nodep->elsesp(), If)->nextp()); && !VN_CAST(nodep->elsesp(), If)->nextp());
if (elsif) VN_CAST(nodep->elsesp(), If)->user1(true); if (elsif) VN_CAST(nodep->elsesp(), If)->user1(true);
// //
nodep->ifsp()->iterateAndNext(*this); iterateAndNextNull(nodep->ifsp());
if (m_checkBlock && !m_inModOff if (m_checkBlock && !m_inModOff
&& nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { // if a "if" branch didn't disable it && nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { // if a "if" branch didn't disable it
UINFO(4," COVER: "<<nodep<<endl); UINFO(4," COVER: "<<nodep<<endl);
@ -301,7 +301,7 @@ private:
// Don't do empty else's, only empty if/case's // Don't do empty else's, only empty if/case's
if (nodep->elsesp()) { if (nodep->elsesp()) {
m_checkBlock = true; m_checkBlock = true;
nodep->elsesp()->iterateAndNext(*this); iterateAndNextNull(nodep->elsesp());
if (m_checkBlock && !m_inModOff if (m_checkBlock && !m_inModOff
&& nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { // if a "else" branch didn't disable it && nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { // if a "else" branch didn't disable it
UINFO(4," COVER: "<<nodep<<endl); UINFO(4," COVER: "<<nodep<<endl);
@ -317,7 +317,7 @@ private:
UINFO(4," CASEI: "<<nodep<<endl); UINFO(4," CASEI: "<<nodep<<endl);
if (m_checkBlock && !m_inModOff if (m_checkBlock && !m_inModOff
&& nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { && nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) {
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
if (m_checkBlock) { // if the case body didn't disable it if (m_checkBlock) { // if the case body didn't disable it
UINFO(4," COVER: "<<nodep<<endl); UINFO(4," COVER: "<<nodep<<endl);
nodep->addBodysp(newCoverInc(nodep->fileline(), "", "v_line", "case")); nodep->addBodysp(newCoverInc(nodep->fileline(), "", "v_line", "case"));
@ -328,7 +328,7 @@ private:
virtual void visit(AstPslCover* nodep) { virtual void visit(AstPslCover* nodep) {
UINFO(4," PSLCOVER: "<<nodep<<endl); UINFO(4," PSLCOVER: "<<nodep<<endl);
m_checkBlock = true; // Always do cover blocks, even if there's a $stop m_checkBlock = true; // Always do cover blocks, even if there's a $stop
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->coverincp()) { if (!nodep->coverincp()) {
// Note the name may be overridden by V3Assert processing // Note the name may be overridden by V3Assert processing
nodep->coverincp(newCoverInc(nodep->fileline(), m_beginHier, "v_user", "cover")); nodep->coverincp(newCoverInc(nodep->fileline(), m_beginHier, "v_user", "cover"));
@ -346,7 +346,7 @@ private:
m_checkBlock = false; m_checkBlock = false;
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
} else { } else {
if (m_checkBlock) nodep->iterateChildren(*this); if (m_checkBlock) iterateChildren(nodep);
} }
} }
virtual void visit(AstBegin* nodep) { virtual void visit(AstBegin* nodep) {
@ -362,7 +362,7 @@ private:
if (nodep->name()!="") { if (nodep->name()!="") {
m_beginHier = m_beginHier + (m_beginHier!=""?".":"") + nodep->name(); m_beginHier = m_beginHier + (m_beginHier!=""?".":"") + nodep->name();
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_beginHier = oldHier; m_beginHier = oldHier;
m_inToggleOff = oldtog; m_inToggleOff = oldtog;
@ -372,7 +372,7 @@ private:
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
if (m_checkBlock) { if (m_checkBlock) {
nodep->iterateChildren(*this); iterateChildren(nodep);
m_checkBlock = true; // Reset as a child may have cleared it m_checkBlock = true; // Reset as a child may have cleared it
} }
} }
@ -385,7 +385,7 @@ public:
m_beginHier = ""; m_beginHier = "";
m_inToggleOff = false; m_inToggleOff = false;
m_inModOff = true; m_inModOff = true;
rootp->iterateChildren(*this); iterateChildren(rootp);
} }
virtual ~CoverageVisitor() {} virtual ~CoverageVisitor() {}
}; };

View File

@ -105,24 +105,24 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Find all Coverage's // Find all Coverage's
nodep->iterateChildren(*this); iterateChildren(nodep);
// Simplify // Simplify
detectDuplicates(); detectDuplicates();
} }
virtual void visit(AstCoverToggle* nodep) { virtual void visit(AstCoverToggle* nodep) {
m_toggleps.push_back(nodep); m_toggleps.push_back(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//-------------------- //--------------------
virtual void visit(AstNodeMath* nodep) {} // Accelerate virtual void visit(AstNodeMath* nodep) {} // Accelerate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit CoverageJoinVisitor(AstNetlist* nodep) { explicit CoverageJoinVisitor(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~CoverageJoinVisitor() { virtual ~CoverageJoinVisitor() {
V3Stats::addStat("Coverage, Toggle points joined", m_statToggleJoins); V3Stats::addStat("Coverage, Toggle points joined", m_statToggleJoins);

View File

@ -59,18 +59,18 @@ private:
// ** Shared with DeadVisitor ** // ** Shared with DeadVisitor **
// VISITORS // VISITORS
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->modp()->user1Inc(-1); nodep->modp()->user1Inc(-1);
} }
//----- //-----
virtual void visit(AstNodeMath* nodep) {} // Accelerate virtual void visit(AstNodeMath* nodep) {} // Accelerate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit DeadModVisitor(AstNodeModule* nodep) { explicit DeadModVisitor(AstNodeModule* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~DeadModVisitor() {} virtual ~DeadModVisitor() {}
}; };
@ -138,18 +138,18 @@ private:
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
if (!nodep->dead()) { if (!nodep->dead()) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
} }
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->scopep()) nodep->scopep()->user1Inc(); if (nodep->scopep()) nodep->scopep()->user1Inc();
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->aboveScopep()) nodep->aboveScopep()->user1Inc(); if (nodep->aboveScopep()) nodep->aboveScopep()->user1Inc();
@ -158,14 +158,14 @@ private:
} }
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
m_cellsp.push_back(nodep); m_cellsp.push_back(nodep);
nodep->modp()->user1Inc(); nodep->modp()->user1Inc();
} }
virtual void visit(AstNodeVarRef* nodep) { virtual void visit(AstNodeVarRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->varScopep()) { if (nodep->varScopep()) {
nodep->varScopep()->user1Inc(); nodep->varScopep()->user1Inc();
@ -180,7 +180,7 @@ private:
} }
} }
virtual void visit(AstNodeFTaskRef* nodep) { virtual void visit(AstNodeFTaskRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->packagep()) { if (nodep->packagep()) {
if (m_elimCells) nodep->packagep(NULL); if (m_elimCells) nodep->packagep(NULL);
@ -188,7 +188,7 @@ private:
} }
} }
virtual void visit(AstRefDType* nodep) { virtual void visit(AstRefDType* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkDType(nodep); checkDType(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->packagep()) { if (nodep->packagep()) {
@ -197,12 +197,12 @@ private:
} }
} }
virtual void visit(AstNodeDType* nodep) { virtual void visit(AstNodeDType* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkDType(nodep); checkDType(nodep);
checkAll(nodep); checkAll(nodep);
} }
virtual void visit(AstEnumItemRef* nodep) { virtual void visit(AstEnumItemRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->packagep()) { if (nodep->packagep()) {
if (m_elimCells) nodep->packagep(NULL); if (m_elimCells) nodep->packagep(NULL);
@ -211,7 +211,7 @@ private:
checkAll(nodep); checkAll(nodep);
} }
virtual void visit(AstModport* nodep) { virtual void visit(AstModport* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_elimCells) { if (m_elimCells) {
if (!nodep->varsp()) { if (!nodep->varsp()) {
pushDeletep(nodep->unlinkFrBack()); VL_DANGLING(nodep); pushDeletep(nodep->unlinkFrBack()); VL_DANGLING(nodep);
@ -221,7 +221,7 @@ private:
checkAll(nodep); checkAll(nodep);
} }
virtual void visit(AstTypedef* nodep) { virtual void visit(AstTypedef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_elimCells && !nodep->attrPublic()) { if (m_elimCells && !nodep->attrPublic()) {
pushDeletep(nodep->unlinkFrBack()); VL_DANGLING(nodep); pushDeletep(nodep->unlinkFrBack()); VL_DANGLING(nodep);
return; return;
@ -232,7 +232,7 @@ private:
if (nodep->attrPublic() && m_modp && VN_IS(m_modp, Package)) m_modp->user1Inc(); if (nodep->attrPublic() && m_modp && VN_IS(m_modp, Package)) m_modp->user1Inc();
} }
virtual void visit(AstVarScope* nodep) { virtual void visit(AstVarScope* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->scopep()) nodep->scopep()->user1Inc(); if (nodep->scopep()) nodep->scopep()->user1Inc();
if (mightElimVar(nodep->varp())) { if (mightElimVar(nodep->varp())) {
@ -240,7 +240,7 @@ private:
} }
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
if (nodep->isSigPublic() && m_modp && VN_IS(m_modp, Package)) m_modp->user1Inc(); if (nodep->isSigPublic() && m_modp && VN_IS(m_modp, Package)) m_modp->user1Inc();
if (mightElimVar(nodep)) { if (mightElimVar(nodep)) {
@ -251,7 +251,7 @@ private:
// See if simple assignments to variables may be eliminated because that variable is never used. // See if simple assignments to variables may be eliminated because that variable is never used.
// Similar code in V3Life // Similar code in V3Life
m_sideEffect = false; m_sideEffect = false;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
checkAll(nodep); checkAll(nodep);
// Has to be direct assignment without any EXTRACTing. // Has to be direct assignment without any EXTRACTing.
AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef);
@ -260,7 +260,7 @@ private:
m_assignMap.insert(make_pair(varrefp->varScopep(), nodep)); m_assignMap.insert(make_pair(varrefp->varScopep(), nodep));
checkAll(varrefp); // Must track reference to dtype() checkAll(varrefp); // Must track reference to dtype()
} else { // Track like any other statement } else { // Track like any other statement
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
} }
checkAll(nodep); checkAll(nodep);
} }
@ -268,7 +268,7 @@ private:
//----- //-----
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
if (nodep->isOutputter()) m_sideEffect=true; if (nodep->isOutputter()) m_sideEffect=true;
nodep->iterateChildren(*this); iterateChildren(nodep);
checkAll(nodep); checkAll(nodep);
} }
@ -405,7 +405,7 @@ public:
// Prepare to remove some datatypes // Prepare to remove some datatypes
nodep->typeTablep()->clearCache(); nodep->typeTablep()->clearCache();
// Operate on whole netlist // Operate on whole netlist
nodep->accept(*this); iterate(nodep);
deadCheckVar(); deadCheckVar();
// We only elimate scopes when in a flattened structure // We only elimate scopes when in a flattened structure

View File

@ -344,16 +344,16 @@ private:
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
//VV***** We reset all userp() on the netlist //VV***** We reset all userp() on the netlist
m_modVarMap.clear(); m_modVarMap.clear();
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
AstNode::user3ClearTree(); AstNode::user3ClearTree();
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
m_cfuncp = nodep; m_cfuncp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_cfuncp = NULL; m_cfuncp = NULL;
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
@ -361,7 +361,7 @@ private:
bool oldinit = m_inInitial; bool oldinit = m_inInitial;
m_inInitial = nodep->hasInitial(); m_inInitial = nodep->hasInitial();
AstNode::user3ClearTree(); // Two sets to same variable in different actives must use different vars. AstNode::user3ClearTree(); // Two sets to same variable in different actives must use different vars.
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inInitial = oldinit; m_inInitial = oldinit;
} }
virtual void visit(AstAssignDly* nodep) { virtual void visit(AstAssignDly* nodep) {
@ -382,7 +382,7 @@ private:
lhsp->deleteTree(); VL_DANGLING(lhsp); lhsp->deleteTree(); VL_DANGLING(lhsp);
} }
else { else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_inDly = false; m_inDly = false;
m_nextDlyp = NULL; m_nextDlyp = NULL;
@ -443,14 +443,14 @@ private:
virtual void visit(AstWhile* nodep) { virtual void visit(AstWhile* nodep) {
bool oldloop = m_inLoop; bool oldloop = m_inLoop;
m_inLoop = true; m_inLoop = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inLoop = oldloop; m_inLoop = oldloop;
} }
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -463,7 +463,7 @@ public:
m_inLoop = false; m_inLoop = false;
m_inInitial = false; m_inInitial = false;
nodep->accept(*this); iterate(nodep);
} }
virtual ~DelayedVisitor() { virtual ~DelayedVisitor() {
V3Stats::addStat("Optimizations, Delayed shared-sets", m_statSharedSet); V3Stats::addStat("Optimizations, Delayed shared-sets", m_statSharedSet);

View File

@ -89,21 +89,21 @@ private:
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
m_modp = nodep; m_modp = nodep;
m_funcp = NULL; m_funcp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
m_funcp = nodep; m_funcp = nodep;
m_depth = 0; m_depth = 0;
m_maxdepth = 0; m_maxdepth = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_funcp = NULL; m_funcp = NULL;
} }
void visitStmt(AstNodeStmt* nodep) { void visitStmt(AstNodeStmt* nodep) {
m_depth = 0; m_depth = 0;
m_maxdepth = 0; m_maxdepth = 0;
m_stmtp = nodep; m_stmtp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_stmtp = NULL; m_stmtp = NULL;
} }
virtual void visit(AstNodeStmt* nodep) { virtual void visit(AstNodeStmt* nodep) {
@ -116,7 +116,7 @@ private:
// We have some operator defines that use 2 parens, so += 2. // We have some operator defines that use 2 parens, so += 2.
m_depth += 2; m_depth += 2;
if (m_depth>m_maxdepth) m_maxdepth=m_depth; if (m_depth>m_maxdepth) m_maxdepth=m_depth;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_depth -= 2; m_depth -= 2;
if (m_stmtp if (m_stmtp
@ -141,7 +141,7 @@ private:
} }
virtual void visit(AstUCFunc* nodep) { virtual void visit(AstUCFunc* nodep) {
needNonStaticFunc(nodep); needNonStaticFunc(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstUCStmt* nodep) { virtual void visit(AstUCStmt* nodep) {
needNonStaticFunc(nodep); needNonStaticFunc(nodep);
@ -152,7 +152,7 @@ private:
// Default: Just iterate // Default: Just iterate
virtual void visit(AstVar* nodep) {} // Don't hit varrefs under vars virtual void visit(AstVar* nodep) {} // Don't hit varrefs under vars
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -164,7 +164,7 @@ public:
m_depth=0; m_depth=0;
m_maxdepth=0; m_maxdepth=0;
// //
nodep->accept(*this); iterate(nodep);
} }
virtual ~DepthVisitor() {} virtual ~DepthVisitor() {}
}; };

View File

@ -80,7 +80,7 @@ private:
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
m_modp = nodep; m_modp = nodep;
m_deepNum = 0; m_deepNum = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
@ -90,7 +90,7 @@ private:
{ {
m_depth = 0; m_depth = 0;
m_funcp = nodep; m_funcp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_depth = lastDepth; m_depth = lastDepth;
m_funcp = lastFuncp; m_funcp = lastFuncp;
@ -103,11 +103,11 @@ private:
AstNode* backp = nodep->backp(); // Only for debug AstNode* backp = nodep->backp(); // Only for debug
if (debug()>=9) backp->dumpTree(cout,"- pre : "); if (debug()>=9) backp->dumpTree(cout,"- pre : ");
AstCFunc* funcp = createDeepFunc(nodep); AstCFunc* funcp = createDeepFunc(nodep);
funcp->accept(*this); iterate(funcp);
if (debug()>=9) backp->dumpTree(cout,"- post: "); if (debug()>=9) backp->dumpTree(cout,"- post: ");
if (debug()>=9) funcp->dumpTree(cout,"- func: "); if (debug()>=9) funcp->dumpTree(cout,"- func: ");
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_depth--; m_depth--;
} }
@ -120,7 +120,7 @@ private:
// Default: Just iterate // Default: Just iterate
virtual void visit(AstVar* nodep) {} // Don't hit varrefs under vars virtual void visit(AstVar* nodep) {} // Don't hit varrefs under vars
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -129,7 +129,7 @@ public:
m_modp=NULL; m_modp=NULL;
m_depth=0; m_depth=0;
// //
nodep->accept(*this); iterate(nodep);
} }
virtual ~DepthBlockVisitor() {} virtual ~DepthBlockVisitor() {}
}; };

View File

@ -234,13 +234,13 @@ private:
m_modp = nodep; m_modp = nodep;
m_modFuncs.clear(); m_modFuncs.clear();
m_modSingleton = modIsSingleton(m_modp); m_modSingleton = modIsSingleton(m_modp);
nodep->iterateChildren(*this); iterateChildren(nodep);
makePublicFuncWrappers(); makePublicFuncWrappers();
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
m_scopep = nodep; m_scopep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_scopep = NULL; m_scopep = NULL;
} }
virtual void visit(AstVarScope* nodep) { virtual void visit(AstVarScope* nodep) {
@ -249,7 +249,7 @@ private:
pushDeletep(nodep); pushDeletep(nodep);
} }
virtual void visit(AstNodeVarRef* nodep) { virtual void visit(AstNodeVarRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Convert the hierch name // Convert the hierch name
if (!m_scopep) nodep->v3fatalSrc("Node not under scope"); if (!m_scopep) nodep->v3fatalSrc("Node not under scope");
bool hierThis; bool hierThis;
@ -259,7 +259,7 @@ private:
} }
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
//UINFO(9," "<<nodep<<endl); //UINFO(9," "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
// Convert the hierch name // Convert the hierch name
if (!m_scopep) nodep->v3fatalSrc("Node not under scope"); if (!m_scopep) nodep->v3fatalSrc("Node not under scope");
if (!nodep->funcp()->scopep()) nodep->v3fatalSrc("CFunc not under scope"); if (!nodep->funcp()->scopep()) nodep->v3fatalSrc("CFunc not under scope");
@ -271,7 +271,7 @@ private:
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
if (!nodep->user1()) { if (!nodep->user1()) {
m_needThis = false; m_needThis = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->user1(true); nodep->user1(true);
if (m_needThis) { if (m_needThis) {
nodep->isStatic(false); nodep->isStatic(false);
@ -292,7 +292,7 @@ private:
} }
virtual void visit(AstVar*) {} virtual void visit(AstVar*) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -301,7 +301,7 @@ public:
m_scopep(NULL), m_scopep(NULL),
m_modSingleton(false), m_modSingleton(false),
m_needThis(false) { m_needThis(false) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~DescopeVisitor() {} virtual ~DescopeVisitor() {}
}; };

View File

@ -123,7 +123,7 @@ public:
for (AstEnumItem* itemp = adtypep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), EnumItem)) { for (AstEnumItem* itemp = adtypep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), EnumItem)) {
puts(itemp->name()); puts(itemp->name());
puts(" = "); puts(" = ");
itemp->valuep()->iterateAndNext(*this); iterateAndNextNull(itemp->valuep());
if (VN_IS(itemp->nextp(), EnumItem)) puts(","); if (VN_IS(itemp->nextp(), EnumItem)) puts(",");
puts("\n"); puts("\n");
} }
@ -148,8 +148,8 @@ public:
puts("I("); puts("I(");
} }
puts(cvtToStr(nodep->widthMin())+","); puts(cvtToStr(nodep->widthMin())+",");
selp->lsbp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(selp->lsbp()); puts(", ");
selp->fromp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(selp->fromp()); puts(", ");
} else { } else {
putbs("VL_ASSIGNSEL_"); putbs("VL_ASSIGNSEL_");
emitIQW (selp->fromp()); emitIQW (selp->fromp());
@ -157,8 +157,8 @@ public:
emitIQW(nodep->rhsp()); emitIQW(nodep->rhsp());
puts("("); puts("(");
puts(cvtToStr(nodep->widthMin())+","); puts(cvtToStr(nodep->widthMin())+",");
selp->lsbp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(selp->lsbp()); puts(", ");
selp->fromp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(selp->fromp()); puts(", ");
} }
} else if (AstVar* varp = AstVar::scVarRecurse(nodep->lhsp())) { } else if (AstVar* varp = AstVar::scVarRecurse(nodep->lhsp())) {
putbs("VL_ASSIGN_"); // Set a systemC variable putbs("VL_ASSIGN_"); // Set a systemC variable
@ -166,14 +166,14 @@ public:
emitIQW(nodep); emitIQW(nodep);
puts("("); puts("(");
puts(cvtToStr(nodep->widthMin())+","); puts(cvtToStr(nodep->widthMin())+",");
nodep->lhsp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(nodep->lhsp()); puts(", ");
} else if (AstVar* varp = AstVar::scVarRecurse(nodep->rhsp())) { } else if (AstVar* varp = AstVar::scVarRecurse(nodep->rhsp())) {
putbs("VL_ASSIGN_"); // Get a systemC variable putbs("VL_ASSIGN_"); // Get a systemC variable
emitIQW(nodep); emitIQW(nodep);
emitScIQW(varp); emitScIQW(varp);
puts("("); puts("(");
puts(cvtToStr(nodep->widthMin())+","); puts(cvtToStr(nodep->widthMin())+",");
nodep->lhsp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(nodep->lhsp()); puts(", ");
} else if (nodep->isWide() } else if (nodep->isWide()
&& VN_IS(nodep->lhsp(), VarRef) && VN_IS(nodep->lhsp(), VarRef)
&& !VN_IS(nodep->rhsp(), CMath) && !VN_IS(nodep->rhsp(), CMath)
@ -185,16 +185,16 @@ public:
} else if (nodep->isWide()) { } else if (nodep->isWide()) {
putbs("VL_ASSIGN_W("); putbs("VL_ASSIGN_W(");
puts(cvtToStr(nodep->widthMin())+","); puts(cvtToStr(nodep->widthMin())+",");
nodep->lhsp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(nodep->lhsp()); puts(", ");
} else { } else {
paren = false; paren = false;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(" "); puts(" ");
ofp()->blockInc(); decind = true; ofp()->blockInc(); decind = true;
if (!VN_IS(nodep->rhsp(), Const)) ofp()->putBreak(); if (!VN_IS(nodep->rhsp(), Const)) ofp()->putBreak();
puts("= "); puts("= ");
} }
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
if (paren) puts(")"); if (paren) puts(")");
if (decind) ofp()->blockDec(); if (decind) ofp()->blockDec();
if (!m_suppressSemi) puts(";\n"); if (!m_suppressSemi) puts(";\n");
@ -209,7 +209,7 @@ public:
bool comma = (nodep->argTypes() != ""); bool comma = (nodep->argTypes() != "");
for (AstNode* subnodep=nodep->argsp(); subnodep; subnodep = subnodep->nextp()) { for (AstNode* subnodep=nodep->argsp(); subnodep; subnodep = subnodep->nextp()) {
if (comma) puts(", "); if (comma) puts(", ");
subnodep->accept(*this); iterate(subnodep);
comma = true; comma = true;
} }
if (VN_IS(nodep->backp(), NodeMath) || VN_IS(nodep->backp(), CReturn)) { if (VN_IS(nodep->backp(), NodeMath) || VN_IS(nodep->backp(), CReturn)) {
@ -225,7 +225,7 @@ public:
} }
virtual void visit(AstComment* nodep) { virtual void visit(AstComment* nodep) {
putsDecoration((string)"// "+nodep->name()+" at "+nodep->fileline()->ascii()+"\n"); putsDecoration((string)"// "+nodep->name()+" at "+nodep->fileline()->ascii()+"\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCoverDecl* nodep) { virtual void visit(AstCoverDecl* nodep) {
puts("__vlCoverInsert("); // As Declared in emitCoverageDecl puts("__vlCoverInsert("); // As Declared in emitCoverageDecl
@ -252,7 +252,7 @@ public:
} }
virtual void visit(AstCReturn* nodep) { virtual void visit(AstCReturn* nodep) {
puts("return ("); puts("return (");
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstDisplay* nodep) { virtual void visit(AstDisplay* nodep) {
@ -289,7 +289,7 @@ public:
emitCvtPackStr(nodep->searchp()); emitCvtPackStr(nodep->searchp());
puts(","); puts(",");
putbs(""); putbs("");
nodep->outp()->iterateAndNext(*this); iterateAndNextNull(nodep->outp());
puts(")"); puts(")");
} }
virtual void visit(AstTestPlusArgs* nodep) { virtual void visit(AstTestPlusArgs* nodep) {
@ -308,7 +308,7 @@ public:
} }
} }
virtual void visit(AstFOpen* nodep) { virtual void visit(AstFOpen* nodep) {
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
puts(" = VL_FOPEN_"); puts(" = VL_FOPEN_");
emitIQW(nodep->filenamep()); emitIQW(nodep->filenamep());
emitIQW(nodep->modep()); emitIQW(nodep->modep());
@ -319,9 +319,9 @@ public:
putbs(", "); putbs(", ");
} }
checkMaxWords(nodep->filenamep()); checkMaxWords(nodep->filenamep());
nodep->filenamep()->iterateAndNext(*this); iterateAndNextNull(nodep->filenamep());
putbs(", "); putbs(", ");
nodep->modep()->iterateAndNext(*this); iterateAndNextNull(nodep->modep());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstNodeReadWriteMem* nodep) { virtual void visit(AstNodeReadWriteMem* nodep) {
@ -353,19 +353,19 @@ public:
checkMaxWords(nodep->filenamep()); checkMaxWords(nodep->filenamep());
putbs(", "); putbs(", ");
} }
nodep->filenamep()->iterateAndNext(*this); iterateAndNextNull(nodep->filenamep());
putbs(", "); putbs(", ");
nodep->memp()->iterateAndNext(*this); iterateAndNextNull(nodep->memp());
putbs(","); if (nodep->lsbp()) { nodep->lsbp()->iterateAndNext(*this); } putbs(","); if (nodep->lsbp()) { iterateAndNextNull(nodep->lsbp()); }
else puts(cvtToStr(array_lsb)); else puts(cvtToStr(array_lsb));
putbs(","); if (nodep->msbp()) { nodep->msbp()->iterateAndNext(*this); } else puts("~0"); putbs(","); if (nodep->msbp()) { iterateAndNextNull(nodep->msbp()); } else puts("~0");
puts(");\n"); puts(");\n");
} }
virtual void visit(AstFClose* nodep) { virtual void visit(AstFClose* nodep) {
puts("VL_FCLOSE_I("); puts("VL_FCLOSE_I(");
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
puts("); "); puts("); ");
nodep->filep()->iterateAndNext(*this); // For saftey, so user doesn't later WRITE with it. iterateAndNextNull(nodep->filep()); // For saftey, so user doesn't later WRITE with it.
puts("=0;\n"); puts("=0;\n");
} }
virtual void visit(AstFFlush* nodep) { virtual void visit(AstFFlush* nodep) {
@ -373,15 +373,15 @@ public:
puts("fflush (stdout);\n"); puts("fflush (stdout);\n");
} else { } else {
puts("if ("); puts("if (");
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
puts(") { fflush (VL_CVT_I_FP("); puts(") { fflush (VL_CVT_I_FP(");
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
puts(")); }\n"); puts(")); }\n");
} }
} }
virtual void visit(AstSysFuncAsTask* nodep) { virtual void visit(AstSysFuncAsTask* nodep) {
if (!nodep->lhsp()->isWide()) puts("(void)"); if (!nodep->lhsp()->isWide()) puts("(void)");
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
if (!nodep->lhsp()->isWide()) puts(";"); if (!nodep->lhsp()->isWide()) puts(";");
} }
virtual void visit(AstSystemT* nodep) { virtual void visit(AstSystemT* nodep) {
@ -393,7 +393,7 @@ public:
putbs(", "); putbs(", ");
} }
checkMaxWords(nodep->lhsp()); checkMaxWords(nodep->lhsp());
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstSystemF* nodep) { virtual void visit(AstSystemF* nodep) {
@ -405,7 +405,7 @@ public:
putbs(", "); putbs(", ");
} }
checkMaxWords(nodep->lhsp()); checkMaxWords(nodep->lhsp());
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(")"); puts(")");
} }
virtual void visit(AstJumpGo* nodep) { virtual void visit(AstJumpGo* nodep) {
@ -413,18 +413,18 @@ public:
} }
virtual void visit(AstJumpLabel* nodep) { virtual void visit(AstJumpLabel* nodep) {
puts("{\n"); puts("{\n");
nodep->stmtsp()->iterateAndNext(*this); iterateAndNextNull(nodep->stmtsp());
puts("}\n"); puts("}\n");
puts("__Vlabel"+cvtToStr(nodep->labelNum())+": ;\n"); puts("__Vlabel"+cvtToStr(nodep->labelNum())+": ;\n");
} }
virtual void visit(AstWhile* nodep) { virtual void visit(AstWhile* nodep) {
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
puts("while ("); puts("while (");
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
puts(") {\n"); puts(") {\n");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
nodep->precondsp()->iterateAndNext(*this); // Need to recompute before next loop iterateAndNextNull(nodep->precondsp()); // Need to recompute before next loop
puts("}\n"); puts("}\n");
} }
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
@ -432,13 +432,13 @@ public:
if (nodep->branchPred() != AstBranchPred::BP_UNKNOWN) { if (nodep->branchPred() != AstBranchPred::BP_UNKNOWN) {
puts(nodep->branchPred().ascii()); puts("("); puts(nodep->branchPred().ascii()); puts("(");
} }
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
if (nodep->branchPred() != AstBranchPred::BP_UNKNOWN) puts(")"); if (nodep->branchPred() != AstBranchPred::BP_UNKNOWN) puts(")");
puts(") {\n"); puts(") {\n");
nodep->ifsp()->iterateAndNext(*this); iterateAndNextNull(nodep->ifsp());
if (nodep->elsesp()) { if (nodep->elsesp()) {
puts("} else {\n"); puts("} else {\n");
nodep->elsesp()->iterateAndNext(*this); iterateAndNextNull(nodep->elsesp());
} }
puts("}\n"); puts("}\n");
} }
@ -465,21 +465,21 @@ public:
} }
virtual void visit(AstCStmt* nodep) { virtual void visit(AstCStmt* nodep) {
putbs(""); putbs("");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
} }
virtual void visit(AstCMath* nodep) { virtual void visit(AstCMath* nodep) {
putbs(""); putbs("");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
} }
virtual void visit(AstUCStmt* nodep) { virtual void visit(AstUCStmt* nodep) {
putsDecoration("// $c statement at "+nodep->fileline()->ascii()+"\n"); putsDecoration("// $c statement at "+nodep->fileline()->ascii()+"\n");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
puts("\n"); puts("\n");
} }
virtual void visit(AstUCFunc* nodep) { virtual void visit(AstUCFunc* nodep) {
puts("\n"); puts("\n");
putsDecoration("// $c function at "+nodep->fileline()->ascii()+"\n"); putsDecoration("// $c function at "+nodep->fileline()->ascii()+"\n");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
puts("\n"); puts("\n");
} }
@ -490,16 +490,16 @@ public:
virtual void visit(AstNodeUniop* nodep) { virtual void visit(AstNodeUniop* nodep) {
if (emitSimpleOk(nodep)) { if (emitSimpleOk(nodep)) {
putbs("("); puts(nodep->emitSimpleOperator()); puts(" "); putbs("("); puts(nodep->emitSimpleOperator()); puts(" ");
nodep->lhsp()->iterateAndNext(*this); puts(")"); iterateAndNextNull(nodep->lhsp()); puts(")");
} else { } else {
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), NULL, NULL); emitOpName(nodep, nodep->emitC(), nodep->lhsp(), NULL, NULL);
} }
} }
virtual void visit(AstNodeBiop* nodep) { virtual void visit(AstNodeBiop* nodep) {
if (emitSimpleOk(nodep)) { if (emitSimpleOk(nodep)) {
putbs("("); nodep->lhsp()->iterateAndNext(*this); putbs("("); iterateAndNextNull(nodep->lhsp());
puts(" "); putbs(nodep->emitSimpleOperator()); puts(" "); puts(" "); putbs(nodep->emitSimpleOperator()); puts(" ");
nodep->rhsp()->iterateAndNext(*this); puts(")"); iterateAndNextNull(nodep->rhsp()); puts(")");
} else { } else {
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), NULL); emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), NULL);
} }
@ -511,7 +511,7 @@ public:
putbs("VL_REDXOR_"); putbs("VL_REDXOR_");
puts(cvtToStr(nodep->lhsp()->dtypep()->widthPow2())); puts(cvtToStr(nodep->lhsp()->dtypep()->widthPow2()));
puts("("); puts("(");
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(")"); puts(")");
} }
} }
@ -557,7 +557,7 @@ public:
} else { } else {
puts("(IData)("); puts("(IData)(");
} }
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(")"); puts(")");
} }
virtual void visit(AstNodeCond* nodep) { virtual void visit(AstNodeCond* nodep) {
@ -566,9 +566,9 @@ public:
emitOpName(nodep, nodep->emitC(), nodep->condp(), nodep->expr1p(), nodep->expr2p()); emitOpName(nodep, nodep->emitC(), nodep->condp(), nodep->expr1p(), nodep->expr2p());
} else { } else {
putbs("("); putbs("(");
nodep->condp()->iterateAndNext(*this); putbs(" ? "); iterateAndNextNull(nodep->condp()); putbs(" ? ");
nodep->expr1p()->iterateAndNext(*this); putbs(" : "); iterateAndNextNull(nodep->expr1p()); putbs(" : ");
nodep->expr2p()->iterateAndNext(*this); puts(")"); iterateAndNextNull(nodep->expr2p()); puts(")");
} }
} }
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
@ -587,8 +587,8 @@ public:
if (nodep->lhsp()) { puts(","+cvtToStr(nodep->lhsp()->widthMin())); } if (nodep->lhsp()) { puts(","+cvtToStr(nodep->lhsp()->widthMin())); }
if (nodep->rhsp()) { puts(","+cvtToStr(nodep->rhsp()->widthMin())); } if (nodep->rhsp()) { puts(","+cvtToStr(nodep->rhsp()->widthMin())); }
puts(","); puts(",");
nodep->lhsp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(nodep->lhsp()); puts(", ");
nodep->rhsp()->iterateAndNext(*this); puts(")"); iterateAndNextNull(nodep->rhsp()); puts(")");
} else { } else {
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), NULL); emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), NULL);
} }
@ -607,7 +607,7 @@ public:
puts(","+cvtToStr(nodep->lhsp()->widthMin())); puts(","+cvtToStr(nodep->lhsp()->widthMin()));
puts(","+cvtToStr(nodep->rhsp()->widthMin())); puts(","+cvtToStr(nodep->rhsp()->widthMin()));
puts(","); puts(",");
nodep->lhsp()->iterateAndNext(*this); puts(", "); iterateAndNextNull(nodep->lhsp()); puts(", ");
uint32_t rd_log2 = V3Number::log2b(VN_CAST(nodep->rhsp(), Const)->toUInt()); uint32_t rd_log2 = V3Number::log2b(VN_CAST(nodep->rhsp(), Const)->toUInt());
puts(cvtToStr(rd_log2)+")"); puts(cvtToStr(rd_log2)+")");
return; return;
@ -633,7 +633,7 @@ public:
puts(cvtToStr(nodep->widthWords())); // Note argument width, not node width (which is always 32) puts(cvtToStr(nodep->widthWords())); // Note argument width, not node width (which is always 32)
puts(","); puts(",");
} }
nodep->iterateAndNext(*this); iterateAndNextNull(nodep);
puts(")"); puts(")");
} }
} }
@ -675,7 +675,7 @@ public:
puts(assigntop->hiername()); puts(assigntop->hiername());
puts(assigntop->varp()->name()); puts(assigntop->varp()->name());
} else { } else {
assigntop->iterateAndNext(*this); iterateAndNextNull(assigntop);
} }
for (int word=VL_WORDS_I(upWidth)-1; word>=0; word--) { for (int word=VL_WORDS_I(upWidth)-1; word>=0; word--) {
// Only 32 bits - llx + long long here just to appease CPP format warning // Only 32 bits - llx + long long here just to appease CPP format warning
@ -696,7 +696,7 @@ public:
puts(assigntop->hiername()); puts(assigntop->hiername());
puts(assigntop->varp()->name()); puts(assigntop->varp()->name());
} else { } else {
assigntop->iterateAndNext(*this); iterateAndNextNull(assigntop);
} }
for (int word=EMITC_NUM_CONSTW-1; word>=0; word--) { for (int word=EMITC_NUM_CONSTW-1; word>=0; word--) {
// Only 32 bits - llx + long long here just to appease CPP format warning // Only 32 bits - llx + long long here just to appease CPP format warning
@ -748,13 +748,13 @@ public:
// Just iterate // Just iterate
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// NOPs // NOPs
virtual void visit(AstTypedef*) {} virtual void visit(AstTypedef*) {}
@ -768,7 +768,7 @@ public:
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
puts((string)"\n???? // "+nodep->prettyTypeName()+"\n"); puts((string)"\n???? // "+nodep->prettyTypeName()+"\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->v3fatalSrc("Unknown node type reached emitter: "<<nodep->prettyTypeName()); nodep->v3fatalSrc("Unknown node type reached emitter: "<<nodep->prettyTypeName());
} }
@ -799,7 +799,7 @@ class EmitCImp : EmitCStmts {
if (!changep->rhsp()) { if (!changep->rhsp()) {
if (!gotOne) gotOne = true; if (!gotOne) gotOne = true;
else puts(" | "); else puts(" | ");
changep->lhsp()->iterateAndNext(*this); iterateAndNextNull(changep->lhsp());
} }
else { else {
AstNode* lhsp = changep->lhsp(); AstNode* lhsp = changep->lhsp();
@ -818,11 +818,11 @@ class EmitCImp : EmitCStmts {
} else { } else {
puts(" | ("); puts(" | (");
} }
changep->lhsp()->iterateAndNext(*this); iterateAndNextNull(changep->lhsp());
if (changep->lhsp()->isWide()) puts("["+cvtToStr(word)+"]"); if (changep->lhsp()->isWide()) puts("["+cvtToStr(word)+"]");
if (changep->lhsp()->isDouble()) puts(" != "); if (changep->lhsp()->isDouble()) puts(" != ");
else puts(" ^ "); else puts(" ^ ");
changep->rhsp()->iterateAndNext(*this); iterateAndNextNull(changep->rhsp());
if (changep->lhsp()->isWide()) puts("["+cvtToStr(word)+"]"); if (changep->lhsp()->isWide()) puts("["+cvtToStr(word)+"]");
puts(")"); puts(")");
} }
@ -909,14 +909,14 @@ class EmitCImp : EmitCStmts {
emitVarList(nodep->initsp(), EVL_FUNC_ALL, ""); emitVarList(nodep->initsp(), EVL_FUNC_ALL, "");
emitVarList(nodep->stmtsp(), EVL_FUNC_ALL, ""); emitVarList(nodep->stmtsp(), EVL_FUNC_ALL, "");
nodep->initsp()->iterateAndNext(*this); iterateAndNextNull(nodep->initsp());
if (nodep->stmtsp()) putsDecoration("// Body\n"); if (nodep->stmtsp()) putsDecoration("// Body\n");
nodep->stmtsp()->iterateAndNext(*this); iterateAndNextNull(nodep->stmtsp());
if (!m_blkChangeDetVec.empty()) emitChangeDet(); if (!m_blkChangeDetVec.empty()) emitChangeDet();
if (nodep->finalsp()) putsDecoration("// Final\n"); if (nodep->finalsp()) putsDecoration("// Final\n");
nodep->finalsp()->iterateAndNext(*this); iterateAndNextNull(nodep->finalsp());
// //
if (!m_blkChangeDetVec.empty()) puts("return __req;\n"); if (!m_blkChangeDetVec.empty()) puts("return __req;\n");
@ -1004,7 +1004,7 @@ public:
virtual ~EmitCImp() {} virtual ~EmitCImp() {}
void main(AstNodeModule* modp, bool slow, bool fast); void main(AstNodeModule* modp, bool slow, bool fast);
void mainDoFunc(AstCFunc* nodep) { void mainDoFunc(AstCFunc* nodep) {
nodep->accept(*this); iterate(nodep);
} }
}; };
@ -1197,7 +1197,7 @@ void EmitCStmts::emitOpName(AstNode* nodep, const string& format,
case 'i': case 'i':
COMMA; COMMA;
if (!detailp) { nodep->v3fatalSrc("emitOperator() references undef node"); } if (!detailp) { nodep->v3fatalSrc("emitOperator() references undef node"); }
else detailp->iterateAndNext(*this); else iterateAndNextNull(detailp);
needComma = true; needComma = true;
break; break;
default: default:
@ -1253,7 +1253,7 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
if (const AstFScanF* dispp = VN_CAST(nodep, FScanF)) { if (const AstFScanF* dispp = VN_CAST(nodep, FScanF)) {
isStmt = false; isStmt = false;
puts("VL_FSCANF_IX("); puts("VL_FSCANF_IX(");
dispp->filep()->iterate(*this); iterate(dispp->filep());
puts(","); puts(",");
} else if (const AstSScanF* dispp = VN_CAST(nodep, SScanF)) { } else if (const AstSScanF* dispp = VN_CAST(nodep, SScanF)) {
isStmt = false; isStmt = false;
@ -1261,13 +1261,13 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
puts("VL_SSCANF_I"); emitIQW(dispp->fromp()); puts("X("); puts("VL_SSCANF_I"); emitIQW(dispp->fromp()); puts("X(");
puts(cvtToStr(dispp->fromp()->widthMin())); puts(cvtToStr(dispp->fromp()->widthMin()));
puts(","); puts(",");
dispp->fromp()->iterate(*this); iterate(dispp->fromp());
puts(","); puts(",");
} else if (const AstDisplay* dispp = VN_CAST(nodep, Display)) { } else if (const AstDisplay* dispp = VN_CAST(nodep, Display)) {
isStmt = true; isStmt = true;
if (dispp->filep()) { if (dispp->filep()) {
puts("VL_FWRITEF("); puts("VL_FWRITEF(");
dispp->filep()->iterate(*this); iterate(dispp->filep());
puts(","); puts(",");
} else { } else {
puts("VL_WRITEF("); puts("VL_WRITEF(");
@ -1277,7 +1277,7 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
puts("VL_SFORMAT_X("); puts("VL_SFORMAT_X(");
puts(cvtToStr(dispp->lhsp()->widthMin())); puts(cvtToStr(dispp->lhsp()->widthMin()));
putbs(","); putbs(",");
dispp->lhsp()->iterate(*this); iterate(dispp->lhsp());
putbs(","); putbs(",");
} else if (const AstSFormatF* dispp = VN_CAST(nodep, SFormatF)) { } else if (const AstSFormatF* dispp = VN_CAST(nodep, SFormatF)) {
isStmt = false; isStmt = false;
@ -1299,7 +1299,7 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
if (argp) { if (argp) {
if (isScan) puts("&("); if (isScan) puts("&(");
else if (fmt == '@') puts("&("); else if (fmt == '@') puts("&(");
argp->iterate(*this); iterate(argp);
if (isScan) puts(")"); if (isScan) puts(")");
else if (fmt == '@') puts(")"); else if (fmt == '@') puts(")");
} }
@ -2072,7 +2072,7 @@ void EmitCImp::emitInt(AstNodeModule* modp) {
puts("enum "); puts("enum ");
puts(varp->isQuad()?"_QData":"_IData"); puts(varp->isQuad()?"_QData":"_IData");
puts(""+varp->name()+" { "+varp->name()+" = "); puts(""+varp->name()+" { "+varp->name()+" = ");
varp->valuep()->iterateAndNext(*this); iterateAndNextNull(varp->valuep());
puts("};"); puts("};");
} }
puts("\n"); puts("\n");
@ -2405,7 +2405,7 @@ class EmitCTrace : EmitCStmts {
} }
void emitTraceChangeOne(AstTraceInc* nodep, int arrayindex) { void emitTraceChangeOne(AstTraceInc* nodep, int arrayindex) {
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
string full = ((m_funcp->funcType() == AstCFuncType::TRACE_FULL string full = ((m_funcp->funcType() == AstCFuncType::TRACE_FULL
|| m_funcp->funcType() == AstCFuncType::TRACE_FULL_SUB) || m_funcp->funcType() == AstCFuncType::TRACE_FULL_SUB)
? "full":"chg"); ? "full":"chg");
@ -2437,7 +2437,7 @@ class EmitCTrace : EmitCStmts {
puts("("); puts("(");
if (emitTraceIsScBigUint(nodep)) puts("(vluint32_t*)"); if (emitTraceIsScBigUint(nodep)) puts("(vluint32_t*)");
else if (emitTraceIsScBv(nodep)) puts("VL_SC_BV_DATAP("); else if (emitTraceIsScBv(nodep)) puts("VL_SC_BV_DATAP(");
varrefp->iterate(*this); // Put var name out iterate(varrefp); // Put var name out
// Tracing only supports 1D arrays // Tracing only supports 1D arrays
if (nodep->declp()->arrayRange().ranged()) { if (nodep->declp()->arrayRange().ranged()) {
if (arrayindex==-2) puts("[i]"); if (arrayindex==-2) puts("[i]");
@ -2451,7 +2451,7 @@ class EmitCTrace : EmitCStmts {
puts(")"); puts(")");
} else { } else {
puts("("); puts("(");
nodep->valuep()->iterate(*this); iterate(nodep->valuep());
puts(")"); puts(")");
} }
} }
@ -2460,10 +2460,10 @@ class EmitCTrace : EmitCStmts {
using EmitCStmts::visit; // Suppress hidden overloaded virtual function warnng using EmitCStmts::visit; // Suppress hidden overloaded virtual function warnng
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Top module only // Top module only
nodep->topModulep()->accept(*this); iterate(nodep->topModulep());
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
if (nodep->slow() != m_slow) return; if (nodep->slow() != m_slow) return;
@ -2499,14 +2499,14 @@ class EmitCTrace : EmitCStmts {
if (nodep->initsp()) putsDecoration("// Variables\n"); if (nodep->initsp()) putsDecoration("// Variables\n");
emitVarList(nodep->initsp(), EVL_FUNC_ALL, ""); emitVarList(nodep->initsp(), EVL_FUNC_ALL, "");
nodep->initsp()->iterateAndNext(*this); iterateAndNextNull(nodep->initsp());
putsDecoration("// Body\n"); putsDecoration("// Body\n");
puts("{\n"); puts("{\n");
nodep->stmtsp()->iterateAndNext(*this); iterateAndNextNull(nodep->stmtsp());
puts("}\n"); puts("}\n");
if (nodep->finalsp()) putsDecoration("// Final\n"); if (nodep->finalsp()) putsDecoration("// Final\n");
nodep->finalsp()->iterateAndNext(*this); iterateAndNextNull(nodep->finalsp());
puts("}\n"); puts("}\n");
} }
m_funcp = NULL; m_funcp = NULL;
@ -2549,7 +2549,7 @@ public:
if (m_slow) emitTraceSlow(); if (m_slow) emitTraceSlow();
else emitTraceFast(); else emitTraceFast();
v3Global.rootp()->accept(*this); iterate(v3Global.rootp());
delete m_ofp; m_ofp=NULL; delete m_ofp; m_ofp=NULL;
} }

View File

@ -102,13 +102,13 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
m_count++; m_count++;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit EmitCBaseCounterVisitor(AstNode* nodep) { explicit EmitCBaseCounterVisitor(AstNode* nodep) {
m_count = 0; m_count = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~EmitCBaseCounterVisitor() {} virtual ~EmitCBaseCounterVisitor() {}
int count() const { return m_count; } int count() const { return m_count; }

View File

@ -51,13 +51,13 @@ class EmitCInlines : EmitCBaseVisitor {
virtual void visit(AstNodeStmt*) {} virtual void visit(AstNodeStmt*) {}
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//--------------------------------------- //---------------------------------------
// ACCESSORS // ACCESSORS
public: public:
explicit EmitCInlines(AstNetlist* nodep) { explicit EmitCInlines(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
if (v3Global.needHInlines()) { if (v3Global.needHInlines()) {
emitInt(); emitInt();
} }

View File

@ -166,7 +166,7 @@ class EmitCSyms : EmitCBaseVisitor {
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Collect list of scopes // Collect list of scopes
nodep->iterateChildren(*this); iterateChildren(nodep);
varsExpand(); varsExpand();
// Sort by names, so line/process order matters less // Sort by names, so line/process order matters less
@ -185,7 +185,7 @@ class EmitCSyms : EmitCBaseVisitor {
nameCheck(nodep); nameCheck(nodep);
m_modp = nodep; m_modp = nodep;
m_labelNum = 0; m_labelNum = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
@ -210,7 +210,7 @@ class EmitCSyms : EmitCBaseVisitor {
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
nameCheck(nodep); nameCheck(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isSigUserRdPublic() if (nodep->isSigUserRdPublic()
&& !nodep->isParam()) { // The VPI functions require a pointer to allow modification, but parameters are constants && !nodep->isParam()) { // The VPI functions require a pointer to allow modification, but parameters are constants
m_modVars.push_back(make_pair(m_modp, nodep)); m_modVars.push_back(make_pair(m_modp, nodep));
@ -224,7 +224,7 @@ class EmitCSyms : EmitCBaseVisitor {
} }
virtual void visit(AstJumpLabel* nodep) { virtual void visit(AstJumpLabel* nodep) {
nodep->labelNum(++m_labelNum); nodep->labelNum(++m_labelNum);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
nameCheck(nodep); nameCheck(nodep);
@ -232,14 +232,14 @@ class EmitCSyms : EmitCBaseVisitor {
m_dpis.push_back(nodep); m_dpis.push_back(nodep);
} }
m_funcp = nodep; m_funcp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_funcp = NULL; m_funcp = NULL;
} }
// NOPs // NOPs
virtual void visit(AstConst*) {} virtual void visit(AstConst*) {}
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//--------------------------------------- //---------------------------------------
// ACCESSORS // ACCESSORS
@ -249,7 +249,7 @@ public:
m_modp = NULL; m_modp = NULL;
m_coverBins = 0; m_coverBins = 0;
m_labelNum = 0; m_labelNum = 0;
nodep->accept(*this); iterate(nodep);
} }
}; };

View File

@ -63,11 +63,11 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
putfs(nodep, nodep->verilogKwd()+" "+modClassName(nodep)+";\n"); putfs(nodep, nodep->verilogKwd()+" "+modClassName(nodep)+";\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
putqs(nodep, "end"+nodep->verilogKwd()+"\n"); putqs(nodep, "end"+nodep->verilogKwd()+"\n");
} }
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
@ -76,7 +76,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
puts(nodep->prettyName()); puts(nodep->prettyName());
puts(";\n"); puts(";\n");
putqs(nodep, "begin\n"); // Only putfs the first time for each visitor; later for same node is putqs putqs(nodep, "begin\n"); // Only putfs the first time for each visitor; later for same node is putqs
nodep->stmtsp()->iterateAndNext(*this); iterateAndNextNull(nodep->stmtsp());
putqs(nodep, "end\n"); putqs(nodep, "end\n");
} }
@ -86,64 +86,64 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
} else { } else {
putbs("begin : "+nodep->name()+"\n"); putbs("begin : "+nodep->name()+"\n");
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
puts("end\n"); puts("end\n");
} }
virtual void visit(AstGenerate* nodep) { virtual void visit(AstGenerate* nodep) {
putfs(nodep, "generate\n"); putfs(nodep, "generate\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
putqs(nodep, "end\n"); putqs(nodep, "end\n");
} }
virtual void visit(AstFinal* nodep) { virtual void visit(AstFinal* nodep) {
putfs(nodep, "final begin\n"); putfs(nodep, "final begin\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
putqs(nodep, "end\n"); putqs(nodep, "end\n");
} }
virtual void visit(AstInitial* nodep) { virtual void visit(AstInitial* nodep) {
putfs(nodep,"initial begin\n"); putfs(nodep,"initial begin\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
putqs(nodep, "end\n"); putqs(nodep, "end\n");
} }
virtual void visit(AstAlways* nodep) { virtual void visit(AstAlways* nodep) {
putfs(nodep,"always "); putfs(nodep,"always ");
if (m_sensesp) m_sensesp->iterateAndNext(*this); // In active if (m_sensesp) iterateAndNextNull(m_sensesp); // In active
else nodep->sensesp()->iterateAndNext(*this); else iterateAndNextNull(nodep->sensesp());
putbs(" begin\n"); putbs(" begin\n");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
putqs(nodep,"end\n"); putqs(nodep,"end\n");
} }
virtual void visit(AstAlwaysPublic* nodep) { virtual void visit(AstAlwaysPublic* nodep) {
putfs(nodep,"/*verilator public_flat_rw "); putfs(nodep,"/*verilator public_flat_rw ");
if (m_sensesp) m_sensesp->iterateAndNext(*this); // In active if (m_sensesp) iterateAndNextNull(m_sensesp); // In active
else nodep->sensesp()->iterateAndNext(*this); else iterateAndNextNull(nodep->sensesp());
putqs(nodep," "); putqs(nodep," ");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
putqs(nodep,"*/\n"); putqs(nodep,"*/\n");
} }
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
putfs(nodep," "+nodep->verilogKwd()+" "); putfs(nodep," "+nodep->verilogKwd()+" ");
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
if (!m_suppressSemi) puts(";\n"); if (!m_suppressSemi) puts(";\n");
} }
virtual void visit(AstAssignDly* nodep) { virtual void visit(AstAssignDly* nodep) {
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
putfs(nodep," <= "); putfs(nodep," <= ");
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
puts(";\n"); puts(";\n");
} }
virtual void visit(AstAssignAlias* nodep) { virtual void visit(AstAssignAlias* nodep) {
putbs("alias "); putbs("alias ");
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
putfs(nodep," = "); putfs(nodep," = ");
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
if (!m_suppressSemi) puts(";\n"); if (!m_suppressSemi) puts(";\n");
} }
virtual void visit(AstAssignW* nodep) { virtual void visit(AstAssignW* nodep) {
putfs(nodep,"assign "); putfs(nodep,"assign ");
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
putbs(" = "); putbs(" = ");
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
if (!m_suppressSemi) puts(";\n"); if (!m_suppressSemi) puts(";\n");
} }
virtual void visit(AstBreak* nodep) { virtual void visit(AstBreak* nodep) {
@ -154,7 +154,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
// AstSenItem is called for dumping in isolation by V3Order // AstSenItem is called for dumping in isolation by V3Order
putfs(nodep,"@("); putfs(nodep,"@(");
for (AstNode* expp=nodep->sensesp(); expp; expp = expp->nextp()) { for (AstNode* expp=nodep->sensesp(); expp; expp = expp->nextp()) {
expp->accept(*this); iterate(expp);
if (expp->nextp()) putqs(expp->nextp()," or "); if (expp->nextp()) putqs(expp->nextp()," or ");
} }
puts(")"); puts(")");
@ -166,7 +166,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
putfs(nodep,""); putfs(nodep,"");
puts(nodep->edgeType().verilogKwd()); puts(nodep->edgeType().verilogKwd());
if (nodep->sensp()) puts(" "); if (nodep->sensp()) puts(" ");
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeCase* nodep) { virtual void visit(AstNodeCase* nodep) {
putfs(nodep,""); putfs(nodep,"");
@ -177,7 +177,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
} }
puts(nodep->verilogKwd()); puts(nodep->verilogKwd());
puts(" ("); puts(" (");
nodep->exprp()->iterateAndNext(*this); iterateAndNextNull(nodep->exprp());
puts(")\n"); puts(")\n");
if (const AstCase* casep = VN_CAST(nodep, Case)) { if (const AstCase* casep = VN_CAST(nodep, Case)) {
if (casep->fullPragma() || casep->parallelPragma()) { if (casep->fullPragma() || casep->parallelPragma()) {
@ -186,20 +186,20 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
if (casep->parallelPragma()) puts(" parallel_case"); if (casep->parallelPragma()) puts(" parallel_case");
} }
} }
nodep->itemsp()->iterateAndNext(*this); iterateAndNextNull(nodep->itemsp());
putqs(nodep,"endcase\n"); putqs(nodep,"endcase\n");
} }
virtual void visit(AstCaseItem* nodep) { virtual void visit(AstCaseItem* nodep) {
if (nodep->condsp()) { if (nodep->condsp()) {
nodep->condsp()->iterateAndNext(*this); iterateAndNextNull(nodep->condsp());
} else putbs("default"); } else putbs("default");
putfs(nodep,": begin "); putfs(nodep,": begin ");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
putqs(nodep,"end\n"); putqs(nodep,"end\n");
} }
virtual void visit(AstComment* nodep) { virtual void visit(AstComment* nodep) {
puts((string)"// "+nodep->name()+"\n"); puts((string)"// "+nodep->name()+"\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstContinue* nodep) { virtual void visit(AstContinue* nodep) {
putbs("continue"); putbs("continue");
@ -212,11 +212,11 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
void visitNodeDisplay(AstNode* nodep, AstNode* fileOrStrgp, const string& text, AstNode* exprsp) { void visitNodeDisplay(AstNode* nodep, AstNode* fileOrStrgp, const string& text, AstNode* exprsp) {
putfs(nodep,nodep->verilogKwd()); putfs(nodep,nodep->verilogKwd());
putbs(" ("); putbs(" (");
if (fileOrStrgp) { fileOrStrgp->iterateAndNext(*this); putbs(","); } if (fileOrStrgp) { iterateAndNextNull(fileOrStrgp); putbs(","); }
putsQuoted(text); putsQuoted(text);
for (AstNode* expp=exprsp; expp; expp = expp->nextp()) { for (AstNode* expp=exprsp; expp; expp = expp->nextp()) {
puts(","); puts(",");
expp->iterateAndNext(*this); iterateAndNextNull(expp);
} }
puts(");\n"); puts(");\n");
} }
@ -241,23 +241,23 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
virtual void visit(AstFOpen* nodep) { virtual void visit(AstFOpen* nodep) {
putfs(nodep,nodep->verilogKwd()); putfs(nodep,nodep->verilogKwd());
putbs(" ("); putbs(" (");
if (nodep->filep()) nodep->filep()->iterateAndNext(*this); if (nodep->filep()) iterateAndNextNull(nodep->filep());
putbs(","); putbs(",");
if (nodep->filenamep()) nodep->filenamep()->iterateAndNext(*this); if (nodep->filenamep()) iterateAndNextNull(nodep->filenamep());
putbs(","); putbs(",");
if (nodep->modep()) nodep->modep()->iterateAndNext(*this); if (nodep->modep()) iterateAndNextNull(nodep->modep());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstFClose* nodep) { virtual void visit(AstFClose* nodep) {
putfs(nodep,nodep->verilogKwd()); putfs(nodep,nodep->verilogKwd());
putbs(" ("); putbs(" (");
if (nodep->filep()) nodep->filep()->iterateAndNext(*this); if (nodep->filep()) iterateAndNextNull(nodep->filep());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstFFlush* nodep) { virtual void visit(AstFFlush* nodep) {
putfs(nodep,nodep->verilogKwd()); putfs(nodep,nodep->verilogKwd());
putbs(" ("); putbs(" (");
if (nodep->filep()) nodep->filep()->iterateAndNext(*this); if (nodep->filep()) iterateAndNextNull(nodep->filep());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstJumpGo* nodep) { virtual void visit(AstJumpGo* nodep) {
@ -265,57 +265,57 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
} }
virtual void visit(AstJumpLabel* nodep) { virtual void visit(AstJumpLabel* nodep) {
putbs("begin : "+cvtToStr((void*)(nodep))+"\n"); putbs("begin : "+cvtToStr((void*)(nodep))+"\n");
if (nodep->stmtsp()) nodep->stmtsp()->iterateAndNext(*this); if (nodep->stmtsp()) iterateAndNextNull(nodep->stmtsp());
puts("end\n"); puts("end\n");
} }
virtual void visit(AstNodeReadWriteMem* nodep) { virtual void visit(AstNodeReadWriteMem* nodep) {
putfs(nodep,nodep->verilogKwd()); putfs(nodep,nodep->verilogKwd());
putbs(" ("); putbs(" (");
if (nodep->filenamep()) nodep->filenamep()->iterateAndNext(*this); if (nodep->filenamep()) iterateAndNextNull(nodep->filenamep());
putbs(","); putbs(",");
if (nodep->memp()) nodep->memp()->iterateAndNext(*this); if (nodep->memp()) iterateAndNextNull(nodep->memp());
if (nodep->lsbp()) { putbs(","); nodep->lsbp()->iterateAndNext(*this); } if (nodep->lsbp()) { putbs(","); iterateAndNextNull(nodep->lsbp()); }
if (nodep->msbp()) { putbs(","); nodep->msbp()->iterateAndNext(*this); } if (nodep->msbp()) { putbs(","); iterateAndNextNull(nodep->msbp()); }
puts(");\n"); puts(");\n");
} }
virtual void visit(AstSysFuncAsTask* nodep) { virtual void visit(AstSysFuncAsTask* nodep) {
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(";\n"); puts(";\n");
} }
virtual void visit(AstSysIgnore* nodep) { virtual void visit(AstSysIgnore* nodep) {
putfs(nodep,nodep->verilogKwd()); putfs(nodep,nodep->verilogKwd());
putbs(" ("); putbs(" (");
nodep->exprsp()->iterateAndNext(*this); iterateAndNextNull(nodep->exprsp());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstNodeFor* nodep) { virtual void visit(AstNodeFor* nodep) {
putfs(nodep,"for ("); putfs(nodep,"for (");
m_suppressSemi = true; m_suppressSemi = true;
nodep->initsp()->iterateAndNext(*this); iterateAndNextNull(nodep->initsp());
puts(";"); puts(";");
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
puts(";"); puts(";");
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
m_suppressSemi = false; m_suppressSemi = false;
puts(") begin\n"); puts(") begin\n");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
putqs(nodep,"end\n"); putqs(nodep,"end\n");
} }
virtual void visit(AstRepeat* nodep) { virtual void visit(AstRepeat* nodep) {
putfs(nodep,"repeat ("); putfs(nodep,"repeat (");
nodep->countp()->iterateAndNext(*this); iterateAndNextNull(nodep->countp());
puts(") begin\n"); puts(") begin\n");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
putfs(nodep,"end\n"); putfs(nodep,"end\n");
} }
virtual void visit(AstWhile* nodep) { virtual void visit(AstWhile* nodep) {
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
putfs(nodep,"while ("); putfs(nodep,"while (");
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
puts(") begin\n"); puts(") begin\n");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
nodep->precondsp()->iterateAndNext(*this); // Need to recompute before next loop iterateAndNextNull(nodep->precondsp()); // Need to recompute before next loop
putfs(nodep,"end\n"); putfs(nodep,"end\n");
} }
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
@ -326,19 +326,19 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
if (ifp->unique0Pragma()) puts("unique0 "); if (ifp->unique0Pragma()) puts("unique0 ");
} }
puts("if ("); puts("if (");
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
puts(") begin\n"); puts(") begin\n");
nodep->ifsp()->iterateAndNext(*this); iterateAndNextNull(nodep->ifsp());
if (nodep->elsesp()) { if (nodep->elsesp()) {
putqs(nodep,"end\n"); putqs(nodep,"end\n");
putqs(nodep,"else begin\n"); putqs(nodep,"else begin\n");
nodep->elsesp()->iterateAndNext(*this); iterateAndNextNull(nodep->elsesp());
} }
putqs(nodep,"end\n"); putqs(nodep,"end\n");
} }
virtual void visit(AstReturn* nodep) { virtual void visit(AstReturn* nodep) {
putfs(nodep,"return "); putfs(nodep,"return ");
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
puts(";\n"); puts(";\n");
} }
virtual void visit(AstStop* nodep) { virtual void visit(AstStop* nodep) {
@ -354,22 +354,22 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
} }
virtual void visit(AstCStmt* nodep) { virtual void visit(AstCStmt* nodep) {
putfs(nodep,"$_CSTMT("); putfs(nodep,"$_CSTMT(");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstCMath* nodep) { virtual void visit(AstCMath* nodep) {
putfs(nodep,"$_CMATH("); putfs(nodep,"$_CMATH(");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstUCStmt* nodep) { virtual void visit(AstUCStmt* nodep) {
putfs(nodep,"$c("); putfs(nodep,"$c(");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
puts(");\n"); puts(");\n");
} }
virtual void visit(AstUCFunc* nodep) { virtual void visit(AstUCFunc* nodep) {
putfs(nodep,"$c("); putfs(nodep,"$c(");
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
puts(")"); puts(")");
} }
@ -399,22 +399,22 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
case 'k': putbs(""); break; case 'k': putbs(""); break;
case 'l': { case 'l': {
if (!lhsp) { nodep->v3fatalSrc("emitVerilog() references undef node"); } if (!lhsp) { nodep->v3fatalSrc("emitVerilog() references undef node"); }
else lhsp->iterateAndNext(*this); else iterateAndNextNull(lhsp);
break; break;
} }
case 'r': { case 'r': {
if (!rhsp) { nodep->v3fatalSrc("emitVerilog() references undef node"); } if (!rhsp) { nodep->v3fatalSrc("emitVerilog() references undef node"); }
else rhsp->iterateAndNext(*this); else iterateAndNextNull(rhsp);
break; break;
} }
case 't': { case 't': {
if (!thsp) { nodep->v3fatalSrc("emitVerilog() references undef node"); } if (!thsp) { nodep->v3fatalSrc("emitVerilog() references undef node"); }
else thsp->iterateAndNext(*this); else iterateAndNextNull(thsp);
break; break;
} }
case 'd': { case 'd': {
if (!nodep->dtypep()) { nodep->v3fatalSrc("emitVerilog() references undef node"); } if (!nodep->dtypep()) { nodep->v3fatalSrc("emitVerilog() references undef node"); }
else nodep->dtypep()->iterateAndNext(*this); else iterateAndNextNull(nodep->dtypep());
break; break;
} }
default: default:
@ -439,10 +439,10 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
} }
virtual void visit(AstAttrOf* nodep) { virtual void visit(AstAttrOf* nodep) {
putfs(nodep,"$_ATTROF("); putfs(nodep,"$_ATTROF(");
nodep->fromp()->iterateAndNext(*this); iterateAndNextNull(nodep->fromp());
if (nodep->dimp()) { if (nodep->dimp()) {
putbs(","); putbs(",");
nodep->dimp()->iterateAndNext(*this); iterateAndNextNull(nodep->dimp());
} }
puts(")"); puts(")");
} }
@ -453,16 +453,16 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
int index = nodep->posIndex(pos); int index = nodep->posIndex(pos);
puts(cvtToStr(index)); puts(cvtToStr(index));
puts(":"); puts(":");
itemp->accept(*this); iterate(itemp);
if (itemp->nextp()) putbs(","); if (itemp->nextp()) putbs(",");
} }
puts("}"); puts("}");
} }
virtual void visit(AstNodeCond* nodep) { virtual void visit(AstNodeCond* nodep) {
putbs("("); putbs("(");
nodep->condp()->iterateAndNext(*this); putfs(nodep," ? "); iterateAndNextNull(nodep->condp()); putfs(nodep," ? ");
nodep->expr1p()->iterateAndNext(*this); putbs(" : "); iterateAndNextNull(nodep->expr1p()); putbs(" : ");
nodep->expr2p()->iterateAndNext(*this); puts(")"); iterateAndNextNull(nodep->expr2p()); puts(")");
} }
virtual void visit(AstRange* nodep) { virtual void visit(AstRange* nodep) {
puts("["); puts("[");
@ -471,18 +471,18 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
puts(cvtToStr(VN_CAST(nodep->leftp(), Const)->toSInt())); puts(":"); puts(cvtToStr(VN_CAST(nodep->leftp(), Const)->toSInt())); puts(":");
puts(cvtToStr(VN_CAST(nodep->rightp(), Const)->toSInt())); puts("]"); puts(cvtToStr(VN_CAST(nodep->rightp(), Const)->toSInt())); puts("]");
} else { } else {
nodep->leftp()->iterateAndNext(*this); puts(":"); iterateAndNextNull(nodep->leftp()); puts(":");
nodep->rightp()->iterateAndNext(*this); puts("]"); iterateAndNextNull(nodep->rightp()); puts("]");
} }
} }
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
nodep->fromp()->iterateAndNext(*this); puts("["); iterateAndNextNull(nodep->fromp()); puts("[");
if (VN_IS(nodep->lsbp(), Const)) { if (VN_IS(nodep->lsbp(), Const)) {
if (nodep->widthp()->isOne()) { if (nodep->widthp()->isOne()) {
if (VN_IS(nodep->lsbp(), Const)) { if (VN_IS(nodep->lsbp(), Const)) {
puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt())); puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt()));
} else { } else {
nodep->lsbp()->iterateAndNext(*this); iterateAndNextNull(nodep->lsbp());
} }
} else { } else {
puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt() puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt()
@ -492,44 +492,44 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt())); puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt()));
} }
} else { } else {
nodep->lsbp()->iterateAndNext(*this); putfs(nodep,"+:"); iterateAndNextNull(nodep->lsbp()); putfs(nodep,"+:");
nodep->widthp()->iterateAndNext(*this); puts("]"); iterateAndNextNull(nodep->widthp()); puts("]");
} }
puts("]"); puts("]");
} }
virtual void visit(AstSliceSel* nodep) { virtual void visit(AstSliceSel* nodep) {
nodep->fromp()->iterateAndNext(*this); iterateAndNextNull(nodep->fromp());
puts(cvtToStr(nodep->declRange())); puts(cvtToStr(nodep->declRange()));
} }
virtual void visit(AstTypedef* nodep) { virtual void visit(AstTypedef* nodep) {
putfs(nodep,"typedef "); putfs(nodep,"typedef ");
nodep->dtypep()->iterateAndNext(*this); puts(" "); iterateAndNextNull(nodep->dtypep()); puts(" ");
puts(nodep->prettyName()); puts(nodep->prettyName());
puts(";\n"); puts(";\n");
} }
virtual void visit(AstBasicDType* nodep) { virtual void visit(AstBasicDType* nodep) {
if (nodep->isSigned()) putfs(nodep,"signed "); if (nodep->isSigned()) putfs(nodep,"signed ");
putfs(nodep,nodep->prettyName()); putfs(nodep,nodep->prettyName());
if (nodep->rangep()) { puts(" "); nodep->rangep()->iterateAndNext(*this); puts(" "); } if (nodep->rangep()) { puts(" "); iterateAndNextNull(nodep->rangep()); puts(" "); }
else if (nodep->isRanged()) { puts(" ["); puts(cvtToStr(nodep->msb())); puts(":0] "); } else if (nodep->isRanged()) { puts(" ["); puts(cvtToStr(nodep->msb())); puts(":0] "); }
} }
virtual void visit(AstConstDType* nodep) { virtual void visit(AstConstDType* nodep) {
putfs(nodep,"const "); putfs(nodep,"const ");
nodep->subDTypep()->accept(*this); iterate(nodep->subDTypep());
} }
virtual void visit(AstNodeArrayDType* nodep) { virtual void visit(AstNodeArrayDType* nodep) {
nodep->subDTypep()->accept(*this); iterate(nodep->subDTypep());
nodep->rangep()->iterateAndNext(*this); iterateAndNextNull(nodep->rangep());
} }
virtual void visit(AstNodeClassDType* nodep) { virtual void visit(AstNodeClassDType* nodep) {
puts(nodep->verilogKwd()+" "); puts(nodep->verilogKwd()+" ");
if (nodep->packed()) puts("packed "); if (nodep->packed()) puts("packed ");
puts("\n"); puts("\n");
nodep->membersp()->iterateAndNext(*this); iterateAndNextNull(nodep->membersp());
puts("}"); puts("}");
} }
virtual void visit(AstMemberDType* nodep) { virtual void visit(AstMemberDType* nodep) {
nodep->subDTypep()->accept(*this); iterate(nodep->subDTypep());
puts(" "); puts(" ");
puts(nodep->name()); puts(nodep->name());
puts("}"); puts("}");
@ -538,11 +538,11 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
if (nodep->dotted()!="") { putfs(nodep,nodep->dotted()); puts("."); puts(nodep->prettyName()); } if (nodep->dotted()!="") { putfs(nodep,nodep->dotted()); puts("."); puts(nodep->prettyName()); }
else { putfs(nodep,nodep->prettyName()); } else { putfs(nodep,nodep->prettyName()); }
puts("("); puts("(");
nodep->pinsp()->iterateAndNext(*this); iterateAndNextNull(nodep->pinsp());
puts(")"); puts(")");
} }
virtual void visit(AstArg* nodep) { virtual void visit(AstArg* nodep) {
nodep->exprp()->iterateAndNext(*this); iterateAndNextNull(nodep->exprp());
} }
// Terminals // Terminals
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
@ -564,21 +564,21 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
// Just iterate // Just iterate
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
putfs(nodep,nodep->verilogKwd()); putfs(nodep,nodep->verilogKwd());
puts(" "); puts(" ");
nodep->dtypep()->iterate(*this); puts(" "); iterate(nodep->dtypep()); puts(" ");
puts(nodep->prettyName()); puts(nodep->prettyName());
puts(";\n"); puts(";\n");
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
m_sensesp = nodep->sensesp(); m_sensesp = nodep->sensesp();
nodep->stmtsp()->iterateAndNext(*this); iterateAndNextNull(nodep->stmtsp());
m_sensesp = NULL; m_sensesp = NULL;
} }
virtual void visit(AstVarScope*) {} virtual void visit(AstVarScope*) {}
@ -591,7 +591,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
puts((string)"\n???? // "+nodep->prettyTypeName()+"\n"); puts((string)"\n???? // "+nodep->prettyTypeName()+"\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
// Not v3fatalSrc so we keep processing // Not v3fatalSrc so we keep processing
nodep->v3error("Internal: Unknown node type reached emitter: "<<nodep->prettyTypeName()); nodep->v3error("Internal: Unknown node type reached emitter: "<<nodep->prettyTypeName());
} }
@ -620,7 +620,7 @@ class EmitVFileVisitor : public EmitVBaseVisitor {
public: public:
EmitVFileVisitor(AstNode* nodep, V3OutFile* ofp) { EmitVFileVisitor(AstNode* nodep, V3OutFile* ofp) {
m_ofp = ofp; m_ofp = ofp;
nodep->accept(*this); iterate(nodep);
} }
virtual ~EmitVFileVisitor() {} virtual ~EmitVFileVisitor() {}
}; };
@ -640,7 +640,7 @@ class EmitVStreamVisitor : public EmitVBaseVisitor {
public: public:
EmitVStreamVisitor(AstNode* nodep, std::ostream& os) EmitVStreamVisitor(AstNode* nodep, std::ostream& os)
: m_os(os) { : m_os(os) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~EmitVStreamVisitor() {} virtual ~EmitVStreamVisitor() {}
}; };
@ -711,7 +711,7 @@ public:
AstSenTree* domainp, bool user3mark) AstSenTree* domainp, bool user3mark)
: EmitVBaseVisitor(domainp), m_formatter(os, prefix, flWidth) { : EmitVBaseVisitor(domainp), m_formatter(os, prefix, flWidth) {
if (user3mark) { AstUser3InUse::check(); } if (user3mark) { AstUser3InUse::check(); }
nodep->accept(*this); iterate(nodep);
} }
virtual ~EmitVPrefixedVisitor() {} virtual ~EmitVPrefixedVisitor() {}
}; };

View File

@ -89,7 +89,7 @@ class EmitXmlFileVisitor : public AstNVisitor {
if (tag=="") tag = VString::downcase(nodep->typeName()); if (tag=="") tag = VString::downcase(nodep->typeName());
if (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) { if (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) {
puts(">\n"); puts(">\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
puts("</"+tag+">\n"); puts("</"+tag+">\n");
} else { } else {
puts("/>\n"); puts("/>\n");
@ -108,7 +108,7 @@ class EmitXmlFileVisitor : public AstNVisitor {
} }
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
puts("<netlist>\n"); puts("<netlist>\n");
nodep->iterateChildren(*this); iterateChildren(nodep);
puts("</netlist>\n"); puts("</netlist>\n");
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
@ -154,7 +154,7 @@ public:
EmitXmlFileVisitor(AstNode* nodep, V3OutFile* ofp) { EmitXmlFileVisitor(AstNode* nodep, V3OutFile* ofp) {
m_ofp = ofp; m_ofp = ofp;
m_id = 0; m_id = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~EmitXmlFileVisitor() {} virtual ~EmitXmlFileVisitor() {}
}; };

View File

@ -312,7 +312,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstExtend* nodep) { virtual void visit(AstExtend* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isWide()) { if (nodep->isWide()) {
// See under ASSIGN(EXTEND) // See under ASSIGN(EXTEND)
} else { } else {
@ -351,7 +351,7 @@ private:
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
// Remember, Sel's may have non-integer rhs, so need to optimize for that! // Remember, Sel's may have non-integer rhs, so need to optimize for that!
if (nodep->widthMin()!=(int)nodep->widthConst()) nodep->v3fatalSrc("Width mismatch"); if (nodep->widthMin()!=(int)nodep->widthConst()) nodep->v3fatalSrc("Width mismatch");
if (VN_IS(nodep->backp(), NodeAssign) && nodep==VN_CAST(nodep->backp(), NodeAssign)->lhsp()) { if (VN_IS(nodep->backp(), NodeAssign) && nodep==VN_CAST(nodep->backp(), NodeAssign)->lhsp()) {
@ -652,7 +652,7 @@ private:
virtual void visit(AstConcat* nodep) { virtual void visit(AstConcat* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isWide()) { if (nodep->isWide()) {
// See under ASSIGN(WIDE) // See under ASSIGN(WIDE)
} else { } else {
@ -692,7 +692,7 @@ private:
virtual void visit(AstReplicate* nodep) { virtual void visit(AstReplicate* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isWide()) { if (nodep->isWide()) {
// See under ASSIGN(WIDE) // See under ASSIGN(WIDE)
} else { } else {
@ -753,7 +753,7 @@ private:
virtual void visit(AstChangeXor* nodep) { virtual void visit(AstChangeXor* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(8," Wordize ChangeXor "<<nodep<<endl); UINFO(8," Wordize ChangeXor "<<nodep<<endl);
// -> (0=={or{for each_word{WORDSEL(lhs,#)^WORDSEL(rhs,#)}}} // -> (0=={or{for each_word{WORDSEL(lhs,#)^WORDSEL(rhs,#)}}}
AstNode* newp = NULL; AstNode* newp = NULL;
@ -768,7 +768,7 @@ private:
void visitEqNeq(AstNodeBiop* nodep) { void visitEqNeq(AstNodeBiop* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->lhsp()->isWide()) { if (nodep->lhsp()->isWide()) {
UINFO(8," Wordize EQ/NEQ "<<nodep<<endl); UINFO(8," Wordize EQ/NEQ "<<nodep<<endl);
// -> (0=={or{for each_word{WORDSEL(lhs,#)^WORDSEL(rhs,#)}}} // -> (0=={or{for each_word{WORDSEL(lhs,#)^WORDSEL(rhs,#)}}}
@ -794,7 +794,7 @@ private:
virtual void visit(AstRedOr* nodep) { virtual void visit(AstRedOr* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->lhsp()->isWide()) { if (nodep->lhsp()->isWide()) {
UINFO(8," Wordize REDOR "<<nodep<<endl); UINFO(8," Wordize REDOR "<<nodep<<endl);
// -> (0!={or{for each_word{WORDSEL(lhs,#)}}} // -> (0!={or{for each_word{WORDSEL(lhs,#)}}}
@ -818,7 +818,7 @@ private:
} }
virtual void visit(AstRedAnd* nodep) { virtual void visit(AstRedAnd* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->lhsp()->isWide()) { if (nodep->lhsp()->isWide()) {
UINFO(8," Wordize REDAND "<<nodep<<endl); UINFO(8," Wordize REDAND "<<nodep<<endl);
// -> (0!={and{for each_word{WORDSEL(lhs,#)}}} // -> (0!={and{for each_word{WORDSEL(lhs,#)}}}
@ -847,7 +847,7 @@ private:
} }
virtual void visit(AstRedXor* nodep) { virtual void visit(AstRedXor* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->lhsp()->isWide()) { if (nodep->lhsp()->isWide()) {
UINFO(8," Wordize REDXOR "<<nodep<<endl); UINFO(8," Wordize REDXOR "<<nodep<<endl);
// -> (0!={redxor{for each_word{XOR(WORDSEL(lhs,#))}}} // -> (0!={redxor{for each_word{XOR(WORDSEL(lhs,#))}}}
@ -867,13 +867,13 @@ private:
virtual void visit(AstNodeStmt* nodep) { virtual void visit(AstNodeStmt* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
m_stmtp = nodep; m_stmtp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_stmtp = NULL; m_stmtp = NULL;
} }
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
if (nodep->user1SetOnce()) return; // Process once if (nodep->user1SetOnce()) return; // Process once
m_stmtp = nodep; m_stmtp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
bool did = false; bool did = false;
if (nodep->isWide() && ((VN_IS(nodep->lhsp(), VarRef) if (nodep->isWide() && ((VN_IS(nodep->lhsp(), VarRef)
|| VN_IS(nodep->lhsp(), ArraySel))) || VN_IS(nodep->lhsp(), ArraySel)))
@ -918,14 +918,14 @@ private:
// Default: Just iterate // Default: Just iterate
virtual void visit(AstVar*) {} // Don't hit varrefs under vars virtual void visit(AstVar*) {} // Don't hit varrefs under vars
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit ExpandVisitor(AstNetlist* nodep) { explicit ExpandVisitor(AstNetlist* nodep) {
m_stmtp=NULL; m_stmtp=NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~ExpandVisitor() {} virtual ~ExpandVisitor() {}
}; };

View File

@ -207,7 +207,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNodeVarRef* nodep) { virtual void visit(AstNodeVarRef* nodep) {
++m_ops; ++m_ops;
nodep->iterateChildren(*this); iterateChildren(nodep);
// We only allow a LHS ref for the var being set, and a RHS ref for something else being read. // We only allow a LHS ref for the var being set, and a RHS ref for something else being read.
if (nodep->varScopep()->varp()->isSc()) { if (nodep->varScopep()->varp()->isSc()) {
clearSimple("SystemC sig"); // Don't want to eliminate the VL_ASSIGN_SI's clearSimple("SystemC sig"); // Don't want to eliminate the VL_ASSIGN_SI's
@ -236,7 +236,7 @@ private:
m_substTreep = nodep->rhsp(); m_substTreep = nodep->rhsp();
if (!VN_IS(nodep->lhsp(), NodeVarRef)) if (!VN_IS(nodep->lhsp(), NodeVarRef))
clearSimple("ASSIGN(non-VARREF)"); clearSimple("ASSIGN(non-VARREF)");
else nodep->iterateChildren(*this); else iterateChildren(nodep);
// We don't push logic other then assignments/NOTs into SenItems // We don't push logic other then assignments/NOTs into SenItems
// This avoids a mess in computing what exactly a POSEDGE is // This avoids a mess in computing what exactly a POSEDGE is
// V3Const cleans up any NOTs by flipping the edges for us // V3Const cleans up any NOTs by flipping the edges for us
@ -265,7 +265,7 @@ private:
UINFO(5, "Non optimizable type: "<<nodep<<endl); UINFO(5, "Non optimizable type: "<<nodep<<endl);
clearSimple("Non optimizable type"); clearSimple("Non optimizable type");
} }
else nodep->iterateChildren(*this); else iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -277,7 +277,7 @@ public:
m_dedupe = dedupe; m_dedupe = dedupe;
m_ops = 0; m_ops = 0;
// Iterate // Iterate
nodep->accept(*this); iterate(nodep);
// Check results // Check results
if (!m_substTreep) { if (!m_substTreep) {
clearSimple("No assignment found\n"); clearSimple("No assignment found\n");
@ -343,7 +343,7 @@ private:
} }
if (consumeReason) m_logicVertexp->setConsumed(consumeReason); if (consumeReason) m_logicVertexp->setConsumed(consumeReason);
if (VN_IS(nodep, SenItem)) m_logicVertexp->setConsumed("senItem"); if (VN_IS(nodep, SenItem)) m_logicVertexp->setConsumed("senItem");
nodep->iterateChildren(*this); iterateChildren(nodep);
m_logicVertexp = NULL; m_logicVertexp = NULL;
} }
} }
@ -384,7 +384,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
//if (debug()>6) m_graph.dump(); //if (debug()>6) m_graph.dump();
if (debug()>6) m_graph.dumpDotFilePrefixed("gate_pre"); if (debug()>6) m_graph.dumpDotFilePrefixed("gate_pre");
warnSignals(); // Before loss of sync/async pointers warnSignals(); // Before loss of sync/async pointers
@ -411,14 +411,14 @@ private:
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
m_activeReducible = true; m_activeReducible = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
UINFO(4," SCOPE "<<nodep<<endl); UINFO(4," SCOPE "<<nodep<<endl);
m_scopep = nodep; m_scopep = nodep;
m_logicVertexp = NULL; m_logicVertexp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_scopep = NULL; m_scopep = NULL;
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
@ -427,7 +427,7 @@ private:
m_activeReducible = !(nodep->hasClocked()); // Seq logic outputs aren't reducible m_activeReducible = !(nodep->hasClocked()); // Seq logic outputs aren't reducible
m_activep = nodep; m_activep = nodep;
AstNode::user2ClearTree(); AstNode::user2ClearTree();
nodep->iterateChildren(*this); iterateChildren(nodep);
AstNode::user2ClearTree(); AstNode::user2ClearTree();
m_activep = NULL; m_activep = NULL;
m_activeReducible = true; m_activeReducible = true;
@ -475,7 +475,7 @@ private:
// The gating term of a AstSenGate is normal logic // The gating term of a AstSenGate is normal logic
m_inSenItem = true; m_inSenItem = true;
if (m_logicVertexp) { // Already under logic; presumably a SenGate if (m_logicVertexp) { // Already under logic; presumably a SenGate
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { // Standalone item, probably right under a SenTree } else { // Standalone item, probably right under a SenTree
iterateNewStmt(nodep, NULL, NULL); iterateNewStmt(nodep, NULL, NULL);
} }
@ -511,13 +511,13 @@ private:
if (VN_IS(nodep->backp(), NodeAssign) && VN_CAST(nodep->backp(), NodeAssign)->lhsp()==nodep) { if (VN_IS(nodep->backp(), NodeAssign) && VN_CAST(nodep->backp(), NodeAssign)->lhsp()==nodep) {
nodep->v3fatalSrc("Concat on LHS of assignment; V3Const should have deleted it"); nodep->v3fatalSrc("Concat on LHS of assignment; V3Const should have deleted it");
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//-------------------- //--------------------
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isOutputter() && m_logicVertexp) m_logicVertexp->setConsumed("outputter"); if (nodep->isOutputter() && m_logicVertexp) m_logicVertexp->setConsumed("outputter");
} }
@ -532,7 +532,7 @@ public:
m_activeReducible = true; m_activeReducible = true;
m_inSenItem = false; m_inSenItem = false;
m_inSlow = false; m_inSlow = false;
nodep->accept(*this); iterate(nodep);
} }
virtual ~GateVisitor() { virtual ~GateVisitor() {
V3Stats::addStat("Optimizations, Gate sigs deleted", m_statSigs); V3Stats::addStat("Optimizations, Gate sigs deleted", m_statSigs);
@ -848,7 +848,7 @@ private:
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -857,7 +857,7 @@ public:
m_didReplace = false; m_didReplace = false;
m_elimVarScp = varscp; m_elimVarScp = varscp;
m_replaceTreep = replaceTreep; m_replaceTreep = replaceTreep;
nodep->accept(*this); iterate(nodep);
} }
bool didReplace() const { return m_didReplace; } bool didReplace() const { return m_didReplace; }
}; };
@ -971,7 +971,7 @@ private:
if (m_dedupable) { if (m_dedupable) {
if (!m_always) { if (!m_always) {
m_always = true; m_always = true;
alwaysp->bodysp()->iterateAndNext(*this); iterateAndNextNull(alwaysp->bodysp());
} else { } else {
m_dedupable = false; m_dedupable = false;
} }
@ -985,7 +985,7 @@ private:
if (m_dedupable) { if (m_dedupable) {
if (m_always && !m_ifCondp && !ifp->elsesp()) { //we're under an always, this is the first IF, and there's no else if (m_always && !m_ifCondp && !ifp->elsesp()) { //we're under an always, this is the first IF, and there's no else
m_ifCondp = ifp->condp(); m_ifCondp = ifp->condp();
ifp->ifsp()->iterateAndNext(*this); iterateAndNextNull(ifp->ifsp());
} else { } else {
m_dedupable = false; m_dedupable = false;
} }
@ -1013,7 +1013,7 @@ public:
m_ifCondp = NULL; m_ifCondp = NULL;
m_always = false; m_always = false;
m_dedupable = true; m_dedupable = true;
nodep->accept(*this); iterate(nodep);
if (m_dedupable && m_assignp) { if (m_dedupable && m_assignp) {
AstNode* lhsp = m_assignp->lhsp(); AstNode* lhsp = m_assignp->lhsp();
// Possible todo, handle more complex lhs expressions // Possible todo, handle more complex lhs expressions
@ -1292,13 +1292,13 @@ private:
} }
virtual void visit(AstConcat* nodep) { virtual void visit(AstConcat* nodep) {
UINFO(9,"CLK DECOMP Concat search (off = "<<m_offset<<") - "<<nodep<<endl); UINFO(9,"CLK DECOMP Concat search (off = "<<m_offset<<") - "<<nodep<<endl);
nodep->rhsp()->iterate(*this); iterate(nodep->rhsp());
nodep->lhsp()->iterate(*this); iterate(nodep->lhsp());
} }
//-------------------- //--------------------
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -1315,7 +1315,7 @@ public:
m_offset = 0; m_offset = 0;
m_found = false; m_found = false;
// Iterate // Iterate
concatp->accept(*this); iterate(concatp);
UINFO(9,"CLK DECOMP Concat Offset (found = "<<m_found<<") ("<<m_found_offset<<") - "<<concatp<<" : "<<vscp<<endl); UINFO(9,"CLK DECOMP Concat Offset (found = "<<m_found<<") ("<<m_found_offset<<") - "<<concatp<<" : "<<vscp<<endl);
offsetr = m_found_offset; offsetr = m_found_offset;
return m_found; return m_found;
@ -1480,13 +1480,13 @@ private:
virtual void visit(AstVar* nodep) {} virtual void visit(AstVar* nodep) {}
virtual void visit(AstActive* nodep) {} virtual void visit(AstActive* nodep) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit GateDeassignVisitor(AstNode* nodep) { explicit GateDeassignVisitor(AstNode* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~GateDeassignVisitor() {} virtual ~GateDeassignVisitor() {}
}; };

View File

@ -94,7 +94,7 @@ private:
if (!scopep) nodep->v3fatalSrc("No scope found on top level"); if (!scopep) nodep->v3fatalSrc("No scope found on top level");
m_scopetopp = scopep; m_scopetopp = scopep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//---- //----
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
@ -115,17 +115,18 @@ private:
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
m_activep = nodep; m_activep = nodep;
nodep->sensesp()->iterateChildren(*this); // iterateAndNext? if (!nodep->sensesp()) nodep->v3fatalSrc("Unlinked");
iterateChildren(nodep->sensesp()); // iterateAndNext?
m_activep = NULL; m_activep = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//----- //-----
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -133,7 +134,7 @@ public:
m_topModp = topModp; m_topModp = topModp;
m_scopetopp = NULL; m_scopetopp = NULL;
m_activep = NULL; m_activep = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~GenClkRenameVisitor() {} virtual ~GenClkRenameVisitor() {}
}; };
@ -157,7 +158,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
AstNode::user1ClearTree(); // user1p() used on entire tree AstNode::user1ClearTree(); // user1p() used on entire tree
nodep->iterateChildren(*this); iterateChildren(nodep);
{ {
// Make the new clock signals and replace any activate references // Make the new clock signals and replace any activate references
// See rename, it does some AstNode::userClearTree()'s // See rename, it does some AstNode::userClearTree()'s
@ -168,15 +169,15 @@ private:
// Only track the top scopes, not lower level functions // Only track the top scopes, not lower level functions
if (nodep->isTop()) { if (nodep->isTop()) {
m_topModp = nodep; m_topModp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->funcp()->entryPoint()) { if (!nodep->funcp()->entryPoint()) {
// Enter the function and trace it // Enter the function and trace it
m_tracingCall = true; m_tracingCall = true;
nodep->funcp()->accept(*this); iterate(nodep->funcp());
} }
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
@ -187,7 +188,7 @@ private:
return; return;
} }
m_tracingCall = false; m_tracingCall = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//---- //----
@ -209,21 +210,22 @@ private:
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
//UINFO(8,"ASS "<<nodep<<endl); //UINFO(8,"ASS "<<nodep<<endl);
m_assignp = nodep; m_assignp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_assignp = NULL; m_assignp = NULL;
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
UINFO(8,"ACTIVE "<<nodep<<endl); UINFO(8,"ACTIVE "<<nodep<<endl);
m_activep = nodep; m_activep = nodep;
nodep->sensesp()->iterateChildren(*this); // iterateAndNext? if (!nodep->sensesp()) nodep->v3fatalSrc("Unlinked");
iterateChildren(nodep->sensesp()); // iterateAndNext?
m_activep = NULL; m_activep = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//----- //-----
virtual void visit(AstVar*) {} // Don't want varrefs under it virtual void visit(AstVar*) {} // Don't want varrefs under it
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -232,7 +234,7 @@ public:
, m_tracingCall(false) , m_tracingCall(false)
, m_assignp(NULL) , m_assignp(NULL)
, m_topModp(NULL) { , m_topModp(NULL) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~GenClkReadVisitor() {} virtual ~GenClkReadVisitor() {}
}; };

View File

@ -75,7 +75,7 @@ private:
// For identical nodes, the type should be the same thus dtypep should be the same too // For identical nodes, the type should be the same thus dtypep should be the same too
m_lowerHash = V3Hash(m_lowerHash, V3Hash(nodep->type()<<6, V3Hash(nodep->dtypep()))); m_lowerHash = V3Hash(m_lowerHash, V3Hash(nodep->type()<<6, V3Hash(nodep->dtypep())));
// Now update m_lowerHash for our children's (and next children) contributions // Now update m_lowerHash for our children's (and next children) contributions
nodep->iterateChildren(*this); iterateChildren(nodep);
// Store the hash value // Store the hash value
nodep->user4(m_lowerHash.fullValue()); nodep->user4(m_lowerHash.fullValue());
//UINFO(9, " hashnode "<<m_lowerHash<<" "<<nodep<<endl); //UINFO(9, " hashnode "<<m_lowerHash<<" "<<nodep<<endl);

View File

@ -117,13 +117,13 @@ private:
} }
if (m_modp->modPublic()) cantInline("modPublic",false); if (m_modp->modPublic()) cantInline("modPublic",false);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
nodep->modp()->user3Inc(); // Inc refs nodep->modp()->user3Inc(); // Inc refs
m_instances[m_modp][nodep->modp()]++; m_instances[m_modp][nodep->modp()]++;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstPragma* nodep) { virtual void visit(AstPragma* nodep) {
if (nodep->pragType() == AstPragmaType::INLINE_MODULE) { if (nodep->pragType() == AstPragmaType::INLINE_MODULE) {
@ -143,7 +143,7 @@ private:
} }
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Remove so don't propagate to upper cell... nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Remove so don't propagate to upper cell...
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstVarXRef* nodep) { virtual void visit(AstVarXRef* nodep) {
@ -153,23 +153,23 @@ private:
virtual void visit(AstNodeFTaskRef* nodep) { virtual void visit(AstNodeFTaskRef* nodep) {
// Cleanup link until V3LinkDot can correct it // Cleanup link until V3LinkDot can correct it
if (!nodep->packagep()) nodep->taskp(NULL); if (!nodep->packagep()) nodep->taskp(NULL);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstAlways* nodep) { virtual void visit(AstAlways* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp->user4Inc(); // statement count m_modp->user4Inc(); // statement count
} }
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
// Don't count assignments, as they'll likely flatten out // Don't count assignments, as they'll likely flatten out
// Still need to iterate though to nullify VarXRefs // Still need to iterate though to nullify VarXRefs
int oldcnt = m_modp->user4(); int oldcnt = m_modp->user4();
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp->user4(oldcnt); m_modp->user4(oldcnt);
} }
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Build user2, user3, and user4 for all modules. // Build user2, user3, and user4 for all modules.
// Also build m_allMods and m_instances. // Also build m_allMods and m_instances.
nodep->iterateChildren(*this); iterateChildren(nodep);
// Iterate through all modules in bottom-up order. // Iterate through all modules in bottom-up order.
// Make a final inlining decision for each. // Make a final inlining decision for each.
@ -210,7 +210,7 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_modp) { if (m_modp) {
m_modp->user4Inc(); // Inc statement count m_modp->user4Inc(); // Inc statement count
} }
@ -220,7 +220,7 @@ public:
// CONSTUCTORS // CONSTUCTORS
explicit InlineMarkVisitor(AstNode* nodep) { explicit InlineMarkVisitor(AstNode* nodep) {
m_modp = NULL; m_modp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~InlineMarkVisitor() { virtual ~InlineMarkVisitor() {
V3Stats::addStat("Optimizations, Inline unsupported", m_statUnsup); V3Stats::addStat("Optimizations, Inline unsupported", m_statUnsup);
@ -255,13 +255,13 @@ private:
virtual void visit(AstNodeStmt* nodep) {} virtual void visit(AstNodeStmt* nodep) {}
virtual void visit(AstNodeMath* nodep) {} virtual void visit(AstNodeMath* nodep) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit InlineCollectVisitor(AstNodeModule* nodep) { // passed OLD module, not new one explicit InlineCollectVisitor(AstNodeModule* nodep) { // passed OLD module, not new one
nodep->accept(*this); iterate(nodep);
} }
virtual ~InlineCollectVisitor() {} virtual ~InlineCollectVisitor() {}
}; };
@ -298,17 +298,17 @@ private:
nodep->name(name); nodep->name(name);
UINFO(6, " Inline "<<nodep<<endl); UINFO(6, " Inline "<<nodep<<endl);
// Do CellInlines under this, but don't move them // Do CellInlines under this, but don't move them
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
// Cell under the inline cell, need to rename to avoid conflicts // Cell under the inline cell, need to rename to avoid conflicts
string name = m_cellp->name() + "__DOT__" + nodep->name(); string name = m_cellp->name() + "__DOT__" + nodep->name();
nodep->name(name); nodep->name(name);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstModule* nodep) { virtual void visit(AstModule* nodep) {
m_renamedInterfaces.clear(); m_renamedInterfaces.clear();
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
if (nodep->user2p()) { if (nodep->user2p()) {
@ -376,17 +376,17 @@ private:
if (!m_cellp->isTrace()) nodep->trace(false); if (!m_cellp->isTrace()) nodep->trace(false);
if (debug()>=9) { nodep->dumpTree(cout,"varchanged:"); } if (debug()>=9) { nodep->dumpTree(cout,"varchanged:"); }
if (debug()>=9 && nodep->valuep()) { nodep->valuep()->dumpTree(cout,"varchangei:"); } if (debug()>=9 && nodep->valuep()) { nodep->valuep()->dumpTree(cout,"varchangei:"); }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
// Function under the inline cell, need to rename to avoid conflicts // Function under the inline cell, need to rename to avoid conflicts
nodep->name(m_cellp->name() + "__DOT__" + nodep->name()); nodep->name(m_cellp->name() + "__DOT__" + nodep->name());
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstTypedef* nodep) { virtual void visit(AstTypedef* nodep) {
// Typedef under the inline cell, need to rename to avoid conflicts // Typedef under the inline cell, need to rename to avoid conflicts
nodep->name(m_cellp->name() + "__DOT__" + nodep->name()); nodep->name(m_cellp->name() + "__DOT__" + nodep->name());
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
if (nodep->varp()->user2p() // It's being converted to an alias. if (nodep->varp()->user2p() // It's being converted to an alias.
@ -407,7 +407,7 @@ private:
} }
} }
nodep->name(nodep->varp()->name()); nodep->name(nodep->varp()->name());
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVarXRef* nodep) { virtual void visit(AstVarXRef* nodep) {
// Track what scope it was originally under so V3LinkDot can resolve it // Track what scope it was originally under so V3LinkDot can resolve it
@ -426,7 +426,7 @@ private:
tryname = tryname.substr(0, pos); tryname = tryname.substr(0, pos);
} }
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeFTaskRef* nodep) { virtual void visit(AstNodeFTaskRef* nodep) {
// Track what scope it was originally under so V3LinkDot can resolve it // Track what scope it was originally under so V3LinkDot can resolve it
@ -436,7 +436,7 @@ private:
nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted()); nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted());
} }
UINFO(8," "<<nodep<<endl); UINFO(8," "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// Not needed, as V3LinkDot doesn't care about typedefs // Not needed, as V3LinkDot doesn't care about typedefs
@ -454,15 +454,15 @@ private:
if (afterp) afterp->unlinkFrBackWithNext(); if (afterp) afterp->unlinkFrBackWithNext();
nodep->scopeEntrp(new AstText(nodep->fileline(), (string)"__DOT__"+m_cellp->name())); nodep->scopeEntrp(new AstText(nodep->fileline(), (string)"__DOT__"+m_cellp->name()));
if (afterp) nodep->scopeEntrp(afterp); if (afterp) nodep->scopeEntrp(afterp);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCoverDecl* nodep) { virtual void visit(AstCoverDecl* nodep) {
// Fix path in coverage statements // Fix path in coverage statements
nodep->hier(VString::dot(m_cellp->prettyName(), ".", nodep->hier())); nodep->hier(VString::dot(m_cellp->prettyName(), ".", nodep->hier()));
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -470,7 +470,7 @@ public:
InlineRelinkVisitor(AstNodeModule* cloneModp, AstNodeModule* oldModp, AstCell* cellp) { InlineRelinkVisitor(AstNodeModule* cloneModp, AstNodeModule* oldModp, AstCell* cellp) {
m_modp = oldModp; m_modp = oldModp;
m_cellp = cellp; m_cellp = cellp;
cloneModp->accept(*this); iterate(cloneModp);
} }
virtual ~InlineRelinkVisitor() {} virtual ~InlineRelinkVisitor() {}
}; };
@ -508,7 +508,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Iterate modules backwards, in bottom-up order. Required! // Iterate modules backwards, in bottom-up order. Required!
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
virtual void visit(AstIfaceRefDType* nodep) { virtual void visit(AstIfaceRefDType* nodep) {
if (nodep->user5()) { if (nodep->user5()) {
@ -520,7 +520,7 @@ private:
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
if (nodep->modp()->user1()) { // Marked with inline request if (nodep->modp()->user1()) { // Marked with inline request
@ -605,14 +605,14 @@ private:
virtual void visit(AstNodeMath* nodep) {} // Accelerate virtual void visit(AstNodeMath* nodep) {} // Accelerate
virtual void visit(AstNodeStmt* nodep) {} // Accelerate virtual void visit(AstNodeStmt* nodep) {} // Accelerate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit InlineVisitor(AstNode* nodep) { explicit InlineVisitor(AstNode* nodep) {
m_modp = NULL; m_modp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~InlineVisitor() { virtual ~InlineVisitor() {
V3Stats::addStat("Optimizations, Inlined cells", m_statCells); V3Stats::addStat("Optimizations, Inlined cells", m_statCells);

View File

@ -64,7 +64,7 @@ private:
m_cellp = nodep; m_cellp = nodep;
//VV***** We reset user1p() on each cell!!! //VV***** We reset user1p() on each cell!!!
AstNode::user1ClearTree(); AstNode::user1ClearTree();
nodep->iterateChildren(*this); iterateChildren(nodep);
m_cellp = NULL; m_cellp = NULL;
} }
virtual void visit(AstPin* nodep) { virtual void visit(AstPin* nodep) {
@ -132,14 +132,14 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit InstVisitor(AstNetlist* nodep) { explicit InstVisitor(AstNetlist* nodep) {
m_cellp=NULL; m_cellp=NULL;
// //
nodep->accept(*this); iterate(nodep);
} }
virtual ~InstVisitor() {} virtual ~InstVisitor() {}
}; };
@ -165,13 +165,13 @@ private:
UINFO(8," dm-1-VAR "<<nodep<<endl); UINFO(8," dm-1-VAR "<<nodep<<endl);
insert(nodep); insert(nodep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// Save some time // Save some time
virtual void visit(AstNodeMath*) {} virtual void visit(AstNodeMath*) {}
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// METHODS // METHODS
@ -198,7 +198,7 @@ public:
void main(AstNodeModule* nodep) { void main(AstNodeModule* nodep) {
UINFO(8," dmMODULE "<<nodep<<endl); UINFO(8," dmMODULE "<<nodep<<endl);
m_modVarNameMap.clear(); m_modVarNameMap.clear();
nodep->accept(*this); iterate(nodep);
} }
virtual ~InstDeModVarVisitor() {} virtual ~InstDeModVarVisitor() {}
}; };
@ -251,7 +251,7 @@ private:
if (prevp) nodep->addNextHere(prevp); if (prevp) nodep->addNextHere(prevp);
if (prevp && debug()==9) { prevp->dumpTree(cout, "newintf: "); cout << endl; } if (prevp && debug()==9) { prevp->dumpTree(cout, "newintf: "); cout << endl; }
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
@ -302,7 +302,7 @@ private:
if (debug()==9) { varNewp->dumpTree(cout, "newintf: "); cout << endl; } if (debug()==9) { varNewp->dumpTree(cout, "newintf: "); cout << endl; }
} }
// Fixup pins // Fixup pins
newp->pinsp()->iterateAndNext(*this); iterateAndNextNull(newp->pinsp());
if (debug()==9) { newp->dumpTree(cout,"newcell: "); cout<<endl; } if (debug()==9) { newp->dumpTree(cout,"newcell: "); cout<<endl; }
} }
@ -314,7 +314,7 @@ private:
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
} else { } else {
m_cellRangep = NULL; m_cellRangep = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
@ -448,7 +448,7 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -456,7 +456,7 @@ public:
m_cellRangep=NULL; m_cellRangep=NULL;
m_instSelNum=0; m_instSelNum=0;
// //
nodep->accept(*this); iterate(nodep);
} }
virtual ~InstDeVisitor() {} virtual ~InstDeVisitor() {}
}; };

View File

@ -322,7 +322,7 @@ private:
// Similar code in V3Dead // Similar code in V3Dead
vluint64_t lastEdit = AstNode::editCountGbl(); // When it was last edited vluint64_t lastEdit = AstNode::editCountGbl(); // When it was last edited
m_sideEffect = false; m_sideEffect = false;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
if (lastEdit != AstNode::editCountGbl()) { if (lastEdit != AstNode::editCountGbl()) {
// We changed something, try to constant propagate, but don't delete the // We changed something, try to constant propagate, but don't delete the
// assignment as we still need nodep to remain. // assignment as we still need nodep to remain.
@ -334,30 +334,30 @@ private:
if (!vscp) nodep->v3fatalSrc("Scope lost on variable"); if (!vscp) nodep->v3fatalSrc("Scope lost on variable");
m_lifep->simpleAssign(vscp, nodep); m_lifep->simpleAssign(vscp, nodep);
} else { } else {
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
} }
} }
virtual void visit(AstAssignDly* nodep) { virtual void visit(AstAssignDly* nodep) {
// Don't treat as normal assign; V3Life doesn't understand time sense // Don't treat as normal assign; V3Life doesn't understand time sense
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//---- Track control flow changes //---- Track control flow changes
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
UINFO(4," IF "<<nodep<<endl); UINFO(4," IF "<<nodep<<endl);
// Condition is part of PREVIOUS block // Condition is part of PREVIOUS block
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
LifeBlock* prevLifep = m_lifep; LifeBlock* prevLifep = m_lifep;
LifeBlock* ifLifep = new LifeBlock (prevLifep, m_statep); LifeBlock* ifLifep = new LifeBlock (prevLifep, m_statep);
LifeBlock* elseLifep = new LifeBlock (prevLifep, m_statep); LifeBlock* elseLifep = new LifeBlock (prevLifep, m_statep);
{ {
m_lifep = ifLifep; m_lifep = ifLifep;
nodep->ifsp()->iterateAndNext(*this); iterateAndNextNull(nodep->ifsp());
m_lifep = prevLifep; m_lifep = prevLifep;
} }
{ {
m_lifep = elseLifep; m_lifep = elseLifep;
nodep->elsesp()->iterateAndNext(*this); iterateAndNextNull(nodep->elsesp());
m_lifep = prevLifep; m_lifep = prevLifep;
} }
UINFO(4," join "<<endl); UINFO(4," join "<<endl);
@ -383,14 +383,14 @@ private:
LifeBlock* bodyLifep = new LifeBlock (prevLifep, m_statep); LifeBlock* bodyLifep = new LifeBlock (prevLifep, m_statep);
{ {
m_lifep = condLifep; m_lifep = condLifep;
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
m_lifep = prevLifep; m_lifep = prevLifep;
} }
{ {
m_lifep = bodyLifep; m_lifep = bodyLifep;
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
m_lifep = prevLifep; m_lifep = prevLifep;
} }
UINFO(4," joinfor"<<endl); UINFO(4," joinfor"<<endl);
@ -410,7 +410,7 @@ private:
{ {
m_lifep = bodyLifep; m_lifep = bodyLifep;
m_noopt = true; m_noopt = true;
nodep->stmtsp()->iterateAndNext(*this); iterateAndNextNull(nodep->stmtsp());
m_lifep = prevLifep; m_lifep = prevLifep;
m_noopt = prev_noopt; m_noopt = prev_noopt;
} }
@ -421,11 +421,11 @@ private:
} }
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
//UINFO(4," CCALL "<<nodep<<endl); //UINFO(4," CCALL "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
// Enter the function and trace it // Enter the function and trace it
if (!nodep->funcp()->entryPoint()) { // else is non-inline or public function we optimize separately if (!nodep->funcp()->entryPoint()) { // else is non-inline or public function we optimize separately
m_tracingCall = true; m_tracingCall = true;
nodep->funcp()->accept(*this); iterate(nodep->funcp());
} }
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
@ -435,20 +435,20 @@ private:
if (nodep->dpiImport() && !nodep->pure()) { if (nodep->dpiImport() && !nodep->pure()) {
m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstUCFunc* nodep) { virtual void visit(AstUCFunc* nodep) {
m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCMath* nodep) { virtual void visit(AstCMath* nodep) {
m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVar*) {} // Don't want varrefs under it virtual void visit(AstVar*) {} // Don't want varrefs under it
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -461,7 +461,7 @@ public:
m_tracingCall = false; m_tracingCall = false;
{ {
m_lifep = new LifeBlock (NULL, m_statep); m_lifep = new LifeBlock (NULL, m_statep);
nodep->accept(*this); iterate(nodep);
if (m_lifep) { delete m_lifep; m_lifep=NULL; } if (m_lifep) { delete m_lifep; m_lifep=NULL; }
} }
} }
@ -502,13 +502,13 @@ private:
virtual void visit(AstNodeStmt*) {} // Accelerate virtual void visit(AstNodeStmt*) {} // Accelerate
virtual void visit(AstNodeMath*) {} // Accelerate virtual void visit(AstNodeMath*) {} // Accelerate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
LifeTopVisitor(AstNetlist* nodep, LifeState* statep) { LifeTopVisitor(AstNetlist* nodep, LifeState* statep) {
m_statep = statep; m_statep = statep;
nodep->accept(*this); iterate(nodep);
} }
virtual ~LifeTopVisitor() {} virtual ~LifeTopVisitor() {}
}; };

View File

@ -75,30 +75,30 @@ private:
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
// Only track the top scopes, not lower level functions // Only track the top scopes, not lower level functions
if (nodep->isTop()) nodep->iterateChildren(*this); if (nodep->isTop()) iterateChildren(nodep);
} }
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->funcp()->entryPoint()) { if (!nodep->funcp()->entryPoint()) {
// Enter the function and trace it // Enter the function and trace it
m_tracingCall = true; m_tracingCall = true;
nodep->funcp()->accept(*this); iterate(nodep->funcp());
} }
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
if (!m_tracingCall && !nodep->entryPoint()) return; if (!m_tracingCall && !nodep->entryPoint()) return;
m_tracingCall = false; m_tracingCall = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVar*) {} // Don't want varrefs under it virtual void visit(AstVar*) {} // Don't want varrefs under it
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit LifePostElimVisitor(AstTopScope* nodep) explicit LifePostElimVisitor(AstTopScope* nodep)
: m_tracingCall(false) { : m_tracingCall(false) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~LifePostElimVisitor() {} virtual ~LifePostElimVisitor() {}
}; };
@ -128,7 +128,7 @@ private:
AstNode::user2ClearTree(); // user2p() used on entire tree AstNode::user2ClearTree(); // user2p() used on entire tree
AstNode::user4ClearTree(); // user4p() used on entire tree AstNode::user4ClearTree(); // user4p() used on entire tree
m_sequence = 0; m_sequence = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
// Replace any node4p varscopes with the new scope // Replace any node4p varscopes with the new scope
LifePostElimVisitor visitor (nodep); LifePostElimVisitor visitor (nodep);
@ -190,32 +190,32 @@ private:
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
// Only track the top scopes, not lower level functions // Only track the top scopes, not lower level functions
if (nodep->isTop()) nodep->iterateChildren(*this); if (nodep->isTop()) iterateChildren(nodep);
} }
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->funcp()->entryPoint()) { if (!nodep->funcp()->entryPoint()) {
// Enter the function and trace it // Enter the function and trace it
m_tracingCall = true; m_tracingCall = true;
nodep->funcp()->accept(*this); iterate(nodep->funcp());
} }
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
if (!m_tracingCall && !nodep->entryPoint()) return; if (!m_tracingCall && !nodep->entryPoint()) return;
m_tracingCall = false; m_tracingCall = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//----- //-----
virtual void visit(AstVar*) {} // Don't want varrefs under it virtual void visit(AstVar*) {} // Don't want varrefs under it
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit LifePostDlyVisitor(AstNetlist* nodep) explicit LifePostDlyVisitor(AstNetlist* nodep)
: m_tracingCall(false) { : m_tracingCall(false) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~LifePostDlyVisitor() { virtual ~LifePostDlyVisitor() {
V3Stats::addStat("Optimizations, Lifetime postassign deletions", m_statAssnDel); V3Stats::addStat("Optimizations, Lifetime postassign deletions", m_statAssnDel);

View File

@ -160,7 +160,7 @@ private:
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
AstNode::user1ClearTree(); AstNode::user1ClearTree();
readModNames(); readModNames();
nodep->iterateChildren(*this); iterateChildren(nodep);
// Find levels in graph // Find levels in graph
m_graph.removeRedundantEdges(&V3GraphEdge::followAlwaysTrue); m_graph.removeRedundantEdges(&V3GraphEdge::followAlwaysTrue);
m_graph.dumpDotFilePrefixed("linkcells"); m_graph.dumpDotFilePrefixed("linkcells");
@ -219,7 +219,7 @@ private:
new V3GraphEdge(&m_graph, m_libVertexp, vertex(nodep), 1, false); new V3GraphEdge(&m_graph, m_libVertexp, vertex(nodep), 1, false);
} }
// Note AstBind also has iteration on cells // Note AstBind also has iteration on cells
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->checkTree(); nodep->checkTree();
m_modp = NULL; m_modp = NULL;
} }
@ -245,7 +245,7 @@ private:
virtual void visit(AstPackageImport* nodep) { virtual void visit(AstPackageImport* nodep) {
// Package Import: We need to do the package before the use of a package // Package Import: We need to do the package before the use of a package
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->packagep()) nodep->v3fatalSrc("Unlinked package"); // Parser should set packagep if (!nodep->packagep()) nodep->v3fatalSrc("Unlinked package"); // Parser should set packagep
new V3GraphEdge(&m_graph, vertex(m_modp), vertex(nodep->packagep()), 1, false); new V3GraphEdge(&m_graph, vertex(m_modp), vertex(nodep->packagep()), 1, false);
} }
@ -264,7 +264,7 @@ private:
{ {
m_modp = modp; m_modp = modp;
modp->addStmtp(cellsp); // Important that this adds to end, as next iterate assumes does all cells modp->addStmtp(cellsp); // Important that this adds to end, as next iterate assumes does all cells
cellsp->iterateAndNext(*this); iterateAndNextNull(cellsp);
} }
m_modp = oldModp; m_modp = oldModp;
} }
@ -428,7 +428,7 @@ private:
} }
} }
if (nodep->modp()) { if (nodep->modp()) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
UINFO(4," Link Cell done: "<<nodep<<endl); UINFO(4," Link Cell done: "<<nodep<<endl);
} }
@ -438,7 +438,7 @@ private:
virtual void visit(AstNodeMath* nodep) {} virtual void visit(AstNodeMath* nodep) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// METHODS // METHODS
@ -470,7 +470,7 @@ public:
m_modp = NULL; m_modp = NULL;
m_libVertexp = NULL; m_libVertexp = NULL;
m_topVertexp = NULL; m_topVertexp = NULL;
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkCellsVisitor() {} virtual ~LinkCellsVisitor() {}
}; };

View File

@ -653,7 +653,7 @@ class LinkDotFindVisitor : public AstNVisitor {
m_statep->insertDUnit(nodep); m_statep->insertDUnit(nodep);
// First back iterate, to find all packages. Backward as must do base packages before using packages // First back iterate, to find all packages. Backward as must do base packages before using packages
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
// The first module in the list is always the top module (sorted before this is called). // The first module in the list is always the top module (sorted before this is called).
// This may not be the module with isTop() set, as early in the steps, // This may not be the module with isTop() set, as early in the steps,
@ -666,7 +666,7 @@ class LinkDotFindVisitor : public AstNVisitor {
m_scope = "TOP"; m_scope = "TOP";
m_curSymp = m_modSymp = m_statep->insertTopCell(topmodp, m_scope); m_curSymp = m_modSymp = m_statep->insertTopCell(topmodp, m_scope);
{ {
topmodp->accept(*this); iterate(topmodp);
} }
m_scope = ""; m_scope = "";
m_curSymp = m_modSymp = NULL; m_curSymp = m_modSymp = NULL;
@ -712,7 +712,7 @@ class LinkDotFindVisitor : public AstNVisitor {
// m_modSymp/m_curSymp for non-packages set by AstCell above this module // m_modSymp/m_curSymp for non-packages set by AstCell above this module
// Iterate // Iterate
nodep->user2(true); nodep->user2(true);
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->user2(false); nodep->user2(false);
nodep->user4(true); nodep->user4(true);
// Interfaces need another pass when signals are resolved // Interfaces need another pass when signals are resolved
@ -741,7 +741,7 @@ class LinkDotFindVisitor : public AstNVisitor {
UINFO(5," CELL under "<<m_scope<<" is "<<nodep<<endl); UINFO(5," CELL under "<<m_scope<<" is "<<nodep<<endl);
// Process XREFs/etc inside pins // Process XREFs/etc inside pins
if (nodep->recursive() && m_inRecursion) return; if (nodep->recursive() && m_inRecursion) return;
nodep->iterateChildren(*this); iterateChildren(nodep);
// Recurse in, preserving state // Recurse in, preserving state
string oldscope = m_scope; string oldscope = m_scope;
AstBegin* oldbeginp = m_beginp; AstBegin* oldbeginp = m_beginp;
@ -769,7 +769,7 @@ class LinkDotFindVisitor : public AstNVisitor {
m_beginp = NULL; m_beginp = NULL;
m_inRecursion = nodep->recursive(); m_inRecursion = nodep->recursive();
// We don't report NotFoundModule, as may be a unused module in a generate // We don't report NotFoundModule, as may be a unused module in a generate
if (nodep->modp()) nodep->modp()->accept(*this); if (nodep->modp()) iterate(nodep->modp());
} }
m_scope = oldscope; m_scope = oldscope;
m_beginp = oldbeginp; m_beginp = oldbeginp;
@ -800,7 +800,7 @@ class LinkDotFindVisitor : public AstNVisitor {
} }
virtual void visit(AstDefParam* nodep) { virtual void visit(AstDefParam* nodep) {
nodep->user1p(m_curSymp); nodep->user1p(m_curSymp);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstGenerate* nodep) { virtual void visit(AstGenerate* nodep) {
// Begin: ... blocks often replicate under genif/genfor, so simply suppress duplicate checks // Begin: ... blocks often replicate under genif/genfor, so simply suppress duplicate checks
@ -808,7 +808,7 @@ class LinkDotFindVisitor : public AstNVisitor {
bool lastInGen = m_inGenerate; bool lastInGen = m_inGenerate;
{ {
m_inGenerate = true; m_inGenerate = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_inGenerate = lastInGen; m_inGenerate = lastInGen;
} }
@ -848,7 +848,7 @@ class LinkDotFindVisitor : public AstNVisitor {
m_curSymp = m_statep->insertBlock(m_curSymp, nodep->name(), nodep, m_packagep); m_curSymp = m_statep->insertBlock(m_curSymp, nodep->name(), nodep, m_packagep);
m_curSymp->fallbackp(oldCurSymp); m_curSymp->fallbackp(oldCurSymp);
// Iterate // Iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_curSymp = oldCurSymp; m_curSymp = oldCurSymp;
m_beginp = oldbegin; m_beginp = oldbegin;
@ -884,7 +884,7 @@ class LinkDotFindVisitor : public AstNVisitor {
m_statep->insertSym(m_curSymp, newvarp->name(), newvarp, NULL/*packagep*/); m_statep->insertSym(m_curSymp, newvarp->name(), newvarp, NULL/*packagep*/);
} }
m_ftaskp = nodep; m_ftaskp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ftaskp = NULL; m_ftaskp = NULL;
} }
m_curSymp = oldCurSymp; m_curSymp = oldCurSymp;
@ -892,7 +892,7 @@ class LinkDotFindVisitor : public AstNVisitor {
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
// Var: Remember its name for later resolution // Var: Remember its name for later resolution
if (!m_curSymp || !m_modSymp) nodep->v3fatalSrc("Var not under module?"); if (!m_curSymp || !m_modSymp) nodep->v3fatalSrc("Var not under module?");
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!m_statep->forScopeCreation()) { if (!m_statep->forScopeCreation()) {
// Find under either a task or the module's vars // Find under either a task or the module's vars
VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name());
@ -976,12 +976,12 @@ class LinkDotFindVisitor : public AstNVisitor {
virtual void visit(AstTypedef* nodep) { virtual void visit(AstTypedef* nodep) {
// Remember its name for later resolution // Remember its name for later resolution
if (!m_curSymp) nodep->v3fatalSrc("Typedef not under module?"); if (!m_curSymp) nodep->v3fatalSrc("Typedef not under module?");
nodep->iterateChildren(*this); iterateChildren(nodep);
m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep); m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep);
} }
virtual void visit(AstParamTypeDType* nodep) { virtual void visit(AstParamTypeDType* nodep) {
if (!m_curSymp) nodep->v3fatalSrc("Parameter type not under module?"); if (!m_curSymp) nodep->v3fatalSrc("Parameter type not under module?");
nodep->iterateChildren(*this); iterateChildren(nodep);
m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep); m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
@ -990,7 +990,7 @@ class LinkDotFindVisitor : public AstNVisitor {
} }
virtual void visit(AstEnumItem* nodep) { virtual void visit(AstEnumItem* nodep) {
// EnumItem: Remember its name for later resolution // EnumItem: Remember its name for later resolution
nodep->iterateChildren(*this); iterateChildren(nodep);
// Find under either a task or the module's vars // Find under either a task or the module's vars
VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name());
if (!foundp && m_modSymp && nodep->name() == m_modSymp->nodep()->name()) foundp = m_modSymp; // Conflicts with modname? if (!foundp && m_modSymp && nodep->name() == m_modSymp->nodep()->name()) foundp = m_modSymp; // Conflicts with modname?
@ -1052,7 +1052,7 @@ class LinkDotFindVisitor : public AstNVisitor {
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -1070,7 +1070,7 @@ public:
m_beginNum = 0; m_beginNum = 0;
m_modBeginNum = 0; m_modBeginNum = 0;
// //
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkDotFindVisitor() {} virtual ~LinkDotFindVisitor() {}
}; };
@ -1127,7 +1127,7 @@ private:
nodep->dead(true); nodep->dead(true);
} else { } else {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
} }
@ -1140,7 +1140,7 @@ private:
} }
} }
virtual void visit(AstDefParam* nodep) { virtual void visit(AstDefParam* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->v3warn(DEFPARAM,"Suggest replace defparam with Verilog 2001 #(."<<nodep->prettyName()<<"(...etc...))"); nodep->v3warn(DEFPARAM,"Suggest replace defparam with Verilog 2001 #(."<<nodep->prettyName()<<"(...etc...))");
VSymEnt* foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->path()); VSymEnt* foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->path());
AstCell* cellp = foundp ? VN_CAST(foundp->nodep(), Cell) : NULL; AstCell* cellp = foundp ? VN_CAST(foundp->nodep(), Cell) : NULL;
@ -1184,7 +1184,7 @@ private:
// We used to nodep->allowImplicit() here, but it turns out // We used to nodep->allowImplicit() here, but it turns out
// normal "assigns" can also make implicit wires. Yuk. // normal "assigns" can also make implicit wires. Yuk.
pinImplicitExprRecurse(nodep->lhsp()); pinImplicitExprRecurse(nodep->lhsp());
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstAssignAlias* nodep) { virtual void visit(AstAssignAlias* nodep) {
// tran gates need implicit creation // tran gates need implicit creation
@ -1196,7 +1196,7 @@ private:
if (AstVarRef* forrefp = VN_CAST(nodep->rhsp(), VarRef)) { if (AstVarRef* forrefp = VN_CAST(nodep->rhsp(), VarRef)) {
pinImplicitExprRecurse(forrefp); pinImplicitExprRecurse(forrefp);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstImplicit* nodep) { virtual void visit(AstImplicit* nodep) {
// Unsupported gates need implicit creation // Unsupported gates need implicit creation
@ -1206,7 +1206,7 @@ private:
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -1216,7 +1216,7 @@ public:
m_statep = statep; m_statep = statep;
m_modp = NULL; m_modp = NULL;
// //
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkDotParamVisitor() {} virtual ~LinkDotParamVisitor() {}
}; };
@ -1236,7 +1236,7 @@ class LinkDotScopeVisitor : public AstNVisitor {
// VISITs // VISITs
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Recurse..., backward as must do packages before using packages // Recurse..., backward as must do packages before using packages
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
UINFO(8," SCOPE "<<nodep<<endl); UINFO(8," SCOPE "<<nodep<<endl);
@ -1245,7 +1245,7 @@ class LinkDotScopeVisitor : public AstNVisitor {
// up with the hierarchy created by the CELL names. // up with the hierarchy created by the CELL names.
m_modSymp = m_statep->getScopeSym(nodep); m_modSymp = m_statep->getScopeSym(nodep);
m_scopep = nodep; m_scopep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modSymp = NULL; m_modSymp = NULL;
m_scopep = NULL; m_scopep = NULL;
} }
@ -1289,7 +1289,7 @@ class LinkDotScopeVisitor : public AstNVisitor {
AstVarScope* toVscp = VN_CAST(nodep->rhsp(), VarRef)->varScopep(); AstVarScope* toVscp = VN_CAST(nodep->rhsp(), VarRef)->varScopep();
if (!fromVscp || !toVscp) nodep->v3fatalSrc("Bad alias scopes"); if (!fromVscp || !toVscp) nodep->v3fatalSrc("Bad alias scopes");
fromVscp->user2p(toVscp); fromVscp->user2p(toVscp);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstAssignVarScope* nodep) { virtual void visit(AstAssignVarScope* nodep) {
UINFO(5,"ASSIGNVARSCOPE "<<nodep<<endl); UINFO(5,"ASSIGNVARSCOPE "<<nodep<<endl);
@ -1341,7 +1341,7 @@ class LinkDotScopeVisitor : public AstNVisitor {
virtual void visit(AstNodeMath*) {} virtual void visit(AstNodeMath*) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -1352,7 +1352,7 @@ public:
m_scopep = NULL; m_scopep = NULL;
m_statep = statep; m_statep = statep;
// //
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkDotScopeVisitor() {} virtual ~LinkDotScopeVisitor() {}
}; };
@ -1377,13 +1377,13 @@ class LinkDotIfaceVisitor : public AstNVisitor {
// Create symbol table for the vars // Create symbol table for the vars
m_curSymp = m_statep->insertBlock(m_curSymp, nodep->name(), nodep, NULL); m_curSymp = m_statep->insertBlock(m_curSymp, nodep->name(), nodep, NULL);
m_curSymp->fallbackp(oldCurSymp); m_curSymp->fallbackp(oldCurSymp);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_curSymp = oldCurSymp; m_curSymp = oldCurSymp;
} }
virtual void visit(AstModportFTaskRef* nodep) { virtual void visit(AstModportFTaskRef* nodep) {
UINFO(5," fif: "<<nodep<<endl); UINFO(5," fif: "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isExport()) nodep->v3error("Unsupported: modport export"); if (nodep->isExport()) nodep->v3error("Unsupported: modport export");
VSymEnt* symp = m_curSymp->findIdFallback(nodep->name()); VSymEnt* symp = m_curSymp->findIdFallback(nodep->name());
if (!symp) { if (!symp) {
@ -1404,7 +1404,7 @@ class LinkDotIfaceVisitor : public AstNVisitor {
} }
virtual void visit(AstModportVarRef* nodep) { virtual void visit(AstModportVarRef* nodep) {
UINFO(5," fiv: "<<nodep<<endl); UINFO(5," fiv: "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
VSymEnt* symp = m_curSymp->findIdFallback(nodep->name()); VSymEnt* symp = m_curSymp->findIdFallback(nodep->name());
if (!symp) { if (!symp) {
nodep->v3error("Modport item not found: "<<nodep->prettyName()); nodep->v3error("Modport item not found: "<<nodep->prettyName());
@ -1428,7 +1428,7 @@ class LinkDotIfaceVisitor : public AstNVisitor {
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -1437,7 +1437,7 @@ public:
UINFO(4,__FUNCTION__<<": "<<endl); UINFO(4,__FUNCTION__<<": "<<endl);
m_curSymp = curSymp; m_curSymp = curSymp;
m_statep = statep; m_statep = statep;
nodep->accept(*this); iterate(nodep);
} }
virtual ~LinkDotIfaceVisitor() {} virtual ~LinkDotIfaceVisitor() {}
}; };
@ -1582,7 +1582,7 @@ private:
// VISITs // VISITs
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Recurse..., backward as must do packages before using packages // Recurse..., backward as must do packages before using packages
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
virtual void visit(AstTypeTable* nodep) {} virtual void visit(AstTypeTable* nodep) {}
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
@ -1594,7 +1594,7 @@ private:
m_cellp = NULL; m_cellp = NULL;
m_modp = nodep; m_modp = nodep;
m_modportNum = 0; m_modportNum = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
m_ds.m_dotSymp = m_curSymp = m_modSymp = NULL; m_ds.m_dotSymp = m_curSymp = m_modSymp = NULL;
} }
@ -1604,7 +1604,7 @@ private:
VSymEnt* oldCurSymp = m_curSymp; VSymEnt* oldCurSymp = m_curSymp;
checkNoDot(nodep); checkNoDot(nodep);
m_ds.m_dotSymp = m_curSymp = m_modSymp = m_statep->getScopeSym(nodep); m_ds.m_dotSymp = m_curSymp = m_modSymp = m_statep->getScopeSym(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ds.m_dotSymp = m_curSymp = m_modSymp = NULL; m_ds.m_dotSymp = m_curSymp = m_modSymp = NULL;
m_modSymp = oldModSymp; m_modSymp = oldModSymp;
m_curSymp = oldCurSymp; m_curSymp = oldCurSymp;
@ -1636,7 +1636,7 @@ private:
UINFO(4,"(Backto) Link Cell: "<<nodep<<endl); UINFO(4,"(Backto) Link Cell: "<<nodep<<endl);
//if (debug()) { nodep->dumpTree(cout,"linkcell:"); } //if (debug()) { nodep->dumpTree(cout,"linkcell:"); }
//if (debug()) { nodep->modp()->dumpTree(cout,"linkcemd:"); } //if (debug()) { nodep->modp()->dumpTree(cout,"linkcemd:"); }
nodep->iterateChildren(*this); iterateChildren(nodep);
m_pinSymp = NULL; m_pinSymp = NULL;
} }
} }
@ -1647,7 +1647,7 @@ private:
virtual void visit(AstPin* nodep) { virtual void visit(AstPin* nodep) {
// Pin: Link to submodule's port // Pin: Link to submodule's port
checkNoDot(nodep); checkNoDot(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->modVarp()) { if (!nodep->modVarp()) {
if (!m_pinSymp) nodep->v3fatalSrc("Pin not under cell?"); if (!m_pinSymp) nodep->v3fatalSrc("Pin not under cell?");
VSymEnt* foundp = m_pinSymp->findIdFlat(nodep->name()); VSymEnt* foundp = m_pinSymp->findIdFlat(nodep->name());
@ -1701,7 +1701,7 @@ private:
m_ds.m_dotPos = DP_PACKAGE; m_ds.m_dotPos = DP_PACKAGE;
} else { } else {
m_ds.m_dotPos = DP_SCOPE; m_ds.m_dotPos = DP_SCOPE;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
//if (debug()>=9) nodep->dumpTree("-dot-lho: "); //if (debug()>=9) nodep->dumpTree("-dot-lho: ");
} }
if (m_ds.m_unresolved && (VN_IS(nodep->lhsp(), CellRef) || VN_IS(nodep->lhsp(), CellArrayRef))) { if (m_ds.m_unresolved && (VN_IS(nodep->lhsp(), CellRef) || VN_IS(nodep->lhsp(), CellArrayRef))) {
@ -1709,7 +1709,7 @@ private:
} }
if (!m_ds.m_dotErr) { // Once something wrong, give up if (!m_ds.m_dotErr) { // Once something wrong, give up
if (start && m_ds.m_dotPos==DP_SCOPE) m_ds.m_dotPos = DP_FINAL; // Top 'final' dot RHS is final RHS, else it's a DOT(DOT(x,*here*),real-rhs) which we consider a RHS if (start && m_ds.m_dotPos==DP_SCOPE) m_ds.m_dotPos = DP_FINAL; // Top 'final' dot RHS is final RHS, else it's a DOT(DOT(x,*here*),real-rhs) which we consider a RHS
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
//if (debug()>=9) nodep->dumpTree("-dot-rho: "); //if (debug()>=9) nodep->dumpTree("-dot-rho: ");
} }
if (start) { if (start) {
@ -1952,7 +1952,7 @@ private:
// ParseRefs are used the first pass (forPrimary) so we shouldn't get can't find // ParseRefs are used the first pass (forPrimary) so we shouldn't get can't find
// errors here now that we have a VarRef. // errors here now that we have a VarRef.
// No checkNoDot; created and iterated from a parseRef // No checkNoDot; created and iterated from a parseRef
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->varp()) { if (!nodep->varp()) {
UINFO(9," linkVarRef se"<<(void*)m_curSymp<<" n="<<nodep<<endl); UINFO(9," linkVarRef se"<<(void*)m_curSymp<<" n="<<nodep<<endl);
if (!m_curSymp) nodep->v3fatalSrc("NULL lookup symbol table"); if (!m_curSymp) nodep->v3fatalSrc("NULL lookup symbol table");
@ -2034,20 +2034,20 @@ private:
} }
virtual void visit(AstEnumItemRef* nodep) { virtual void visit(AstEnumItemRef* nodep) {
// EnumItemRef may be under a dot. Should already be resolved. // EnumItemRef may be under a dot. Should already be resolved.
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstMethodSel* nodep) { virtual void visit(AstMethodSel* nodep) {
// Created here so should already be resolved. // Created here so should already be resolved.
DotStates lastStates = m_ds; DotStates lastStates = m_ds;
{ {
m_ds.init(m_curSymp); m_ds.init(m_curSymp);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_ds = lastStates; m_ds = lastStates;
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
checkNoDot(nodep); checkNoDot(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_statep->forPrimary() && nodep->isIO() && !m_ftaskp && !nodep->user4()) { if (m_statep->forPrimary() && nodep->isIO() && !m_ftaskp && !nodep->user4()) {
nodep->v3error("Input/output/inout does not appear in port list: "<<nodep->prettyName()); nodep->v3error("Input/output/inout does not appear in port list: "<<nodep->prettyName());
} }
@ -2138,13 +2138,13 @@ private:
DotStates lastStates = m_ds; DotStates lastStates = m_ds;
{ {
m_ds.init(m_curSymp); m_ds.init(m_curSymp);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_ds = lastStates; m_ds = lastStates;
} }
virtual void visit(AstSelBit* nodep) { virtual void visit(AstSelBit* nodep) {
if (nodep->user3SetOnce()) return; if (nodep->user3SetOnce()) return;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
if (m_ds.m_dotPos == DP_SCOPE) { // Already under dot, so this is {modulepart} DOT {modulepart} if (m_ds.m_dotPos == DP_SCOPE) { // Already under dot, so this is {modulepart} DOT {modulepart}
UINFO(9," deferring until after a V3Param pass: "<<nodep<<endl); UINFO(9," deferring until after a V3Param pass: "<<nodep<<endl);
m_ds.m_dotText += "__BRA__??__KET__"; m_ds.m_dotText += "__BRA__??__KET__";
@ -2152,12 +2152,12 @@ private:
// And pass up m_ds.m_dotText // And pass up m_ds.m_dotText
} }
// Pass dot state down to fromp() // Pass dot state down to fromp()
nodep->fromp()->iterateAndNext(*this); iterateAndNextNull(nodep->fromp());
DotStates lastStates = m_ds; DotStates lastStates = m_ds;
{ {
m_ds.init(m_curSymp); m_ds.init(m_curSymp);
nodep->bitp()->iterateAndNext(*this); iterateAndNextNull(nodep->bitp());
nodep->attrp()->iterateAndNext(*this); iterateAndNextNull(nodep->attrp());
} }
m_ds = lastStates; m_ds = lastStates;
if (m_ds.m_unresolved && m_ds.m_dotPos == DP_SCOPE) { if (m_ds.m_unresolved && m_ds.m_dotPos == DP_SCOPE) {
@ -2174,19 +2174,19 @@ private:
m_ds.m_dotErr = true; m_ds.m_dotErr = true;
return; return;
} }
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
DotStates lastStates = m_ds; DotStates lastStates = m_ds;
{ {
m_ds.init(m_curSymp); m_ds.init(m_curSymp);
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
nodep->thsp()->iterateAndNext(*this); iterateAndNextNull(nodep->thsp());
nodep->attrp()->iterateAndNext(*this); iterateAndNextNull(nodep->attrp());
} }
m_ds = lastStates; m_ds = lastStates;
} }
virtual void visit(AstMemberSel* nodep) { virtual void visit(AstMemberSel* nodep) {
// checkNoDot not appropriate, can be under a dot // checkNoDot not appropriate, can be under a dot
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstBegin* nodep) { virtual void visit(AstBegin* nodep) {
UINFO(5," "<<nodep<<endl); UINFO(5," "<<nodep<<endl);
@ -2195,7 +2195,7 @@ private:
{ {
m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep); m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep);
UINFO(5," cur=se"<<(void*)m_curSymp<<endl); UINFO(5," cur=se"<<(void*)m_curSymp<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_ds.m_dotSymp = m_curSymp = oldCurSymp; m_ds.m_dotSymp = m_curSymp = oldCurSymp;
UINFO(5," cur=se"<<(void*)m_curSymp<<endl); UINFO(5," cur=se"<<(void*)m_curSymp<<endl);
@ -2207,7 +2207,7 @@ private:
{ {
m_ftaskp = nodep; m_ftaskp = nodep;
m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep); m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_ds.m_dotSymp = m_curSymp = oldCurSymp; m_ds.m_dotSymp = m_curSymp = oldCurSymp;
m_ftaskp = NULL; m_ftaskp = NULL;
@ -2243,11 +2243,11 @@ private:
nodep->v3error("Can't find typedef: "<<nodep->prettyName()); nodep->v3error("Can't find typedef: "<<nodep->prettyName());
} }
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstDpiExport* nodep) { virtual void visit(AstDpiExport* nodep) {
// AstDpiExport: Make sure the function referenced exists, then dump it // AstDpiExport: Make sure the function referenced exists, then dump it
nodep->iterateChildren(*this); iterateChildren(nodep);
checkNoDot(nodep); checkNoDot(nodep);
VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name());
AstNodeFTask* taskp = foundp ? VN_CAST(foundp->nodep(), NodeFTask) : NULL; AstNodeFTask* taskp = foundp ? VN_CAST(foundp->nodep(), NodeFTask) : NULL;
@ -2277,7 +2277,7 @@ private:
} }
virtual void visit(AstCellRef* nodep) { virtual void visit(AstCellRef* nodep) {
UINFO(5," AstCellRef: "<<nodep<<" "<<m_ds.ascii()<<endl); UINFO(5," AstCellRef: "<<nodep<<" "<<m_ds.ascii()<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCellArrayRef* nodep) { virtual void visit(AstCellArrayRef* nodep) {
UINFO(5," AstCellArrayRef: "<<nodep<<" "<<m_ds.ascii()<<endl); UINFO(5," AstCellArrayRef: "<<nodep<<" "<<m_ds.ascii()<<endl);
@ -2291,7 +2291,7 @@ private:
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
checkNoDot(nodep); checkNoDot(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -2306,7 +2306,7 @@ public:
m_ftaskp = NULL; m_ftaskp = NULL;
m_modportNum = 0; m_modportNum = 0;
// //
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkDotResolveVisitor() {} virtual ~LinkDotResolveVisitor() {}
}; };

View File

@ -117,18 +117,18 @@ private:
if (nodep->dead()) return; if (nodep->dead()) return;
m_modp = nodep; m_modp = nodep;
m_repeatNum = 0; m_repeatNum = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
m_ftaskp = nodep; m_ftaskp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ftaskp = NULL; m_ftaskp = NULL;
} }
virtual void visit(AstBegin* nodep) { virtual void visit(AstBegin* nodep) {
UINFO(8," "<<nodep<<endl); UINFO(8," "<<nodep<<endl);
m_beginStack.push_back(nodep); m_beginStack.push_back(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_beginStack.pop_back(); m_beginStack.pop_back();
} }
virtual void visit(AstRepeat* nodep) { virtual void visit(AstRepeat* nodep) {
@ -167,16 +167,16 @@ private:
bool lastInc = m_loopInc; bool lastInc = m_loopInc;
m_loopp = nodep; m_loopp = nodep;
m_loopInc = false; m_loopInc = false;
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
m_loopInc = true; m_loopInc = true;
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
m_loopInc = lastInc; m_loopInc = lastInc;
m_loopp = lastLoopp; m_loopp = lastLoopp;
} }
virtual void visit(AstReturn* nodep) { virtual void visit(AstReturn* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
AstFunc* funcp = VN_CAST(m_ftaskp, Func); AstFunc* funcp = VN_CAST(m_ftaskp, Func);
if (!m_ftaskp) { nodep->v3error("Return isn't underneath a task or function"); } if (!m_ftaskp) { nodep->v3error("Return isn't underneath a task or function"); }
else if (funcp && !nodep->lhsp()) { nodep->v3error("Return underneath a function should have return value"); } else if (funcp && !nodep->lhsp()) { nodep->v3error("Return underneath a function should have return value"); }
@ -195,7 +195,7 @@ private:
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
} }
virtual void visit(AstBreak* nodep) { virtual void visit(AstBreak* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!m_loopp) { nodep->v3error("break isn't underneath a loop"); } if (!m_loopp) { nodep->v3error("break isn't underneath a loop"); }
else { else {
// Jump to the end of the loop // Jump to the end of the loop
@ -205,7 +205,7 @@ private:
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
} }
virtual void visit(AstContinue* nodep) { virtual void visit(AstContinue* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!m_loopp) { nodep->v3error("continue isn't underneath a loop"); } if (!m_loopp) { nodep->v3error("continue isn't underneath a loop"); }
else { else {
// Jump to the end of this iteration // Jump to the end of this iteration
@ -217,7 +217,7 @@ private:
} }
virtual void visit(AstDisable* nodep) { virtual void visit(AstDisable* nodep) {
UINFO(8," DISABLE "<<nodep<<endl); UINFO(8," DISABLE "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
AstBegin* beginp = NULL; AstBegin* beginp = NULL;
for (BeginStack::reverse_iterator it = m_beginStack.rbegin(); it != m_beginStack.rend(); ++it) { for (BeginStack::reverse_iterator it = m_beginStack.rbegin(); it != m_beginStack.rend(); ++it) {
UINFO(9," UNDERBLK "<<*it<<endl); UINFO(9," UNDERBLK "<<*it<<endl);
@ -242,7 +242,7 @@ private:
virtual void visit(AstConst* nodep) {} virtual void visit(AstConst* nodep) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -252,7 +252,7 @@ public:
m_loopp = NULL; m_loopp = NULL;
m_loopInc = false; m_loopInc = false;
m_repeatNum = 0; m_repeatNum = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~LinkJumpVisitor() {} virtual ~LinkJumpVisitor() {}
}; };

View File

@ -67,7 +67,7 @@ private:
} }
} }
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// Nodes that start propagating down lvalues // Nodes that start propagating down lvalues
@ -76,19 +76,19 @@ private:
// When the varref's were created, we didn't know the I/O state // When the varref's were created, we didn't know the I/O state
// Now that we do, and it's from a output, we know it's a lvalue // Now that we do, and it's from a output, we know it's a lvalue
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_setRefLvalue = false; m_setRefLvalue = false;
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -96,10 +96,10 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->filenamep()->iterateAndNext(*this); iterateAndNextNull(nodep->filenamep());
nodep->modep()->iterateAndNext(*this); iterateAndNextNull(nodep->modep());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -107,7 +107,7 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -115,7 +115,7 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -123,7 +123,7 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -131,8 +131,8 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
nodep->strgp()->iterateAndNext(*this); iterateAndNextNull(nodep->strgp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -140,8 +140,8 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->filep()->iterateAndNext(*this); iterateAndNextNull(nodep->filep());
nodep->exprsp()->iterateAndNext(*this); iterateAndNextNull(nodep->exprsp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -149,25 +149,25 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->exprsp()->iterateAndNext(*this); iterateAndNextNull(nodep->exprsp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
virtual void visit(AstSysIgnore* nodep) { virtual void visit(AstSysIgnore* nodep) {
// Can't know if lvalue or not; presume so as stricter // Can't know if lvalue or not; presume so as stricter
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
virtual void visit(AstReadMem* nodep) { virtual void visit(AstReadMem* nodep) {
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->memp()->iterateAndNext(*this); iterateAndNextNull(nodep->memp());
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->filenamep()->iterateAndNext(*this); iterateAndNextNull(nodep->filenamep());
nodep->lsbp()->iterateAndNext(*this); iterateAndNextNull(nodep->lsbp());
nodep->msbp()->iterateAndNext(*this); iterateAndNextNull(nodep->msbp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -175,9 +175,9 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->searchp()->iterateAndNext(*this); iterateAndNextNull(nodep->searchp());
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->outp()->iterateAndNext(*this); iterateAndNextNull(nodep->outp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -185,9 +185,9 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
m_setRefLvalue = true; m_setRefLvalue = true;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->fmtp()->iterateAndNext(*this); iterateAndNextNull(nodep->fmtp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -196,20 +196,20 @@ private:
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ {
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
// Only set lvalues on the from // Only set lvalues on the from
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
nodep->thsp()->iterateAndNext(*this); iterateAndNextNull(nodep->thsp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
virtual void visit(AstNodeSel* nodep) { virtual void visit(AstNodeSel* nodep) {
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ // Only set lvalues on the from { // Only set lvalues on the from
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
@ -217,23 +217,23 @@ private:
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ // selp is not an lvalue { // selp is not an lvalue
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->selp()->iterateAndNext(*this); iterateAndNextNull(nodep->selp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
virtual void visit(AstNodePreSel* nodep) { virtual void visit(AstNodePreSel* nodep) {
bool last_setRefLvalue = m_setRefLvalue; bool last_setRefLvalue = m_setRefLvalue;
{ // Only set lvalues on the from { // Only set lvalues on the from
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_setRefLvalue = false; m_setRefLvalue = false;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
nodep->thsp()->iterateAndNext(*this); iterateAndNextNull(nodep->thsp());
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
m_ftaskp = nodep; m_ftaskp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ftaskp = NULL; m_ftaskp = NULL;
} }
virtual void visit(AstNodeFTaskRef* nodep) { virtual void visit(AstNodeFTaskRef* nodep) {
@ -245,10 +245,10 @@ private:
if (const AstVar* portp = VN_CAST(stmtp, Var)) { if (const AstVar* portp = VN_CAST(stmtp, Var)) {
if (portp->isIO()) { if (portp->isIO()) {
if (portp->isInput()) { if (portp->isInput()) {
pinp->iterate(*this); iterate(pinp);
} else { // Output or Inout } else { // Output or Inout
m_setRefLvalue = true; m_setRefLvalue = true;
pinp->iterate(*this); iterate(pinp);
m_setRefLvalue = false; m_setRefLvalue = false;
} }
// Advance pin // Advance pin
@ -260,7 +260,7 @@ private:
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -268,7 +268,7 @@ public:
LinkLValueVisitor(AstNode* nodep, bool start) { LinkLValueVisitor(AstNode* nodep, bool start) {
m_setRefLvalue = start; m_setRefLvalue = start;
m_ftaskp = NULL; m_ftaskp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~LinkLValueVisitor() {} virtual ~LinkLValueVisitor() {}
}; };

View File

@ -91,7 +91,7 @@ private:
if (!nodep->user1SetOnce()) { // Process only once. if (!nodep->user1SetOnce()) { // Process only once.
cleanFileline(nodep); cleanFileline(nodep);
m_ftaskp = nodep; m_ftaskp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ftaskp = NULL; m_ftaskp = NULL;
} }
} }
@ -101,7 +101,7 @@ private:
UINFO(5," "<<nodep<<endl); UINFO(5," "<<nodep<<endl);
AstNodeModule* upperValueModp = m_valueModp; AstNodeModule* upperValueModp = m_valueModp;
m_valueModp = NULL; m_valueModp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_valueModp = upperValueModp; m_valueModp = upperValueModp;
} }
} }
@ -110,14 +110,14 @@ private:
cleanFileline(nodep); cleanFileline(nodep);
AstNodeDType* upperDtypep = m_dtypep; AstNodeDType* upperDtypep = m_dtypep;
m_dtypep = nodep; m_dtypep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_dtypep = upperDtypep; m_dtypep = upperDtypep;
} }
} }
virtual void visit(AstEnumItem* nodep) { virtual void visit(AstEnumItem* nodep) {
// Expand ranges // Expand ranges
cleanFileline(nodep); cleanFileline(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->rangep()) { if (nodep->rangep()) {
if (!VN_IS(nodep->rangep()->msbp(), Const) if (!VN_IS(nodep->rangep()->msbp(), Const)
|| !VN_IS(nodep->rangep()->lsbp(), Const)) nodep->v3error("Enum ranges must be integral, per spec"); || !VN_IS(nodep->rangep()->lsbp(), Const)) nodep->v3error("Enum ranges must be integral, per spec");
@ -166,7 +166,7 @@ private:
nodep->trace(false); nodep->trace(false);
} }
m_varp = nodep; m_varp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_varp = NULL; m_varp = NULL;
// temporaries under an always aren't expected to be blocking // temporaries under an always aren't expected to be blocking
if (m_inAlways) nodep->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true); if (m_inAlways) nodep->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true);
@ -202,7 +202,7 @@ private:
virtual void visit(AstAttrOf* nodep) { virtual void visit(AstAttrOf* nodep) {
cleanFileline(nodep); cleanFileline(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->attrType() == AstAttrType::DT_PUBLIC) { if (nodep->attrType() == AstAttrType::DT_PUBLIC) {
AstTypedef* typep = VN_CAST(nodep->backp(), Typedef); AstTypedef* typep = VN_CAST(nodep->backp(), Typedef);
if (!typep) nodep->v3fatalSrc("Attribute not attached to typedef"); if (!typep) nodep->v3fatalSrc("Attribute not attached to typedef");
@ -270,7 +270,7 @@ private:
// AlwaysPublic was attached under a var, but it's a statement that should be // AlwaysPublic was attached under a var, but it's a statement that should be
// at the same level as the var // at the same level as the var
cleanFileline(nodep); cleanFileline(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_varp) { if (m_varp) {
nodep->unlinkFrBack(); nodep->unlinkFrBack();
m_varp->addNext(nodep); m_varp->addNext(nodep);
@ -383,7 +383,7 @@ private:
// //
m_modp = nodep; m_modp = nodep;
m_valueModp = nodep; m_valueModp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
m_valueModp = NULL; m_valueModp = NULL;
} }
@ -393,7 +393,7 @@ private:
// //
AstNodeModule* upperValueModp = m_valueModp; AstNodeModule* upperValueModp = m_valueModp;
m_valueModp = NULL; m_valueModp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_valueModp = upperValueModp; m_valueModp = upperValueModp;
} }
virtual void visit(AstInitial* nodep) { virtual void visit(AstInitial* nodep) {
@ -414,7 +414,7 @@ private:
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
cleanFileline(nodep); cleanFileline(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -428,7 +428,7 @@ public:
m_inGenerate = false; m_inGenerate = false;
m_needStart = false; m_needStart = false;
m_valueModp = NULL; m_valueModp = NULL;
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkParseVisitor() {} virtual ~LinkParseVisitor() {}
}; };

View File

@ -76,11 +76,11 @@ private:
if (nodep->dead()) return; if (nodep->dead()) return;
m_modp = nodep; m_modp = nodep;
m_senitemCvtNum = 0; m_senitemCvtNum = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstInitial* nodep) { virtual void visit(AstInitial* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Initial assignments under function/tasks can just be simple assignments without the initial // Initial assignments under function/tasks can just be simple assignments without the initial
if (m_ftaskp) { if (m_ftaskp) {
nodep->replaceWith(nodep->bodysp()->unlinkFrBackWithNext()); VL_DANGLING(nodep); nodep->replaceWith(nodep->bodysp()->unlinkFrBackWithNext()); VL_DANGLING(nodep);
@ -89,12 +89,12 @@ private:
virtual void visit(AstVAssert* nodep) { virtual void visit(AstVAssert* nodep) {
if (m_assertp) nodep->v3error("Assert not allowed under another assert"); if (m_assertp) nodep->v3error("Assert not allowed under another assert");
m_assertp = nodep; m_assertp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_assertp = NULL; m_assertp = NULL;
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_ftaskp) nodep->funcLocal(true); if (m_ftaskp) nodep->funcLocal(true);
if (nodep->isSigModPublic()) { if (nodep->isSigModPublic()) {
nodep->sigModPublic(false); // We're done with this attribute nodep->sigModPublic(false); // We're done with this attribute
@ -107,21 +107,21 @@ private:
if (nodep->varp()) { if (nodep->varp()) {
nodep->varp()->usedParam(true); nodep->varp()->usedParam(true);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
// NodeTask: Remember its name for later resolution // NodeTask: Remember its name for later resolution
// Remember the existing symbol table scope // Remember the existing symbol table scope
m_ftaskp = nodep; m_ftaskp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ftaskp = NULL; m_ftaskp = NULL;
if (nodep->dpiExport()) { if (nodep->dpiExport()) {
nodep->scopeNamep(new AstScopeName(nodep->fileline())); nodep->scopeNamep(new AstScopeName(nodep->fileline()));
} }
} }
virtual void visit(AstNodeFTaskRef* nodep) { virtual void visit(AstNodeFTaskRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->taskp() && (nodep->taskp()->dpiContext() || nodep->taskp()->dpiExport())) { if (nodep->taskp() && (nodep->taskp()->dpiContext() || nodep->taskp()->dpiExport())) {
nodep->scopeNamep(new AstScopeName(nodep->fileline())); nodep->scopeNamep(new AstScopeName(nodep->fileline()));
} }
@ -129,7 +129,7 @@ private:
virtual void visit(AstSenItem* nodep) { virtual void visit(AstSenItem* nodep) {
// Remove bit selects, and bark if it's not a simple variable // Remove bit selects, and bark if it's not a simple variable
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isClocked()) { if (nodep->isClocked()) {
// If it's not a simple variable wrap in a temporary // If it's not a simple variable wrap in a temporary
// This is a bit unfortunate as we haven't done width resolution // This is a bit unfortunate as we haven't done width resolution
@ -197,7 +197,7 @@ private:
virtual void visit(AstNodePreSel* nodep) { virtual void visit(AstNodePreSel* nodep) {
if (!nodep->attrp()) { if (!nodep->attrp()) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Constification may change the fromp() to a constant, which will lose the // Constification may change the fromp() to a constant, which will lose the
// variable we're extracting from (to determine MSB/LSB/endianness/etc.) // variable we're extracting from (to determine MSB/LSB/endianness/etc.)
// So we replicate it in another node // So we replicate it in another node
@ -225,7 +225,7 @@ private:
virtual void visit(AstCaseItem* nodep) { virtual void visit(AstCaseItem* nodep) {
// Move default caseItems to the bottom of the list // Move default caseItems to the bottom of the list
// That saves us from having to search each case list twice, for non-defaults and defaults // That saves us from having to search each case list twice, for non-defaults and defaults
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->user2() && nodep->isDefault() && nodep->nextp()) { if (!nodep->user2() && nodep->isDefault() && nodep->nextp()) {
nodep->user2(true); nodep->user2(true);
AstNode* nextp = nodep->nextp(); AstNode* nextp = nodep->nextp();
@ -252,7 +252,7 @@ private:
} }
} }
else { else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
@ -356,27 +356,27 @@ private:
} }
virtual void visit(AstFOpen* nodep) { virtual void visit(AstFOpen* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef));
} }
virtual void visit(AstFClose* nodep) { virtual void visit(AstFClose* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef));
} }
virtual void visit(AstFEof* nodep) { virtual void visit(AstFEof* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef));
} }
virtual void visit(AstFScanF* nodep) { virtual void visit(AstFScanF* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
expectFormat(nodep, nodep->text(), nodep->exprsp(), true); expectFormat(nodep, nodep->text(), nodep->exprsp(), true);
} }
virtual void visit(AstSScanF* nodep) { virtual void visit(AstSScanF* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
expectFormat(nodep, nodep->text(), nodep->exprsp(), true); expectFormat(nodep, nodep->text(), nodep->exprsp(), true);
} }
virtual void visit(AstSFormatF* nodep) { virtual void visit(AstSFormatF* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Cleanup old-school displays without format arguments // Cleanup old-school displays without format arguments
if (!nodep->hasFormat()) { if (!nodep->hasFormat()) {
if (nodep->text()!="") nodep->v3fatalSrc("Non-format $sformatf should have \"\" format"); if (nodep->text()!="") nodep->v3fatalSrc("Non-format $sformatf should have \"\" format");
@ -397,7 +397,7 @@ private:
} }
} }
virtual void visit(AstDisplay* nodep) { virtual void visit(AstDisplay* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstUdpTable* nodep) { virtual void visit(AstUdpTable* nodep) {
@ -430,22 +430,22 @@ private:
virtual void visit(AstScCtor* nodep) { virtual void visit(AstScCtor* nodep) {
// Constructor info means the module must remain public // Constructor info means the module must remain public
m_modp->modPublic(true); m_modp->modPublic(true);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstScDtor* nodep) { virtual void visit(AstScDtor* nodep) {
// Destructor info means the module must remain public // Destructor info means the module must remain public
m_modp->modPublic(true); m_modp->modPublic(true);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstScInt* nodep) { virtual void visit(AstScInt* nodep) {
// Special class info means the module must remain public // Special class info means the module must remain public
m_modp->modPublic(true); m_modp->modPublic(true);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -456,7 +456,7 @@ public:
m_assertp = NULL; m_assertp = NULL;
m_senitemCvtNum = 0; m_senitemCvtNum = 0;
// //
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkResolveVisitor() {} virtual ~LinkResolveVisitor() {}
}; };
@ -481,11 +481,11 @@ private:
// VISITs // VISITs
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Iterate modules backwards, in bottom-up order. // Iterate modules backwards, in bottom-up order.
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
@ -498,14 +498,14 @@ private:
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit LinkBotupVisitor(AstNetlist* rootp) { explicit LinkBotupVisitor(AstNetlist* rootp) {
m_modp = NULL; m_modp = NULL;
// //
rootp->accept(*this); iterate(rootp);
} }
virtual ~LinkBotupVisitor() {} virtual ~LinkBotupVisitor() {}
}; };

View File

@ -90,12 +90,12 @@ private:
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit LocalizeDehierVisitor(AstNetlist* nodep) { explicit LocalizeDehierVisitor(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~LocalizeDehierVisitor() {} virtual ~LocalizeDehierVisitor() {}
}; };
@ -157,7 +157,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
moveVars(); moveVars();
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
@ -167,7 +167,7 @@ private:
searchFuncStmts(nodep->initsp()); searchFuncStmts(nodep->initsp());
searchFuncStmts(nodep->stmtsp()); searchFuncStmts(nodep->stmtsp());
searchFuncStmts(nodep->finalsp()); searchFuncStmts(nodep->finalsp());
nodep->iterateChildren(*this); iterateChildren(nodep);
m_cfuncp = NULL; m_cfuncp = NULL;
} }
void searchFuncStmts(AstNode* nodep) { void searchFuncStmts(AstNode* nodep) {
@ -230,13 +230,13 @@ private:
// No iterate; Don't want varrefs under it // No iterate; Don't want varrefs under it
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit LocalizeVisitor(AstNetlist* nodep) { explicit LocalizeVisitor(AstNetlist* nodep) {
m_cfuncp = NULL; m_cfuncp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~LocalizeVisitor() { virtual ~LocalizeVisitor() {
V3Stats::addStat("Optimizations, Vars localized", m_statLocVars); V3Stats::addStat("Optimizations, Vars localized", m_statLocVars);

View File

@ -78,7 +78,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
// Add __PVT__ to names of local signals // Add __PVT__ to names of local signals
@ -91,54 +91,54 @@ private:
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
if (!nodep->user1()) { if (!nodep->user1()) {
nodep->iterateChildren(*this); iterateChildren(nodep);
rename(nodep, false); rename(nodep, false);
} }
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
if (nodep->varp()) { if (nodep->varp()) {
nodep->varp()->iterate(*this); iterate(nodep->varp());
nodep->name(nodep->varp()->name()); nodep->name(nodep->varp()->name());
} }
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
if (!nodep->user1()) { if (!nodep->user1()) {
rename(nodep, !nodep->modp()->modPublic()); rename(nodep, !nodep->modp()->modPublic());
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstMemberDType* nodep) { virtual void visit(AstMemberDType* nodep) {
if (!nodep->user1()) { if (!nodep->user1()) {
rename(nodep, false); rename(nodep, false);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstMemberSel* nodep) { virtual void visit(AstMemberSel* nodep) {
if (!nodep->user1()) { if (!nodep->user1()) {
rename(nodep, false); rename(nodep, false);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
if (!nodep->user1SetOnce()) { if (!nodep->user1SetOnce()) {
if (nodep->aboveScopep()) nodep->aboveScopep()->iterate(*this); if (nodep->aboveScopep()) iterate(nodep->aboveScopep());
if (nodep->aboveCellp()) nodep->aboveCellp()->iterate(*this); if (nodep->aboveCellp()) iterate(nodep->aboveCellp());
// Always recompute name (as many level above scope may have changed) // Always recompute name (as many level above scope may have changed)
// Same formula as V3Scope // Same formula as V3Scope
nodep->name(nodep->isTop() ? "TOP" nodep->name(nodep->isTop() ? "TOP"
: (nodep->aboveScopep()->name()+"."+nodep->aboveCellp()->name())); : (nodep->aboveScopep()->name()+"."+nodep->aboveCellp()->name()));
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit NameVisitor(AstNetlist* nodep) { explicit NameVisitor(AstNetlist* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~NameVisitor() {} virtual ~NameVisitor() {}
}; };

View File

@ -284,7 +284,7 @@ private:
} else { } else {
m_inAss = true; m_inAss = true;
m_childClkWidth = 0; m_childClkWidth = 0;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
m_rightClkWidth = m_childClkWidth; m_rightClkWidth = m_childClkWidth;
m_inAss = false; m_inAss = false;
} }
@ -320,29 +320,29 @@ private:
} }
virtual void visit(AstConcat* nodep) { virtual void visit(AstConcat* nodep) {
if (m_inAss) { if (m_inAss) {
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
int lw = m_childClkWidth; int lw = m_childClkWidth;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
int rw = m_childClkWidth; int rw = m_childClkWidth;
m_childClkWidth = lw + rw; // Pass up m_childClkWidth = lw + rw; // Pass up
} }
} }
virtual void visit(AstNodeSel* nodep) { virtual void visit(AstNodeSel* nodep) {
if (m_inAss) { if (m_inAss) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Pass up result width // Pass up result width
if (m_childClkWidth > nodep->width()) m_childClkWidth = nodep->width(); if (m_childClkWidth > nodep->width()) m_childClkWidth = nodep->width();
} }
} }
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
if (m_inAss) { if (m_inAss) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_childClkWidth > nodep->width()) m_childClkWidth = nodep->width(); if (m_childClkWidth > nodep->width()) m_childClkWidth = nodep->width();
} }
} }
virtual void visit(AstReplicate* nodep) { virtual void visit(AstReplicate* nodep) {
if (m_inAss) { if (m_inAss) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (VN_IS(nodep->rhsp(), Const)) { if (VN_IS(nodep->rhsp(), Const)) {
m_childClkWidth = m_childClkWidth * VN_CAST(nodep->rhsp(), Const)->toUInt(); m_childClkWidth = m_childClkWidth * VN_CAST(nodep->rhsp(), Const)->toUInt();
} else { } else {
@ -352,11 +352,11 @@ private:
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
m_inClocked = nodep->hasClocked(); m_inClocked = nodep->hasClocked();
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inClocked = false; m_inClocked = false;
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -369,7 +369,7 @@ public:
m_rightClkWidth = 0; m_rightClkWidth = 0;
do { do {
m_newClkMarked = false; m_newClkMarked = false;
nodep->accept(*this); iterate(nodep);
} while (m_newClkMarked); } while (m_newClkMarked);
} }
virtual ~OrderClkMarkVisitor() {} virtual ~OrderClkMarkVisitor() {}
@ -394,7 +394,7 @@ private:
m_clkAss = true; m_clkAss = true;
UINFO(6, "node was marked as clocker "<<varrefp<<endl); UINFO(6, "node was marked as clocker "<<varrefp<<endl);
} }
nodep->rhsp()->iterateChildren(*this); iterateChildren(nodep->rhsp());
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
if (nodep->varp()->attrClocker() == AstVarAttrClocker::CLOCKER_YES) { if (nodep->varp()->attrClocker() == AstVarAttrClocker::CLOCKER_YES) {
@ -403,14 +403,14 @@ private:
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit OrderClkAssVisitor(AstNode* nodep) { explicit OrderClkAssVisitor(AstNode* nodep) {
m_clkAss = false; m_clkAss = false;
nodep->accept(*this); iterate(nodep);
} }
virtual ~OrderClkAssVisitor() {} virtual ~OrderClkAssVisitor() {}
@ -502,7 +502,7 @@ private:
new OrderEdge(&m_graph, m_activeSenVxp, m_logicVxp, WEIGHT_NORMAL); new OrderEdge(&m_graph, m_activeSenVxp, m_logicVxp, WEIGHT_NORMAL);
} }
nodep->user1p(m_modp); nodep->user1p(m_modp);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_logicVxp = NULL; m_logicVxp = NULL;
} }
} }
@ -695,7 +695,7 @@ private:
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
{ {
AstUser4InUse m_inuser4; // Used only when building tree, so below AstUser4InUse m_inuser4; // Used only when building tree, so below
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// We're finished, complete the topscopes // We're finished, complete the topscopes
if (m_topScopep) { process(); m_topScopep=NULL; } if (m_topScopep) { process(); m_topScopep=NULL; }
@ -732,7 +732,7 @@ private:
m_activeSenVxp = NULL; m_activeSenVxp = NULL;
m_inputsVxp = new OrderInputsVertex(&m_graph, NULL); m_inputsVxp = new OrderInputsVertex(&m_graph, NULL);
// //
nodep->iterateChildren(*this); iterateChildren(nodep);
// Done topscope, erase extra user information // Done topscope, erase extra user information
// user1p passed to next process() operation // user1p passed to next process() operation
AstNode::user3ClearTree(); AstNode::user3ClearTree();
@ -740,7 +740,7 @@ private:
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
@ -750,7 +750,7 @@ private:
m_activeSenVxp = NULL; m_activeSenVxp = NULL;
nodep->user1p(m_modp); nodep->user1p(m_modp);
// Iterate // Iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
m_scopep = NULL; m_scopep = NULL;
} }
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
@ -761,9 +761,9 @@ private:
m_inClocked = nodep->hasClocked(); m_inClocked = nodep->hasClocked();
// Grab the sensitivity list // Grab the sensitivity list
if (nodep->sensesStorep()) nodep->v3fatalSrc("Senses should have been activeTop'ed to be global!"); if (nodep->sensesStorep()) nodep->v3fatalSrc("Senses should have been activeTop'ed to be global!");
nodep->sensesp()->accept(*this); iterate(nodep->sensesp());
// Collect statements under it // Collect statements under it
nodep->iterateChildren(*this); iterateChildren(nodep);
m_activep = NULL; m_activep = NULL;
} }
virtual void visit(AstVarScope* nodep) { virtual void visit(AstVarScope* nodep) {
@ -906,7 +906,7 @@ private:
if (!m_activeSenVxp) { if (!m_activeSenVxp) {
m_activeSenVxp = new OrderLogicVertex(&m_graph, m_scopep, nodep, m_activep); m_activeSenVxp = new OrderLogicVertex(&m_graph, m_scopep, nodep, m_activep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_inSenTree = false; m_inSenTree = false;
} }
@ -964,7 +964,7 @@ private:
//-------------------- //--------------------
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -1004,7 +1004,7 @@ public:
m_graph.debug(V3Error::debugDefault()); m_graph.debug(V3Error::debugDefault());
} }
void main(AstNode* nodep) { void main(AstNode* nodep) {
nodep->accept(*this); iterate(nodep);
} }
}; };

View File

@ -222,7 +222,7 @@ private:
if (!nodep->user5SetOnce()) { // 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
m_modp = nodep; m_modp = nodep;
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
// Note above iterate may add to m_todoModps // Note above iterate may add to m_todoModps
// //
// Process interface cells, then non-interface which may ref an interface cell // Process interface cells, then non-interface which may ref an interface cell
@ -244,7 +244,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
// Modules must be done in top-down-order // Modules must be done in top-down-order
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
if (nodep->dead()) { if (nodep->dead()) {
@ -271,7 +271,7 @@ private:
// Make sure all parameters are constantified // Make sure all parameters are constantified
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
if (!nodep->user5SetOnce()) { // Process once if (!nodep->user5SetOnce()) { // Process once
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->isParam()) { if (nodep->isParam()) {
if (!nodep->valuep()) { nodep->v3fatalSrc("Parameter without initial value"); } if (!nodep->valuep()) { nodep->v3fatalSrc("Parameter without initial value"); }
V3Const::constifyParamsEdit(nodep); // The variable, not just the var->init() V3Const::constifyParamsEdit(nodep); // The variable, not just the var->init()
@ -288,7 +288,7 @@ private:
} }
// Make sure varrefs cause vars to constify before things above // Make sure varrefs cause vars to constify before things above
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
if (nodep->varp()) nodep->varp()->iterate(*this); if (nodep->varp()) iterate(nodep->varp());
} }
bool ifaceParamReplace(AstVarXRef* nodep, AstNode* candp) { bool ifaceParamReplace(AstVarXRef* nodep, AstNode* candp) {
for (; candp; candp = candp->nextp()) { for (; candp; candp = candp->nextp()) {
@ -357,7 +357,7 @@ private:
nodep->v3fatalSrc("Unexpected AstUnlinkedRef node"); nodep->v3fatalSrc("Unexpected AstUnlinkedRef node");
return; return;
} }
nodep->cellrefp()->iterate(*this); iterate(nodep->cellrefp());
if (varxrefp) { if (varxrefp) {
varxrefp->dotted(m_unlinkedTxt); varxrefp->dotted(m_unlinkedTxt);
@ -387,7 +387,7 @@ private:
// Generate Statements // Generate Statements
virtual void visit(AstGenerate* nodep) { virtual void visit(AstGenerate* nodep) {
if (debug()>=9) nodep->dumpTree(cout,"-genin: "); if (debug()>=9) nodep->dumpTree(cout,"-genin: ");
nodep->iterateChildren(*this); iterateChildren(nodep);
// After expanding the generate, all statements under it can be moved // After expanding the generate, all statements under it can be moved
// up, and the generate block deleted as it's not relevant // up, and the generate block deleted as it's not relevant
if (AstNode* stmtsp = nodep->stmtsp()) { if (AstNode* stmtsp = nodep->stmtsp()) {
@ -401,7 +401,7 @@ private:
} }
virtual void visit(AstGenIf* nodep) { virtual void visit(AstGenIf* nodep) {
UINFO(9," GENIF "<<nodep<<endl); UINFO(9," GENIF "<<nodep<<endl);
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
// We suppress errors when widthing params since short-circuiting in // We suppress errors when widthing params since short-circuiting in
// the conditional evaluation may mean these error can never occur. We // the conditional evaluation may mean these error can never occur. We
// then make sure that short-circuiting is used by constifyParamsEdit. // then make sure that short-circuiting is used by constifyParamsEdit.
@ -454,7 +454,7 @@ private:
// Note this clears nodep->genforp(), so begin is no longer special // Note this clears nodep->genforp(), so begin is no longer special
} }
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstGenFor* nodep) { virtual void visit(AstGenFor* nodep) {
@ -463,7 +463,7 @@ private:
virtual void visit(AstGenCase* nodep) { virtual void visit(AstGenCase* nodep) {
UINFO(9," GENCASE "<<nodep<<endl); UINFO(9," GENCASE "<<nodep<<endl);
AstNode* keepp = NULL; AstNode* keepp = NULL;
nodep->exprp()->iterateAndNext(*this); iterateAndNextNull(nodep->exprp());
V3Case::caseLint(nodep); V3Case::caseLint(nodep);
V3Width::widthParamsEdit(nodep); // Param typed widthing will NOT recurse the body, V3Width::widthParamsEdit(nodep); // Param typed widthing will NOT recurse the body,
// don't trigger errors yet. // don't trigger errors yet.
@ -473,7 +473,7 @@ private:
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) { for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) {
for (AstNode* ep = itemp->condsp(); ep; ) { for (AstNode* ep = itemp->condsp(); ep; ) {
AstNode* nextp = ep->nextp(); //May edit list AstNode* nextp = ep->nextp(); //May edit list
ep->iterateAndNext(*this); iterateAndNextNull(ep);
V3Const::constifyParamsEdit(ep); VL_DANGLING(ep); // ep may change V3Const::constifyParamsEdit(ep); VL_DANGLING(ep); // ep may change
ep = nextp; ep = nextp;
} }
@ -511,7 +511,7 @@ private:
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -520,7 +520,7 @@ public:
m_longId = 0; m_longId = 0;
m_modp = NULL; m_modp = NULL;
// //
nodep->accept(*this); iterate(nodep);
} }
virtual ~ParamVisitor() {} virtual ~ParamVisitor() {}
}; };
@ -530,7 +530,7 @@ public:
void ParamVisitor::visitCell(AstCell* nodep) { void ParamVisitor::visitCell(AstCell* nodep) {
// Cell: Check for parameters in the instantiation. // Cell: Check for parameters in the instantiation.
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->modp()) nodep->v3fatalSrc("Not linked?"); if (!nodep->modp()) nodep->v3fatalSrc("Not linked?");
// We always run this, even if no parameters, as need to look for interfaces, // We always run this, even if no parameters, as need to look for interfaces,
// and remove any recursive references // and remove any recursive references

View File

@ -64,9 +64,9 @@ private:
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
//AstNode::user4ClearTree(); // Implied by AstUser4InUse //AstNode::user4ClearTree(); // Implied by AstUser4InUse
// LHS first as fewer varrefs // LHS first as fewer varrefs
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
// Now find vars marked as lhs // Now find vars marked as lhs
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
// it's LHS var is used so need a deep temporary // it's LHS var is used so need a deep temporary
@ -80,7 +80,7 @@ private:
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -88,7 +88,7 @@ public:
explicit PremitAssignVisitor(AstNodeAssign* nodep) { explicit PremitAssignVisitor(AstNodeAssign* nodep) {
UINFO(4," PremitAssignVisitor on "<<nodep<<endl); UINFO(4," PremitAssignVisitor on "<<nodep<<endl);
m_noopt = false; m_noopt = false;
nodep->accept(*this); iterate(nodep);
} }
virtual ~PremitAssignVisitor() {} virtual ~PremitAssignVisitor() {}
bool noOpt() const { return m_noopt; } bool noOpt() const { return m_noopt; }
@ -209,12 +209,12 @@ private:
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
m_modp = nodep; m_modp = nodep;
m_funcp = NULL; m_funcp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
m_funcp = nodep; m_funcp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_funcp = NULL; m_funcp = NULL;
} }
void startStatement(AstNode* nodep) { void startStatement(AstNode* nodep) {
@ -224,14 +224,14 @@ private:
virtual void visit(AstWhile* nodep) { virtual void visit(AstWhile* nodep) {
UINFO(4," WHILE "<<nodep<<endl); UINFO(4," WHILE "<<nodep<<endl);
startStatement(nodep); startStatement(nodep);
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
startStatement(nodep); startStatement(nodep);
m_inWhilep = nodep; m_inWhilep = nodep;
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
m_inWhilep = NULL; m_inWhilep = NULL;
startStatement(nodep); startStatement(nodep);
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
m_stmtp = NULL; m_stmtp = NULL;
} }
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
@ -244,22 +244,22 @@ private:
createDeepTemp(nodep->rhsp(), false); createDeepTemp(nodep->rhsp(), false);
} }
} }
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
m_assignLhs = true; m_assignLhs = true;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_assignLhs = false; m_assignLhs = false;
m_stmtp = NULL; m_stmtp = NULL;
} }
virtual void visit(AstNodeStmt* nodep) { virtual void visit(AstNodeStmt* nodep) {
UINFO(4," STMT "<<nodep<<endl); UINFO(4," STMT "<<nodep<<endl);
startStatement(nodep); startStatement(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_stmtp = NULL; m_stmtp = NULL;
} }
virtual void visit(AstTraceInc* nodep) { virtual void visit(AstTraceInc* nodep) {
startStatement(nodep); startStatement(nodep);
m_inTracep = nodep; m_inTracep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inTracep = NULL; m_inTracep = NULL;
m_stmtp = NULL; m_stmtp = NULL;
} }
@ -308,7 +308,7 @@ private:
replaceHandle.relink(newp); replaceHandle.relink(newp);
} }
} }
nodep->iterateChildren(*this); checkNode(nodep); iterateChildren(nodep); checkNode(nodep);
} }
virtual void visit(AstShiftL* nodep) { virtual void visit(AstShiftL* nodep) {
visitShift(nodep); visitShift(nodep);
@ -321,43 +321,43 @@ private:
} }
// Operators // Operators
virtual void visit(AstNodeTermop* nodep) { virtual void visit(AstNodeTermop* nodep) {
nodep->iterateChildren(*this); checkNode(nodep); iterateChildren(nodep); checkNode(nodep);
} }
virtual void visit(AstNodeUniop* nodep) { virtual void visit(AstNodeUniop* nodep) {
nodep->iterateChildren(*this); checkNode(nodep); iterateChildren(nodep); checkNode(nodep);
} }
virtual void visit(AstNodeBiop* nodep) { virtual void visit(AstNodeBiop* nodep) {
nodep->iterateChildren(*this); checkNode(nodep); iterateChildren(nodep); checkNode(nodep);
} }
virtual void visit(AstUCFunc* nodep) { virtual void visit(AstUCFunc* nodep) {
nodep->iterateChildren(*this); checkNode(nodep); iterateChildren(nodep); checkNode(nodep);
} }
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
nodep->fromp()->iterateAndNext(*this); iterateAndNextNull(nodep->fromp());
{ // Only the 'from' is part of the assignment LHS { // Only the 'from' is part of the assignment LHS
bool prevAssign = m_assignLhs; bool prevAssign = m_assignLhs;
m_assignLhs = false; m_assignLhs = false;
nodep->lsbp()->iterateAndNext(*this); iterateAndNextNull(nodep->lsbp());
nodep->widthp()->iterateAndNext(*this); iterateAndNextNull(nodep->widthp());
m_assignLhs = prevAssign; m_assignLhs = prevAssign;
} }
checkNode(nodep); checkNode(nodep);
} }
virtual void visit(AstArraySel* nodep) { virtual void visit(AstArraySel* nodep) {
nodep->fromp()->iterateAndNext(*this); iterateAndNextNull(nodep->fromp());
{ // Only the 'from' is part of the assignment LHS { // Only the 'from' is part of the assignment LHS
bool prevAssign = m_assignLhs; bool prevAssign = m_assignLhs;
m_assignLhs = false; m_assignLhs = false;
nodep->bitp()->iterateAndNext(*this); iterateAndNextNull(nodep->bitp());
m_assignLhs = prevAssign; m_assignLhs = prevAssign;
} }
checkNode(nodep); checkNode(nodep);
} }
virtual void visit(AstConst* nodep) { virtual void visit(AstConst* nodep) {
nodep->iterateChildren(*this); checkNode(nodep); iterateChildren(nodep); checkNode(nodep);
} }
virtual void visit(AstNodeCond* nodep) { virtual void visit(AstNodeCond* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->expr1p()->isWide() if (nodep->expr1p()->isWide()
&& !VN_IS(nodep->condp(), Const) && !VN_IS(nodep->condp(), Const)
&& !VN_IS(nodep->condp(), VarRef)) { && !VN_IS(nodep->condp(), VarRef)) {
@ -371,7 +371,7 @@ private:
// Autoflush // Autoflush
virtual void visit(AstDisplay* nodep) { virtual void visit(AstDisplay* nodep) {
startStatement(nodep); startStatement(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_stmtp = NULL; m_stmtp = NULL;
if (v3Global.opt.autoflush()) { if (v3Global.opt.autoflush()) {
AstNode* searchp = nodep->nextp(); AstNode* searchp = nodep->nextp();
@ -388,7 +388,7 @@ private:
} }
} }
virtual void visit(AstSFormatF* nodep) { virtual void visit(AstSFormatF* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Any strings sent to a display must be var of string data type, // Any strings sent to a display must be var of string data type,
// to avoid passing a pointer to a temporary. // to avoid passing a pointer to a temporary.
for (AstNode* expp=nodep->exprsp(); expp; expp = expp->nextp()) { for (AstNode* expp=nodep->exprsp(); expp; expp = expp->nextp()) {
@ -403,7 +403,7 @@ private:
// Default: Just iterate // Default: Just iterate
virtual void visit(AstVar* nodep) {} // Don't hit varrefs under vars virtual void visit(AstVar* nodep) {} // Don't hit varrefs under vars
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -414,7 +414,7 @@ public:
m_stmtp = NULL; m_stmtp = NULL;
m_inWhilep = NULL; m_inWhilep = NULL;
m_inTracep = NULL; m_inTracep = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~PremitVisitor() {} virtual ~PremitVisitor() {}
}; };

View File

@ -99,7 +99,7 @@ private:
// Operate starting at the top of the hierarchy // Operate starting at the top of the hierarchy
m_aboveCellp = NULL; m_aboveCellp = NULL;
m_aboveScopep = NULL; m_aboveScopep = NULL;
modp->accept(*this); iterate(modp);
cleanupVarRefs(); cleanupVarRefs();
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
@ -126,7 +126,7 @@ private:
m_aboveScopep = m_scopep; m_aboveScopep = m_scopep;
AstNodeModule* modp = cellp->modp(); AstNodeModule* modp = cellp->modp();
if (!modp) cellp->v3fatalSrc("Unlinked mod"); if (!modp) cellp->v3fatalSrc("Unlinked mod");
modp->accept(*this); // Recursive call to visit(AstNodeModule) iterate(modp); // Recursive call to visit(AstNodeModule)
} }
// Done, restore vars // Done, restore vars
m_scopep = oldScopep; m_scopep = oldScopep;
@ -148,7 +148,7 @@ private:
// Copy blocks into this scope // Copy blocks into this scope
// If this is the first usage of the block ever, we can simply move the reference // If this is the first usage of the block ever, we can simply move the reference
nodep->iterateChildren(*this); iterateChildren(nodep);
// ***Note m_scopep is passed back to the caller of the routine (above) // ***Note m_scopep is passed back to the caller of the routine (above)
} }
@ -161,7 +161,7 @@ private:
AstInitial* clonep = nodep->cloneTree(false); AstInitial* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstFinal* nodep) { virtual void visit(AstFinal* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -169,7 +169,7 @@ private:
AstFinal* clonep = nodep->cloneTree(false); AstFinal* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstAssignAlias* nodep) { virtual void visit(AstAssignAlias* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -177,7 +177,7 @@ private:
AstNode* clonep = nodep->cloneTree(false); AstNode* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstAssignVarScope* nodep) { virtual void visit(AstAssignVarScope* nodep) {
// Copy under the scope but don't recurse // Copy under the scope but don't recurse
@ -185,7 +185,7 @@ private:
AstNode* clonep = nodep->cloneTree(false); AstNode* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstAssignW* nodep) { virtual void visit(AstAssignW* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -193,7 +193,7 @@ private:
AstNode* clonep = nodep->cloneTree(false); AstNode* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstAlways* nodep) { virtual void visit(AstAlways* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -201,7 +201,7 @@ private:
AstNode* clonep = nodep->cloneTree(false); AstNode* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstAlwaysPublic* nodep) { virtual void visit(AstAlwaysPublic* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -209,7 +209,7 @@ private:
AstNode* clonep = nodep->cloneTree(false); AstNode* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstCoverToggle* nodep) { virtual void visit(AstCoverToggle* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -217,7 +217,7 @@ private:
AstNode* clonep = nodep->cloneTree(false); AstNode* clonep = nodep->cloneTree(false);
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* iterateChildren(clonep); // We iterate under the *clone*
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -227,7 +227,7 @@ private:
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->scopep(m_scopep); clonep->scopep(m_scopep);
// We iterate under the *clone* // We iterate under the *clone*
clonep->iterateChildren(*this); iterateChildren(clonep);
} }
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
@ -236,7 +236,7 @@ private:
nodep->user2p(clonep); nodep->user2p(clonep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
// We iterate under the *clone* // We iterate under the *clone*
clonep->iterateChildren(*this); iterateChildren(clonep);
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
// Make new scope variable // Make new scope variable
@ -284,7 +284,7 @@ private:
if (afterp) afterp->unlinkFrBackWithNext(); if (afterp) afterp->unlinkFrBackWithNext();
nodep->scopeEntrp(new AstText(nodep->fileline(), prefix)); nodep->scopeEntrp(new AstText(nodep->fileline(), prefix));
if (afterp) nodep->scopeEntrp(afterp); if (afterp) nodep->scopeEntrp(afterp);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
// Scope that was made by this module for different cell; // Scope that was made by this module for different cell;
@ -293,7 +293,7 @@ private:
//-------------------- //--------------------
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -303,7 +303,7 @@ public:
m_modp = NULL; m_modp = NULL;
m_scopep = NULL; m_scopep = NULL;
// //
nodep->accept(*this); iterate(nodep);
} }
virtual ~ScopeVisitor() {} virtual ~ScopeVisitor() {}
}; };
@ -327,14 +327,14 @@ private:
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
// Want to ignore blocks under it // Want to ignore blocks under it
m_scopep = nodep; m_scopep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_scopep = NULL; m_scopep = NULL;
} }
virtual void movedDeleteOrIterate(AstNode* nodep) { virtual void movedDeleteOrIterate(AstNode* nodep) {
if (m_scopep) { if (m_scopep) {
// The new block; repair varrefs // The new block; repair varrefs
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
// A block that was just moved under a scope, Kill it. // A block that was just moved under a scope, Kill it.
// Certain nodes can be referenced later in this pass, notably // Certain nodes can be referenced later in this pass, notably
@ -392,24 +392,24 @@ private:
nodep->taskp(NULL); nodep->taskp(NULL);
UINFO(9," New pkg-taskref "<<nodep<<endl); UINFO(9," New pkg-taskref "<<nodep<<endl);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstModportFTaskRef* nodep) { virtual void visit(AstModportFTaskRef* nodep) {
// The crossrefs are dealt with in V3LinkDot // The crossrefs are dealt with in V3LinkDot
nodep->ftaskp(NULL); nodep->ftaskp(NULL);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//-------------------- //--------------------
// Default // Default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit ScopeCleanupVisitor(AstNetlist* nodep) { explicit ScopeCleanupVisitor(AstNetlist* nodep) {
m_scopep = NULL; m_scopep = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~ScopeCleanupVisitor() {} virtual ~ScopeCleanupVisitor() {}
}; };

View File

@ -65,12 +65,12 @@ private:
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
// Only do the top // Only do the top
if (nodep->isTop()) { if (nodep->isTop()) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
m_topscopep = nodep; m_topscopep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
// Don't clear topscopep, the namer persists beyond this visit // Don't clear topscopep, the namer persists beyond this visit
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
@ -79,7 +79,7 @@ private:
// Memorize existing block names // Memorize existing block names
virtual void visit(AstActive* nodep) { virtual void visit(AstActive* nodep) {
// Don't grab SenTrees under Actives, only those that are global (under Scope directly) // Don't grab SenTrees under Actives, only those that are global (under Scope directly)
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSenTree* nodep) { virtual void visit(AstSenTree* nodep) {
m_treesp.push_back(nodep); m_treesp.push_back(nodep);
@ -87,7 +87,7 @@ private:
// Empty visitors, speed things up // Empty visitors, speed things up
virtual void visit(AstNodeStmt* nodep) { } virtual void visit(AstNodeStmt* nodep) { }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
// METHODS // METHODS
public: public:
@ -129,7 +129,7 @@ public:
} }
virtual ~SenTreeFinder() {} virtual ~SenTreeFinder() {}
void main(AstTopScope* nodep) { void main(AstTopScope* nodep) {
nodep->accept(*this); iterate(nodep);
} }
}; };

View File

@ -327,7 +327,7 @@ private:
virtual void visit(AstAlways* nodep) { virtual void visit(AstAlways* nodep) {
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSenTree* nodep) { virtual void visit(AstSenTree* nodep) {
// Sensitivities aren't inputs per se; we'll keep our tree under the same sens. // Sensitivities aren't inputs per se; we'll keep our tree under the same sens.
@ -335,7 +335,8 @@ private:
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
nodep->varp()->iterateChildren(*this); if (!nodep->varp()) nodep->v3fatalSrc("Unlinked");
iterateChildren(nodep->varp());
AstNode* vscp = varOrScope(nodep); AstNode* vscp = varOrScope(nodep);
// We can't have non-delayed assignments with same value on LHS and RHS // We can't have non-delayed assignments with same value on LHS and RHS
@ -401,21 +402,21 @@ private:
if (!m_params) { badNodeType(nodep); return; } if (!m_params) { badNodeType(nodep); return; }
if (nodep->dpiImport()) { clearOptimizable(nodep,"DPI import functions aren't simulatable"); } if (nodep->dpiImport()) { clearOptimizable(nodep,"DPI import functions aren't simulatable"); }
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
UINFO(5," IF "<<nodep<<endl); UINFO(5," IF "<<nodep<<endl);
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
if (optimizable()) { if (optimizable()) {
if (fetchNumber(nodep->condp())->isNeqZero()) { if (fetchNumber(nodep->condp())->isNeqZero()) {
nodep->ifsp()->iterateAndNext(*this); iterateAndNextNull(nodep->ifsp());
} else { } else {
nodep->elsesp()->iterateAndNext(*this); iterateAndNextNull(nodep->elsesp());
} }
} }
} }
@ -432,7 +433,7 @@ private:
if (!m_checkOnly && optimizable()) { if (!m_checkOnly && optimizable()) {
AstNode* valuep = nodep->itemp()->valuep(); AstNode* valuep = nodep->itemp()->valuep();
if (valuep) { if (valuep) {
valuep->iterateAndNext(*this); iterateAndNextNull(valuep);
if (optimizable()) { if (optimizable()) {
newNumber(nodep)->opAssign(*fetchNumber(valuep)); newNumber(nodep)->opAssign(*fetchNumber(valuep));
} }
@ -444,7 +445,7 @@ private:
virtual void visit(AstNodeUniop* nodep) { virtual void visit(AstNodeUniop* nodep) {
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!m_checkOnly && optimizable()) { if (!m_checkOnly && optimizable()) {
nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp())); nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp()));
} }
@ -452,7 +453,7 @@ private:
virtual void visit(AstNodeBiop* nodep) { virtual void visit(AstNodeBiop* nodep) {
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!m_checkOnly && optimizable()) { if (!m_checkOnly && optimizable()) {
nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp()), *fetchNumber(nodep->rhsp())); nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp()), *fetchNumber(nodep->rhsp()));
} }
@ -460,7 +461,7 @@ private:
virtual void visit(AstNodeTriop* nodep) { virtual void visit(AstNodeTriop* nodep) {
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!m_checkOnly && optimizable()) { if (!m_checkOnly && optimizable()) {
nodep->numberOperate(*newNumber(nodep), nodep->numberOperate(*newNumber(nodep),
*fetchNumber(nodep->lhsp()), *fetchNumber(nodep->lhsp()),
@ -473,12 +474,12 @@ private:
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->lhsp()->accept(*this); iterate(nodep->lhsp());
if (optimizable()) { if (optimizable()) {
if (fetchNumber(nodep->lhsp())->isNeqZero()) { if (fetchNumber(nodep->lhsp())->isNeqZero()) {
nodep->rhsp()->accept(*this); iterate(nodep->rhsp());
newNumber(nodep)->opAssign(*fetchNumber(nodep->rhsp())); newNumber(nodep)->opAssign(*fetchNumber(nodep->rhsp()));
} else { } else {
newNumber(nodep)->opAssign(*fetchNumber(nodep->lhsp())); // a zero newNumber(nodep)->opAssign(*fetchNumber(nodep->lhsp())); // a zero
@ -491,14 +492,14 @@ private:
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->lhsp()->accept(*this); iterate(nodep->lhsp());
if (optimizable()) { if (optimizable()) {
if (fetchNumber(nodep->lhsp())->isNeqZero()) { if (fetchNumber(nodep->lhsp())->isNeqZero()) {
newNumber(nodep)->opAssign(*fetchNumber(nodep->lhsp())); // a one newNumber(nodep)->opAssign(*fetchNumber(nodep->lhsp())); // a one
} else { } else {
nodep->rhsp()->accept(*this); iterate(nodep->rhsp());
newNumber(nodep)->opAssign(*fetchNumber(nodep->rhsp())); newNumber(nodep)->opAssign(*fetchNumber(nodep->rhsp()));
} }
} }
@ -509,14 +510,14 @@ private:
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->lhsp()->accept(*this); iterate(nodep->lhsp());
if (optimizable()) { if (optimizable()) {
if (fetchNumber(nodep->lhsp())->isEqZero()) { if (fetchNumber(nodep->lhsp())->isEqZero()) {
newNumber(nodep)->opAssign(V3Number(nodep->fileline(), 1, 1)); // a one newNumber(nodep)->opAssign(V3Number(nodep->fileline(), 1, 1)); // a one
} else { } else {
nodep->rhsp()->accept(*this); iterate(nodep->rhsp());
newNumber(nodep)->opAssign(*fetchNumber(nodep->rhsp())); newNumber(nodep)->opAssign(*fetchNumber(nodep->rhsp()));
} }
} }
@ -528,15 +529,15 @@ private:
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->condp()->accept(*this); iterate(nodep->condp());
if (optimizable()) { if (optimizable()) {
if (fetchNumber(nodep->condp())->isNeqZero()) { if (fetchNumber(nodep->condp())->isNeqZero()) {
nodep->expr1p()->accept(*this); iterate(nodep->expr1p());
newNumber(nodep)->opAssign(*fetchNumber(nodep->expr1p())); newNumber(nodep)->opAssign(*fetchNumber(nodep->expr1p()));
} else { } else {
nodep->expr2p()->accept(*this); iterate(nodep->expr2p());
newNumber(nodep)->opAssign(*fetchNumber(nodep->expr2p())); newNumber(nodep)->opAssign(*fetchNumber(nodep->expr2p()));
} }
} }
@ -546,7 +547,7 @@ private:
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) { void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
AstVarRef* varrefp = NULL; AstVarRef* varrefp = NULL;
V3Number lsb = V3Number(nodep->fileline()); V3Number lsb = V3Number(nodep->fileline());
nodep->rhsp()->iterateAndNext(*this); // Value to assign iterateAndNextNull(nodep->rhsp()); // Value to assign
handleAssignSelRecurse(nodep, selp, varrefp/*ref*/, lsb/*ref*/, 0); handleAssignSelRecurse(nodep, selp, varrefp/*ref*/, lsb/*ref*/, 0);
if (!m_checkOnly && optimizable()) { if (!m_checkOnly && optimizable()) {
if (!varrefp) nodep->v3fatalSrc("Indicated optimizable, but no variable found on RHS of select"); if (!varrefp) nodep->v3fatalSrc("Indicated optimizable, but no variable found on RHS of select");
@ -575,7 +576,7 @@ private:
int depth) { int depth) {
// Recurse down to find final variable being set (outVarrefp), with value to write on nodep->rhsp() // Recurse down to find final variable being set (outVarrefp), with value to write on nodep->rhsp()
checkNodeInfo(selp); checkNodeInfo(selp);
selp->lsbp()->iterateAndNext(*this); // Bit index iterateAndNextNull(selp->lsbp()); // Bit index
if (AstVarRef* varrefp = VN_CAST(selp->fromp(), VarRef)) { if (AstVarRef* varrefp = VN_CAST(selp->fromp(), VarRef)) {
outVarrefpRef = varrefp; outVarrefpRef = varrefp;
lsbRef = *fetchNumber(selp->lsbp()); lsbRef = *fetchNumber(selp->lsbp());
@ -612,10 +613,10 @@ private:
clearOptimizable(nodep, "LHS isn't simple variable"); clearOptimizable(nodep, "LHS isn't simple variable");
} }
else if (m_checkOnly) { else if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
else if (optimizable()) { else if (optimizable()) {
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
if (optimizable()) { if (optimizable()) {
AstNode* vscp = varOrScope(VN_CAST(nodep->lhsp(), VarRef)); AstNode* vscp = varOrScope(VN_CAST(nodep->lhsp(), VarRef));
assignOutNumber(nodep, vscp, fetchNumber(nodep->rhsp())); assignOutNumber(nodep, vscp, fetchNumber(nodep->rhsp()));
@ -625,27 +626,27 @@ private:
} }
virtual void visit(AstBegin* nodep) { virtual void visit(AstBegin* nodep) {
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeCase* nodep) { virtual void visit(AstNodeCase* nodep) {
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
UINFO(5," CASE "<<nodep<<endl); UINFO(5," CASE "<<nodep<<endl);
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else if (optimizable()) { } else if (optimizable()) {
nodep->exprp()->iterateAndNext(*this); iterateAndNextNull(nodep->exprp());
bool hit = false; bool hit = false;
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) { for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) {
if (!itemp->isDefault()) { if (!itemp->isDefault()) {
for (AstNode* ep = itemp->condsp(); ep; ep=ep->nextp()) { for (AstNode* ep = itemp->condsp(); ep; ep=ep->nextp()) {
if (hit) break; if (hit) break;
ep->iterateAndNext(*this); iterateAndNextNull(ep);
if (optimizable()) { if (optimizable()) {
V3Number match (nodep->fileline(), 1); V3Number match (nodep->fileline(), 1);
match.opEq(*fetchNumber(nodep->exprp()), *fetchNumber(ep)); match.opEq(*fetchNumber(nodep->exprp()), *fetchNumber(ep));
if (match.isNeqZero()) { if (match.isNeqZero()) {
itemp->bodysp()->iterateAndNext(*this); iterateAndNextNull(itemp->bodysp());
hit = true; hit = true;
} }
} }
@ -656,7 +657,7 @@ private:
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) { for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) {
if (hit) break; if (hit) break;
if (!hit && itemp->isDefault()) { if (!hit && itemp->isDefault()) {
itemp->bodysp()->iterateAndNext(*this); iterateAndNextNull(itemp->bodysp());
hit = true; hit = true;
} }
} }
@ -667,7 +668,7 @@ private:
// Real handling is in AstNodeCase // Real handling is in AstNodeCase
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstComment*) {} virtual void visit(AstComment*) {}
@ -683,7 +684,7 @@ private:
virtual void visit(AstJumpLabel* nodep) { virtual void visit(AstJumpLabel* nodep) {
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
checkNodeInfo(nodep); checkNodeInfo(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_jumpp && m_jumpp->labelp() == nodep) { if (m_jumpp && m_jumpp->labelp() == nodep) {
UINFO(5," JUMP DONE "<<nodep<<endl); UINFO(5," JUMP DONE "<<nodep<<endl);
m_jumpp = NULL; m_jumpp = NULL;
@ -704,19 +705,19 @@ private:
if (!m_params) { badNodeType(nodep); return; } if (!m_params) { badNodeType(nodep); return; }
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else if (optimizable()) { } else if (optimizable()) {
int loops = 0; int loops = 0;
nodep->initsp()->iterateAndNext(*this); iterateAndNextNull(nodep->initsp());
while (1) { while (1) {
UINFO(5," FOR-ITER "<<nodep<<endl); UINFO(5," FOR-ITER "<<nodep<<endl);
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
if (!optimizable()) break; if (!optimizable()) break;
if (!fetchNumber(nodep->condp())->isNeqZero()) { if (!fetchNumber(nodep->condp())->isNeqZero()) {
break; break;
} }
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
if (loops++ > unrollCount()*16) { if (loops++ > unrollCount()*16) {
clearOptimizable(nodep, "Loop unrolling took too long; probably this is an" clearOptimizable(nodep, "Loop unrolling took too long; probably this is an"
"infinite loop, or set --unroll-count above " "infinite loop, or set --unroll-count above "
@ -734,22 +735,22 @@ private:
if (!m_params) { badNodeType(nodep); return; } if (!m_params) { badNodeType(nodep); return; }
checkNodeInfo(nodep); checkNodeInfo(nodep);
if (m_checkOnly) { if (m_checkOnly) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else if (optimizable()) { } else if (optimizable()) {
int loops = 0; int loops = 0;
while (1) { while (1) {
UINFO(5," WHILE-ITER "<<nodep<<endl); UINFO(5," WHILE-ITER "<<nodep<<endl);
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
if (jumpingOver(nodep)) break; if (jumpingOver(nodep)) break;
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
if (jumpingOver(nodep)) break; if (jumpingOver(nodep)) break;
if (!optimizable()) break; if (!optimizable()) break;
if (!fetchNumber(nodep->condp())->isNeqZero()) { if (!fetchNumber(nodep->condp())->isNeqZero()) {
break; break;
} }
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
if (jumpingOver(nodep)) break; if (jumpingOver(nodep)) break;
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
if (jumpingOver(nodep)) break; if (jumpingOver(nodep)) break;
// Prep for next loop // Prep for next loop
@ -783,7 +784,7 @@ private:
return; return;
} }
// Evaluate pin value // Evaluate pin value
pinp->accept(*this); iterate(pinp);
} }
} }
for (V3TaskConnects::iterator it=tconnects.begin(); it!=tconnects.end(); ++it) { for (V3TaskConnects::iterator it=tconnects.begin(); it!=tconnects.end(); ++it) {
@ -799,7 +800,7 @@ private:
SimulateStackNode stackNode(nodep, &tconnects); SimulateStackNode stackNode(nodep, &tconnects);
m_callStack.push_front(&stackNode); m_callStack.push_front(&stackNode);
// Evaluate the function // Evaluate the function
funcp->accept(*this); iterate(funcp);
m_callStack.pop_front(); m_callStack.pop_front();
if (!m_checkOnly && optimizable()) { if (!m_checkOnly && optimizable()) {
// Grab return value from output variable (if it's a function) // Grab return value from output variable (if it's a function)
@ -822,7 +823,7 @@ private:
virtual void visit(AstSFormatF *nodep) { virtual void visit(AstSFormatF *nodep) {
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_params) { if (m_params) {
AstNode* nextArgp = nodep->exprsp(); AstNode* nextArgp = nodep->exprsp();
@ -875,7 +876,7 @@ private:
virtual void visit(AstDisplay *nodep) { virtual void visit(AstDisplay *nodep) {
if (jumpingOver(nodep)) return; if (jumpingOver(nodep)) return;
if (!optimizable()) return; // Accelerate if (!optimizable()) return; // Accelerate
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_params) { if (m_params) {
V3Number* textp = fetchNumber(nodep->fmtp()); V3Number* textp = fetchNumber(nodep->fmtp());
switch (nodep->displayType()) { switch (nodep->displayType()) {
@ -916,7 +917,7 @@ private:
m_params = params; m_params = params;
} }
void mainGuts(AstNode* nodep) { void mainGuts(AstNode* nodep) {
nodep->accept(*this); iterate(nodep);
if (m_jumpp) { if (m_jumpp) {
m_jumpp->v3fatalSrc("JumpGo branched to label that wasn't found"); m_jumpp->v3fatalSrc("JumpGo branched to label that wasn't found");
m_jumpp = NULL; m_jumpp = NULL;

View File

@ -156,7 +156,7 @@ class SliceVisitor : public AstNVisitor {
return; return;
} }
m_assignp = nodep; m_assignp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_assignp = NULL; m_assignp = NULL;
} }
} }
@ -208,7 +208,7 @@ class SliceVisitor : public AstNVisitor {
pushDeletep(nodep); VL_DANGLING(nodep); pushDeletep(nodep); VL_DANGLING(nodep);
nodep = logp; nodep = logp;
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstEq* nodep) { virtual void visit(AstEq* nodep) {
@ -226,7 +226,7 @@ class SliceVisitor : public AstNVisitor {
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
// Default: Just iterate // Default: Just iterate
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -234,7 +234,7 @@ public:
explicit SliceVisitor(AstNetlist* rootp) { explicit SliceVisitor(AstNetlist* rootp) {
m_assignp = NULL; m_assignp = NULL;
m_assignError = false; m_assignError = false;
rootp->accept(*this); iterate(rootp);
} }
virtual ~SliceVisitor() {} virtual ~SliceVisitor() {}
}; };

View File

@ -328,7 +328,7 @@ protected:
// Iterate across current block, making the scoreboard // Iterate across current block, making the scoreboard
for (AstNode* nextp=nodep; nextp; nextp=nextp->nextp()) { for (AstNode* nextp=nodep; nextp; nextp=nextp->nextp()) {
scoreboardPushStmt(nextp); scoreboardPushStmt(nextp);
nextp->accept(*this); iterate(nextp);
scoreboardPopStmt(); scoreboardPopStmt();
} }
} }
@ -364,7 +364,7 @@ protected:
virtual void visit(AstAssignDly* nodep) { virtual void visit(AstAssignDly* nodep) {
m_inDly = true; m_inDly = true;
UINFO(4," ASSIGNDLY "<<nodep<<endl); UINFO(4," ASSIGNDLY "<<nodep<<endl);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inDly = false; m_inDly = false;
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
@ -434,7 +434,7 @@ protected:
// in always, so the performance gain probably isn't worth the work. // in always, so the performance gain probably isn't worth the work.
UINFO(9," NoReordering "<<nodep<<endl); UINFO(9," NoReordering "<<nodep<<endl);
m_noReorderWhy = "JumpGo"; m_noReorderWhy = "JumpGo";
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//-------------------- //--------------------
@ -445,7 +445,7 @@ protected:
UINFO(9," NotSplittable "<<nodep<<endl); UINFO(9," NotSplittable "<<nodep<<endl);
scoreboardPli(nodep); scoreboardPli(nodep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
private: private:
@ -457,7 +457,7 @@ class ReorderVisitor : public SplitReorderBaseVisitor {
public: public:
explicit ReorderVisitor(AstNetlist* nodep) explicit ReorderVisitor(AstNetlist* nodep)
: SplitReorderBaseVisitor() { : SplitReorderBaseVisitor() {
nodep->accept(*this); iterate(nodep);
} }
virtual ~ReorderVisitor() {} virtual ~ReorderVisitor() {}
@ -585,7 +585,7 @@ protected:
// Process it // Process it
if (!nodep->nextp()) { if (!nodep->nextp()) {
// Just one, so can't reorder. Just look for more blocks/statements. // Just one, so can't reorder. Just look for more blocks/statements.
nodep->accept(*this); iterate(nodep);
} else { } else {
UINFO(9," processBlock "<<nodep<<endl); UINFO(9," processBlock "<<nodep<<endl);
// Process block and followers // Process block and followers
@ -618,7 +618,7 @@ protected:
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
UINFO(4," IF "<<nodep<<endl); UINFO(4," IF "<<nodep<<endl);
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
processBlock(nodep->ifsp()); processBlock(nodep->ifsp());
processBlock(nodep->elsesp()); processBlock(nodep->elsesp());
} }
@ -645,7 +645,7 @@ public:
// Visit through *nodep and map each AstNodeIf within to the set of // Visit through *nodep and map each AstNodeIf within to the set of
// colors it will participate in. Also find the whole set of colors. // colors it will participate in. Also find the whole set of colors.
explicit IfColorVisitor(AstAlways* nodep) { explicit IfColorVisitor(AstAlways* nodep) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~IfColorVisitor() {} virtual ~IfColorVisitor() {}
@ -660,7 +660,7 @@ public:
protected: protected:
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
m_ifStack.push_back(nodep); m_ifStack.push_back(nodep);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_ifStack.pop_back(); m_ifStack.pop_back();
} }
@ -677,7 +677,7 @@ protected:
m_ifColors[*it].insert(color); m_ifColors[*it].insert(color);
} }
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
static int debug() { static int debug() {
@ -737,7 +737,7 @@ public:
// Scan the body of the always. We'll handle if/else // Scan the body of the always. We'll handle if/else
// specially, everything else is a leaf node that we can // specially, everything else is a leaf node that we can
// just clone into one of the split always blocks. // just clone into one of the split always blocks.
m_origAlwaysp->bodysp()->iterateAndNext(*this); iterateAndNextNull(m_origAlwaysp->bodysp());
} }
protected: protected:
@ -803,14 +803,14 @@ protected:
m_addAfter[*color] = if_placeholderp; m_addAfter[*color] = if_placeholderp;
} }
nodep->ifsp()->iterateAndNext(*this); iterateAndNextNull(nodep->ifsp());
for (ColorSet::const_iterator color = colors.begin(); for (ColorSet::const_iterator color = colors.begin();
color != colors.end(); ++color) { color != colors.end(); ++color) {
m_addAfter[*color] = clones[*color]->elsesp(); m_addAfter[*color] = clones[*color]->elsesp();
} }
nodep->elsesp()->iterateAndNext(*this); iterateAndNextNull(nodep->elsesp());
for (ColorSet::const_iterator color = colors.begin(); for (ColorSet::const_iterator color = colors.begin();
color != colors.end(); ++color) { color != colors.end(); ++color) {
@ -827,7 +827,7 @@ class RemovePlaceholdersVisitor : public AstNVisitor {
NodeSet m_removeSet; // placeholders to be removed NodeSet m_removeSet; // placeholders to be removed
public: public:
explicit RemovePlaceholdersVisitor(AstNode* nodep) { explicit RemovePlaceholdersVisitor(AstNode* nodep) {
nodep->accept(*this); iterate(nodep);
for (NodeSet::const_iterator it = m_removeSet.begin(); for (NodeSet::const_iterator it = m_removeSet.begin();
it != m_removeSet.end(); ++it) { it != m_removeSet.end(); ++it) {
AstNode* np = *it; AstNode* np = *it;
@ -837,7 +837,7 @@ public:
} }
virtual ~RemovePlaceholdersVisitor() {} virtual ~RemovePlaceholdersVisitor() {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSplitPlaceholder* nodep) { virtual void visit(AstSplitPlaceholder* nodep) {
m_removeSet.insert(nodep); m_removeSet.insert(nodep);
@ -862,7 +862,7 @@ public:
explicit SplitVisitor(AstNetlist* nodep) explicit SplitVisitor(AstNetlist* nodep)
: SplitReorderBaseVisitor() : SplitReorderBaseVisitor()
, m_curIfConditional(NULL) { , m_curIfConditional(NULL) {
nodep->accept(*this); iterate(nodep);
// Splice newly-split blocks into the tree. Remove placeholders // Splice newly-split blocks into the tree. Remove placeholders
// from newly-split blocks. Delete the original always blocks // from newly-split blocks. Delete the original always blocks
@ -1000,7 +1000,7 @@ protected:
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) {
UINFO(4," IF "<<nodep<<endl); UINFO(4," IF "<<nodep<<endl);
m_curIfConditional = nodep; m_curIfConditional = nodep;
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
m_curIfConditional = NULL; m_curIfConditional = NULL;
scanBlock(nodep->ifsp()); scanBlock(nodep->ifsp());
scanBlock(nodep->elsesp()); scanBlock(nodep->elsesp());

View File

@ -67,13 +67,13 @@ private:
} }
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit SplitAsFindVisitor(AstAlways* nodep) { explicit SplitAsFindVisitor(AstAlways* nodep) {
m_splitVscp = NULL; m_splitVscp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~SplitAsFindVisitor() {} virtual ~SplitAsFindVisitor() {}
// METHODS // METHODS
@ -107,7 +107,7 @@ private:
m_matches = false; m_matches = false;
m_keepStmt = false; m_keepStmt = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_keepStmt if (m_keepStmt
|| (m_modeMatch ? m_matches : !m_matches)) { || (m_modeMatch ? m_matches : !m_matches)) {
@ -123,14 +123,14 @@ private:
UINFO(9," upKeep="<<m_keepStmt<<" STMT "<<nodep<<endl); UINFO(9," upKeep="<<m_keepStmt<<" STMT "<<nodep<<endl);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
SplitAsCleanVisitor(AstAlways* nodep, AstVarScope* vscp, bool modeMatch) { SplitAsCleanVisitor(AstAlways* nodep, AstVarScope* vscp, bool modeMatch) {
m_splitVscp = vscp; m_splitVscp = vscp;
m_modeMatch = modeMatch; m_modeMatch = modeMatch;
nodep->accept(*this); iterate(nodep);
} }
virtual ~SplitAsCleanVisitor() {} virtual ~SplitAsCleanVisitor() {}
}; };
@ -195,7 +195,7 @@ private:
virtual void visit(AstNodeMath* nodep) {} virtual void visit(AstNodeMath* nodep) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -203,7 +203,7 @@ public:
explicit SplitAsVisitor(AstNetlist* nodep) { explicit SplitAsVisitor(AstNetlist* nodep) {
m_splitVscp = NULL; m_splitVscp = NULL;
AstNode::user1ClearTree(); // user1p() used on entire tree AstNode::user1ClearTree(); // user1p() used on entire tree
nodep->accept(*this); iterate(nodep);
} }
virtual ~SplitAsVisitor() { virtual ~SplitAsVisitor() {
V3Stats::addStat("Optimizations, isolate_assignments blocks", m_statSplits); V3Stats::addStat("Optimizations, isolate_assignments blocks", m_statSplits);

View File

@ -91,14 +91,14 @@ private:
allNodes(nodep); allNodes(nodep);
if (!m_fast) { if (!m_fast) {
// Count all CFuncs below this module // Count all CFuncs below this module
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
} }
// Else we recursively trace fast CFuncs from the top _eval // Else we recursively trace fast CFuncs from the top _eval
// func, see visit(AstNetlist*) // func, see visit(AstNetlist*)
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
allNodes(nodep); allNodes(nodep);
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
if (m_counting && nodep->dtypep()) { if (m_counting && nodep->dtypep()) {
if (nodep->isUsedClock()) ++m_statVarClock; if (nodep->isUsedClock()) ++m_statVarClock;
if (VN_IS(nodep->dtypeSkipRefp(), UnpackArrayDType)) ++m_statVarArray; if (VN_IS(nodep->dtypeSkipRefp(), UnpackArrayDType)) ++m_statVarArray;
@ -121,7 +121,7 @@ private:
} }
virtual void visit(AstVarScope* nodep) { virtual void visit(AstVarScope* nodep) {
allNodes(nodep); allNodes(nodep);
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
if (m_counting) { if (m_counting) {
if (VN_IS(nodep->varp()->dtypeSkipRefp(), BasicDType)) { if (VN_IS(nodep->varp()->dtypeSkipRefp(), BasicDType)) {
m_statVarScpBytes += nodep->varp()->dtypeSkipRefp()->widthTotalBytes(); m_statVarScpBytes += nodep->varp()->dtypeSkipRefp()->widthTotalBytes();
@ -132,14 +132,14 @@ private:
UINFO(4," IF i="<<m_instrs<<" "<<nodep<<endl); UINFO(4," IF i="<<m_instrs<<" "<<nodep<<endl);
allNodes(nodep); allNodes(nodep);
// Condition is part of cost allocated to PREVIOUS block // Condition is part of cost allocated to PREVIOUS block
nodep->condp()->iterateAndNextConst(*this); iterateAndNextConstNull(nodep->condp());
// Track prediction // Track prediction
if (m_counting) { if (m_counting) {
++m_statPred[nodep->branchPred()]; ++m_statPred[nodep->branchPred()];
} }
if (!m_fast) { if (!m_fast) {
// Count everything // Count everything
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
} else { } else {
// See which path we want to take // See which path we want to take
// Need to do even if !m_counting because maybe determining upstream if/else // Need to do even if !m_counting because maybe determining upstream if/else
@ -151,7 +151,7 @@ private:
{ {
m_counting = false; m_counting = false;
m_instrs = 0.0; m_instrs = 0.0;
nodep->ifsp()->iterateAndNextConst(*this); iterateAndNextConstNull(nodep->ifsp());
ifInstrs = m_instrs; ifInstrs = m_instrs;
} }
m_instrs = prevInstr; m_instrs = prevInstr;
@ -163,7 +163,7 @@ private:
{ {
m_counting = false; m_counting = false;
m_instrs = 0.0; m_instrs = 0.0;
nodep->elsesp()->iterateAndNextConst(*this); iterateAndNextConstNull(nodep->elsesp());
elseInstrs = m_instrs; elseInstrs = m_instrs;
} }
m_instrs = prevInstr; m_instrs = prevInstr;
@ -172,9 +172,9 @@ private:
// Now collect the stats // Now collect the stats
if (m_counting) { if (m_counting) {
if (ifInstrs >= elseInstrs) { if (ifInstrs >= elseInstrs) {
nodep->ifsp()->iterateAndNextConst(*this); iterateAndNextConstNull(nodep->ifsp());
} else { } else {
nodep->elsesp()->iterateAndNextConst(*this); iterateAndNextConstNull(nodep->elsesp());
} }
} }
} }
@ -184,11 +184,11 @@ private:
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
allNodes(nodep); allNodes(nodep);
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
if (m_fast && !nodep->funcp()->entryPoint()) { if (m_fast && !nodep->funcp()->entryPoint()) {
// Enter the function and trace it // Enter the function and trace it
m_tracingCall = true; m_tracingCall = true;
nodep->funcp()->accept(*this); iterate(nodep->funcp());
} }
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
@ -198,22 +198,22 @@ private:
} }
m_cfuncp = nodep; m_cfuncp = nodep;
allNodes(nodep); allNodes(nodep);
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
m_cfuncp = NULL; m_cfuncp = NULL;
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
allNodes(nodep); allNodes(nodep);
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
} }
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
if (m_fast && nodep->evalp()) { if (m_fast && nodep->evalp()) {
m_instrs = 0; m_instrs = 0;
m_counting = true; m_counting = true;
nodep->evalp()->iterateChildrenConst(*this); if (nodep->evalp()) iterateChildrenConst(nodep->evalp());
m_counting = false; m_counting = false;
} }
allNodes(nodep); allNodes(nodep);
nodep->iterateChildrenConst(*this); iterateChildrenConst(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -227,7 +227,7 @@ public:
// Initialize arrays // Initialize arrays
m_statTypeCount.resize(AstType::_ENUM_END); m_statTypeCount.resize(AstType::_ENUM_END);
// Process // Process
nodep->accept(*this); iterate(nodep);
} }
virtual ~StatsVisitor() { virtual ~StatsVisitor() {
// Done. Publish statistics // Done. Publish statistics

View File

@ -210,7 +210,7 @@ private:
} }
virtual void visit(AstConst* nodep) {} // Accelerate virtual void visit(AstConst* nodep) {} // Accelerate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -218,7 +218,7 @@ public:
UINFO(9, " SubstUseVisitor "<<origStep<<" "<<nodep<<endl); UINFO(9, " SubstUseVisitor "<<origStep<<" "<<nodep<<endl);
m_ok = true; m_ok = true;
m_origStep = origStep; m_origStep = origStep;
nodep->accept(*this); iterate(nodep);
} }
virtual ~SubstUseVisitor() {} virtual ~SubstUseVisitor() {}
// METHODS // METHODS
@ -266,7 +266,7 @@ private:
virtual void visit(AstNodeAssign* nodep) { virtual void visit(AstNodeAssign* nodep) {
m_ops = 0; m_ops = 0;
m_assignStep++; m_assignStep++;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
bool hit=false; bool hit=false;
if (AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef)) { if (AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef)) {
if (isSubstVar(varrefp->varp())) { if (isSubstVar(varrefp->varp())) {
@ -299,7 +299,7 @@ private:
} }
} }
if (!hit) { if (!hit) {
nodep->lhsp()->accept(*this); iterate(nodep->lhsp());
} }
} }
void replaceSubstEtc(AstNode* nodep, AstNode* substp) { void replaceSubstEtc(AstNode* nodep, AstNode* substp) {
@ -314,7 +314,7 @@ private:
++m_statSubsts; ++m_statSubsts;
} }
virtual void visit(AstWordSel* nodep) { virtual void visit(AstWordSel* nodep) {
nodep->rhsp()->accept(*this); iterate(nodep->rhsp());
AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef);
AstConst* constp = VN_CAST(nodep->rhsp(), Const); AstConst* constp = VN_CAST(nodep->rhsp(), Const);
if (varrefp && isSubstVar(varrefp->varp()) if (varrefp && isSubstVar(varrefp->varp())
@ -337,7 +337,7 @@ private:
entryp->consumeWord(word); entryp->consumeWord(word);
} }
} else { } else {
nodep->lhsp()->accept(*this); iterate(nodep->lhsp());
} }
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
@ -375,7 +375,7 @@ private:
if (!nodep->isSubstOptimizable()) { if (!nodep->isSubstOptimizable()) {
m_ops = SUBST_MAX_OPS_NA; m_ops = SUBST_MAX_OPS_NA;
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -384,7 +384,7 @@ public:
AstNode::user2ClearTree(); // user2p() used on entire tree AstNode::user2ClearTree(); // user2p() used on entire tree
m_ops = 0; m_ops = 0;
m_assignStep = 0; m_assignStep = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~SubstVisitor() { virtual ~SubstVisitor() {
V3Stats::addStat("Optimizations, Substituted temps", m_statSubsts); V3Stats::addStat("Optimizations, Substituted temps", m_statSubsts);

View File

@ -406,19 +406,19 @@ private:
// VISITORS // VISITORS
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
m_modTables = 0; m_modTables = 0;
m_modTableVscs.clear(); m_modTableVscs.clear();
m_modp = nodep; m_modp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
UINFO(4," SCOPE "<<nodep<<endl); UINFO(4," SCOPE "<<nodep<<endl);
m_scopep = nodep; m_scopep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_scopep = NULL; m_scopep = NULL;
} }
virtual void visit(AstAlways* nodep) { virtual void visit(AstAlways* nodep) {
@ -436,7 +436,7 @@ private:
} }
// default // default
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -448,7 +448,7 @@ public:
m_inWidth = 0; m_inWidth = 0;
m_outWidth = 0; m_outWidth = 0;
m_totalBytes = 0; m_totalBytes = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~TableVisitor() { virtual ~TableVisitor() {
V3Stats::addStat("Optimizations, Tables created", m_statTablesCre); V3Stats::addStat("Optimizations, Tables created", m_statTablesCre);

View File

@ -179,11 +179,11 @@ private:
taskp->user3p(nodep); taskp->user3p(nodep);
} }
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstAssignW* nodep) { virtual void visit(AstAssignW* nodep) {
m_assignwp = nodep; m_assignwp = nodep;
nodep->iterateChildren(*this); VL_DANGLING(nodep); // May delete nodep. iterateChildren(nodep); VL_DANGLING(nodep); // May delete nodep.
m_assignwp = NULL; m_assignwp = NULL;
} }
virtual void visit(AstNodeFTaskRef* nodep) { virtual void visit(AstNodeFTaskRef* nodep) {
@ -202,7 +202,7 @@ private:
TaskBaseVertex* lastVxp = m_curVxp; TaskBaseVertex* lastVxp = m_curVxp;
m_curVxp = getFTaskVertex(nodep); m_curVxp = getFTaskVertex(nodep);
if (nodep->dpiImport()) m_curVxp->noInline(true); if (nodep->dpiImport()) m_curVxp->noInline(true);
nodep->iterateChildren(*this); iterateChildren(nodep);
m_curVxp = lastVxp; m_curVxp = lastVxp;
} }
virtual void visit(AstPragma* nodep) { virtual void visit(AstPragma* nodep) {
@ -212,15 +212,15 @@ private:
nodep->unlinkFrBack()->deleteTree(); nodep->unlinkFrBack()->deleteTree();
} }
else { else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->user4p(m_curVxp); // Remember what task it's under nodep->user4p(m_curVxp); // Remember what task it's under
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->varp()->user4u().toGraphVertex() != m_curVxp) { if (nodep->varp()->user4u().toGraphVertex() != m_curVxp) {
if (m_curVxp->pure() if (m_curVxp->pure()
&& !nodep->varp()->isXTemp()) { && !nodep->varp()->isXTemp()) {
@ -231,7 +231,7 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -241,7 +241,7 @@ public:
AstNode::user3ClearTree(); AstNode::user3ClearTree();
AstNode::user4ClearTree(); AstNode::user4ClearTree();
// //
nodep->accept(*this); iterate(nodep);
// //
m_callGraph.removeRedundantEdgesSum(&TaskEdge::followAlwaysTrue); m_callGraph.removeRedundantEdgesSum(&TaskEdge::followAlwaysTrue);
m_callGraph.dumpDotFilePrefixed("task_call"); m_callGraph.dumpDotFilePrefixed("task_call");
@ -269,17 +269,17 @@ private:
nodep->varp(nodep->varScopep()->varp()); nodep->varp(nodep->varScopep()->varp());
nodep->name(nodep->varp()->name()); nodep->name(nodep->varp()->name());
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
explicit TaskRelinkVisitor(AstBegin* nodep) { // Passed temporary tree explicit TaskRelinkVisitor(AstBegin* nodep) { // Passed temporary tree
nodep->accept(*this); iterate(nodep);
} }
virtual ~TaskRelinkVisitor() {} virtual ~TaskRelinkVisitor() {}
}; };
@ -1076,7 +1076,7 @@ private:
InsertMode prevInsMode = m_insMode; InsertMode prevInsMode = m_insMode;
AstNode* prevInsStmtp = m_insStmtp; AstNode* prevInsStmtp = m_insStmtp;
m_scopep = m_statep->getScope(nodep); m_scopep = m_statep->getScope(nodep);
nodep->accept(*this); iterate(nodep);
m_scopep = oldscopep; m_scopep = oldscopep;
m_insMode = prevInsMode; m_insMode = prevInsMode;
m_insStmtp = prevInsStmtp; m_insStmtp = prevInsStmtp;
@ -1113,17 +1113,17 @@ private:
m_modp = nodep; m_modp = nodep;
m_insStmtp = NULL; m_insStmtp = NULL;
m_modNCalls = 0; m_modNCalls = 0;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
m_topScopep = nodep; m_topScopep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstScope* nodep) { virtual void visit(AstScope* nodep) {
m_scopep = nodep; m_scopep = nodep;
m_insStmtp = NULL; m_insStmtp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_scopep = NULL; m_scopep = NULL;
} }
virtual void visit(AstNodeFTaskRef* nodep) { virtual void visit(AstNodeFTaskRef* nodep) {
@ -1224,15 +1224,15 @@ private:
// Special, as statements need to be put in different places // Special, as statements need to be put in different places
// Preconditions insert first just before themselves (the normal rule for other statement types) // Preconditions insert first just before themselves (the normal rule for other statement types)
m_insStmtp = NULL; // First thing should be new statement m_insStmtp = NULL; // First thing should be new statement
nodep->precondsp()->iterateAndNext(*this); iterateAndNextNull(nodep->precondsp());
// Conditions insert first at end of precondsp. // Conditions insert first at end of precondsp.
m_insMode = IM_WHILE_PRECOND; m_insMode = IM_WHILE_PRECOND;
m_insStmtp = nodep; m_insStmtp = nodep;
nodep->condp()->iterateAndNext(*this); iterateAndNextNull(nodep->condp());
// Body insert just before themselves // Body insert just before themselves
m_insStmtp = NULL; // First thing should be new statement m_insStmtp = NULL; // First thing should be new statement
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
nodep->incsp()->iterateAndNext(*this); iterateAndNextNull(nodep->incsp());
// Done the loop // Done the loop
m_insStmtp = NULL; // Next thing should be new statement m_insStmtp = NULL; // Next thing should be new statement
} }
@ -1242,13 +1242,13 @@ private:
virtual void visit(AstNodeStmt* nodep) { virtual void visit(AstNodeStmt* nodep) {
m_insMode = IM_BEFORE; m_insMode = IM_BEFORE;
m_insStmtp = nodep; m_insStmtp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_insStmtp = NULL; // Next thing should be new statement m_insStmtp = NULL; // Next thing should be new statement
} }
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -1260,7 +1260,7 @@ public:
m_scopep = NULL; m_scopep = NULL;
m_insStmtp = NULL; m_insStmtp = NULL;
AstNode::user1ClearTree(); AstNode::user1ClearTree();
nodep->accept(*this); iterate(nodep);
} }
virtual ~TaskVisitor() {} virtual ~TaskVisitor() {}
}; };

View File

@ -569,11 +569,11 @@ private:
// Add vertexes for all TRACES, and edges from VARs each trace looks at // Add vertexes for all TRACES, and edges from VARs each trace looks at
m_finding = false; m_finding = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
// Add vertexes for all CFUNCs, and edges to VARs the func sets // Add vertexes for all CFUNCs, and edges to VARs the func sets
m_finding = true; m_finding = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_finding = false; m_finding = false;
// Detect and remove duplicate values // Detect and remove duplicate values
@ -590,13 +590,13 @@ private:
} }
virtual void visit(AstNodeModule* nodep) { virtual void visit(AstNodeModule* nodep) {
if (nodep->isTop()) m_topModp = nodep; if (nodep->isTop()) m_topModp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstTopScope* nodep) { virtual void visit(AstTopScope* nodep) {
AstScope* scopep = nodep->scopep(); AstScope* scopep = nodep->scopep();
if (!scopep) nodep->v3fatalSrc("No scope found on top level"); if (!scopep) nodep->v3fatalSrc("No scope found on top level");
m_highScopep = scopep; m_highScopep = scopep;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCCall* nodep) { virtual void visit(AstCCall* nodep) {
UINFO(8," CCALL "<<nodep<<endl); UINFO(8," CCALL "<<nodep<<endl);
@ -614,7 +614,7 @@ private:
} }
} }
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstCFunc* nodep) { virtual void visit(AstCFunc* nodep) {
UINFO(8," CFUNC "<<nodep<<endl); UINFO(8," CFUNC "<<nodep<<endl);
@ -636,7 +636,7 @@ private:
} }
} }
m_funcp = nodep; m_funcp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_funcp = NULL; m_funcp = NULL;
} }
virtual void visit(AstTraceInc* nodep) { virtual void visit(AstTraceInc* nodep) {
@ -649,7 +649,7 @@ private:
if (!m_funcp || (!m_chgFuncp || !m_fullFuncp)) nodep->v3fatalSrc("Trace not under func"); if (!m_funcp || (!m_chgFuncp || !m_fullFuncp)) nodep->v3fatalSrc("Trace not under func");
m_tracep = nodep; m_tracep = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_tracep = NULL; m_tracep = NULL;
} }
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) {
@ -679,7 +679,7 @@ private:
} }
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -701,7 +701,7 @@ public:
m_chgSubParentp = NULL; m_chgSubParentp = NULL;
m_chgSubStmts = 0; m_chgSubStmts = 0;
m_funcNum = 0; m_funcNum = 0;
nodep->accept(*this); iterate(nodep);
} }
virtual ~TraceVisitor() { virtual ~TraceVisitor() {
V3Stats::addStat("Tracing, Unique changing signals", m_statChgSigs); V3Stats::addStat("Tracing, Unique changing signals", m_statChgSigs);

View File

@ -146,10 +146,10 @@ private:
// //
m_initSubFuncp = newCFuncSub(m_initFuncp); m_initSubFuncp = newCFuncSub(m_initFuncp);
// And find variables // And find variables
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstVarScope* nodep) { virtual void visit(AstVarScope* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Avoid updating this if (), instead see varp->isTrace() // Avoid updating this if (), instead see varp->isTrace()
if (!nodep->varp()->isTemp() && !nodep->varp()->isFuncLocal()) { if (!nodep->varp()->isTemp() && !nodep->varp()->isFuncLocal()) {
UINFO(5, " vsc "<<nodep<<endl); UINFO(5, " vsc "<<nodep<<endl);
@ -172,7 +172,7 @@ private:
else m_traValuep = new AstVarRef(nodep->fileline(), nodep, false); else m_traValuep = new AstVarRef(nodep->fileline(), nodep, false);
{ {
// Recurse into data type of the signal; the visitors will call addTraceDecl() // Recurse into data type of the signal; the visitors will call addTraceDecl()
varp->dtypeSkipRefp()->accept(*this); iterate(varp->dtypeSkipRefp());
} }
// Cleanup // Cleanup
if (m_traValuep) { m_traValuep->deleteTree(); m_traValuep=NULL; } if (m_traValuep) { m_traValuep->deleteTree(); m_traValuep=NULL; }
@ -185,12 +185,12 @@ private:
// VISITORS - Data types when tracing // VISITORS - Data types when tracing
virtual void visit(AstConstDType* nodep) { virtual void visit(AstConstDType* nodep) {
if (m_traVscp) { if (m_traVscp) {
nodep->subDTypep()->skipRefp()->accept(*this); iterate(nodep->subDTypep()->skipRefp());
} }
} }
virtual void visit(AstRefDType* nodep) { virtual void visit(AstRefDType* nodep) {
if (m_traVscp) { if (m_traVscp) {
nodep->subDTypep()->skipRefp()->accept(*this); iterate(nodep->subDTypep()->skipRefp());
} }
} }
virtual void visit(AstUnpackArrayDType* nodep) { virtual void visit(AstUnpackArrayDType* nodep) {
@ -214,7 +214,7 @@ private:
m_traValuep = new AstArraySel(nodep->fileline(), m_traValuep->cloneTree(true), m_traValuep = new AstArraySel(nodep->fileline(), m_traValuep->cloneTree(true),
i - nodep->lsb()); i - nodep->lsb());
subtypep->accept(*this); iterate(subtypep);
m_traValuep->deleteTree(); m_traValuep = NULL; m_traValuep->deleteTree(); m_traValuep = NULL;
} }
m_traShowname = oldShowname; m_traShowname = oldShowname;
@ -239,7 +239,7 @@ private:
m_traValuep = new AstSel(nodep->fileline(), m_traValuep->cloneTree(true), m_traValuep = new AstSel(nodep->fileline(), m_traValuep->cloneTree(true),
(i - nodep->lsb())*subtypep->width(), (i - nodep->lsb())*subtypep->width(),
subtypep->width()); subtypep->width());
subtypep->accept(*this); iterate(subtypep);
m_traValuep->deleteTree(); m_traValuep = NULL; m_traValuep->deleteTree(); m_traValuep = NULL;
} }
m_traShowname = oldShowname; m_traShowname = oldShowname;
@ -267,10 +267,10 @@ private:
if (VN_IS(nodep, StructDType)) { if (VN_IS(nodep, StructDType)) {
m_traValuep = new AstSel(nodep->fileline(), m_traValuep->cloneTree(true), m_traValuep = new AstSel(nodep->fileline(), m_traValuep->cloneTree(true),
itemp->lsb(), subtypep->width()); itemp->lsb(), subtypep->width());
subtypep->accept(*this); iterate(subtypep);
m_traValuep->deleteTree(); m_traValuep = NULL; m_traValuep->deleteTree(); m_traValuep = NULL;
} else { // Else union, replicate fields } else { // Else union, replicate fields
subtypep->accept(*this); iterate(subtypep);
} }
} }
m_traShowname = oldShowname; m_traShowname = oldShowname;
@ -297,7 +297,7 @@ private:
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -312,7 +312,7 @@ public:
m_funcNum = 0; m_funcNum = 0;
m_traVscp = NULL; m_traVscp = NULL;
m_traValuep = NULL; m_traValuep = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~TraceDeclVisitor() { virtual ~TraceDeclVisitor() {
V3Stats::addStat("Tracing, Traced signals", m_statSigs); V3Stats::addStat("Tracing, Traced signals", m_statSigs);

View File

@ -302,21 +302,21 @@ class TristatePinVisitor : public TristateBaseVisitor {
virtual void visit(AstArraySel* nodep) { virtual void visit(AstArraySel* nodep) {
// Doesn't work because we'd set lvalue on the array index's var // Doesn't work because we'd set lvalue on the array index's var
if (m_lvalue) nodep->v3fatalSrc("ArraySel conversion to output, under tristate node"); if (m_lvalue) nodep->v3fatalSrc("ArraySel conversion to output, under tristate node");
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSliceSel* nodep) { virtual void visit(AstSliceSel* nodep) {
// Doesn't work because we'd set lvalue on the array index's var // Doesn't work because we'd set lvalue on the array index's var
if (m_lvalue) nodep->v3fatalSrc("SliceSel conversion to output, under tristate node"); if (m_lvalue) nodep->v3fatalSrc("SliceSel conversion to output, under tristate node");
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
TristatePinVisitor(AstNode* nodep, TristateGraph& tgraph, bool lvalue) TristatePinVisitor(AstNode* nodep, TristateGraph& tgraph, bool lvalue)
: m_tgraph(tgraph), m_lvalue(lvalue) { : m_tgraph(tgraph), m_lvalue(lvalue) {
nodep->accept(*this); iterate(nodep);
} }
virtual ~TristatePinVisitor() {} virtual ~TristatePinVisitor() {}
}; };
@ -676,7 +676,7 @@ class TristateVisitor : public TristateBaseVisitor {
virtual void visit(AstCond* nodep) { virtual void visit(AstCond* nodep) {
if (m_graphing) { if (m_graphing) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_alhs) { if (m_alhs) {
associateLogic(nodep, nodep->expr1p()); associateLogic(nodep, nodep->expr1p());
associateLogic(nodep, nodep->expr2p()); associateLogic(nodep, nodep->expr2p());
@ -686,7 +686,7 @@ class TristateVisitor : public TristateBaseVisitor {
} }
} else { } else {
if (m_alhs && nodep->user1p()) { nodep->v3error("Unsupported LHS tristate construct: "<<nodep->prettyTypeName()); return; } if (m_alhs && nodep->user1p()) { nodep->v3error("Unsupported LHS tristate construct: "<<nodep->prettyTypeName()); return; }
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
// Generate the new output enable signal for this cond if either // Generate the new output enable signal for this cond if either
// expression 1 or 2 have an output enable '__en' signal. If the // expression 1 or 2 have an output enable '__en' signal. If the
@ -715,7 +715,7 @@ class TristateVisitor : public TristateBaseVisitor {
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
if (m_graphing) { if (m_graphing) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_alhs) { if (m_alhs) {
associateLogic(nodep, nodep->fromp()); associateLogic(nodep, nodep->fromp());
} else { } else {
@ -731,9 +731,9 @@ class TristateVisitor : public TristateBaseVisitor {
if (debug()>=9) newp->dumpTree(cout,"-assign-sel; "); if (debug()>=9) newp->dumpTree(cout,"-assign-sel; ");
m_tgraph.didProcess(nodep); m_tgraph.didProcess(nodep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
if (nodep->lsbp()->user1p()) { if (nodep->lsbp()->user1p()) {
nodep->v3error("Unsupported RHS tristate construct: "<<nodep->prettyTypeName()); nodep->v3error("Unsupported RHS tristate construct: "<<nodep->prettyTypeName());
@ -752,7 +752,7 @@ class TristateVisitor : public TristateBaseVisitor {
virtual void visit(AstConcat* nodep) { virtual void visit(AstConcat* nodep) {
if (m_graphing) { if (m_graphing) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_alhs) { if (m_alhs) {
associateLogic(nodep, nodep->lhsp()); associateLogic(nodep, nodep->lhsp());
associateLogic(nodep, nodep->rhsp()); associateLogic(nodep, nodep->rhsp());
@ -778,9 +778,9 @@ class TristateVisitor : public TristateBaseVisitor {
nodep->rhsp()->width())); nodep->rhsp()->width()));
m_tgraph.didProcess(nodep); m_tgraph.didProcess(nodep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
// Generate the new output enable signal, just as a concat identical to the data concat // Generate the new output enable signal, just as a concat identical to the data concat
AstNode* expr1p = nodep->lhsp(); AstNode* expr1p = nodep->lhsp();
@ -801,7 +801,7 @@ class TristateVisitor : public TristateBaseVisitor {
virtual void visit(AstBufIf1* nodep) { virtual void visit(AstBufIf1* nodep) {
// For BufIf1, the enable is the LHS expression // For BufIf1, the enable is the LHS expression
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
if (m_graphing) { if (m_graphing) {
associateLogic(nodep->rhsp(), nodep); associateLogic(nodep->rhsp(), nodep);
@ -829,7 +829,7 @@ class TristateVisitor : public TristateBaseVisitor {
} }
void visitAndOr(AstNodeBiop* nodep, bool isAnd) { void visitAndOr(AstNodeBiop* nodep, bool isAnd) {
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
if (m_graphing) { if (m_graphing) {
associateLogic(nodep->lhsp(), nodep); associateLogic(nodep->lhsp(), nodep);
@ -891,9 +891,9 @@ class TristateVisitor : public TristateBaseVisitor {
if (nodep->user2() & U2_GRAPHING) return; if (nodep->user2() & U2_GRAPHING) return;
nodep->user2(U2_GRAPHING); nodep->user2(U2_GRAPHING);
m_logicp = nodep; m_logicp = nodep;
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
m_alhs = true; m_alhs = true;
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_alhs = false; m_alhs = false;
associateLogic(nodep->rhsp(), nodep); associateLogic(nodep->rhsp(), nodep);
associateLogic(nodep, nodep->lhsp()); associateLogic(nodep, nodep->lhsp());
@ -901,7 +901,7 @@ class TristateVisitor : public TristateBaseVisitor {
} else { } else {
if (nodep->user2() & U2_NONGRAPH) return; // Iterated here, or created assignment to ignore if (nodep->user2() & U2_NONGRAPH) return; // Iterated here, or created assignment to ignore
nodep->user2(U2_NONGRAPH); nodep->user2(U2_NONGRAPH);
nodep->rhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->rhsp());
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
if (debug()>=9) nodep->dumpTree(cout,"-assign: "); if (debug()>=9) nodep->dumpTree(cout,"-assign: ");
// if the rhsp of this assign statement has an output enable driver, // if the rhsp of this assign statement has an output enable driver,
@ -915,7 +915,7 @@ class TristateVisitor : public TristateBaseVisitor {
m_tgraph.didProcess(nodep); m_tgraph.didProcess(nodep);
} }
m_alhs = true; // And user1p() will indicate tristate equation, if any m_alhs = true; // And user1p() will indicate tristate equation, if any
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
m_alhs = false; m_alhs = false;
} }
} }
@ -928,14 +928,14 @@ class TristateVisitor : public TristateBaseVisitor {
void visitCaseEq(AstNodeBiop* nodep, bool neq) { void visitCaseEq(AstNodeBiop* nodep, bool neq) {
if (m_graphing) { if (m_graphing) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
checkUnhandled(nodep); checkUnhandled(nodep);
// Unsupported: A === 3'b000 should compare with the enables, but we don't do // Unsupported: A === 3'b000 should compare with the enables, but we don't do
// so at present, we only compare if there is a z in the equation. // so at present, we only compare if there is a z in the equation.
// Otherwise we'd need to attach an enable to every signal, then optimize them // Otherwise we'd need to attach an enable to every signal, then optimize them
// away later when we determine the signal has no tristate // away later when we determine the signal has no tristate
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
const AstConst* constp = VN_CAST(nodep->lhsp(), Const); // Constification always moves const to LHS const AstConst* constp = VN_CAST(nodep->lhsp(), Const); // Constification always moves const to LHS
AstVarRef* varrefp = VN_CAST(nodep->rhsp(), VarRef); // Input variable AstVarRef* varrefp = VN_CAST(nodep->rhsp(), VarRef); // Input variable
@ -967,7 +967,7 @@ class TristateVisitor : public TristateBaseVisitor {
nodep->v3error("Unsupported: RHS of ==? or !=? must be constant to be synthesizable"); // Says spec. nodep->v3error("Unsupported: RHS of ==? or !=? must be constant to be synthesizable"); // Says spec.
// rhs we want to keep X/Z intact, so otherwise ignore // rhs we want to keep X/Z intact, so otherwise ignore
} }
nodep->lhsp()->iterateAndNext(*this); iterateAndNextNull(nodep->lhsp());
if (nodep->lhsp()->user1p()) { nodep->v3error("Unsupported LHS tristate construct: "<<nodep->prettyTypeName()); return; } if (nodep->lhsp()->user1p()) { nodep->v3error("Unsupported LHS tristate construct: "<<nodep->prettyTypeName()); return; }
} }
virtual void visit(AstEqCase* nodep) { virtual void visit(AstEqCase* nodep) {
@ -1028,14 +1028,14 @@ class TristateVisitor : public TristateBaseVisitor {
associateLogic(nodep->exprp(), nodep); associateLogic(nodep->exprp(), nodep);
associateLogic(nodep, nodep->exprp()); associateLogic(nodep, nodep->exprp());
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
m_logicp = NULL; m_logicp = NULL;
} else { } else {
// All heavy lifting completed in graph visitor. // All heavy lifting completed in graph visitor.
if (nodep->exprp()) { if (nodep->exprp()) {
m_tgraph.didProcess(nodep); m_tgraph.didProcess(nodep);
} }
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
@ -1239,7 +1239,7 @@ class TristateVisitor : public TristateBaseVisitor {
} }
virtual void visit(AstVar* nodep) { virtual void visit(AstVar* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
UINFO(9,dbgState()<<nodep<<endl); UINFO(9,dbgState()<<nodep<<endl);
if (m_graphing) { if (m_graphing) {
// If tri0/1 force a pullup // If tri0/1 force a pullup
@ -1282,13 +1282,13 @@ class TristateVisitor : public TristateBaseVisitor {
// Walk the graph, finding all variables and tristate constructs // Walk the graph, finding all variables and tristate constructs
{ {
m_graphing = true; m_graphing = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_graphing = false; m_graphing = false;
} }
// Use graph to find tristate signals // Use graph to find tristate signals
m_tgraph.graphWalk(nodep); m_tgraph.graphWalk(nodep);
// Build the LHS drivers map for this module // Build the LHS drivers map for this module
nodep->iterateChildren(*this); iterateChildren(nodep);
// Insert new logic for all tristates // Insert new logic for all tristates
insertTristates(nodep); insertTristates(nodep);
m_modp = NULL; m_modp = NULL;
@ -1300,23 +1300,23 @@ class TristateVisitor : public TristateBaseVisitor {
virtual void visit(AstCaseItem* nodep) { virtual void visit(AstCaseItem* nodep) {
// don't deal with casez compare '???? values // don't deal with casez compare '???? values
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
} }
virtual void visit(AstCell* nodep) { virtual void visit(AstCell* nodep) {
m_cellp = nodep; m_cellp = nodep;
m_alhs = false; m_alhs = false;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_cellp = NULL; m_cellp = NULL;
} }
virtual void visit(AstNetlist* nodep) { virtual void visit(AstNetlist* nodep) {
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
checkUnhandled(nodep); checkUnhandled(nodep);
} }
@ -1330,7 +1330,7 @@ public:
m_alhs = false; m_alhs = false;
m_logicp = NULL; m_logicp = NULL;
m_tgraph.clear(); m_tgraph.clear();
nodep->accept(*this); iterate(nodep);
} }
virtual ~TristateVisitor() { virtual ~TristateVisitor() {
V3Stats::addStat("Tristate, Tristate resolved nets", m_statTriSigs); V3Stats::addStat("Tristate, Tristate resolved nets", m_statTriSigs);

View File

@ -292,15 +292,15 @@ private:
} }
} }
// Discover variables used in bit definitions, etc // Discover variables used in bit definitions, etc
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstArraySel* nodep) { virtual void visit(AstArraySel* nodep) {
// Arrays are rarely constant assigned, so for now we punt and do all entries // Arrays are rarely constant assigned, so for now we punt and do all entries
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSliceSel* nodep) { virtual void visit(AstSliceSel* nodep) {
// Arrays are rarely constant assigned, so for now we punt and do all entries // Arrays are rarely constant assigned, so for now we punt and do all entries
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
AstNodeVarRef* varrefp = VN_CAST(nodep->fromp(), NodeVarRef); AstNodeVarRef* varrefp = VN_CAST(nodep->fromp(), NodeVarRef);
@ -321,7 +321,7 @@ private:
} }
} else { } else {
// else other varrefs handled as unknown mess in AstVarRef // else other varrefs handled as unknown mess in AstVarRef
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
virtual void visit(AstNodeVarRef* nodep) { virtual void visit(AstNodeVarRef* nodep) {
@ -344,7 +344,7 @@ private:
virtual void visit(AstSysIgnore* nodep) { virtual void visit(AstSysIgnore* nodep) {
bool prevMark = m_inBBox; bool prevMark = m_inBBox;
m_inBBox = true; m_inBBox = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_inBBox = prevMark; m_inBBox = prevMark;
} }
@ -355,7 +355,7 @@ private:
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9," "<<nodep<<endl); if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9," "<<nodep<<endl);
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) m_alwaysp = nodep; if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) m_alwaysp = nodep;
else m_alwaysp = NULL; else m_alwaysp = NULL;
nodep->iterateChildren(*this); iterateChildren(nodep);
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9," Done "<<nodep<<endl); if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9," Done "<<nodep<<endl);
} }
m_alwaysp = prevAlwp; m_alwaysp = prevAlwp;
@ -364,7 +364,7 @@ private:
virtual void visit(AstNodeFTask* nodep) { virtual void visit(AstNodeFTask* nodep) {
AstNodeFTask* prevTaskp = m_taskp; AstNodeFTask* prevTaskp = m_taskp;
m_taskp = nodep; m_taskp = nodep;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_taskp = prevTaskp; m_taskp = prevTaskp;
} }
@ -381,7 +381,7 @@ private:
// iterate // iterate
virtual void visit(AstConst* nodep) {} virtual void visit(AstConst* nodep) {}
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
@ -389,7 +389,7 @@ public:
m_inBBox = false; m_inBBox = false;
m_taskp = NULL; m_taskp = NULL;
m_alwaysp = NULL; m_alwaysp = NULL;
nodep->accept(*this); iterate(nodep);
} }
virtual ~UndrivenVisitor() { virtual ~UndrivenVisitor() {
for (std::vector<UndrivenVarEntry*>::iterator it = m_entryps[1].begin(); it != m_entryps[1].end(); ++it) { for (std::vector<UndrivenVarEntry*>::iterator it = m_entryps[1].begin(); it != m_entryps[1].end(); ++it) {

View File

@ -151,28 +151,28 @@ private:
UINFO(4," MOD "<<nodep<<endl); UINFO(4," MOD "<<nodep<<endl);
m_modp = nodep; m_modp = nodep;
m_constXCvt = true; m_constXCvt = true;
nodep->iterateChildren(*this); iterateChildren(nodep);
m_modp = NULL; m_modp = NULL;
} }
virtual void visit(AstAssignDly* nodep) { virtual void visit(AstAssignDly* nodep) {
m_assigndlyp = nodep; m_assigndlyp = nodep;
nodep->iterateChildren(*this); VL_DANGLING(nodep); // May delete nodep. iterateChildren(nodep); VL_DANGLING(nodep); // May delete nodep.
m_assigndlyp = NULL; m_assigndlyp = NULL;
} }
virtual void visit(AstAssignW* nodep) { virtual void visit(AstAssignW* nodep) {
m_assignwp = nodep; m_assignwp = nodep;
nodep->iterateChildren(*this); VL_DANGLING(nodep); // May delete nodep. iterateChildren(nodep); VL_DANGLING(nodep); // May delete nodep.
m_assignwp = NULL; m_assignwp = NULL;
} }
virtual void visit(AstCaseItem* nodep) { virtual void visit(AstCaseItem* nodep) {
m_constXCvt = false; // Avoid losing the X's in casex m_constXCvt = false; // Avoid losing the X's in casex
nodep->condsp()->iterateAndNext(*this); iterateAndNextNull(nodep->condsp());
m_constXCvt = true; m_constXCvt = true;
nodep->bodysp()->iterateAndNext(*this); iterateAndNextNull(nodep->bodysp());
} }
virtual void visit(AstNodeDType* nodep) { virtual void visit(AstNodeDType* nodep) {
m_constXCvt = false; // Avoid losing the X's in casex m_constXCvt = false; // Avoid losing the X's in casex
nodep->iterateChildren(*this); iterateChildren(nodep);
m_constXCvt = true; m_constXCvt = true;
} }
void visitEqNeqCase(AstNodeBiop* nodep) { void visitEqNeqCase(AstNodeBiop* nodep) {
@ -202,7 +202,7 @@ private:
nodep->replaceWith(newp); nodep->replaceWith(newp);
nodep->deleteTree(); VL_DANGLING(nodep); nodep->deleteTree(); VL_DANGLING(nodep);
// Iterate tree now that we may have gotten rid of Xs // Iterate tree now that we may have gotten rid of Xs
newp->iterateChildren(*this); iterateChildren(newp);
} }
} }
void visitEqNeqWild(AstNodeBiop* nodep) { void visitEqNeqWild(AstNodeBiop* nodep) {
@ -238,7 +238,7 @@ private:
nodep->replaceWith(newp); nodep->replaceWith(newp);
nodep->deleteTree(); VL_DANGLING(nodep); nodep->deleteTree(); VL_DANGLING(nodep);
// Iterate tree now that we may have gotten rid of the compare // Iterate tree now that we may have gotten rid of the compare
newp->iterateChildren(*this); iterateChildren(newp);
} }
} }
@ -255,7 +255,7 @@ private:
visitEqNeqWild(nodep); visitEqNeqWild(nodep);
} }
virtual void visit(AstIsUnknown* nodep) { virtual void visit(AstIsUnknown* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
// Ahh, we're two state, so this is easy // Ahh, we're two state, so this is easy
UINFO(4," ISUNKNOWN->0 "<<nodep<<endl); UINFO(4," ISUNKNOWN->0 "<<nodep<<endl);
V3Number zero (nodep->fileline(), 1, 0); V3Number zero (nodep->fileline(), 1, 0);
@ -328,7 +328,7 @@ private:
} }
virtual void visit(AstSel* nodep) { virtual void visit(AstSel* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->user1SetOnce()) { if (!nodep->user1SetOnce()) {
// Guard against reading/writing past end of bit vector array // Guard against reading/writing past end of bit vector array
AstNode* basefromp = AstArraySel::baseFromp(nodep); AstNode* basefromp = AstArraySel::baseFromp(nodep);
@ -367,7 +367,7 @@ private:
// Link in conditional // Link in conditional
replaceHandle.relink(newp); replaceHandle.relink(newp);
// Added X's, tristate them too // Added X's, tristate them too
newp->accept(*this); iterate(newp);
} }
else { // lvalue else { // lvalue
replaceBoundLvalue(nodep, condp); replaceBoundLvalue(nodep, condp);
@ -379,7 +379,7 @@ private:
// in V3Width. // in V3Width.
virtual void visit(AstArraySel* nodep) { virtual void visit(AstArraySel* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (!nodep->user1SetOnce()) { if (!nodep->user1SetOnce()) {
if (debug()==9) nodep->dumpTree(cout,"-in: "); if (debug()==9) nodep->dumpTree(cout,"-in: ");
// Guard against reading/writing past end of arrays // Guard against reading/writing past end of arrays
@ -433,7 +433,7 @@ private:
// Link in conditional, can blow away temp xor // Link in conditional, can blow away temp xor
replaceHandle.relink(newp); replaceHandle.relink(newp);
// Added X's, tristate them too // Added X's, tristate them too
newp->accept(*this); iterate(newp);
} }
else if (!lvalue) { // Mid-multidimension read, just use zero else if (!lvalue) { // Mid-multidimension read, just use zero
// ARRAYSEL(...) -> ARRAYSEL(COND(LT(bit<maxbit), bit, 0)) // ARRAYSEL(...) -> ARRAYSEL(COND(LT(bit<maxbit), bit, 0))
@ -447,7 +447,7 @@ private:
// Added X's, tristate them too // Added X's, tristate them too
if (debug()>=9) newp->dumpTree(cout," _new: "); if (debug()>=9) newp->dumpTree(cout," _new: ");
replaceHandle.relink(newp); replaceHandle.relink(newp);
newp->accept(*this); iterate(newp);
} }
else { // lvalue else { // lvalue
replaceBoundLvalue(nodep, condp); replaceBoundLvalue(nodep, condp);
@ -457,7 +457,7 @@ private:
//-------------------- //--------------------
// Default: Just iterate // Default: Just iterate
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
public: public:
@ -467,7 +467,7 @@ public:
m_assigndlyp = NULL; m_assigndlyp = NULL;
m_assignwp = NULL; m_assignwp = NULL;
m_constXCvt = false; m_constXCvt = false;
nodep->accept(*this); iterate(nodep);
} }
virtual ~UnknownVisitor() { virtual ~UnknownVisitor() {
V3Stats::addStat("Unknowns, variables created", m_statUnkVars); V3Stats::addStat("Unknowns, variables created", m_statUnkVars);

View File

@ -142,9 +142,9 @@ private:
m_varModeCheck = true; m_varModeCheck = true;
m_varAssignHit = false; m_varAssignHit = false;
m_ignoreIncp = incp; m_ignoreIncp = incp;
precondsp->iterateAndNext(*this); iterateAndNextNull(precondsp);
bodysp->iterateAndNext(*this); iterateAndNextNull(bodysp);
incp->iterateAndNext(*this); iterateAndNextNull(incp);
m_varModeCheck = false; m_varModeCheck = false;
m_ignoreIncp = NULL; m_ignoreIncp = NULL;
if (m_varAssignHit) return cantUnroll(nodep, "genvar assigned *inside* loop"); if (m_varAssignHit) return cantUnroll(nodep, "genvar assigned *inside* loop");
@ -203,7 +203,7 @@ private:
// Iteration requires a back, so put under temporary node // Iteration requires a back, so put under temporary node
AstBegin* tempp = new AstBegin (nodep->fileline(), "[EditWrapper]", clone); AstBegin* tempp = new AstBegin (nodep->fileline(), "[EditWrapper]", clone);
m_varModeReplace = true; m_varModeReplace = true;
tempp->stmtsp()->iterateAndNext(*this); iterateAndNextNull(tempp->stmtsp());
m_varModeReplace = false; m_varModeReplace = false;
clone = tempp->stmtsp()->unlinkFrBackWithNext(); clone = tempp->stmtsp()->unlinkFrBackWithNext();
tempp->deleteTree(); tempp->deleteTree();
@ -319,7 +319,7 @@ private:
if (oneloopp) { if (oneloopp) {
AstBegin* tempp = new AstBegin(oneloopp->fileline(),"[EditWrapper]",oneloopp); AstBegin* tempp = new AstBegin(oneloopp->fileline(),"[EditWrapper]",oneloopp);
m_varModeReplace = true; m_varModeReplace = true;
tempp->stmtsp()->iterateAndNext(*this); iterateAndNextNull(tempp->stmtsp());
m_varModeReplace = false; m_varModeReplace = false;
oneloopp = tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); VL_DANGLING(tempp); oneloopp = tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); VL_DANGLING(tempp);
} }
@ -363,7 +363,7 @@ private:
} }
virtual void visit(AstWhile* nodep) { virtual void visit(AstWhile* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
if (m_varModeCheck || m_varModeReplace) { if (m_varModeCheck || m_varModeReplace) {
} else { } else {
// Constify before unroll call, as it may change what is underneath. // Constify before unroll call, as it may change what is underneath.
@ -393,7 +393,7 @@ private:
} }
virtual void visit(AstGenFor* nodep) { virtual void visit(AstGenFor* nodep) {
if (!m_generate || m_varModeReplace) { if (!m_generate || m_varModeReplace) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} // else V3Param will recursively call each for loop to be unrolled for us } // else V3Param will recursively call each for loop to be unrolled for us
if (m_varModeCheck || m_varModeReplace) { if (m_varModeCheck || m_varModeReplace) {
} else { } else {
@ -421,7 +421,7 @@ private:
} }
virtual void visit(AstNodeFor* nodep) { virtual void visit(AstNodeFor* nodep) {
if (m_generate) { // Ignore for's when expanding genfor's if (m_generate) { // Ignore for's when expanding genfor's
nodep->iterateChildren(*this); iterateChildren(nodep);
} else { } else {
nodep->v3error("V3Begin should have removed standard FORs"); nodep->v3error("V3Begin should have removed standard FORs");
} }
@ -452,7 +452,7 @@ private:
if (m_varModeCheck && nodep == m_ignoreIncp) { if (m_varModeCheck && nodep == m_ignoreIncp) {
// Ignore subtree that is the increment // Ignore subtree that is the increment
} else { } else {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
} }
@ -467,7 +467,7 @@ public:
m_generate = generate; m_generate = generate;
m_beginName = beginName; m_beginName = beginName;
// //
nodep->accept(*this); iterate(nodep);
} }
virtual ~UnrollVisitor() { virtual ~UnrollVisitor() {
V3Stats::addStatSum("Optimizations, Unrolled Loops", m_statLoops); V3Stats::addStatSum("Optimizations, Unrolled Loops", m_statLoops);

View File

@ -3807,7 +3807,7 @@ private:
AstNode* ret; AstNode* ret;
{ {
m_vup = vup; m_vup = vup;
ret = nodep->iterateSubtreeReturnEdits(*this); ret = iterateSubtreeReturnEdits(nodep);
} }
m_vup = saveVup; m_vup = saveVup;
return ret; return ret;
@ -3817,7 +3817,7 @@ private:
WidthVP* saveVup = m_vup; WidthVP* saveVup = m_vup;
{ {
m_vup = vup; m_vup = vup;
nodep->iterate(*this); iterate(nodep);
} }
m_vup = saveVup; m_vup = saveVup;
} }
@ -3826,7 +3826,7 @@ private:
WidthVP* saveVup = m_vup; WidthVP* saveVup = m_vup;
{ {
m_vup = vup; m_vup = vup;
nodep->iterateAndNext(*this); iterateAndNextNull(nodep);
} }
m_vup = saveVup; m_vup = saveVup;
} }
@ -3835,7 +3835,7 @@ private:
WidthVP* saveVup = m_vup; WidthVP* saveVup = m_vup;
{ {
m_vup = vup; m_vup = vup;
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
m_vup = saveVup; m_vup = saveVup;
} }
@ -3844,7 +3844,7 @@ private:
WidthVP* saveVup = m_vup; WidthVP* saveVup = m_vup;
{ {
m_vup = vup; m_vup = vup;
nodep->iterateChildrenBackwards(*this); iterateChildrenBackwards(nodep);
} }
m_vup = saveVup; m_vup = saveVup;
} }

View File

@ -44,7 +44,7 @@ private:
replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()); VL_DANGLING(nodep); replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()); VL_DANGLING(nodep);
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
} }
void replaceWithSignedVersion(AstNode* nodep, AstNode* newp) { void replaceWithSignedVersion(AstNode* nodep, AstNode* newp) {
UINFO(6," Replace "<<nodep<<" w/ "<<newp<<endl); UINFO(6," Replace "<<nodep<<" w/ "<<newp<<endl);
@ -57,7 +57,7 @@ public:
WidthRemoveVisitor() {} WidthRemoveVisitor() {}
virtual ~WidthRemoveVisitor() {} virtual ~WidthRemoveVisitor() {}
AstNode* mainAcceptEdit(AstNode* nodep) { AstNode* mainAcceptEdit(AstNode* nodep) {
return nodep->iterateSubtreeReturnEdits(*this); return iterateSubtreeReturnEdits(nodep);
} }
}; };
@ -99,7 +99,7 @@ private:
// dtypep() figures into sameTree() results in better optimizations // dtypep() figures into sameTree() results in better optimizations
if (!nodep) return NULL; if (!nodep) return NULL;
// Recurse to handle the data type, as may change the size etc of this type // Recurse to handle the data type, as may change the size etc of this type
if (!nodep->user1()) nodep->accept(*this); if (!nodep->user1()) iterate(nodep);
// Look for duplicate // Look for duplicate
if (AstBasicDType* bdtypep = VN_CAST(nodep, BasicDType)) { if (AstBasicDType* bdtypep = VN_CAST(nodep, BasicDType)) {
AstBasicDType* newp = nodep->findInsertSameDType(bdtypep); AstBasicDType* newp = nodep->findInsertSameDType(bdtypep);
@ -114,7 +114,7 @@ private:
// VISITORS // VISITORS
virtual void visit(AstConst* nodep) { virtual void visit(AstConst* nodep) {
if (!nodep->dtypep()) nodep->v3fatalSrc("No dtype"); if (!nodep->dtypep()) nodep->v3fatalSrc("No dtype");
nodep->dtypep()->accept(*this); // Do datatype first iterate(nodep->dtypep()); // Do datatype first
if (AstConst* newp = newIfConstCommitSize(nodep)) { if (AstConst* newp = newIfConstCommitSize(nodep)) {
nodep->replaceWith(newp); nodep->replaceWith(newp);
AstNode* oldp = nodep; nodep = newp; AstNode* oldp = nodep; nodep = newp;
@ -147,7 +147,7 @@ private:
nodep->widthMinFromWidth(); nodep->widthMinFromWidth();
// Too late to any unspecified sign to be anything but unsigned // Too late to any unspecified sign to be anything but unsigned
if (nodep->numeric().isNosign()) nodep->numeric(AstNumeric::UNSIGNED); if (nodep->numeric().isNosign()) nodep->numeric(AstNumeric::UNSIGNED);
nodep->iterateChildren(*this); iterateChildren(nodep);
nodep->virtRefDTypep(editOneDType(nodep->virtRefDTypep())); nodep->virtRefDTypep(editOneDType(nodep->virtRefDTypep()));
} }
virtual void visit(AstNodePreSel* nodep) { virtual void visit(AstNodePreSel* nodep) {
@ -155,7 +155,7 @@ private:
nodep->v3fatalSrc("Presels should have been removed before this point"); nodep->v3fatalSrc("Presels should have been removed before this point");
} }
virtual void visit(AstNode* nodep) { virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this); iterateChildren(nodep);
editDType(nodep); editDType(nodep);
} }
public: public:
@ -163,7 +163,7 @@ public:
explicit WidthCommitVisitor(AstNetlist* nodep) { explicit WidthCommitVisitor(AstNetlist* nodep) {
// Were changing widthMin's, so the table is now somewhat trashed // Were changing widthMin's, so the table is now somewhat trashed
nodep->typeTablep()->clearCache(); nodep->typeTablep()->clearCache();
nodep->accept(*this); iterate(nodep);
// Don't want to repairCache, as all needed nodes have been added back in // Don't want to repairCache, as all needed nodes have been added back in
// a repair would prevent dead nodes from being detected // a repair would prevent dead nodes from being detected
} }

View File

@ -478,7 +478,7 @@ public:
// CONSTUCTORS // CONSTUCTORS
WidthSelVisitor() {} WidthSelVisitor() {}
AstNode* mainAcceptEdit(AstNode* nodep) { AstNode* mainAcceptEdit(AstNode* nodep) {
return nodep->iterateSubtreeReturnEdits(*this); return iterateSubtreeReturnEdits(nodep);
} }
virtual ~WidthSelVisitor() {} virtual ~WidthSelVisitor() {}
}; };

View File

@ -618,11 +618,11 @@ sub tree_base {
if ($out_for_type_sc[0]) { # Short-circuited types if ($out_for_type_sc[0]) { # Short-circuited types
$self->print(" // Generated by astgen with short-circuiting\n", $self->print(" // Generated by astgen with short-circuiting\n",
" virtual void visit(Ast${type}* nodep) {\n", " virtual void visit(Ast${type}* nodep) {\n",
" nodep->lhsp()->iterateAndNext(*this);\n", " iterateAndNextNull(nodep->lhsp());\n",
@out_for_type_sc); @out_for_type_sc);
$self->print(" nodep->rhsp()->iterateAndNext(*this);\n", $self->print(" iterateAndNextNull(nodep->rhsp());\n",
" AstNodeTriop *tnp = VN_CAST(nodep, NodeTriop);\n", " AstNodeTriop *tnp = VN_CAST(nodep, NodeTriop);\n",
" if (tnp && tnp->thsp()) tnp->thsp()->iterateAndNext(*this);\n", " if (tnp && tnp->thsp()) iterateAndNextNull(tnp->thsp());\n",
@out_for_type, @out_for_type,
" }\n") if ($out_for_type[0]); " }\n") if ($out_for_type[0]);
} elsif ($out_for_type[0]) { # Other types with something to print } elsif ($out_for_type[0]) { # Other types with something to print
@ -631,7 +631,7 @@ sub tree_base {
$self->print(" // Generated by astgen\n", $self->print(" // Generated by astgen\n",
" virtual void visit$gen(Ast${type}* nodep) {\n", " virtual void visit$gen(Ast${type}* nodep) {\n",
($skip?"": ($skip?"":
" nodep->iterateChildren(*this);\n"), " iterateChildren(nodep);\n"),
@out_for_type, @out_for_type,
" }\n"); " }\n");
} }