diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-01-06 07:48:29 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-01-06 18:20:28 +0100 |
commit | 2b876a4a4f3e27bbfa132bbbcb66966b8df307de (patch) | |
tree | 2c35fc0cc52ceea29d7c4c65c1a4dc6d64ed2f6d /src | |
parent | da9d03552cf47d96fb7d2157b3500059115996f7 (diff) | |
download | ghdl-2b876a4a4f3e27bbfa132bbbcb66966b8df307de.tar.gz ghdl-2b876a4a4f3e27bbfa132bbbcb66966b8df307de.tar.bz2 ghdl-2b876a4a4f3e27bbfa132bbbcb66966b8df307de.zip |
vhdl/translate: minor refactoring.
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 80 | ||||
-rw-r--r-- | src/vhdl/translate/trans-helpers2.adb | 5 |
2 files changed, 43 insertions, 42 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index 9289e04bb..051585d58 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -1054,7 +1054,7 @@ package body Trans.Chap3 is end loop; end Create_Array_For_Array_Subtype; - procedure Translate_Array_Subtype_Definition + procedure Translate_Bounded_Array_Subtype_Definition (Def : Iir_Array_Subtype_Definition; Parent_Type : Iir) is El_Type : constant Iir := Get_Element_Subtype (Def); @@ -1112,7 +1112,7 @@ package body Trans.Chap3 is New_Type_Decl (Id, Info.Ortho_Type (I)); end loop; end if; - end Translate_Array_Subtype_Definition; + end Translate_Bounded_Array_Subtype_Definition; procedure Translate_Array_Subtype_Definition_Constrained_Element (Def : Iir_Array_Subtype_Definition; Parent_Type : Iir) @@ -1181,6 +1181,44 @@ package body Trans.Chap3 is Finish_Subprogram_Body; end Create_Array_Type_Builder; + procedure Translate_Array_Subtype_Definition + (Def : Iir; Parent_Type : Iir; With_Vars : Boolean) + is + El_Type : constant Iir := Get_Element_Subtype (Def); + Parent_El_Type : constant Iir := Get_Element_Subtype (Parent_Type); + Mark : Id_Mark_Type; + begin + -- Handle element subtype. + if El_Type /= Parent_El_Type then + -- TODO: do not create vars for element subtype, but use + -- the layout field of the array vars. + Push_Identifier_Prefix (Mark, "ET"); + Translate_Subtype_Definition (El_Type, Parent_El_Type, With_Vars); + Pop_Identifier_Prefix (Mark); + end if; + + if Get_Constraint_State (Def) = Fully_Constrained then + Translate_Bounded_Array_Subtype_Definition (Def, Parent_Type); + if With_Vars then + Create_Composite_Subtype_Layout_Var (Def, False); + end if; + elsif Is_Fully_Constrained_Type (El_Type) + and then not Is_Fully_Constrained_Type (Parent_El_Type) + and then Is_Static_Type (Get_Info (El_Type)) + then + -- The array subtype is not constrained, but the element + -- subtype was just contrained. Create an array for + -- ortho, if the element subtype is static. + Translate_Array_Subtype_Definition_Constrained_Element + (Def, Parent_Type); + else + -- An unconstrained array subtype. Use same infos as base + -- type. + Free_Info (Def); + Set_Info (Def, Get_Info (Parent_Type)); + end if; + end Translate_Array_Subtype_Definition; + -------------- -- record -- -------------- @@ -2412,43 +2450,7 @@ package body Trans.Chap3 is end if; when Iir_Kind_Array_Subtype_Definition => - declare - El_Type : constant Iir := Get_Element_Subtype (Def); - Parent_El_Type : constant Iir := - Get_Element_Subtype (Parent_Type); - Mark : Id_Mark_Type; - begin - -- Handle element subtype. - if El_Type /= Parent_El_Type then - -- TODO: do not create vars for element subtype, but use - -- the layout field of the array vars. - Push_Identifier_Prefix (Mark, "ET"); - Translate_Subtype_Definition - (El_Type, Parent_El_Type, With_Vars); - Pop_Identifier_Prefix (Mark); - end if; - - if Get_Constraint_State (Def) = Fully_Constrained then - Translate_Array_Subtype_Definition (Def, Parent_Type); - if With_Vars then - Create_Composite_Subtype_Layout_Var (Def, False); - end if; - elsif Is_Fully_Constrained_Type (El_Type) - and then not Is_Fully_Constrained_Type (Parent_El_Type) - and then Is_Static_Type (Get_Info (El_Type)) - then - -- The array subtype is not constrained, but the element - -- subtype was just contrained. Create an array for - -- ortho, if the element subtype is static. - Translate_Array_Subtype_Definition_Constrained_Element - (Def, Parent_Type); - else - -- An unconstrained array subtype. Use same infos as base - -- type. - Free_Info (Def); - Set_Info (Def, Get_Info (Parent_Type)); - end if; - end; + Translate_Array_Subtype_Definition (Def, Parent_Type, With_Vars); when Iir_Kind_Record_Subtype_Definition => Translate_Record_Subtype (Def, With_Vars); diff --git a/src/vhdl/translate/trans-helpers2.adb b/src/vhdl/translate/trans-helpers2.adb index 1886ccab5..1c17e27da 100644 --- a/src/vhdl/translate/trans-helpers2.adb +++ b/src/vhdl/translate/trans-helpers2.adb @@ -248,15 +248,14 @@ package body Trans.Helpers2 is function Gen_Oenode_Update_Data_Array (Val : Mnode; Targ_Type : Iir; Index : O_Dnode) - return O_Enode - is + return O_Enode is begin return M2E (Chap3.Index_Base (Val, Targ_Type, New_Obj_Value (Index))); end Gen_Oenode_Update_Data_Array; function Gen_Oenode_Update_Data_Record (Val : Mnode; Targ_Type : Iir; El : Iir_Element_Declaration) - return O_Enode + return O_Enode is pragma Unreferenced (Targ_Type); begin |