Internal speedups: Skip iterator for Termop or VarRefs.

Fix AstUCFunc being mis-labeled as a Termop.
This commit is contained in:
Wilson Snyder 2008-11-22 15:28:29 -05:00
parent c595d67311
commit a242c1019d
4 changed files with 12 additions and 3 deletions

View File

@ -804,7 +804,7 @@ void AstNode::checkTreeIter(AstNode* backp) {
if (backp != this->backp()) { if (backp != this->backp()) {
this->v3fatalSrc("Back node inconsistent"); this->v3fatalSrc("Back node inconsistent");
} }
if (castNodeTermop()) { if (castNodeTermop() || castNodeVarRef()) {
// Termops have a short-circuited iterateChildren, so check usage // Termops have a short-circuited iterateChildren, so check usage
if (op1p()||op2p()||op3p()||op4p()) if (op1p()||op2p()||op3p()||op4p())
this->v3fatalSrc("Terminal operation with non-terminals"); this->v3fatalSrc("Terminal operation with non-terminals");

View File

@ -823,6 +823,9 @@ struct AstNodeTermop : public AstNodeMath {
AstNodeTermop(FileLine* fl) AstNodeTermop(FileLine* fl)
: AstNodeMath(fl) {} : AstNodeMath(fl) {}
ASTNODE_BASE_FUNCS(NodeTermop) ASTNODE_BASE_FUNCS(NodeTermop)
// Know no children, and hot function, so skip iterator for speed
// See checkTreeIter also that asserts no children
void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { }
}; };
struct AstNodeUniop : public AstNodeMath { struct AstNodeUniop : public AstNodeMath {
@ -1070,6 +1073,9 @@ public:
void hiername(const string& hn) { m_hiername = hn; } void hiername(const string& hn) { m_hiername = hn; }
bool hierThis() const { return m_hierThis; } bool hierThis() const { return m_hierThis; }
void hierThis(bool flag) { m_hierThis = flag; } void hierThis(bool flag) { m_hierThis = flag; }
// Know no children, and hot function, so skip iterator for speed
// See checkTreeIter also that asserts no children
void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { }
}; };
class AstNodePli : public AstNodeStmt { class AstNodePli : public AstNodeStmt {

View File

@ -1675,11 +1675,12 @@ struct AstTime : public AstNodeTermop {
virtual bool same(AstNode* samep) const { return true; } virtual bool same(AstNode* samep) const { return true; }
}; };
struct AstUCFunc : public AstNodeTermop { struct AstUCFunc : public AstNodeMath {
// User's $c function // User's $c function
// Perhaps this should be a AstNodeListop; but there's only one list math right now
public: public:
AstUCFunc(FileLine* fl, AstNode* exprsp) AstUCFunc(FileLine* fl, AstNode* exprsp)
: AstNodeTermop(fl) { : AstNodeMath(fl) {
addNOp1p(exprsp); addNOp1p(exprsp);
} }
ASTNODE_NODE_FUNCS(UCFunc, UCFUNC) ASTNODE_NODE_FUNCS(UCFunc, UCFUNC)

View File

@ -246,6 +246,8 @@ private:
nodep->iterateChildren(*this); checkNode(nodep); } nodep->iterateChildren(*this); checkNode(nodep); }
virtual void visit(AstNodeBiop* nodep, AstNUser*) { virtual void visit(AstNodeBiop* nodep, AstNUser*) {
nodep->iterateChildren(*this); checkNode(nodep); } nodep->iterateChildren(*this); checkNode(nodep); }
virtual void visit(AstUCFunc* nodep, AstNUser*) {
nodep->iterateChildren(*this); checkNode(nodep); }
virtual void visit(AstSel* nodep, AstNUser*) { virtual void visit(AstSel* nodep, AstNUser*) {
nodep->fromp()->iterateAndNext(*this); nodep->fromp()->iterateAndNext(*this);
{ // Only the 'from' is part of the assignment LHS { // Only the 'from' is part of the assignment LHS