forked from github/verilator
Optimize one-statement fork/join into begin
This commit is contained in:
parent
9702d11657
commit
8455ee7091
@ -562,9 +562,14 @@ private:
|
||||
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
|
||||
return;
|
||||
}
|
||||
if (v3Global.opt.bboxUnsup()) {
|
||||
AstBegin* newp
|
||||
= new AstBegin(nodep->fileline(), nodep->name(), nodep->stmtsp()->unlinkFrBack());
|
||||
if (v3Global.opt.bboxUnsup()
|
||||
// With no statements, begin is identical
|
||||
|| !nodep->stmtsp()
|
||||
// With one statement, a begin block does as good as a fork/join or join_any
|
||||
|| (!nodep->stmtsp()->nextp() && !nodep->joinType().joinNone())) {
|
||||
AstNode* stmtsp = nullptr;
|
||||
if (nodep->stmtsp()) stmtsp = nodep->stmtsp()->unlinkFrBack();
|
||||
AstBegin* newp = new AstBegin{nodep->fileline(), nodep->name(), stmtsp};
|
||||
nodep->replaceWith(newp);
|
||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
} else {
|
||||
|
@ -1,5 +0,0 @@
|
||||
%Error-UNSUPPORTED: t/t_fork.v:10:14: Unsupported: fork statements
|
||||
: ... In instance t
|
||||
10 | fork : fblk
|
||||
| ^~~~
|
||||
%Error: Exiting due to
|
@ -8,12 +8,11 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(vlt => 1);
|
||||
scenarios(simulator => 1);
|
||||
|
||||
lint(
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
compile();
|
||||
|
||||
execute();
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
@ -7,6 +7,14 @@
|
||||
module t (/*AUTOARG*/);
|
||||
|
||||
initial begin
|
||||
// With no statements this is a NOP
|
||||
fork
|
||||
join
|
||||
fork
|
||||
join_any
|
||||
fork
|
||||
join_none
|
||||
// With one statement this is supported and optimized to a begin/end
|
||||
fork : fblk
|
||||
begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
|
5
test_regress/t/t_fork2.out
Normal file
5
test_regress/t/t_fork2.out
Normal file
@ -0,0 +1,5 @@
|
||||
%Error-UNSUPPORTED: t/t_fork2.v:10:14: Unsupported: fork statements
|
||||
: ... In instance t
|
||||
10 | fork : fblk
|
||||
| ^~~~
|
||||
%Error: Exiting due to
|
19
test_regress/t/t_fork2.pl
Executable file
19
test_regress/t/t_fork2.pl
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(vlt => 1);
|
||||
|
||||
lint(
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
21
test_regress/t/t_fork2.v
Normal file
21
test_regress/t/t_fork2.v
Normal file
@ -0,0 +1,21 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
|
||||
initial begin
|
||||
fork : fblk
|
||||
begin
|
||||
$write("Forked");
|
||||
end
|
||||
begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
join : fblk
|
||||
end
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user