Fix parameters referencing interface fields (#1593) (#5910)

This commit is contained in:
Ryszard Rozak
2025-04-02 09:43:12 -04:00
committed by GitHub
parent 6d1e82b908
commit 353a4b7b4a
9 changed files with 39 additions and 11 deletions
+3
View File
@@ -5742,6 +5742,7 @@ class AstVarXRef final : public AstNodeVarRef {
string m_name;
string m_dotted; // Dotted part of scope the name()'ed reference is under or ""
string m_inlinedDots; // Dotted hierarchy flattened out
bool m_containsGenBlock = false; // Contains gen block reference
public:
AstVarXRef(FileLine* fl, const string& name, const string& dotted, const VAccess& access)
: ASTGEN_SUPER_VarXRef(fl, nullptr, access)
@@ -5757,6 +5758,8 @@ public:
void dotted(const string& dotted) { m_dotted = dotted; }
string inlinedDots() const { return m_inlinedDots; }
void inlinedDots(const string& flag) { m_inlinedDots = flag; }
bool containsGenBlock() const { return m_containsGenBlock; }
void containsGenBlock(const bool flag) { m_containsGenBlock = flag; }
string emitVerilog() override { V3ERROR_NA_RETURN(""); }
string emitC() override { V3ERROR_NA_RETURN(""); }
bool cleanOut() const override { return true; }
+2
View File
@@ -2509,6 +2509,7 @@ AstNodeVarRef* AstNodeVarRef::varRefLValueRecurse(AstNode* nodep) {
void AstVarXRef::dump(std::ostream& str) const {
this->AstNodeVarRef::dump(str);
if (containsGenBlock()) str << " [GENBLK]";
str << ".=" << dotted() << " ";
if (inlinedDots() != "") str << " inline.=" << inlinedDots() << " - ";
if (varScopep()) {
@@ -2520,6 +2521,7 @@ void AstVarXRef::dump(std::ostream& str) const {
}
}
void AstVarXRef::dumpJson(std::ostream& str) const {
dumpJsonBoolFunc(str, containsGenBlock);
dumpJsonStrFunc(str, dotted);
dumpJsonStrFunc(str, inlinedDots);
dumpJsonGen(str);
+7
View File
@@ -2266,6 +2266,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
bool m_super; // Starts with super reference
bool m_unresolvedCell; // Unresolved cell, needs help from V3Param
bool m_unresolvedClass; // Unresolved class reference, needs help from V3Param
bool m_genBlk; // Contains gen block reference
AstNode* m_unlinkedScopep; // Unresolved scope, needs corresponding VarXRef
bool m_dotErr; // Error found in dotted resolution, ignore upwards
string m_dotText; // String of dotted names found in below parseref
@@ -2280,6 +2281,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
m_dotText = "";
m_unresolvedCell = false;
m_unresolvedClass = false;
m_genBlk = false;
m_unlinkedScopep = nullptr;
}
string ascii() const {
@@ -2295,6 +2297,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
if (m_super) sstr << " [super]";
if (m_unresolvedCell) sstr << " [unrCell]";
if (m_unresolvedClass) sstr << " [unrClass]";
if (m_genBlk) sstr << " [genBlk]";
sstr << " txt=" << m_dotText;
return sstr.str();
}
@@ -3075,6 +3078,9 @@ class LinkDotResolveVisitor final : public VNVisitor {
m_ds.m_dotText = VString::dot(m_ds.m_dotText, ".", nodep->name());
m_ds.m_dotSymp = foundp;
m_ds.m_dotPos = DP_SCOPE;
if (const AstBegin* const beginp = VN_CAST(foundp->nodep(), Begin)) {
if (beginp->generate()) m_ds.m_genBlk = true;
}
// Upper AstDot visitor will handle it from here
} else if (VN_IS(foundp->nodep(), Cell) && allowVar) {
AstCell* const cellp = VN_AS(foundp->nodep(), Cell);
@@ -3135,6 +3141,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
= new AstVarXRef{nodep->fileline(), nodep->name(), m_ds.m_dotText,
VAccess::READ}; // lvalue'ness computed later
refp->varp(varp);
refp->containsGenBlock(m_ds.m_genBlk);
if (varp->attrSplitVar()) {
refp->v3warn(
SPLITVAR,
+4 -1
View File
@@ -1292,7 +1292,10 @@ class ParamVisitor final : public VNVisitor {
}
}
}
nodep->varp(nullptr); // Needs relink, as may remove pointed-to var
if (nodep->containsGenBlock()) {
// Needs relink, as may remove pointed-to var
nodep->varp(nullptr);
}
}
void visit(AstDot* nodep) override {