aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-11-07 07:48:55 +0100
committerTristan Gingold <tgingold@free.fr>2017-11-07 07:48:55 +0100
commita08289c5ad4c904a1b16445ee35fb00c05f87b64 (patch)
tree9406b043b8a90c06f0136ab19b6fadc20a1ae161 /src
parent06d553f9d32184ad71f47bbcfcde2528d40408ac (diff)
downloadghdl-a08289c5ad4c904a1b16445ee35fb00c05f87b64.tar.gz
ghdl-a08289c5ad4c904a1b16445ee35fb00c05f87b64.tar.bz2
ghdl-a08289c5ad4c904a1b16445ee35fb00c05f87b64.zip
Use flist for enumerations.
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/disp_tree.adb2
-rw-r--r--src/vhdl/disp_vhdl.adb2
-rw-r--r--src/vhdl/evaluation.adb18
-rw-r--r--src/vhdl/ieee-std_logic_1164.adb2
-rw-r--r--src/vhdl/iirs.adb8
-rw-r--r--src/vhdl/iirs.ads4
-rw-r--r--src/vhdl/iirs_utils.adb26
-rw-r--r--src/vhdl/iirs_utils.ads1
-rw-r--r--src/vhdl/nodes_meta.adb10
-rw-r--r--src/vhdl/parse.adb3
-rw-r--r--src/vhdl/sem_decls.adb5
-rw-r--r--src/vhdl/sem_expr.adb2
-rw-r--r--src/vhdl/sem_inst.adb45
-rw-r--r--src/vhdl/sem_names.adb6
-rw-r--r--src/vhdl/sem_scopes.adb10
-rw-r--r--src/vhdl/sem_specs.adb7
-rw-r--r--src/vhdl/sem_types.adb53
-rw-r--r--src/vhdl/std_package.adb76
-rw-r--r--src/vhdl/translate/trans-chap14.adb10
-rw-r--r--src/vhdl/translate/trans-chap3.adb7
-rw-r--r--src/vhdl/translate/trans-chap7.adb22
-rw-r--r--src/vhdl/translate/trans-chap8.adb4
-rw-r--r--src/vhdl/translate/trans-rtis.adb4
23 files changed, 180 insertions, 147 deletions
diff --git a/src/vhdl/disp_tree.adb b/src/vhdl/disp_tree.adb
index 97fde1910..c01dd61cd 100644
--- a/src/vhdl/disp_tree.adb
+++ b/src/vhdl/disp_tree.adb
@@ -348,7 +348,7 @@ package body Disp_Tree is
else
declare
El : constant Iir := Get_Base_Type (Get_Element_Subtype (T));
- Lits : constant Iir_List := Get_Enumeration_Literal_List (El);
+ Lits : constant Iir_Flist := Get_Enumeration_Literal_List (El);
Res : String (1 .. Natural (Len));
C : Natural;
begin
diff --git a/src/vhdl/disp_vhdl.adb b/src/vhdl/disp_vhdl.adb
index 808567bf0..5fbf6d657 100644
--- a/src/vhdl/disp_vhdl.adb
+++ b/src/vhdl/disp_vhdl.adb
@@ -2676,7 +2676,7 @@ package body Disp_Vhdl is
is
Str_Id : constant String8_Id := Get_String8_Id (Str);
Len : constant Nat32 := Get_String_Length (Str);
- Literal_List : constant Iir_List :=
+ Literal_List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Get_Base_Type (El_Type));
Pos : Nat8;
Lit : Iir;
diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb
index 0c1a91444..94a142403 100644
--- a/src/vhdl/evaluation.adb
+++ b/src/vhdl/evaluation.adb
@@ -98,7 +98,7 @@ package body Evaluation is
return Iir_Enumeration_Literal
is
Enum_Type : constant Iir := Get_Base_Type (Get_Type (Origin));
- Enum_List : constant Iir_List :=
+ Enum_List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Enum_Type);
Lit : constant Iir_Enumeration_Literal :=
Get_Nth_Element (Enum_List, Integer (Val));
@@ -270,7 +270,7 @@ package body Evaluation is
return Iir_Enumeration_Literal
is
Enum_Type : constant Iir := Get_Base_Type (Get_Type (Origin));
- Enum_List : constant Iir_List :=
+ Enum_List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Enum_Type);
begin
return Get_Nth_Element (Enum_List, Integer (Val));
@@ -280,7 +280,7 @@ package body Evaluation is
return Iir_Enumeration_Literal
is
Enum_Type : constant Iir := Get_Base_Type (Get_Type (Origin));
- Enum_List : constant Iir_List :=
+ Enum_List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Enum_Type);
begin
return Get_Nth_Element (Enum_List, Boolean'Pos (Val));
@@ -465,7 +465,7 @@ package body Evaluation is
is
Element_Type : constant Iir := Get_Base_Type
(Get_Element_Subtype (Get_Base_Type (Get_Type (Str))));
- Literal_List : constant Iir_List :=
+ Literal_List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Element_Type);
Len : constant Nat32 := Get_String_Length (Str);
@@ -908,10 +908,10 @@ package body Evaluation is
when Iir_Predefined_Array_Sll
| Iir_Predefined_Array_Srl =>
declare
- Enum_List : Iir_List;
- begin
- Enum_List := Get_Enumeration_Literal_List
+ Enum_List : constant Iir_Flist :=
+ Get_Enumeration_Literal_List
(Get_Base_Type (Get_Element_Subtype (Get_Type (Left))));
+ begin
E := Get_Nth_Element (Enum_List, 0);
end;
when Iir_Predefined_Array_Sla
@@ -1812,7 +1812,7 @@ package body Evaluation is
function Build_Enumeration_Value (Val : String; Enum, Expr : Iir) return Iir
is
- List : constant Iir_List := Get_Enumeration_Literal_List (Enum);
+ List : constant Iir_Flist := Get_Enumeration_Literal_List (Enum);
Value : String (Val'range);
Id : Name_Id;
Res : Iir;
@@ -1828,7 +1828,7 @@ package body Evaluation is
end loop;
Id := Get_Identifier (Value);
end if;
- Res := Find_Name_In_List (List, Id);
+ Res := Find_Name_In_Flist (List, Id);
if Res /= Null_Iir then
return Build_Constant (Res, Expr);
else
diff --git a/src/vhdl/ieee-std_logic_1164.adb b/src/vhdl/ieee-std_logic_1164.adb
index 14b8cd625..9d66942f9 100644
--- a/src/vhdl/ieee-std_logic_1164.adb
+++ b/src/vhdl/ieee-std_logic_1164.adb
@@ -147,7 +147,7 @@ package body Ieee.Std_Logic_1164 is
-- Get node of some literals.
declare
use Name_Table;
- Lit_List : constant Iir_List := Get_Enumeration_Literal_List (Def);
+ Lit_List : constant Iir_Flist := Get_Enumeration_Literal_List (Def);
begin
if Get_Nbr_Elements (Lit_List) /= 9 then
raise Error;
diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb
index efca22532..39e7f7082 100644
--- a/src/vhdl/iirs.adb
+++ b/src/vhdl/iirs.adb
@@ -2616,20 +2616,20 @@ package body Iirs is
Set_Field5 (Def, Atype);
end Set_Associated_Type;
- function Get_Enumeration_Literal_List (Target : Iir) return Iir_List is
+ function Get_Enumeration_Literal_List (Target : Iir) return Iir_Flist is
begin
pragma Assert (Target /= Null_Iir);
pragma Assert (Has_Enumeration_Literal_List (Get_Kind (Target)),
"no field Enumeration_Literal_List");
- return Iir_To_Iir_List (Get_Field2 (Target));
+ return Iir_To_Iir_Flist (Get_Field2 (Target));
end Get_Enumeration_Literal_List;
- procedure Set_Enumeration_Literal_List (Target : Iir; List : Iir_List) is
+ procedure Set_Enumeration_Literal_List (Target : Iir; List : Iir_Flist) is
begin
pragma Assert (Target /= Null_Iir);
pragma Assert (Has_Enumeration_Literal_List (Get_Kind (Target)),
"no field Enumeration_Literal_List");
- Set_Field2 (Target, Iir_List_To_Iir (List));
+ Set_Field2 (Target, Iir_Flist_To_Iir (List));
end Set_Enumeration_Literal_List;
function Get_Entity_Class_Entry_Chain (Target : Iir) return Iir is
diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads
index b8b344580..66fc4bf96 100644
--- a/src/vhdl/iirs.ads
+++ b/src/vhdl/iirs.ads
@@ -6425,8 +6425,8 @@ package Iirs is
procedure Set_Associated_Type (Def : Iir; Atype : Iir);
-- Field: Field2 (uc)
- function Get_Enumeration_Literal_List (Target : Iir) return Iir_List;
- procedure Set_Enumeration_Literal_List (Target : Iir; List : Iir_List);
+ function Get_Enumeration_Literal_List (Target : Iir) return Iir_Flist;
+ procedure Set_Enumeration_Literal_List (Target : Iir; List : Iir_Flist);
-- Field: Field1 Chain
function Get_Entity_Class_Entry_Chain (Target : Iir) return Iir;
diff --git a/src/vhdl/iirs_utils.adb b/src/vhdl/iirs_utils.adb
index 6a0c39a07..d60bd12c0 100644
--- a/src/vhdl/iirs_utils.adb
+++ b/src/vhdl/iirs_utils.adb
@@ -574,22 +574,6 @@ package body Iirs_Utils is
end case;
end Is_Parameter;
- function Find_Name_In_List (List: Iir_List; Lit: Name_Id) return Iir
- is
- El: Iir;
- Ident: Name_Id;
- begin
- for I in Natural loop
- El := Get_Nth_Element (List, I);
- exit when El = Null_Iir;
- Ident := Get_Identifier (El);
- if Ident = Lit then
- return El;
- end if;
- end loop;
- return Null_Iir;
- end Find_Name_In_List;
-
function Find_Name_In_Flist (List : Iir_Flist; Lit : Name_Id) return Iir
is
El : Iir;
@@ -767,15 +751,19 @@ package body Iirs_Utils is
(Def : Iir_Enumeration_Type_Definition)
is
Range_Expr : Iir_Range_Expression;
- Literal_List : constant Iir_List := Get_Enumeration_Literal_List (Def);
+ Literal_List : constant Iir_Flist := Get_Enumeration_Literal_List (Def);
begin
-- Create a constraint.
Range_Expr := Create_Iir (Iir_Kind_Range_Expression);
Location_Copy (Range_Expr, Def);
Set_Type (Range_Expr, Def);
Set_Direction (Range_Expr, Iir_To);
- Set_Left_Limit (Range_Expr, Get_First_Element (Literal_List));
- Set_Right_Limit (Range_Expr, Get_Last_Element (Literal_List));
+ Set_Left_Limit
+ (Range_Expr,
+ Get_Nth_Element (Literal_List, 0));
+ Set_Right_Limit
+ (Range_Expr,
+ Get_Nth_Element (Literal_List, Get_Nbr_Elements (Literal_List) - 1));
Set_Expr_Staticness (Range_Expr, Locally);
Set_Range_Constraint (Def, Range_Expr);
end Create_Range_Constraint_For_Enumeration_Type;
diff --git a/src/vhdl/iirs_utils.ads b/src/vhdl/iirs_utils.ads
index ad2cee1b6..25fb936fa 100644
--- a/src/vhdl/iirs_utils.ads
+++ b/src/vhdl/iirs_utils.ads
@@ -38,7 +38,6 @@ package Iirs_Utils is
-- Find LIT in the list of identifiers or characters LIST.
-- Return the literal (whose name is LIT) or null_iir if not found.
function Find_Name_In_Chain (Chain: Iir; Lit: Name_Id) return Iir;
- function Find_Name_In_List (List : Iir_List; Lit: Name_Id) return Iir;
function Find_Name_In_Flist (List : Iir_Flist; Lit: Name_Id) return Iir;
-- Return TRUE if EL in an element of chain CHAIN.
diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb
index be071c35a..ef395e224 100644
--- a/src/vhdl/nodes_meta.adb
+++ b/src/vhdl/nodes_meta.adb
@@ -144,7 +144,7 @@ package body Nodes_Meta is
Field_Complete_Type_Definition => Type_Iir,
Field_Incomplete_Type_Ref_Chain => Type_Iir,
Field_Associated_Type => Type_Iir,
- Field_Enumeration_Literal_List => Type_Iir_List,
+ Field_Enumeration_Literal_List => Type_Iir_Flist,
Field_Entity_Class_Entry_Chain => Type_Iir,
Field_Group_Constituent_List => Type_Iir_List,
Field_Unit_Chain => Type_Iir,
@@ -5911,6 +5911,8 @@ package body Nodes_Meta is
case F is
when Field_Simple_Aggregate_List =>
return Get_Simple_Aggregate_List (N);
+ when Field_Enumeration_Literal_List =>
+ return Get_Enumeration_Literal_List (N);
when Field_Index_Subtype_List =>
return Get_Index_Subtype_List (N);
when Field_Index_Subtype_Definition_List =>
@@ -5935,6 +5937,8 @@ package body Nodes_Meta is
case F is
when Field_Simple_Aggregate_List =>
Set_Simple_Aggregate_List (N, V);
+ when Field_Enumeration_Literal_List =>
+ Set_Enumeration_Literal_List (N, V);
when Field_Index_Subtype_List =>
Set_Index_Subtype_List (N, V);
when Field_Index_Subtype_Definition_List =>
@@ -6083,8 +6087,6 @@ package body Nodes_Meta is
return Get_Entity_Name_List (N);
when Field_Signal_List =>
return Get_Signal_List (N);
- when Field_Enumeration_Literal_List =>
- return Get_Enumeration_Literal_List (N);
when Field_Group_Constituent_List =>
return Get_Group_Constituent_List (N);
when Field_Sensitivity_List =>
@@ -6119,8 +6121,6 @@ package body Nodes_Meta is
Set_Entity_Name_List (N, V);
when Field_Signal_List =>
Set_Signal_List (N, V);
- when Field_Enumeration_Literal_List =>
- Set_Enumeration_Literal_List (N, V);
when Field_Group_Constituent_List =>
Set_Group_Constituent_List (N, V);
when Field_Sensitivity_List =>
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb
index e459e3cbd..6284ac0fe 100644
--- a/src/vhdl/parse.adb
+++ b/src/vhdl/parse.adb
@@ -1849,7 +1849,6 @@ package body Parse is
Enum_Type := Create_Iir (Iir_Kind_Enumeration_Type_Definition);
Set_Location (Enum_Type);
Enum_List := Create_Iir_List;
- Set_Enumeration_Literal_List (Enum_Type, Enum_List);
-- LRM93 3.1.1
-- The position number of the first listed enumeration literal is zero.
@@ -1907,6 +1906,8 @@ package body Parse is
-- Skip ')'.
Scan;
+ Set_Enumeration_Literal_List (Enum_Type, List_To_Flist (Enum_List));
+
return Enum_Type;
end Parse_Enumeration_Type_Definition;
diff --git a/src/vhdl/sem_decls.adb b/src/vhdl/sem_decls.adb
index 5fdf71c9a..4d3fc535e 100644
--- a/src/vhdl/sem_decls.adb
+++ b/src/vhdl/sem_decls.adb
@@ -2408,7 +2408,7 @@ package body Sem_Decls is
Type_Decl : constant Iir := Get_Type_Declarator (Def);
Last : Iir;
El : Iir;
- Enum_List : Iir_Enumeration_Literal_List;
+ Enum_List : Iir_Flist;
-- Append an implicit alias
procedure Add_Implicit_Alias (Decl : Iir)
@@ -2453,9 +2453,8 @@ package body Sem_Decls is
-- of the literals of the base type immediately follows the
-- alias declaration for the enumeration type; [...]
Enum_List := Get_Enumeration_Literal_List (Def);
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (Enum_List) loop
El := Get_Nth_Element (Enum_List, I);
- exit when El = Null_Iir;
-- LRM93 4.3.3.2 Non-Object Aliases
-- [...] each such implicit declaration has, as its alias
-- designator, the simple name or character literal of the
diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb
index 19287295f..34bc6e5ca 100644
--- a/src/vhdl/sem_expr.adb
+++ b/src/vhdl/sem_expr.adb
@@ -1944,7 +1944,7 @@ package body Sem_Expr is
-- be visible at the place of the string literal.
-- Character C is not visible...
- if Find_Name_In_List (Get_Enumeration_Literal_List (Etype), Id)
+ if Find_Name_In_Flist (Get_Enumeration_Literal_List (Etype), Id)
= Null_Iir
then
-- ... because it is not defined.
diff --git a/src/vhdl/sem_inst.adb b/src/vhdl/sem_inst.adb
index 3101d4219..10eac72dd 100644
--- a/src/vhdl/sem_inst.adb
+++ b/src/vhdl/sem_inst.adb
@@ -640,6 +640,7 @@ package body Sem_Inst is
procedure Set_Instance_On_Chain (Chain : Iir; Inst_Chain : Iir);
procedure Set_Instance_On_Iir_List (N : Iir_List; Inst : Iir_List);
+ procedure Set_Instance_On_Iir_Flist (N : Iir_Flist; Inst : Iir_Flist);
procedure Set_Instance_On_Iir (N : Iir; Inst : Iir) is
begin
@@ -719,6 +720,28 @@ package body Sem_Inst is
raise Internal_Error;
end case;
end;
+ when Type_Iir_Flist =>
+ declare
+ S : constant Iir_Flist := Get_Iir_Flist (N, F);
+ S_Inst : constant Iir_Flist := Get_Iir_Flist (Inst, F);
+ begin
+ case Get_Field_Attribute (F) is
+ when Attr_None =>
+ Set_Instance_On_Iir_Flist (S, S_Inst);
+ when Attr_Of_Maybe_Ref =>
+ if not Get_Is_Ref (N) then
+ Set_Instance_On_Iir_Flist (S, S_Inst);
+ end if;
+ when Attr_Of_Ref
+ | Attr_Ref
+ | Attr_Forward_Ref =>
+ null;
+ when others =>
+ -- Ref is specially handled in Instantiate_Iir.
+ -- Others cannot appear for lists.
+ raise Internal_Error;
+ end case;
+ end;
when others =>
null;
end case;
@@ -750,6 +773,28 @@ package body Sem_Inst is
end case;
end Set_Instance_On_Iir_List;
+ procedure Set_Instance_On_Iir_Flist (N : Iir_Flist; Inst : Iir_Flist)
+ is
+ El : Iir;
+ El_Inst : Iir;
+ begin
+ case N is
+ when Null_Iir_Flist
+ | Iir_Flist_All
+ | Iir_Flist_Others =>
+ pragma Assert (Inst = N);
+ return;
+ when others =>
+ pragma Assert (Get_Nbr_Elements (N) = Get_Nbr_Elements (Inst));
+ for I in Flist_First .. Flist_Last (N) loop
+ El := Get_Nth_Element (N, I);
+ El_Inst := Get_Nth_Element (Inst, I);
+
+ Set_Instance_On_Iir (El, El_Inst);
+ end loop;
+ end case;
+ end Set_Instance_On_Iir_Flist;
+
procedure Set_Instance_On_Chain (Chain : Iir; Inst_Chain : Iir)
is
El : Iir;
diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb
index dbb0e8143..98b7e01bb 100644
--- a/src/vhdl/sem_names.adb
+++ b/src/vhdl/sem_names.adb
@@ -3948,9 +3948,9 @@ package body Sem_Names is
and then Kind_In (Name, Iir_Kind_Simple_Name,
Iir_Kind_Character_Literal)
then
- Res := Find_Name_In_List (Get_Enumeration_Literal_List
- (Get_Base_Type (A_Type)),
- Get_Identifier (Name));
+ Res := Find_Name_In_Flist (Get_Enumeration_Literal_List
+ (Get_Base_Type (A_Type)),
+ Get_Identifier (Name));
if Res /= Null_Iir then
Error_Msg_Sem
(+Name, "enumeration literal %i is not visible "
diff --git a/src/vhdl/sem_scopes.adb b/src/vhdl/sem_scopes.adb
index d1f71a49b..4db8ffdf3 100644
--- a/src/vhdl/sem_scopes.adb
+++ b/src/vhdl/sem_scopes.adb
@@ -988,7 +988,7 @@ package body Sem_Scopes is
when Iir_Kind_Type_Declaration =>
declare
Def : constant Iir := Get_Type_Definition (Decl);
- List : Iir_List;
+ List : Iir_Flist;
El : Iir;
begin
-- Handle incomplete type declaration.
@@ -1000,9 +1000,8 @@ package body Sem_Scopes is
if Get_Kind (Def) = Iir_Kind_Enumeration_Type_Definition then
List := Get_Enumeration_Literal_List (Def);
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (List) loop
El := Get_Nth_Element (List, I);
- exit when El = Null_Iir;
Handle_Decl (El, Arg);
end loop;
end if;
@@ -1327,13 +1326,12 @@ package body Sem_Scopes is
-- an enumeration type, the enumeration literals of the base
-- type
declare
- List : constant Iir_List :=
+ List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Base_Type);
El : Iir;
begin
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (List) loop
El := Get_Nth_Element (List, I);
- exit when El = Null_Iir;
Potentially_Add_Name (El);
end loop;
end;
diff --git a/src/vhdl/sem_specs.adb b/src/vhdl/sem_specs.adb
index 8c9cd2391..0909315e1 100644
--- a/src/vhdl/sem_specs.adb
+++ b/src/vhdl/sem_specs.adb
@@ -479,13 +479,12 @@ package body Sem_Specs is
Def := Get_Type_Definition (El);
if Get_Kind (Def) = Iir_Kind_Enumeration_Type_Definition then
declare
- List : Iir_List;
+ List : constant Iir_Flist :=
+ Get_Enumeration_Literal_List (Def);
El1 : Iir;
begin
- List := Get_Enumeration_Literal_List (Def);
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (List) loop
El1 := Get_Nth_Element (List, I);
- exit when El1 = Null_Iir;
Sem_Named_Entity (El1);
end loop;
end;
diff --git a/src/vhdl/sem_types.adb b/src/vhdl/sem_types.adb
index fa3696776..a931d7409 100644
--- a/src/vhdl/sem_types.adb
+++ b/src/vhdl/sem_types.adb
@@ -750,41 +750,36 @@ package body Sem_Types is
function Sem_Enumeration_Type_Definition (Def: Iir; Decl: Iir) return Iir
is
+ Literal_List : constant Iir_Flist := Get_Enumeration_Literal_List (Def);
+ El: Iir;
+ Only_Characters : Boolean;
begin
Set_Base_Type (Def, Def);
Set_Type_Staticness (Def, Locally);
Set_Signal_Type_Flag (Def, True);
-- Makes all literal visible.
- declare
- El: Iir;
- Literal_List: Iir_List;
- Only_Characters : Boolean;
- begin
- Only_Characters := True;
- Literal_List := Get_Enumeration_Literal_List (Def);
- for I in Natural loop
- El := Get_Nth_Element (Literal_List, I);
- exit when El = Null_Iir;
- Set_Expr_Staticness (El, Locally);
- Set_Name_Staticness (El, Locally);
- Set_Type (El, Def);
- Sem.Compute_Subprogram_Hash (El);
- Sem_Scopes.Add_Name (El);
- Name_Visible (El);
- Xref_Decl (El);
-
- -- LRM93 3.1.1 Enumeration types
- -- An enumeration type is said to be a character type if at least
- -- one of its enumeration literals is a character literal.
- if Name_Table.Is_Character (Get_Identifier (El)) then
- Set_Is_Character_Type (Def, True);
- else
- Only_Characters := False;
- end if;
- end loop;
- Set_Only_Characters_Flag (Def, Only_Characters);
- end;
+ Only_Characters := True;
+ for I in Flist_First .. Flist_Last (Literal_List) loop
+ El := Get_Nth_Element (Literal_List, I);
+ Set_Expr_Staticness (El, Locally);
+ Set_Name_Staticness (El, Locally);
+ Set_Type (El, Def);
+ Sem.Compute_Subprogram_Hash (El);
+ Sem_Scopes.Add_Name (El);
+ Name_Visible (El);
+ Xref_Decl (El);
+
+ -- LRM93 3.1.1 Enumeration types
+ -- An enumeration type is said to be a character type if at least
+ -- one of its enumeration literals is a character literal.
+ if Name_Table.Is_Character (Get_Identifier (El)) then
+ Set_Is_Character_Type (Def, True);
+ else
+ Only_Characters := False;
+ end if;
+ end loop;
+ Set_Only_Characters_Flag (Def, Only_Characters);
Set_Resolved_Flag (Def, False);
Create_Range_Constraint_For_Enumeration_Type (Def);
diff --git a/src/vhdl/std_package.adb b/src/vhdl/std_package.adb
index 234f1000c..ddf1ec43a 100644
--- a/src/vhdl/std_package.adb
+++ b/src/vhdl/std_package.adb
@@ -152,22 +152,22 @@ package body Std_Package is
return Res;
end Create_Std_Range_Expr;
- function Create_Std_Literal
- (Name : Name_Id; Sub_Type : Iir_Enumeration_Type_Definition)
- return Iir_Enumeration_Literal
+ function Create_Std_Literal (Name : Name_Id;
+ Pos : Natural;
+ Sub_Type : Iir_Enumeration_Type_Definition)
+ return Iir_Enumeration_Literal
is
+ List : constant Iir_Flist := Get_Enumeration_Literal_List (Sub_Type);
Res : Iir_Enumeration_Literal;
- List : Iir_List;
begin
Res := Create_Std_Decl (Iir_Kind_Enumeration_Literal);
- List := Get_Enumeration_Literal_List (Sub_Type);
Set_Std_Identifier (Res, Name);
Set_Type (Res, Sub_Type);
Set_Expr_Staticness (Res, Locally);
Set_Name_Staticness (Res, Locally);
- Set_Enum_Pos (Res, Iir_Int32 (Get_Nbr_Elements (List)));
+ Set_Enum_Pos (Res, Iir_Int32 (Pos));
Sem.Compute_Subprogram_Hash (Res);
- Append_Element (List, Res);
+ Set_Nth_Element (List, Pos, Res);
return Res;
end Create_Std_Literal;
@@ -440,11 +440,11 @@ package body Std_Package is
Create_Std_Iir (Iir_Kind_Enumeration_Type_Definition);
Set_Base_Type (Boolean_Type_Definition, Boolean_Type_Definition);
Set_Enumeration_Literal_List
- (Boolean_Type_Definition, Create_Iir_List);
+ (Boolean_Type_Definition, Create_Iir_Flist (2));
Boolean_False := Create_Std_Literal
- (Name_False, Boolean_Type_Definition);
+ (Name_False, 0, Boolean_Type_Definition);
Boolean_True := Create_Std_Literal
- (Name_True, Boolean_Type_Definition);
+ (Name_True, 1, Boolean_Type_Definition);
Set_Type_Staticness (Boolean_Type_Definition, Locally);
Set_Signal_Type_Flag (Boolean_Type_Definition, True);
Set_Has_Signal_Flag (Boolean_Type_Definition,
@@ -475,13 +475,13 @@ package body Std_Package is
Bit_Type_Definition :=
Create_Std_Iir (Iir_Kind_Enumeration_Type_Definition);
Set_Enumeration_Literal_List
- (Bit_Type_Definition, Create_Iir_List);
+ (Bit_Type_Definition, Create_Iir_Flist (2));
Set_Base_Type (Bit_Type_Definition, Bit_Type_Definition);
Set_Is_Character_Type (Bit_Type_Definition, True);
Bit_0 := Create_Std_Literal
- (Get_Std_Character ('0'), Bit_Type_Definition);
+ (Get_Std_Character ('0'), 0, Bit_Type_Definition);
Bit_1 := Create_Std_Literal
- (Get_Std_Character ('1'), Bit_Type_Definition);
+ (Get_Std_Character ('1'), 1, Bit_Type_Definition);
Set_Type_Staticness (Bit_Type_Definition, Locally);
Set_Signal_Type_Flag (Bit_Type_Definition, True);
Set_Has_Signal_Flag (Bit_Type_Definition,
@@ -510,29 +510,39 @@ package body Std_Package is
declare
El: Iir;
pragma Unreferenced (El);
+ Len : Natural;
begin
Character_Type_Definition :=
Create_Std_Iir (Iir_Kind_Enumeration_Type_Definition);
Set_Base_Type (Character_Type_Definition, Character_Type_Definition);
Set_Is_Character_Type (Character_Type_Definition, True);
+ if Vhdl_Std = Vhdl_87 then
+ Len := 128;
+ else
+ Len := 256;
+ end if;
Set_Enumeration_Literal_List
- (Character_Type_Definition, Create_Iir_List);
+ (Character_Type_Definition, Create_Iir_Flist (Len));
for I in Name_Nul .. Name_Usp loop
- El := Create_Std_Literal (I, Character_Type_Definition);
+ El := Create_Std_Literal
+ (I, Natural (I - Name_Nul), Character_Type_Definition);
end loop;
for I in Character'(' ') .. Character'('~') loop
El := Create_Std_Literal
- (Get_Std_Character (I), Character_Type_Definition);
+ (Get_Std_Character (I), Character'Pos (I),
+ Character_Type_Definition);
end loop;
- El := Create_Std_Literal (Name_Del, Character_Type_Definition);
+ El := Create_Std_Literal (Name_Del, 127, Character_Type_Definition);
if Vhdl_Std /= Vhdl_87 then
for I in Name_C128 .. Name_C159 loop
- El := Create_Std_Literal (I, Character_Type_Definition);
+ El := Create_Std_Literal
+ (I, 128 + Natural (I - Name_C128), Character_Type_Definition);
end loop;
for I in Character'Val (160) .. Character'Val (255) loop
El := Create_Std_Literal
- (Get_Std_Character (I), Character_Type_Definition);
+ (Get_Std_Character (I), Character'Pos (I),
+ Character_Type_Definition);
end loop;
end if;
Set_Type_Staticness (Character_Type_Definition, Locally);
@@ -558,16 +568,16 @@ package body Std_Package is
Set_Base_Type (Severity_Level_Type_Definition,
Severity_Level_Type_Definition);
Set_Enumeration_Literal_List
- (Severity_Level_Type_Definition, Create_Iir_List);
+ (Severity_Level_Type_Definition, Create_Iir_Flist (4));
Severity_Level_Note := Create_Std_Literal
- (Name_Note, Severity_Level_Type_Definition);
+ (Name_Note, 0, Severity_Level_Type_Definition);
Severity_Level_Warning := Create_Std_Literal
- (Name_Warning, Severity_Level_Type_Definition);
+ (Name_Warning, 1, Severity_Level_Type_Definition);
Severity_Level_Error := Create_Std_Literal
- (Name_Error, Severity_Level_Type_Definition);
+ (Name_Error, 2, Severity_Level_Type_Definition);
Severity_Level_Failure := Create_Std_Literal
- (Name_Failure, Severity_Level_Type_Definition);
+ (Name_Failure, 3, Severity_Level_Type_Definition);
Set_Type_Staticness (Severity_Level_Type_Definition, Locally);
Set_Signal_Type_Flag (Severity_Level_Type_Definition, True);
Set_Has_Signal_Flag (Severity_Level_Type_Definition,
@@ -1134,14 +1144,14 @@ package body Std_Package is
Set_Base_Type (File_Open_Kind_Type_Definition,
File_Open_Kind_Type_Definition);
Set_Enumeration_Literal_List
- (File_Open_Kind_Type_Definition, Create_Iir_List);
+ (File_Open_Kind_Type_Definition, Create_Iir_Flist (3));
File_Open_Kind_Read_Mode := Create_Std_Literal
- (Name_Read_Mode, File_Open_Kind_Type_Definition);
+ (Name_Read_Mode, 0, File_Open_Kind_Type_Definition);
File_Open_Kind_Write_Mode := Create_Std_Literal
- (Name_Write_Mode, File_Open_Kind_Type_Definition);
+ (Name_Write_Mode, 1, File_Open_Kind_Type_Definition);
File_Open_Kind_Append_Mode := Create_Std_Literal
- (Name_Append_Mode, File_Open_Kind_Type_Definition);
+ (Name_Append_Mode, 2, File_Open_Kind_Type_Definition);
Set_Type_Staticness (File_Open_Kind_Type_Definition, Locally);
Set_Signal_Type_Flag (File_Open_Kind_Type_Definition, True);
Set_Has_Signal_Flag (File_Open_Kind_Type_Definition,
@@ -1172,16 +1182,16 @@ package body Std_Package is
Set_Base_Type (File_Open_Status_Type_Definition,
File_Open_Status_Type_Definition);
Set_Enumeration_Literal_List
- (File_Open_Status_Type_Definition, Create_Iir_List);
+ (File_Open_Status_Type_Definition, Create_Iir_Flist (4));
File_Open_Status_Open_Ok := Create_Std_Literal
- (Name_Open_Ok, File_Open_Status_Type_Definition);
+ (Name_Open_Ok, 0, File_Open_Status_Type_Definition);
File_Open_Status_Status_Error := Create_Std_Literal
- (Name_Status_Error, File_Open_Status_Type_Definition);
+ (Name_Status_Error, 1, File_Open_Status_Type_Definition);
File_Open_Status_Name_Error := Create_Std_Literal
- (Name_Name_Error, File_Open_Status_Type_Definition);
+ (Name_Name_Error, 2, File_Open_Status_Type_Definition);
File_Open_Status_Mode_Error := Create_Std_Literal
- (Name_Mode_Error, File_Open_Status_Type_Definition);
+ (Name_Mode_Error, 3, File_Open_Status_Type_Definition);
Set_Type_Staticness (File_Open_Status_Type_Definition, Locally);
Set_Signal_Type_Flag (File_Open_Status_Type_Definition, True);
Set_Has_Signal_Flag (File_Open_Status_Type_Definition,
diff --git a/src/vhdl/translate/trans-chap14.adb b/src/vhdl/translate/trans-chap14.adb
index 8fd37261b..2e554d556 100644
--- a/src/vhdl/translate/trans-chap14.adb
+++ b/src/vhdl/translate/trans-chap14.adb
@@ -326,21 +326,21 @@ package body Trans.Chap14 is
| Type_Mode_E32 =>
-- Should check it is not the last.
declare
- List : constant Iir_List := Get_Enumeration_Literal_List
+ List : constant Iir_Flist := Get_Enumeration_Literal_List
(Get_Base_Type (Expr_Type));
- Limit : Iir;
+ Limit : Natural;
L : O_Dnode;
begin
L := Create_Temp_Init (Ttype, Expr);
if Is_Inc then
- Limit := Get_Last_Element (List);
+ Limit := Get_Nbr_Elements (List) - 1;
else
- Limit := Get_First_Element (List);
+ Limit := 0;
end if;
Chap6.Check_Bound_Error
(New_Compare_Op (ON_Eq,
New_Obj_Value (L),
- New_Lit (Get_Ortho_Expr (Limit)),
+ New_Lit (Get_Ortho_Expr (Get_Nth_Element (List, Limit))),
Ghdl_Bool_Type),
Attr, 0);
return New_Convert_Ov
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index 3538a6ac6..cd350565f 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -221,7 +221,7 @@ package body Trans.Chap3 is
procedure Translate_Enumeration_Type
(Def : Iir_Enumeration_Type_Definition)
is
- El_List : constant Iir_List := Get_Enumeration_Literal_List (Def);
+ El_List : constant Iir_Flist := Get_Enumeration_Literal_List (Def);
Nbr : constant Natural := Get_Nbr_Elements (El_List);
Info : constant Type_Info_Acc := Get_Info (Def);
El : Iir_Enumeration_Literal;
@@ -236,9 +236,8 @@ package body Trans.Chap3 is
Size := 32;
end if;
Start_Enum_Type (Constr, Size);
- for I in Natural loop
+ for I in Flist_First .. Flist_Last (El_List) loop
El := Get_Nth_Element (El_List, I);
- exit when El = Null_Iir;
Lit_Name := Translate_Enumeration_Literal (El);
New_Enum_Literal (Constr, Lit_Name, Val);
@@ -259,7 +258,7 @@ package body Trans.Chap3 is
procedure Translate_Bool_Type (Def : Iir_Enumeration_Type_Definition)
is
Info : constant Type_Info_Acc := Get_Info (Def);
- El_List : constant Iir_List := Get_Enumeration_Literal_List (Def);
+ El_List : constant Iir_Flist := Get_Enumeration_Literal_List (Def);
pragma Assert (Get_Nbr_Elements (El_List) = 2);
False_Lit : constant Iir := Get_Nth_Element (El_List, 0);
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 72eaa7714..1627afebc 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -170,7 +170,7 @@ package body Trans.Chap7 is
is
use Name_Table;
- Literal_List : constant Iir_List :=
+ Literal_List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Get_Base_Type (El_Type));
Len : constant Nat32 := Get_String_Length (Str);
Id : constant String8_Id := Get_String8_Id (Str);
@@ -421,7 +421,8 @@ package body Trans.Chap7 is
is
use Name_Table;
- Literal_List : Iir_List;
+ Literal_List : constant Iir_Flist :=
+ Get_Enumeration_Literal_List (Character_Type_Definition);
Lit : Iir;
List : O_Array_Aggr_List;
Res : O_Cnode;
@@ -430,7 +431,6 @@ package body Trans.Chap7 is
Start_Array_Aggr (List, Get_Ortho_Type (Str_Type, Mode_Value));
- Literal_List := Get_Enumeration_Literal_List (Character_Type_Definition);
Image (Str_Ident);
for I in 1 .. Nam_Length loop
Lit := Get_Nth_Element (Literal_List,
@@ -506,10 +506,10 @@ package body Trans.Chap7 is
when Iir_Kind_Enumeration_Literal =>
declare
Enum_Type : constant Iir := Get_Base_Type (Get_Type (Expr));
- Lit_List : Iir_List;
+ Lit_List : constant Iir_Flist :=
+ Get_Enumeration_Literal_List (Enum_Type);
Enum : Iir;
begin
- Lit_List := Get_Enumeration_Literal_List (Enum_Type);
Enum := Get_Nth_Element
(Lit_List, Natural (Get_Enum_Pos (Expr)));
return Get_Ortho_Expr (Enum);
@@ -1968,7 +1968,7 @@ package body Trans.Chap7 is
(Op : ON_Op_Kind; Operand : Iir; Res_Type : Iir) return O_Enode
is
Arr_Type : constant Iir := Get_Type (Operand);
- Enums : constant Iir_List :=
+ Enums : constant Iir_Flist :=
Get_Enumeration_Literal_List (Get_Base_Type (Res_Type));
Init_Enum : Iir;
@@ -2073,7 +2073,7 @@ package body Trans.Chap7 is
function Translate_Predefined_TF_Edge (Is_Rising : Boolean; Left : Iir)
return O_Enode
is
- Enums : constant Iir_List :=
+ Enums : constant Iir_Flist :=
Get_Enumeration_Literal_List (Get_Base_Type (Get_Type (Left)));
Sig : Mnode;
Val : Mnode;
@@ -5208,12 +5208,12 @@ package body Trans.Chap7 is
case Shift is
when Sh_Logical =>
declare
- Enum_List : Iir_List;
- begin
- Enum_List := Get_Enumeration_Literal_List
+ Enum_List : constant Iir_Flist :=
+ Get_Enumeration_Literal_List
(Get_Base_Type (Get_Element_Subtype (Arr_Type)));
+ begin
Tmp := New_Lit
- (Get_Ortho_Expr (Get_First_Element (Enum_List)));
+ (Get_Ortho_Expr (Get_Nth_Element (Enum_List, 0)));
end;
when Sh_Arith =>
Tmp := New_Obj_Value (Var_E);
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb
index 493f2336e..734559e81 100644
--- a/src/vhdl/translate/trans-chap8.adb
+++ b/src/vhdl/translate/trans-chap8.adb
@@ -400,9 +400,9 @@ package body Trans.Chap8 is
(Get_Ortho_Type (Base_Type, Mode_Value), Integer_64 (Val)));
when Iir_Kind_Enumeration_Type_Definition =>
declare
- List : Iir_List;
+ List : constant Iir_Flist :=
+ Get_Enumeration_Literal_List (Base_Type);
begin
- List := Get_Enumeration_Literal_List (Base_Type);
-- FIXME: what about type E is ('T') ??
if Natural (Val) > Get_Nbr_Elements (List) then
raise Internal_Error;
diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb
index a60138fea..cde74a439 100644
--- a/src/vhdl/translate/trans-rtis.adb
+++ b/src/vhdl/translate/trans-rtis.adb
@@ -1079,9 +1079,9 @@ package body Trans.Rtis is
end if;
declare
- Lit_List : constant Iir_List :=
+ Lit_List : constant Iir_Flist :=
Get_Enumeration_Literal_List (Atype);
- Nbr_Lit : constant Integer := Get_Nbr_Elements (Lit_List);
+ Nbr_Lit : constant Natural := Get_Nbr_Elements (Lit_List);
Lit : Iir;
type Dnode_Array is array (Natural range <>) of O_Dnode;