From 9caa79a7eac1fd9164c5ff69602dbaab1f4e0663 Mon Sep 17 00:00:00 2001 From: Krzysztof Bieganski Date: Thu, 3 Aug 2023 08:52:52 +0200 Subject: [PATCH] Internals: Remove the name field from `AstVarRef` (#4395) --- src/V3Ast.cpp | 6 +- src/V3Ast.h | 8 +-- src/V3AstInlines.h | 10 +++- src/V3AstNodeDType.h | 4 +- src/V3AstNodeExpr.h | 22 ++++---- src/V3AstNodeOther.h | 2 +- src/V3AstNodes.cpp | 10 +++- src/V3Begin.cpp | 42 ++------------ src/V3EmitCBase.h | 2 +- src/V3EmitCImp.cpp | 5 +- src/V3Gate.cpp | 4 +- src/V3Inline.cpp | 1 - src/V3LinkDot.cpp | 62 ++++++++++----------- src/V3LinkParse.cpp | 10 ++-- src/V3Name.cpp | 7 +-- src/V3ParseGrammar.cpp | 7 ++- src/V3Split.cpp | 6 +- src/V3Task.cpp | 1 - src/V3Timing.cpp | 2 +- src/V3Tristate.cpp | 5 +- src/verilog.y | 12 ++-- test_regress/t/t_xml_flat.out | 18 +++--- test_regress/t/t_xml_flat_no_inline_mod.out | 4 +- test_regress/t/t_xml_flat_pub_mod.out | 4 +- test_regress/t/t_xml_flat_vlvbound.out | 8 +-- 25 files changed, 110 insertions(+), 152 deletions(-) diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 5a9ea2275..4242138db 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -125,9 +125,7 @@ string AstNode::encodeNumber(int64_t num) { } } -string AstNode::nameProtect() const VL_MT_STABLE { - return VIdProtect::protectIf(name(), protect()); -} +string AstNode::nameProtect() const { return VIdProtect::protectIf(name(), protect()); } string AstNode::origNameProtect() const { return VIdProtect::protectIf(origName(), protect()); } string AstNode::shortName() const { @@ -285,7 +283,7 @@ string AstNode::vpiName(const string& namein) { return pretty; } -string AstNode::prettyTypeName() const VL_MT_STABLE { +string AstNode::prettyTypeName() const { if (name() == "") return typeName(); return std::string{typeName()} + " '" + prettyName() + "'"; } diff --git a/src/V3Ast.h b/src/V3Ast.h index db79c7ba4..1be69f7cb 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1686,7 +1686,7 @@ public: static constexpr int INSTR_COUNT_PLI = 20; // PLI routines // ACCESSORS - virtual string name() const VL_MT_STABLE { return ""; } + virtual string name() const { return ""; } virtual string origName() const { return ""; } virtual void name(const string& name) { this->v3fatalSrc("name() called on object without name() method"); @@ -1694,7 +1694,7 @@ public: virtual void tag(const string& text) {} virtual string tag() const { return ""; } virtual string verilogKwd() const { return ""; } - string nameProtect() const VL_MT_STABLE; // Name with --protect-id applied + string nameProtect() const; // Name with --protect-id applied string origNameProtect() const; // origName with --protect-id applied string shortName() const; // Name with __PVT__ removed for concatenating scopes static string dedotName(const string& namein); // Name with dots removed @@ -1707,10 +1707,10 @@ public: static string encodeName(const string& namein); static string encodeNumber(int64_t num); // Encode number into internal C representation static string vcdName(const string& namein); // Name for printing out to vcd files - string prettyName() const VL_MT_STABLE { return prettyName(name()); } + string prettyName() const { return prettyName(name()); } string prettyNameQ() const { return prettyNameQ(name()); } // "VARREF" for error messages (NOT dtype's pretty name) - string prettyTypeName() const VL_MT_STABLE; + string prettyTypeName() const; virtual string prettyOperatorName() const { return "operator " + prettyTypeName(); } FileLine* fileline() const VL_MT_SAFE { return m_fileline; } void fileline(FileLine* fl) { m_fileline = fl; } diff --git a/src/V3AstInlines.h b/src/V3AstInlines.h index d2325c14b..cff4fd9e5 100644 --- a/src/V3AstInlines.h +++ b/src/V3AstInlines.h @@ -154,12 +154,15 @@ AstCExpr::AstCExpr(FileLine* fl, const string& textStmt, int setwidth, bool clea } AstVarRef::AstVarRef(FileLine* fl, AstVar* varp, const VAccess& access) - : ASTGEN_SUPER_VarRef(fl, varp->name(), varp, access) {} + : ASTGEN_SUPER_VarRef(fl, varp, access) {} // This form only allowed post-link (see above) AstVarRef::AstVarRef(FileLine* fl, AstVarScope* varscp, const VAccess& access) - : ASTGEN_SUPER_VarRef(fl, varscp->varp()->name(), varscp->varp(), access) { + : ASTGEN_SUPER_VarRef(fl, varscp->varp(), access) { varScopep(varscp); } + +string AstVarRef::name() const { return varp() ? varp()->name() : ""; } + bool AstVarRef::same(const AstVarRef* samep) const { if (varScopep()) { return (varScopep() == samep->varScopep() && access() == samep->access()); @@ -179,7 +182,8 @@ bool AstVarRef::sameNoLvalue(AstVarRef* samep) const { } AstVarXRef::AstVarXRef(FileLine* fl, AstVar* varp, const string& dotted, const VAccess& access) - : ASTGEN_SUPER_VarXRef(fl, varp->name(), varp, access) + : ASTGEN_SUPER_VarXRef(fl, varp, access) + , m_name{varp->name()} , m_dotted{dotted} { dtypeFrom(varp); } diff --git a/src/V3AstNodeDType.h b/src/V3AstNodeDType.h index 80e597e87..981cb1810 100644 --- a/src/V3AstNodeDType.h +++ b/src/V3AstNodeDType.h @@ -126,13 +126,13 @@ public: const char* charIQWN() const { return (isString() ? "N" : isWide() ? "W" : isQuad() ? "Q" : "I"); } - string cType(const string& name, bool forFunc, bool isRef) const VL_MT_STABLE; + string cType(const string& name, bool forFunc, bool isRef) const; // Represents a C++ LiteralType? (can be constexpr) bool isLiteralType() const VL_MT_STABLE; private: class CTypeRecursed; - CTypeRecursed cTypeRecurse(bool compound) const VL_MT_STABLE; + CTypeRecursed cTypeRecurse(bool compound) const; }; class AstNodeArrayDType VL_NOT_FINAL : public AstNodeDType { // Array data type, ie "some_dtype var_name [2:0]" diff --git a/src/V3AstNodeExpr.h b/src/V3AstNodeExpr.h index e537dc879..73aa5a3df 100644 --- a/src/V3AstNodeExpr.h +++ b/src/V3AstNodeExpr.h @@ -450,20 +450,17 @@ class AstNodeVarRef VL_NOT_FINAL : public AstNodeExpr { AstVar* m_varp; // [AfterLink] Pointer to variable itself AstVarScope* m_varScopep = nullptr; // Varscope for hierarchy AstNodeModule* m_classOrPackagep = nullptr; // Package hierarchy - string m_name; // Name of variable string m_selfPointer; // Output code object pointer (e.g.: 'this') protected: - AstNodeVarRef(VNType t, FileLine* fl, const string& name, const VAccess& access) + AstNodeVarRef(VNType t, FileLine* fl, const VAccess& access) : AstNodeExpr{t, fl} - , m_access{access} - , m_name{name} { + , m_access{access} { varp(nullptr); } - AstNodeVarRef(VNType t, FileLine* fl, const string& name, AstVar* varp, const VAccess& access) + AstNodeVarRef(VNType t, FileLine* fl, AstVar* varp, const VAccess& access) : AstNodeExpr{t, fl} - , m_access{access} - , m_name{name} { + , m_access{access} { // May have varp==nullptr this->varp(varp); } @@ -474,8 +471,6 @@ public: const char* broken() const override; int instrCount() const override { return widthInstrs(); } void cloneRelink() override; - string name() const override VL_MT_STABLE { return m_name; } // * = Var name - void name(const string& name) override { m_name = name; } VAccess access() const { return m_access; } void access(const VAccess& flag) { m_access = flag; } // Avoid using this; Set in constructor AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable @@ -5355,15 +5350,15 @@ public: class AstVarRef final : public AstNodeVarRef { // A reference to a variable (lvalue or rvalue) public: - AstVarRef(FileLine* fl, const string& name, const VAccess& access) - : ASTGEN_SUPER_VarRef(fl, name, nullptr, access) {} // This form only allowed post-link because output/wire compression may // lead to deletion of AstVar's inline AstVarRef(FileLine* fl, AstVar* varp, const VAccess& access); // This form only allowed post-link (see above) inline AstVarRef(FileLine* fl, AstVarScope* varscp, const VAccess& access); ASTGEN_MEMBERS_AstVarRef; + inline string name() const override; // * = Var name void dump(std::ostream& str) const override; + const char* broken() const override; bool same(const AstNode* samep) const override; inline bool same(const AstVarRef* samep) const; inline bool sameNoLvalue(AstVarRef* samep) const; @@ -5375,14 +5370,17 @@ public: class AstVarXRef final : public AstNodeVarRef { // A VarRef to something in another module before AstScope. // Includes pin on a cell, as part of a ASSIGN statement to connect I/Os until AstScope + string m_name; string m_dotted; // Dotted part of scope the name()'ed reference is under or "" string m_inlinedDots; // Dotted hierarchy flattened out public: AstVarXRef(FileLine* fl, const string& name, const string& dotted, const VAccess& access) - : ASTGEN_SUPER_VarXRef(fl, name, nullptr, access) + : ASTGEN_SUPER_VarXRef(fl, nullptr, access) + , m_name{name} , m_dotted{dotted} {} inline AstVarXRef(FileLine* fl, AstVar* varp, const string& dotted, const VAccess& access); ASTGEN_MEMBERS_AstVarXRef; + string name() const override VL_MT_STABLE { return m_name; } // * = Var name void dump(std::ostream& str) const override; string dotted() const { return m_dotted; } void dotted(const string& dotted) { m_dotted = dotted; } diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index 1d2507024..e58185966 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -1812,7 +1812,7 @@ public: string dpiTmpVarType(const string& varName) const; // Return Verilator internal type for argument: CData, SData, IData, WData string vlArgType(bool named, bool forReturn, bool forFunc, const string& namespc = "", - bool asRef = false) const VL_MT_STABLE; + bool asRef = false) const; string vlEnumType() const; // Return VerilatorVarType: VLVT_UINT32, etc string vlEnumDir() const; // Return VerilatorVarDir: VLVD_INOUT, etc string vlPropDecl(const string& propName) const; // Return VerilatorVarProps declaration diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 3281dc81e..ad31bc0f4 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -378,7 +378,7 @@ string AstVar::verilogKwd() const { } string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string& namespc, - bool asRef) const VL_MT_STABLE { + bool asRef) const { UASSERT_OBJ(!forReturn, this, "Internal data is never passed as return, but as first argument"); string ostatic; @@ -695,12 +695,12 @@ public: } }; -string AstNodeDType::cType(const string& name, bool /*forFunc*/, bool isRef) const VL_MT_STABLE { +string AstNodeDType::cType(const string& name, bool /*forFunc*/, bool isRef) const { const CTypeRecursed info = cTypeRecurse(false); return info.render(name, isRef); } -AstNodeDType::CTypeRecursed AstNodeDType::cTypeRecurse(bool compound) const VL_MT_STABLE { +AstNodeDType::CTypeRecursed AstNodeDType::cTypeRecurse(bool compound) const { // Legacy compound argument currently just passed through and unused CTypeRecursed info; @@ -2076,6 +2076,10 @@ void AstVarRef::dump(std::ostream& str) const { str << "UNLINKED"; } } +const char* AstVarRef::broken() const { + BROKEN_RTN(!varp()); + return AstNodeVarRef::broken(); +} bool AstVarRef::same(const AstNode* samep) const { return same(static_cast(samep)); } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index d18f4be1d..abe27a1dc 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -40,39 +40,6 @@ VL_DEFINE_DEBUG_FUNCTIONS; //###################################################################### -class RenameStaticVisitor final : public VNVisitor { -private: - // STATE - const std::set& m_staticFuncVarsr; // Static variables from m_ftaskp - AstNodeFTask* const m_ftaskp; // Current function/task - - // VISITORS - void visit(AstVarRef* nodep) override { - const auto it = m_staticFuncVarsr.find(nodep->varp()); - if (it != m_staticFuncVarsr.end()) nodep->name((*it)->name()); - iterateChildren(nodep); - } - - void visit(AstInitialStatic* nodep) override { - iterateChildren(nodep); - nodep->unlinkFrBack(); - m_ftaskp->addHereThisAsNext(nodep); - } - - void visit(AstNode* nodep) override { iterateChildren(nodep); } - -public: - // CONSTRUCTORS - RenameStaticVisitor(std::set& staticFuncVars, AstNodeFTask* ftaskp, AstNode* nodep) - : m_staticFuncVarsr(staticFuncVars) - , m_ftaskp(ftaskp) { - iterateChildren(nodep); - } - ~RenameStaticVisitor() override = default; -}; - -//###################################################################### - class BeginState final { private: // NODE STATE @@ -105,7 +72,6 @@ private: string m_unnamedScope; // Name of begin blocks, including unnamed blocks int m_ifDepth = 0; // Current if depth bool m_keepBegins = false; // True if begins should not be inlined - std::set m_staticFuncVars; // Static variables from m_ftaskp // METHODS @@ -212,7 +178,10 @@ private: m_ftaskp = nodep; m_liftedp = nullptr; iterateChildren(nodep); - RenameStaticVisitor{m_staticFuncVars, m_ftaskp, nodep}; + nodep->foreach([&](AstInitialStatic* const initp) { + initp->unlinkFrBack(); + m_ftaskp->addHereThisAsNext(initp); + }); if (m_liftedp) { // Place lifted nodes at beginning of stmtsp, so Var nodes appear before referenced if (AstNode* const stmtsp = nodep->stmtsp()) { @@ -222,7 +191,6 @@ private: nodep->addStmtsp(m_liftedp); m_liftedp = nullptr; } - m_staticFuncVars.clear(); m_ftaskp = nullptr; } } @@ -266,7 +234,6 @@ private: nodep->name(newName); nodep->unlinkFrBack(); m_ftaskp->addHereThisAsNext(nodep); - m_staticFuncVars.insert(nodep); nodep->funcLocal(false); } else if (m_unnamedScope != "") { // Rename it @@ -377,7 +344,6 @@ private: void visit(AstVarRef* nodep) override { if (nodep->varp()->user1()) { // It was converted UINFO(9, " relinVarRef " << nodep << endl); - nodep->name(nodep->varp()->name()); } iterateChildren(nodep); } diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index 4be6b7b91..88fa6cae6 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -62,7 +62,7 @@ public: static string symClassAssign() { return symClassName() + "* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;\n"; } - static string prefixNameProtect(const AstNode* nodep) VL_MT_STABLE { // C++ name with prefix + static string prefixNameProtect(const AstNode* nodep) { // C++ name with prefix return v3Global.opt.modPrefix() + "_" + VIdProtect::protect(nodep->name()); } static bool isAnonOk(const AstVar* varp) { diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index 571388b44..e11daab55 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -147,7 +147,7 @@ class EmitCGatherDependencies final : VNVisitorConst { } public: - static const std::set gather(AstCFunc* cfuncp) VL_MT_STABLE { + static const std::set gather(AstCFunc* cfuncp) { const EmitCGatherDependencies visitor{cfuncp}; return std::move(visitor.m_dependencies); } @@ -566,8 +566,7 @@ class EmitCImp final : EmitCFunc { ~EmitCImp() override = default; public: - static void main(const AstNodeModule* modp, bool slow, - std::deque& cfilesr) VL_MT_STABLE { + static void main(const AstNodeModule* modp, bool slow, std::deque& cfilesr) { EmitCImp{modp, slow, cfilesr}; } }; diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 252a68ce4..09ff35046 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -176,9 +176,7 @@ public: , m_slow{slow} {} ~GateLogicVertex() override = default; // ACCESSORS - string name() const override VL_MT_STABLE { - return (cvtToHex(m_nodep) + "@" + scopep()->prettyName()); - } + string name() const override { return (cvtToHex(m_nodep) + "@" + scopep()->prettyName()); } string dotColor() const override { return "purple"; } FileLine* fileline() const override { return nodep()->fileline(); } AstNode* nodep() const { return m_nodep; } diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 43aac0fa4..e97ce6ec6 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -384,7 +384,6 @@ private: nodep->v3fatalSrc("Null connection?"); } } - nodep->name(nodep->varp()->name()); } void visit(AstVarXRef* nodep) override { // Track what scope it was originally under so V3LinkDot can resolve it diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 20379ad40..4b43c4fbb 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2065,40 +2065,38 @@ private: } m_ds; // State to preserve across recursions // METHODS - Variables - void createImplicitVar(VSymEnt* /*lookupSymp*/, AstVarRef* nodep, AstNodeModule* modp, - VSymEnt* moduleSymp, bool noWarn) { + AstVar* createImplicitVar(VSymEnt* /*lookupSymp*/, AstParseRef* nodep, AstNodeModule* modp, + VSymEnt* moduleSymp, bool noWarn) { // Create implicit after warning - if (!nodep->varp()) { - if (!noWarn) { - if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) { - const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), - LinkNodeMatcherVar{}); - nodep->v3error("Signal definition not found, and implicit disabled with " - "`default_nettype: " - << nodep->prettyNameQ() << '\n' - << (suggest.empty() ? "" : nodep->warnMore() + suggest)); + if (!noWarn) { + if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) { + const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), + LinkNodeMatcherVar{}); + nodep->v3error("Signal definition not found, and implicit disabled with " + "`default_nettype: " + << nodep->prettyNameQ() << '\n' + << (suggest.empty() ? "" : nodep->warnMore() + suggest)); - } - // Bypass looking for suggestions if IMPLICIT is turned off - // as there could be thousands of these suppressed in large netlists - else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) { - const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), - LinkNodeMatcherVar{}); - nodep->v3warn(IMPLICIT, - "Signal definition not found, creating implicitly: " - << nodep->prettyNameQ() << '\n' - << (suggest.empty() ? "" : nodep->warnMore() + suggest)); - } } - AstVar* const newp = new AstVar{nodep->fileline(), VVarType::WIRE, nodep->name(), - VFlagLogicPacked{}, 1}; - newp->trace(modp->modTrace()); - nodep->varp(newp); - modp->addStmtsp(newp); - // Link it to signal list, must add the variable under the module; - // current scope might be lower now - m_statep->insertSym(moduleSymp, newp->name(), newp, nullptr /*classOrPackagep*/); + // Bypass looking for suggestions if IMPLICIT is turned off + // as there could be thousands of these suppressed in large netlists + else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) { + const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), + LinkNodeMatcherVar{}); + nodep->v3warn(IMPLICIT, + "Signal definition not found, creating implicitly: " + << nodep->prettyNameQ() << '\n' + << (suggest.empty() ? "" : nodep->warnMore() + suggest)); + } } + AstVar* const newp + = new AstVar{nodep->fileline(), VVarType::WIRE, nodep->name(), VFlagLogicPacked{}, 1}; + newp->trace(modp->modTrace()); + modp->addStmtsp(newp); + // Link it to signal list, must add the variable under the module; + // current scope might be lower now + m_statep->insertSym(moduleSymp, newp->name(), newp, nullptr /*classOrPackagep*/); + return newp; } AstVar* foundToVarp(const VSymEnt* symp, AstNode* nodep, VAccess access) { // Return a variable if possible, auto converting a modport to variable @@ -2844,11 +2842,11 @@ private: if (checkImplicit) { // Create if implicit, and also if error (so only complain once) // Else if a scope is allowed, making a signal won't help error cascade + auto varp = createImplicitVar(m_curSymp, nodep, m_modp, m_modSymp, err); AstVarRef* const newp - = new AstVarRef{nodep->fileline(), nodep->name(), VAccess::READ}; + = new AstVarRef{nodep->fileline(), varp, VAccess::READ}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); - createImplicitVar(m_curSymp, newp, m_modp, m_modSymp, err); } } } diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 84be83294..117104a30 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -370,9 +370,11 @@ private: // Making an AstAssign (vs AstAssignW) to a wire is an error, suppress it FileLine* const newfl = new FileLine{fl}; newfl->warnOff(V3ErrorCode::PROCASSWIRE, true); - auto* const assp - = new AstAssign{newfl, new AstVarRef{newfl, nodep->name(), VAccess::WRITE}, - VN_AS(nodep->valuep()->unlinkFrBack(), NodeExpr)}; + // Create a ParseRef to the wire. We cannot use the var as it may be deleted if + // it's a port (see t_var_set_link.v) + auto* const assp = new AstAssign{ + newfl, new AstParseRef{newfl, VParseRefExp::PX_TEXT, nodep->name()}, + VN_AS(nodep->valuep()->unlinkFrBack(), NodeExpr)}; if (nodep->lifetime().isAutomatic()) { nodep->addNextHere(new AstInitialAutomatic{newfl, assp}); } else { @@ -381,7 +383,7 @@ private: } // 4. Under blocks, it's an initial value to be under an assign else { nodep->addNextHere( - new AstAssign{fl, new AstVarRef{fl, nodep->name(), VAccess::WRITE}, + new AstAssign{fl, new AstVarRef{fl, nodep, VAccess::WRITE}, VN_AS(nodep->valuep()->unlinkFrBack(), NodeExpr)}); } } diff --git a/src/V3Name.cpp b/src/V3Name.cpp index cf4bec4f0..fc532f498 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -89,12 +89,7 @@ private: rename(nodep, false); } } - void visit(AstVarRef* nodep) override { - if (nodep->varp()) { - iterate(nodep->varp()); - nodep->name(nodep->varp()->name()); - } - } + void visit(AstVarRef* nodep) override { iterate(nodep->varp()); } void visit(AstCell* nodep) override { if (!nodep->user1()) { rename(nodep, (!nodep->modp()->modPublic() && !VN_IS(nodep->modp(), ClassPackage))); diff --git a/src/V3ParseGrammar.cpp b/src/V3ParseGrammar.cpp index f2f7f7949..74b729abc 100644 --- a/src/V3ParseGrammar.cpp +++ b/src/V3ParseGrammar.cpp @@ -85,9 +85,10 @@ AstArg* V3ParseGrammar::argWrapList(AstNodeExpr* nodep) { } AstNode* V3ParseGrammar::createSupplyExpr(FileLine* fileline, const string& name, int value) { - AstAssignW* assignp = new AstAssignW{fileline, new AstVarRef{fileline, name, VAccess::WRITE}, - value ? new AstConst{fileline, AstConst::All1{}} - : new AstConst{fileline, AstConst::All0{}}}; + AstAssignW* assignp + = new AstAssignW{fileline, new AstParseRef{fileline, VParseRefExp::PX_TEXT, name}, + value ? new AstConst{fileline, AstConst::All1{}} + : new AstConst{fileline, AstConst::All0{}}}; AstStrengthSpec* strengthSpecp = new AstStrengthSpec{fileline, VStrength::SUPPLY, VStrength::SUPPLY}; assignp->strengthSpecp(strengthSpecp); diff --git a/src/V3Split.cpp b/src/V3Split.cpp index c937deb08..cbabdbffc 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -109,9 +109,7 @@ protected: // ACCESSORS // Do not make accessor for nodep(), It may change due to // reordering a lower block, but we don't repair it - string name() const override VL_MT_STABLE { - return cvtToHex(m_nodep) + ' ' + m_nodep->prettyTypeName(); - } + string name() const override { return cvtToHex(m_nodep) + ' ' + m_nodep->prettyTypeName(); } FileLine* fileline() const override { return nodep()->fileline(); } public: @@ -148,7 +146,7 @@ public: SplitVarPostVertex(V3Graph* graphp, AstNode* nodep) : SplitNodeVertex{graphp, nodep} {} ~SplitVarPostVertex() override = default; - string name() const override VL_MT_STABLE { return string{"POST "} + SplitNodeVertex::name(); } + string name() const override { return string{"POST "} + SplitNodeVertex::name(); } string dotColor() const override { return "CadetBlue"; } }; diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 1ab29ea06..11fce0631 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -412,7 +412,6 @@ private: AstVarScope* const newvscp = VN_AS(refp->varp()->user2p(), VarScope); refp->varScopep(newvscp); refp->varp(refp->varScopep()->varp()); - refp->name(refp->varp()->name()); } }); } diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index d24dfeb9b..ab099d647 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -96,7 +96,7 @@ private: AstNode* const m_nodep; // AST node represented by this graph vertex // ACCESSORS - string name() const override VL_MT_STABLE { + string name() const override { if (m_classp) { if (VN_IS(nodep(), CFunc)) { return cvtToHex(nodep()) + ' ' + classp()->name() + "::" + nodep()->name(); diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index ee0eeb271..6ad090603 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -154,7 +154,7 @@ public: // ACCESSORS AstNode* nodep() const VL_MT_STABLE { return m_nodep; } const AstVar* varp() const { return VN_CAST(nodep(), Var); } - string name() const override VL_MT_STABLE { + string name() const override { return ((isTristate() ? "tri\\n" : feedsTri() ? "feed\\n" : "-\\n") @@ -672,8 +672,7 @@ class TristateVisitor final : public TristateBaseVisitor { VFlagBitPacked{}, w}; // 2-state ok; sep enable UINFO(9, " newout " << newLhsp << endl); nodep->addStmtsp(newLhsp); - refp->varp(newLhsp); // assign the new var to the varref - refp->name(newLhsp->name()); + refp->varp(newLhsp); // create a new var for this drivers enable signal AstVar* const newEnLhsp = new AstVar{varp->fileline(), VVarType::MODULETEMP, diff --git a/src/verilog.y b/src/verilog.y index bb0b15139..08cd48cdc 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -2251,7 +2251,7 @@ tf_variable_identifier: // IEEE: part of list_of_tf_variable_ide id variable_dimensionListE sigAttrListE exprEqE { $$ = VARDONEA($1, *$1, $2, $3); if ($4) AstNode::addNext( - $$, new AstAssign{$4->fileline(), new AstVarRef{$1, *$1, VAccess::WRITE}, $4}); } + $$, new AstAssign{$4->fileline(), new AstParseRef{$1, VParseRefExp::PX_TEXT, *$1}, $4}); } ; variable_declExpr: // IEEE: part of variable_decl_assignment - rhs of expr @@ -2995,7 +2995,7 @@ netSig: // IEEE: net_decl_assignment - one element from { $$ = VARDONEA($1, *$1, nullptr, $2); } | netId sigAttrListE '=' expr { $$ = VARDONEA($1, *$1, nullptr, $2); - auto* const assignp = new AstAssignW{$3, new AstVarRef{$1, *$1, VAccess::WRITE}, $4}; + auto* const assignp = new AstAssignW{$3, new AstParseRef{$1, VParseRefExp::PX_TEXT, *$1}, $4}; if (GRAMMARP->m_netStrengthp) assignp->strengthSpecp(GRAMMARP->m_netStrengthp->cloneTree(false)); AstNode::addNext($$, assignp); } | netId variable_dimensionList sigAttrListE @@ -3912,14 +3912,14 @@ for_initializationItem: // IEEE: variable_assignment + for_varia AstVar* const varp = VARDONEA($2, *$2, nullptr, nullptr); varp->lifetime(VLifetime::AUTOMATIC); $$ = varp; - $$->addNext(new AstAssign{$3, new AstVarRef{$2, *$2, VAccess::WRITE}, $4}); } + $$->addNext(new AstAssign{$3, new AstParseRef{$2, VParseRefExp::PX_TEXT, *$2}, $4}); } // // IEEE-2012: | yVAR data_type idAny/*new*/ '=' expr { VARRESET_NONLIST(VAR); VARDTYPE($2); AstVar* const varp = VARDONEA($3, *$3, nullptr, nullptr); varp->lifetime(VLifetime::AUTOMATIC); $$ = varp; - $$->addNext(new AstAssign{$4, new AstVarRef{$3, *$3, VAccess::WRITE}, $5}); } + $$->addNext(new AstAssign{$4, new AstParseRef{$3, VParseRefExp::PX_TEXT, *$3}, $5}); } // // IEEE: variable_assignment // // UNSUP variable_lvalue below | varRefBase '=' expr { $$ = new AstAssign{$2, $1, $3}; } @@ -5614,8 +5614,8 @@ idArrayedForeach: // IEEE: id + select (under foreach expression) ; // VarRef without any dots or vectorizaion -varRefBase: - id { $$ = new AstVarRef{$1, *$1, VAccess::READ}; } +varRefBase: + id { $$ = new AstParseRef{$1, VParseRefExp::PX_TEXT, *$1}; } ; // ParseRef diff --git a/test_regress/t/t_xml_flat.out b/test_regress/t/t_xml_flat.out index d7ec257c2..e17361489 100644 --- a/test_regress/t/t_xml_flat.out +++ b/test_regress/t/t_xml_flat.out @@ -53,27 +53,27 @@ - + - + - + - + - + - + @@ -88,15 +88,15 @@ - + - + - + diff --git a/test_regress/t/t_xml_flat_no_inline_mod.out b/test_regress/t/t_xml_flat_no_inline_mod.out index 228c0e8f2..d39485a05 100644 --- a/test_regress/t/t_xml_flat_no_inline_mod.out +++ b/test_regress/t/t_xml_flat_no_inline_mod.out @@ -25,11 +25,11 @@ - + - + diff --git a/test_regress/t/t_xml_flat_pub_mod.out b/test_regress/t/t_xml_flat_pub_mod.out index e659f2ba4..6257a743a 100644 --- a/test_regress/t/t_xml_flat_pub_mod.out +++ b/test_regress/t/t_xml_flat_pub_mod.out @@ -25,11 +25,11 @@ - + - + diff --git a/test_regress/t/t_xml_flat_vlvbound.out b/test_regress/t/t_xml_flat_vlvbound.out index 214b2626a..006f33f89 100644 --- a/test_regress/t/t_xml_flat_vlvbound.out +++ b/test_regress/t/t_xml_flat_vlvbound.out @@ -43,19 +43,19 @@ - + - + - + - +