aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-stmts.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-17 08:26:41 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-17 08:26:41 +0100
commita8f26431fe37cc668185be39f15cf3b7a8790422 (patch)
tree093a32023ad9b02ba398edfdb78e786fff663f6a /src/synth/synth-stmts.adb
parent5f2be92340bb4ecf1ea0e773e4c734e53204979a (diff)
downloadghdl-a8f26431fe37cc668185be39f15cf3b7a8790422.tar.gz
ghdl-a8f26431fe37cc668185be39f15cf3b7a8790422.tar.bz2
ghdl-a8f26431fe37cc668185be39f15cf3b7a8790422.zip
synth-stmts: improve support of exit statement (static case).
Diffstat (limited to 'src/synth/synth-stmts.adb')
-rw-r--r--src/synth/synth-stmts.adb22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index 7527045c8..2df7705fb 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -1779,6 +1779,7 @@ package body Synth.Stmts is
is
Cond : constant Node := Get_Condition (Stmt);
Is_Exit : constant Boolean := Get_Kind (Stmt) = Iir_Kind_Exit_Statement;
+ Static_Cond : Boolean;
Loop_Label : Node;
Lc : Loop_Context_Acc;
Cond_Val : Value_Acc;
@@ -1788,7 +1789,15 @@ package body Synth.Stmts is
if Cond /= Null_Node then
Cond_Val := Synth_Expression (C.Inst, Cond);
- Push_Phi;
+ Static_Cond := Is_Static_Val (Cond_Val);
+ if Static_Cond then
+ if Get_Static_Discrete (Cond_Val) = 0 then
+ -- Not executed.
+ return;
+ end if;
+ else
+ Push_Phi;
+ end if;
end if;
-- Execution is suspended.
@@ -1817,7 +1826,7 @@ package body Synth.Stmts is
Lc := Lc.Prev_Loop;
end loop;
- if Cond /= Null_Node then
+ if Cond /= Null_Node and not Static_Cond then
Pop_Phi (Phi_True);
Push_Phi;
Pop_Phi (Phi_False);
@@ -1905,6 +1914,15 @@ package body Synth.Stmts is
Synth_Sequential_Statements (C, Stmts);
Loop_Control_Update (C);
+
+ -- Exit from the loop if W_Exit = 0
+ if Lc.W_Exit /= No_Wire_Id
+ and then
+ Get_Current_Value (null, Lc.W_Exit) = Get_Inst_Bit0 (C.Inst)
+ then
+ exit;
+ end if;
+ -- FIXME: W_Quit = 0, W_Ret = 0 ??
end loop;
Loop_Control_Finish (C);