diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-08-10 16:54:52 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-08-10 16:54:52 +0200 |
commit | 8a3922778cd92df96aaf5771f24d650bb8290559 (patch) | |
tree | 8c4854acc7c4681a0f46bcdabd50fb16be19ec66 /src/vhdl/translate/trans-chap3.adb | |
parent | aabb982856fed89ebb696127803577fcec036508 (diff) | |
download | ghdl-8a3922778cd92df96aaf5771f24d650bb8290559.tar.gz ghdl-8a3922778cd92df96aaf5771f24d650bb8290559.tar.bz2 ghdl-8a3922778cd92df96aaf5771f24d650bb8290559.zip |
trans: rework aggregate. For #2166
Diffstat (limited to 'src/vhdl/translate/trans-chap3.adb')
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index 6d0e3c21d..139a90f00 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -3137,6 +3137,7 @@ package body Trans.Chap3 is return Lv2M (New_Indexed_Element (M2Lv (Base), Index), El_Tinfo, Kind); elsif Is_Unbounded_Type (El_Tinfo) then + pragma Assert (Stride /= O_Enode_Null); return E2M (Add_Pointer (M2E (Base), New_Dyadic_Op (ON_Mul_Ov, Index, Stride), El_Tinfo.B.Base_Ptr_Type (Kind)), @@ -3165,24 +3166,32 @@ package body Trans.Chap3 is end if; end Convert_Array_Base; - function Index_Array (Arr : Mnode; Atype : Iir; Index : O_Enode) - return Mnode + -- For array with unbounded elements, return the stride. + -- Otherwise, return O_Enode_Null. + function Get_Array_Stride (Arr : Mnode; Atype : Iir) return O_Enode is El_Type : constant Iir := Get_Element_Subtype (Atype); El_Tinfo : constant Type_Info_Acc := Get_Info (El_Type); Kind : constant Object_Kind_Type := Get_Object_Kind (Arr); - Base : Mnode; - Stride : O_Enode; begin - Base := Get_Composite_Base (Arr); - -- For indexing, we need to consider the size of elements. if Is_Unbounded_Type (El_Tinfo) then - Stride := New_Value + return New_Value (Array_Bounds_To_Element_Size (Get_Composite_Bounds (Arr), Atype, Kind)); else - Stride := O_Enode_Null; + return O_Enode_Null; end if; + end Get_Array_Stride; + + function Index_Array (Arr : Mnode; Atype : Iir; Index : O_Enode) + return Mnode + is + Base : Mnode; + Stride : O_Enode; + begin + Base := Get_Composite_Base (Arr); + -- For indexing, we need to consider the size of elements. + Stride := Get_Array_Stride (Arr, Atype); return Index_Base (Base, Atype, Index, Stride); end Index_Array; |