From 1c94fbb5d6376d6050f72eeafe0de0855fc0280d Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Fri, 25 Sep 2026 08:30:34 +0200 Subject: [PATCH] Internals: Remove code dead after recent refactoring (#8498) --- src/V3Dead.cpp | 53 ++++++----------------------------------- src/V3Inst.cpp | 7 +----- src/V3Interface.cpp | 58 ++++++++++++--------------------------------- src/V3LinkLevel.cpp | 14 ----------- 4 files changed, 23 insertions(+), 109 deletions(-) diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 824557341..a7ed9974c 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -798,48 +798,10 @@ class DeadVisitor final : public VNVisitor { } } - // cppcheck-suppress constParameterPointer - void preserveTopIfaces(AstNetlist* rootp) { - // cppcheck-suppress constVariablePointer - for (AstNodeModule* modp = rootp->modulesp(); modp && modp->isTop(); - modp = VN_AS(modp->nextp(), NodeModule)) { - for (AstNode* subnodep = modp->stmtsp(); subnodep; subnodep = subnodep->nextp()) { - if (AstVar* const varp = VN_CAST(subnodep, Var)) { - if (varp->isIfaceRef()) { - const AstNodeDType* const subtypep = varp->subDTypep(); - const AstIfaceRefDType* ifacerefp = nullptr; - if (VN_IS(subtypep, IfaceRefDType)) { - ifacerefp = VN_AS(varp->subDTypep(), IfaceRefDType); - } else if (VN_IS(subtypep, BracketArrayDType)) { - const AstBracketArrayDType* const arrp - = VN_AS(subtypep, BracketArrayDType); - const AstNodeDType* const arrsubtypep = arrp->subDTypep(); - if (VN_IS(arrsubtypep, IfaceRefDType)) { - ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); - } - } else if (VN_IS(subtypep, UnpackArrayDType)) { - const AstUnpackArrayDType* const arrp - = VN_AS(subtypep, UnpackArrayDType); - const AstNodeDType* const arrsubtypep = arrp->subDTypep(); - if (VN_IS(arrsubtypep, IfaceRefDType)) { - ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); - } - } - - if (ifacerefp && !ifacerefp->cellp() - && (ifacerefp->ifacep()->user1() == 0)) { - ifacerefp->ifacep()->user1(1); - } - } - } - } - } - } - public: // CONSTRUCTORS DeadVisitor(AstNetlist* nodep, bool elimUserVars, bool elimDTypes, bool elimScopes, - bool elimCells, bool elimTopIfaces, bool elimTasks) + bool elimCells, bool elimTasks) : m_elimUserVars{elimUserVars} , m_elimDTypes{elimDTypes} , m_elimCells{elimCells} @@ -874,7 +836,6 @@ public: if (elimCells) deadCheckCells(); deadCheckClasses(); // Modules after vars, because might be vars we delete inside a mod we delete - if (!elimTopIfaces) preserveTopIfaces(nodep); deadCheckMod(); // After deleting as much as can, demote some virtual functions @@ -901,32 +862,32 @@ public: void V3Dead::deadifyModules(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ":"); - { // node, elimUserVars, elimDTypes, elimScopes, elimCells, elimTopIfaces - DeadVisitor{nodep, false, false, false, false, !v3Global.opt.topIfacesSupported(), false}; + { // node, elimUserVars, elimDTypes, elimScopes, elimCells, elimTasks + DeadVisitor{nodep, false, false, false, false, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadModules", 0, dumpTreeEitherLevel() >= 6); } void V3Dead::deadifyDTypes(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ":"); - { DeadVisitor{nodep, false, true, false, false, false, true}; } // Destruct before checking + { DeadVisitor{nodep, false, true, false, false, true}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadDtypes", 0, dumpTreeEitherLevel() >= 3); } void V3Dead::deadifyDTypesScoped(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ":"); - { DeadVisitor{nodep, false, true, true, false, false, false}; } // Destruct before checking + { DeadVisitor{nodep, false, true, true, false, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadDtypesScoped", 0, dumpTreeEitherLevel() >= 3); } void V3Dead::deadifyAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ":"); - { DeadVisitor{nodep, true, true, false, true, false, true}; } // Destruct before checking + { DeadVisitor{nodep, true, true, false, true, true}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadAll", 0, dumpTreeEitherLevel() >= 3); } void V3Dead::deadifyAllScoped(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ":"); - { DeadVisitor{nodep, true, true, true, true, false, true}; } // Destruct before checking + { DeadVisitor{nodep, true, true, true, true, true}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadAllScoped", 0, dumpTreeEitherLevel() >= 3); } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 6c65c5700..c6ccb8ce3 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -149,12 +149,7 @@ class InstVisitor final : public VNVisitor { m_cellp->addNextHere(new AstAlways{assp}); UINFOTREE(9, assp, "", "_new"); } - } else if (nodep->modVarp()->isIfaceRef() - || (VN_IS(nodep->modVarp()->dtypep()->skipRefp(), UnpackArrayDType) - && VN_IS(VN_AS(nodep->modVarp()->dtypep()->skipRefp(), UnpackArrayDType) - ->subDTypep() - ->skipRefp(), - IfaceRefDType))) { + } else if (nodep->modVarp()->isIfaceRef()) { // Create an AstAliasScope for Vars to Cells so we can // link with their scope later AstNodeExpr* const lhsp = new AstVarXRef{exprp->fileline(), nodep->modVarp(), diff --git a/src/V3Interface.cpp b/src/V3Interface.cpp index 6be3361d5..044fe58d0 100644 --- a/src/V3Interface.cpp +++ b/src/V3Interface.cpp @@ -36,12 +36,11 @@ class InlineIntfRefVisitor final : public VNVisitor { // NODE STATE // AstVar::user1p() // AstCell which this Var points to const VNUser1InUse m_inuser1; - const VNUser2InUse m_inuser2; string m_scope; // Scope name // VISITORS - void visit(AstNetlist* nodep) override { iterateChildren(nodep->topModulep()); } + void visit(AstNetlist* nodep) override { iterateChildrenConst(nodep->topModulep()); } void visit(AstCell* nodep) override { VL_RESTORER_COPY(m_scope); if (m_scope.empty()) { @@ -56,60 +55,33 @@ class InlineIntfRefVisitor final : public VNVisitor { AstVar* const varp = pinp->modVarp(); const AstVarRef* const varrefp = VN_CAST(pinp->exprp(), VarRef); if (!varrefp) continue; + const AstVar* const fromVarp = varrefp->varp(); const AstIfaceRefDType* const irdtp = VN_CAST(fromVarp->dtypep(), IfaceRefDType); if (!irdtp) continue; - AstCell* cellp; - if ((cellp = VN_CAST(fromVarp->user1p(), Cell)) || (cellp = irdtp->cellp())) { - varp->user1p(cellp); - const string alias = m_scope + "__DOT__" + pinp->name(); - // Prefer the port's own dtype; the source may have no modport - const AstIfaceRefDType* const portIrdtp = VN_CAST(varp->dtypep(), IfaceRefDType); - const string modportName - = portIrdtp ? portIrdtp->modportName() : irdtp->modportName(); - cellp->addIntfRefsp( - new AstIntfRef{pinp->fileline(), alias, pinp->name(), modportName}); - } + AstCell* cellp = VN_CAST(fromVarp->user1p(), Cell); + if (!cellp) cellp = irdtp->cellp(); + if (!cellp) continue; + varp->user1p(cellp); + const string alias = m_scope + "__DOT__" + pinp->name(); + // Prefer the port's own dtype; the source may have no modport + const AstIfaceRefDType* const portIrdtp = VN_CAST(varp->dtypep(), IfaceRefDType); + const string modportName = portIrdtp ? portIrdtp->modportName() : irdtp->modportName(); + FileLine* const flp = pinp->fileline(); + cellp->addIntfRefsp(new AstIntfRef{flp, alias, pinp->name(), modportName}); } - iterateChildren(modp); - } - void visit(AstAliasScope* nodep) override { - // Reference - const AstVarRef* const reflp = VN_CAST(nodep->lhsp(), VarRef); - // What the reference refers to - const AstVarRef* const refrp = VN_CAST(nodep->rhsp(), VarRef); - if (!(reflp && refrp)) return; - - const AstVar* const varlp = reflp->varp(); - const AstVar* const varrp = refrp->varp(); - if (!(varlp && varrp)) return; - - AstCell* cellp = VN_CAST(varrp->user1p(), Cell); - if (!cellp) { - const AstIfaceRefDType* const irdtp = VN_CAST(varrp->dtypep(), IfaceRefDType); - if (!irdtp) return; - - cellp = irdtp->cellp(); - } - if (!cellp) return; - string alias; - if (!m_scope.empty()) alias = m_scope + "__DOT__"; - alias += varlp->name(); - const AstIfaceRefDType* const lirdtp = VN_CAST(varlp->dtypep(), IfaceRefDType); - const string modportName = lirdtp ? lirdtp->modportName() : ""; - cellp->addIntfRefsp( - new AstIntfRef{varlp->fileline(), alias, varlp->origName(), modportName}); + iterateChildrenConst(modp); } //-------------------- void visit(AstNodeExpr*) override {} // Accelerate void visit(AstNodeStmt*) override {} // Accelerate - void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } public: // CONSTRUCTORS - explicit InlineIntfRefVisitor(AstNode* nodep) { iterate(nodep); } + explicit InlineIntfRefVisitor(AstNode* nodep) { iterateConst(nodep); } ~InlineIntfRefVisitor() override = default; }; diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index 42493dd46..3d3f068e6 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -237,20 +237,6 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { } } } - if (VN_IS(subtypep, UnpackArrayDType)) { - const AstUnpackArrayDType* const arrp = VN_AS(subtypep, UnpackArrayDType); - const AstNodeDType* const arrsubtypep = arrp->subDTypep(); - if (VN_IS(arrsubtypep, IfaceRefDType)) { - const AstIfaceRefDType* const ifacerefp - = VN_AS(arrsubtypep, IfaceRefDType); - if (!ifacerefp->cellp()) { - if (!ioNames.insert(oldvarp->name()).second) { - // UINFO(8, "Multitop dup interface array found: " << oldvarp); - dupNames.insert(oldvarp->name()); - } - } - } - } } } }