aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/translate
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-11-06 20:20:52 +0100
committerTristan Gingold <tgingold@free.fr>2017-11-06 20:20:52 +0100
commit1984d2adb083153f03eb7775d956445772ca484f (patch)
tree92939d572fd44940755e30d3963101c0a797f9e7 /src/vhdl/translate
parentf9dd14670a2b17575bc879f82030faaaabdbbea6 (diff)
downloadghdl-1984d2adb083153f03eb7775d956445772ca484f.tar.gz
ghdl-1984d2adb083153f03eb7775d956445772ca484f.tar.bz2
ghdl-1984d2adb083153f03eb7775d956445772ca484f.zip
Use Flist for array indexes.
Diffstat (limited to 'src/vhdl/translate')
-rw-r--r--src/vhdl/translate/trans-chap1.adb4
-rw-r--r--src/vhdl/translate/trans-chap2.adb31
-rw-r--r--src/vhdl/translate/trans-chap3.adb53
-rw-r--r--src/vhdl/translate/trans-chap4.adb2
-rw-r--r--src/vhdl/translate/trans-chap6.adb4
-rw-r--r--src/vhdl/translate/trans-chap7.adb24
-rw-r--r--src/vhdl/translate/trans-chap8.adb2
-rw-r--r--src/vhdl/translate/trans-chap9.adb31
-rw-r--r--src/vhdl/translate/trans-rtis.adb4
9 files changed, 103 insertions, 52 deletions
diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb
index 93534f028..08b22098c 100644
--- a/src/vhdl/translate/trans-chap1.adb
+++ b/src/vhdl/translate/trans-chap1.adb
@@ -708,10 +708,10 @@ package body Trans.Chap1 is
Apply_To_All_Others_Blocks (True);
when Iir_Kind_Indexed_Name =>
declare
- Index_List : constant Iir_List := Get_Index_List (Spec);
+ Index_List : constant Iir_Flist := Get_Index_List (Spec);
Rng : Mnode;
begin
- if Index_List = Iir_List_Others then
+ if Index_List = Iir_Flist_Others then
Apply_To_All_Others_Blocks (False);
else
Open_Temp;
diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb
index 790200218..d975a2ac1 100644
--- a/src/vhdl/translate/trans-chap2.adb
+++ b/src/vhdl/translate/trans-chap2.adb
@@ -1134,6 +1134,23 @@ package body Trans.Chap2 is
end case;
end Instantiate_Iir_List_Info;
+ procedure Instantiate_Iir_Flist_Info (L : Iir_Flist)
+ is
+ El : Iir;
+ begin
+ case L is
+ when Null_Iir_Flist
+ | Iir_Flist_All
+ | Iir_Flist_Others =>
+ return;
+ when others =>
+ for I in Flist_First .. Flist_Last (L) loop
+ El := Get_Nth_Element (L, I);
+ Instantiate_Iir_Info (El);
+ end loop;
+ end case;
+ end Instantiate_Iir_Flist_Info;
+
-- B must be passed by reference.
procedure Adjust_Info_Basetype (B : access Ortho_Info_Basetype_Type;
Orig : access Ortho_Info_Basetype_Type) is
@@ -1422,6 +1439,20 @@ package body Trans.Chap2 is
when others =>
raise Internal_Error;
end case;
+ when Type_Iir_Flist =>
+ case Get_Field_Attribute (F) is
+ when Attr_None =>
+ Instantiate_Iir_Flist_Info (Get_Iir_Flist (N, F));
+ when Attr_Of_Maybe_Ref =>
+ if not Get_Is_Ref (N) then
+ Instantiate_Iir_Flist_Info (Get_Iir_Flist (N, F));
+ end if;
+ when Attr_Ref
+ | Attr_Of_Ref =>
+ null;
+ when others =>
+ raise Internal_Error;
+ end case;
when Type_PSL_NFA
| Type_PSL_Node =>
-- TODO
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index e5ba9a1ee..e585cc747 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -564,13 +564,12 @@ package body Trans.Chap3 is
case Get_Kind (Def) is
when Iir_Kind_Array_Subtype_Definition =>
declare
- Indexes_List : constant Iir_List :=
+ Indexes_List : constant Iir_Flist :=
Get_Index_Subtype_List (Def);
Index : Iir;
begin
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Indexes_List) loop
Index := Get_Index_Type (Indexes_List, I);
- exit when Index = Null_Iir;
New_Record_Aggr_El
(List, Create_Static_Type_Definition_Type_Range (Index));
end loop;
@@ -621,18 +620,17 @@ package body Trans.Chap3 is
case Get_Kind (Def) is
when Iir_Kind_Array_Subtype_Definition =>
declare
- Indexes_List : constant Iir_List :=
+ Indexes_List : constant Iir_Flist :=
Get_Index_Subtype_List (Def);
- Indexes_Def_List : constant Iir_List :=
+ Indexes_Def_List : constant Iir_Flist :=
Get_Index_Subtype_Definition_List (Base_Type);
Index : Iir;
begin
if Get_Nbr_Elements (Indexes_List) > 1 then
Targ := Stabilize (Targ);
end if;
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Indexes_List) loop
Index := Get_Index_Type (Indexes_List, I);
- exit when Index = Null_Iir;
declare
Index_Type : constant Iir := Get_Base_Type (Index);
Index_Info : constant Type_Info_Acc :=
@@ -737,7 +735,7 @@ package body Trans.Chap3 is
procedure Translate_Array_Type_Bounds
(Def : Iir_Array_Type_Definition; Info : Type_Info_Acc)
is
- Indexes_List : constant Iir_List :=
+ Indexes_List : constant Iir_Flist :=
Get_Index_Subtype_Definition_List (Def);
Constr : O_Element_List;
Dim : String (1 .. 8);
@@ -748,9 +746,8 @@ package body Trans.Chap3 is
Index_Type_Mark : Iir;
begin
Start_Record_Type (Constr);
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Indexes_List) loop
Index_Type_Mark := Get_Nth_Element (Indexes_List, I);
- exit when Index_Type_Mark = Null_Iir;
Index := Get_Index_Type (Index_Type_Mark);
-- Index comes from a type mark.
@@ -835,16 +832,15 @@ package body Trans.Chap3 is
function Get_Array_Subtype_Length (Def : Iir_Array_Subtype_Definition)
return Iir_Int64
is
- Indexes_List : constant Iir_List := Get_Index_Subtype_List (Def);
+ Indexes_List : constant Iir_Flist := Get_Index_Subtype_List (Def);
Index : Iir;
Idx_Len : Iir_Int64;
Len : Iir_Int64;
begin
-- Check if the bounds of the array are locally static.
Len := 1;
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Indexes_List) loop
Index := Get_Index_Type (Indexes_List, I);
- exit when Index = Null_Iir;
if Get_Type_Staticness (Index) /= Locally then
return -1;
@@ -1817,13 +1813,12 @@ package body Trans.Chap3 is
when Iir_Kind_Array_Type_Definition =>
declare
- Index_List : constant Iir_List :=
+ Index_List : constant Iir_Flist :=
Get_Index_Subtype_List (Def);
Index : Iir;
begin
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Index_List) loop
Index := Get_Index_Type (Index_List, I);
- exit when Index = Null_Iir;
if Is_Anonymous_Type_Definition (Index) then
Create_Type_Definition_Type_Range (Index);
end if;
@@ -2540,7 +2535,7 @@ package body Trans.Chap3 is
function Get_Thin_Array_Length (Atype : Iir) return O_Cnode
is
- Indexes_List : constant Iir_List := Get_Index_Subtype_List (Atype);
+ Indexes_List : constant Iir_Flist := Get_Index_Subtype_List (Atype);
Nbr_Dim : constant Natural := Get_Nbr_Elements (Indexes_List);
Index : Iir;
Val : Iir_Int64;
@@ -2558,7 +2553,7 @@ package body Trans.Chap3 is
function Bounds_To_Range (B : Mnode; Atype : Iir; Dim : Positive)
return Mnode
is
- Indexes_List : constant Iir_List :=
+ Indexes_List : constant Iir_Flist :=
Get_Index_Subtype_Definition_List (Get_Base_Type (Atype));
Index_Type_Mark : constant Iir :=
Get_Nth_Element (Indexes_List, Dim - 1);
@@ -2696,7 +2691,7 @@ package body Trans.Chap3 is
function Get_Bounds_Length (Bounds : Mnode; Atype : Iir) return O_Enode
is
Type_Info : constant Type_Info_Acc := Get_Info (Atype);
- Index_List : constant Iir_List := Get_Index_Subtype_List (Atype);
+ Index_List : constant Iir_Flist := Get_Index_Subtype_List (Atype);
Nbr_Dim : constant Natural := Get_Nbr_Elements (Index_List);
Dim_Length : O_Enode;
Res : O_Enode;
@@ -3266,15 +3261,14 @@ package body Trans.Chap3 is
function Locally_Array_Match (L_Type, R_Type : Iir) return Boolean
is
- L_Indexes : constant Iir_List := Get_Index_Subtype_List (L_Type);
- R_Indexes : constant Iir_List := Get_Index_Subtype_List (R_Type);
+ L_Indexes : constant Iir_Flist := Get_Index_Subtype_List (L_Type);
+ R_Indexes : constant Iir_Flist := Get_Index_Subtype_List (R_Type);
L_El : Iir;
R_El : Iir;
begin
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (L_Indexes) loop
L_El := Get_Index_Type (L_Indexes, I);
R_El := Get_Index_Type (R_Indexes, I);
- exit when L_El = Null_Iir and R_El = Null_Iir;
if Eval_Discrete_Type_Length (L_El)
/= Eval_Discrete_Type_Length (R_El)
then
@@ -3308,23 +3302,20 @@ package body Trans.Chap3 is
else
-- Check length match.
declare
- Index_List : constant Iir_List :=
+ Index_List : constant Iir_Flist :=
Get_Index_Subtype_List (L_Type);
- Index : Iir;
Cond : O_Enode;
Sub_Cond : O_Enode;
begin
- for I in Natural loop
- Index := Get_Nth_Element (Index_List, I);
- exit when Index = Null_Iir;
+ for I in 1 .. Get_Nbr_Elements (Index_List) loop
Sub_Cond := New_Compare_Op
(ON_Neq,
M2E (Range_To_Length
- (Get_Array_Range (L_Node, L_Type, I + 1))),
+ (Get_Array_Range (L_Node, L_Type, I))),
M2E (Range_To_Length
- (Get_Array_Range (R_Node, R_Type, I + 1))),
+ (Get_Array_Range (R_Node, R_Type, I))),
Ghdl_Bool_Type);
- if I = 0 then
+ if I = 1 then
Cond := Sub_Cond;
else
Cond := New_Dyadic_Op (ON_Or, Cond, Sub_Cond);
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index c5d7df598..d4808ed2f 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -1978,7 +1978,7 @@ package body Trans.Chap4 is
Arr_Type := Get_Type (Get_Interface_Declaration_Chain (Func));
Base_Type := Get_Base_Type (Arr_Type);
Index_Info := Get_Info
- (Get_First_Element (Get_Index_Subtype_Definition_List (Base_Type)));
+ (Get_Nth_Element (Get_Index_Subtype_Definition_List (Base_Type), 0));
Base_Info := Get_Info (Base_Type);
El_Type := Get_Element_Subtype (Arr_Type);
diff --git a/src/vhdl/translate/trans-chap6.adb b/src/vhdl/translate/trans-chap6.adb
index 5838562f3..5537890c9 100644
--- a/src/vhdl/translate/trans-chap6.adb
+++ b/src/vhdl/translate/trans-chap6.adb
@@ -350,8 +350,8 @@ package body Trans.Chap6 is
is
Prefix_Type : constant Iir := Get_Type (Get_Prefix (Expr));
Prefix_Info : constant Type_Info_Acc := Get_Info (Prefix_Type);
- Index_List : constant Iir_List := Get_Index_List (Expr);
- Type_List : constant Iir_List := Get_Index_Subtype_List (Prefix_Type);
+ Index_List : constant Iir_Flist := Get_Index_List (Expr);
+ Type_List : constant Iir_Flist := Get_Index_Subtype_List (Prefix_Type);
Nbr_Dim : constant Natural := Get_Nbr_Elements (Index_List);
Prefix : Mnode;
Index : Iir;
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 1e741d024..833cbc5ed 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -797,7 +797,7 @@ package body Trans.Chap7 is
when Iir_Kind_Array_Type_Definition
| Iir_Kind_Array_Subtype_Definition =>
declare
- Expr_Indexes : constant Iir_List :=
+ Expr_Indexes : constant Iir_Flist :=
Get_Index_Subtype_List (Expr_Type);
begin
for I in 1 .. Get_Nbr_Elements (Expr_Indexes) loop
@@ -2889,7 +2889,7 @@ package body Trans.Chap7 is
Dim : Natural;
Var_Index : O_Dnode)
is
- Index_List : Iir_List;
+ Index_List : Iir_Flist;
Expr_Type : Iir;
Final : Boolean;
@@ -3199,9 +3199,9 @@ package body Trans.Chap7 is
(Target : Mnode; Target_Type : Iir; Aggr : Iir)
is
Aggr_Type : constant Iir := Get_Type (Aggr);
- Index_List : constant Iir_List :=
+ Index_List : constant Iir_Flist :=
Get_Index_Subtype_List (Aggr_Type);
- Targ_Index_List : constant Iir_List :=
+ Targ_Index_List : constant Iir_Flist :=
Get_Index_Subtype_List (Target_Type);
Aggr_Info : Iir_Aggregate_Info;
@@ -3255,9 +3255,8 @@ package body Trans.Chap7 is
Aggr_Info := Get_Aggregate_Info (Aggr);
-- Check type
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Index_List) loop
Subaggr_Type := Get_Index_Type (Index_List, I);
- exit when Subaggr_Type = Null_Iir;
Subtarg_Type := Get_Index_Type (Targ_Index_List, I);
Bt := Get_Base_Type (Subaggr_Type);
@@ -3633,23 +3632,22 @@ package body Trans.Chap7 is
procedure Translate_Type_Conversion_Bounds
(Res : Mnode; Src : Mnode; Res_Type : Iir; Src_Type : Iir; Loc : Iir)
is
- Res_Indexes : constant Iir_List := Get_Index_Subtype_List (Res_Type);
- Src_Indexes : constant Iir_List := Get_Index_Subtype_List (Src_Type);
+ Res_Indexes : constant Iir_Flist := Get_Index_Subtype_List (Res_Type);
+ Src_Indexes : constant Iir_Flist := Get_Index_Subtype_List (Src_Type);
Res_Base_Type : constant Iir := Get_Base_Type (Res_Type);
Src_Base_Type : constant Iir := Get_Base_Type (Src_Type);
- Res_Base_Indexes : constant Iir_List :=
+ Res_Base_Indexes : constant Iir_Flist :=
Get_Index_Subtype_List (Res_Base_Type);
- Src_Base_Indexes : constant Iir_List :=
+ Src_Base_Indexes : constant Iir_Flist :=
Get_Index_Subtype_List (Src_Base_Type);
R_El : Iir;
S_El : Iir;
begin
-- Convert bounds.
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Src_Indexes) loop
R_El := Get_Index_Type (Res_Indexes, I);
S_El := Get_Index_Type (Src_Indexes, I);
- exit when S_El = Null_Iir;
declare
Rb_Ptr : Mnode;
Sb_Ptr : Mnode;
@@ -4712,7 +4710,7 @@ package body Trans.Chap7 is
Info : constant Type_Info_Acc := Get_Info (Arr_Type);
F_Info : constant Operator_Info_Acc := Get_Info (Subprg);
L, R : Mnode;
- Indexes : constant Iir_List := Get_Index_Subtype_List (Arr_Type);
+ Indexes : constant Iir_Flist := Get_Index_Subtype_List (Arr_Type);
Nbr_Indexes : constant Natural := Get_Nbr_Elements (Indexes);
If_Blk : O_If_Block;
Var_I : O_Dnode;
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb
index c97807064..a4416f068 100644
--- a/src/vhdl/translate/trans-chap8.adb
+++ b/src/vhdl/translate/trans-chap8.adb
@@ -3907,7 +3907,7 @@ package body Trans.Chap8 is
Idx : O_Dnode;
Dim : Natural)
is
- Index_List : constant Iir_List :=
+ Index_List : constant Iir_Flist :=
Get_Index_Subtype_List (Target_Type);
Nbr_Dim : constant Natural := Get_Nbr_Elements (Index_List);
Sub_Aggr : Mnode;
diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb
index bd8bcde4b..c6a900855 100644
--- a/src/vhdl/translate/trans-chap9.adb
+++ b/src/vhdl/translate/trans-chap9.adb
@@ -1127,6 +1127,23 @@ package body Trans.Chap9 is
end case;
end Destroy_Types_In_List;
+ procedure Destroy_Types_In_Flist (L : Iir_Flist)
+ is
+ El : Iir;
+ begin
+ case L is
+ when Null_Iir_Flist
+ | Iir_Flist_All
+ | Iir_Flist_Others =>
+ return;
+ when others =>
+ for I in Flist_First .. Flist_Last (L) loop
+ El := Get_Nth_Element (L, I);
+ Destroy_Types (El);
+ end loop;
+ end case;
+ end Destroy_Types_In_Flist;
+
procedure Destroy_Types (N : Iir) is
begin
-- Nothing to do for null node.
@@ -1194,6 +1211,20 @@ package body Trans.Chap9 is
when others =>
raise Internal_Error;
end case;
+ when Type_Iir_Flist =>
+ case Get_Field_Attribute (F) is
+ when Attr_None =>
+ Destroy_Types_In_Flist (Get_Iir_Flist (N, F));
+ when Attr_Of_Maybe_Ref =>
+ if not Get_Is_Ref (N) then
+ Destroy_Types_In_Flist (Get_Iir_Flist (N, F));
+ end if;
+ when Attr_Ref
+ | Attr_Of_Ref =>
+ null;
+ when others =>
+ raise Internal_Error;
+ end case;
when Type_PSL_NFA
| Type_PSL_Node =>
-- TODO
diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb
index dd60c817a..a555920e7 100644
--- a/src/vhdl/translate/trans-rtis.adb
+++ b/src/vhdl/translate/trans-rtis.adb
@@ -1398,7 +1398,7 @@ package body Trans.Rtis is
procedure Generate_Array_Type_Indexes
(Atype : Iir; Res : out O_Dnode; Max_Depth : in out Rti_Depth_Type)
is
- List : constant Iir_List := Get_Index_Subtype_List (Atype);
+ List : constant Iir_Flist := Get_Index_Subtype_List (Atype);
Nbr_Indexes : constant Natural := Get_Nbr_Elements (List);
Index : Iir;
Tmp : O_Dnode;
@@ -1456,7 +1456,7 @@ package body Trans.Rtis is
Info : Type_Info_Acc;
Aggr : O_Record_Aggr_List;
Val : O_Cnode;
- List : Iir_List;
+ List : Iir_Flist;
Arr : O_Dnode;
Element : Iir;
Name : O_Dnode;