From 0e0c3efd5e7a375329982f293e85c01d254eaac1 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 2 Jan 2017 04:16:49 +0100 Subject: iirs: renames Iir_Kinds_Scalar_Type_Definition --- src/vhdl/canon.adb | 3 ++- src/vhdl/evaluation.adb | 15 ++++++++------ src/vhdl/iirs.ads | 2 +- src/vhdl/sem_assocs.adb | 3 ++- src/vhdl/sem_decls.adb | 2 +- src/vhdl/sem_expr.adb | 20 ++++++++++--------- src/vhdl/sem_names.adb | 5 +++-- src/vhdl/sem_types.adb | 39 ++++++++++++++++++++----------------- src/vhdl/translate/trans-chap14.adb | 6 ++++-- src/vhdl/translate/trans-chap2.adb | 5 ++--- src/vhdl/translate/trans-chap3.adb | 12 ++++++------ src/vhdl/translate/trans-chap7.adb | 2 +- src/vhdl/translate/trans-chap8.adb | 2 +- 13 files changed, 64 insertions(+), 52 deletions(-) diff --git a/src/vhdl/canon.adb b/src/vhdl/canon.adb index 0304aea9a..a444ab12c 100644 --- a/src/vhdl/canon.adb +++ b/src/vhdl/canon.adb @@ -129,7 +129,8 @@ package body Canon is Canon_Extract_Sensitivity (Get_Prefix (Expr), Sensitivity_List, Is_Target); Suff := Get_Suffix (Expr); - if Get_Kind (Suff) not in Iir_Kinds_Scalar_Type_Definition + if Get_Kind (Suff) + not in Iir_Kinds_Scalar_Type_And_Subtype_Definition then Canon_Extract_Sensitivity (Suff, Sensitivity_List, False); diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb index 0e67a10fc..c09cac7d0 100644 --- a/src/vhdl/evaluation.adb +++ b/src/vhdl/evaluation.adb @@ -571,7 +571,7 @@ package body Evaluation is if not Get_Same_Alternative_Flag (Assoc) then Expr := Get_Associated_Expr (Assoc); if Get_Kind (Get_Type (Expr)) - in Iir_Kinds_Scalar_Type_Definition + in Iir_Kinds_Scalar_Type_And_Subtype_Definition then Expr := Eval_Expr_Keep_Orig (Expr, True); Set_Associated_Expr (Assoc, Expr); @@ -2752,8 +2752,8 @@ package body Evaluation is end if; -- Element must be scalar. - if Get_Kind (Get_Element_Subtype (Expr_Type)) not in - Iir_Kinds_Scalar_Type_Definition + if Get_Kind (Get_Element_Subtype (Expr_Type)) + not in Iir_Kinds_Scalar_Type_And_Subtype_Definition then return False; end if; @@ -2776,7 +2776,9 @@ package body Evaluation is function Can_Eval_Value (Expr : Iir; Top : Boolean) return Boolean is begin -- Always evaluate scalar values. - if Get_Kind (Get_Type (Expr)) in Iir_Kinds_Scalar_Type_Definition then + if Get_Kind (Get_Type (Expr)) + in Iir_Kinds_Scalar_Type_And_Subtype_Definition + then return True; end if; return Can_Eval_Composite_Value (Expr, Top); @@ -2795,7 +2797,7 @@ package body Evaluation is -- We are only considering composite types. pragma Assert (Get_Kind (Get_Type (Expr)) - not in Iir_Kinds_Scalar_Type_Definition); + not in Iir_Kinds_Scalar_Type_And_Subtype_Definition); begin case Get_Kind (Expr) is when Iir_Kind_Type_Conversion @@ -2899,7 +2901,8 @@ package body Evaluation is if Expr /= Null_Iir and then Get_Expr_Staticness (Expr) = Locally then -- Expression is static and can be evaluated. Don't try to -- evaluate non-scalar expressions, that may create too large data. - if Get_Kind (Atype) in Iir_Kinds_Scalar_Type_Definition then + if Get_Kind (Atype) in Iir_Kinds_Scalar_Type_And_Subtype_Definition + then Res := Eval_Expr_Keep_Orig (Expr, False); else Res := Expr; diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index a12ee15bb..f313191fb 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -4885,7 +4885,7 @@ package Iirs is --Iir_Kind_Integer_Subtype_Definition Iir_Kind_Enumeration_Subtype_Definition; - subtype Iir_Kinds_Scalar_Type_Definition is Iir_Kind range + subtype Iir_Kinds_Scalar_Type_And_Subtype_Definition is Iir_Kind range Iir_Kind_Physical_Subtype_Definition .. --Iir_Kind_Floating_Subtype_Definition --Iir_Kind_Integer_Subtype_Definition diff --git a/src/vhdl/sem_assocs.adb b/src/vhdl/sem_assocs.adb index 2d050e9e2..1eef39292 100644 --- a/src/vhdl/sem_assocs.adb +++ b/src/vhdl/sem_assocs.adb @@ -510,7 +510,8 @@ package body Sem_Assocs is Src_Range : Iir; Dst_Range : Iir; begin - if Get_Kind (Src) not in Iir_Kinds_Scalar_Type_Definition then + if Get_Kind (Src) not in Iir_Kinds_Scalar_Type_And_Subtype_Definition + then return True; end if; diff --git a/src/vhdl/sem_decls.adb b/src/vhdl/sem_decls.adb index e75092a33..d021bee98 100644 --- a/src/vhdl/sem_decls.adb +++ b/src/vhdl/sem_decls.adb @@ -1056,7 +1056,7 @@ package body Sem_Decls is -- function MAXIMUM (L : T) return E; if Vhdl_Std >= Vhdl_08 and then (Get_Kind (Element_Type) in - Iir_Kinds_Scalar_Type_Definition) + Iir_Kinds_Scalar_Type_And_Subtype_Definition) then Add_Vector_Min_Max (Name_Maximum, Iir_Predefined_Vector_Maximum); diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb index bb412d649..084aa377f 100644 --- a/src/vhdl/sem_expr.adb +++ b/src/vhdl/sem_expr.adb @@ -682,8 +682,8 @@ package body Sem_Expr is end if; Set_Type (Expr, Expr_Type); - if Get_Kind (Get_Base_Type (Expr_Type)) - not in Iir_Kinds_Scalar_Type_Definition + if Get_Kind (Expr_Type) + not in Iir_Kinds_Scalar_Type_And_Subtype_Definition then Error_Msg_Sem (+Expr, "type of range is not a scalar type"); return Null_Iir; @@ -756,7 +756,9 @@ package body Sem_Expr is return Null_Iir; end case; - if Get_Kind (Res_Type) not in Iir_Kinds_Scalar_Type_Definition then + if Get_Kind (Res_Type) + not in Iir_Kinds_Scalar_Type_And_Subtype_Definition + then Error_Msg_Sem (+Expr, "%n is not a range type", +Res); return Null_Iir; end if; @@ -3453,6 +3455,7 @@ package body Sem_Expr is Infos : Array_Aggr_Info_Arr (1 .. Nbr_Dim); Aggr_Constrained : Boolean; Info, Prev_Info : Iir_Aggregate_Info; + Type_Staticness : Iir_Staticness; begin -- By default, consider the aggregate can be statically built. Set_Aggregate_Expand_Flag (Aggr, True); @@ -3477,20 +3480,19 @@ package body Sem_Expr is -- and statically match the subtype of the aggregate. if Aggr_Constrained then A_Subtype := Create_Array_Subtype (Base_Type, Get_Location (Aggr)); + Type_Staticness := Get_Type_Staticness (A_Subtype); for I in Infos'Range loop Append_Element (Get_Index_Subtype_List (A_Subtype), Infos (I).Index_Subtype); - Set_Type_Staticness - (A_Subtype, - Iirs.Min (Get_Type_Staticness (A_Subtype), - Get_Type_Staticness (Infos (I).Index_Subtype))); + Type_Staticness := Min + (Type_Staticness, Get_Type_Staticness (Infos (I).Index_Subtype)); end loop; + Set_Type_Staticness (A_Subtype, Type_Staticness); Set_Index_Constraint_Flag (A_Subtype, True); Set_Constraint_State (A_Subtype, Fully_Constrained); Set_Type (Aggr, A_Subtype); Set_Literal_Subtype (Aggr, A_Subtype); - if Get_Type_Staticness (A_Subtype) = Locally - and then Get_Aggregate_Expand_Flag (Aggr) + if Type_Staticness = Locally and then Get_Aggregate_Expand_Flag (Aggr) then -- Compute ratio of elements vs size of the aggregate to determine -- if the aggregate can be expanded. diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb index b7c4a41b9..76dce228f 100644 --- a/src/vhdl/sem_names.adb +++ b/src/vhdl/sem_names.adb @@ -2903,7 +2903,8 @@ package body Sem_Names is case Id is when Name_Image | Name_Value => - if Get_Kind (Prefix_Type) not in Iir_Kinds_Scalar_Type_Definition + if Get_Kind (Prefix_Type) + not in Iir_Kinds_Scalar_Type_And_Subtype_Definition then Error_Msg_Sem (+Attr, "prefix of %i attribute must be a scalar type", @@ -3145,7 +3146,7 @@ package body Sem_Names is end case; case Get_Kind (Prefix_Type) is - when Iir_Kinds_Scalar_Type_Definition => + when Iir_Kinds_Scalar_Type_And_Subtype_Definition => -- Note: prefix is a scalar type or subtype. return Sem_Predefined_Type_Attribute (Attr); when Iir_Kinds_Array_Type_Definition => diff --git a/src/vhdl/sem_types.adb b/src/vhdl/sem_types.adb index 2576bb269..e6f242c1e 100644 --- a/src/vhdl/sem_types.adb +++ b/src/vhdl/sem_types.adb @@ -799,7 +799,7 @@ package body Sem_Types is El: Iir; El_Type : Iir; Resolved_Flag : Boolean; - Staticness : Iir_Staticness; + Type_Staticness : Iir_Staticness; Constraint : Iir_Constraint; begin -- LRM 10.1 @@ -808,7 +808,7 @@ package body Sem_Types is Resolved_Flag := True; Last_Type := Null_Iir; - Staticness := Locally; + Type_Staticness := Locally; Constraint := Fully_Constrained; Set_Signal_Type_Flag (Def, True); @@ -848,12 +848,11 @@ package body Sem_Types is end if; Resolved_Flag := Resolved_Flag and Get_Resolved_Flag (El_Type); - Staticness := Min (Staticness, - Get_Type_Staticness (El_Type)); - Constraint := Update_Record_Constraint - (Constraint, El_Type); + Type_Staticness := Min (Type_Staticness, + Get_Type_Staticness (El_Type)); + Constraint := Update_Record_Constraint (Constraint, El_Type); else - Staticness := None; + Type_Staticness := None; end if; Set_Base_Element_Declaration (El, El); Sem_Scopes.Add_Name (El); @@ -863,7 +862,7 @@ package body Sem_Types is Close_Declarative_Region; Set_Base_Type (Def, Def); Set_Resolved_Flag (Def, Resolved_Flag); - Set_Type_Staticness (Def, Staticness); + Set_Type_Staticness (Def, Type_Staticness); Set_Constraint_State (Def, Constraint); return Def; end Sem_Record_Type_Definition; @@ -1414,6 +1413,7 @@ package body Sem_Types is Set_Is_Ref (Res, True); Set_Resolution_Indication (Res, Copy_Resolution_Indication (Def)); + when Iir_Kind_Enumeration_Type_Definition => Res := Create_Iir (Iir_Kind_Enumeration_Subtype_Definition); Set_Range_Constraint (Res, Get_Range_Constraint (Def)); @@ -1434,6 +1434,7 @@ package body Sem_Types is Set_Element_Subtype (Res, Get_Element_Subtype (Def)); Set_Index_Constraint_Flag (Res, False); Set_Constraint_State (Res, Get_Constraint_State (Def)); + when Iir_Kind_Array_Subtype_Definition => Res := Create_Iir (Iir_Kind_Array_Subtype_Definition); Set_Resolution_Indication (Res, Copy_Resolution_Indication (Def)); @@ -1455,6 +1456,7 @@ package body Sem_Types is Set_Resolved_Flag (Res, Get_Resolved_Flag (Def)); Set_Constraint_State (Res, Get_Constraint_State (Def)); Copy_Record_Elements_Declaration_List (Res, Def); + when others => -- FIXME: todo (protected type ?) Error_Kind ("copy_subtype_indication", Def); @@ -1476,7 +1478,7 @@ package body Sem_Types is Type_Index, Subtype_Index: Iir; Base_Type : Iir; El_Def : Iir; - Staticness : Iir_Staticness; + Index_Staticness : Iir_Staticness; Error_Seen : Boolean; Type_Index_List : Iir_List; Subtype_Index_List : Iir_List; @@ -1532,6 +1534,7 @@ package body Sem_Types is -- No element constraint. El_Def := Null_Iir; + Index_Staticness := None; when Iir_Kind_Array_Subtype_Definition => -- Case of a constraint for an array. @@ -1541,7 +1544,7 @@ package body Sem_Types is Set_Base_Type (Def, Base_Type); El_Def := Get_Array_Element_Constraint (Def); - Staticness := Get_Type_Staticness (El_Type); + Index_Staticness := Locally; Error_Seen := False; Type_Index_List := Get_Index_Subtype_Definition_List (Base_Type); @@ -1594,8 +1597,8 @@ package body Sem_Types is if Subtype_Index /= Null_Iir then Subtype_Index := Range_To_Subtype_Indication (Subtype_Index); - Staticness := Min - (Staticness, + Index_Staticness := Min + (Index_Staticness, Get_Type_Staticness (Get_Type_Of_Subtype_Indication (Subtype_Index))); @@ -1605,7 +1608,7 @@ package body Sem_Types is -- Create a fake subtype from type_index. -- FIXME: It is too fake. Subtype_Index := Type_Index; - Staticness := None; + Index_Staticness := None; end if; if Error_Seen then Append_Element (Subtype_Index_List, Subtype_Index); @@ -1617,7 +1620,8 @@ package body Sem_Types is Set_Index_Subtype_List (Def, Subtype_Index_List); Set_Index_Constraint_Flag (Def, True); end if; - Set_Type_Staticness (Def, Staticness); + Set_Type_Staticness + (Def, Min (Get_Type_Staticness (El_Type), Index_Staticness)); Set_Signal_Type_Flag (Def, Get_Signal_Type_Flag (Type_Mark)); Res := Def; @@ -1807,8 +1811,7 @@ package body Sem_Types is end Reparse_As_Array_Constraint; function Sem_Record_Constraint - (Def : Iir; Type_Mark : Iir; Resolution : Iir) - return Iir + (Def : Iir; Type_Mark : Iir; Resolution : Iir) return Iir is Res : Iir; El_List, Tm_El_List : Iir_List; @@ -1961,6 +1964,7 @@ package body Sem_Types is Tm_El := Get_Nth_Element (Tm_El_List, I); if Els (I) = Null_Iir and Res_Els (I) = Null_Iir then El := Tm_El; + El_Type := Get_Type (El); else if Els (I) = Null_Iir then El := Create_Iir (Iir_Kind_Record_Element_Constraint); @@ -1978,8 +1982,7 @@ package body Sem_Types is Set_Type (El, El_Type); end if; Append_Element (El_List, El); - Constraint := Update_Record_Constraint - (Constraint, Get_Type (El)); + Constraint := Update_Record_Constraint (Constraint, El_Type); end loop; Set_Constraint_State (Res, Constraint); end; diff --git a/src/vhdl/translate/trans-chap14.adb b/src/vhdl/translate/trans-chap14.adb index 05f017c3f..cd1254d6f 100644 --- a/src/vhdl/translate/trans-chap14.adb +++ b/src/vhdl/translate/trans-chap14.adb @@ -431,7 +431,8 @@ package body Trans.Chap14 is Prefix : constant Iir := Get_Prefix (Attr); Prefix_Type : constant Iir := Get_Type (Prefix); begin - if Get_Kind (Prefix_Type) in Iir_Kinds_Scalar_Type_Definition then + if Get_Kind (Prefix_Type) in Iir_Kinds_Scalar_Type_And_Subtype_Definition + then -- Effecient handling for a scalar signal. Name := Chap6.Translate_Name (Prefix, Mode_Signal); return New_Value (Get_Signal_Field (Name, Field)); @@ -720,7 +721,8 @@ package body Trans.Chap14 is Prefix := Get_Prefix (Attr); Prefix_Type := Get_Type (Prefix); - if Get_Kind (Prefix_Type) in Iir_Kinds_Scalar_Type_Definition then + if Get_Kind (Prefix_Type) in Iir_Kinds_Scalar_Type_And_Subtype_Definition + then -- Effecient handling for a scalar signal. Name := Chap6.Translate_Name (Prefix, Mode_Signal); return Read_Driving_Attribute (New_Value (M2Lv (Name))); diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index 139bf2223..519034131 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -367,9 +367,8 @@ package body Trans.Chap2 is when Iir_Kind_Type_Declaration | Iir_Kind_Anonymous_Type_Declaration => Atype := Get_Type_Definition (Decl); - case Iir_Kinds_Type_And_Subtype_Definition - (Get_Kind (Atype)) is - when Iir_Kinds_Scalar_Type_Definition => + case Iir_Kinds_Type_And_Subtype_Definition (Get_Kind (Atype)) is + when Iir_Kinds_Scalar_Type_And_Subtype_Definition => null; when Iir_Kind_Access_Type_Definition | Iir_Kind_Access_Subtype_Definition => diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index 77a998b19..b14a86acd 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -399,7 +399,7 @@ package body Trans.Chap3 is function Get_File_Signature_Length (Def : Iir) return Natural is begin case Get_Kind (Def) is - when Iir_Kinds_Scalar_Type_Definition => + when Iir_Kinds_Scalar_Type_And_Subtype_Definition => return 1; when Iir_Kind_Array_Type_Definition | Iir_Kind_Array_Subtype_Definition => @@ -434,7 +434,7 @@ package body Trans.Chap3 is := "beEiIpPF"; begin case Get_Kind (Def) is - when Iir_Kinds_Scalar_Type_Definition => + when Iir_Kinds_Scalar_Type_And_Subtype_Definition => Res (Off) := Scalar_Map (Get_Info (Def).Type_Mode); Off := Off + 1; when Iir_Kind_Array_Type_Definition @@ -471,7 +471,8 @@ package body Trans.Chap3 is Type_Name : constant Iir := Get_Type (Get_File_Type_Mark (Def)); Info : Type_Info_Acc; begin - if Get_Kind (Type_Name) in Iir_Kinds_Scalar_Type_Definition then + if Get_Kind (Type_Name) in Iir_Kinds_Scalar_Type_And_Subtype_Definition + then return; end if; declare @@ -856,7 +857,7 @@ package body Trans.Chap3 is Base_Info := Get_Info (Get_Base_Type (Def)); case Get_Array_Bounds_Staticness (Def) is when None - | Globally => + | Globally => Info.S.Static_Bounds := False; Info.S.Array_Bounds := Create_Var (Create_Var_Identifier ("STB"), Base_Info.B.Bounds_Type); @@ -2026,7 +2027,6 @@ package body Trans.Chap3 is Translate_Array_Subtype_Definition (Def); Info.B := Base_Info.B; Info.S := Base_Info.S; - --Info.Type_Range_Type := Base_Info.Type_Range_Type; if With_Vars then Create_Array_Subtype_Bounds_Var (Def, False); end if; @@ -2888,7 +2888,7 @@ package body Trans.Chap3 is Expr_Type : constant Iir := Get_Type (Expr); begin -- pragma Assert (Base_Type = Get_Base_Type (Atype)); - if Get_Kind (Expr_Type) in Iir_Kinds_Scalar_Type_Definition + if Get_Kind (Expr_Type) in Iir_Kinds_Scalar_Type_And_Subtype_Definition and then Need_Range_Check (Expr, Atype) then return Insert_Scalar_Check (Value, Expr, Atype, Expr); diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index 4ad38dfc2..cba7018aa 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -3475,7 +3475,7 @@ package body Trans.Chap7 is Res : O_Enode; begin case Get_Kind (Res_Type) is - when Iir_Kinds_Scalar_Type_Definition => + when Iir_Kinds_Scalar_Type_And_Subtype_Definition => Res := New_Convert_Ov (Expr, Res_Info.Ortho_Type (Mode_Value)); if Chap3.Need_Range_Check (Null_Iir, Res_Type) then Res := Chap3.Insert_Scalar_Check diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb index b01691607..080894562 100644 --- a/src/vhdl/translate/trans-chap8.adb +++ b/src/vhdl/translate/trans-chap8.adb @@ -2248,7 +2248,7 @@ package body Trans.Chap8 is if Is_Static_Construct (Actual) or else (Get_Kind (Act_Type) - in Iir_Kinds_Scalar_Type_Definition) + in Iir_Kinds_Scalar_Type_And_Subtype_Definition) or else Get_Kind (Ftype) = Iir_Kind_File_Type_Definition or else Is_Result_On_Stack2_Expression (Actual) then -- cgit v1.2.3