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<decl_assignment_t*>`. The one that takes a `std::list<decl_assignment_t*>` 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<decl_assignment_t*>` for wire declarations. This allows to remove one of the two functions. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
47b6ee714d
commit
a5e9358d42
24
parse.y
24
parse.y
|
|
@ -439,7 +439,6 @@ static void current_function_set_statement(const YYLTYPE&loc, std::vector<Statem
|
|||
Statement*statement;
|
||||
std::vector<Statement*>*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<Statem
|
|||
%type <perm_strings> list_of_identifiers loop_variables
|
||||
%type <port_list> list_of_port_identifiers list_of_variable_port_identifiers
|
||||
|
||||
%type <net_decl_assign> net_decl_assign net_decl_assigns
|
||||
%type <decl_assignments> net_decl_assigns
|
||||
%type <decl_assignment> net_decl_assign
|
||||
|
||||
%type <mport> port port_opt port_reference port_reference_list
|
||||
%type <mport> 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<decl_assignment_t*>*tmp = $1;
|
||||
tmp->push_back($3);
|
||||
$$ = tmp;
|
||||
}
|
||||
| net_decl_assign
|
||||
{ $$ = $1;
|
||||
}
|
||||
{ std::list<decl_assignment_t*>*tmp = new std::list<decl_assignment_t*>;
|
||||
tmp->push_back($1);
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
||||
net_type
|
||||
|
|
|
|||
48
pform.cc
48
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<PExpr*>*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<perm_string>*names = new list<perm_string>;
|
||||
|
||||
// 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<PExpr*>*delay,
|
||||
str_pair_t str,
|
||||
|
|
|
|||
12
pform.h
12
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<named_pexpr_t>*attr);
|
||||
|
||||
/* This form handles assignment declarations. */
|
||||
extern void pform_makewire(const struct vlltype&li,
|
||||
std::list<PExpr*>*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<PExpr*>*delay,
|
||||
|
|
|
|||
Loading…
Reference in New Issue