Add --autoflush option

This commit is contained in:
Wilson Snyder
2008-07-16 14:06:08 -04:00
parent f0a06182ca
commit 4591f35b7c
11 changed files with 82 additions and 9 deletions
+23
View File
@@ -23,6 +23,9 @@
// For each wide OP, make a a temporary variable with the wide value
// For each deep expression, assign expression to temporary.
//
// Each display (independant transformation; here as Premit is a good point)
// If autoflush, insert a flush
//
//*************************************************************************
#include "config_build.h"
@@ -264,6 +267,26 @@ private:
checkNode(nodep);
}
// Autoflush
virtual void visit(AstDisplay* nodep, AstNUser* vup) {
startStatement(nodep);
nodep->iterateChildren(*this);
m_stmtp = NULL;
if (v3Global.opt.autoflush()) {
AstNode* searchp = nodep->nextp();
while (searchp && searchp->castComment()) searchp = searchp->nextp();
if (searchp
&& searchp->castDisplay()
&& nodep->filep()->sameTree(searchp->castDisplay()->filep())) {
// There's another display next; we can just wait to flush
} else {
UINFO(4,"Autoflush "<<nodep<<endl);
nodep->addNextHere(new AstFFlush(nodep->fileline(),
nodep->filep()->cloneTree(true)));
}
}
}
//--------------------
// Default: Just iterate
virtual void visit(AstVar* nodep, AstNUser*) {} // Don't hit varrefs under vars