From a5e9358d42580b56195621908012c548f5811244 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 20 Jan 2022 15:57:46 +0100 Subject: [PATCH] Consolidate pform_makewire() variants There are currently two very similar implementations of pform_makewire(). One that takes a `net_decl_assign_t`, the other a `std::list`. The one that takes a `std::list` is a superset of the other. It can handle both wires and variables, while the other can only handle wires. Update the parser to generate a `std::list` for wire declarations. This allows to remove one of the two functions. Signed-off-by: Lars-Peter Clausen --- parse.y | 24 ++++++++++++------------ pform.cc | 48 ------------------------------------------------ pform.h | 12 ------------ 3 files changed, 12 insertions(+), 72 deletions(-) diff --git a/parse.y b/parse.y index 64fe44da7..2294860a9 100644 --- a/parse.y +++ b/parse.y @@ -439,7 +439,6 @@ static void current_function_set_statement(const YYLTYPE&loc, std::vector*statement_list; - net_decl_assign_t*net_decl_assign; enum_type_t*enum_type; decl_assignment_t*decl_assignment; @@ -610,7 +609,8 @@ static void current_function_set_statement(const YYLTYPE&loc, std::vector list_of_identifiers loop_variables %type list_of_port_identifiers list_of_variable_port_identifiers -%type net_decl_assign net_decl_assigns +%type net_decl_assigns +%type net_decl_assign %type port port_opt port_reference port_reference_list %type port_declaration @@ -5523,10 +5523,9 @@ generate_block net_decl_assign : IDENTIFIER '=' expression - { net_decl_assign_t*tmp = new net_decl_assign_t; - tmp->next = tmp; + { decl_assignment_t*tmp = new decl_assignment_t; tmp->name = lex_strings.make($1); - tmp->expr = $3; + tmp->expr.reset($3); delete[]$1; $$ = tmp; } @@ -5534,14 +5533,15 @@ net_decl_assign net_decl_assigns : net_decl_assigns ',' net_decl_assign - { net_decl_assign_t*tmp = $1; - $3->next = tmp->next; - tmp->next = $3; - $$ = tmp; - } + { std::list*tmp = $1; + tmp->push_back($3); + $$ = tmp; + } | net_decl_assign - { $$ = $1; - } + { std::list*tmp = new std::list; + tmp->push_back($1); + $$ = tmp; + } ; net_type diff --git a/pform.cc b/pform.cc index 21a106c15..fe2cb3d03 100644 --- a/pform.cc +++ b/pform.cc @@ -2823,54 +2823,6 @@ void pform_makewire(const vlltype&li, perm_string name, } } -/* - * This form makes nets with delays and continuous assignments. - */ -void pform_makewire(const vlltype&li, - list*delay, - str_pair_t str, - net_decl_assign_t*decls, - NetNet::Type type, - data_type_t*data_type) -{ - // The decls pointer is a circularly linked list. - net_decl_assign_t*first = decls->next; - - list*names = new list; - - // Go through the circularly linked list non-destructively. - do { - pform_makewire(li, first->name, type, NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0); - names->push_back(first->name); - first = first->next; - } while (first != decls->next); - - // The pform_set_data_type function will delete the names list. - pform_set_data_type(li, data_type, names, type, 0); - - // This time, go through the list, deleting cells as I'm done. - first = decls->next; - decls->next = 0; - while (first) { - net_decl_assign_t*next = first->next; - PWire*cur = pform_get_wire_in_scope(first->name); - if (cur != 0) { - PEIdent*lval = new PEIdent(first->name); - FILE_NAME(lval, li.text, li.first_line); - PGAssign*ass = pform_make_pgassign(lval, first->expr, - delay, str); - FILE_NAME(ass, li.text, li.first_line); - } - - delete first; - first = next; - } -} - -/* - * This should eventually replace the form above that takes a - * net_decl_assign_t argument. - */ void pform_makewire(const struct vlltype&li, std::list*delay, str_pair_t str, diff --git a/pform.h b/pform.h index 5f08678cd..d61b18ae5 100644 --- a/pform.h +++ b/pform.h @@ -96,12 +96,6 @@ struct parmvalue_t { struct str_pair_t { ivl_drive_t str0, str1; }; -struct net_decl_assign_t { - perm_string name; - PExpr*expr; - struct net_decl_assign_t*next; -}; - /* The lgate is gate instantiation information. */ struct lgate { explicit inline lgate(int =0) @@ -360,12 +354,6 @@ extern void pform_makewire(const struct vlltype&li, perm_string name, std::list*attr); /* This form handles assignment declarations. */ -extern void pform_makewire(const struct vlltype&li, - std::list*delay, - str_pair_t str, - net_decl_assign_t*assign_list, - NetNet::Type type, - data_type_t*data_type); extern void pform_makewire(const struct vlltype&li, std::list*delay,