aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/synth/elab-vhdl_decls.adb12
-rw-r--r--src/synth/elab-vhdl_objtypes.adb23
-rw-r--r--src/synth/elab-vhdl_objtypes.ads2
-rw-r--r--src/synth/elab-vhdl_types.adb47
-rw-r--r--src/synth/elab-vhdl_types.ads6
-rw-r--r--src/synth/synth-vhdl_stmts.adb21
6 files changed, 87 insertions, 24 deletions
diff --git a/src/synth/elab-vhdl_decls.adb b/src/synth/elab-vhdl_decls.adb
index 5d5f38d25..7be65af08 100644
--- a/src/synth/elab-vhdl_decls.adb
+++ b/src/synth/elab-vhdl_decls.adb
@@ -350,7 +350,17 @@ package body Elab.Vhdl_Decls is
when Iir_Kind_Attribute_Specification =>
Elab_Attribute_Specification (Syn_Inst, Decl);
when Iir_Kind_Type_Declaration =>
- Elab_Type_Definition (Syn_Inst, Get_Type_Definition (Decl));
+ declare
+ Incomp : constant Node :=
+ Get_Incomplete_Type_Declaration (Decl);
+ Def : constant Node := Get_Type_Definition (Decl);
+ begin
+ Elab_Type_Definition (Syn_Inst, Def);
+ if Incomp /= Null_Node then
+ Elab_Incomplete_Type_Finish
+ (Syn_Inst, Get_Type_Definition (Incomp), Def);
+ end if;
+ end;
when Iir_Kind_Anonymous_Type_Declaration =>
Elab_Anonymous_Type_Definition
(Syn_Inst, Get_Type_Definition (Decl),
diff --git a/src/synth/elab-vhdl_objtypes.adb b/src/synth/elab-vhdl_objtypes.adb
index 3662758d6..b027c84f1 100644
--- a/src/synth/elab-vhdl_objtypes.adb
+++ b/src/synth/elab-vhdl_objtypes.adb
@@ -631,7 +631,12 @@ package body Elab.Vhdl_Objtypes is
function Alloc is new Areapools.Alloc_On_Pool_Addr (Access_Type_Type);
Bnd_Sz : Size_Type;
begin
- Bnd_Sz := Compute_Size_Type (Acc_Type);
+ if Acc_Type = null then
+ -- For incomplete type.
+ Bnd_Sz := 0;
+ else
+ Bnd_Sz := Compute_Size_Type (Acc_Type);
+ end if;
return To_Type_Acc (Alloc (Current_Pool, (Kind => Type_Access,
Wkind => Wkind_Sim,
Al => 2,
@@ -642,6 +647,12 @@ package body Elab.Vhdl_Objtypes is
Acc_Bnd_Sz => Bnd_Sz)));
end Create_Access_Type;
+ procedure Complete_Access_Type (Acc_Type : Type_Acc; Des_Typ : Type_Acc) is
+ begin
+ Acc_Type.Acc_Acc := Des_Typ;
+ Acc_Type.Acc_Bnd_Sz := Compute_Size_Type (Des_Typ);
+ end Complete_Access_Type;
+
function Create_File_Type (File_Type : Type_Acc) return Type_Acc
is
subtype File_Type_Type is Type_Type (Type_File);
@@ -1039,7 +1050,12 @@ package body Elab.Vhdl_Objtypes is
Typ => Unshare (T.Rec.E (I).Typ, Pool));
end loop;
when Type_Access =>
- Res.Acc_Acc := Unshare (T.Acc_Acc, Pool);
+ if T.Acc_Acc /= null then
+ Res.Acc_Acc := Unshare (T.Acc_Acc, Pool);
+ else
+ -- For incomplete types
+ Res.Acc_Acc := null;
+ end if;
when Type_File =>
Res.File_Typ := Unshare (T.File_Typ, Pool);
when Type_Protected =>
@@ -1122,7 +1138,8 @@ package body Elab.Vhdl_Objtypes is
when Type_Bit
| Type_Logic
| Type_Discrete
- | Type_Float =>
+ | Type_Float
+ | Type_Access =>
Res := Typ;
return;
when others =>
diff --git a/src/synth/elab-vhdl_objtypes.ads b/src/synth/elab-vhdl_objtypes.ads
index fe1508fbc..3b3547132 100644
--- a/src/synth/elab-vhdl_objtypes.ads
+++ b/src/synth/elab-vhdl_objtypes.ads
@@ -252,7 +252,9 @@ package Elab.Vhdl_Objtypes is
function Create_Record_Type (Els : Rec_El_Array_Acc) return Type_Acc;
function Create_Unbounded_Record (Els : Rec_El_Array_Acc) return Type_Acc;
+ -- ACC_TYPE can be null for an incomplete type.
function Create_Access_Type (Acc_Type : Type_Acc) return Type_Acc;
+ procedure Complete_Access_Type (Acc_Type : Type_Acc; Des_Typ : Type_Acc);
function Create_File_Type (File_Type : Type_Acc) return Type_Acc;
diff --git a/src/synth/elab-vhdl_types.adb b/src/synth/elab-vhdl_types.adb
index 411b90519..9a8825493 100644
--- a/src/synth/elab-vhdl_types.adb
+++ b/src/synth/elab-vhdl_types.adb
@@ -211,14 +211,6 @@ package body Elab.Vhdl_Types is
return Res;
end Create_Bounds_From_Length;
- procedure Synth_Subtype_Indication_If_Anonymous
- (Syn_Inst : Synth_Instance_Acc; Atype : Node) is
- begin
- if Get_Type_Declarator (Atype) = Null_Node then
- Synth_Subtype_Indication (Syn_Inst, Atype);
- end if;
- end Synth_Subtype_Indication_If_Anonymous;
-
function Synth_Subtype_Indication_If_Anonymous
(Syn_Inst : Synth_Instance_Acc; Atype : Node) return Type_Acc is
begin
@@ -310,16 +302,49 @@ package body Elab.Vhdl_Types is
(Syn_Inst : Synth_Instance_Acc; Def : Node) return Type_Acc
is
Des_Type : constant Node := Get_Designated_Type (Def);
+ Des_Ind : constant Node := Get_Designated_Subtype_Indication (Def);
+ T : Node;
Des_Typ : Type_Acc;
Typ : Type_Acc;
begin
- Synth_Subtype_Indication_If_Anonymous (Syn_Inst, Des_Type);
- Des_Typ := Get_Subtype_Object (Syn_Inst, Des_Type);
+ if Get_Kind (Des_Ind) in Iir_Kinds_Denoting_Name then
+ T := Get_Named_Entity (Des_Ind);
+ if Get_Kind (T) = Iir_Kind_Type_Declaration
+ and then
+ Get_Kind (Get_Type (T)) = Iir_Kind_Incomplete_Type_Definition
+ then
+ -- Access to incomplete type.
+ Des_Typ := null;
+ else
+ Des_Typ := Get_Subtype_Object (Syn_Inst, Des_Type);
+ end if;
+ else
+ Des_Typ := Synth_Subtype_Indication_If_Anonymous (Syn_Inst, Des_Type);
+ end if;
Typ := Create_Access_Type (Des_Typ);
return Typ;
end Synth_Access_Type_Definition;
+ procedure Elab_Incomplete_Type_Finish (Syn_Inst : Synth_Instance_Acc;
+ Incomp : Node;
+ Des_Def : Node)
+ is
+ Des_Typ : Type_Acc;
+ Acc : Node;
+ Acc_Typ : Type_Acc;
+ begin
+ Des_Typ := Get_Subtype_Object (Syn_Inst, Des_Def);
+
+ -- Complete all the access types in the chain.
+ Acc := Get_Incomplete_Type_Ref_Chain (Incomp);
+ while Acc /= Null_Node loop
+ Acc_Typ := Get_Subtype_Object (Syn_Inst, Acc);
+ Complete_Access_Type (Acc_Typ, Des_Typ);
+ Acc := Get_Incomplete_Type_Ref_Chain (Acc);
+ end loop;
+ end Elab_Incomplete_Type_Finish;
+
function Synth_File_Type_Definition
(Syn_Inst : Synth_Instance_Acc; Def : Node) return Type_Acc
is
@@ -415,6 +440,8 @@ package body Elab.Vhdl_Types is
-- TODO...
Elab.Vhdl_Decls.Elab_Declarations
(Syn_Inst, Get_Declaration_Chain (Def));
+ when Iir_Kind_Incomplete_Type_Definition =>
+ return;
when others =>
Vhdl.Errors.Error_Kind ("synth_type_definition", Def);
end case;
diff --git a/src/synth/elab-vhdl_types.ads b/src/synth/elab-vhdl_types.ads
index 5f8bbab0e..30591e8da 100644
--- a/src/synth/elab-vhdl_types.ads
+++ b/src/synth/elab-vhdl_types.ads
@@ -64,6 +64,12 @@ package Elab.Vhdl_Types is
procedure Elab_Anonymous_Type_Definition
(Syn_Inst : Synth_Instance_Acc; Def : Node; St : Node);
+ -- Complete incomplete type definition INCOMP.
+ -- DES_DEF is the complete designated type.
+ procedure Elab_Incomplete_Type_Finish (Syn_Inst : Synth_Instance_Acc;
+ Incomp : Node;
+ Des_Def : Node);
+
-- Exported only for Vhdl.Evaluation to create temporary types.
function Elab_Enumeration_Type_Definition (Def : Node) return Type_Acc;
function Elab_Scalar_Type_Definition (Def : Node; St : Node)
diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb
index 199bd86d6..36c8cb6cb 100644
--- a/src/synth/synth-vhdl_stmts.adb
+++ b/src/synth/synth-vhdl_stmts.adb
@@ -258,16 +258,17 @@ package body Synth.Vhdl_Stmts is
when Iir_Kind_Implicit_Dereference
| Iir_Kind_Dereference =>
- Synth_Assignment_Prefix
- (Syn_Inst, Get_Prefix (Pfx), Dest_Base, Dest_Typ, Dest_Off);
- if Dest_Off /= (0, 0) then
- raise Internal_Error;
- end if;
- Dest_Base := Create_Value_Memtyp
- (Elab.Vhdl_Heap.Synth_Dereference (Read_Access (Dest_Base)));
- Dest_Typ := Dest_Base.Typ;
- Dest_Dyn := No_Dyn_Name;
-
+ declare
+ Acc : Memtyp;
+ begin
+ Synth_Assignment_Prefix
+ (Syn_Inst, Get_Prefix (Pfx), Dest_Base, Dest_Typ, Dest_Off);
+ Acc := (Dest_Typ, Dest_Base.Val.Mem + Dest_Off.Mem_Off);
+ Dest_Base := Create_Value_Memtyp
+ (Elab.Vhdl_Heap.Synth_Dereference (Read_Access (Acc)));
+ Dest_Typ := Dest_Base.Typ;
+ Dest_Dyn := No_Dyn_Name;
+ end;
when others =>
Error_Kind ("synth_assignment_prefix", Pfx);
end case;