diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-12-09 17:26:08 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-12-09 17:26:08 +0100 |
commit | f7ee7d70756e4dd2ebcaeb6a0d8292a73678956c (patch) | |
tree | 6ea006fcf43fc2c3c106106d07df91c4d5ee358f | |
parent | a7e43bb203602e382d07a72cfd16dcae386d99a7 (diff) | |
download | ghdl-f7ee7d70756e4dd2ebcaeb6a0d8292a73678956c.tar.gz ghdl-f7ee7d70756e4dd2ebcaeb6a0d8292a73678956c.tar.bz2 ghdl-f7ee7d70756e4dd2ebcaeb6a0d8292a73678956c.zip |
record ownership of record element constraints.
-rw-r--r-- | src/vhdl/iirs.adb | 16 | ||||
-rw-r--r-- | src/vhdl/iirs.ads | 26 | ||||
-rw-r--r-- | src/vhdl/iirs_utils.adb | 8 | ||||
-rw-r--r-- | src/vhdl/iirs_utils.ads | 4 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.adb | 477 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/sem_assocs.adb | 5 | ||||
-rw-r--r-- | src/vhdl/sem_expr.adb | 12 | ||||
-rw-r--r-- | src/vhdl/sem_types.adb | 36 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 8 |
10 files changed, 327 insertions, 267 deletions
diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb index 6169df39a..a181fcae3 100644 --- a/src/vhdl/iirs.adb +++ b/src/vhdl/iirs.adb @@ -3182,6 +3182,22 @@ package body Iirs is Set_Field1 (Decl, Iir_Flist_To_Iir (List)); end Set_Elements_Declaration_List; + function Get_Owned_Elements_Chain (Atype : Iir) return Iir is + begin + pragma Assert (Atype /= Null_Iir); + pragma Assert (Has_Owned_Elements_Chain (Get_Kind (Atype)), + "no field Owned_Elements_Chain"); + return Get_Field6 (Atype); + end Get_Owned_Elements_Chain; + + procedure Set_Owned_Elements_Chain (Atype : Iir; Chain : Iir) is + begin + pragma Assert (Atype /= Null_Iir); + pragma Assert (Has_Owned_Elements_Chain (Get_Kind (Atype)), + "no field Owned_Elements_Chain"); + Set_Field6 (Atype, Chain); + end Set_Owned_Elements_Chain; + function Get_Designated_Type (Target : Iir) return Iir is begin pragma Assert (Target /= Null_Iir); diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index 471af7952..e46673308 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -1797,6 +1797,9 @@ package Iirs is -- -- Get/Set_Type (Field1) -- + -- For Owned_Elements_Chain, so that the node has an owner. + -- Get/Set_Chain (Field2) + -- -- Get/Set_Identifier (Field3) -- -- Return the position of the element in the record, starting from 0 for @@ -2267,6 +2270,9 @@ package Iirs is -- Get/Set_End_Has_Reserved_Id (Flag8) -- -- Get/Set_End_Has_Identifier (Flag9) + -- + -- Always false for record type: elements are owned by this node. + -- Get/Set_Is_Ref (Flag12) -- Iir_Kind_Access_Type_Definition (Short) -- @@ -2585,6 +2591,10 @@ package Iirs is -- Iir_Kind_Record_Subtype_Definition (Medium) -- + -- Chain of new elements constraint. Needed only for internal consistency + -- of the tree (ownership). + -- Get/Set_Owned_Elements_Chain (Field6) + -- -- Get/Set_Elements_Declaration_List (Field1) -- -- Get/Set_Subtype_Type_Mark (Field2) @@ -2606,6 +2616,10 @@ package Iirs is -- Get/Set_Type_Staticness (State1) -- -- Get/Set_Constraint_State (State2) + -- + -- Always false for record type: elements are owned through + -- Owned_Elements_Chain + -- Get/Set_Is_Ref (Flag12) -- Iir_Kind_Array_Subtype_Definition (Medium) -- @@ -6659,11 +6673,19 @@ package Iirs is function Get_Array_Element_Constraint (Def : Iir) return Iir; procedure Set_Array_Element_Constraint (Def : Iir; El : Iir); - -- Chains of elements of a record. - -- Field: Field1 (uc) + -- List of elements of a record. + -- For a record_type_definition: Is_Ref is false, as the elements + -- declaration are owned by the type definition. + -- For a record_subtype_definition: Is_Ref is false, as new constrained + -- elements are owned through the Owned_Elements_Chain list. + -- Field: Field1 Of_Maybe_Ref (uc) function Get_Elements_Declaration_List (Decl : Iir) return Iir_Flist; procedure Set_Elements_Declaration_List (Decl : Iir; List : Iir_Flist); + -- Field: Field6 Chain + function Get_Owned_Elements_Chain (Atype : Iir) return Iir; + procedure Set_Owned_Elements_Chain (Atype : Iir; Chain : Iir); + -- Field: Field1 Forward_Ref function Get_Designated_Type (Target : Iir) return Iir; procedure Set_Designated_Type (Target : Iir; Dtype : Iir); diff --git a/src/vhdl/iirs_utils.adb b/src/vhdl/iirs_utils.adb index 110300487..6f655569f 100644 --- a/src/vhdl/iirs_utils.adb +++ b/src/vhdl/iirs_utils.adb @@ -1189,6 +1189,14 @@ package body Iirs_Utils is (Els_List, Natural (Get_Element_Position (El))); end Get_Base_Element_Declaration; + procedure Append_Owned_Element_Constraint (Rec_Type : Iir; El : Iir) is + begin + pragma Assert (Get_Parent (El) = Rec_Type); + Set_Chain (El, Get_Owned_Elements_Chain (Rec_Type)); + Set_Owned_Elements_Chain (Rec_Type, El); + end Append_Owned_Element_Constraint; + + function Is_Second_Subprogram_Specification (Spec : Iir) return Boolean is Bod : constant Iir := Get_Chain (Spec); diff --git a/src/vhdl/iirs_utils.ads b/src/vhdl/iirs_utils.ads index 170452925..cade6b332 100644 --- a/src/vhdl/iirs_utils.ads +++ b/src/vhdl/iirs_utils.ads @@ -248,6 +248,10 @@ package Iirs_Utils is -- element declaration in the base record type. function Get_Base_Element_Declaration (El : Iir) return Iir; + -- Append EL to the chain of owned elements of REC_TYPE. Used only when + -- a record_element_constraint is built. + procedure Append_Owned_Element_Constraint (Rec_Type : Iir; El : Iir); + -- Return true iff L and R have the same profile. -- L and R must be subprograms specification (or spec_body). function Is_Same_Profile (L, R: Iir) return Boolean; diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb index 78513d284..23be8afaf 100644 --- a/src/vhdl/nodes_meta.adb +++ b/src/vhdl/nodes_meta.adb @@ -179,6 +179,7 @@ package body Nodes_Meta is Field_Index_Constraint_List => Type_Iir_Flist, Field_Array_Element_Constraint => Type_Iir, Field_Elements_Declaration_List => Type_Iir_Flist, + Field_Owned_Elements_Chain => Type_Iir, Field_Designated_Type => Type_Iir, Field_Designated_Subtype_Indication => Type_Iir, Field_Index_List => Type_Iir_Flist, @@ -675,6 +676,8 @@ package body Nodes_Meta is return "array_element_constraint"; when Field_Elements_Declaration_List => return "elements_declaration_list"; + when Field_Owned_Elements_Chain => + return "owned_elements_chain"; when Field_Designated_Type => return "designated_type"; when Field_Designated_Subtype_Indication => @@ -1876,7 +1879,9 @@ package body Nodes_Meta is when Field_Array_Element_Constraint => return Attr_None; when Field_Elements_Declaration_List => - return Attr_None; + return Attr_Of_Maybe_Ref; + when Field_Owned_Elements_Chain => + return Attr_Chain; when Field_Designated_Type => return Attr_Forward_Ref; when Field_Designated_Subtype_Indication => @@ -2498,6 +2503,7 @@ package body Nodes_Meta is Field_Visible_Flag, Field_Parent, Field_Type, + Field_Chain, -- Iir_Kind_Array_Element_Resolution Field_Resolution_Indication, Field_Element_Subtype_Indication, @@ -2576,6 +2582,7 @@ package body Nodes_Meta is Field_Base_Type, -- Iir_Kind_Record_Type_Definition Field_Resolved_Flag, + Field_Is_Ref, Field_Signal_Type_Flag, Field_Has_Signal_Flag, Field_End_Has_Reserved_Id, @@ -2616,10 +2623,12 @@ package body Nodes_Meta is Field_Base_Type, -- Iir_Kind_Record_Subtype_Definition Field_Resolved_Flag, + Field_Is_Ref, Field_Signal_Type_Flag, Field_Has_Signal_Flag, Field_Type_Staticness, Field_Constraint_State, + Field_Owned_Elements_Chain, Field_Elements_Declaration_List, Field_Subtype_Type_Mark, Field_Type_Declarator, @@ -4458,233 +4467,233 @@ package body Nodes_Meta is Iir_Kind_Signature => 224, Iir_Kind_Aggregate_Info => 231, Iir_Kind_Procedure_Call => 235, - Iir_Kind_Record_Element_Constraint => 240, - Iir_Kind_Array_Element_Resolution => 242, - Iir_Kind_Record_Resolution => 243, - Iir_Kind_Record_Element_Resolution => 246, - Iir_Kind_Attribute_Specification => 254, - Iir_Kind_Disconnection_Specification => 260, - Iir_Kind_Configuration_Specification => 266, - Iir_Kind_Access_Type_Definition => 274, - Iir_Kind_Incomplete_Type_Definition => 282, - Iir_Kind_Interface_Type_Definition => 289, - Iir_Kind_File_Type_Definition => 296, - Iir_Kind_Protected_Type_Declaration => 305, - Iir_Kind_Record_Type_Definition => 315, - Iir_Kind_Array_Type_Definition => 327, - Iir_Kind_Array_Subtype_Definition => 342, - Iir_Kind_Record_Subtype_Definition => 353, - Iir_Kind_Access_Subtype_Definition => 361, - Iir_Kind_Physical_Subtype_Definition => 371, - Iir_Kind_Floating_Subtype_Definition => 382, - Iir_Kind_Integer_Subtype_Definition => 392, - Iir_Kind_Enumeration_Subtype_Definition => 402, - Iir_Kind_Enumeration_Type_Definition => 413, - Iir_Kind_Integer_Type_Definition => 421, - Iir_Kind_Floating_Type_Definition => 429, - Iir_Kind_Physical_Type_Definition => 440, - Iir_Kind_Range_Expression => 448, - Iir_Kind_Protected_Type_Body => 455, - Iir_Kind_Wildcard_Type_Definition => 460, - Iir_Kind_Subtype_Definition => 465, - Iir_Kind_Scalar_Nature_Definition => 469, - Iir_Kind_Overload_List => 470, - Iir_Kind_Type_Declaration => 477, - Iir_Kind_Anonymous_Type_Declaration => 483, - Iir_Kind_Subtype_Declaration => 490, - Iir_Kind_Nature_Declaration => 496, - Iir_Kind_Subnature_Declaration => 502, - Iir_Kind_Entity_Declaration => 514, - Iir_Kind_Configuration_Declaration => 523, - Iir_Kind_Context_Declaration => 529, - Iir_Kind_Package_Declaration => 544, - Iir_Kind_Package_Instantiation_Declaration => 558, - Iir_Kind_Package_Body => 566, - Iir_Kind_Architecture_Body => 578, - Iir_Kind_Package_Header => 580, - Iir_Kind_Unit_Declaration => 589, - Iir_Kind_Library_Declaration => 596, - Iir_Kind_Component_Declaration => 606, - Iir_Kind_Attribute_Declaration => 613, - Iir_Kind_Group_Template_Declaration => 619, - Iir_Kind_Group_Declaration => 626, - Iir_Kind_Element_Declaration => 633, - Iir_Kind_Non_Object_Alias_Declaration => 641, - Iir_Kind_Psl_Declaration => 649, - Iir_Kind_Psl_Endpoint_Declaration => 663, - Iir_Kind_Terminal_Declaration => 669, - Iir_Kind_Free_Quantity_Declaration => 678, - Iir_Kind_Across_Quantity_Declaration => 690, - Iir_Kind_Through_Quantity_Declaration => 702, - Iir_Kind_Enumeration_Literal => 713, - Iir_Kind_Function_Declaration => 738, - Iir_Kind_Procedure_Declaration => 762, - Iir_Kind_Function_Body => 772, - Iir_Kind_Procedure_Body => 783, - Iir_Kind_Object_Alias_Declaration => 794, - Iir_Kind_File_Declaration => 808, - Iir_Kind_Guard_Signal_Declaration => 821, - Iir_Kind_Signal_Declaration => 838, - Iir_Kind_Variable_Declaration => 851, - Iir_Kind_Constant_Declaration => 865, - Iir_Kind_Iterator_Declaration => 876, - Iir_Kind_Interface_Constant_Declaration => 892, - Iir_Kind_Interface_Variable_Declaration => 908, - Iir_Kind_Interface_Signal_Declaration => 929, - Iir_Kind_Interface_File_Declaration => 945, - Iir_Kind_Interface_Type_Declaration => 955, - Iir_Kind_Interface_Package_Declaration => 967, - Iir_Kind_Interface_Function_Declaration => 984, - Iir_Kind_Interface_Procedure_Declaration => 997, - Iir_Kind_Signal_Attribute_Declaration => 1000, - Iir_Kind_Identity_Operator => 1004, - Iir_Kind_Negation_Operator => 1008, - Iir_Kind_Absolute_Operator => 1012, - Iir_Kind_Not_Operator => 1016, - Iir_Kind_Implicit_Condition_Operator => 1020, - Iir_Kind_Condition_Operator => 1024, - Iir_Kind_Reduction_And_Operator => 1028, - Iir_Kind_Reduction_Or_Operator => 1032, - Iir_Kind_Reduction_Nand_Operator => 1036, - Iir_Kind_Reduction_Nor_Operator => 1040, - Iir_Kind_Reduction_Xor_Operator => 1044, - Iir_Kind_Reduction_Xnor_Operator => 1048, - Iir_Kind_And_Operator => 1053, - Iir_Kind_Or_Operator => 1058, - Iir_Kind_Nand_Operator => 1063, - Iir_Kind_Nor_Operator => 1068, - Iir_Kind_Xor_Operator => 1073, - Iir_Kind_Xnor_Operator => 1078, - Iir_Kind_Equality_Operator => 1083, - Iir_Kind_Inequality_Operator => 1088, - Iir_Kind_Less_Than_Operator => 1093, - Iir_Kind_Less_Than_Or_Equal_Operator => 1098, - Iir_Kind_Greater_Than_Operator => 1103, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1108, - Iir_Kind_Match_Equality_Operator => 1113, - Iir_Kind_Match_Inequality_Operator => 1118, - Iir_Kind_Match_Less_Than_Operator => 1123, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1128, - Iir_Kind_Match_Greater_Than_Operator => 1133, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1138, - Iir_Kind_Sll_Operator => 1143, - Iir_Kind_Sla_Operator => 1148, - Iir_Kind_Srl_Operator => 1153, - Iir_Kind_Sra_Operator => 1158, - Iir_Kind_Rol_Operator => 1163, - Iir_Kind_Ror_Operator => 1168, - Iir_Kind_Addition_Operator => 1173, - Iir_Kind_Substraction_Operator => 1178, - Iir_Kind_Concatenation_Operator => 1183, - Iir_Kind_Multiplication_Operator => 1188, - Iir_Kind_Division_Operator => 1193, - Iir_Kind_Modulus_Operator => 1198, - Iir_Kind_Remainder_Operator => 1203, - Iir_Kind_Exponentiation_Operator => 1208, - Iir_Kind_Function_Call => 1216, - Iir_Kind_Aggregate => 1223, - Iir_Kind_Parenthesis_Expression => 1226, - Iir_Kind_Qualified_Expression => 1230, - Iir_Kind_Type_Conversion => 1235, - Iir_Kind_Allocator_By_Expression => 1239, - Iir_Kind_Allocator_By_Subtype => 1244, - Iir_Kind_Selected_Element => 1251, - Iir_Kind_Dereference => 1256, - Iir_Kind_Implicit_Dereference => 1261, - Iir_Kind_Slice_Name => 1268, - Iir_Kind_Indexed_Name => 1274, - Iir_Kind_Psl_Expression => 1276, - Iir_Kind_Sensitized_Process_Statement => 1297, - Iir_Kind_Process_Statement => 1317, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1329, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1341, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1354, - Iir_Kind_Concurrent_Assertion_Statement => 1362, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1369, - Iir_Kind_Psl_Assert_Statement => 1382, - Iir_Kind_Psl_Cover_Statement => 1395, - Iir_Kind_Block_Statement => 1408, - Iir_Kind_If_Generate_Statement => 1419, - Iir_Kind_Case_Generate_Statement => 1428, - Iir_Kind_For_Generate_Statement => 1437, - Iir_Kind_Component_Instantiation_Statement => 1448, - Iir_Kind_Psl_Default_Clock => 1452, - Iir_Kind_Simple_Simultaneous_Statement => 1459, - Iir_Kind_Generate_Statement_Body => 1470, - Iir_Kind_If_Generate_Else_Clause => 1476, - Iir_Kind_Simple_Signal_Assignment_Statement => 1486, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1496, - Iir_Kind_Selected_Waveform_Assignment_Statement => 1507, - Iir_Kind_Null_Statement => 1511, - Iir_Kind_Assertion_Statement => 1518, - Iir_Kind_Report_Statement => 1524, - Iir_Kind_Wait_Statement => 1532, - Iir_Kind_Variable_Assignment_Statement => 1539, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1546, - Iir_Kind_Return_Statement => 1552, - Iir_Kind_For_Loop_Statement => 1561, - Iir_Kind_While_Loop_Statement => 1570, - Iir_Kind_Next_Statement => 1577, - Iir_Kind_Exit_Statement => 1584, - Iir_Kind_Case_Statement => 1592, - Iir_Kind_Procedure_Call_Statement => 1598, - Iir_Kind_If_Statement => 1608, - Iir_Kind_Elsif => 1614, - Iir_Kind_Character_Literal => 1622, - Iir_Kind_Simple_Name => 1630, - Iir_Kind_Selected_Name => 1639, - Iir_Kind_Operator_Symbol => 1645, - Iir_Kind_Reference_Name => 1648, - Iir_Kind_External_Constant_Name => 1657, - Iir_Kind_External_Signal_Name => 1666, - Iir_Kind_External_Variable_Name => 1675, - Iir_Kind_Selected_By_All_Name => 1681, - Iir_Kind_Parenthesis_Name => 1686, - Iir_Kind_Package_Pathname => 1690, - Iir_Kind_Absolute_Pathname => 1691, - Iir_Kind_Relative_Pathname => 1692, - Iir_Kind_Pathname_Element => 1697, - Iir_Kind_Base_Attribute => 1699, - Iir_Kind_Subtype_Attribute => 1704, - Iir_Kind_Element_Attribute => 1709, - Iir_Kind_Left_Type_Attribute => 1714, - Iir_Kind_Right_Type_Attribute => 1719, - Iir_Kind_High_Type_Attribute => 1724, - Iir_Kind_Low_Type_Attribute => 1729, - Iir_Kind_Ascending_Type_Attribute => 1734, - Iir_Kind_Image_Attribute => 1740, - Iir_Kind_Value_Attribute => 1746, - Iir_Kind_Pos_Attribute => 1752, - Iir_Kind_Val_Attribute => 1758, - Iir_Kind_Succ_Attribute => 1764, - Iir_Kind_Pred_Attribute => 1770, - Iir_Kind_Leftof_Attribute => 1776, - Iir_Kind_Rightof_Attribute => 1782, - Iir_Kind_Delayed_Attribute => 1791, - Iir_Kind_Stable_Attribute => 1800, - Iir_Kind_Quiet_Attribute => 1809, - Iir_Kind_Transaction_Attribute => 1818, - Iir_Kind_Event_Attribute => 1822, - Iir_Kind_Active_Attribute => 1826, - Iir_Kind_Last_Event_Attribute => 1830, - Iir_Kind_Last_Active_Attribute => 1834, - Iir_Kind_Last_Value_Attribute => 1838, - Iir_Kind_Driving_Attribute => 1842, - Iir_Kind_Driving_Value_Attribute => 1846, - Iir_Kind_Behavior_Attribute => 1846, - Iir_Kind_Structure_Attribute => 1846, - Iir_Kind_Simple_Name_Attribute => 1853, - Iir_Kind_Instance_Name_Attribute => 1858, - Iir_Kind_Path_Name_Attribute => 1863, - Iir_Kind_Left_Array_Attribute => 1870, - Iir_Kind_Right_Array_Attribute => 1877, - Iir_Kind_High_Array_Attribute => 1884, - Iir_Kind_Low_Array_Attribute => 1891, - Iir_Kind_Length_Array_Attribute => 1898, - Iir_Kind_Ascending_Array_Attribute => 1905, - Iir_Kind_Range_Array_Attribute => 1912, - Iir_Kind_Reverse_Range_Array_Attribute => 1919, - Iir_Kind_Attribute_Name => 1928 + Iir_Kind_Record_Element_Constraint => 241, + Iir_Kind_Array_Element_Resolution => 243, + Iir_Kind_Record_Resolution => 244, + Iir_Kind_Record_Element_Resolution => 247, + Iir_Kind_Attribute_Specification => 255, + Iir_Kind_Disconnection_Specification => 261, + Iir_Kind_Configuration_Specification => 267, + Iir_Kind_Access_Type_Definition => 275, + Iir_Kind_Incomplete_Type_Definition => 283, + Iir_Kind_Interface_Type_Definition => 290, + Iir_Kind_File_Type_Definition => 297, + Iir_Kind_Protected_Type_Declaration => 306, + Iir_Kind_Record_Type_Definition => 317, + Iir_Kind_Array_Type_Definition => 329, + Iir_Kind_Array_Subtype_Definition => 344, + Iir_Kind_Record_Subtype_Definition => 357, + Iir_Kind_Access_Subtype_Definition => 365, + Iir_Kind_Physical_Subtype_Definition => 375, + Iir_Kind_Floating_Subtype_Definition => 386, + Iir_Kind_Integer_Subtype_Definition => 396, + Iir_Kind_Enumeration_Subtype_Definition => 406, + Iir_Kind_Enumeration_Type_Definition => 417, + Iir_Kind_Integer_Type_Definition => 425, + Iir_Kind_Floating_Type_Definition => 433, + Iir_Kind_Physical_Type_Definition => 444, + Iir_Kind_Range_Expression => 452, + Iir_Kind_Protected_Type_Body => 459, + Iir_Kind_Wildcard_Type_Definition => 464, + Iir_Kind_Subtype_Definition => 469, + Iir_Kind_Scalar_Nature_Definition => 473, + Iir_Kind_Overload_List => 474, + Iir_Kind_Type_Declaration => 481, + Iir_Kind_Anonymous_Type_Declaration => 487, + Iir_Kind_Subtype_Declaration => 494, + Iir_Kind_Nature_Declaration => 500, + Iir_Kind_Subnature_Declaration => 506, + Iir_Kind_Entity_Declaration => 518, + Iir_Kind_Configuration_Declaration => 527, + Iir_Kind_Context_Declaration => 533, + Iir_Kind_Package_Declaration => 548, + Iir_Kind_Package_Instantiation_Declaration => 562, + Iir_Kind_Package_Body => 570, + Iir_Kind_Architecture_Body => 582, + Iir_Kind_Package_Header => 584, + Iir_Kind_Unit_Declaration => 593, + Iir_Kind_Library_Declaration => 600, + Iir_Kind_Component_Declaration => 610, + Iir_Kind_Attribute_Declaration => 617, + Iir_Kind_Group_Template_Declaration => 623, + Iir_Kind_Group_Declaration => 630, + Iir_Kind_Element_Declaration => 637, + Iir_Kind_Non_Object_Alias_Declaration => 645, + Iir_Kind_Psl_Declaration => 653, + Iir_Kind_Psl_Endpoint_Declaration => 667, + Iir_Kind_Terminal_Declaration => 673, + Iir_Kind_Free_Quantity_Declaration => 682, + Iir_Kind_Across_Quantity_Declaration => 694, + Iir_Kind_Through_Quantity_Declaration => 706, + Iir_Kind_Enumeration_Literal => 717, + Iir_Kind_Function_Declaration => 742, + Iir_Kind_Procedure_Declaration => 766, + Iir_Kind_Function_Body => 776, + Iir_Kind_Procedure_Body => 787, + Iir_Kind_Object_Alias_Declaration => 798, + Iir_Kind_File_Declaration => 812, + Iir_Kind_Guard_Signal_Declaration => 825, + Iir_Kind_Signal_Declaration => 842, + Iir_Kind_Variable_Declaration => 855, + Iir_Kind_Constant_Declaration => 869, + Iir_Kind_Iterator_Declaration => 880, + Iir_Kind_Interface_Constant_Declaration => 896, + Iir_Kind_Interface_Variable_Declaration => 912, + Iir_Kind_Interface_Signal_Declaration => 933, + Iir_Kind_Interface_File_Declaration => 949, + Iir_Kind_Interface_Type_Declaration => 959, + Iir_Kind_Interface_Package_Declaration => 971, + Iir_Kind_Interface_Function_Declaration => 988, + Iir_Kind_Interface_Procedure_Declaration => 1001, + Iir_Kind_Signal_Attribute_Declaration => 1004, + Iir_Kind_Identity_Operator => 1008, + Iir_Kind_Negation_Operator => 1012, + Iir_Kind_Absolute_Operator => 1016, + Iir_Kind_Not_Operator => 1020, + Iir_Kind_Implicit_Condition_Operator => 1024, + Iir_Kind_Condition_Operator => 1028, + Iir_Kind_Reduction_And_Operator => 1032, + Iir_Kind_Reduction_Or_Operator => 1036, + Iir_Kind_Reduction_Nand_Operator => 1040, + Iir_Kind_Reduction_Nor_Operator => 1044, + Iir_Kind_Reduction_Xor_Operator => 1048, + Iir_Kind_Reduction_Xnor_Operator => 1052, + Iir_Kind_And_Operator => 1057, + Iir_Kind_Or_Operator => 1062, + Iir_Kind_Nand_Operator => 1067, + Iir_Kind_Nor_Operator => 1072, + Iir_Kind_Xor_Operator => 1077, + Iir_Kind_Xnor_Operator => 1082, + Iir_Kind_Equality_Operator => 1087, + Iir_Kind_Inequality_Operator => 1092, + Iir_Kind_Less_Than_Operator => 1097, + Iir_Kind_Less_Than_Or_Equal_Operator => 1102, + Iir_Kind_Greater_Than_Operator => 1107, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1112, + Iir_Kind_Match_Equality_Operator => 1117, + Iir_Kind_Match_Inequality_Operator => 1122, + Iir_Kind_Match_Less_Than_Operator => 1127, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1132, + Iir_Kind_Match_Greater_Than_Operator => 1137, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1142, + Iir_Kind_Sll_Operator => 1147, + Iir_Kind_Sla_Operator => 1152, + Iir_Kind_Srl_Operator => 1157, + Iir_Kind_Sra_Operator => 1162, + Iir_Kind_Rol_Operator => 1167, + Iir_Kind_Ror_Operator => 1172, + Iir_Kind_Addition_Operator => 1177, + Iir_Kind_Substraction_Operator => 1182, + Iir_Kind_Concatenation_Operator => 1187, + Iir_Kind_Multiplication_Operator => 1192, + Iir_Kind_Division_Operator => 1197, + Iir_Kind_Modulus_Operator => 1202, + Iir_Kind_Remainder_Operator => 1207, + Iir_Kind_Exponentiation_Operator => 1212, + Iir_Kind_Function_Call => 1220, + Iir_Kind_Aggregate => 1227, + Iir_Kind_Parenthesis_Expression => 1230, + Iir_Kind_Qualified_Expression => 1234, + Iir_Kind_Type_Conversion => 1239, + Iir_Kind_Allocator_By_Expression => 1243, + Iir_Kind_Allocator_By_Subtype => 1248, + Iir_Kind_Selected_Element => 1255, + Iir_Kind_Dereference => 1260, + Iir_Kind_Implicit_Dereference => 1265, + Iir_Kind_Slice_Name => 1272, + Iir_Kind_Indexed_Name => 1278, + Iir_Kind_Psl_Expression => 1280, + Iir_Kind_Sensitized_Process_Statement => 1301, + Iir_Kind_Process_Statement => 1321, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1333, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1345, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1358, + Iir_Kind_Concurrent_Assertion_Statement => 1366, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1373, + Iir_Kind_Psl_Assert_Statement => 1386, + Iir_Kind_Psl_Cover_Statement => 1399, + Iir_Kind_Block_Statement => 1412, + Iir_Kind_If_Generate_Statement => 1423, + Iir_Kind_Case_Generate_Statement => 1432, + Iir_Kind_For_Generate_Statement => 1441, + Iir_Kind_Component_Instantiation_Statement => 1452, + Iir_Kind_Psl_Default_Clock => 1456, + Iir_Kind_Simple_Simultaneous_Statement => 1463, + Iir_Kind_Generate_Statement_Body => 1474, + Iir_Kind_If_Generate_Else_Clause => 1480, + Iir_Kind_Simple_Signal_Assignment_Statement => 1490, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1500, + Iir_Kind_Selected_Waveform_Assignment_Statement => 1511, + Iir_Kind_Null_Statement => 1515, + Iir_Kind_Assertion_Statement => 1522, + Iir_Kind_Report_Statement => 1528, + Iir_Kind_Wait_Statement => 1536, + Iir_Kind_Variable_Assignment_Statement => 1543, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1550, + Iir_Kind_Return_Statement => 1556, + Iir_Kind_For_Loop_Statement => 1565, + Iir_Kind_While_Loop_Statement => 1574, + Iir_Kind_Next_Statement => 1581, + Iir_Kind_Exit_Statement => 1588, + Iir_Kind_Case_Statement => 1596, + Iir_Kind_Procedure_Call_Statement => 1602, + Iir_Kind_If_Statement => 1612, + Iir_Kind_Elsif => 1618, + Iir_Kind_Character_Literal => 1626, + Iir_Kind_Simple_Name => 1634, + Iir_Kind_Selected_Name => 1643, + Iir_Kind_Operator_Symbol => 1649, + Iir_Kind_Reference_Name => 1652, + Iir_Kind_External_Constant_Name => 1661, + Iir_Kind_External_Signal_Name => 1670, + Iir_Kind_External_Variable_Name => 1679, + Iir_Kind_Selected_By_All_Name => 1685, + Iir_Kind_Parenthesis_Name => 1690, + Iir_Kind_Package_Pathname => 1694, + Iir_Kind_Absolute_Pathname => 1695, + Iir_Kind_Relative_Pathname => 1696, + Iir_Kind_Pathname_Element => 1701, + Iir_Kind_Base_Attribute => 1703, + Iir_Kind_Subtype_Attribute => 1708, + Iir_Kind_Element_Attribute => 1713, + Iir_Kind_Left_Type_Attribute => 1718, + Iir_Kind_Right_Type_Attribute => 1723, + Iir_Kind_High_Type_Attribute => 1728, + Iir_Kind_Low_Type_Attribute => 1733, + Iir_Kind_Ascending_Type_Attribute => 1738, + Iir_Kind_Image_Attribute => 1744, + Iir_Kind_Value_Attribute => 1750, + Iir_Kind_Pos_Attribute => 1756, + Iir_Kind_Val_Attribute => 1762, + Iir_Kind_Succ_Attribute => 1768, + Iir_Kind_Pred_Attribute => 1774, + Iir_Kind_Leftof_Attribute => 1780, + Iir_Kind_Rightof_Attribute => 1786, + Iir_Kind_Delayed_Attribute => 1795, + Iir_Kind_Stable_Attribute => 1804, + Iir_Kind_Quiet_Attribute => 1813, + Iir_Kind_Transaction_Attribute => 1822, + Iir_Kind_Event_Attribute => 1826, + Iir_Kind_Active_Attribute => 1830, + Iir_Kind_Last_Event_Attribute => 1834, + Iir_Kind_Last_Active_Attribute => 1838, + Iir_Kind_Last_Value_Attribute => 1842, + Iir_Kind_Driving_Attribute => 1846, + Iir_Kind_Driving_Value_Attribute => 1850, + Iir_Kind_Behavior_Attribute => 1850, + Iir_Kind_Structure_Attribute => 1850, + Iir_Kind_Simple_Name_Attribute => 1857, + Iir_Kind_Instance_Name_Attribute => 1862, + Iir_Kind_Path_Name_Attribute => 1867, + Iir_Kind_Left_Array_Attribute => 1874, + Iir_Kind_Right_Array_Attribute => 1881, + Iir_Kind_High_Array_Attribute => 1888, + Iir_Kind_Low_Array_Attribute => 1895, + Iir_Kind_Length_Array_Attribute => 1902, + Iir_Kind_Ascending_Array_Attribute => 1909, + Iir_Kind_Range_Array_Attribute => 1916, + Iir_Kind_Reverse_Range_Array_Attribute => 1923, + Iir_Kind_Attribute_Name => 1932 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -5249,6 +5258,8 @@ package body Nodes_Meta is return Get_Element_Subtype (N); when Field_Array_Element_Constraint => return Get_Array_Element_Constraint (N); + when Field_Owned_Elements_Chain => + return Get_Owned_Elements_Chain (N); when Field_Designated_Type => return Get_Designated_Type (N); when Field_Designated_Subtype_Indication => @@ -5643,6 +5654,8 @@ package body Nodes_Meta is Set_Element_Subtype (N, V); when Field_Array_Element_Constraint => Set_Array_Element_Constraint (N, V); + when Field_Owned_Elements_Chain => + Set_Owned_Elements_Chain (N, V); when Field_Designated_Type => Set_Designated_Type (N, V); when Field_Designated_Subtype_Indication => @@ -7281,6 +7294,7 @@ package body Nodes_Meta is | Iir_Kind_Block_Configuration | Iir_Kind_Component_Configuration | Iir_Kind_Entity_Class + | Iir_Kind_Record_Element_Constraint | Iir_Kind_Record_Element_Resolution | Iir_Kind_Attribute_Specification | Iir_Kind_Disconnection_Specification @@ -8542,6 +8556,11 @@ package body Nodes_Meta is end case; end Has_Elements_Declaration_List; + function Has_Owned_Elements_Chain (K : Iir_Kind) return Boolean is + begin + return K = Iir_Kind_Record_Subtype_Definition; + end Has_Owned_Elements_Chain; + function Has_Designated_Type (K : Iir_Kind) return Boolean is begin case K is @@ -10621,6 +10640,8 @@ package body Nodes_Meta is | Iir_Kind_Component_Configuration | Iir_Kind_Disconnection_Specification | Iir_Kind_Configuration_Specification + | Iir_Kind_Record_Type_Definition + | Iir_Kind_Record_Subtype_Definition | Iir_Kind_Physical_Subtype_Definition | Iir_Kind_Floating_Subtype_Definition | Iir_Kind_Integer_Subtype_Definition diff --git a/src/vhdl/nodes_meta.ads b/src/vhdl/nodes_meta.ads index db47be7f5..c546dc1ba 100644 --- a/src/vhdl/nodes_meta.ads +++ b/src/vhdl/nodes_meta.ads @@ -220,6 +220,7 @@ package Nodes_Meta is Field_Index_Constraint_List, Field_Array_Element_Constraint, Field_Elements_Declaration_List, + Field_Owned_Elements_Chain, Field_Designated_Type, Field_Designated_Subtype_Indication, Field_Index_List, @@ -751,6 +752,7 @@ package Nodes_Meta is function Has_Index_Constraint_List (K : Iir_Kind) return Boolean; function Has_Array_Element_Constraint (K : Iir_Kind) return Boolean; function Has_Elements_Declaration_List (K : Iir_Kind) return Boolean; + function Has_Owned_Elements_Chain (K : Iir_Kind) return Boolean; function Has_Designated_Type (K : Iir_Kind) return Boolean; function Has_Designated_Subtype_Indication (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/sem_assocs.adb b/src/vhdl/sem_assocs.adb index 322e0c420..fda27f750 100644 --- a/src/vhdl/sem_assocs.adb +++ b/src/vhdl/sem_assocs.adb @@ -1055,10 +1055,11 @@ package body Sem_Assocs is Location_Copy (Nrec_El, Ch); Set_Parent (Nrec_El, Ntype); Set_Identifier (Nrec_El, Get_Identifier (Rec_El)); - Set_Element_Position - (Nrec_El, Get_Element_Position (Rec_El)); + pragma Assert (I = Natural (Get_Element_Position (Rec_El))); + Set_Element_Position (Nrec_El, Iir_Index32 (I)); Ch := Get_Associated_Expr (Ch); Set_Type (Nrec_El, Get_Type (Get_Actual (Ch))); + Append_Owned_Element_Constraint (Ntype, Nrec_El); end if; Staticness := Min (Staticness, Get_Type_Staticness (Get_Type (Nrec_El))); diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb index 770b295d3..78d62c57c 100644 --- a/src/vhdl/sem_expr.adb +++ b/src/vhdl/sem_expr.adb @@ -3170,6 +3170,7 @@ package body Sem_Expr is Rec_El_List : Iir_Flist; Rec_El : Iir; Rec_El_Type : Iir; + New_Rec_El : Iir; Constraint : Iir_Constraint; Composite_Found : Boolean; Staticness : Iir_Staticness; @@ -3188,7 +3189,16 @@ package body Sem_Expr is and then not Is_Fully_Constrained_Type (Rec_El_Type) then Rec_El_Type := El_Type; - Set_Type (Rec_El, Rec_El_Type); + New_Rec_El := + Create_Iir (Iir_Kind_Record_Element_Constraint); + Location_Copy (New_Rec_El, Rec_El); + Set_Parent (New_Rec_El, Rec_Type); + Set_Identifier (New_Rec_El, Get_Identifier (Rec_El)); + pragma Assert (I = Natural (Get_Element_Position (Rec_El))); + Set_Element_Position (New_Rec_El, Iir_Index32 (I)); + Set_Nth_Element (Rec_El_List, I, New_Rec_El); + Set_Type (New_Rec_El, Rec_El_Type); + Append_Owned_Element_Constraint (Rec_Type, New_Rec_El); end if; Staticness := Min (Staticness, Get_Type_Staticness (Rec_El_Type)); diff --git a/src/vhdl/sem_types.adb b/src/vhdl/sem_types.adb index 8ea3a4c08..98d2343ad 100644 --- a/src/vhdl/sem_types.adb +++ b/src/vhdl/sem_types.adb @@ -1412,41 +1412,18 @@ package body Sem_Types is function Sem_Subtype_Constraint (Def : Iir; Type_Mark : Iir; Resolution : Iir) return Iir; - function Copy_Record_Element_Declaration (El : Iir; Parent : Iir) return Iir - is - New_El : Iir; - begin - case Get_Kind (El) is - when Iir_Kind_Element_Declaration => - New_El := Create_Iir (Iir_Kind_Element_Declaration); - -- As this is a copy, it has no subtype indication. - Set_Subtype_Indication (New_El, Null_Iir); - when Iir_Kind_Record_Element_Constraint => - New_El := Create_Iir (Iir_Kind_Record_Element_Constraint); - when others => - Error_Kind ("copy_record_element_declaration", El); - end case; - Location_Copy (New_El, El); - Set_Parent (New_El, Parent); - Set_Identifier (New_El, Get_Identifier (El)); - Set_Type (New_El, Get_Type (El)); - Set_Element_Position (New_El, Get_Element_Position (El)); - return New_El; - end Copy_Record_Element_Declaration; - -- Create a copy of elements_declaration_list of SRC and set it to DST. procedure Copy_Record_Elements_Declaration_List (Dst : Iir; Src : Iir) is El_List : constant Iir_Flist := Get_Elements_Declaration_List (Src); New_El_List : Iir_Flist; - El, New_El : Iir; + El : Iir; begin New_El_List := Create_Iir_Flist (Get_Nbr_Elements (El_List)); Set_Elements_Declaration_List (Dst, New_El_List); for I in Flist_First .. Flist_Last (El_List) loop El := Get_Nth_Element (El_List, I); - New_El := Copy_Record_Element_Declaration (El, Dst); - Set_Nth_Element (New_El_List, I, New_El); + Set_Nth_Element (New_El_List, I, El); end loop; end Copy_Record_Elements_Declaration_List; @@ -1514,6 +1491,7 @@ package body Sem_Types is when Iir_Kind_Record_Type_Definition | Iir_Kind_Record_Subtype_Definition => Res := Create_Iir (Iir_Kind_Record_Subtype_Definition); + Set_Is_Ref (Res, True); Set_Type_Staticness (Res, Get_Type_Staticness (Def)); if Get_Kind (Def) = Iir_Kind_Record_Subtype_Definition then Set_Resolution_Indication @@ -1819,6 +1797,7 @@ package body Sem_Types is begin pragma Assert (Get_Prefix (Def) = Null_Iir); Res := Create_Iir (Iir_Kind_Record_Subtype_Definition); + Set_Is_Ref (Res, True); Location_Copy (Res, Def); El_List := Create_Iir_List; Chain := Get_Association_Chain (Def); @@ -1831,6 +1810,8 @@ package body Sem_Types is El := Reparse_As_Record_Element_Constraint (Get_Actual (Chain)); if El /= Null_Iir then Append_Element (El_List, El); + Set_Parent (El, Res); + Append_Owned_Element_Constraint (Res, El); end if; end if; Chain := Get_Chain (Chain); @@ -1913,6 +1894,7 @@ package body Sem_Types is Index_El : Iir; begin Res := Create_Iir (Iir_Kind_Record_Subtype_Definition); + Set_Is_Ref (Res, True); Location_Copy (Res, Def); Set_Base_Type (Res, Get_Base_Type (Type_Mark)); if Get_Kind (Type_Mark) = Iir_Kind_Record_Subtype_Definition then @@ -2064,14 +2046,16 @@ package body Sem_Types is if Els (I) = Null_Iir and Res_Els (I) = Null_Iir then -- No new record element constraints. Copy the element from -- the type mark. - El := Copy_Record_Element_Declaration (Tm_El, Res); + El := Tm_El; El_Type := Get_Type (El); else if Els (I) = Null_Iir then -- Only a resolution constraint. El := Create_Iir (Iir_Kind_Record_Element_Constraint); Location_Copy (El, Tm_El); + Set_Parent (El, Res); El_Type := Null_Iir; + Append_Owned_Element_Constraint (Res, El); else El := Els (I); El_Type := Get_Type (El); diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index c9b5c9ffb..8b6ff6400 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -1384,14 +1384,6 @@ package body Trans.Chap3 is -- The subtype is simply an alias. -- In both cases, use the same representation as its type mark. - for I in Flist_First .. Flist_Last (El_Blist) loop - B_El := Get_Nth_Element (El_Blist, I); - El := Get_Nth_Element (El_List, I); - if El /= B_El then - Set_Info (El, Get_Info (B_El)); - end if; - end loop; - return; end if; |