From e023113b79ddf14df0650dd7f7e87eb7b0b5d095 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sun, 22 Feb 2026 09:15:28 +0000 Subject: [PATCH] Internals: Carry 'with' clause as op4 on AstNodeFTaskRef (#7114) op4 is now available to carry the 'with' clause explicitly instead of being part of the argument lit. Will strengthen 'pinsp' to be List[AstArg] next. --- src/V3AstNodeExpr.h | 7 +- src/V3EmitV.cpp | 7 ++ src/V3LinkDot.cpp | 15 +++-- src/V3LinkLValue.cpp | 1 + src/V3Randomize.cpp | 24 ++----- src/V3SplitVar.cpp | 1 + src/V3Task.cpp | 1 - src/V3Width.cpp | 100 ++++++++++++++--------------- test_regress/t/t_debug_emitv.out | 1 + test_regress/t/t_debug_emitv.v | 2 + test_regress/t/t_dump_json.out | 44 ++++++------- test_regress/t/t_json_only_tag.out | 2 +- 12 files changed, 100 insertions(+), 105 deletions(-) diff --git a/src/V3AstNodeExpr.h b/src/V3AstNodeExpr.h index 8deb4943b..8be56ec77 100644 --- a/src/V3AstNodeExpr.h +++ b/src/V3AstNodeExpr.h @@ -219,8 +219,9 @@ public: }; class AstNodeFTaskRef VL_NOT_FINAL : public AstNodeExpr { // A reference to a task (or function) - // op2 used by some sub-types only - // @astgen op3 := pinsp : List[AstNodeExpr] + // op1 used by some sub-types only + // @astgen op2 := pinsp : List[AstNodeExpr] + // @astgen op3 := withp : Optional[AstWith] // @astgen op4 := scopeNamep : Optional[AstScopeName] // // @astgen ptr := m_taskp : Optional[AstNodeFTask] // [AfterLink] Pointer to task referenced @@ -4503,7 +4504,7 @@ public: class AstMethodCall final : public AstNodeFTaskRef { // A reference to a member task (or function) // Don't need the class we are extracting from, as the "fromp()"'s datatype can get us to it - // @astgen op2 := fromp : AstNodeExpr + // @astgen op1 := fromp : AstNodeExpr // public: AstMethodCall(FileLine* fl, AstNodeExpr* fromp, VFlagChildDType, const string& name, diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 4724e5f6d..cc64c3419 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -1014,6 +1014,7 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public VNVisitorConst { puts("("); iterateAndNextConstNull(nodep->pinsp()); puts(")"); + iterateConstNull(nodep->withp()); } } void visit(AstCCall* nodep) override { @@ -1023,6 +1024,12 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public VNVisitorConst { puts(")"); } void visit(AstArg* nodep) override { iterateAndNextConstNull(nodep->exprp()); } + void visit(AstWith* nodep) override { + putfs(nodep, "with ("); + iterateConstNull(nodep->exprp()); + puts(") "); + } + void visit(AstLambdaArgRef* nodep) override { putfs(nodep, nodep->name()); } void visit(AstPrintTimeScale* nodep) override { puts(nodep->verilogKwd()); puts(";\n"); diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index a9c12cce6..ea91b9914 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2016,7 +2016,7 @@ class LinkDotFindVisitor final : public VNVisitor { AstLambdaArgRef* const valueArgRefp = new AstLambdaArgRef{argFl, name, false}; AstWith* const newp = new AstWith{nodep->fileline(), indexArgRefp, valueArgRefp, exprOrConstraintsp}; - funcrefp->addPinsp(newp); + funcrefp->withp(newp); } funcrefp->addPinsp(argp); nodep->replaceWith(nodep->funcrefp()->unlinkFrBack()); @@ -4765,7 +4765,7 @@ class LinkDotResolveVisitor final : public VNVisitor { VL_RESTORER(m_randMethodCallp); { m_ds.init(m_curSymp); - if (nodep->name() == "randomize" && nodep->pinsp()) { + if (nodep->name() == "randomize" && (nodep->pinsp() || nodep->withp())) { m_randMethodCallp = nodep; const AstNodeDType* fromDtp = nodep->fromp()->dtypep(); if (!fromDtp) { @@ -4775,7 +4775,7 @@ class LinkDotResolveVisitor final : public VNVisitor { fromDtp = getExprDTypep(nodep->fromp()); } if (!fromDtp) { - if (VN_IS(nodep->pinsp(), With)) { + if (nodep->withp()) { nodep->v3warn( E_UNSUPPORTED, "Unsupported: 'randomize() with' on complex expressions"); @@ -4889,10 +4889,11 @@ class LinkDotResolveVisitor final : public VNVisitor { // Found a Var, everything following is method call. // {scope}.{var}.HERE {method} ( ARGS ) AstNodeExpr* const varEtcp = VN_AS(m_ds.m_dotp->lhsp()->unlinkFrBack(), NodeExpr); - AstNodeExpr* argsp = nullptr; - if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext(); - AstNode* const newp = new AstMethodCall{nodep->fileline(), varEtcp, VFlagChildDType{}, - nodep->name(), argsp}; + AstNodeExpr* const argsp = nodep->pinsp(); + if (argsp) argsp->unlinkFrBackWithNext(); + AstMethodCall* const newp = new AstMethodCall{nodep->fileline(), varEtcp, + VFlagChildDType{}, nodep->name(), argsp}; + if (AstWith* const withp = nodep->withp()) newp->withp(withp->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index 272a2d3c7..9258d7fa4 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -336,6 +336,7 @@ class LinkLValueVisitor final : public VNVisitor { iterate(pinp); } } + if (nodep->withp()) iterate(nodep->withp()); } void visit(AstConstraint* nodep) override { VL_RESTORER(m_setIfRand); diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index f3fa98379..647f6407d 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -167,7 +167,6 @@ class RandomizeMarkVisitor final : public VNVisitor { if (!m_inStdWith || !m_stdRandCallp) return false; for (AstNode* pinp = m_stdRandCallp->pinsp(); pinp; pinp = pinp->nextp()) { - if (VN_IS(pinp, With)) continue; const AstArg* const argp = VN_CAST(pinp, Arg); if (!argp) continue; const AstNodeExpr* exprp = argp->exprp(); @@ -693,11 +692,7 @@ class RandomizeMarkVisitor final : public VNVisitor { void visit(AstWith* nodep) override { VL_RESTORER(m_withp); m_withp = nodep; - for (AstNode* pinp = m_stdRandCallp ? m_stdRandCallp->pinsp() : nullptr; pinp; - pinp = pinp->nextp()) { - AstWith* const withp = VN_CAST(pinp, With); - if (withp == nodep) m_inStdWith = true; - } + if (m_stdRandCallp && nodep == m_stdRandCallp->withp()) m_inStdWith = true; iterateChildrenConst(nodep); m_inStdWith = false; } @@ -3646,10 +3641,7 @@ class RandomizeVisitor final : public VNVisitor { new AstConst{nodep->fileline(), AstConst::WidthedValue{}, 32, 1}}); std::unique_ptr withCapturep; int argn = 0; - AstWith* withp = nullptr; - for (AstNode* pinp = nodep->pinsp(); pinp; pinp = pinp->nextp()) { - if ((withp = VN_CAST(pinp, With))) break; - } + AstWith* const withp = nodep->withp(); for (const AstNode* pinp = nodep->pinsp(); pinp; pinp = pinp->nextp()) { const AstArg* const argp = VN_CAST(pinp, Arg); if (!argp) continue; @@ -3722,14 +3714,8 @@ class RandomizeVisitor final : public VNVisitor { = new AstAnd{fl, new AstVarRef{fl, fvarp, VAccess::READ}, solverCallp}; randomizeFuncp->addStmtsp( new AstAssign{fl, new AstVarRef{fl, fvarp, VAccess::WRITE}, andExprp}); - } - // Remove With nodes from pins as they have been processed - for (AstNode* pinp = nodep->pinsp(); pinp;) { - AstNode* const nextp = pinp->nextp(); - if (VN_IS(pinp, With)) { - VL_DO_DANGLING(pinp->unlinkFrBack()->deleteTree(), pinp); - } - pinp = nextp; + // Remove With nodes as processed + VL_DO_DANGLING(withp->unlinkFrBack()->deleteTree(), withp); } // Replace the node with a call to that function nodep->name(randomizeFuncp->name()); @@ -3743,7 +3729,7 @@ class RandomizeVisitor final : public VNVisitor { } handleRandomizeArgs(nodep); - AstWith* const withp = VN_CAST(nodep->pinsp(), With); + AstWith* const withp = nodep->withp(); if (!withp) { iterateChildren(nodep); wrapRandomizeCallWithNullGuard(nodep); diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index a1c7c53b9..a21c2b554 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -505,6 +505,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { } m_foundTargetVar.clear(); } + if (nodep->withp()) iterate(nodep->withp()); } void visit(AstPin* nodep) override { UINFO(5, nodep->modVarp()->prettyNameQ() << " pin "); diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 7d50e2a17..d1ca861e9 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -1777,7 +1777,6 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp, bool reorganize = false; for (AstNode *nextp, *pinp = nodep->pinsp(); pinp; pinp = nextp) { nextp = pinp->nextp(); - if (VN_IS(pinp, With)) continue; AstArg* const argp = VN_AS(pinp, Arg); UASSERT_OBJ(argp, pinp, "Non-arg under ftask reference"); if (argp->name() != "") { diff --git a/src/V3Width.cpp b/src/V3Width.cpp index a61a0904e..89fb36b0b 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -3611,7 +3611,7 @@ class WidthVisitor final : public VNVisitor { // Should check types the method requires, but at present we don't do much userIterate(nodep->fromp(), WidthVP{SELF, BOTH}.p()); // Args are checked within each particular method's decode - // Any AstWith is checked later when know types, in methodWithArgument + // Any AstWith is checked later when know types, in methodWithClause // Find the fromp dtype - should be a class UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression"); AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); @@ -3652,18 +3652,16 @@ class WidthVisitor final : public VNVisitor { nodep->dtypeSetVoid(); } } - AstWith* methodWithArgument(AstNodeFTaskRef* nodep, bool required, bool arbReturn, - AstNodeDType* returnDtp, AstNodeDType* indexDtp, - AstNodeDType* valueDtp) { + AstWith* methodWithClause(AstNodeFTaskRef* nodep, bool required, bool arbReturn, + AstNodeDType* returnDtp, AstNodeDType* indexDtp, + AstNodeDType* valueDtp) { UASSERT_OBJ(arbReturn || returnDtp, nodep, "Null return type"); - for (AstNode* pinp = nodep->pinsp(); pinp; pinp = pinp->nextp()) { - if (AstWith* const withp = VN_CAST(pinp, With)) { - withp->indexArgRefp()->dtypep(indexDtp); - withp->valueArgRefp()->dtypep(valueDtp); - userIterate(withp, WidthVP{returnDtp, BOTH}.p()); - withp->unlinkFrBack(); - return withp; - } + if (AstWith* const withp = nodep->withp()) { + withp->indexArgRefp()->dtypep(indexDtp); + withp->valueArgRefp()->dtypep(valueDtp); + userIterate(withp, WidthVP{returnDtp, BOTH}.p()); + withp->unlinkFrBack(); + return withp; } if (required) { nodep->v3error("'with' statement is required for ." << nodep->prettyName() @@ -3673,13 +3671,11 @@ class WidthVisitor final : public VNVisitor { } void methodOkArguments(AstNodeFTaskRef* nodep, int minArg, int maxArg) { int narg = 0; + if (AstWith* const withp = nodep->withp()) { + withp->v3error("'with' not legal on this method"); + VL_DO_DANGLING(pushDeletep(withp->unlinkFrBack()), withp); + } for (AstNode* argp = nodep->pinsp(); argp; argp = argp->nextp()) { - if (VN_IS(argp, With)) { - argp->v3error("'with' not legal on this method"); - // Delete all arguments as nextp() otherwise dangling - VL_DO_DANGLING(pushDeletep(argp->unlinkFrBackWithNext()), argp); - break; - } ++narg; UASSERT_OBJ(VN_IS(argp, Arg), nodep, "Method arg without Arg type"); } @@ -3859,8 +3855,8 @@ class WidthVisitor final : public VNVisitor { || nodep->name() == "sum" || nodep->name() == "product") { // All value return AstWith* const withp - = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - adtypep->findStringDType(), adtypep->subDTypep()); + = methodWithClause(nodep, false, false, adtypep->subDTypep(), + adtypep->findStringDType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -3877,8 +3873,8 @@ class WidthVisitor final : public VNVisitor { } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last") { AstWith* const withp - = methodWithArgument(nodep, true, false, nodep->findBitDType(), - adtypep->findStringDType(), adtypep->subDTypep()); + = methodWithClause(nodep, true, false, nodep->findBitDType(), + adtypep->findStringDType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -3952,8 +3948,8 @@ class WidthVisitor final : public VNVisitor { } else if (nodep->name() == "and" || nodep->name() == "or" || nodep->name() == "xor" || nodep->name() == "sum" || nodep->name() == "product") { // All value return - AstWith* const withp = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - adtypep->keyDTypep(), adtypep->subDTypep()); + AstWith* const withp = methodWithClause(nodep, false, false, adtypep->subDTypep(), + adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -3962,7 +3958,7 @@ class WidthVisitor final : public VNVisitor { if (!nodep->firstAbovep()) newp->dtypeSetVoid(); } else if (nodep->name() == "min" || nodep->name() == "max" || nodep->name() == "unique" || nodep->name() == "unique_index") { - AstWith* const withp = methodWithArgument( + AstWith* const withp = methodWithClause( nodep, false, true, nullptr, nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -3976,8 +3972,8 @@ class WidthVisitor final : public VNVisitor { if (!nodep->firstAbovep()) newp->dtypeSetVoid(); } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last") { - AstWith* const withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - adtypep->keyDTypep(), adtypep->subDTypep()); + AstWith* const withp = methodWithClause(nodep, true, false, nodep->findBitDType(), + adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -3986,8 +3982,8 @@ class WidthVisitor final : public VNVisitor { if (!nodep->firstAbovep()) newp->dtypeSetVoid(); } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { - AstWith* const withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - adtypep->keyDTypep(), adtypep->subDTypep()); + AstWith* const withp = methodWithClause(nodep, true, false, nodep->findBitDType(), + adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -4080,8 +4076,8 @@ class WidthVisitor final : public VNVisitor { || nodep->name() == "rsort") { AstWith* withp = nullptr; if (nodep->name() == "sort" || nodep->name() == "rsort") { - withp = methodWithArgument(nodep, false, true, nullptr, nodep->findUInt32DType(), - adtypep->subDTypep()); + withp = methodWithClause(nodep, false, true, nullptr, nodep->findUInt32DType(), + adtypep->subDTypep()); } methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); @@ -4090,7 +4086,7 @@ class WidthVisitor final : public VNVisitor { newp->dtypeSetVoid(); } else if (nodep->name() == "min" || nodep->name() == "max" || nodep->name() == "unique" || nodep->name() == "unique_index") { - AstWith* const withp = methodWithArgument( + AstWith* const withp = methodWithClause( nodep, false, true, nullptr, nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -4105,8 +4101,8 @@ class WidthVisitor final : public VNVisitor { } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last" || nodep->name() == "find_index") { AstWith* const withp - = methodWithArgument(nodep, true, false, nodep->findBitDType(), - nodep->findUInt32DType(), adtypep->subDTypep()); + = methodWithClause(nodep, true, false, nodep->findBitDType(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -4116,8 +4112,8 @@ class WidthVisitor final : public VNVisitor { } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { AstWith* const withp - = methodWithArgument(nodep, true, false, nodep->findBitDType(), - nodep->findUInt32DType(), adtypep->subDTypep()); + = methodWithClause(nodep, true, false, nodep->findBitDType(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -4161,8 +4157,8 @@ class WidthVisitor final : public VNVisitor { || nodep->name() == "sum" || nodep->name() == "product") { // All value return AstWith* const withp - = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - nodep->findUInt32DType(), adtypep->subDTypep()); + = methodWithClause(nodep, false, false, adtypep->subDTypep(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -4262,8 +4258,8 @@ class WidthVisitor final : public VNVisitor { } else if (nodep->name() == "and" || nodep->name() == "or" || nodep->name() == "xor" || nodep->name() == "sum" || nodep->name() == "product") { AstWith* const withp - = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - nodep->findUInt32DType(), adtypep->subDTypep()); + = methodWithClause(nodep, false, false, adtypep->subDTypep(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -4410,8 +4406,8 @@ class WidthVisitor final : public VNVisitor { if (nodep->name() == "randomize") { VL_RESTORER(m_randomizeFromp); m_randomizeFromp = nodep->fromp(); - withp = methodWithArgument(nodep, false, false, adtypep->findVoidDType(), - adtypep->findBitDType(), adtypep); + withp = methodWithClause(nodep, false, false, adtypep->findVoidDType(), + adtypep->findBitDType(), adtypep); for (AstNode* pinp = nodep->pinsp(); pinp; pinp = pinp->nextp()) { if (AstArg* const argp = VN_CAST(pinp, Arg)) { if (argp->exprp()) userIterate(argp->exprp(), WidthVP{SELF, BOTH}.p()); @@ -4476,7 +4472,7 @@ class WidthVisitor final : public VNVisitor { } nodep->dtypeSetVoid(); } - if (withp) nodep->addPinsp(withp); + if (withp) nodep->withp(withp); processFTaskRefArgs(nodep); } return; @@ -4583,8 +4579,8 @@ class WidthVisitor final : public VNVisitor { if (methodId) { AstWith* const withp - = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - nodep->findUInt32DType(), adtypep->subDTypep()); + = methodWithClause(nodep, false, false, adtypep->subDTypep(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); if (withp) { methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -6937,13 +6933,13 @@ class WidthVisitor final : public VNVisitor { if (nodep->classOrPackagep() && nodep->classOrPackagep()->name() == "std") { v3Global.useRandomizeMethods(true); AstNodeDType* const adtypep = nodep->findBitDType(); - withp = methodWithArgument(nodep, false, false, adtypep->findVoidDType(), - adtypep->findBitDType(), adtypep); + withp = methodWithClause(nodep, false, false, adtypep->findVoidDType(), + adtypep->findBitDType(), adtypep); for (const AstNode* argp = nodep->pinsp(); argp; argp = argp->nextp()) userIterateAndNext(VN_AS(argp, Arg)->exprp(), WidthVP{SELF, BOTH}.p()); handleStdRandomizeArgs(nodep); // Provided args should be in current scope processFTaskRefArgs(nodep); - nodep->addPinsp(withp); + if (withp) nodep->withp(withp); nodep->didWidth(true); return; } @@ -6952,8 +6948,8 @@ class WidthVisitor final : public VNVisitor { AstClassRefDType* const adtypep = new AstClassRefDType{nodep->fileline(), classp, nullptr}; v3Global.rootp()->typeTablep()->addTypesp(adtypep); - withp = methodWithArgument(nodep, false, false, adtypep->findVoidDType(), - adtypep->findBitDType(), adtypep); + withp = methodWithClause(nodep, false, false, adtypep->findVoidDType(), + adtypep->findBitDType(), adtypep); for (const AstNode* argp = nodep->pinsp(); argp; argp = argp->nextp()) userIterateAndNext(VN_AS(argp, Arg)->exprp(), WidthVP{SELF, BOTH}.p()); handleRandomizeArgs(nodep, classp); @@ -6991,7 +6987,7 @@ class WidthVisitor final : public VNVisitor { } UASSERT_OBJ(nodep->taskp(), nodep, "Unlinked"); if (nodep->didWidth()) { - nodep->addPinsp(withp); + if (withp) nodep->withp(withp); return; } if ((nodep->taskp()->classMethod() && !nodep->taskp()->isStatic()) @@ -7022,7 +7018,7 @@ class WidthVisitor final : public VNVisitor { } // And do the arguments to the task/function too processFTaskRefArgs(nodep); - nodep->addPinsp(withp); + if (withp) nodep->withp(withp); nodep->didWidth(true); // See steps that follow in visit(AstFuncRef*) } diff --git a/test_regress/t/t_debug_emitv.out b/test_regress/t/t_debug_emitv.out index 0f4a63db9..744f7cc7d 100644 --- a/test_regress/t/t_debug_emitv.out +++ b/test_regress/t/t_debug_emitv.out @@ -291,6 +291,7 @@ module Vt_debug_emitv_t; sum = $random('sha); sum = $urandom(); sum = $urandom('sha); + sum = array.r_sum(with ((item * 'sh2)) ); if ((PKG_PARAM != 'sh1)) begin $stop; end diff --git a/test_regress/t/t_debug_emitv.v b/test_regress/t/t_debug_emitv.v index c12165806..674b3537a 100644 --- a/test_regress/t/t_debug_emitv.v +++ b/test_regress/t/t_debug_emitv.v @@ -229,6 +229,8 @@ module t (/*AUTOARG*/ sum = $urandom; sum = $urandom(10); + sum = array.sum with (item * 2); + if (Pkg::PKG_PARAM != 1) $stop; sub.r = 62.0; diff --git a/test_regress/t/t_dump_json.out b/test_regress/t/t_dump_json.out index 401c38059..ab18c80c9 100644 --- a/test_regress/t/t_dump_json.out +++ b/test_regress/t/t_dump_json.out @@ -1316,7 +1316,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(WT)","loc":"d,45:14,45:21","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(XT)","loc":"d,45:22,45:26","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(XT)","loc":"d,45:22,45:26","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ]} ],"scopeNamep": []}, @@ -1348,7 +1348,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(JU)","loc":"d,50:30,50:37","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(KU)","loc":"d,50:38,50:42","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(KU)","loc":"d,50:38,50:42","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ @@ -1365,7 +1365,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(PU)","loc":"d,51:15,51:22","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(QU)","loc":"d,51:23,51:27","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(QU)","loc":"d,51:23,51:27","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ @@ -1386,7 +1386,7 @@ "exprp": [ {"type":"PARSEREF","name":"message","addr":"(YU)","loc":"d,52:25,52:32","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ]} - ],"scopeNamep": []} + ],"withp": [],"scopeNamep": []} ]} ]} ],"scopeNamep": []}, @@ -1414,7 +1414,7 @@ "rhsp": [ {"type":"LT","name":"","addr":"(IV)","loc":"d,57:33,57:34","dtypep":"(YE)", "lhsp": [ - {"type":"FUNCREF","name":"num","addr":"(JV)","loc":"d,57:27,57:30","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"num","addr":"(JV)","loc":"d,57:27,57:30","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ], "rhsp": [ {"type":"PARSEREF","name":"m_bound","addr":"(KV)","loc":"d,57:35,57:42","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} @@ -1437,7 +1437,7 @@ "exprp": [ {"type":"PARSEREF","name":"message","addr":"(RV)","loc":"d,58:27,58:34","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ]} - ],"scopeNamep": []} + ],"withp": [],"scopeNamep": []} ]} ]}, {"type":"RETURN","name":"","addr":"(SV)","loc":"d,59:9,59:15", @@ -1468,7 +1468,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(DW)","loc":"d,66:14,66:21","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(EW)","loc":"d,66:22,66:26","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(EW)","loc":"d,66:22,66:26","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ @@ -1486,7 +1486,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(KW)","loc":"d,67:15,67:22","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(LW)","loc":"d,67:23,67:27","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(LW)","loc":"d,67:23,67:27","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ @@ -1502,7 +1502,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(PW)","loc":"d,69:17,69:24","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"pop_front","addr":"(QW)","loc":"d,69:25,69:34","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"pop_front","addr":"(QW)","loc":"d,69:25,69:34","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "lhsp": [ @@ -1522,7 +1522,7 @@ "condp": [ {"type":"GT","name":"","addr":"(XW)","loc":"d,74:17,74:18","dtypep":"(YE)", "lhsp": [ - {"type":"FUNCREF","name":"num","addr":"(YW)","loc":"d,74:11,74:14","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"num","addr":"(YW)","loc":"d,74:11,74:14","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ], "rhsp": [ {"type":"CONST","name":"?32?sh0","addr":"(ZW)","loc":"d,74:19,74:20","dtypep":"(N)"} @@ -1538,7 +1538,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(DX)","loc":"d,75:19,75:26","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"pop_front","addr":"(EX)","loc":"d,75:27,75:36","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"pop_front","addr":"(EX)","loc":"d,75:27,75:36","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "lhsp": [ @@ -1572,7 +1572,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(RX)","loc":"d,83:14,83:21","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(SX)","loc":"d,83:22,83:26","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(SX)","loc":"d,83:22,83:26","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ @@ -1590,7 +1590,7 @@ {"type":"PARSEREF","name":"m_queue","addr":"(YX)","loc":"d,84:15,84:22","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(ZX)","loc":"d,84:23,84:27","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(ZX)","loc":"d,84:23,84:27","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ @@ -1626,7 +1626,7 @@ "condp": [ {"type":"GT","name":"","addr":"(LY)","loc":"d,91:17,91:18","dtypep":"(YE)", "lhsp": [ - {"type":"FUNCREF","name":"num","addr":"(MY)","loc":"d,91:11,91:14","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"num","addr":"(MY)","loc":"d,91:11,91:14","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ], "rhsp": [ {"type":"CONST","name":"?32?sh0","addr":"(NY)","loc":"d,91:19,91:20","dtypep":"(N)"} @@ -1853,7 +1853,7 @@ {"type":"REFDTYPE","name":"process","addr":"(YBB)","loc":"d,143:7,143:14","dtypep":"UNLINKED","typedefp":"UNLINKED","refDTypep":"UNLINKED","classOrPackagep":"UNLINKED","typeofp": [],"classOrPackageOpp": [],"paramsp": []} ],"delayp": [], "valuep": [ - {"type":"NEW","name":"new","addr":"(ZBB)","loc":"d,143:19,143:22","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"NEW","name":"new","addr":"(ZBB)","loc":"d,143:19,143:22","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ],"attrsp": []}, {"type":"CSTMTUSER","name":"","addr":"(ACB)","loc":"d,145:7,145:9", "nodesp": [ @@ -1915,7 +1915,7 @@ "exprp": [ {"type":"PARSEREF","name":"KILLED","addr":"(BDB)","loc":"d,165:18,165:24","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ]} - ],"scopeNamep": []} + ],"withp": [],"scopeNamep": []} ]} ],"scopeNamep": []}, {"type":"TASK","name":"suspend","addr":"(CDB)","loc":"d,168:19,168:26","cname":"suspend","fvarp": [],"classOrPackagep": [], @@ -1939,7 +1939,7 @@ "exprp": [ {"type":"PARSEREF","name":"RUNNING","addr":"(MDB)","loc":"d,173:18,173:25","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ]} - ],"scopeNamep": []} + ],"withp": [],"scopeNamep": []} ]} ],"scopeNamep": []}, {"type":"TASK","name":"await","addr":"(NDB)","loc":"d,176:10,176:15","cname":"await","fvarp": [],"classOrPackagep": [], @@ -1950,7 +1950,7 @@ "lhsp": [ {"type":"EQ","name":"","addr":"(QDB)","loc":"d,178:22,178:24","dtypep":"(YE)", "lhsp": [ - {"type":"FUNCREF","name":"status","addr":"(RDB)","loc":"d,178:13,178:19","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"status","addr":"(RDB)","loc":"d,178:13,178:19","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ], "rhsp": [ {"type":"PARSEREF","name":"FINISHED","addr":"(SDB)","loc":"d,178:25,178:33","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} @@ -1959,7 +1959,7 @@ "rhsp": [ {"type":"EQ","name":"","addr":"(TDB)","loc":"d,178:46,178:48","dtypep":"(YE)", "lhsp": [ - {"type":"FUNCREF","name":"status","addr":"(UDB)","loc":"d,178:37,178:43","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"status","addr":"(UDB)","loc":"d,178:37,178:43","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ], "rhsp": [ {"type":"PARSEREF","name":"KILLED","addr":"(VDB)","loc":"d,178:49,178:55","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} @@ -1990,7 +1990,7 @@ {"type":"PARSEREF","name":"processQueue","addr":"(FEB)","loc":"d,184:14,184:26","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"size","addr":"(GEB)","loc":"d,184:27,184:31","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"size","addr":"(GEB)","loc":"d,184:27,184:31","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ @@ -2008,11 +2008,11 @@ {"type":"PARSEREF","name":"processQueue","addr":"(MEB)","loc":"d,185:9,185:21","dtypep":"UNLINKED","lhsp": [],"ftaskrefp": []} ], "rhsp": [ - {"type":"FUNCREF","name":"pop_back","addr":"(NEB)","loc":"d,185:22,185:30","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"FUNCREF","name":"pop_back","addr":"(NEB)","loc":"d,185:22,185:30","dtypep":"UNLINKED","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ], "rhsp": [ - {"type":"TASKREF","name":"kill","addr":"(OEB)","loc":"d,185:33,185:37","dtypep":"(WU)","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"scopeNamep": []} + {"type":"TASKREF","name":"kill","addr":"(OEB)","loc":"d,185:33,185:37","dtypep":"(WU)","dotted":"","taskp":"UNLINKED","classOrPackagep":"UNLINKED","pinsp": [],"withp": [],"scopeNamep": []} ]} ]} ]} diff --git a/test_regress/t/t_json_only_tag.out b/test_regress/t/t_json_only_tag.out index b2948b339..9e10ef7f2 100644 --- a/test_regress/t/t_json_only_tag.out +++ b/test_regress/t/t_json_only_tag.out @@ -43,7 +43,7 @@ "exprp": [ {"type":"CONST","name":"\\\"\\001\\002\\003\\004\\005\\006\\007\\010\\t\\n\\013\\014\\r\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\033\\034\\035\\036\\037 !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\177\\200\\201\\202\\203\\204\\205\\206\\207\\210\\211\\212\\213\\214\\215\\216\\217\\220\\221\\222\\223\\224\\225\\226\\227\\230\\231\\232\\233\\234\\235\\236\\237\\240\\241\\242\\243\\244\\245\\246\\247\\250\\251\\252\\253\\254\\255\\256\\257\\260\\261\\262\\263\\264\\265\\266\\267\\270\\271\\272\\273\\274\\275\\276\\277\\300\\301\\302\\303\\304\\305\\306\\307\\310\\311\\312\\313\\314\\315\\316\\317\\320\\321\\322\\323\\324\\325\\326\\327\\330\\331\\332\\333\\334\\335\\336\\337\\340\\341\\342\\343\\344\\345\\346\\347\\350\\351\\352\\353\\354\\355\\356\\357\\360\\361\\362\\363\\364\\365\\366\\367\\370\\371\\372\\373\\374\\375\\376\\377\\\"","addr":"(LB)","loc":"d,41:9,41:736","dtypep":"(BB)"} ]} - ],"scopeNamep": []} + ],"withp": [],"scopeNamep": []} ]} ]} ]}