aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-01-02 18:17:10 +0100
committerTristan Gingold <tgingold@free.fr>2023-01-03 16:47:24 +0100
commit131063995d1065a78858feb8afbb0d694ea827b4 (patch)
tree48a80696ab37a6f1d8a08cc2690566022830df26
parent980dde3da865a9570ad88f89387cf009e9520e60 (diff)
downloadghdl-131063995d1065a78858feb8afbb0d694ea827b4.tar.gz
ghdl-131063995d1065a78858feb8afbb0d694ea827b4.tar.bz2
ghdl-131063995d1065a78858feb8afbb0d694ea827b4.zip
synth: add support of interface subprogram
-rw-r--r--src/synth/elab-vhdl_annotations.adb11
-rw-r--r--src/synth/elab-vhdl_insts.adb41
-rw-r--r--src/vhdl/vhdl-sem_inst.adb12
3 files changed, 33 insertions, 31 deletions
diff --git a/src/synth/elab-vhdl_annotations.adb b/src/synth/elab-vhdl_annotations.adb
index 4341d4747..ad83e0645 100644
--- a/src/synth/elab-vhdl_annotations.adb
+++ b/src/synth/elab-vhdl_annotations.adb
@@ -369,13 +369,10 @@ package body Elab.Vhdl_Annotations is
when Iir_Kind_Interface_Package_Declaration =>
Annotate_Interface_Package_Declaration (Block_Info, Decl);
when Iir_Kind_Interface_Type_Declaration =>
- if Get_Kind (Get_Parent (Decl)) = Iir_Kind_Entity_Declaration
- then
- -- Create an info on the interface_type_definition.
- -- This is needed for a generic type in an entity, as the
- -- nodes are not instantiated.
- Create_Object_Info (Block_Info, Get_Type (Decl));
- end if;
+ -- Create an info on the interface_type_definition.
+ -- This is needed for a generic type in an entity, as the
+ -- nodes are not instantiated.
+ Create_Object_Info (Block_Info, Get_Type (Decl));
when Iir_Kinds_Interface_Subprogram_Declaration =>
-- Macro-expanded
null;
diff --git a/src/synth/elab-vhdl_insts.adb b/src/synth/elab-vhdl_insts.adb
index c2c72c9fa..c1c8fe371 100644
--- a/src/synth/elab-vhdl_insts.adb
+++ b/src/synth/elab-vhdl_insts.adb
@@ -156,27 +156,24 @@ package body Elab.Vhdl_Insts is
end;
when Iir_Kind_Interface_Type_Declaration =>
- if Get_Kind (Get_Parent (Inter)) = Iir_Kind_Entity_Declaration
- then
- declare
- Act : Node;
- Act_Typ : Type_Acc;
- begin
- Act := Get_Actual (Assoc);
- if Get_Kind (Act) in Iir_Kinds_Denoting_Name then
- Act := Get_Type (Act);
- end if;
- if Get_Kind (Act) in Iir_Kinds_Subtype_Definition then
- Act_Typ := Synth_Subtype_Indication (Syn_Inst, Act);
- else
- Act_Typ := Get_Subtype_Object (Syn_Inst, Act);
- end if;
- Act_Typ := Unshare (Act_Typ, Instance_Pool);
- Create_Subtype_Object
- (Sub_Inst, Get_Type (Inter), Act_Typ);
- Release_Expr_Pool (Marker);
- end;
- end if;
+ declare
+ Act : Node;
+ Act_Typ : Type_Acc;
+ begin
+ Act := Get_Actual (Assoc);
+ if Get_Kind (Act) in Iir_Kinds_Denoting_Name then
+ Act := Get_Type (Act);
+ end if;
+ if Get_Kind (Act) in Iir_Kinds_Subtype_Definition then
+ Act_Typ := Synth_Subtype_Indication (Syn_Inst, Act);
+ else
+ Act_Typ := Get_Subtype_Object (Syn_Inst, Act);
+ end if;
+ Act_Typ := Unshare (Act_Typ, Instance_Pool);
+ Create_Subtype_Object
+ (Sub_Inst, Get_Type (Inter), Act_Typ);
+ Release_Expr_Pool (Marker);
+ end;
when Iir_Kind_Interface_Variable_Declaration
| Iir_Kind_Interface_File_Declaration
@@ -186,7 +183,7 @@ package body Elab.Vhdl_Insts is
raise Internal_Error;
when Iir_Kinds_Interface_Subprogram_Declaration =>
- raise Internal_Error;
+ null;
end case;
Next_Association_Interface (Assoc, Assoc_Inter);
diff --git a/src/vhdl/vhdl-sem_inst.adb b/src/vhdl/vhdl-sem_inst.adb
index b5a390a49..6b9061a58 100644
--- a/src/vhdl/vhdl-sem_inst.adb
+++ b/src/vhdl/vhdl-sem_inst.adb
@@ -735,7 +735,14 @@ package body Vhdl.Sem_Inst is
Instantiate_Iir_Chain (Get_Declaration_Chain (Inter)));
end if;
when Iir_Kind_Interface_Type_Declaration =>
- Set_Type (Res, Get_Type (Inter));
+ declare
+ Itype : Iir;
+ begin
+ Itype := Instantiate_Iir (Get_Type (Inter), False);
+ Set_Type (Res, Itype);
+ Set_Interface_Type_Definition (Res, Itype);
+ Set_Is_Ref (Res, True);
+ end;
when Iir_Kinds_Interface_Subprogram_Declaration =>
Sem_Utils.Compute_Subprogram_Hash (Res);
when others =>
@@ -1036,7 +1043,8 @@ package body Vhdl.Sem_Inst is
-- Replace the incomplete interface type by the actual subtype
-- indication.
declare
- Inter_Type_Def : constant Iir := Get_Type (Assoc_Formal);
+ Orig_Formal : constant Iir := Get_Origin (Assoc_Formal);
+ Inter_Type_Def : constant Iir := Get_Type (Orig_Formal);
Actual_Type : constant Iir := Get_Actual_Type (Assoc);
begin
Set_Instance (Inter_Type_Def, Actual_Type);