diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-10-19 04:13:48 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-10-19 04:15:12 +0200 |
commit | ab0e8ee2d7a77ce7eb2a935be378bd94d1155901 (patch) | |
tree | d531d64e0fe01f6c6239dfa92e4e580e2e513d59 /src/vhdl/translate | |
parent | 1a937d7be6bc85c9fe79d00184762e9ddad9460c (diff) | |
download | ghdl-ab0e8ee2d7a77ce7eb2a935be378bd94d1155901.tar.gz ghdl-ab0e8ee2d7a77ce7eb2a935be378bd94d1155901.tar.bz2 ghdl-ab0e8ee2d7a77ce7eb2a935be378bd94d1155901.zip |
canon: do not set formal of association by position.
Diffstat (limited to 'src/vhdl/translate')
-rw-r--r-- | src/vhdl/translate/trans-chap1.adb | 14 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap2.adb | 9 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap4.adb | 27 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap4.ads | 4 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap5.adb | 53 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap5.ads | 9 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 12 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap8.adb | 173 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap9.adb | 35 | ||||
-rw-r--r-- | src/vhdl/translate/trans_analyzes.adb | 10 |
10 files changed, 186 insertions, 160 deletions
diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb index 4c5083ef6..a84442df4 100644 --- a/src/vhdl/translate/trans-chap1.adb +++ b/src/vhdl/translate/trans-chap1.adb @@ -392,6 +392,10 @@ package body Trans.Chap1 is end if; Entity_Aspect := Get_Entity_Aspect (Binding); + if Get_Kind (Entity_Aspect) = Iir_Kind_Entity_Aspect_Open then + -- Unbound component. + return; + end if; Comp := Get_Named_Entity (Get_Component_Name (Cfg)); Comp_Info := Get_Info (Comp); @@ -530,13 +534,21 @@ package body Trans.Chap1 is procedure Translate_Component_Configuration_Call (Cfg : Iir; Base_Block : Iir; Block_Info : Block_Info_Acc) is + Binding : constant Iir := Get_Binding_Indication (Cfg); + Aspect : Iir; Cfg_Info : Config_Info_Acc; Base_Info : Block_Info_Acc; begin - if Get_Binding_Indication (Cfg) = Null_Iir then + if Is_Null (Binding) then -- Unbound component configuration, nothing to do. return; end if; + Aspect := Get_Entity_Aspect (Binding); + if Is_Null (Aspect) + or else Get_Kind (Aspect) = Iir_Kind_Entity_Aspect_Open + then + return; + end if; Cfg_Info := Get_Info (Cfg); Base_Info := Get_Info (Base_Block); diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index f011020f1..d721a7816 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -1001,8 +1001,8 @@ package body Trans.Chap2 is if Is_Generic_Mapped_Package (Spec) then Chap5.Elab_Generic_Map_Aspect - (Get_Package_Header (Spec), (Info.Package_Spec_Scope'Access, - Info.Package_Spec_Scope)); + (Get_Package_Header (Spec), Get_Package_Header (Spec), + (Info.Package_Spec_Scope'Access, Info.Package_Spec_Scope)); end if; Chap4.Elab_Declaration_Chain (Spec, Final); @@ -1404,8 +1404,9 @@ package body Trans.Chap2 is Set_Scope_Via_Field (Pkg_Info.Package_Spec_Scope, Pkg_Info.Package_Spec_Field, Pkg_Info.Package_Body_Scope'Access); - Chap5.Elab_Generic_Map_Aspect (Inst, (Pkg_Info.Package_Body_Scope'Access, - Pkg_Info.Package_Body_Scope)); + Chap5.Elab_Generic_Map_Aspect + (Get_Package_Header (Spec), Inst, + (Pkg_Info.Package_Body_Scope'Access, Pkg_Info.Package_Body_Scope)); Clear_Scope (Pkg_Info.Package_Spec_Scope); -- Call the elaborator of the generic. The generic must be diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb index e59e7945c..14d04d486 100644 --- a/src/vhdl/translate/trans-chap4.adb +++ b/src/vhdl/translate/trans-chap4.adb @@ -2550,12 +2550,13 @@ package body Trans.Chap4 is (Stmt : Iir; Block : Iir; Assoc : Iir; + Inter : Iir; Mode : Conv_Mode; Conv_Info : in out Assoc_Conv_Info; Base_Block : Iir; Entity : Iir) is - Formal : constant Iir := Get_Formal (Assoc); + Formal : constant Iir := Get_Association_Formal (Assoc, Inter); Actual : constant Iir := Get_Actual (Assoc); Mark2, Mark3 : Id_Mark_Type; @@ -2598,7 +2599,7 @@ package body Trans.Chap4 is end case; -- FIXME: individual assoc -> overload. Push_Identifier_Prefix - (Mark3, Get_Identifier (Get_Association_Interface (Assoc))); + (Mark3, Get_Identifier (Get_Association_Interface (Assoc, Inter))); -- Handle anonymous subtypes. Chap3.Translate_Anonymous_Type_Definition (Out_Type); @@ -2835,9 +2836,15 @@ package body Trans.Chap4 is (Stmt : Iir; Block : Iir; Base_Block : Iir; Entity : Iir) is Assoc : Iir; + Inter : Iir; Info : Assoc_Info_Acc; begin Assoc := Get_Port_Map_Aspect_Chain (Stmt); + if Is_Null (Entity) then + Inter := Get_Port_Chain (Stmt); + else + Inter := Get_Port_Chain (Entity); + end if; while Assoc /= Null_Iir loop if Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression then @@ -2845,7 +2852,7 @@ package body Trans.Chap4 is if Get_In_Conversion (Assoc) /= Null_Iir then Info := Add_Info (Assoc, Kind_Assoc); Translate_Association_Subprogram - (Stmt, Block, Assoc, Conv_Mode_In, Info.Assoc_In, + (Stmt, Block, Assoc, Inter, Conv_Mode_In, Info.Assoc_In, Base_Block, Entity); end if; if Get_Out_Conversion (Assoc) /= Null_Iir then @@ -2853,11 +2860,11 @@ package body Trans.Chap4 is Info := Add_Info (Assoc, Kind_Assoc); end if; Translate_Association_Subprogram - (Stmt, Block, Assoc, Conv_Mode_Out, Info.Assoc_Out, + (Stmt, Block, Assoc, Inter, Conv_Mode_Out, Info.Assoc_Out, Base_Block, Entity); end if; end if; - Assoc := Get_Chain (Assoc); + Next_Association_Interface (Assoc, Inter); end loop; end Translate_Association_Subprograms; @@ -2983,22 +2990,24 @@ package body Trans.Chap4 is end Elab_Conversion; -- In conversion: from actual to formal. - procedure Elab_In_Conversion (Assoc : Iir; Ndest : out Mnode) + procedure Elab_In_Conversion (Assoc : Iir; Inter : Iir; Ndest : out Mnode) is Assoc_Info : constant Assoc_Info_Acc := Get_Info (Assoc); begin Elab_Conversion - (Get_Actual (Assoc), Get_Formal (Assoc), + (Get_Actual (Assoc), Get_Association_Formal (Assoc, Inter), Ghdl_Signal_In_Conversion, Assoc_Info.Assoc_In, Ndest); end Elab_In_Conversion; -- Out conversion: from formal to actual. - procedure Elab_Out_Conversion (Assoc : Iir; Ndest : out Mnode) + procedure Elab_Out_Conversion (Assoc : Iir; Inter : Iir; Ndest : out Mnode) is + -- Note: because it's an out conversion, the formal of ASSOC is set. + -- Still pass INTER for coherence with Elab_In_Conversion. Assoc_Info : constant Assoc_Info_Acc := Get_Info (Assoc); begin Elab_Conversion - (Get_Formal (Assoc), Get_Actual (Assoc), + (Get_Association_Formal (Assoc, Inter), Get_Actual (Assoc), Ghdl_Signal_Out_Conversion, Assoc_Info.Assoc_Out, Ndest); end Elab_Out_Conversion; diff --git a/src/vhdl/translate/trans-chap4.ads b/src/vhdl/translate/trans-chap4.ads index d91f0ee52..3505fac4e 100644 --- a/src/vhdl/translate/trans-chap4.ads +++ b/src/vhdl/translate/trans-chap4.ads @@ -51,8 +51,8 @@ package Trans.Chap4 is -- Elaborate In/Out_Conversion for ASSOC (signals only). -- NDEST is the data structure to be registered. - procedure Elab_In_Conversion (Assoc : Iir; Ndest : out Mnode); - procedure Elab_Out_Conversion (Assoc : Iir; Ndest : out Mnode); + procedure Elab_In_Conversion (Assoc : Iir; Inter : Iir; Ndest : out Mnode); + procedure Elab_Out_Conversion (Assoc : Iir; Inter : Iir; Ndest : out Mnode); -- Create code to elaborate declarations. -- NEED_FINAL is set when at least one declaration needs to be diff --git a/src/vhdl/translate/trans-chap5.adb b/src/vhdl/translate/trans-chap5.adb index 7a6bb0cfb..18f54fd7e 100644 --- a/src/vhdl/translate/trans-chap5.adb +++ b/src/vhdl/translate/trans-chap5.adb @@ -368,15 +368,16 @@ package body Trans.Chap5 is Finish_Data_Record => Connect_Finish_Data_Composite); procedure Elab_Port_Map_Aspect_Assoc (Assoc : Iir; + Inter : Iir; By_Copy : Boolean; Formal_Env : Map_Env; Actual_Env : Map_Env) is - Formal : constant Iir := Get_Formal (Assoc); + Formal : constant Iir := Get_Association_Formal (Assoc, Inter); Actual : constant Iir := Get_Actual (Assoc); Formal_Type : constant Iir := Get_Type (Formal); Actual_Type : constant Iir := Get_Type (Actual); - Inter : constant Iir := Get_Association_Interface (Assoc); + Port : constant Iir := Get_Interface_Of_Formal (Formal); Formal_Sig : Mnode; Formal_Val : Mnode; Actual_Sig : Mnode; @@ -412,7 +413,7 @@ package body Trans.Chap5 is -- association element that associates an actual -- with S. -- * [...] - case Get_Mode (Inter) is + case Get_Mode (Port) is when Iir_In_Mode => Mode := Connect_Effective; when Iir_Inout_Mode => @@ -473,7 +474,7 @@ package body Trans.Chap5 is Connect (Formal_Sig, Formal_Type, Data); else if Get_In_Conversion (Assoc) /= Null_Iir then - Chap4.Elab_In_Conversion (Assoc, Actual_Sig); + Chap4.Elab_In_Conversion (Assoc, Inter, Actual_Sig); Set_Map_Env (Formal_Env); Formal_Sig := Chap6.Translate_Name (Formal, Mode_Signal); Data := (Actual_Sig => Actual_Sig, @@ -485,7 +486,7 @@ package body Trans.Chap5 is end if; if Get_Out_Conversion (Assoc) /= Null_Iir then -- flow: FORMAL to ACTUAL - Chap4.Elab_Out_Conversion (Assoc, Formal_Sig); + Chap4.Elab_Out_Conversion (Assoc, Inter, Formal_Sig); Set_Map_Env (Actual_Env); Actual_Sig := Chap6.Translate_Name (Actual, Mode_Signal); Data := (Actual_Sig => Actual_Sig, @@ -517,7 +518,8 @@ package body Trans.Chap5 is Tinfo.T.Bounds_Ptr_Type); end Alloc_Bounds; - function Get_Unconstrained_Port_Bounds (Assoc : Iir) return Mnode + function Get_Unconstrained_Port_Bounds (Assoc : Iir; Inter : Iir) + return Mnode is Actual : constant Iir := Get_Actual (Assoc); Actual_Type : constant Iir := Get_Type (Actual); @@ -598,7 +600,7 @@ package body Trans.Chap5 is end if; pragma Assert (Can_Convert); - Res_Type := Get_Type (Get_Association_Interface (Assoc)); + Res_Type := Get_Type (Get_Association_Interface (Assoc, Inter)); Bounds := Get_Actual_Bounds (False); Res := Alloc_Bounds (Res_Type, Alloc_System); Chap7.Translate_Type_Conversion_Bounds @@ -616,7 +618,7 @@ package body Trans.Chap5 is case Iir_Kinds_Association_Element (Get_Kind (Assoc)) is when Iir_Kind_Association_Element_By_Expression => pragma Assert (Get_Whole_Association_Flag (Assoc)); - Bounds := Get_Unconstrained_Port_Bounds (Assoc); + Bounds := Get_Unconstrained_Port_Bounds (Assoc, Port); when Iir_Kind_Association_Element_Open => declare Actual_Type : constant Iir := @@ -648,19 +650,21 @@ package body Trans.Chap5 is end Elab_Unconstrained_Port_Bounds; procedure Elab_Port_Map_Aspect - (Mapping : Iir; Block_Parent : Iir; Formal_Env : Map_Env) + (Header : Iir; Map : Iir; Block_Parent : Iir; Formal_Env : Map_Env) is Actual_Env : Map_Env; Assoc : Iir; + Inter : Iir; begin Save_Map_Env (Actual_Env, Formal_Env.Scope_Ptr); -- Ports. - Assoc := Get_Port_Map_Aspect_Chain (Mapping); + Assoc := Get_Port_Map_Aspect_Chain (Map); + Inter := Get_Port_Chain (Header); while Assoc /= Null_Iir loop declare - Formal : constant Iir := Strip_Denoting_Name (Get_Formal (Assoc)); - Formal_Base : constant Iir := Get_Association_Interface (Assoc); + Formal : constant Iir := Get_Association_Formal (Assoc, Inter); + Formal_Base : constant Iir := Get_Interface_Of_Formal (Formal); Fb_Type : constant Iir := Get_Type (Formal_Base); Fbt_Info : constant Type_Info_Acc := Get_Info (Fb_Type); begin @@ -697,14 +701,14 @@ package body Trans.Chap5 is if Get_Collapse_Signal_Flag (Assoc) then -- For collapsed association, copy signals. Elab_Port_Map_Aspect_Assoc - (Assoc, True, Formal_Env, Actual_Env); + (Assoc, Inter, True, Formal_Env, Actual_Env); else -- Create non-collapsed signals. Chap4.Elab_Signal_Declaration_Object (Formal, Block_Parent, False); -- And associate. Elab_Port_Map_Aspect_Assoc - (Assoc, False, Formal_Env, Actual_Env); + (Assoc, Inter, False, Formal_Env, Actual_Env); end if; else -- By sub-element. @@ -712,7 +716,7 @@ package body Trans.Chap5 is -- created. -- And associate. Elab_Port_Map_Aspect_Assoc - (Assoc, False, Formal_Env, Actual_Env); + (Assoc, Inter, False, Formal_Env, Actual_Env); end if; when Iir_Kind_Association_Element_Open | Iir_Kind_Association_Element_By_Individual => @@ -723,24 +727,27 @@ package body Trans.Chap5 is end case; Close_Temp; end; - Assoc := Get_Chain (Assoc); + Next_Association_Interface (Assoc, Inter); end loop; Set_Map_Env (Actual_Env); end Elab_Port_Map_Aspect; - procedure Elab_Generic_Map_Aspect (Mapping : Iir; Formal_Env : Map_Env) + procedure Elab_Generic_Map_Aspect + (Header : Iir; Map : Iir; Formal_Env : Map_Env) is Actual_Env : Map_Env; Assoc : Iir; Formal : Iir; + Inter : Iir; begin Save_Map_Env (Actual_Env, Formal_Env.Scope_Ptr); -- Elab generics, and associate. - Assoc := Get_Generic_Map_Aspect_Chain (Mapping); + Assoc := Get_Generic_Map_Aspect_Chain (Map); + Inter := Get_Generic_Chain (Header); while Assoc /= Null_Iir loop + Formal := Get_Association_Formal (Assoc, Inter); Open_Temp; - Formal := Strip_Denoting_Name (Get_Formal (Assoc)); case Get_Kind (Assoc) is when Iir_Kind_Association_Element_By_Expression => declare @@ -833,12 +840,12 @@ package body Trans.Chap5 is Error_Kind ("elab_generic_map_aspect(1)", Assoc); end case; Close_Temp; - Assoc := Get_Chain (Assoc); + Next_Association_Interface (Assoc, Inter); end loop; end Elab_Generic_Map_Aspect; procedure Elab_Map_Aspect - (Mapping : Iir; Block_Parent : Iir; Formal_Env : Map_Env) is + (Header : Iir; Maps : Iir; Block_Parent : Iir; Formal_Env : Map_Env) is begin -- The use of FORMAL_ENV (and then later ACTUAL_ENV) is rather fragile -- as in some cases both the formal and the actual are referenced in the @@ -848,8 +855,8 @@ package body Trans.Chap5 is -- The generic map must be done before the elaboration of -- the ports, since a port subtype may depend on a generic. - Elab_Generic_Map_Aspect (Mapping, Formal_Env); + Elab_Generic_Map_Aspect (Header, Maps, Formal_Env); - Elab_Port_Map_Aspect (Mapping, Block_Parent, Formal_Env); + Elab_Port_Map_Aspect (Header, Maps, Block_Parent, Formal_Env); end Elab_Map_Aspect; end Trans.Chap5; diff --git a/src/vhdl/translate/trans-chap5.ads b/src/vhdl/translate/trans-chap5.ads index 6902d3b3b..6b545e051 100644 --- a/src/vhdl/translate/trans-chap5.ads +++ b/src/vhdl/translate/trans-chap5.ads @@ -45,7 +45,8 @@ package Trans.Chap5 is procedure Save_Map_Env (Env : out Map_Env; Scope_Ptr : Var_Scope_Acc); procedure Set_Map_Env (Env : Map_Env); - procedure Elab_Generic_Map_Aspect (Mapping : Iir; Formal_Env : Map_Env); + procedure Elab_Generic_Map_Aspect + (Header : Iir; Map : Iir; Formal_Env : Map_Env); -- There are 4 cases of generic/port map: -- 1) component instantiation @@ -54,8 +55,8 @@ package Trans.Chap5 is -- 3) block header -- 4) direct (entity + architecture or configuration) instantiation -- - -- MAPPING is the node containing the generic/port map aspects. - + -- HEADER is the node containing generics and ports declarations. + -- MAPS is the node containing the generic/port map aspects. procedure Elab_Map_Aspect - (Mapping : Iir; Block_Parent : Iir; Formal_Env : Map_Env); + (Header : Iir; Maps : Iir; Block_Parent : Iir; Formal_Env : Map_Env); end Trans.Chap5; diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index c216e199d..f2f1cd906 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -718,29 +718,23 @@ package body Trans.Chap7 is is Imp : constant Iir := Get_Implementation (Call); - function Create_Assoc (Actual : Iir; Formal : Iir) return Iir + function Create_Assoc (Actual : Iir) return Iir is R : Iir; begin R := Create_Iir (Iir_Kind_Association_Element_By_Expression); Location_Copy (R, Actual); Set_Actual (R, Actual); - Set_Formal (R, Formal); return R; end Create_Assoc; - Inter : Iir; El_L : Iir; El_R : Iir; Res : O_Enode; begin - Inter := Get_Interface_Declaration_Chain (Imp); - - El_L := Create_Assoc (Left, Inter); - + El_L := Create_Assoc (Left); if Right /= Null_Iir then - Inter := Get_Chain (Inter); - El_R := Create_Assoc (Right, Inter); + El_R := Create_Assoc (Right); Set_Chain (El_L, El_R); end if; diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb index 296f4de7f..f532afb39 100644 --- a/src/vhdl/translate/trans-chap8.adb +++ b/src/vhdl/translate/trans-chap8.adb @@ -1802,18 +1802,16 @@ package body Trans.Chap8 is procedure Translate_Write_Procedure_Call (Imp : Iir; Param_Chain : Iir) is - F_Assoc : Iir; - Value_Assoc : Iir; + Inter_Chain : constant Iir := Get_Interface_Declaration_Chain (Imp); + F_Assoc : constant Iir := Param_Chain; + Value_Assoc : constant Iir := Get_Chain (Param_Chain); + Value_Inter : constant Iir := Get_Chain (Inter_Chain); + Formal_Type : constant Iir := Get_Type (Value_Inter); + Tinfo : constant Type_Info_Acc := Get_Info (Formal_Type); Value : O_Dnode; - Formal_Type : Iir; - Tinfo : Type_Info_Acc; Assocs : O_Assoc_List; Subprg_Info : Subprg_Info_Acc; begin - F_Assoc := Param_Chain; - Value_Assoc := Get_Chain (Param_Chain); - Formal_Type := Get_Type (Get_Formal (Value_Assoc)); - Tinfo := Get_Info (Formal_Type); case Tinfo.Type_Mode is when Type_Mode_Scalar => Open_Temp; @@ -1862,18 +1860,16 @@ package body Trans.Chap8 is procedure Translate_Read_Procedure_Call (Imp : Iir; Param_Chain : Iir) is - F_Assoc : Iir; - Value_Assoc : Iir; + Inter_Chain : constant Iir := Get_Interface_Declaration_Chain (Imp); + F_Assoc : constant Iir := Param_Chain; + Value_Assoc : constant Iir := Get_Chain (Param_Chain); + Value_Inter : constant Iir := Get_Chain (Inter_Chain); + Formal_Type : constant Iir := Get_Type (Value_Inter); + Tinfo : constant Type_Info_Acc := Get_Info (Formal_Type); Value : Mnode; - Formal_Type : Iir; - Tinfo : Type_Info_Acc; Assocs : O_Assoc_List; Subprg_Info : Subprg_Info_Acc; begin - F_Assoc := Param_Chain; - Value_Assoc := Get_Chain (Param_Chain); - Formal_Type := Get_Type (Get_Formal (Value_Assoc)); - Tinfo := Get_Info (Formal_Type); case Tinfo.Type_Mode is when Type_Mode_Scalar => Open_Temp; @@ -1940,89 +1936,84 @@ package body Trans.Chap8 is Imp : constant Iir := Get_Implementation (Call); Kind : constant Iir_Predefined_Functions := Get_Implicit_Definition (Imp); - Param_Chain : constant Iir := Get_Parameter_Association_Chain (Call); + Assoc_Chain : constant Iir := Get_Parameter_Association_Chain (Call); + Inter_Chain : constant Iir := Get_Interface_Declaration_Chain (Imp); begin case Kind is when Iir_Predefined_Write => - -- Check wether text or not. declare - File_Param : Iir; + File_Assoc : constant Iir := Assoc_Chain; + File_Param : constant Iir := Get_Actual (File_Assoc); + Value_Assoc : constant Iir := Get_Chain (File_Assoc); + Value_Param : constant Iir := Get_Actual (Value_Assoc); Assocs : O_Assoc_List; begin - File_Param := Param_Chain; - -- FIXME: do the test. - if Get_Text_File_Flag (Get_Type (Get_Formal (File_Param))) - then + -- Check whether text or not. + if Get_Text_File_Flag (Get_Type (File_Param)) then -- If text: Start_Association (Assocs, Ghdl_Text_Write); -- compute file parameter (get an index) New_Association - (Assocs, - Chap7.Translate_Expression (Get_Actual (File_Param))); + (Assocs, Chap7.Translate_Expression (File_Param)); -- compute string parameter (get a fat array pointer) New_Association (Assocs, Chap7.Translate_Expression - (Get_Actual (Get_Chain (Param_Chain)), - String_Type_Definition)); + (Value_Param, String_Type_Definition)); -- call a predefined procedure New_Procedure_Call (Assocs); else - Translate_Write_Procedure_Call (Imp, Param_Chain); + Translate_Write_Procedure_Call (Imp, Assoc_Chain); end if; end; when Iir_Predefined_Read_Length => -- FIXME: works only for text read length. declare - File_Param : Iir; - N_Param : Iir; + File_Assoc : constant Iir := Assoc_Chain; + File_Param : constant Iir := Get_Actual (File_Assoc); + N_Assoc : Iir; Assocs : O_Assoc_List; Str : O_Enode; Res : Mnode; begin - File_Param := Param_Chain; - if Get_Text_File_Flag (Get_Type (Get_Formal (File_Param))) - then - N_Param := Get_Chain (File_Param); + if Get_Text_File_Flag (Get_Type (File_Param)) then + N_Assoc := Get_Chain (File_Assoc); Str := Chap7.Translate_Expression - (Get_Actual (N_Param), String_Type_Definition); - N_Param := Get_Chain (N_Param); + (Get_Actual (N_Assoc), String_Type_Definition); + N_Assoc := Get_Chain (N_Assoc); Res := - Chap6.Translate_Name (Get_Actual (N_Param), Mode_Value); + Chap6.Translate_Name (Get_Actual (N_Assoc), Mode_Value); Start_Association (Assocs, Ghdl_Text_Read_Length); -- compute file parameter (get an index) New_Association - (Assocs, - Chap7.Translate_Expression (Get_Actual (File_Param))); + (Assocs, Chap7.Translate_Expression (File_Param)); -- compute string parameter (get a fat array pointer) New_Association (Assocs, Str); -- call a predefined procedure - New_Assign_Stmt - (M2Lv (Res), New_Function_Call (Assocs)); + New_Assign_Stmt (M2Lv (Res), New_Function_Call (Assocs)); else - Translate_Read_Procedure_Call (Imp, Param_Chain); + Translate_Read_Procedure_Call (Imp, Assoc_Chain); end if; end; when Iir_Predefined_Read => - Translate_Read_Procedure_Call (Imp, Param_Chain); + Translate_Read_Procedure_Call (Imp, Assoc_Chain); when Iir_Predefined_Deallocate => - Chap3.Translate_Object_Deallocation (Get_Actual (Param_Chain)); + Chap3.Translate_Object_Deallocation (Get_Actual (Assoc_Chain)); when Iir_Predefined_File_Open => declare - N_Param : Iir; - File_Param : Iir; - Name_Param : Iir; - Kind_Param : Iir; + File_Param : constant Iir := Get_Actual (Assoc_Chain); + Name_Inter : constant Iir := Get_Chain (Inter_Chain); + Name_Assoc : constant Iir := Get_Chain (Assoc_Chain); + Name_Param : constant Iir := Get_Actual (Name_Assoc); + Kind_Inter : constant Iir := Get_Chain (Name_Inter); + Kind_Assoc : constant Iir := Get_Chain (Name_Assoc); + Kind_Param : constant Iir := + Get_Actual_Or_Default (Kind_Assoc, Kind_Inter); Constr : O_Assoc_List; begin - File_Param := Get_Actual (Param_Chain); - N_Param := Get_Chain (Param_Chain); - Name_Param := Get_Actual (N_Param); - N_Param := Get_Chain (N_Param); - Kind_Param := Get_Actual_Or_Default (N_Param); if Get_Text_File_Flag (Get_Type (File_Param)) then Start_Association (Constr, Ghdl_Text_File_Open); else @@ -2045,21 +2036,21 @@ package body Trans.Chap8 is Std_File_Open_Status_Otype : constant O_Tnode := Get_Ortho_Type (File_Open_Status_Type_Definition, Mode_Value); - N_Param : Iir; - Status_Param : constant Iir := Get_Actual (Param_Chain); - File_Param : Iir; - Name_Param : Iir; - Kind_Param : Iir; + Status_Param : constant Iir := Get_Actual (Assoc_Chain); + File_Inter : constant Iir := Get_Chain (Inter_Chain); + File_Assoc : constant Iir := Get_Chain (Assoc_Chain); + File_Param : constant Iir := Get_Actual (File_Assoc); + Name_Inter : constant Iir := Get_Chain (File_Inter); + Name_Assoc : constant Iir := Get_Chain (File_Assoc); + Name_Param : constant Iir := Get_Actual (Name_Assoc); + Kind_Inter : constant Iir := Get_Chain (Name_Inter); + Kind_Assoc : constant Iir := Get_Chain (Name_Assoc); + Kind_Param : constant Iir := + Get_Actual_Or_Default (Kind_Assoc, Kind_Inter); Constr : O_Assoc_List; Status : Mnode; begin Status := Chap6.Translate_Name (Status_Param, Mode_Value); - N_Param := Get_Chain (Param_Chain); - File_Param := Get_Actual (N_Param); - N_Param := Get_Chain (N_Param); - Name_Param := Get_Actual (N_Param); - N_Param := Get_Chain (N_Param); - Kind_Param := Get_Actual_Or_Default (N_Param); if Get_Text_File_Flag (Get_Type (File_Param)) then Start_Association (Constr, Ghdl_Text_File_Open_Status); else @@ -2073,16 +2064,16 @@ package body Trans.Chap8 is New_Association (Constr, Chap7.Translate_Expression (Name_Param, - String_Type_Definition)); + String_Type_Definition)); New_Assign_Stmt (M2Lv (Status), New_Convert_Ov (New_Function_Call (Constr), - Std_File_Open_Status_Otype)); + Std_File_Open_Status_Otype)); end; when Iir_Predefined_File_Close => declare - File_Param : constant Iir := Get_Actual (Param_Chain); + File_Param : constant Iir := Get_Actual (Assoc_Chain); Constr : O_Assoc_List; begin if Get_Text_File_Flag (Get_Type (File_Param)) then @@ -2097,7 +2088,7 @@ package body Trans.Chap8 is when Iir_Predefined_Flush => declare - File_Param : constant Iir := Get_Actual (Param_Chain); + File_Param : constant Iir := Get_Actual (Assoc_Chain); Constr : O_Assoc_List; begin Start_Association (Constr, Ghdl_File_Flush); @@ -2128,7 +2119,7 @@ package body Trans.Chap8 is Imp : constant Iir := Get_Implementation (Call); Info : constant Call_Info_Acc := Get_Info (Call); - Assoc : Iir; + Assoc, Inter : Iir; Num : Natural; begin Push_Instance_Factory (Info.Call_State_Scope'Access); @@ -2141,13 +2132,13 @@ package body Trans.Chap8 is Ghdl_Ptr_Type, O_Storage_Local); Assoc := Get_Parameter_Association_Chain (Call); + Inter := Get_Interface_Declaration_Chain (Imp); Num := 0; while Assoc /= Null_Iir loop declare - Formal : constant Iir := Strip_Denoting_Name (Get_Formal (Assoc)); + Formal : constant Iir := Get_Association_Formal (Assoc, Inter); Ftype : constant Iir := Get_Type (Formal); Ftype_Info : constant Type_Info_Acc := Get_Info (Ftype); - Inter : constant Iir := Get_Association_Interface (Assoc); Call_Assoc_Info : Call_Assoc_Info_Acc; Actual : Iir; Act_Type : Iir; @@ -2271,6 +2262,8 @@ package body Trans.Chap8 is return True; end Need_Value_Field; begin + Inter := Get_Association_Interface (Assoc, Inter); + Call_Assoc_Info := null; Has_Bounds_Field := False; Has_Fat_Pointer_Field := False; @@ -2412,7 +2405,7 @@ package body Trans.Chap8 is Num := Num + 1; end if; end; - Assoc := Get_Chain (Assoc); + Next_Association_Interface (Assoc, Inter); end loop; Pop_Instance_Factory (Info.Call_State_Scope'Access); @@ -2515,6 +2508,7 @@ package body Trans.Chap8 is (Call : Iir; Assoc_Chain : Iir; Obj : Iir) return O_Enode is Imp : constant Iir := Get_Implementation (Call); + Inter_Chain : constant Iir := Get_Interface_Declaration_Chain (Imp); Is_Procedure : constant Boolean := Get_Kind (Imp) = Iir_Kind_Procedure_Declaration; @@ -2552,6 +2546,7 @@ package body Trans.Chap8 is Params_Var : Var_Type; Res : Mnode; El : Iir; + Inter : Iir; Pos : Natural; Constr : O_Assoc_List; Last_Individual : Natural; @@ -2614,6 +2609,7 @@ package body Trans.Chap8 is -- Non-composite in-out parameters address are saved in order to -- be able to assignate the result. El := Assoc_Chain; + Inter := Inter_Chain; Pos := 0; while El /= Null_Iir loop Params (Pos) := Mnode_Null; @@ -2622,15 +2618,15 @@ package body Trans.Chap8 is Inout_Params (Pos) := Mnode_Null; declare - Assoc_Info : Call_Assoc_Info_Acc; - Base_Formal : constant Iir := Get_Association_Interface (El); - Formal : constant Iir := Strip_Denoting_Name (Get_Formal (El)); + Formal : constant Iir := Get_Association_Formal (El, Inter); Formal_Type : constant Iir := Get_Type (Formal); Ftype_Info : constant Type_Info_Acc := Get_Info (Formal_Type); + Base_Formal : constant Iir := Get_Interface_Of_Formal (Formal); Formal_Info : constant Interface_Info_Acc := Get_Info (Base_Formal); Formal_Object_Kind : constant Object_Kind_Type := Get_Interface_Kind (Base_Formal); + Assoc_Info : Call_Assoc_Info_Acc; Act : Iir; Actual_Type : Iir; In_Conv : Iir; @@ -2668,7 +2664,7 @@ package body Trans.Chap8 is case Get_Kind (El) is when Iir_Kind_Association_Element_Open => - Act := Get_Default_Value (Formal); + Act := Get_Default_Value (Base_Formal); In_Conv := Null_Iir; when Iir_Kind_Association_Element_By_Expression => Act := Get_Actual (El); @@ -2976,7 +2972,7 @@ package body Trans.Chap8 is << Continue >> null; end; - El := Get_Chain (El); + Next_Association_Interface (El, Inter); Pos := Pos + 1; end loop; @@ -3011,8 +3007,9 @@ package body Trans.Chap8 is begin Open_Temp; El := Assoc_Chain; + Inter := Inter_Chain; while El /= Null_Iir loop - Base_Formal := Get_Association_Interface (El); + Base_Formal := Get_Association_Interface (El, Inter); case Get_Kind (El) is when Iir_Kind_Association_Element_By_Individual => if Get_Kind (Base_Formal) @@ -3051,7 +3048,7 @@ package body Trans.Chap8 is when others => null; end case; - El := Get_Chain (El); + Next_Association_Interface (El, Inter); end loop; Close_Temp; end; @@ -3082,11 +3079,13 @@ package body Trans.Chap8 is -- Parameters. El := Assoc_Chain; + Inter := Inter_Chain; Pos := 0; while El /= Null_Iir loop declare - Formal : constant Iir := Strip_Denoting_Name (Get_Formal (El)); - Base_Formal : constant Iir := Get_Association_Interface (El); + Formal : constant Iir := Get_Association_Formal (El, Inter); + Base_Formal : constant Iir := + Get_Association_Interface (El, Inter); Formal_Info : constant Ortho_Info_Acc := Get_Info (Base_Formal); begin if Formal_Info.Interface_Field (Mode_Value) = O_Fnode_Null then @@ -3110,7 +3109,7 @@ package body Trans.Chap8 is end if; end; - El := Get_Chain (El); + Next_Association_Interface (El, Inter); Pos := Pos + 1; end loop; @@ -3144,13 +3143,15 @@ package body Trans.Chap8 is -- Copy-out non-composite parameters. El := Assoc_Chain; + Inter := Inter_Chain; Pos := 0; while El /= Null_Iir loop if Get_Kind (El) = Iir_Kind_Association_Element_By_Individual then Last_Individual := Pos; declare Assoc_Info : constant Call_Assoc_Info_Acc := Get_Info (El); - Base_Formal : constant Iir := Get_Association_Interface (El); + Base_Formal : constant Iir := + Get_Association_Interface (El, Inter); Formal_Type : Iir; Ftype_Info : Type_Info_Acc; begin @@ -3178,8 +3179,8 @@ package body Trans.Chap8 is elsif Params (Pos) /= Mnode_Null then declare Assoc_Info : constant Call_Assoc_Info_Acc := Get_Info (El); - Formal : constant Iir := Strip_Denoting_Name (Get_Formal (El)); - Base_Formal : constant Iir := Get_Association_Interface (El); + Formal : constant Iir := Get_Association_Formal (El, Inter); + Base_Formal : constant Iir := Get_Interface_Of_Formal (Formal); Formal_Type : constant Iir := Get_Type (Formal); Ftype_Info : constant Type_Info_Acc := Get_Info (Formal_Type); Formal_Info : constant Ortho_Info_Acc := Get_Info (Base_Formal); @@ -3238,7 +3239,7 @@ package body Trans.Chap8 is Chap7.Translate_Assign (Param, Val, Out_Expr, Actual_Type, El); end; end if; - El := Get_Chain (El); + Next_Association_Interface (El, Inter); Pos := Pos + 1; end loop; diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb index b8cc5741a..5f4ef84bf 100644 --- a/src/vhdl/translate/trans-chap9.adb +++ b/src/vhdl/translate/trans-chap9.adb @@ -159,12 +159,11 @@ package body Trans.Chap9 is procedure Translate_Component_Instantiation_Statement (Inst : Iir) is - Comp : constant Iir := Get_Instantiated_Unit (Inst); - Info : Block_Info_Acc; - Comp_Info : Comp_Info_Acc; + Info : Block_Info_Acc; + Ports : Iir; Mark, Mark2 : Id_Mark_Type; - Assoc, Conv, In_Type : Iir; + Assoc, Inter, Conv, In_Type : Iir; Has_Conv_Record : Boolean := False; begin Info := Add_Info (Inst, Kind_Block); @@ -172,15 +171,22 @@ package body Trans.Chap9 is if Is_Component_Instantiation (Inst) then -- Via a component declaration. - Comp_Info := Get_Info (Get_Named_Entity (Comp)); - Info.Block_Link_Field := Add_Instance_Factory_Field - (Create_Identifier_Without_Prefix (Inst), - Get_Scope_Type (Comp_Info.Comp_Scope)); + declare + Comp : constant Iir := + Get_Named_Entity (Get_Instantiated_Unit (Inst)); + Comp_Info : constant Comp_Info_Acc := Get_Info (Comp); + begin + Info.Block_Link_Field := Add_Instance_Factory_Field + (Create_Identifier_Without_Prefix (Inst), + Get_Scope_Type (Comp_Info.Comp_Scope)); + Ports := Comp; + end; else -- Direct instantiation. Info.Block_Link_Field := Add_Instance_Factory_Field (Create_Identifier_Without_Prefix (Inst), Rtis.Ghdl_Component_Link_Type); + Ports := Get_Entity_From_Entity_Aspect (Get_Instantiated_Unit (Inst)); end if; -- When conversions are used, the subtype of the actual (or of the @@ -189,6 +195,7 @@ package body Trans.Chap9 is -- We need to translate it and create variables in the instance -- because it will be referenced by the conversion subprogram. Assoc := Get_Port_Map_Aspect_Chain (Inst); + Inter := Get_Port_Chain (Ports); while Assoc /= Null_Iir loop if Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression then @@ -207,12 +214,12 @@ package body Trans.Chap9 is -- formal. Push_Identifier_Prefix (Mark2, - Get_Identifier (Get_Association_Interface (Assoc))); + Get_Identifier (Get_Association_Interface (Assoc, Inter))); Chap3.Translate_Type_Definition (In_Type, True); Pop_Identifier_Prefix (Mark2); end if; end if; - Assoc := Get_Chain (Assoc); + Next_Association_Interface (Assoc, Inter); end loop; if Has_Conv_Record then Pop_Instance_Factory (Info.Block_Scope'Access); @@ -946,8 +953,8 @@ package body Trans.Chap9 is -- instantiation statement. Set_Component_Link (Comp_Info.Comp_Scope, Comp_Info.Comp_Link); - Chap5.Elab_Map_Aspect (Stmt, Comp, (Comp_Info.Comp_Scope'Access, - Comp_Info.Comp_Scope)); + Chap5.Elab_Map_Aspect (Comp, Stmt, Comp, (Comp_Info.Comp_Scope'Access, + Comp_Info.Comp_Scope)); Clear_Scope (Comp_Info.Comp_Scope); end if; @@ -1723,7 +1730,7 @@ package body Trans.Chap9 is begin Entity_Map.Scope_Ptr := Entity_Info.Block_Scope'Access; Set_Scope_Via_Param_Ptr (Entity_Map.Scope, Var_Sub); - Chap5.Elab_Map_Aspect (Mapping, Entity, Entity_Map); + Chap5.Elab_Map_Aspect (Entity, Mapping, Entity, Entity_Map); Clear_Scope (Entity_Map.Scope); end; @@ -2453,7 +2460,7 @@ package body Trans.Chap9 is Block_Info := Get_Info (Block); Block_Env := (Block_Info.Block_Scope'Access, Block_Info.Block_Scope); - Chap5.Elab_Map_Aspect (Header, Block, Block_Env); + Chap5.Elab_Map_Aspect (Header, Header, Block, Block_Env); Merge_Signals_Rti_Of_Port_Chain (Get_Port_Chain (Header)); end if; end; diff --git a/src/vhdl/translate/trans_analyzes.adb b/src/vhdl/translate/trans_analyzes.adb index 8fce7c2bc..427989935 100644 --- a/src/vhdl/translate/trans_analyzes.adb +++ b/src/vhdl/translate/trans_analyzes.adb @@ -97,13 +97,7 @@ package body Trans_Analyzes is Inter := Get_Interface_Declaration_Chain (Get_Implementation (Call)); while Assoc /= Null_Iir loop - Formal := Get_Formal (Assoc); - if Formal = Null_Iir then - Formal := Inter; - Inter := Get_Chain (Inter); - else - Formal := Get_Association_Interface (Assoc); - end if; + Formal := Get_Association_Interface (Assoc, Inter); if Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression and then @@ -112,7 +106,7 @@ package body Trans_Analyzes is then Status := Extract_Driver_Target (Get_Actual (Assoc)); end if; - Assoc := Get_Chain (Assoc); + Next_Association_Interface (Assoc, Inter); end loop; end; when others => |