From 85b05366bc25277f46d625ca74ec6d4c16f97045 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 31 Oct 2020 09:24:16 -0400 Subject: [PATCH] Internals: Misc prep work for 'with' support. --- src/V3AstNodes.h | 13 +++++++++---- src/V3LinkDot.cpp | 2 +- src/verilog.y | 14 +++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index e3038b17c..66eceb58f 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -3071,19 +3071,24 @@ public: void cname(const string& cname) { m_cname = cname; } }; -class AstWith : public AstNodeStmt { +class AstWithParse : public AstNodeStmt { + // In early parse, FUNC(index) WITH equation-using-index + // Replaced with AstWith + // Parents: math|stmt + // Children: funcref, math public: - AstWith(FileLine* fl, bool stmt, AstNode* funcrefp, AstNode* argsp) + AstWithParse(FileLine* fl, bool stmt, AstNode* funcrefp, AstNode* exprp) : ASTGEN_SUPER(fl) { statement(stmt); setOp1p(funcrefp); - addNOp2p(argsp); + addNOp2p(exprp); } - ASTNODE_NODE_FUNCS(With) + ASTNODE_NODE_FUNCS(WithParse) virtual V3Hash sameHash() const override { return V3Hash(); } virtual bool same(const AstNode* samep) const override { return true; } // AstNode* funcrefp() const { return op1p(); } + AstNode* exprp() const { return op2p(); } }; //###################################################################### diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 822a43692..4a029073f 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2400,7 +2400,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstWith* nodep) override { + virtual void visit(AstWithParse* nodep) override { nodep->v3warn(E_UNSUPPORTED, "Unsupported: with statements"); nodep->replaceWith(nodep->funcrefp()->unlinkFrBack()); VL_DO_DANGLING(nodep->deleteTree(), nodep); diff --git a/src/verilog.y b/src/verilog.y index 72275ccd9..e6c018af2 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3496,9 +3496,9 @@ task_subroutine_callNoMethod: // function_subroutine_callNoMethod (as tas // // IEEE: tf_call taskRef { $$ = $1; } // // funcref below not task ref to avoid conflict, must later handle either - | funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, true, $1, $4); } + | funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, true, $1, $4); } // // can call as method and yWITH without parenthesis - | id yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, true, new AstFuncRef($1, *$1, nullptr), $4); } + | id yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, true, new AstFuncRef($1, *$1, nullptr), $4); } | system_t_call { $$ = $1; } // // IEEE: method_call requires a "." so is in expr // // IEEE: ['std::'] not needed, as normal std package resolution will find it @@ -3511,9 +3511,9 @@ task_subroutine_callNoMethod: // function_subroutine_callNoMethod (as tas function_subroutine_callNoMethod: // IEEE: function_subroutine_call (as function) // // IEEE: tf_call funcRef { $$ = $1; } - | funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, false, $1, $4); } + | funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, false, $1, $4); } // // can call as method and yWITH without parenthesis - | id yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, false, new AstFuncRef($1, *$1, nullptr), $4); } + | id yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, false, new AstFuncRef($1, *$1, nullptr), $4); } | system_f_call { $$ = $1; } // // IEEE: method_call requires a "." so is in expr // // IEEE: ['std::'] not needed, as normal std package resolution will find it @@ -3521,7 +3521,7 @@ function_subroutine_callNoMethod: // IEEE: function_subroutine_call (as f // // We implement randomize as a normal funcRef, since randomize isn't a keyword // // Note yNULL is already part of expressions, so they come for free | funcRef yWITH__CUR constraint_block { $$ = $1; BBUNSUP($2, "Unsupported: randomize() 'with' constraint"); } - | funcRef yWITH__CUR '{' '}' { $$ = new AstWith($2, false, $1, nullptr); } + | funcRef yWITH__CUR '{' '}' { $$ = new AstWithParse($2, false, $1, nullptr); } ; system_t_call: // IEEE: system_tf_call (as task) @@ -4028,9 +4028,9 @@ array_methodNoRoot: array_methodWith: array_methodNoRoot { $$ = $1; } | array_methodNoRoot parenE yWITH__PAREN '(' expr ')' - { $$ = new AstWith($3, false, $1, $5); } + { $$ = new AstWithParse($3, false, $1, $5); } | array_methodNoRoot '(' expr ')' yWITH__PAREN '(' expr ')' - { $$ = new AstWith($5, false, $1, $7); $1->addPinsp($3); } + { $$ = new AstWithParse($5, false, $1, $7); $1->addPinsp($3); } ; dpi_import_export: // ==IEEE: dpi_import_export