aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libraries.adb42
-rw-r--r--src/vhdl/canon.adb66
-rw-r--r--src/vhdl/sem_inst.adb10
-rw-r--r--src/vhdl/translate/trans-chap12.adb4
-rw-r--r--src/vhdl/translate/trans-chap2.adb188
-rw-r--r--src/vhdl/translate/trans-chap2.ads2
-rw-r--r--src/vhdl/translate/trans-chap4.adb14
-rw-r--r--src/vhdl/translate/trans-rtis.adb11
8 files changed, 186 insertions, 151 deletions
diff --git a/src/libraries.adb b/src/libraries.adb
index 6173af87d..3f737f466 100644
--- a/src/libraries.adb
+++ b/src/libraries.adb
@@ -23,8 +23,6 @@ with System;
with Errorout; use Errorout;
with Scanner;
with Iirs_Utils; use Iirs_Utils;
-with Iir_Chains;
-with Nodes_Meta;
with Parse;
with Name_Table; use Name_Table;
with Str_Table;
@@ -35,7 +33,6 @@ with Std_Package;
with Disp_Tree;
with Disp_Vhdl;
with Sem;
-with Sem_Inst;
with Post_Sems;
with Canon;
with Nodes_GC;
@@ -1605,45 +1602,6 @@ package body Libraries is
Canon.Canonicalize (Unit);
- -- The library unit may have been changed from package instantiation
- -- to package declaration.
- Lib_Unit := Get_Library_Unit (Unit);
-
- -- FIXME: for Main only ?
- if Get_Kind (Lib_Unit) = Iir_Kind_Package_Declaration
- and then not Get_Need_Body (Lib_Unit)
- and then Get_Need_Instance_Bodies (Lib_Unit)
- then
- -- This is a package declaration without body. If there are package
- -- instantiations within that package and if the instances need
- -- bodies, create them. Ideally they should be created in the
- -- package body, but as we don't know if there is one, do it now.
- Set_Package_Instantiation_Bodies_Chain
- (Lib_Unit, Canon.Create_Instantiation_Bodies (Lib_Unit, Lib_Unit));
- elsif Get_Kind (Lib_Unit) = Iir_Kind_Package_Body
- and then Get_Need_Instance_Bodies (Get_Package (Lib_Unit))
- then
- -- If there are package instances in the package declaration and if
- -- they need bodies, create them now that the body (of the package
- -- containing the instances) is analyzed.
- Iir_Chains.Append_Chain
- (Lib_Unit, Nodes_Meta.Field_Declaration_Chain,
- Canon.Create_Instantiation_Bodies (Get_Package (Lib_Unit),
- Lib_Unit));
- elsif Get_Kind (Lib_Unit) = Iir_Kind_Package_Declaration
- and then Get_Package_Origin (Lib_Unit) /= Null_Iir
- and then (Get_Kind (Get_Package_Origin (Lib_Unit))
- = Iir_Kind_Package_Instantiation_Declaration)
- then
- -- Instantiate the body for package instantiation.
- declare
- Bod : Iir;
- begin
- Bod := Sem_Inst.Instantiate_Package_Body (Lib_Unit);
- Set_Package_Body (Lib_Unit, Bod);
- end;
- end if;
-
if (Main or Flags.Dump_All) and then Flags.Dump_Canon then
Disp_Tree.Disp_Tree (Unit);
end if;
diff --git a/src/vhdl/canon.adb b/src/vhdl/canon.adb
index 471058843..eb1378c1c 100644
--- a/src/vhdl/canon.adb
+++ b/src/vhdl/canon.adb
@@ -2592,6 +2592,7 @@ package body Canon is
function Canon_Package_Instantiation_Declaration (Decl : Iir) return Iir
is
Pkg : constant Iir := Get_Uninstantiated_Package_Decl (Decl);
+ Bod : Iir;
begin
-- Canon map aspect.
Set_Generic_Map_Aspect_Chain
@@ -2600,41 +2601,20 @@ package body Canon is
(Get_Generic_Chain (Decl),
Get_Generic_Map_Aspect_Chain (Decl), Decl));
- if Get_Macro_Expanded_Flag (Pkg) then
- declare
- New_Decl : Iir;
- New_Hdr : Iir;
- begin
- -- Replace package instantiation by the macro-expanded
- -- generic-mapped package.
- -- Use move semantics.
- -- FIXME: adjust Parent.
- New_Decl := Create_Iir (Iir_Kind_Package_Declaration);
- Location_Copy (New_Decl, Decl);
- Set_Parent (New_Decl, Get_Parent (Decl));
- Set_Identifier (New_Decl, Get_Identifier (Decl));
- Set_Need_Body (New_Decl, False);
-
- New_Hdr := Create_Iir (Iir_Kind_Package_Header);
- Set_Package_Header (New_Decl, New_Hdr);
- Location_Copy (New_Hdr, Get_Package_Header (Pkg));
- Set_Generic_Chain (New_Hdr, Get_Generic_Chain (Decl));
- Set_Generic_Map_Aspect_Chain
- (New_Hdr, Get_Generic_Map_Aspect_Chain (Decl));
- Set_Generic_Chain (Decl, Null_Iir);
- Set_Generic_Map_Aspect_Chain (Decl, Null_Iir);
-
- Set_Declaration_Chain (New_Decl, Get_Declaration_Chain (Decl));
- Set_Declaration_Chain (Decl, Null_Iir);
- Set_Chain (New_Decl, Get_Chain (Decl));
- Set_Chain (Decl, Null_Iir);
-
- Set_Package_Origin (New_Decl, Decl);
- return New_Decl;
- end;
- else
- return Decl;
+ -- Generate the body now.
+ -- Note: according to the LRM, if the instantiation occurs within a
+ -- package, the body of the instance should be appended to the package
+ -- body.
+ -- FIXME: generate only if generating code for this unit.
+ if Get_Macro_Expanded_Flag (Pkg)
+ and then Get_Need_Body (Pkg)
+ then
+ Bod := Sem_Inst.Instantiate_Package_Body (Decl);
+ Set_Parent (Bod, Get_Parent (Decl));
+ Set_Package_Body (Decl, Bod);
end if;
+
+ return Decl;
end Canon_Package_Instantiation_Declaration;
function Create_Instantiation_Bodies
@@ -2643,15 +2623,15 @@ package body Canon is
First, Last : Iir;
El : Iir;
Bod : Iir;
- Orig : Iir;
+ Spec : Iir;
begin
Sub_Chain_Init (First, Last);
El := Get_Declaration_Chain (Decl);
while Is_Valid (El) loop
- if Get_Kind (El) = Iir_Kind_Package_Declaration then
- Orig := Get_Package_Origin (El);
- if Orig /= Null_Iir
- and then Get_Need_Body (Get_Uninstantiated_Package_Decl (Orig))
+ if Get_Kind (El) = Iir_Kind_Package_Instantiation_Declaration then
+ Spec := Get_Uninstantiated_Package_Decl (El);
+ if Get_Macro_Expanded_Flag (Spec)
+ and then Get_Need_Body (Spec)
then
-- That's a package instantiation of a package that needs a
-- body. Therefore, the instantiation also needs a body.
@@ -2667,11 +2647,9 @@ package body Canon is
return First;
end Create_Instantiation_Bodies;
- function Canon_Declaration (Top : Iir_Design_Unit;
- Decl : Iir;
- Parent : Iir;
- Decl_Parent : Iir)
- return Iir
+ function Canon_Declaration
+ (Top : Iir_Design_Unit; Decl : Iir; Parent : Iir; Decl_Parent : Iir)
+ return Iir
is
Stmts : Iir;
begin
diff --git a/src/vhdl/sem_inst.adb b/src/vhdl/sem_inst.adb
index caba67456..b396e6327 100644
--- a/src/vhdl/sem_inst.adb
+++ b/src/vhdl/sem_inst.adb
@@ -861,8 +861,7 @@ package body Sem_Inst is
function Instantiate_Package_Body (Inst : Iir) return Iir
is
- Inst_Decl : constant Iir := Get_Package_Origin (Inst);
- Pkg : constant Iir := Get_Uninstantiated_Package_Decl (Inst_Decl);
+ Pkg : constant Iir := Get_Uninstantiated_Package_Decl (Inst);
Prev_Instance_File : constant Source_File_Entry := Instance_File;
Mark : constant Instance_Index_Type := Prev_Instance_Table.Last;
Res : Iir;
@@ -877,7 +876,6 @@ package body Sem_Inst is
Set_Instance (Pkg, Inst);
declare
Pkg_Hdr : constant Iir := Get_Package_Header (Pkg);
- Inst_Hdr : constant Iir := Get_Package_Header (Inst);
Pkg_El : Iir;
Inst_El : Iir;
Inter_El : Iir;
@@ -886,7 +884,7 @@ package body Sem_Inst is
-- In the body, references to interface object are redirected to the
-- instantiated interface objects.
Pkg_El := Get_Generic_Chain (Pkg_Hdr);
- Inst_El := Get_Generic_Chain (Inst_Hdr);
+ Inst_El := Get_Generic_Chain (Inst);
while Is_Valid (Pkg_El) loop
if Get_Kind (Pkg_El) in Iir_Kinds_Interface_Object_Declaration then
Set_Instance (Pkg_El, Inst_El);
@@ -897,8 +895,8 @@ package body Sem_Inst is
-- In the body, references to interface type are substitued to the
-- mapped type.
- Inst_El := Get_Generic_Map_Aspect_Chain (Inst_Hdr);
- Inter_El := Get_Generic_Chain (Inst_Hdr);
+ Inst_El := Get_Generic_Map_Aspect_Chain (Inst);
+ Inter_El := Get_Generic_Chain (Inst);
while Is_Valid (Inst_El) loop
case Get_Kind (Inst_El) is
when Iir_Kind_Association_Element_Type =>
diff --git a/src/vhdl/translate/trans-chap12.adb b/src/vhdl/translate/trans-chap12.adb
index 4d25fd77e..28883babb 100644
--- a/src/vhdl/translate/trans-chap12.adb
+++ b/src/vhdl/translate/trans-chap12.adb
@@ -711,9 +711,7 @@ package body Trans.Chap12 is
Lib_Unit := Get_Library_Unit (Unit);
case Get_Kind (Lib_Unit) is
when Iir_Kind_Package_Declaration =>
- if not Get_Elab_Flag (Unit)
- and then Get_Package_Origin (Lib_Unit) = Null_Iir
- then
+ if not Get_Elab_Flag (Unit) then
Chap2.Elab_Package_Body (Lib_Unit, Null_Iir);
end if;
when Iir_Kind_Entity_Declaration =>
diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb
index 015bca20d..065a85f52 100644
--- a/src/vhdl/translate/trans-chap2.adb
+++ b/src/vhdl/translate/trans-chap2.adb
@@ -755,21 +755,20 @@ package body Trans.Chap2 is
Pop_Instance_Factory (Info.Package_Body_Scope'Access);
end Pop_Package_Instance_Factory;
- procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration)
+ -- Translate a package declaration or a macro-expanded package
+ -- instantiation. HEADER is the node containing generic and generic_map.
+ procedure Translate_Package (Decl : Iir; Header : Iir)
is
Is_Nested : constant Boolean := Is_Nested_Package (Decl);
- Header : constant Iir := Get_Package_Header (Decl);
+ Is_Uninstantiated : constant Boolean :=
+ Get_Kind (Decl) = Iir_Kind_Package_Declaration
+ and then Is_Uninstantiated_Package (Decl);
Mark : Id_Mark_Type;
Info : Ortho_Info_Acc;
Interface_List : O_Inter_List;
Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack;
Bod : Iir;
begin
- -- Skip uninstantiated package that have to be macro-expanded.
- if Get_Macro_Expanded_Flag (Decl) then
- return;
- end if;
-
Info := Add_Info (Decl, Kind_Package);
if Is_Nested then
@@ -777,7 +776,7 @@ package body Trans.Chap2 is
end if;
-- Translate declarations.
- if Is_Uninstantiated_Package (Decl) then
+ if Is_Uninstantiated then
-- Create an instance for the spec.
Push_Instance_Factory (Info.Package_Spec_Scope'Access);
Chap4.Translate_Generic_Chain (Header);
@@ -806,10 +805,6 @@ package body Trans.Chap2 is
Chap4.Translate_Generic_Chain (Header);
end if;
Chap4.Translate_Declaration_Chain (Decl);
- Bod := Get_Package_Instantiation_Bodies_Chain (Decl);
- if Is_Valid (Bod) then
- Chap4.Translate_Declaration_Chain (Bod);
- end if;
if not Is_Nested then
Info.Package_Elab_Var := Create_Var
(Create_Var_Identifier ("ELABORATED"), Ghdl_Bool_Type);
@@ -821,9 +816,17 @@ package body Trans.Chap2 is
-- For nested package, this will be translated when translating
-- subprograms.
Chap4.Translate_Declaration_Chain_Subprograms (Decl);
+ -- Bod := Get_Package_Instantiation_Bodies_Chain (Decl);
+ -- if Is_Valid (Bod) then
+ -- Chap4.Translate_Declaration_Chain_Subprograms (Bod);
+ -- end if;
+ end if;
+
+ -- Translate bodies of instances.
+ if Get_Kind (Decl) = Iir_Kind_Package_Declaration then
Bod := Get_Package_Instantiation_Bodies_Chain (Decl);
if Is_Valid (Bod) then
- Chap4.Translate_Declaration_Chain_Subprograms (Bod);
+ Chap4.Translate_Declaration_Chain (Bod);
end if;
end if;
@@ -837,7 +840,7 @@ package body Trans.Chap2 is
(Interface_List, Info.Package_Elab_Body_Subprg);
end if;
- if Is_Uninstantiated_Package (Decl) then
+ if Is_Uninstantiated then
Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance);
-- The spec elaborator has a spec instance argument.
@@ -862,16 +865,16 @@ package body Trans.Chap2 is
if Global_Storage = O_Storage_Public then
-- Create elaboration procedure for the spec
- Elab_Package (Decl);
+ Elab_Package (Decl, Header);
end if;
end if;
- if Is_Uninstantiated_Package (Decl) then
+ if Is_Uninstantiated then
Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance);
end if;
Save_Local_Identifier (Info.Package_Local_Id);
- if Is_Uninstantiated_Package (Decl)
+ if Is_Uninstantiated
and then not Get_Need_Body (Decl)
and then Get_Package_Body (Decl) = Null_Iir
then
@@ -884,18 +887,58 @@ package body Trans.Chap2 is
if Is_Nested then
Pop_Identifier_Prefix (Mark);
end if;
+ end Translate_Package;
+
+ procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration)
+ is
+ El : Iir;
+ Bod : Iir;
+ begin
+ -- Skip uninstantiated package that have to be macro-expanded.
+ if Get_Macro_Expanded_Flag (Decl) then
+ return;
+ end if;
+
+ Translate_Package (Decl, Get_Package_Header (Decl));
+
+ if Global_Storage = O_Storage_Public then
+ -- If there are package instances declared that were macro-expanded
+ -- and if the package has (possibly) no body, translate the bodies
+ -- of the instances.
+ if Get_Need_Instance_Bodies (Decl)
+-- and not Get_Need_Body (Decl)
+ then
+ El := Get_Declaration_Chain (Decl);
+ while Is_Valid (El) loop
+ if Get_Kind (El) = Iir_Kind_Package_Instantiation_Declaration
+ then
+ Bod := Get_Package_Body (El);
+ if Is_Valid (Bod) then
+ Translate_Package_Body (Bod);
+ end if;
+ end if;
+ El := Get_Chain (El);
+ end loop;
+ end if;
+ end if;
end Translate_Package_Declaration;
procedure Translate_Package_Body (Bod : Iir_Package_Body)
is
Is_Nested : constant Boolean := Is_Nested_Package (Bod);
Spec : constant Iir_Package_Declaration := Get_Package (Bod);
+
+ -- True if the package spec is a package declaration. It could be a
+ -- package instantiation declaration.
+ Is_Spec_Decl : constant Boolean :=
+ Get_Kind (Spec) = Iir_Kind_Package_Declaration;
+
Info : constant Ortho_Info_Acc := Get_Info (Spec);
Prev_Storage : constant O_Storage := Global_Storage;
Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack;
Mark : Id_Mark_Type;
begin
- if Get_Macro_Expanded_Flag (Spec) then
+ if Is_Spec_Decl and then Get_Macro_Expanded_Flag (Spec) then
return;
end if;
@@ -904,7 +947,7 @@ package body Trans.Chap2 is
end if;
-- Translate declarations.
- if Is_Uninstantiated_Package (Spec) then
+ if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then
Push_Package_Instance_Factory (Spec);
-- Translate the specifications.
@@ -921,7 +964,7 @@ package body Trans.Chap2 is
return;
end if;
- if not Is_Uninstantiated_Package (Spec) then
+ if not (Is_Spec_Decl and then Is_Uninstantiated_Package (Spec)) then
Restore_Local_Identifier (Info.Package_Local_Id);
Chap4.Translate_Declaration_Chain (Bod);
@@ -935,7 +978,7 @@ package body Trans.Chap2 is
Rtis.Generate_Unit (Bod);
end if;
- if Is_Uninstantiated_Package (Spec) then
+ if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then
-- Add access to the specs.
Subprgs.Push_Subprg_Instance
(Info.Package_Body_Scope'Access, Info.Package_Body_Ptr_Type,
@@ -945,13 +988,13 @@ package body Trans.Chap2 is
Info.Package_Body_Scope'Access);
end if;
- if not Is_Nested then
+ if not Is_Nested or else not Is_Spec_Decl then
-- Translate subprograms. For nested package, this has to be called
-- when translating subprograms.
Chap4.Translate_Declaration_Chain_Subprograms (Bod);
end if;
- if Is_Uninstantiated_Package (Spec) then
+ if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then
Clear_Scope (Info.Package_Spec_Scope);
Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance);
end if;
@@ -967,7 +1010,8 @@ package body Trans.Chap2 is
end if;
end Translate_Package_Body;
- procedure Elab_Package (Spec : Iir_Package_Declaration)
+ -- Elaborate a package or a package instantiation.
+ procedure Elab_Package (Spec : Iir; Header : Iir)
is
Is_Nested : constant Boolean := Is_Nested_Package (Spec);
Info : constant Ortho_Info_Acc := Get_Info (Spec);
@@ -982,8 +1026,8 @@ package body Trans.Chap2 is
Elab_Dependence (Get_Design_Unit (Spec));
- if not Is_Uninstantiated_Package (Spec)
- and then Get_Kind (Get_Parent (Spec)) = Iir_Kind_Design_Unit
+ if not (Get_Kind (Spec) = Iir_Kind_Package_Declaration
+ and then Is_Uninstantiated_Package (Spec))
then
-- Register the top level package. This is done dynamically, as
-- we know only during elaboration that the design depends on a
@@ -999,9 +1043,11 @@ package body Trans.Chap2 is
Open_Temp;
end if;
- if Is_Generic_Mapped_Package (Spec) then
+ if Is_Valid (Header)
+ and then Is_Valid (Get_Generic_Map_Aspect_Chain (Header))
+ then
Chap5.Elab_Generic_Map_Aspect
- (Get_Package_Header (Spec), Get_Package_Header (Spec),
+ (Header, Header,
(Info.Package_Spec_Scope'Access, Info.Package_Spec_Scope));
end if;
Chap4.Elab_Declaration_Chain (Spec, Final);
@@ -1017,16 +1063,23 @@ package body Trans.Chap2 is
procedure Elab_Package_Body (Spec : Iir_Package_Declaration; Bod : Iir)
is
+ Is_Spec_Decl : constant Boolean :=
+ Get_Kind (Spec) = Iir_Kind_Package_Declaration;
+
Info : constant Ortho_Info_Acc := Get_Info (Spec);
If_Blk : O_If_Block;
Constr : O_Assoc_List;
Final : Boolean;
begin
+ if Is_Spec_Decl and then Get_Macro_Expanded_Flag (Spec) then
+ return;
+ end if;
+
Start_Subprogram_Body (Info.Package_Elab_Body_Subprg);
Push_Local_Factory;
Subprgs.Start_Subprg_Instance_Use (Info.Package_Elab_Body_Instance);
- if Is_Uninstantiated_Package (Spec) then
+ if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then
Set_Scope_Via_Field (Info.Package_Spec_Scope,
Info.Package_Spec_Field,
Info.Package_Body_Scope'Access);
@@ -1053,7 +1106,7 @@ package body Trans.Chap2 is
Close_Temp;
end if;
- if Is_Uninstantiated_Package (Spec) then
+ if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then
Clear_Scope (Info.Package_Spec_Scope);
end if;
@@ -1346,8 +1399,25 @@ package body Trans.Chap2 is
Info : Ortho_Info_Acc;
Interface_List : O_Inter_List;
begin
- -- Canon must have replaced instatiation by generic-mapped packages.
- pragma Assert (not Get_Macro_Expanded_Flag (Spec));
+ if Get_Macro_Expanded_Flag (Spec) then
+ -- Macro-expanded instantiations are translated like a package.
+ Translate_Package (Inst, Inst);
+
+ -- For top-level package, generate code for the body.
+ if Global_Storage = O_Storage_Public
+ and then not Is_Nested_Package (Inst)
+ then
+ declare
+ Bod : constant Iir := Get_Package_Body (Inst);
+ begin
+ if Is_Valid (Bod) then
+ Translate_Package_Body (Bod);
+ end if;
+ end;
+ end if;
+
+ return;
+ end if;
Instantiate_Info_Package (Inst);
Info := Get_Info (Inst);
@@ -1402,6 +1472,11 @@ package body Trans.Chap2 is
Info : constant Ortho_Info_Acc := Get_Info (Inst);
Constr : O_Assoc_List;
begin
+ if Get_Macro_Expanded_Flag (Spec) then
+ Elab_Package (Inst, Inst);
+ return;
+ end if;
+
Set_Scope_Via_Var (Pkg_Info.Package_Body_Scope,
Info.Package_Instance_Body_Var);
@@ -1423,22 +1498,12 @@ package body Trans.Chap2 is
Clear_Scope (Pkg_Info.Package_Body_Scope);
end Elab_Package_Instantiation_Declaration;
- procedure Elab_Dependence_Package (Pkg : Iir_Package_Declaration)
+ procedure Elab_Dependence_Package (Pkg : Iir)
is
Info : Ortho_Info_Acc;
If_Blk : O_If_Block;
Constr : O_Assoc_List;
begin
- -- Std.Standard is pre-elaborated.
- if Pkg = Standard_Package then
- return;
- end if;
-
- -- Nothing to do for uninstantiated package.
- if Is_Uninstantiated_Package (Pkg) then
- return;
- end if;
-
-- Call the package elaborator only if not already elaborated.
Info := Get_Info (Pkg);
Start_If_Stmt
@@ -1451,13 +1516,36 @@ package body Trans.Chap2 is
Finish_If_Stmt (If_Blk);
end Elab_Dependence_Package;
- procedure Elab_Dependence_Package_Instantiation (Pkg : Iir)
- is
- Info : constant Ortho_Info_Acc := Get_Info (Pkg);
- Constr : O_Assoc_List;
+ procedure Elab_Dependence_Package_Declaration
+ (Pkg : Iir_Package_Declaration) is
begin
- Start_Association (Constr, Info.Package_Instance_Elab_Subprg);
- New_Procedure_Call (Constr);
+ -- Std.Standard is pre-elaborated.
+ if Pkg = Standard_Package then
+ return;
+ end if;
+
+ -- Nothing to do for uninstantiated package.
+ if Is_Uninstantiated_Package (Pkg) then
+ return;
+ end if;
+
+ Elab_Dependence_Package (Pkg);
+ end Elab_Dependence_Package_Declaration;
+
+ procedure Elab_Dependence_Package_Instantiation (Pkg : Iir) is
+ begin
+ if Get_Macro_Expanded_Flag (Get_Uninstantiated_Package_Decl (Pkg)) then
+ -- Handled as a normal package
+ Elab_Dependence_Package (Pkg);
+ else
+ declare
+ Info : constant Ortho_Info_Acc := Get_Info (Pkg);
+ Constr : O_Assoc_List;
+ begin
+ Start_Association (Constr, Info.Package_Instance_Elab_Subprg);
+ New_Procedure_Call (Constr);
+ end;
+ end if;
end Elab_Dependence_Package_Instantiation;
procedure Elab_Dependence (Design_Unit: Iir_Design_Unit)
@@ -1475,7 +1563,7 @@ package body Trans.Chap2 is
Library_Unit := Get_Library_Unit (Design);
case Get_Kind (Library_Unit) is
when Iir_Kind_Package_Declaration =>
- Elab_Dependence_Package (Library_Unit);
+ Elab_Dependence_Package_Declaration (Library_Unit);
when Iir_Kind_Package_Instantiation_Declaration =>
Elab_Dependence_Package_Instantiation (Library_Unit);
when Iir_Kind_Entity_Declaration =>
diff --git a/src/vhdl/translate/trans-chap2.ads b/src/vhdl/translate/trans-chap2.ads
index 74247d6e1..4d81c2bf6 100644
--- a/src/vhdl/translate/trans-chap2.ads
+++ b/src/vhdl/translate/trans-chap2.ads
@@ -35,7 +35,7 @@ package Trans.Chap2 is
procedure Translate_Package_Body (Bod : Iir_Package_Body);
procedure Translate_Package_Instantiation_Declaration (Inst : Iir);
- procedure Elab_Package (Spec : Iir_Package_Declaration);
+ procedure Elab_Package (Spec : Iir; Header : Iir);
procedure Elab_Package_Body (Spec : Iir_Package_Declaration; Bod : Iir);
procedure Elab_Package_Instantiation_Declaration (Inst : Iir);
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 14d04d486..ba5853935 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -2388,6 +2388,18 @@ package body Trans.Chap4 is
Translate_Declaration_Chain_Subprograms (El);
Pop_Identifier_Prefix (Mark);
end;
+ when Iir_Kind_Package_Instantiation_Declaration =>
+ if Get_Macro_Expanded_Flag
+ (Get_Uninstantiated_Package_Decl (El))
+ then
+ declare
+ Mark : Id_Mark_Type;
+ begin
+ Push_Identifier_Prefix (Mark, Get_Identifier (El));
+ Translate_Declaration_Chain_Subprograms (El);
+ Pop_Identifier_Prefix (Mark);
+ end;
+ end if;
when others =>
null;
end case;
@@ -2485,7 +2497,7 @@ package body Trans.Chap4 is
null;
when Iir_Kind_Package_Declaration =>
- Chap2.Elab_Package (Decl);
+ Chap2.Elab_Package (Decl, Get_Package_Header (Decl));
-- FIXME: finalizer
when Iir_Kind_Package_Body =>
declare
diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb
index 672ef9b5b..7623b5032 100644
--- a/src/vhdl/translate/trans-rtis.adb
+++ b/src/vhdl/translate/trans-rtis.adb
@@ -2606,7 +2606,8 @@ package body Trans.Rtis is
Field_Off := O_Cnode_Null;
case Get_Kind (Blk) is
- when Iir_Kind_Package_Declaration =>
+ when Iir_Kind_Package_Declaration
+ | Iir_Kind_Package_Instantiation_Declaration =>
Kind := Ghdl_Rtik_Package;
Generate_Declaration_Chain (Get_Declaration_Chain (Blk), Rti);
when Iir_Kind_Package_Body =>
@@ -2747,7 +2748,8 @@ package body Trans.Rtis is
when Iir_Kind_Process_Statement
| Iir_Kind_Sensitized_Process_Statement =>
Info.Process_Rti_Const := Rti;
- when Iir_Kind_Package_Declaration =>
+ when Iir_Kind_Package_Declaration
+ | Iir_Kind_Package_Instantiation_Declaration =>
Info.Package_Rti_Const := Rti;
when Iir_Kind_Package_Body =>
-- Replace package declaration RTI with the body one.
@@ -2861,8 +2863,9 @@ package body Trans.Rtis is
-- Compute parent RTI.
case Get_Kind (Lib_Unit) is
when Iir_Kind_Package_Declaration
- | Iir_Kind_Entity_Declaration
- | Iir_Kind_Configuration_Declaration =>
+ | Iir_Kind_Entity_Declaration
+ | Iir_Kind_Configuration_Declaration
+ | Iir_Kind_Package_Instantiation_Declaration =>
-- The library.
declare
Lib : Iir_Library_Declaration;