Skip to content

Commit 32f5ee1

Browse files
committed
Fixed performance bug in ilang parser
1 parent a7ffb85 commit 32f5ee1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

frontends/ilang/ilang_parser.y

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ USING_YOSYS_NAMESPACE
5050
int integer;
5151
YOSYS_NAMESPACE_PREFIX RTLIL::Const *data;
5252
YOSYS_NAMESPACE_PREFIX RTLIL::SigSpec *sigspec;
53+
std::vector<YOSYS_NAMESPACE_PREFIX RTLIL::SigSpec> *rsigspec;
5354
}
5455

5556
%token <string> TOK_ID TOK_VALUE TOK_STRING
@@ -60,6 +61,7 @@ USING_YOSYS_NAMESPACE
6061
%token TOK_UPDATE TOK_PROCESS TOK_END TOK_INVALID TOK_EOL TOK_OFFSET
6162
%token TOK_PARAMETER TOK_ATTRIBUTE TOK_MEMORY TOK_SIZE TOK_SIGNED TOK_UPTO
6263

64+
%type <rsigspec> sigspec_list_reversed
6365
%type <sigspec> sigspec sigspec_list
6466
%type <integer> sync_type
6567
%type <data> constant
@@ -389,16 +391,20 @@ sigspec:
389391
$$ = $2;
390392
};
391393

392-
sigspec_list:
393-
sigspec_list sigspec {
394-
$$ = new RTLIL::SigSpec;
395-
$$->append(*$2);
396-
$$->append(*$1);
397-
delete $1;
394+
sigspec_list_reversed:
395+
sigspec_list_reversed sigspec {
396+
$$->push_back(*$2);
398397
delete $2;
399398
} |
400399
/* empty */ {
400+
$$ = new std::vector<RTLIL::SigSpec>;
401+
};
402+
403+
sigspec_list: sigspec_list_reversed {
401404
$$ = new RTLIL::SigSpec;
405+
for (auto it = $1->rbegin(); it != $1->rend(); it++)
406+
$$->append(*it);
407+
delete $1;
402408
};
403409

404410
conn_stmt:

0 commit comments

Comments
 (0)