aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/synth/synth-context.adb12
-rw-r--r--src/synth/synth-context.ads9
-rw-r--r--src/synth/synth-oper.adb6
-rw-r--r--src/synth/synth-stmts.adb80
4 files changed, 81 insertions, 26 deletions
diff --git a/src/synth/synth-context.adb b/src/synth/synth-context.adb
index e5e5479a8..b192994ab 100644
--- a/src/synth/synth-context.adb
+++ b/src/synth/synth-context.adb
@@ -61,6 +61,7 @@ package body Synth.Context is
Res := new Synth_Instance_Type'(Max_Objs => Global_Info.Nbr_Objects,
Is_Const => False,
+ Is_Error => False,
Base => Base,
Name => No_Sname,
Block_Scope => Global_Info,
@@ -96,6 +97,7 @@ package body Synth.Context is
Res := new Synth_Instance_Type'(Max_Objs => Info.Nbr_Objects,
Is_Const => False,
+ Is_Error => False,
Base => Parent.Base,
Name => Name,
Block_Scope => Scope,
@@ -135,6 +137,16 @@ package body Synth.Context is
Inst.Base := Base;
end Set_Instance_Module;
+ function Is_Error (Inst : Synth_Instance_Acc) return Boolean is
+ begin
+ return Inst.Is_Error;
+ end Is_Error;
+
+ procedure Set_Error (Inst : Synth_Instance_Acc) is
+ begin
+ Inst.Is_Error := True;
+ end Set_Error;
+
function Get_Instance_Module (Inst : Synth_Instance_Acc) return Module is
begin
return Inst.Base.Cur_Module;
diff --git a/src/synth/synth-context.ads b/src/synth/synth-context.ads
index e01011256..b5c1619f1 100644
--- a/src/synth/synth-context.ads
+++ b/src/synth/synth-context.ads
@@ -52,6 +52,11 @@ package Synth.Context is
return Synth_Instance_Acc;
procedure Free_Instance (Synth_Inst : in out Synth_Instance_Acc);
+ function Is_Error (Inst : Synth_Instance_Acc) return Boolean;
+ pragma Inline (Is_Error);
+
+ procedure Set_Error (Inst : Synth_Instance_Acc);
+
function Get_Sname (Inst : Synth_Instance_Acc) return Sname;
pragma Inline (Get_Sname);
@@ -133,6 +138,10 @@ private
type Synth_Instance_Type (Max_Objs : Object_Slot_Type) is limited record
Is_Const : Boolean;
+ -- True if a fatal error has been detected that aborts the synthesis
+ -- of this instance.
+ Is_Error : Boolean;
+
Base : Base_Instance_Acc;
-- Name prefix for declarations.
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb
index 2399c33f1..4e8c434c4 100644
--- a/src/synth/synth-oper.adb
+++ b/src/synth/synth-oper.adb
@@ -573,9 +573,15 @@ package body Synth.Oper is
end Synth_Rotation;
begin
Left := Synth_Expression_With_Type (Syn_Inst, Left_Expr, Left_Typ);
+ if Left = null then
+ return null;
+ end if;
Left := Synth_Subtype_Conversion (Left, Left_Typ, False, Expr);
Strip_Const (Left);
Right := Synth_Expression_With_Type (Syn_Inst, Right_Expr, Right_Typ);
+ if Right = null then
+ return null;
+ end if;
Right := Synth_Subtype_Conversion (Right, Right_Typ, False, Expr);
Strip_Const (Right);
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index 7b2213301..59f14a990 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -94,6 +94,9 @@ package body Synth.Stmts is
Offset : Uns32;
Loc : Source.Syn_Src) is
begin
+ if Val = null then
+ return;
+ end if;
Phi_Assign (Build_Context, Wid,
Get_Net (Synth_Subtype_Conversion (Val, Typ, False, Loc)),
Offset);
@@ -572,6 +575,7 @@ package body Synth.Stmts is
Cwf : Node;
Inp : Input;
Val, Cond_Val : Value_Acc;
+ Cond_Net : Net;
First, Last : Net;
V : Net;
begin
@@ -586,9 +590,13 @@ package body Synth.Stmts is
Cond := Get_Condition (Cwf);
if Cond /= Null_Node then
Cond_Val := Synth_Expression (Syn_Inst, Cond);
- V := Build_Mux2 (Build_Context,
- Get_Net (Cond_Val),
- No_Net, V);
+ if Cond_Val = null then
+ Cond_Net := Build_Const_UB32 (Build_Context, 0, 1);
+ else
+ Cond_Net := Get_Net (Cond_Val);
+ end if;
+
+ V := Build_Mux2 (Build_Context, Cond_Net, No_Net, V);
Set_Location (V, Cwf);
end if;
@@ -1541,6 +1549,11 @@ package body Synth.Stmts is
end case;
end case;
+ if Val = null then
+ Set_Error (Subprg_Inst);
+ return;
+ end if;
+
-- FIXME: conversion only for constants, reshape for all.
Val := Synth_Subtype_Conversion (Val, Inter_Type, True, Assoc);
@@ -1716,21 +1729,26 @@ package body Synth.Stmts is
Phi_Assign (Build_Context, C.W_Ret, Get_Inst_Bit1 (Syn_Inst), 0);
Decls.Synth_Declarations (C.Inst, Get_Declaration_Chain (Bod), True);
+ if not Is_Error (C.Inst) then
+ Synth_Sequential_Statements (C, Get_Sequential_Statement_Chain (Bod));
+ end if;
- Synth_Sequential_Statements (C, Get_Sequential_Statement_Chain (Bod));
-
- if Is_Func then
- if C.Nbr_Ret = 0 then
- raise Internal_Error;
- elsif C.Nbr_Ret = 1 and then Is_Static (C.Ret_Value) then
- Res := C.Ret_Value;
+ if Is_Error (C.Inst) then
+ Res := null;
+ else
+ if Is_Func then
+ if C.Nbr_Ret = 0 then
+ raise Internal_Error;
+ elsif C.Nbr_Ret = 1 and then Is_Static (C.Ret_Value) then
+ Res := C.Ret_Value;
+ else
+ Res := Create_Value_Net
+ (Get_Current_Value (Build_Context, C.W_Val), C.Ret_Value.Typ);
+ end if;
else
- Res := Create_Value_Net
- (Get_Current_Value (Build_Context, C.W_Val), C.Ret_Value.Typ);
+ Res := null;
+ Synth_Subprogram_Back_Association (C.Inst, Syn_Inst, Init, Infos);
end if;
- else
- Res := null;
- Synth_Subprogram_Back_Association (C.Inst, Syn_Inst, Init, Infos);
end if;
Pop_Phi (Subprg_Phi);
@@ -1821,18 +1839,22 @@ package body Synth.Stmts is
New_Internal_Name (Build_Context));
Synth_Subprogram_Association (Sub_Inst, Syn_Inst, Init, Infos);
- if not Is_Func then
- if Get_Purity_State (Imp) /= Pure then
- Set_Instance_Const (Sub_Inst, False);
+ if Is_Error (Sub_Inst) then
+ Res := null;
+ else
+ if not Is_Func then
+ if Get_Purity_State (Imp) /= Pure then
+ Set_Instance_Const (Sub_Inst, False);
+ end if;
end if;
- end if;
- if Get_Instance_Const (Sub_Inst) then
- Res := Synth_Static_Subprogram_Call
- (Syn_Inst, Sub_Inst, Call, Init, Infos);
- else
- Res := Synth_Dynamic_Subprogram_Call
- (Syn_Inst, Sub_Inst, Call, Init, Infos);
+ if Get_Instance_Const (Sub_Inst) then
+ Res := Synth_Static_Subprogram_Call
+ (Syn_Inst, Sub_Inst, Call, Init, Infos);
+ else
+ Res := Synth_Dynamic_Subprogram_Call
+ (Syn_Inst, Sub_Inst, Call, Init, Infos);
+ end if;
end if;
Free_Instance (Sub_Inst);
@@ -2350,6 +2372,11 @@ package body Synth.Stmts is
if Expr /= Null_Node then
-- Return in function.
Val := Synth_Expression_With_Type (C.Inst, Expr, C.Ret_Typ);
+ if Val = null then
+ Set_Error (C.Inst);
+ return;
+ end if;
+
Val := Synth_Subtype_Conversion (Val, C.Ret_Typ, True, Stmt);
if C.Nbr_Ret = 0 then
@@ -2599,7 +2626,8 @@ package body Synth.Stmts is
if Get_Identifier (Lib) = Std_Names.Name_Ieee then
Error_Msg_Synth
(+Expr, "unhandled call to an ieee function");
- raise Internal_Error;
+ Set_Error (Syn_Inst);
+ return null;
end if;
end if;
end if;