Internals: Separate pure from branching. No functional change.

This commit is contained in:
Wilson Snyder 2011-12-15 22:23:11 -05:00
parent 4da9b5e491
commit 76232cd9e7
4 changed files with 9 additions and 7 deletions

View File

@ -968,6 +968,7 @@ public:
// METHODS - queries // METHODS - queries
virtual bool isPure() const { return true; } // Else a $display, etc, that must be ordered with other displays virtual bool isPure() const { return true; } // Else a $display, etc, that must be ordered with other displays
virtual bool isBrancher() const { return false; } // Changes control flow, disable some optimizations
virtual bool isGateOptimizable() const { return true; } // Else a AstTime etc that can't be pushed out virtual bool isGateOptimizable() const { return true; } // Else a AstTime etc that can't be pushed out
virtual bool isSubstOptimizable() const { return true; } // Else a AstTime etc that can't be substituted out virtual bool isSubstOptimizable() const { return true; } // Else a AstTime etc that can't be substituted out
virtual bool isPredictOptimizable() const { return true; } // Else a AstTime etc which output can't be predicted from input virtual bool isPredictOptimizable() const { return true; } // Else a AstTime etc which output can't be predicted from input

View File

@ -2040,7 +2040,7 @@ struct AstBreak : public AstNodeStmt {
ASTNODE_NODE_FUNCS(Break, BREAK) ASTNODE_NODE_FUNCS(Break, BREAK)
virtual string verilogKwd() const { return "break"; }; virtual string verilogKwd() const { return "break"; };
virtual V3Hash sameHash() const { return V3Hash(); } virtual V3Hash sameHash() const { return V3Hash(); }
virtual bool isPure() const { return false; } // SPECIAL: We don't process code after breaks virtual bool isBrancher() const { return true; } // SPECIAL: We don't process code after breaks
}; };
struct AstContinue : public AstNodeStmt { struct AstContinue : public AstNodeStmt {
@ -2049,7 +2049,7 @@ struct AstContinue : public AstNodeStmt {
ASTNODE_NODE_FUNCS(Continue, CONTINUE) ASTNODE_NODE_FUNCS(Continue, CONTINUE)
virtual string verilogKwd() const { return "continue"; }; virtual string verilogKwd() const { return "continue"; };
virtual V3Hash sameHash() const { return V3Hash(); } virtual V3Hash sameHash() const { return V3Hash(); }
virtual bool isPure() const { return false; } // SPECIAL: We don't process code after breaks virtual bool isBrancher() const { return true; } // SPECIAL: We don't process code after breaks
}; };
struct AstDisable : public AstNodeStmt { struct AstDisable : public AstNodeStmt {
@ -2061,7 +2061,7 @@ public:
ASTNODE_NODE_FUNCS(Disable, DISABLE) ASTNODE_NODE_FUNCS(Disable, DISABLE)
virtual string name() const { return m_name; } // * = Block name virtual string name() const { return m_name; } // * = Block name
void name(const string& flag) { m_name=flag; } void name(const string& flag) { m_name=flag; }
virtual bool isPure() const { return false; } // SPECIAL: We don't process code after breaks virtual bool isBrancher() const { return true; } // SPECIAL: We don't process code after breaks
}; };
struct AstReturn : public AstNodeStmt { struct AstReturn : public AstNodeStmt {
@ -2073,7 +2073,7 @@ struct AstReturn : public AstNodeStmt {
virtual string verilogKwd() const { return "return"; }; virtual string verilogKwd() const { return "return"; };
virtual V3Hash sameHash() const { return V3Hash(); } virtual V3Hash sameHash() const { return V3Hash(); }
AstNode* lhsp() const { return op1p(); } AstNode* lhsp() const { return op1p(); }
virtual bool isPure() const { return false; } // SPECIAL: We don't process code after breaks virtual bool isBrancher() const { return true; } // SPECIAL: We don't process code after breaks
}; };
struct AstGenIf : public AstNodeIf { struct AstGenIf : public AstNodeIf {
@ -2145,7 +2145,7 @@ public:
virtual bool same(AstNode* samep) const { // Also same if identical tree structure all the way down, but hard to detect virtual bool same(AstNode* samep) const { // Also same if identical tree structure all the way down, but hard to detect
return labelp()==samep->castJumpGo()->labelp(); } return labelp()==samep->castJumpGo()->labelp(); }
virtual bool isGateOptimizable() const { return false; } virtual bool isGateOptimizable() const { return false; }
virtual bool isPure() const { return false; } // SPECIAL: We don't process code after breaks virtual bool isBrancher() const { return true; } // SPECIAL: We don't process code after breaks
AstJumpLabel* labelp() const { return m_labelp; } AstJumpLabel* labelp() const { return m_labelp; }
}; };

View File

@ -862,7 +862,7 @@ class GaterVisitor : public GaterBaseVisitor {
m_stmtVscp = NULL; m_stmtVscp = NULL;
m_stmtInPli = false; m_stmtInPli = false;
} }
if (!nodep->isPure()) { if (!nodep->isPure() || nodep->isBrancher()) {
// May also be a new statement (above if); if so we mark it immediately // May also be a new statement (above if); if so we mark it immediately
UINFO(9," NotPure "<<nodep<<endl); UINFO(9," NotPure "<<nodep<<endl);
scoreboardPli(nodep); scoreboardPli(nodep);

View File

@ -195,7 +195,8 @@ private:
// *** Special iterator // *** Special iterator
if (!m_isSimple) return; // Fastpath if (!m_isSimple) return; // Fastpath
if (!nodep->isGateOptimizable() if (!nodep->isGateOptimizable()
|| !nodep->isPure()) { || !nodep->isPure()
|| nodep->isBrancher()) {
UINFO(5, "Non optimizable type: "<<nodep<<endl); UINFO(5, "Non optimizable type: "<<nodep<<endl);
clearSimple("Non optimizable type"); clearSimple("Non optimizable type");
} }