aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-11-02 05:32:48 +0100
committerTristan Gingold <tgingold@free.fr>2014-11-02 05:32:48 +0100
commitaf5eebc96a1e2a445b6199d3a5b15beec870bb32 (patch)
tree6f25c0410fddc354690a5107e8ec0d4099984b82
parentad9367ec8a27a56e0a83f91ee0cc50785d076862 (diff)
downloadghdl-af5eebc96a1e2a445b6199d3a5b15beec870bb32.tar.gz
ghdl-af5eebc96a1e2a445b6199d3a5b15beec870bb32.tar.bz2
ghdl-af5eebc96a1e2a445b6199d3a5b15beec870bb32.zip
Fix package interface for gcc (separate compilation).
-rw-r--r--sem_inst.adb3
-rw-r--r--translate/translation.adb46
2 files changed, 34 insertions, 15 deletions
diff --git a/sem_inst.adb b/sem_inst.adb
index d6368397f..a9ba7560e 100644
--- a/sem_inst.adb
+++ b/sem_inst.adb
@@ -360,7 +360,8 @@ package body Sem_Inst is
case F is
when Field_Index_Subtype_List =>
-- Index_Subtype_List is always a reference, so retrieve
- -- the instance of the referenced list.
+ -- the instance of the referenced list. This is a special
+ -- case because there is no origins for list.
declare
List : Iir_List;
begin
diff --git a/translate/translation.adb b/translate/translation.adb
index b2b21f3cc..7c5fbe85c 100644
--- a/translate/translation.adb
+++ b/translate/translation.adb
@@ -1570,8 +1570,14 @@ package body Translation is
Package_Local_Id : Local_Identifier_Type;
when Kind_Package_Instance =>
- -- The variable containing the instance.
- Package_Instance_Var : Var_Type;
+ -- The variables containing the instance. There are two variables
+ -- for interface package: one for the spec, one for the body.
+ -- For package instantiation, only the variable for the body is
+ -- used. The variable for spec is added so that packages with
+ -- package interfaces don't need to know the body of their
+ -- interfaces.
+ Package_Instance_Spec_Var : Var_Type;
+ Package_Instance_Body_Var : Var_Type;
-- Elaboration procedure for the instance.
Package_Instance_Elab_Subprg : O_Dnode;
@@ -5888,14 +5894,14 @@ package body Translation is
-- FIXME: if the instantiation occurs within a package declaration,
-- the variable must be declared extern (and public in the body).
- Info.Package_Instance_Var := Create_Var
+ Info.Package_Instance_Body_Var := Create_Var
(Create_Var_Identifier (Inst),
Get_Scope_Type (Pkg_Info.Package_Body_Scope));
-- FIXME: this is correct only for global instantiation, and only if
-- there is only one.
Set_Scope_Via_Decl (Info.Package_Instance_Body_Scope,
- Get_Var_Label (Info.Package_Instance_Var));
+ Get_Var_Label (Info.Package_Instance_Body_Var));
Set_Scope_Via_Field (Info.Package_Instance_Spec_Scope,
Pkg_Info.Package_Spec_Field,
Info.Package_Instance_Body_Scope'Access);
@@ -5920,7 +5926,7 @@ package body Translation is
Elab_Dependence (Get_Design_Unit (Inst));
Set_Scope_Via_Decl (Pkg_Info.Package_Body_Scope,
- Get_Var_Label (Info.Package_Instance_Var));
+ Get_Var_Label (Info.Package_Instance_Body_Var));
Set_Scope_Via_Field (Pkg_Info.Package_Spec_Scope,
Pkg_Info.Package_Spec_Field,
Pkg_Info.Package_Body_Scope'Access);
@@ -5932,7 +5938,7 @@ package body Translation is
-- temporary associated with the instance variable.
Start_Association (Constr, Pkg_Info.Package_Elab_Body_Subprg);
Set_Scope_Via_Decl (Pkg_Info.Package_Body_Scope,
- Get_Var_Label (Info.Package_Instance_Var));
+ Get_Var_Label (Info.Package_Instance_Body_Var));
Add_Subprg_Instance_Assoc
(Constr, Pkg_Info.Package_Elab_Body_Instance);
Clear_Scope (Pkg_Info.Package_Body_Scope);
@@ -9698,16 +9704,22 @@ package body Translation is
begin
Chap2.Instantiate_Info_Package (Inter);
Info := Get_Info (Inter);
- Info.Package_Instance_Var :=
- Create_Var (Create_Var_Identifier (Inter),
+
+ -- The spec
+ Info.Package_Instance_Spec_Var :=
+ Create_Var (Create_Var_Identifier (Inter, "SPEC", 0),
+ Pkg_Info.Package_Spec_Ptr_Type);
+ Set_Scope_Via_Var_Ptr
+ (Info.Package_Instance_Spec_Scope,
+ Info.Package_Instance_Spec_Var);
+
+ -- The body
+ Info.Package_Instance_Body_Var :=
+ Create_Var (Create_Var_Identifier (Inter, "BODY", 0),
Pkg_Info.Package_Body_Ptr_Type);
Set_Scope_Via_Var_Ptr
(Info.Package_Instance_Body_Scope,
- Info.Package_Instance_Var);
- Set_Scope_Via_Field
- (Info.Package_Instance_Spec_Scope,
- Pkg_Info.Package_Spec_Field,
- Info.Package_Instance_Body_Scope'Access);
+ Info.Package_Instance_Body_Var);
end Create_Package_Interface;
procedure Allocate_Complex_Object (Obj_Type : Iir;
@@ -12790,7 +12802,13 @@ package body Translation is
Get_Info (Actual);
begin
New_Assign_Stmt
- (Get_Var (Formal_Info.Package_Instance_Var),
+ (Get_Var (Formal_Info.Package_Instance_Spec_Var),
+ New_Address
+ (Get_Instance_Ref
+ (Actual_Info.Package_Instance_Spec_Scope),
+ Uninst_Info.Package_Spec_Ptr_Type));
+ New_Assign_Stmt
+ (Get_Var (Formal_Info.Package_Instance_Body_Var),
New_Address
(Get_Instance_Ref
(Actual_Info.Package_Instance_Body_Scope),