aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-12-18 17:16:57 +0100
committerTristan Gingold <tgingold@free.fr>2022-12-18 17:16:57 +0100
commitc0095f3f0c37a2db4d56dc289854252e2e6e67d4 (patch)
tree6fa51ee45d62cd7af1d181bda4495d00ccb6b484 /src/vhdl
parentb4f09236ad974a133318d17a8487b36ebc35a78c (diff)
downloadghdl-c0095f3f0c37a2db4d56dc289854252e2e6e67d4.tar.gz
ghdl-c0095f3f0c37a2db4d56dc289854252e2e6e67d4.tar.bz2
ghdl-c0095f3f0c37a2db4d56dc289854252e2e6e67d4.zip
vhdl-sem_inst: add instantiate_interface_package_declaration
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/vhdl-sem_decls.adb4
-rw-r--r--src/vhdl/vhdl-sem_inst.adb37
-rw-r--r--src/vhdl/vhdl-sem_inst.ads11
3 files changed, 50 insertions, 2 deletions
diff --git a/src/vhdl/vhdl-sem_decls.adb b/src/vhdl/vhdl-sem_decls.adb
index a9c686707..974cc21d8 100644
--- a/src/vhdl/vhdl-sem_decls.adb
+++ b/src/vhdl/vhdl-sem_decls.adb
@@ -517,7 +517,9 @@ package body Vhdl.Sem_Decls is
-- Not yet fully supported - need to check the instance.
end if;
- Sem_Inst.Instantiate_Package_Declaration (Inter, Pkg);
+ -- Create generics and declarations for the interface package so that
+ -- references are resolved to those declarations.
+ Sem_Inst.Instantiate_Interface_Package_Declaration (Inter, Pkg);
Sem_Scopes.Add_Name (Inter);
Set_Is_Within_Flag (Inter, True);
diff --git a/src/vhdl/vhdl-sem_inst.adb b/src/vhdl/vhdl-sem_inst.adb
index 4e7e1aa42..db34e5f39 100644
--- a/src/vhdl/vhdl-sem_inst.adb
+++ b/src/vhdl/vhdl-sem_inst.adb
@@ -1100,6 +1100,43 @@ package body Vhdl.Sem_Inst is
Restore_Origin (Mark);
end Instantiate_Subprogram_Declaration;
+ procedure Instantiate_Interface_Package_Declaration (Inter : Iir; Pkg : Iir)
+ is
+ Header : constant Iir := Get_Package_Header (Pkg);
+ Prev_Instance_File : constant Source_File_Entry := Instance_File;
+ Mark : constant Instance_Index_Type := Prev_Instance_Table.Last;
+ Prev_Within_Shared_Instance : constant Boolean :=
+ Is_Within_Shared_Instance;
+ begin
+ Create_Relocation (Inter, Pkg);
+ Set_Instance_Source_File (Inter, Instance_File);
+
+ -- Be sure Get_Origin_Priv can be called on existing nodes.
+ Expand_Origin_Table;
+
+ -- For Parent: the instance of PKG is INST.
+ Set_Origin (Pkg, Inter);
+
+ Is_Within_Shared_Instance := not Get_Macro_Expanded_Flag (Pkg);
+
+ -- Manually instantiate the package declaration.
+ Set_Generic_Chain
+ (Inter, Instantiate_Generic_Chain (Inter, Get_Generic_Chain (Header)));
+ Instantiate_Generic_Map_Chain (Inter, Pkg);
+ Set_Declaration_Chain
+ (Inter, Instantiate_Iir_Chain (Get_Declaration_Chain (Pkg)));
+ Set_Attribute_Value_Chain
+ (Inter, Instantiate_Iir (Get_Attribute_Value_Chain (Pkg), True));
+ Instantiate_Attribute_Value_Chain (Inter);
+
+ Set_Origin (Pkg, Null_Iir);
+
+ Instance_File := Prev_Instance_File;
+ Restore_Origin (Mark);
+
+ Is_Within_Shared_Instance := Prev_Within_Shared_Instance;
+ end Instantiate_Interface_Package_Declaration;
+
procedure Instantiate_Package_Declaration (Inst : Iir; Pkg : Iir)
is
Header : constant Iir := Get_Package_Header (Pkg);
diff --git a/src/vhdl/vhdl-sem_inst.ads b/src/vhdl/vhdl-sem_inst.ads
index 6d8a76300..1099479de 100644
--- a/src/vhdl/vhdl-sem_inst.ads
+++ b/src/vhdl/vhdl-sem_inst.ads
@@ -21,7 +21,16 @@ package Vhdl.Sem_Inst is
-- If N is not an instance, this function returns Null_Iir.
function Get_Origin (N : Iir) return Iir;
- -- Create declaration chain and generic declarations for INST from PKG.
+ -- Create declaration chain and generic declarations for INTER from PKG,
+ -- so the the parent of INTER can be analyzed and references to PKG
+ -- points to an instance.
+ -- It is necessary to create an instance because two interface packages
+ -- are different even if they have the same uninstantiated package.
+ procedure Instantiate_Interface_Package_Declaration
+ (Inter : Iir; Pkg : Iir);
+
+ -- - package instantiations
+ -- instantiate each node.
procedure Instantiate_Package_Declaration (Inst : Iir; Pkg : Iir);
-- Create interface parameters of INST from SUBPRG.