address comments

This commit is contained in:
Edmund Lam 2026-06-11 09:57:10 -04:00
parent 59863f43dc
commit 28dbecbe8b
1 changed files with 22 additions and 27 deletions

View File

@ -1305,7 +1305,7 @@ class ParamProcessor final {
// Walk up any outer `.fieldN[.fieldM...]` chain (struct lparam // Walk up any outer `.fieldN[.fieldM...]` chain (struct lparam
// member access like `CFG::cfg.jt.cam_type`) and accumulate the // member access like `CFG::cfg.jt.cam_type`) and accumulate the
// packed-struct bit offset. Replace the topmost Dot with a // packed-struct bit offset. Replace the topmost Dot with a
// Sel(constp, lsb, width) that constify can fold. // Sel(constp, lsb, width) matching V3Width::memberSelStruct.
int totalLsb = 0; int totalLsb = 0;
int sliceWidth = varp->width(); int sliceWidth = varp->width();
AstNodeDType* curDTypep = varp->dtypep(); AstNodeDType* curDTypep = varp->dtypep();
@ -1318,14 +1318,8 @@ class ParamProcessor final {
AstNodeUOrStructDType* const structp AstNodeUOrStructDType* const structp
= VN_CAST(skippedp, NodeUOrStructDType); = VN_CAST(skippedp, NodeUOrStructDType);
if (!structp) break; if (!structp) break;
AstMemberDType* foundMemp = nullptr; AstMemberDType* const foundMemp = VN_CAST(
for (AstMemberDType* memp = structp->membersp(); memp; m_memberMap.findMember(structp, fieldRef->name()), MemberDType);
memp = VN_AS(memp->nextp(), MemberDType)) {
if (memp->name() == fieldRef->name()) {
foundMemp = memp;
break;
}
}
if (!foundMemp) break; if (!foundMemp) break;
totalLsb += foundMemp->lsb(); totalLsb += foundMemp->lsb();
sliceWidth = foundMemp->width(); sliceWidth = foundMemp->width();
@ -1340,9 +1334,10 @@ class ParamProcessor final {
AstConst* const clonep = static_cast<AstConst*>(constp->cloneTree(false)); AstConst* const clonep = static_cast<AstConst*>(constp->cloneTree(false));
AstSel* const selp AstSel* const selp
= new AstSel{topp->fileline(), clonep, totalLsb, sliceWidth}; = new AstSel{topp->fileline(), clonep, totalLsb, sliceWidth};
// Preserve the field's actual dtype (e.g. enum) on the Sel so // Match V3Width::memberSelStruct: skip RefDTypes to surface
// assignments to enum-typed pins don't trip ENUMVALUE. // enum dtype, and mark didWidth so V3Width doesn't reflatten.
if (curDTypep) selp->dtypep(curDTypep); if (curDTypep) selp->dtypep(curDTypep->skipRefToEnump());
selp->didWidth(true);
topp->replaceWith(selp); topp->replaceWith(selp);
VL_DO_DANGLING(topp->deleteTree(), topp); VL_DO_DANGLING(topp->deleteTree(), topp);
} }
@ -2254,21 +2249,21 @@ public:
while (!worklist.empty()) { while (!worklist.empty()) {
AstNode* const p = worklist.back(); AstNode* const p = worklist.back();
worklist.pop_back(); worklist.pop_back();
p->foreach([&](AstDot* dotp) { p->foreach([&](AstNode* np) {
if (VN_IS(dotp->lhsp(), ClassOrPackageRef)) dotps.push_back(dotp); if (AstDot* const dotp = VN_CAST(np, Dot)) {
}); if (VN_IS(dotp->lhsp(), ClassOrPackageRef)) dotps.push_back(dotp);
p->foreach([&](const AstRefDType* refp) { } else if (const AstRefDType* const refp = VN_CAST(np, RefDType)) {
AstTypedef* const tdefp = refp->typedefp(); AstTypedef* const tdefp = refp->typedefp();
if (tdefp && reachedTypedefs.insert(tdefp).second) { if (tdefp && reachedTypedefs.insert(tdefp).second) {
tdefps.push_back(tdefp); tdefps.push_back(tdefp);
if (tdefp->subDTypep()) worklist.push_back(tdefp->subDTypep()); if (tdefp->subDTypep()) worklist.push_back(tdefp->subDTypep());
} }
}); } else if (const AstVarRef* const refp = VN_CAST(np, VarRef)) {
p->foreach([&](const AstVarRef* refp) { AstVar* const varp = refp->varp();
AstVar* const varp = refp->varp(); if (varp && varp->varType() == VVarType::LPARAM && deferredVarps.count(varp)
if (varp && varp->varType() == VVarType::LPARAM && deferredVarps.count(varp) && reachedDeferred.insert(varp).second && varp->valuep()) {
&& reachedDeferred.insert(varp).second && varp->valuep()) { worklist.push_back(varp->valuep());
worklist.push_back(varp->valuep()); }
} }
}); });
} }