mirror of
https://github.com/verilator/verilator.git
synced 2026-10-08 02:53:12 +02:00
Internals: Cleanup case condition lifting (#7768)
V3Begin used to lift impure case expressions. With V3LiftExpr, this is now redundant.
This commit is contained in:
+2
-30
@@ -61,7 +61,6 @@ class BeginVisitor final : public VNVisitor {
|
||||
// NODE STATE
|
||||
// AstCase::user1 -> bool, if already purified
|
||||
|
||||
V3UniqueNames m_caseTempNames; // For generating unique temporary variable names used by cases
|
||||
// STATE - across all visitors
|
||||
BeginState* const m_statep; // Current global state
|
||||
|
||||
@@ -75,7 +74,6 @@ class BeginVisitor final : public VNVisitor {
|
||||
string m_unnamedScope; // Name of begin blocks, including unnamed blocks
|
||||
int m_ifDepth = 0; // Current if depth
|
||||
bool m_keepBegins = false; // True if begins should not be inlined
|
||||
VDouble0 m_statPurifiedCaseExpr; // Count of purified case expressions
|
||||
|
||||
// METHODS
|
||||
|
||||
@@ -132,7 +130,6 @@ class BeginVisitor final : public VNVisitor {
|
||||
}
|
||||
void visit(AstNodeModule* nodep) override {
|
||||
VL_RESTORER(m_modp);
|
||||
VL_RESTORER(m_caseTempNames);
|
||||
m_modp = nodep;
|
||||
// Rename it (e.g. class under a generate)
|
||||
if (m_unnamedScope != "") {
|
||||
@@ -171,7 +168,6 @@ class BeginVisitor final : public VNVisitor {
|
||||
VL_RESTORER(m_liftedp);
|
||||
VL_RESTORER(m_namedScope);
|
||||
VL_RESTORER(m_unnamedScope);
|
||||
VL_RESTORER(m_caseTempNames);
|
||||
m_displayScope = dot(m_displayScope, nodep->name());
|
||||
m_namedScope = "";
|
||||
m_unnamedScope = "";
|
||||
@@ -415,29 +411,7 @@ class BeginVisitor final : public VNVisitor {
|
||||
// any BEGINs, but V3Coverage adds them all under the module itself.
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
void visit(AstCase* nodep) override {
|
||||
// Introduce temporary variable for AstCase if needed - it is done here and not in V3Case
|
||||
// because this phase is before V3Scope and V3Case is not. Doing it before V3Scope ensures
|
||||
// that V3Scope will take care of a scope creation
|
||||
if (!nodep->exprp()->isPure() && !nodep->user1SetOnce()) {
|
||||
++m_statPurifiedCaseExpr;
|
||||
FileLine* const fl = nodep->exprp()->fileline();
|
||||
AstVar* const varp = new AstVar{fl, VVarType::XTEMP, m_caseTempNames.get(nodep),
|
||||
nodep->exprp()->dtypep()};
|
||||
nodep->exprp(new AstExprStmt{fl,
|
||||
new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE},
|
||||
nodep->exprp()->unlinkFrBack()},
|
||||
new AstVarRef{fl, varp, VAccess::READ}});
|
||||
if (m_ftaskp) {
|
||||
varp->funcLocal(true);
|
||||
varp->lifetime(VLifetime::AUTOMATIC_EXPLICIT);
|
||||
m_ftaskp->stmtsp()->addHereThisAsNext(varp);
|
||||
} else {
|
||||
m_modp->stmtsp()->addHereThisAsNext(varp);
|
||||
}
|
||||
}
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
void visit(AstCase* nodep) override { iterateChildren(nodep); }
|
||||
// VISITORS - LINT CHECK
|
||||
void visit(AstIf* nodep) override { // not AstNodeIf; other types not covered
|
||||
VL_RESTORER(m_keepBegins);
|
||||
@@ -464,10 +438,8 @@ class BeginVisitor final : public VNVisitor {
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
BeginVisitor(AstNetlist* nodep, BeginState* statep)
|
||||
: m_caseTempNames{"__VCase"}
|
||||
, m_statep{statep} {
|
||||
: m_statep{statep} {
|
||||
iterate(nodep);
|
||||
V3Stats::addStatSum("Impure case expressions", m_statPurifiedCaseExpr);
|
||||
}
|
||||
~BeginVisitor() override = default;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user