diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/vhdl-canon.adb | 15 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.adb | 4 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 10 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.adb | 418 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem.adb | 103 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem.ads | 5 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_decls.adb | 7 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_inst.adb | 31 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_inst.ads | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-utils.adb | 9 | ||||
-rw-r--r-- | src/vhdl/vhdl-utils.ads | 2 |
11 files changed, 390 insertions, 217 deletions
diff --git a/src/vhdl/vhdl-canon.adb b/src/vhdl/vhdl-canon.adb index 53cb5430b..50bad4ce8 100644 --- a/src/vhdl/vhdl-canon.adb +++ b/src/vhdl/vhdl-canon.adb @@ -2913,7 +2913,7 @@ package body Vhdl.Canon is begin case Get_Kind (Decl) is when Iir_Kind_Procedure_Body - | Iir_Kind_Function_Body => + | Iir_Kind_Function_Body => Canon_Declarations (Top, Decl, Null_Iir); if Canon_Flag_Sequentials_Stmts then Stmts := Get_Sequential_Statement_Chain (Decl); @@ -2922,7 +2922,10 @@ package body Vhdl.Canon is end if; when Iir_Kind_Procedure_Declaration - | Iir_Kind_Function_Declaration => + | Iir_Kind_Function_Declaration => + null; + when Iir_Kind_Function_Instantiation_Declaration + | Iir_Kind_Procedure_Instantiation_Declaration => null; when Iir_Kind_Type_Declaration => @@ -2936,15 +2939,15 @@ package body Vhdl.Canon is end; when Iir_Kind_Anonymous_Type_Declaration - | Iir_Kind_Subtype_Declaration => + | Iir_Kind_Subtype_Declaration => null; when Iir_Kind_Protected_Type_Body => Canon_Declarations (Top, Decl, Null_Iir); when Iir_Kind_Variable_Declaration - | Iir_Kind_Signal_Declaration - | Iir_Kind_Constant_Declaration => + | Iir_Kind_Signal_Declaration + | Iir_Kind_Constant_Declaration => if Canon_Flag_Expressions then Canon_Subtype_Indication_If_Anonymous (Get_Type (Decl)); Canon_Expression (Get_Default_Value (Decl)); @@ -3042,7 +3045,7 @@ package body Vhdl.Canon is null; when Iir_Kind_Nature_Declaration - | Iir_Kind_Subnature_Declaration => + | Iir_Kind_Subnature_Declaration => null; when Iir_Kind_Terminal_Declaration => null; diff --git a/src/vhdl/vhdl-nodes.adb b/src/vhdl/vhdl-nodes.adb index 6c05149a7..5425a4a34 100644 --- a/src/vhdl/vhdl-nodes.adb +++ b/src/vhdl/vhdl-nodes.adb @@ -3273,7 +3273,7 @@ package body Vhdl.Nodes is pragma Assert (N /= Null_Iir); pragma Assert (Has_Uninstantiated_Subprogram_Name (Get_Kind (N)), "no field Uninstantiated_Subprogram_Name"); - return Get_Field6 (N); + return Get_Field7 (N); end Get_Uninstantiated_Subprogram_Name; procedure Set_Uninstantiated_Subprogram_Name (N : Iir; Name : Iir) is @@ -3281,7 +3281,7 @@ package body Vhdl.Nodes is pragma Assert (N /= Null_Iir); pragma Assert (Has_Uninstantiated_Subprogram_Name (Get_Kind (N)), "no field Uninstantiated_Subprogram_Name"); - Set_Field6 (N, Name); + Set_Field7 (N, Name); end Set_Uninstantiated_Subprogram_Name; function Get_Default_Value (Target : Iir) return Iir is diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index 16181a3af..e6a9c3534 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -1681,10 +1681,16 @@ package Vhdl.Nodes is -- -- Get/Set_Interface_Declaration_Chain (Field5) -- + -- Get/Set_Generic_Chain (Field6) + -- -- A signature or a simple name. - -- Get/Set_Uninstantiated_Subprogram_Name (Field6) + -- Get/Set_Uninstantiated_Subprogram_Name (Field7) -- -- Get/Set_Generic_Map_Aspect_Chain (Field8) + -- + -- Get/Set_Instance_Source_File (Field10) + -- + -- Get/Set_Visible_Flag (Flag4) -- Iir_Kind_Interface_Function_Declaration (Medium) -- Iir_Kind_Interface_Procedure_Declaration (Medium) @@ -7933,7 +7939,7 @@ package Vhdl.Nodes is function Get_Implicit_Definition (D : Iir) return Iir_Predefined_Functions; procedure Set_Implicit_Definition (D : Iir; Def : Iir_Predefined_Functions); - -- Field: Field6 + -- Field: Field7 function Get_Uninstantiated_Subprogram_Name (N : Iir) return Iir; procedure Set_Uninstantiated_Subprogram_Name (N : Iir; Name : Iir); diff --git a/src/vhdl/vhdl-nodes_meta.adb b/src/vhdl/vhdl-nodes_meta.adb index d3627db87..e455c6840 100644 --- a/src/vhdl/vhdl-nodes_meta.adb +++ b/src/vhdl/vhdl-nodes_meta.adb @@ -3477,20 +3477,26 @@ package body Vhdl.Nodes_Meta is Field_Subprogram_Specification, Field_Callees_List, -- Iir_Kind_Function_Instantiation_Declaration + Field_Instance_Source_File, Field_Identifier, Field_Subprogram_Hash, + Field_Visible_Flag, Field_Parent, Field_Return_Type, Field_Chain, Field_Interface_Declaration_Chain, + Field_Generic_Chain, Field_Uninstantiated_Subprogram_Name, Field_Generic_Map_Aspect_Chain, -- Iir_Kind_Procedure_Instantiation_Declaration + Field_Instance_Source_File, Field_Identifier, Field_Subprogram_Hash, + Field_Visible_Flag, Field_Parent, Field_Chain, Field_Interface_Declaration_Chain, + Field_Generic_Chain, Field_Uninstantiated_Subprogram_Name, Field_Generic_Map_Aspect_Chain, -- Iir_Kind_Terminal_Declaration @@ -5305,209 +5311,209 @@ package body Vhdl.Nodes_Meta is Iir_Kind_Procedure_Declaration => 831, Iir_Kind_Function_Body => 841, Iir_Kind_Procedure_Body => 852, - Iir_Kind_Function_Instantiation_Declaration => 860, - Iir_Kind_Procedure_Instantiation_Declaration => 867, - Iir_Kind_Terminal_Declaration => 876, - Iir_Kind_Object_Alias_Declaration => 888, - Iir_Kind_Free_Quantity_Declaration => 900, - Iir_Kind_Spectrum_Quantity_Declaration => 913, - Iir_Kind_Noise_Quantity_Declaration => 925, - Iir_Kind_Across_Quantity_Declaration => 941, - Iir_Kind_Through_Quantity_Declaration => 957, - Iir_Kind_File_Declaration => 972, - Iir_Kind_Guard_Signal_Declaration => 986, - Iir_Kind_Signal_Declaration => 1003, - Iir_Kind_Variable_Declaration => 1016, - Iir_Kind_Constant_Declaration => 1030, - Iir_Kind_Iterator_Declaration => 1042, - Iir_Kind_Interface_Constant_Declaration => 1059, - Iir_Kind_Interface_Variable_Declaration => 1075, - Iir_Kind_Interface_Signal_Declaration => 1096, - Iir_Kind_Interface_File_Declaration => 1112, - Iir_Kind_Interface_Quantity_Declaration => 1128, - Iir_Kind_Interface_Terminal_Declaration => 1140, - Iir_Kind_Interface_Type_Declaration => 1151, - Iir_Kind_Interface_Package_Declaration => 1164, - Iir_Kind_Interface_Function_Declaration => 1182, - Iir_Kind_Interface_Procedure_Declaration => 1196, - Iir_Kind_Anonymous_Signal_Declaration => 1205, - Iir_Kind_Signal_Attribute_Declaration => 1208, - Iir_Kind_Identity_Operator => 1212, - Iir_Kind_Negation_Operator => 1216, - Iir_Kind_Absolute_Operator => 1220, - Iir_Kind_Not_Operator => 1224, - Iir_Kind_Implicit_Condition_Operator => 1228, - Iir_Kind_Condition_Operator => 1232, - Iir_Kind_Reduction_And_Operator => 1236, - Iir_Kind_Reduction_Or_Operator => 1240, - Iir_Kind_Reduction_Nand_Operator => 1244, - Iir_Kind_Reduction_Nor_Operator => 1248, - Iir_Kind_Reduction_Xor_Operator => 1252, - Iir_Kind_Reduction_Xnor_Operator => 1256, - Iir_Kind_And_Operator => 1261, - Iir_Kind_Or_Operator => 1266, - Iir_Kind_Nand_Operator => 1271, - Iir_Kind_Nor_Operator => 1276, - Iir_Kind_Xor_Operator => 1281, - Iir_Kind_Xnor_Operator => 1286, - Iir_Kind_Equality_Operator => 1291, - Iir_Kind_Inequality_Operator => 1296, - Iir_Kind_Less_Than_Operator => 1301, - Iir_Kind_Less_Than_Or_Equal_Operator => 1306, - Iir_Kind_Greater_Than_Operator => 1311, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1316, - Iir_Kind_Match_Equality_Operator => 1321, - Iir_Kind_Match_Inequality_Operator => 1326, - Iir_Kind_Match_Less_Than_Operator => 1331, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1336, - Iir_Kind_Match_Greater_Than_Operator => 1341, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1346, - Iir_Kind_Sll_Operator => 1351, - Iir_Kind_Sla_Operator => 1356, - Iir_Kind_Srl_Operator => 1361, - Iir_Kind_Sra_Operator => 1366, - Iir_Kind_Rol_Operator => 1371, - Iir_Kind_Ror_Operator => 1376, - Iir_Kind_Addition_Operator => 1381, - Iir_Kind_Substraction_Operator => 1386, - Iir_Kind_Concatenation_Operator => 1391, - Iir_Kind_Multiplication_Operator => 1396, - Iir_Kind_Division_Operator => 1401, - Iir_Kind_Modulus_Operator => 1406, - Iir_Kind_Remainder_Operator => 1411, - Iir_Kind_Exponentiation_Operator => 1416, - Iir_Kind_Function_Call => 1424, - Iir_Kind_Aggregate => 1431, - Iir_Kind_Parenthesis_Expression => 1434, - Iir_Kind_Qualified_Expression => 1438, - Iir_Kind_Type_Conversion => 1443, - Iir_Kind_Allocator_By_Expression => 1448, - Iir_Kind_Allocator_By_Subtype => 1454, - Iir_Kind_Selected_Element => 1462, - Iir_Kind_Dereference => 1467, - Iir_Kind_Implicit_Dereference => 1472, - Iir_Kind_Slice_Name => 1479, - Iir_Kind_Indexed_Name => 1485, - Iir_Kind_Psl_Prev => 1491, - Iir_Kind_Psl_Stable => 1496, - Iir_Kind_Psl_Rose => 1501, - Iir_Kind_Psl_Fell => 1506, - Iir_Kind_Psl_Expression => 1508, - Iir_Kind_Sensitized_Process_Statement => 1529, - Iir_Kind_Process_Statement => 1549, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1562, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1575, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1589, - Iir_Kind_Concurrent_Assertion_Statement => 1597, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1604, - Iir_Kind_Concurrent_Break_Statement => 1612, - Iir_Kind_Psl_Assert_Directive => 1625, - Iir_Kind_Psl_Assume_Directive => 1636, - Iir_Kind_Psl_Cover_Directive => 1648, - Iir_Kind_Psl_Restrict_Directive => 1659, - Iir_Kind_Block_Statement => 1673, - Iir_Kind_If_Generate_Statement => 1684, - Iir_Kind_Case_Generate_Statement => 1693, - Iir_Kind_For_Generate_Statement => 1702, - Iir_Kind_Component_Instantiation_Statement => 1713, - Iir_Kind_Psl_Default_Clock => 1717, - Iir_Kind_Generate_Statement_Body => 1728, - Iir_Kind_If_Generate_Else_Clause => 1734, - Iir_Kind_Simple_Simultaneous_Statement => 1741, - Iir_Kind_Simultaneous_Null_Statement => 1745, - Iir_Kind_Simultaneous_Procedural_Statement => 1756, - Iir_Kind_Simultaneous_Case_Statement => 1765, - Iir_Kind_Simultaneous_If_Statement => 1774, - Iir_Kind_Simultaneous_Elsif => 1780, - Iir_Kind_Simple_Signal_Assignment_Statement => 1791, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1802, - Iir_Kind_Selected_Waveform_Assignment_Statement => 1814, - Iir_Kind_Signal_Force_Assignment_Statement => 1824, - Iir_Kind_Signal_Release_Assignment_Statement => 1833, - Iir_Kind_Null_Statement => 1837, - Iir_Kind_Assertion_Statement => 1844, - Iir_Kind_Report_Statement => 1850, - Iir_Kind_Wait_Statement => 1858, - Iir_Kind_Variable_Assignment_Statement => 1865, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1872, - Iir_Kind_Return_Statement => 1878, - Iir_Kind_For_Loop_Statement => 1889, - Iir_Kind_While_Loop_Statement => 1900, - Iir_Kind_Next_Statement => 1907, - Iir_Kind_Exit_Statement => 1914, - Iir_Kind_Case_Statement => 1922, - Iir_Kind_Procedure_Call_Statement => 1928, - Iir_Kind_Break_Statement => 1935, - Iir_Kind_If_Statement => 1945, - Iir_Kind_Elsif => 1951, - Iir_Kind_Character_Literal => 1959, - Iir_Kind_Simple_Name => 1967, - Iir_Kind_Selected_Name => 1976, - Iir_Kind_Operator_Symbol => 1982, - Iir_Kind_Reference_Name => 1987, - Iir_Kind_External_Constant_Name => 1996, - Iir_Kind_External_Signal_Name => 2005, - Iir_Kind_External_Variable_Name => 2015, - Iir_Kind_Selected_By_All_Name => 2021, - Iir_Kind_Parenthesis_Name => 2026, - Iir_Kind_Package_Pathname => 2030, - Iir_Kind_Absolute_Pathname => 2031, - Iir_Kind_Relative_Pathname => 2032, - Iir_Kind_Pathname_Element => 2037, - Iir_Kind_Base_Attribute => 2039, - Iir_Kind_Subtype_Attribute => 2044, - Iir_Kind_Element_Attribute => 2049, - Iir_Kind_Across_Attribute => 2054, - Iir_Kind_Through_Attribute => 2059, - Iir_Kind_Nature_Reference_Attribute => 2063, - Iir_Kind_Left_Type_Attribute => 2068, - Iir_Kind_Right_Type_Attribute => 2073, - Iir_Kind_High_Type_Attribute => 2078, - Iir_Kind_Low_Type_Attribute => 2083, - Iir_Kind_Ascending_Type_Attribute => 2088, - Iir_Kind_Image_Attribute => 2094, - Iir_Kind_Value_Attribute => 2100, - Iir_Kind_Pos_Attribute => 2106, - Iir_Kind_Val_Attribute => 2112, - Iir_Kind_Succ_Attribute => 2118, - Iir_Kind_Pred_Attribute => 2124, - Iir_Kind_Leftof_Attribute => 2130, - Iir_Kind_Rightof_Attribute => 2136, - Iir_Kind_Signal_Slew_Attribute => 2144, - Iir_Kind_Quantity_Slew_Attribute => 2152, - Iir_Kind_Ramp_Attribute => 2160, - Iir_Kind_Zoh_Attribute => 2168, - Iir_Kind_Ltf_Attribute => 2176, - Iir_Kind_Ztf_Attribute => 2186, - Iir_Kind_Dot_Attribute => 2193, - Iir_Kind_Integ_Attribute => 2200, - Iir_Kind_Above_Attribute => 2208, - Iir_Kind_Quantity_Delayed_Attribute => 2216, - Iir_Kind_Delayed_Attribute => 2225, - Iir_Kind_Stable_Attribute => 2234, - Iir_Kind_Quiet_Attribute => 2243, - Iir_Kind_Transaction_Attribute => 2252, - Iir_Kind_Event_Attribute => 2256, - Iir_Kind_Active_Attribute => 2260, - Iir_Kind_Last_Event_Attribute => 2264, - Iir_Kind_Last_Active_Attribute => 2268, - Iir_Kind_Last_Value_Attribute => 2272, - Iir_Kind_Driving_Attribute => 2276, - Iir_Kind_Driving_Value_Attribute => 2280, - Iir_Kind_Behavior_Attribute => 2280, - Iir_Kind_Structure_Attribute => 2280, - Iir_Kind_Simple_Name_Attribute => 2287, - Iir_Kind_Instance_Name_Attribute => 2292, - Iir_Kind_Path_Name_Attribute => 2297, - Iir_Kind_Left_Array_Attribute => 2304, - Iir_Kind_Right_Array_Attribute => 2311, - Iir_Kind_High_Array_Attribute => 2318, - Iir_Kind_Low_Array_Attribute => 2325, - Iir_Kind_Length_Array_Attribute => 2332, - Iir_Kind_Ascending_Array_Attribute => 2339, - Iir_Kind_Range_Array_Attribute => 2346, - Iir_Kind_Reverse_Range_Array_Attribute => 2353, - Iir_Kind_Attribute_Name => 2362 + Iir_Kind_Function_Instantiation_Declaration => 863, + Iir_Kind_Procedure_Instantiation_Declaration => 873, + Iir_Kind_Terminal_Declaration => 882, + Iir_Kind_Object_Alias_Declaration => 894, + Iir_Kind_Free_Quantity_Declaration => 906, + Iir_Kind_Spectrum_Quantity_Declaration => 919, + Iir_Kind_Noise_Quantity_Declaration => 931, + Iir_Kind_Across_Quantity_Declaration => 947, + Iir_Kind_Through_Quantity_Declaration => 963, + Iir_Kind_File_Declaration => 978, + Iir_Kind_Guard_Signal_Declaration => 992, + Iir_Kind_Signal_Declaration => 1009, + Iir_Kind_Variable_Declaration => 1022, + Iir_Kind_Constant_Declaration => 1036, + Iir_Kind_Iterator_Declaration => 1048, + Iir_Kind_Interface_Constant_Declaration => 1065, + Iir_Kind_Interface_Variable_Declaration => 1081, + Iir_Kind_Interface_Signal_Declaration => 1102, + Iir_Kind_Interface_File_Declaration => 1118, + Iir_Kind_Interface_Quantity_Declaration => 1134, + Iir_Kind_Interface_Terminal_Declaration => 1146, + Iir_Kind_Interface_Type_Declaration => 1157, + Iir_Kind_Interface_Package_Declaration => 1170, + Iir_Kind_Interface_Function_Declaration => 1188, + Iir_Kind_Interface_Procedure_Declaration => 1202, + Iir_Kind_Anonymous_Signal_Declaration => 1211, + Iir_Kind_Signal_Attribute_Declaration => 1214, + Iir_Kind_Identity_Operator => 1218, + Iir_Kind_Negation_Operator => 1222, + Iir_Kind_Absolute_Operator => 1226, + Iir_Kind_Not_Operator => 1230, + Iir_Kind_Implicit_Condition_Operator => 1234, + Iir_Kind_Condition_Operator => 1238, + Iir_Kind_Reduction_And_Operator => 1242, + Iir_Kind_Reduction_Or_Operator => 1246, + Iir_Kind_Reduction_Nand_Operator => 1250, + Iir_Kind_Reduction_Nor_Operator => 1254, + Iir_Kind_Reduction_Xor_Operator => 1258, + Iir_Kind_Reduction_Xnor_Operator => 1262, + Iir_Kind_And_Operator => 1267, + Iir_Kind_Or_Operator => 1272, + Iir_Kind_Nand_Operator => 1277, + Iir_Kind_Nor_Operator => 1282, + Iir_Kind_Xor_Operator => 1287, + Iir_Kind_Xnor_Operator => 1292, + Iir_Kind_Equality_Operator => 1297, + Iir_Kind_Inequality_Operator => 1302, + Iir_Kind_Less_Than_Operator => 1307, + Iir_Kind_Less_Than_Or_Equal_Operator => 1312, + Iir_Kind_Greater_Than_Operator => 1317, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1322, + Iir_Kind_Match_Equality_Operator => 1327, + Iir_Kind_Match_Inequality_Operator => 1332, + Iir_Kind_Match_Less_Than_Operator => 1337, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1342, + Iir_Kind_Match_Greater_Than_Operator => 1347, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1352, + Iir_Kind_Sll_Operator => 1357, + Iir_Kind_Sla_Operator => 1362, + Iir_Kind_Srl_Operator => 1367, + Iir_Kind_Sra_Operator => 1372, + Iir_Kind_Rol_Operator => 1377, + Iir_Kind_Ror_Operator => 1382, + Iir_Kind_Addition_Operator => 1387, + Iir_Kind_Substraction_Operator => 1392, + Iir_Kind_Concatenation_Operator => 1397, + Iir_Kind_Multiplication_Operator => 1402, + Iir_Kind_Division_Operator => 1407, + Iir_Kind_Modulus_Operator => 1412, + Iir_Kind_Remainder_Operator => 1417, + Iir_Kind_Exponentiation_Operator => 1422, + Iir_Kind_Function_Call => 1430, + Iir_Kind_Aggregate => 1437, + Iir_Kind_Parenthesis_Expression => 1440, + Iir_Kind_Qualified_Expression => 1444, + Iir_Kind_Type_Conversion => 1449, + Iir_Kind_Allocator_By_Expression => 1454, + Iir_Kind_Allocator_By_Subtype => 1460, + Iir_Kind_Selected_Element => 1468, + Iir_Kind_Dereference => 1473, + Iir_Kind_Implicit_Dereference => 1478, + Iir_Kind_Slice_Name => 1485, + Iir_Kind_Indexed_Name => 1491, + Iir_Kind_Psl_Prev => 1497, + Iir_Kind_Psl_Stable => 1502, + Iir_Kind_Psl_Rose => 1507, + Iir_Kind_Psl_Fell => 1512, + Iir_Kind_Psl_Expression => 1514, + Iir_Kind_Sensitized_Process_Statement => 1535, + Iir_Kind_Process_Statement => 1555, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1568, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1581, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1595, + Iir_Kind_Concurrent_Assertion_Statement => 1603, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1610, + Iir_Kind_Concurrent_Break_Statement => 1618, + Iir_Kind_Psl_Assert_Directive => 1631, + Iir_Kind_Psl_Assume_Directive => 1642, + Iir_Kind_Psl_Cover_Directive => 1654, + Iir_Kind_Psl_Restrict_Directive => 1665, + Iir_Kind_Block_Statement => 1679, + Iir_Kind_If_Generate_Statement => 1690, + Iir_Kind_Case_Generate_Statement => 1699, + Iir_Kind_For_Generate_Statement => 1708, + Iir_Kind_Component_Instantiation_Statement => 1719, + Iir_Kind_Psl_Default_Clock => 1723, + Iir_Kind_Generate_Statement_Body => 1734, + Iir_Kind_If_Generate_Else_Clause => 1740, + Iir_Kind_Simple_Simultaneous_Statement => 1747, + Iir_Kind_Simultaneous_Null_Statement => 1751, + Iir_Kind_Simultaneous_Procedural_Statement => 1762, + Iir_Kind_Simultaneous_Case_Statement => 1771, + Iir_Kind_Simultaneous_If_Statement => 1780, + Iir_Kind_Simultaneous_Elsif => 1786, + Iir_Kind_Simple_Signal_Assignment_Statement => 1797, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1808, + Iir_Kind_Selected_Waveform_Assignment_Statement => 1820, + Iir_Kind_Signal_Force_Assignment_Statement => 1830, + Iir_Kind_Signal_Release_Assignment_Statement => 1839, + Iir_Kind_Null_Statement => 1843, + Iir_Kind_Assertion_Statement => 1850, + Iir_Kind_Report_Statement => 1856, + Iir_Kind_Wait_Statement => 1864, + Iir_Kind_Variable_Assignment_Statement => 1871, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1878, + Iir_Kind_Return_Statement => 1884, + Iir_Kind_For_Loop_Statement => 1895, + Iir_Kind_While_Loop_Statement => 1906, + Iir_Kind_Next_Statement => 1913, + Iir_Kind_Exit_Statement => 1920, + Iir_Kind_Case_Statement => 1928, + Iir_Kind_Procedure_Call_Statement => 1934, + Iir_Kind_Break_Statement => 1941, + Iir_Kind_If_Statement => 1951, + Iir_Kind_Elsif => 1957, + Iir_Kind_Character_Literal => 1965, + Iir_Kind_Simple_Name => 1973, + Iir_Kind_Selected_Name => 1982, + Iir_Kind_Operator_Symbol => 1988, + Iir_Kind_Reference_Name => 1993, + Iir_Kind_External_Constant_Name => 2002, + Iir_Kind_External_Signal_Name => 2011, + Iir_Kind_External_Variable_Name => 2021, + Iir_Kind_Selected_By_All_Name => 2027, + Iir_Kind_Parenthesis_Name => 2032, + Iir_Kind_Package_Pathname => 2036, + Iir_Kind_Absolute_Pathname => 2037, + Iir_Kind_Relative_Pathname => 2038, + Iir_Kind_Pathname_Element => 2043, + Iir_Kind_Base_Attribute => 2045, + Iir_Kind_Subtype_Attribute => 2050, + Iir_Kind_Element_Attribute => 2055, + Iir_Kind_Across_Attribute => 2060, + Iir_Kind_Through_Attribute => 2065, + Iir_Kind_Nature_Reference_Attribute => 2069, + Iir_Kind_Left_Type_Attribute => 2074, + Iir_Kind_Right_Type_Attribute => 2079, + Iir_Kind_High_Type_Attribute => 2084, + Iir_Kind_Low_Type_Attribute => 2089, + Iir_Kind_Ascending_Type_Attribute => 2094, + Iir_Kind_Image_Attribute => 2100, + Iir_Kind_Value_Attribute => 2106, + Iir_Kind_Pos_Attribute => 2112, + Iir_Kind_Val_Attribute => 2118, + Iir_Kind_Succ_Attribute => 2124, + Iir_Kind_Pred_Attribute => 2130, + Iir_Kind_Leftof_Attribute => 2136, + Iir_Kind_Rightof_Attribute => 2142, + Iir_Kind_Signal_Slew_Attribute => 2150, + Iir_Kind_Quantity_Slew_Attribute => 2158, + Iir_Kind_Ramp_Attribute => 2166, + Iir_Kind_Zoh_Attribute => 2174, + Iir_Kind_Ltf_Attribute => 2182, + Iir_Kind_Ztf_Attribute => 2192, + Iir_Kind_Dot_Attribute => 2199, + Iir_Kind_Integ_Attribute => 2206, + Iir_Kind_Above_Attribute => 2214, + Iir_Kind_Quantity_Delayed_Attribute => 2222, + Iir_Kind_Delayed_Attribute => 2231, + Iir_Kind_Stable_Attribute => 2240, + Iir_Kind_Quiet_Attribute => 2249, + Iir_Kind_Transaction_Attribute => 2258, + Iir_Kind_Event_Attribute => 2262, + Iir_Kind_Active_Attribute => 2266, + Iir_Kind_Last_Event_Attribute => 2270, + Iir_Kind_Last_Active_Attribute => 2274, + Iir_Kind_Last_Value_Attribute => 2278, + Iir_Kind_Driving_Attribute => 2282, + Iir_Kind_Driving_Value_Attribute => 2286, + Iir_Kind_Behavior_Attribute => 2286, + Iir_Kind_Structure_Attribute => 2286, + Iir_Kind_Simple_Name_Attribute => 2293, + Iir_Kind_Instance_Name_Attribute => 2298, + Iir_Kind_Path_Name_Attribute => 2303, + Iir_Kind_Left_Array_Attribute => 2310, + Iir_Kind_Right_Array_Attribute => 2317, + Iir_Kind_High_Array_Attribute => 2324, + Iir_Kind_Low_Array_Attribute => 2331, + Iir_Kind_Length_Array_Attribute => 2338, + Iir_Kind_Ascending_Array_Attribute => 2345, + Iir_Kind_Range_Array_Attribute => 2352, + Iir_Kind_Reverse_Range_Array_Attribute => 2359, + Iir_Kind_Attribute_Name => 2368 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -8534,6 +8540,8 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Component_Declaration | Iir_Kind_Function_Declaration | Iir_Kind_Procedure_Declaration + | Iir_Kind_Function_Instantiation_Declaration + | Iir_Kind_Procedure_Instantiation_Declaration | Iir_Kind_Interface_Package_Declaration => return True; when others => @@ -9493,6 +9501,8 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Enumeration_Literal | Iir_Kind_Function_Declaration | Iir_Kind_Procedure_Declaration + | Iir_Kind_Function_Instantiation_Declaration + | Iir_Kind_Procedure_Instantiation_Declaration | Iir_Kind_Terminal_Declaration | Iir_Kind_Object_Alias_Declaration | Iir_Kind_Free_Quantity_Declaration @@ -10687,6 +10697,8 @@ package body Vhdl.Nodes_Meta is begin case K is when Iir_Kind_Package_Instantiation_Declaration + | Iir_Kind_Function_Instantiation_Declaration + | Iir_Kind_Procedure_Instantiation_Declaration | Iir_Kind_Interface_Package_Declaration => return True; when others => diff --git a/src/vhdl/vhdl-sem.adb b/src/vhdl/vhdl-sem.adb index ff963ec38..f0934de0b 100644 --- a/src/vhdl/vhdl-sem.adb +++ b/src/vhdl/vhdl-sem.adb @@ -410,9 +410,15 @@ package body Vhdl.Sem is Miss := Missing_Allowed; when Iir_Kind_Block_Header => Miss := Missing_Generic; + when Iir_Kind_Procedure_Instantiation_Declaration + | Iir_Kind_Function_Instantiation_Declaration => + -- LRM08 4.4 + -- Each formal generic (or member thereof) shall be associated + -- at most once. + Miss := Missing_Generic; when Iir_Kind_Package_Instantiation_Declaration - | Iir_Kind_Interface_Package_Declaration - | Iir_Kind_Package_Header => + | Iir_Kind_Interface_Package_Declaration + | Iir_Kind_Package_Header => -- LRM08 4.9 -- Each formal generic (or member thereof) shall be associated -- at most once. @@ -1925,6 +1931,12 @@ package body Vhdl.Sem is -- subprogram body. Open_Declarative_Region; + -- Sem generics. + if Get_Kind (Subprg) in Iir_Kinds_Subprogram_Declaration then + Sem_Interface_Chain + (Get_Generic_Chain (Subprg), Generic_Interface_List); + end if; + -- Sem interfaces. Interface_Chain := Get_Interface_Declaration_Chain (Subprg); case Get_Kind (Subprg) is @@ -2219,6 +2231,93 @@ package body Vhdl.Sem is end if; end Sem_Subprogram_Body; + function Sem_Uninstantiated_Subprogram_Name (Decl : Iir) return Iir + is + Name : Iir; + Subprg : Iir; + begin + Name := Get_Uninstantiated_Subprogram_Name (Decl); + if Get_Kind (Name) = Iir_Kind_Signature then + -- TODO + raise Internal_Error; + end if; + + Name := Sem_Denoting_Name (Name); + Set_Uninstantiated_Subprogram_Name (Decl, Name); + Subprg := Get_Named_Entity (Name); + if Is_Error (Subprg) then + return Subprg; + end if; + + if Is_Overload_List (Subprg) then + -- TODO + raise Internal_Error; + end if; + + if Get_Kind (Subprg) not in Iir_Kinds_Subprogram_Declaration then + Error_Class_Match (Name, "package"); + return Create_Error (Subprg); + end if; + + case Get_Kind (Decl) is + when Iir_Kind_Procedure_Instantiation_Declaration => + if Get_Kind (Subprg) /= Iir_Kind_Procedure_Declaration then + Error_Msg_Sem + (+Name, + "a procedure instantiation cannot instantiate %i", +Subprg); + return Create_Error (Subprg); + end if; + when Iir_Kind_Function_Instantiation_Declaration => + if Get_Kind (Subprg) /= Iir_Kind_Function_Declaration then + Error_Msg_Sem + (+Name, + "a function instantiation cannot instantiate %i", +Subprg); + return Create_Error (Subprg); + end if; + when others => + raise Internal_Error; + end case; + + if not Is_Uninstantiated_Subprogram (Subprg) then + Error_Msg_Sem + (+Name, "%n is not an uninstantiated subprogram", +Subprg); + return Create_Error (Subprg); + end if; + + return Subprg; + end Sem_Uninstantiated_Subprogram_Name; + + procedure Sem_Subprogram_Instantiation_Declaration (Decl : Iir) + is + Subprg : Iir; + begin + Xref_Decl (Decl); + + Subprg := Sem_Uninstantiated_Subprogram_Name (Decl); + if Subprg = Null_Iir or Is_Error (Subprg) then + -- What could be done ? + return; + end if; + + -- LRM08 4.4 Subprogram instantiation declarations + -- The generic map aspect, if present, optionally associates a single + -- actual with each formal generic (or member thereof) in the + -- corresponding subprogram declaration. Each formal generic (of member + -- thereof) shall be associated at most once. + if not Sem_Generic_Association_Chain (Subprg, Decl) then + -- FIXME: stop analysis here ? + return; + end if; + + -- Create the interface parameters. + Sem_Inst.Instantiate_Subprogram_Declaration (Decl, Subprg); + + -- Add DECL. Must be done after parameters creation to handle + -- homographs. + Sem_Scopes.Add_Name (Decl); + Set_Visible_Flag (Decl, True); + end Sem_Subprogram_Instantiation_Declaration; + -- Return the subprogram body of SPEC. If there is no body, and if SPEC -- is an instance, returns the body of the generic specification but only -- if known. diff --git a/src/vhdl/vhdl-sem.ads b/src/vhdl/vhdl-sem.ads index ab1056899..18acc666b 100644 --- a/src/vhdl/vhdl-sem.ads +++ b/src/vhdl/vhdl-sem.ads @@ -73,13 +73,16 @@ package Vhdl.Sem is -- LRM 2.2 Subprogram Bodies. procedure Sem_Subprogram_Body (Subprg : Iir); + -- LRM08 4.4 Subprogram instantiation declarations + procedure Sem_Subprogram_Instantiation_Declaration (Decl : Iir); + -- LRM 2.5 Package Declarations. procedure Sem_Package_Declaration (Pkg : Iir_Package_Declaration); -- LRM 2.6 Package Bodies. procedure Sem_Package_Body (Decl : Iir); - -- LRM08 4.9 Package Instantiation Declaration + -- LRM08 4.9 Package Instantiation Declarations procedure Sem_Package_Instantiation_Declaration (Decl : Iir); -- Do late analysis checks (pure rules). diff --git a/src/vhdl/vhdl-sem_decls.adb b/src/vhdl/vhdl-sem_decls.adb index 8b365a225..64df1cbfb 100644 --- a/src/vhdl/vhdl-sem_decls.adb +++ b/src/vhdl/vhdl-sem_decls.adb @@ -2276,6 +2276,7 @@ package body Vhdl.Sem_Decls is end if; when Iir_Kind_Component_Declaration => Sem_Component_Declaration (Decl); + when Iir_Kind_Function_Declaration | Iir_Kind_Procedure_Declaration => if Is_Implicit_Subprogram (Decl) then @@ -2291,8 +2292,12 @@ package body Vhdl.Sem_Decls is end if; end if; when Iir_Kind_Function_Body - | Iir_Kind_Procedure_Body => + | Iir_Kind_Procedure_Body => Sem_Subprogram_Body (Decl); + when Iir_Kind_Function_Instantiation_Declaration + | Iir_Kind_Procedure_Instantiation_Declaration => + Sem_Subprogram_Instantiation_Declaration (Decl); + when Iir_Kind_Non_Object_Alias_Declaration => -- Added by Sem_Alias_Declaration. Need to check that no -- existing attribute specification apply to them. diff --git a/src/vhdl/vhdl-sem_inst.adb b/src/vhdl/vhdl-sem_inst.adb index d8ee3bdf6..07ce3f88d 100644 --- a/src/vhdl/vhdl-sem_inst.adb +++ b/src/vhdl/vhdl-sem_inst.adb @@ -1028,6 +1028,37 @@ package body Vhdl.Sem_Inst is return Res; end Copy_Tree; + procedure Instantiate_Subprogram_Declaration (Inst : Iir; Subprg : Iir) + is + Prev_Instance_File : constant Source_File_Entry := Instance_File; + Mark : constant Instance_Index_Type := Prev_Instance_Table.Last; + begin + Create_Relocation (Inst, Subprg); + Set_Instance_Source_File (Inst, Instance_File); + + -- Be sure Get_Origin_Priv can be called on existing nodes. + Expand_Origin_Table; + + -- For Parent: the instance of PKG is INST. + Set_Origin (Subprg, Inst); + + -- Manually instantiate the package declaration. + Set_Generic_Chain + (Inst, Instantiate_Generic_Chain (Inst, Get_Generic_Chain (Subprg))); + Instantiate_Generic_Map_Chain (Inst, Subprg); + if Get_Kind (Subprg) = Iir_Kind_Function_Instantiation_Declaration then + Set_Return_Type (Inst, Instantiate_Iir (Subprg, True)); + end if; + Set_Interface_Declaration_Chain + (Inst, + Instantiate_Iir_Chain (Get_Interface_Declaration_Chain (Subprg))); + + Set_Origin (Subprg, Null_Iir); + + Instance_File := Prev_Instance_File; + Restore_Origin (Mark); + end Instantiate_Subprogram_Declaration; + procedure Instantiate_Package_Declaration (Inst : Iir; Pkg : Iir) is Header : constant Iir := Get_Package_Header (Pkg); diff --git a/src/vhdl/vhdl-sem_inst.ads b/src/vhdl/vhdl-sem_inst.ads index eb87994d2..6d8a76300 100644 --- a/src/vhdl/vhdl-sem_inst.ads +++ b/src/vhdl/vhdl-sem_inst.ads @@ -24,6 +24,9 @@ package Vhdl.Sem_Inst is -- Create declaration chain and generic declarations for INST from PKG. procedure Instantiate_Package_Declaration (Inst : Iir; Pkg : Iir); + -- Create interface parameters of INST from SUBPRG. + procedure Instantiate_Subprogram_Declaration (Inst : Iir; Subprg : Iir); + -- Return the instantiation of the body for INST, ie macro-expand the -- body. INST has the form of a generic-mapped package. function Instantiate_Package_Body (Inst : Iir) return Iir; diff --git a/src/vhdl/vhdl-utils.adb b/src/vhdl/vhdl-utils.adb index 52f2c073e..83013200f 100644 --- a/src/vhdl/vhdl-utils.adb +++ b/src/vhdl/vhdl-utils.adb @@ -1819,6 +1819,15 @@ package body Vhdl.Utils is and then Get_Generic_Map_Aspect_Chain (Header) /= Null_Iir; end Is_Generic_Mapped_Package; + -- LRM08 4.2 Subprogram declarations + -- If the subprogram header contains the reserved word GENERIC, a generic + -- list, and no generic map aspect, the subprogram is called an + -- uninstantiated subprogram. + function Is_Uninstantiated_Subprogram (Subprg : Iir) return Boolean is + begin + return Get_Generic_Chain (Subprg) /= Null_Iir; + end Is_Uninstantiated_Subprogram; + function Kind_In (N : Iir; K1, K2 : Iir_Kind) return Boolean is K : constant Iir_Kind := Get_Kind (N); diff --git a/src/vhdl/vhdl-utils.ads b/src/vhdl/vhdl-utils.ads index 5cbdc8c25..08e7c6342 100644 --- a/src/vhdl/vhdl-utils.ads +++ b/src/vhdl/vhdl-utils.ads @@ -390,6 +390,8 @@ package Vhdl.Utils is function Is_Uninstantiated_Package (Pkg : Iir) return Boolean; function Is_Generic_Mapped_Package (Pkg : Iir) return Boolean; + function Is_Uninstantiated_Subprogram (Subprg : Iir) return Boolean; + -- Return TRUE if the base name of NAME is a signal object. function Is_Signal_Object (Name: Iir) return Boolean; |