diff options
author | Tristan Gingold <tgingold@free.fr> | 2014-12-14 12:36:43 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2014-12-14 12:36:43 +0100 |
commit | 51f657fde8d771ca5c4002ca70ad5175c6ef3cdf (patch) | |
tree | f5487dafd4682425ec2af9947fcac279153fc3ac | |
parent | df03d4120b0689b30dc4f629407d96b45b0db5a4 (diff) | |
download | ghdl-51f657fde8d771ca5c4002ca70ad5175c6ef3cdf.tar.gz ghdl-51f657fde8d771ca5c4002ca70ad5175c6ef3cdf.tar.bz2 ghdl-51f657fde8d771ca5c4002ca70ad5175c6ef3cdf.zip |
iirs: reduce size of signal_declaration.
-rw-r--r-- | src/vhdl/canon.adb | 2 | ||||
-rw-r--r-- | src/vhdl/disp_tree.adb | 2 | ||||
-rw-r--r-- | src/vhdl/disp_vhdl.adb | 24 | ||||
-rw-r--r-- | src/vhdl/ieee-vital_timing.adb | 2 | ||||
-rw-r--r-- | src/vhdl/iirs.adb | 25 | ||||
-rw-r--r-- | src/vhdl/iirs.adb.in | 5 | ||||
-rw-r--r-- | src/vhdl/iirs.ads | 38 | ||||
-rw-r--r-- | src/vhdl/nodes.ads | 19 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.adb | 318 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/parse.adb | 30 | ||||
-rw-r--r-- | src/vhdl/sem_decls.adb | 62 | ||||
-rw-r--r-- | src/vhdl/sem_specs.adb | 2 | ||||
-rw-r--r-- | src/vhdl/sem_stmts.adb | 2 | ||||
-rw-r--r-- | src/vhdl/translate/trans-rtis.adb | 12 | ||||
-rwxr-xr-x | src/xtools/pnodes.py | 8 |
16 files changed, 317 insertions, 236 deletions
diff --git a/src/vhdl/canon.adb b/src/vhdl/canon.adb index 883e89e1b..8b8ffe49a 100644 --- a/src/vhdl/canon.adb +++ b/src/vhdl/canon.adb @@ -2172,7 +2172,7 @@ package body Canon is while El /= Null_Iir loop if Get_Kind (El) = Iir_Kind_Signal_Declaration and then Get_Type (El) = Dis_Type - and then Get_Signal_Kind (El) /= Iir_No_Signal_Kind + and then Get_Guarded_Signal_Flag (El) then if not Get_Has_Disconnect_Flag (El) then Set_Has_Disconnect_Flag (El, True); diff --git a/src/vhdl/disp_tree.adb b/src/vhdl/disp_tree.adb index fbaaa939b..1fd3bd500 100644 --- a/src/vhdl/disp_tree.adb +++ b/src/vhdl/disp_tree.adb @@ -226,8 +226,6 @@ package body Disp_Tree is function Image_Iir_Signal_Kind (Kind : Iir_Signal_Kind) return String is begin case Kind is - when Iir_No_Signal_Kind => - return "no"; when Iir_Register_Kind => return "register"; when Iir_Bus_Kind => diff --git a/src/vhdl/disp_vhdl.adb b/src/vhdl/disp_vhdl.adb index 3683ae5e3..f67261862 100644 --- a/src/vhdl/disp_vhdl.adb +++ b/src/vhdl/disp_vhdl.adb @@ -1009,16 +1009,16 @@ package body Disp_Vhdl is end case; end Disp_Mode; - procedure Disp_Signal_Kind (Kind: Iir_Signal_Kind) is - begin - case Kind is - when Iir_No_Signal_Kind => - null; - when Iir_Register_Kind => - Put (" register"); - when Iir_Bus_Kind => - Put (" bus"); - end case; + procedure Disp_Signal_Kind (Sig : Iir) is + begin + if Get_Guarded_Signal_Flag (Sig) then + case Get_Signal_Kind (Sig) is + when Iir_Register_Kind => + Put (" register"); + when Iir_Bus_Kind => + Put (" bus"); + end case; + end if; end Disp_Signal_Kind; procedure Disp_Interface_Class (Inter: Iir) is @@ -1055,7 +1055,7 @@ package body Disp_Vhdl is Disp_Subtype_Indication (Get_Subtype_Indication (Inter)); end if; if Get_Kind (Inter) = Iir_Kind_Interface_Signal_Declaration then - Disp_Signal_Kind (Get_Signal_Kind (Inter)); + Disp_Signal_Kind (Inter); end if; if Default /= Null_Iir then Put (" := "); @@ -1396,7 +1396,7 @@ package body Disp_Vhdl is Put (": "); Disp_Subtype_Indication (Get_Subtype_Indication (Decl)); if Get_Kind (Decl) = Iir_Kind_Signal_Declaration then - Disp_Signal_Kind (Get_Signal_Kind (Decl)); + Disp_Signal_Kind (Decl); end if; if Get_Default_Value (Decl) /= Null_Iir then diff --git a/src/vhdl/ieee-vital_timing.adb b/src/vhdl/ieee-vital_timing.adb index d7166da5d..3b94e3e0b 100644 --- a/src/vhdl/ieee-vital_timing.adb +++ b/src/vhdl/ieee-vital_timing.adb @@ -294,7 +294,7 @@ package body Ieee.Vital_Timing is Decl); end if; - if Get_Signal_Kind (Decl) /= Iir_No_Signal_Kind then + if Get_Guarded_Signal_Flag (Decl) then Error_Vital ("VITAL entity port cannot be guarded", Decl); end if; end Check_Entity_Port_Declaration; diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb index 92bd7a122..43d7658bb 100644 --- a/src/vhdl/iirs.adb +++ b/src/vhdl/iirs.adb @@ -208,6 +208,11 @@ package body Iirs is function Iir_Delay_Mechanism_To_Boolean is new Ada.Unchecked_Conversion (Source => Iir_Delay_Mechanism, Target => Boolean); + function Boolean_To_Iir_Signal_Kind is new Ada.Unchecked_Conversion + (Source => Boolean, Target => Iir_Signal_Kind); + function Iir_Signal_Kind_To_Boolean is new Ada.Unchecked_Conversion + (Source => Iir_Signal_Kind, Target => Boolean); + function Iir_To_String_Id is new Ada.Unchecked_Conversion (Source => Iir, Target => String_Id); function String_Id_To_Iir is new Ada.Unchecked_Conversion @@ -299,6 +304,7 @@ package body Iirs is | Iir_Kind_Terminal_Declaration | Iir_Kind_Free_Quantity_Declaration | Iir_Kind_Object_Alias_Declaration + | Iir_Kind_Signal_Declaration | Iir_Kind_Variable_Declaration | Iir_Kind_Identity_Operator | Iir_Kind_Negation_Operator @@ -452,7 +458,6 @@ package body Iirs is | Iir_Kind_Procedure_Body | Iir_Kind_File_Declaration | Iir_Kind_Guard_Signal_Declaration - | Iir_Kind_Signal_Declaration | Iir_Kind_Constant_Declaration | Iir_Kind_Iterator_Declaration | Iir_Kind_Interface_Constant_Declaration @@ -1655,18 +1660,32 @@ package body Iirs is Set_Odigit1 (Target, Iir_Mode'Pos (Mode)); end Set_Mode; + function Get_Guarded_Signal_Flag (Target : Iir) return Boolean is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Guarded_Signal_Flag (Get_Kind (Target))); + return Get_Flag8 (Target); + end Get_Guarded_Signal_Flag; + + procedure Set_Guarded_Signal_Flag (Target : Iir; Guarded : Boolean) is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Guarded_Signal_Flag (Get_Kind (Target))); + Set_Flag8 (Target, Guarded); + end Set_Guarded_Signal_Flag; + function Get_Signal_Kind (Target : Iir) return Iir_Signal_Kind is begin pragma Assert (Target /= Null_Iir); pragma Assert (Has_Signal_Kind (Get_Kind (Target))); - return Iir_Signal_Kind'Val (Get_State3 (Target)); + return Boolean_To_Iir_Signal_Kind (Get_Flag9 (Target)); end Get_Signal_Kind; procedure Set_Signal_Kind (Target : Iir; Signal_Kind : Iir_Signal_Kind) is begin pragma Assert (Target /= Null_Iir); pragma Assert (Has_Signal_Kind (Get_Kind (Target))); - Set_State3 (Target, Iir_Signal_Kind'Pos (Signal_Kind)); + Set_Flag9 (Target, Iir_Signal_Kind_To_Boolean (Signal_Kind)); end Set_Signal_Kind; function Get_Base_Name (Target : Iir) return Iir is diff --git a/src/vhdl/iirs.adb.in b/src/vhdl/iirs.adb.in index b44eb4f0c..d8e8bc0e4 100644 --- a/src/vhdl/iirs.adb.in +++ b/src/vhdl/iirs.adb.in @@ -208,6 +208,11 @@ package body Iirs is function Iir_Delay_Mechanism_To_Boolean is new Ada.Unchecked_Conversion (Source => Iir_Delay_Mechanism, Target => Boolean); + function Boolean_To_Iir_Signal_Kind is new Ada.Unchecked_Conversion + (Source => Boolean, Target => Iir_Signal_Kind); + function Iir_Signal_Kind_To_Boolean is new Ada.Unchecked_Conversion + (Source => Iir_Signal_Kind, Target => Boolean); + function Iir_To_String_Id is new Ada.Unchecked_Conversion (Source => Iir, Target => String_Id); function String_Id_To_Iir is new Ada.Unchecked_Conversion diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index 591da44f1..00daef21e 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -1114,12 +1114,14 @@ package Iirs is -- -- Get/Set_Is_Ref (Flag7) -- + -- Get/Set_Guarded_Signal_Flag (Flag8) + -- + -- Only for Iir_Kind_Interface_Signal_Declaration: + -- Get/Set_Signal_Kind (Flag9) + -- -- Get/Set_Expr_Staticness (State1) -- -- Get/Set_Name_Staticness (State2) - -- - -- Only for Iir_Kind_Interface_Signal_Declaration: - -- Get/Set_Signal_Kind (State3) -- Iir_Kind_Interface_Package_Declaration (Medium) -- @@ -1324,7 +1326,7 @@ package Iirs is -- -- Get/Set_Use_Flag (Flag6) - -- Iir_Kind_Signal_Declaration (Medium) + -- Iir_Kind_Signal_Declaration (Short) -- -- Get/Set_Parent (Field0) -- @@ -1342,14 +1344,14 @@ package Iirs is -- a process/concurrent_statement for which the signal should have a -- driver. This is used to catch at analyse time unresolved signals with -- several drivers. - -- Get/Set_Signal_Driver (Field7) + -- -- Get/Set_Signal_Driver (Field7) -- -- Get/Set_Has_Disconnect_Flag (Flag1) -- - -- Get/Set_Has_Identifier_List (Flag3) - -- -- Get/Set_Has_Active_Flag (Flag2) -- + -- Get/Set_Has_Identifier_List (Flag3) + -- -- Get/Set_Visible_Flag (Flag4) -- -- Get/Set_After_Drivers_Flag (Flag5) @@ -1358,11 +1360,13 @@ package Iirs is -- -- Get/Set_Is_Ref (Flag7) -- + -- Get/Set_Guarded_Signal_Flag (Flag8) + -- + -- Get/Set_Signal_Kind (Flag9) + -- -- Get/Set_Expr_Staticness (State1) -- -- Get/Set_Name_Staticness (State2) - -- - -- Get/Set_Signal_Kind (State3) -- Iir_Kind_Guard_Signal_Declaration (Medium) -- @@ -1384,11 +1388,13 @@ package Iirs is -- -- Get/Set_Use_Flag (Flag6) -- + -- Get/Set_Guarded_Signal_Flag (Flag8) + -- + -- Get/Set_Signal_Kind (Flag9) + -- -- Get/Set_Expr_Staticness (State1) -- -- Get/Set_Name_Staticness (State2) - -- - -- Get/Set_Signal_Kind (State3) -- Iir_Kind_Constant_Declaration (Medium) -- Iir_Kind_Iterator_Declaration (Medium) @@ -3649,10 +3655,9 @@ package Iirs is type Iir_Signal_Kind is ( - Iir_No_Signal_Kind, Iir_Register_Kind, Iir_Bus_Kind - ); + ); -- If the order of elements in IIR_MODE is modified, also modify the -- order in GRT (types and rtis). @@ -5332,7 +5337,12 @@ package Iirs is function Get_Mode (Target : Iir) return Iir_Mode; procedure Set_Mode (Target : Iir; Mode : Iir_Mode); - -- Field: State3 (pos) + -- True if the signal is guarded (has a signal kind). + -- Field: Flag8 + function Get_Guarded_Signal_Flag (Target : Iir) return Boolean; + procedure Set_Guarded_Signal_Flag (Target : Iir; Guarded : Boolean); + + -- Field: Flag9 (uc) function Get_Signal_Kind (Target : Iir) return Iir_Signal_Kind; procedure Set_Signal_Kind (Target : Iir; Signal_Kind : Iir_Signal_Kind); diff --git a/src/vhdl/nodes.ads b/src/vhdl/nodes.ads index adf6a5ee8..6b80703ed 100644 --- a/src/vhdl/nodes.ads +++ b/src/vhdl/nodes.ads @@ -39,20 +39,13 @@ package Nodes is Format_Int ); - -- Future layout: (rem) - -- Format: 0 bits 32 - -- Nkind: 16 bits 16 - -- Flags: 8*1 bits 8 - -- State: 2*2 bits 4 - -- Odigit is to be removed. - - -- Future layout (2):(rem) + -- Current layout: (rem) -- Format: 2 bits 30 - -- Nkind: 8 bits 22 (vhdl: 216 nodes) - -- Flags: 8*1 bits 14 - -- State: 2*2 bits 10 - -- Lang: 2 bits 8 - -- Odigit: 1*3 bits 5 + -- Flags: 6*1 bits 24 + -- Nkind: 8 bits 16 (vhdl: 216 nodes) + -- State: 2*2 bits 12 + -- Flags: 6*1 bits 6 + -- Odigit: 2*3 bits 0 -- Common fields are: -- Flag1 : Boolean diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb index 7e3aba364..f43c07743 100644 --- a/src/vhdl/nodes_meta.adb +++ b/src/vhdl/nodes_meta.adb @@ -102,6 +102,7 @@ package body Nodes_Meta is Field_Subtype_Definition => Type_Iir, Field_Nature => Type_Iir, Field_Mode => Type_Iir_Mode, + Field_Guarded_Signal_Flag => Type_Boolean, Field_Signal_Kind => Type_Iir_Signal_Kind, Field_Base_Name => Type_Iir, Field_Interface_Declaration_Chain => Type_Iir, @@ -481,6 +482,8 @@ package body Nodes_Meta is return "nature"; when Field_Mode => return "mode"; + when Field_Guarded_Signal_Flag => + return "guarded_signal_flag"; when Field_Signal_Kind => return "signal_kind"; when Field_Base_Name => @@ -1545,6 +1548,8 @@ package body Nodes_Meta is return Attr_None; when Field_Mode => return Attr_None; + when Field_Guarded_Signal_Flag => + return Attr_None; when Field_Signal_Kind => return Attr_None; when Field_Base_Name => @@ -2794,9 +2799,10 @@ package body Nodes_Meta is Field_Has_Active_Flag, Field_Visible_Flag, Field_Use_Flag, + Field_Guarded_Signal_Flag, + Field_Signal_Kind, Field_Expr_Staticness, Field_Name_Staticness, - Field_Signal_Kind, Field_Guard_Expression, Field_Guard_Sensitivity_List, Field_Block_Statement, @@ -2811,11 +2817,11 @@ package body Nodes_Meta is Field_After_Drivers_Flag, Field_Use_Flag, Field_Is_Ref, + Field_Guarded_Signal_Flag, + Field_Signal_Kind, Field_Expr_Staticness, Field_Name_Staticness, - Field_Signal_Kind, Field_Chain, - Field_Signal_Driver, Field_Default_Value, Field_Subtype_Indication, Field_Parent, @@ -2868,6 +2874,7 @@ package body Nodes_Meta is Field_After_Drivers_Flag, Field_Use_Flag, Field_Is_Ref, + Field_Guarded_Signal_Flag, Field_Mode, Field_Lexical_Layout, Field_Expr_Staticness, @@ -2883,6 +2890,7 @@ package body Nodes_Meta is Field_After_Drivers_Flag, Field_Use_Flag, Field_Is_Ref, + Field_Guarded_Signal_Flag, Field_Mode, Field_Lexical_Layout, Field_Expr_Staticness, @@ -2901,11 +2909,12 @@ package body Nodes_Meta is Field_After_Drivers_Flag, Field_Use_Flag, Field_Is_Ref, + Field_Guarded_Signal_Flag, + Field_Signal_Kind, Field_Mode, Field_Lexical_Layout, Field_Expr_Staticness, Field_Name_Staticness, - Field_Signal_Kind, Field_Chain, Field_Default_Value, Field_Subtype_Indication, @@ -2917,6 +2926,7 @@ package body Nodes_Meta is Field_After_Drivers_Flag, Field_Use_Flag, Field_Is_Ref, + Field_Guarded_Signal_Flag, Field_Mode, Field_Lexical_Layout, Field_Expr_Staticness, @@ -3926,145 +3936,145 @@ package body Nodes_Meta is Iir_Kind_Procedure_Body => 704, Iir_Kind_Object_Alias_Declaration => 716, Iir_Kind_File_Declaration => 731, - Iir_Kind_Guard_Signal_Declaration => 743, - Iir_Kind_Signal_Declaration => 760, - Iir_Kind_Variable_Declaration => 773, - Iir_Kind_Constant_Declaration => 787, - Iir_Kind_Iterator_Declaration => 799, - Iir_Kind_Interface_Constant_Declaration => 813, - Iir_Kind_Interface_Variable_Declaration => 827, - Iir_Kind_Interface_Signal_Declaration => 845, - Iir_Kind_Interface_File_Declaration => 859, - Iir_Kind_Interface_Package_Declaration => 868, - Iir_Kind_Identity_Operator => 872, - Iir_Kind_Negation_Operator => 876, - Iir_Kind_Absolute_Operator => 880, - Iir_Kind_Not_Operator => 884, - Iir_Kind_Condition_Operator => 888, - Iir_Kind_Reduction_And_Operator => 892, - Iir_Kind_Reduction_Or_Operator => 896, - Iir_Kind_Reduction_Nand_Operator => 900, - Iir_Kind_Reduction_Nor_Operator => 904, - Iir_Kind_Reduction_Xor_Operator => 908, - Iir_Kind_Reduction_Xnor_Operator => 912, - Iir_Kind_And_Operator => 917, - Iir_Kind_Or_Operator => 922, - Iir_Kind_Nand_Operator => 927, - Iir_Kind_Nor_Operator => 932, - Iir_Kind_Xor_Operator => 937, - Iir_Kind_Xnor_Operator => 942, - Iir_Kind_Equality_Operator => 947, - Iir_Kind_Inequality_Operator => 952, - Iir_Kind_Less_Than_Operator => 957, - Iir_Kind_Less_Than_Or_Equal_Operator => 962, - Iir_Kind_Greater_Than_Operator => 967, - Iir_Kind_Greater_Than_Or_Equal_Operator => 972, - Iir_Kind_Match_Equality_Operator => 977, - Iir_Kind_Match_Inequality_Operator => 982, - Iir_Kind_Match_Less_Than_Operator => 987, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 992, - Iir_Kind_Match_Greater_Than_Operator => 997, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1002, - Iir_Kind_Sll_Operator => 1007, - Iir_Kind_Sla_Operator => 1012, - Iir_Kind_Srl_Operator => 1017, - Iir_Kind_Sra_Operator => 1022, - Iir_Kind_Rol_Operator => 1027, - Iir_Kind_Ror_Operator => 1032, - Iir_Kind_Addition_Operator => 1037, - Iir_Kind_Substraction_Operator => 1042, - Iir_Kind_Concatenation_Operator => 1047, - Iir_Kind_Multiplication_Operator => 1052, - Iir_Kind_Division_Operator => 1057, - Iir_Kind_Modulus_Operator => 1062, - Iir_Kind_Remainder_Operator => 1067, - Iir_Kind_Exponentiation_Operator => 1072, - Iir_Kind_Function_Call => 1080, - Iir_Kind_Aggregate => 1086, - Iir_Kind_Parenthesis_Expression => 1089, - Iir_Kind_Qualified_Expression => 1093, - Iir_Kind_Type_Conversion => 1098, - Iir_Kind_Allocator_By_Expression => 1102, - Iir_Kind_Allocator_By_Subtype => 1106, - Iir_Kind_Selected_Element => 1112, - Iir_Kind_Dereference => 1117, - Iir_Kind_Implicit_Dereference => 1122, - Iir_Kind_Slice_Name => 1129, - Iir_Kind_Indexed_Name => 1135, - Iir_Kind_Psl_Expression => 1137, - Iir_Kind_Sensitized_Process_Statement => 1156, - Iir_Kind_Process_Statement => 1174, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1185, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1197, - Iir_Kind_Concurrent_Assertion_Statement => 1205, - Iir_Kind_Psl_Default_Clock => 1209, - Iir_Kind_Psl_Assert_Statement => 1218, - Iir_Kind_Psl_Cover_Statement => 1227, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1233, - Iir_Kind_Block_Statement => 1246, - Iir_Kind_Generate_Statement => 1258, - Iir_Kind_Component_Instantiation_Statement => 1268, - Iir_Kind_Simple_Simultaneous_Statement => 1275, - Iir_Kind_Signal_Assignment_Statement => 1284, - Iir_Kind_Null_Statement => 1288, - Iir_Kind_Assertion_Statement => 1295, - Iir_Kind_Report_Statement => 1301, - Iir_Kind_Wait_Statement => 1308, - Iir_Kind_Variable_Assignment_Statement => 1314, - Iir_Kind_Return_Statement => 1320, - Iir_Kind_For_Loop_Statement => 1328, - Iir_Kind_While_Loop_Statement => 1335, - Iir_Kind_Next_Statement => 1341, - Iir_Kind_Exit_Statement => 1347, - Iir_Kind_Case_Statement => 1354, - Iir_Kind_Procedure_Call_Statement => 1359, - Iir_Kind_If_Statement => 1367, - Iir_Kind_Elsif => 1372, - Iir_Kind_Character_Literal => 1379, - Iir_Kind_Simple_Name => 1386, - Iir_Kind_Selected_Name => 1394, - Iir_Kind_Operator_Symbol => 1399, - Iir_Kind_Selected_By_All_Name => 1404, - Iir_Kind_Parenthesis_Name => 1408, - Iir_Kind_Base_Attribute => 1410, - Iir_Kind_Left_Type_Attribute => 1415, - Iir_Kind_Right_Type_Attribute => 1420, - Iir_Kind_High_Type_Attribute => 1425, - Iir_Kind_Low_Type_Attribute => 1430, - Iir_Kind_Ascending_Type_Attribute => 1435, - Iir_Kind_Image_Attribute => 1441, - Iir_Kind_Value_Attribute => 1447, - Iir_Kind_Pos_Attribute => 1453, - Iir_Kind_Val_Attribute => 1459, - Iir_Kind_Succ_Attribute => 1465, - Iir_Kind_Pred_Attribute => 1471, - Iir_Kind_Leftof_Attribute => 1477, - Iir_Kind_Rightof_Attribute => 1483, - Iir_Kind_Delayed_Attribute => 1491, - Iir_Kind_Stable_Attribute => 1499, - Iir_Kind_Quiet_Attribute => 1507, - Iir_Kind_Transaction_Attribute => 1515, - Iir_Kind_Event_Attribute => 1519, - Iir_Kind_Active_Attribute => 1523, - Iir_Kind_Last_Event_Attribute => 1527, - Iir_Kind_Last_Active_Attribute => 1531, - Iir_Kind_Last_Value_Attribute => 1535, - Iir_Kind_Driving_Attribute => 1539, - Iir_Kind_Driving_Value_Attribute => 1543, - Iir_Kind_Behavior_Attribute => 1543, - Iir_Kind_Structure_Attribute => 1543, - Iir_Kind_Simple_Name_Attribute => 1550, - Iir_Kind_Instance_Name_Attribute => 1555, - Iir_Kind_Path_Name_Attribute => 1560, - Iir_Kind_Left_Array_Attribute => 1567, - Iir_Kind_Right_Array_Attribute => 1574, - Iir_Kind_High_Array_Attribute => 1581, - Iir_Kind_Low_Array_Attribute => 1588, - Iir_Kind_Length_Array_Attribute => 1595, - Iir_Kind_Ascending_Array_Attribute => 1602, - Iir_Kind_Range_Array_Attribute => 1609, - Iir_Kind_Reverse_Range_Array_Attribute => 1616, - Iir_Kind_Attribute_Name => 1624 + Iir_Kind_Guard_Signal_Declaration => 744, + Iir_Kind_Signal_Declaration => 761, + Iir_Kind_Variable_Declaration => 774, + Iir_Kind_Constant_Declaration => 788, + Iir_Kind_Iterator_Declaration => 800, + Iir_Kind_Interface_Constant_Declaration => 815, + Iir_Kind_Interface_Variable_Declaration => 830, + Iir_Kind_Interface_Signal_Declaration => 849, + Iir_Kind_Interface_File_Declaration => 864, + Iir_Kind_Interface_Package_Declaration => 873, + Iir_Kind_Identity_Operator => 877, + Iir_Kind_Negation_Operator => 881, + Iir_Kind_Absolute_Operator => 885, + Iir_Kind_Not_Operator => 889, + Iir_Kind_Condition_Operator => 893, + Iir_Kind_Reduction_And_Operator => 897, + Iir_Kind_Reduction_Or_Operator => 901, + Iir_Kind_Reduction_Nand_Operator => 905, + Iir_Kind_Reduction_Nor_Operator => 909, + Iir_Kind_Reduction_Xor_Operator => 913, + Iir_Kind_Reduction_Xnor_Operator => 917, + Iir_Kind_And_Operator => 922, + Iir_Kind_Or_Operator => 927, + Iir_Kind_Nand_Operator => 932, + Iir_Kind_Nor_Operator => 937, + Iir_Kind_Xor_Operator => 942, + Iir_Kind_Xnor_Operator => 947, + Iir_Kind_Equality_Operator => 952, + Iir_Kind_Inequality_Operator => 957, + Iir_Kind_Less_Than_Operator => 962, + Iir_Kind_Less_Than_Or_Equal_Operator => 967, + Iir_Kind_Greater_Than_Operator => 972, + Iir_Kind_Greater_Than_Or_Equal_Operator => 977, + Iir_Kind_Match_Equality_Operator => 982, + Iir_Kind_Match_Inequality_Operator => 987, + Iir_Kind_Match_Less_Than_Operator => 992, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 997, + Iir_Kind_Match_Greater_Than_Operator => 1002, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1007, + Iir_Kind_Sll_Operator => 1012, + Iir_Kind_Sla_Operator => 1017, + Iir_Kind_Srl_Operator => 1022, + Iir_Kind_Sra_Operator => 1027, + Iir_Kind_Rol_Operator => 1032, + Iir_Kind_Ror_Operator => 1037, + Iir_Kind_Addition_Operator => 1042, + Iir_Kind_Substraction_Operator => 1047, + Iir_Kind_Concatenation_Operator => 1052, + Iir_Kind_Multiplication_Operator => 1057, + Iir_Kind_Division_Operator => 1062, + Iir_Kind_Modulus_Operator => 1067, + Iir_Kind_Remainder_Operator => 1072, + Iir_Kind_Exponentiation_Operator => 1077, + Iir_Kind_Function_Call => 1085, + Iir_Kind_Aggregate => 1091, + Iir_Kind_Parenthesis_Expression => 1094, + Iir_Kind_Qualified_Expression => 1098, + Iir_Kind_Type_Conversion => 1103, + Iir_Kind_Allocator_By_Expression => 1107, + Iir_Kind_Allocator_By_Subtype => 1111, + Iir_Kind_Selected_Element => 1117, + Iir_Kind_Dereference => 1122, + Iir_Kind_Implicit_Dereference => 1127, + Iir_Kind_Slice_Name => 1134, + Iir_Kind_Indexed_Name => 1140, + Iir_Kind_Psl_Expression => 1142, + Iir_Kind_Sensitized_Process_Statement => 1161, + Iir_Kind_Process_Statement => 1179, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1190, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1202, + Iir_Kind_Concurrent_Assertion_Statement => 1210, + Iir_Kind_Psl_Default_Clock => 1214, + Iir_Kind_Psl_Assert_Statement => 1223, + Iir_Kind_Psl_Cover_Statement => 1232, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1238, + Iir_Kind_Block_Statement => 1251, + Iir_Kind_Generate_Statement => 1263, + Iir_Kind_Component_Instantiation_Statement => 1273, + Iir_Kind_Simple_Simultaneous_Statement => 1280, + Iir_Kind_Signal_Assignment_Statement => 1289, + Iir_Kind_Null_Statement => 1293, + Iir_Kind_Assertion_Statement => 1300, + Iir_Kind_Report_Statement => 1306, + Iir_Kind_Wait_Statement => 1313, + Iir_Kind_Variable_Assignment_Statement => 1319, + Iir_Kind_Return_Statement => 1325, + Iir_Kind_For_Loop_Statement => 1333, + Iir_Kind_While_Loop_Statement => 1340, + Iir_Kind_Next_Statement => 1346, + Iir_Kind_Exit_Statement => 1352, + Iir_Kind_Case_Statement => 1359, + Iir_Kind_Procedure_Call_Statement => 1364, + Iir_Kind_If_Statement => 1372, + Iir_Kind_Elsif => 1377, + Iir_Kind_Character_Literal => 1384, + Iir_Kind_Simple_Name => 1391, + Iir_Kind_Selected_Name => 1399, + Iir_Kind_Operator_Symbol => 1404, + Iir_Kind_Selected_By_All_Name => 1409, + Iir_Kind_Parenthesis_Name => 1413, + Iir_Kind_Base_Attribute => 1415, + Iir_Kind_Left_Type_Attribute => 1420, + Iir_Kind_Right_Type_Attribute => 1425, + Iir_Kind_High_Type_Attribute => 1430, + Iir_Kind_Low_Type_Attribute => 1435, + Iir_Kind_Ascending_Type_Attribute => 1440, + Iir_Kind_Image_Attribute => 1446, + Iir_Kind_Value_Attribute => 1452, + Iir_Kind_Pos_Attribute => 1458, + Iir_Kind_Val_Attribute => 1464, + Iir_Kind_Succ_Attribute => 1470, + Iir_Kind_Pred_Attribute => 1476, + Iir_Kind_Leftof_Attribute => 1482, + Iir_Kind_Rightof_Attribute => 1488, + Iir_Kind_Delayed_Attribute => 1496, + Iir_Kind_Stable_Attribute => 1504, + Iir_Kind_Quiet_Attribute => 1512, + Iir_Kind_Transaction_Attribute => 1520, + Iir_Kind_Event_Attribute => 1524, + Iir_Kind_Active_Attribute => 1528, + Iir_Kind_Last_Event_Attribute => 1532, + Iir_Kind_Last_Active_Attribute => 1536, + Iir_Kind_Last_Value_Attribute => 1540, + Iir_Kind_Driving_Attribute => 1544, + Iir_Kind_Driving_Value_Attribute => 1548, + Iir_Kind_Behavior_Attribute => 1548, + Iir_Kind_Structure_Attribute => 1548, + Iir_Kind_Simple_Name_Attribute => 1555, + Iir_Kind_Instance_Name_Attribute => 1560, + Iir_Kind_Path_Name_Attribute => 1565, + Iir_Kind_Left_Array_Attribute => 1572, + Iir_Kind_Right_Array_Attribute => 1579, + Iir_Kind_High_Array_Attribute => 1586, + Iir_Kind_Low_Array_Attribute => 1593, + Iir_Kind_Length_Array_Attribute => 1600, + Iir_Kind_Ascending_Array_Attribute => 1607, + Iir_Kind_Range_Array_Attribute => 1614, + Iir_Kind_Reverse_Range_Array_Attribute => 1621, + Iir_Kind_Attribute_Name => 1629 ); function Get_Fields (K : Iir_Kind) return Fields_Array @@ -4124,6 +4134,8 @@ package body Nodes_Meta is return Get_Same_Alternative_Flag (N); when Field_Need_Body => return Get_Need_Body (N); + when Field_Guarded_Signal_Flag => + return Get_Guarded_Signal_Flag (N); when Field_Deferred_Declaration_Flag => return Get_Deferred_Declaration_Flag (N); when Field_Shared_Flag => @@ -4216,6 +4228,8 @@ package body Nodes_Meta is Set_Same_Alternative_Flag (N, V); when Field_Need_Body => Set_Need_Body (N, V); + when Field_Guarded_Signal_Flag => + Set_Guarded_Signal_Flag (N, V); when Field_Deferred_Declaration_Flag => Set_Deferred_Declaration_Flag (N, V); when Field_Shared_Flag => @@ -6696,6 +6710,21 @@ package body Nodes_Meta is end case; end Has_Mode; + function Has_Guarded_Signal_Flag (K : Iir_Kind) return Boolean is + begin + case K is + when Iir_Kind_Guard_Signal_Declaration + | Iir_Kind_Signal_Declaration + | Iir_Kind_Interface_Constant_Declaration + | Iir_Kind_Interface_Variable_Declaration + | Iir_Kind_Interface_Signal_Declaration + | Iir_Kind_Interface_File_Declaration => + return True; + when others => + return False; + end case; + end Has_Guarded_Signal_Flag; + function Has_Signal_Kind (K : Iir_Kind) return Boolean is begin case K is @@ -6948,8 +6977,9 @@ package body Nodes_Meta is end Has_Block_Statement; function Has_Signal_Driver (K : Iir_Kind) return Boolean is + pragma Unreferenced (K); begin - return K = Iir_Kind_Signal_Declaration; + return False; end Has_Signal_Driver; function Has_Declaration_Chain (K : Iir_Kind) return Boolean is diff --git a/src/vhdl/nodes_meta.ads b/src/vhdl/nodes_meta.ads index 2d1f5e1c0..4e312e7d1 100644 --- a/src/vhdl/nodes_meta.ads +++ b/src/vhdl/nodes_meta.ads @@ -142,6 +142,7 @@ package Nodes_Meta is Field_Subtype_Definition, Field_Nature, Field_Mode, + Field_Guarded_Signal_Flag, Field_Signal_Kind, Field_Base_Name, Field_Interface_Declaration_Chain, @@ -610,6 +611,7 @@ package Nodes_Meta is function Has_Subtype_Definition (K : Iir_Kind) return Boolean; function Has_Nature (K : Iir_Kind) return Boolean; function Has_Mode (K : Iir_Kind) return Boolean; + function Has_Guarded_Signal_Flag (K : Iir_Kind) return Boolean; function Has_Signal_Kind (K : Iir_Kind) return Boolean; function Has_Base_Name (K : Iir_Kind) return Boolean; function Has_Interface_Declaration_Chain (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb index 98895f4a6..1b4b41021 100644 --- a/src/vhdl/parse.adb +++ b/src/vhdl/parse.adb @@ -247,20 +247,29 @@ package body Parse is -- precond : next token -- postcond: next token -- - -- [ §4.3.1.2 ] + -- [ LRM 4.3.1.2 ] -- signal_kind ::= REGISTER | BUS -- -- If there is no signal_kind, then no_signal_kind is returned. - function Parse_Signal_Kind return Iir_Signal_Kind is + procedure Parse_Signal_Kind + (Is_Guarded : out Boolean; Signal_Kind : out Iir_Signal_Kind) is begin if Current_Token = Tok_Bus then + -- Eat 'bus' Scan; - return Iir_Bus_Kind; + + Is_Guarded := True; + Signal_Kind := Iir_Bus_Kind; elsif Current_Token = Tok_Register then + -- Eat 'register' Scan; - return Iir_Register_Kind; + + Is_Guarded := True; + Signal_Kind := Iir_Register_Kind; else - return Iir_No_Signal_Kind; + Is_Guarded := False; + -- Avoid uninitialized variable. + Signal_Kind := Iir_Bus_Kind; end if; end Parse_Signal_Kind; @@ -974,6 +983,7 @@ package body Parse is Is_Default : Boolean; Interface_Mode: Iir_Mode; Interface_Type: Iir; + Is_Guarded : Boolean; Signal_Kind: Iir_Signal_Kind; Default_Value: Iir; Lexical_Layout : Iir_Lexical_Layout_Type; @@ -1153,9 +1163,10 @@ package body Parse is -- Signal kind (but only for signal). if Get_Kind (Inter) = Iir_Kind_Interface_Signal_Declaration then - Signal_Kind := Parse_Signal_Kind; + Parse_Signal_Kind (Is_Guarded, Signal_Kind); else - Signal_Kind := Iir_No_Signal_Kind; + Is_Guarded := False; + Signal_Kind := Iir_Register_Kind; end if; if Current_Token = Tok_Assign then @@ -1190,6 +1201,7 @@ package body Parse is Set_Lexical_Layout (Inter, Lexical_Layout); end if; if Get_Kind (Inter) = Iir_Kind_Interface_Signal_Declaration then + Set_Guarded_Signal_Flag (Inter, Is_Guarded); Set_Signal_Kind (Inter, Signal_Kind); end if; Inter := Get_Chain (Inter); @@ -2864,6 +2876,7 @@ package body Parse is Default_Value : Iir; Mode: Iir_Mode; Signal_Kind : Iir_Signal_Kind; + Is_Guarded : Boolean; Open_Kind : Iir; Logical_Name : Iir; Kind: Iir_Kind; @@ -2927,7 +2940,7 @@ package body Parse is Object_Type := Parse_Subtype_Indication; if Kind = Iir_Kind_Signal_Declaration then - Signal_Kind := Parse_Signal_Kind; + Parse_Signal_Kind (Is_Guarded, Signal_Kind); end if; if Current_Token = Tok_Assign then @@ -2999,6 +3012,7 @@ package body Parse is Set_File_Logical_Name (Object, Logical_Name); Set_Has_Mode (Object, Has_Mode); when Iir_Kind_Signal_Declaration => + Set_Guarded_Signal_Flag (Object, Is_Guarded); Set_Signal_Kind (Object, Signal_Kind); when others => null; diff --git a/src/vhdl/sem_decls.adb b/src/vhdl/sem_decls.adb index 3230bf0f8..d5036c18a 100644 --- a/src/vhdl/sem_decls.adb +++ b/src/vhdl/sem_decls.adb @@ -104,35 +104,35 @@ package body Sem_Decls is Set_Type (Inter, A_Type); if Get_Kind (Inter) = Iir_Kind_Interface_Signal_Declaration then - case Get_Signal_Kind (Inter) is - when Iir_No_Signal_Kind => - null; - when Iir_Bus_Kind => - -- FIXME: where this test came from ? - -- FIXME: from 4.3.1.2 ? - if False - and - (Get_Kind (A_Type) not in Iir_Kinds_Subtype_Definition - or else Get_Resolution_Indication (A_Type) = Null_Iir) - then - Error_Msg_Sem - (Disp_Node (A_Type) & " of guarded " & Disp_Node (Inter) - & " is not resolved", Inter); - end if; + if Get_Guarded_Signal_Flag (Inter) then + case Get_Signal_Kind (Inter) is + when Iir_Bus_Kind => + -- LRM93 4.3.1.2 + -- It is also an error if a guarded signal of a scalar + -- type is neither a resolved signal nor a subelement of + -- a resolved signal. + if not Get_Resolved_Flag (A_Type) then + Error_Msg_Sem + (Disp_Node (A_Type) & " of guarded " + & Disp_Node (Inter) & " is not resolved", Inter); + end if; - -- LRM 2.1.1.2 Signal parameter - -- It is an error if the declaration of a formal signal - -- parameter includes the reserved word BUS. - if Flags.Vhdl_Std >= Vhdl_93 - and then Interface_Kind in Parameter_Interface_List - then + -- LRM 2.1.1.2 Signal parameter + -- It is an error if the declaration of a formal signal + -- parameter includes the reserved word BUS. + if Flags.Vhdl_Std >= Vhdl_93 + and then Interface_Kind in Parameter_Interface_List + then + Error_Msg_Sem + ("signal parameter can't be of kind bus", Inter); + end if; + when Iir_Register_Kind => + -- LRM93 4.3.2 Interface declarations + -- Grammar for interface_signal_declaration. Error_Msg_Sem - ("signal parameter can't be of kind bus", Inter); - end if; - when Iir_Register_Kind => - Error_Msg_Sem - ("interface signal can't be of kind register", Inter); - end case; + ("interface signal can't be of kind register", Inter); + end case; + end if; Set_Type_Has_Signal (A_Type); end if; @@ -1683,10 +1683,10 @@ package body Sem_Decls is when Iir_Kind_Signal_Declaration => -- LRM93 4.3.1.2 - -- It is also an error if a guarded signal of a - -- scalar type is neither a resolved signal nor a - -- subelement of a resolved signal. - if Get_Signal_Kind (Decl) /= Iir_No_Signal_Kind + -- It is also an error if a guarded signal of a scalar type is + -- neither a resolved signal nor a subelement of a resolved + -- signal. + if Get_Guarded_Signal_Flag (Decl) and then not Get_Resolved_Flag (Atype) then Error_Msg_Sem diff --git a/src/vhdl/sem_specs.adb b/src/vhdl/sem_specs.adb index 7a6c180c8..1746903c1 100644 --- a/src/vhdl/sem_specs.adb +++ b/src/vhdl/sem_specs.adb @@ -991,7 +991,7 @@ package body Sem_Specs is if Get_Name_Staticness (Sig) /= Locally then Error_Msg_Sem ("signal name must be locally static", El); end if; - if Get_Signal_Kind (Prefix) = Iir_No_Signal_Kind then + if not Get_Guarded_Signal_Flag (Prefix) then Error_Msg_Sem ("signal must be a guarded signal", El); end if; Set_Has_Disconnect_Flag (Prefix, True); diff --git a/src/vhdl/sem_stmts.adb b/src/vhdl/sem_stmts.adb index d14276892..7712bb99f 100644 --- a/src/vhdl/sem_stmts.adb +++ b/src/vhdl/sem_stmts.adb @@ -379,7 +379,7 @@ package body Sem_Stmts is then Guarded_Target := Unknown; else - if Get_Signal_Kind (Target_Prefix) /= Iir_No_Signal_Kind then + if Get_Guarded_Signal_Flag (Target_Prefix) then Guarded_Target := True; else Guarded_Target := False; diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb index 0b804370a..9bdc7a96d 100644 --- a/src/vhdl/translate/trans-rtis.adb +++ b/src/vhdl/translate/trans-rtis.adb @@ -1832,9 +1832,15 @@ package body Trans.Rtis is end case; case Get_Kind (Decl) is when Iir_Kind_Signal_Declaration - | Iir_Kind_Interface_Signal_Declaration => - Mode := Mode - + 16 * Iir_Signal_Kind'Pos (Get_Signal_Kind (Decl)); + | Iir_Kind_Interface_Signal_Declaration => + if Get_Guarded_Signal_Flag (Decl) then + case Get_Signal_Kind (Decl) is + when Iir_Register_Kind => + Mode := Mode + 16; + when Iir_Bus_Kind => + Mode := Mode + 32; + end case; + end if; when others => null; end case; diff --git a/src/xtools/pnodes.py b/src/xtools/pnodes.py index e00cf4d89..f62180208 100755 --- a/src/xtools/pnodes.py +++ b/src/xtools/pnodes.py @@ -696,9 +696,13 @@ elif args.action == 'meta_body': print for f in funcs: gen_has_func_spec(f.name, ' is') - print ' begin' choices = [k for k in kinds if f.name in nodes[k].attrs] - if len(choices) == 1: + if len(choices) == 0: + print ' pragma Unreferenced (K);' + print ' begin' + if len(choices) == 0: + print ' return False;' + elif len(choices) == 1: print ' return K = ' + prefix_name + choices[0] + ';' else: print ' case K is' |