From b68e5ee66de491cfb6840a4a9a850f77465fa40f Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Tue, 24 Oct 2023 11:59:35 +0200 Subject: [PATCH] Move superReference to AstFuncRef and AstTaskRef Signed-off-by: Ryszard Rozak --- src/V3AstNodeExpr.h | 9 ++++++--- src/V3LinkDot.cpp | 10 +++++++++- src/V3Task.cpp | 7 ++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/V3AstNodeExpr.h b/src/V3AstNodeExpr.h index 50d90803fd..d026e5fccf 100644 --- a/src/V3AstNodeExpr.h +++ b/src/V3AstNodeExpr.h @@ -229,7 +229,6 @@ class AstNodeFTaskRef VL_NOT_FINAL : public AstNodeExpr { string m_dotted; // Dotted part of scope the name()ed task/func is under or "" string m_inlinedDots; // Dotted hierarchy flattened out bool m_pli = false; // Pli system call ($name) - bool m_superReference = false; // Called with super reference VIsCached m_purity; // Pure state protected: @@ -262,8 +261,6 @@ class AstNodeFTaskRef VL_NOT_FINAL : public AstNodeExpr { void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; } bool pli() const { return m_pli; } void pli(bool flag) { m_pli = flag; } - bool superReference() const { return m_superReference; } - void superReference(bool flag) { m_superReference = flag; } bool isPure() override; string emitVerilog() final override { V3ERROR_NA_RETURN(""); } @@ -4204,12 +4201,15 @@ class AstCNew final : public AstNodeCCall { // === AstNodeFTaskRef === class AstFuncRef final : public AstNodeFTaskRef { // A reference to a function + bool m_superReference = false; // Called with super reference public: AstFuncRef(FileLine* fl, AstParseRef* namep, AstNodeExpr* pinsp) : ASTGEN_SUPER_FuncRef(fl, (AstNode*)namep, pinsp) {} AstFuncRef(FileLine* fl, const string& name, AstNodeExpr* pinsp) : ASTGEN_SUPER_FuncRef(fl, name, pinsp) {} ASTGEN_MEMBERS_AstFuncRef; + bool superReference() const { return m_superReference; } + void superReference(bool flag) { m_superReference = flag; } }; class AstMethodCall final : public AstNodeFTaskRef { // A reference to a member task (or function) @@ -4246,6 +4246,7 @@ class AstNew final : public AstNodeFTaskRef { }; class AstTaskRef final : public AstNodeFTaskRef { // A reference to a task + bool m_superReference = false; // Called with super reference public: AstTaskRef(FileLine* fl, AstParseRef* namep, AstNodeExpr* pinsp) : ASTGEN_SUPER_TaskRef(fl, (AstNode*)namep, pinsp) { @@ -4256,6 +4257,8 @@ class AstTaskRef final : public AstNodeFTaskRef { dtypeSetVoid(); } ASTGEN_MEMBERS_AstTaskRef; + bool superReference() const { return m_superReference; } + void superReference(bool flag) { m_superReference = flag; } }; // === AstNodePreSel === diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index fef775115d..a3b5a350b6 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -3081,7 +3081,15 @@ class LinkDotResolveVisitor final : public VNVisitor { m_ds.init(m_curSymp); iterateChildren(nodep); } - if (m_ds.m_super) nodep->superReference(true); + + if (m_ds.m_super) { + if (AstFuncRef* const funcRefp = VN_CAST(nodep, FuncRef)) { + funcRefp->superReference(true); + } else if (AstTaskRef* const taskRefp = VN_CAST(nodep, TaskRef)) { + taskRefp->superReference(true); + } + } + bool staticAccess = false; if (m_ds.m_unresolvedClass) { // Unable to link before V3Param diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 922c6929bc..9bd96ef03f 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -637,7 +637,12 @@ class TaskVisitor final : public VNVisitor { ccallp->dtypeSetVoid(); beginp->addNext(ccallp->makeStmt()); } - ccallp->superReference(refp->superReference()); + + if (const AstFuncRef* const funcRefp = VN_CAST(refp, FuncRef)) { + ccallp->superReference(funcRefp->superReference()); + } else if (const AstTaskRef* const taskRefp = VN_CAST(refp, TaskRef)) { + ccallp->superReference(taskRefp->superReference()); + } // Convert complicated outputs to temp signals {