mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Optimize instance port connections by aliasing rather than by assignment (#8427)
Use AstAlias instead of AstAssignW in V3Inst port connection lowering, the same way as V3Inline would do if the instance is inlined. This closes some of the gap between -finline and -fno-inline behaviour, and is also required for moving V3Inline post scope, where it could not create aliases anymore (hence required for future patch to maintain current behaviour). This is also a partial fix to #4698 (only when the connected expression is a plain VarRef)
This commit is contained in:
+14
-1
@@ -2759,7 +2759,20 @@ private:
|
||||
UINFOTREE(9, nodep, "", "alias");
|
||||
AstVarScope* aliasVscp = nullptr;
|
||||
for (AstNode* itemp = nodep->itemsp(); itemp; itemp = itemp->nextp()) {
|
||||
AstVarScope* const vscp = VN_AS(itemp, VarRef)->varScopep();
|
||||
AstVarScope* vscp = nullptr;
|
||||
if (const AstVarRef* const refp = VN_CAST(itemp, VarRef)) {
|
||||
vscp = refp->varScopep();
|
||||
} else {
|
||||
// Reaches into the scope of an instance, look it up by name
|
||||
const AstVarXRef* const xrefp = VN_AS(itemp, VarXRef);
|
||||
const string scopename = xrefp->dotted() + "." + xrefp->name();
|
||||
string baddot;
|
||||
VSymEnt* okSymp;
|
||||
VSymEnt* const symp = m_statep->findDotted(xrefp->fileline(), m_modSymp, scopename,
|
||||
baddot, okSymp, false);
|
||||
UASSERT_OBJ(symp, nodep, "No symbol for alias item: " << scopename);
|
||||
vscp = VN_CAST(symp->nodep(), VarScope);
|
||||
}
|
||||
UASSERT_OBJ(vscp, nodep, "VarScope unset");
|
||||
if (aliasVscp) {
|
||||
setAliasVarScope(aliasVscp, vscp);
|
||||
|
||||
Reference in New Issue
Block a user