diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-09-19 02:32:16 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-09-19 02:32:16 +0200 |
commit | 8c6e8db93f3ef85f7edf242d83c3e7e9af194636 (patch) | |
tree | eb353ac4ba18040935973d15801420b8c0fe953f /src/vhdl | |
parent | 62652e356f2e91d2317f5305a03f972385ba7ca1 (diff) | |
download | ghdl-8c6e8db93f3ef85f7edf242d83c3e7e9af194636.tar.gz ghdl-8c6e8db93f3ef85f7edf242d83c3e7e9af194636.tar.bz2 ghdl-8c6e8db93f3ef85f7edf242d83c3e7e9af194636.zip |
vhdl08: create interface subprogram declaration.
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/errorout.adb | 8 | ||||
-rw-r--r-- | src/vhdl/evaluation.adb | 4 | ||||
-rw-r--r-- | src/vhdl/iirs.adb | 2 | ||||
-rw-r--r-- | src/vhdl/iirs.ads | 70 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.adb | 386 | ||||
-rw-r--r-- | src/vhdl/sem_decls.adb | 29 | ||||
-rw-r--r-- | src/vhdl/sem_expr.adb | 43 | ||||
-rw-r--r-- | src/vhdl/sem_inst.adb | 42 | ||||
-rw-r--r-- | src/vhdl/sem_scopes.adb | 8 | ||||
-rw-r--r-- | src/vhdl/sem_stmts.adb | 9 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap2.adb | 11 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 3 |
12 files changed, 412 insertions, 203 deletions
diff --git a/src/vhdl/errorout.adb b/src/vhdl/errorout.adb index 1181af907..5ee924cba 100644 --- a/src/vhdl/errorout.adb +++ b/src/vhdl/errorout.adb @@ -910,11 +910,15 @@ package body Errorout is when Iir_Kind_Procedure_Declaration => return Disp_Identifier (Node, "procedure"); + when Iir_Kind_Function_Declaration => + return Disp_Identifier (Node, "function"); + when Iir_Kind_Interface_Procedure_Declaration => + return Disp_Identifier (Node, "interface procedure"); + when Iir_Kind_Interface_Function_Declaration => + return Disp_Identifier (Node, "interface function"); when Iir_Kind_Procedure_Body | Iir_Kind_Function_Body => return "subprogram body"; - when Iir_Kind_Function_Declaration => - return Disp_Identifier (Node, "function"); when Iir_Kind_Package_Declaration => return Disp_Identifier (Node, "package"); diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb index 0c561f195..f774208b2 100644 --- a/src/vhdl/evaluation.adb +++ b/src/vhdl/evaluation.adb @@ -1450,10 +1450,6 @@ package body Evaluation is -- TODO raise Internal_Error; - when Iir_Predefined_Interface_Type_Equality - | Iir_Predefined_Interface_Type_Inequality => - raise Internal_Error; - when Iir_Predefined_Explicit => raise Internal_Error; end case; diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb index 5524ad66d..de4272d77 100644 --- a/src/vhdl/iirs.adb +++ b/src/vhdl/iirs.adb @@ -500,6 +500,8 @@ package body Iirs is | Iir_Kind_Constant_Declaration | Iir_Kind_Iterator_Declaration | Iir_Kind_Interface_Package_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration | Iir_Kind_Sensitized_Process_Statement | Iir_Kind_Process_Statement | Iir_Kind_Concurrent_Simple_Signal_Assignment diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index c86b12ab3..2a2337049 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -1402,6 +1402,62 @@ package Iirs is -- Only for Iir_Kind_Procedure_Body: -- Get/Set_Suspend_Flag (Flag11) + -- Iir_Kind_Interface_Function_Declaration (Medium) + -- Iir_Kind_Interface_Procedure_Declaration (Medium) + -- + -- LRM08 6.5.4 Interface subprogram declarations + -- + -- interface_subprogram_declaration ::= + -- interface_subprogram_specification + -- [ IS interface_subprogram_default ] + -- + -- interface_subprogram_specification ::= + -- interface_procedure_specification | interface_function_specification + -- + -- interface_procedure_specification ::= + -- PROCEDURE designator + -- [ [ PARAMETER ] ( formal_parameter_list ) ] + -- + -- interface_function_specification ::= + -- [ PURE | IMPURE ] FUNCTION designator + -- [ [ PARAMETER ] ( formal_parameter_list ) ] return type_mark + -- + -- Get/Set_Parent (Field0) + -- + -- Only for Iir_Kind_Interface_Function_Declaration: + -- Get/Set_Return_Type (Field1) + -- + -- Only for Iir_Kind_Interface_Function_Declaration: + -- Get/Set_Type (Alias Field1) + -- + -- Get/Set_Chain (Field2) + -- + -- For string, the identifier is the corresponding reserved word. + -- Get/Set_Identifier (Field3) + -- + -- Get/Set_Subprogram_Hash (Field4) + -- + -- Get/Set_Interface_Declaration_Chain (Field5) + -- + -- Get/Set_Return_Type_Mark (Field8) + -- + -- Get/Set_Subprogram_Depth (Field10) + -- + -- Get/Set_Seen_Flag (Flag1) + -- + -- Only for Iir_Kind_Interface_Function_Declaration: + -- Get/Set_Pure_Flag (Flag2) + -- + -- Get/Set_Visible_Flag (Flag4) + -- + -- Get/Set_Use_Flag (Flag6) + -- + -- Only for Iir_Kind_Interface_Function_Declaration: + -- Get/Set_Resolution_Function_Flag (Flag7) + -- + -- Only for Iir_Kind_Interface_Function_Declaration: + -- Get/Set_Has_Pure (Flag8) + -- Iir_Kind_Signal_Declaration (Short) -- -- Get/Set_Parent (Field0) @@ -3868,6 +3924,8 @@ package Iirs is Iir_Kind_Interface_File_Declaration, -- object, interface Iir_Kind_Interface_Type_Declaration, Iir_Kind_Interface_Package_Declaration, + Iir_Kind_Interface_Function_Declaration, + Iir_Kind_Interface_Procedure_Declaration, -- Expressions. Iir_Kind_Identity_Operator, @@ -4360,10 +4418,6 @@ package Iirs is Iir_Predefined_Std_Ulogic_Array_Match_Equality, Iir_Predefined_Std_Ulogic_Array_Match_Inequality, - -- For interface type - Iir_Predefined_Interface_Type_Equality, - Iir_Predefined_Interface_Type_Inequality, - -- -- Predefined attribute functions. -- Iir_Predefined_Attribute_Image, -- Iir_Predefined_Attribute_Value, @@ -5802,7 +5856,9 @@ package Iirs is function Get_Subtype_Indication (Target : Iir) return Iir; procedure Set_Subtype_Indication (Target : Iir; Atype : Iir); - -- Field: Field6 + -- Discrete range of an iterator. During analysis, a subtype indiciation + -- is created from this range. + -- Field: Field6 Ref function Get_Discrete_Range (Target : Iir) return Iir; procedure Set_Discrete_Range (Target : Iir; Rng : Iir); @@ -6808,12 +6864,12 @@ package Iirs is procedure Set_Simple_Name_Subtype (Target : Iir; Atype : Iir); -- Body of a protected type declaration. - -- Field: Field2 + -- Field: Field2 Ref function Get_Protected_Type_Body (Target : Iir) return Iir; procedure Set_Protected_Type_Body (Target : Iir; Bod : Iir); -- Corresponsing protected type declaration of a protected type body. - -- Field: Field4 + -- Field: Field4 Ref function Get_Protected_Type_Declaration (Target : Iir) return Iir; procedure Set_Protected_Type_Declaration (Target : Iir; Decl : Iir); diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb index 2c1856613..08c968c89 100644 --- a/src/vhdl/nodes_meta.adb +++ b/src/vhdl/nodes_meta.adb @@ -1194,6 +1194,10 @@ package body Nodes_Meta is return "interface_type_declaration"; when Iir_Kind_Interface_Package_Declaration => return "interface_package_declaration"; + when Iir_Kind_Interface_Function_Declaration => + return "interface_function_declaration"; + when Iir_Kind_Interface_Procedure_Declaration => + return "interface_procedure_declaration"; when Iir_Kind_Identity_Operator => return "identity_operator"; when Iir_Kind_Negation_Operator => @@ -1657,7 +1661,7 @@ package body Nodes_Meta is when Field_Subtype_Indication => return Attr_Maybe_Ref; when Field_Discrete_Range => - return Attr_None; + return Attr_Ref; when Field_Type_Definition => return Attr_None; when Field_Subtype_Definition => @@ -2049,9 +2053,9 @@ package body Nodes_Meta is when Field_Simple_Name_Subtype => return Attr_None; when Field_Protected_Type_Body => - return Attr_None; + return Attr_Ref; when Field_Protected_Type_Declaration => - return Attr_None; + return Attr_Ref; when Field_End_Location => return Attr_None; when Field_Use_Flag => @@ -2580,8 +2584,8 @@ package body Nodes_Meta is Field_End_Has_Identifier, Field_Declaration_Chain, Field_Chain, - Field_Protected_Type_Declaration, Field_Parent, + Field_Protected_Type_Declaration, -- Iir_Kind_Wildcard_Type_Definition Field_Resolved_Flag, Field_Signal_Type_Flag, @@ -3039,10 +3043,10 @@ package body Nodes_Meta is Field_Expr_Staticness, Field_Name_Staticness, Field_Chain, - Field_Discrete_Range, Field_Subtype_Indication, Field_Parent, Field_Type, + Field_Discrete_Range, -- Iir_Kind_Interface_Constant_Declaration Field_Identifier, Field_Has_Mode, @@ -3138,6 +3142,32 @@ package body Nodes_Meta is Field_Uninstantiated_Package_Name, Field_Generic_Map_Aspect_Chain, Field_Parent, + -- Iir_Kind_Interface_Function_Declaration + Field_Subprogram_Depth, + Field_Identifier, + Field_Subprogram_Hash, + Field_Seen_Flag, + Field_Pure_Flag, + Field_Visible_Flag, + Field_Use_Flag, + Field_Resolution_Function_Flag, + Field_Has_Pure, + Field_Chain, + Field_Interface_Declaration_Chain, + Field_Return_Type_Mark, + Field_Parent, + Field_Return_Type, + -- Iir_Kind_Interface_Procedure_Declaration + Field_Subprogram_Depth, + Field_Identifier, + Field_Subprogram_Hash, + Field_Seen_Flag, + Field_Visible_Flag, + Field_Use_Flag, + Field_Chain, + Field_Interface_Declaration_Chain, + Field_Return_Type_Mark, + Field_Parent, -- Iir_Kind_Identity_Operator Field_Expr_Staticness, Field_Operand, @@ -4270,149 +4300,151 @@ package body Nodes_Meta is Iir_Kind_Interface_File_Declaration => 892, Iir_Kind_Interface_Type_Declaration => 902, Iir_Kind_Interface_Package_Declaration => 912, - Iir_Kind_Identity_Operator => 916, - Iir_Kind_Negation_Operator => 920, - Iir_Kind_Absolute_Operator => 924, - Iir_Kind_Not_Operator => 928, - Iir_Kind_Condition_Operator => 932, - Iir_Kind_Reduction_And_Operator => 936, - Iir_Kind_Reduction_Or_Operator => 940, - Iir_Kind_Reduction_Nand_Operator => 944, - Iir_Kind_Reduction_Nor_Operator => 948, - Iir_Kind_Reduction_Xor_Operator => 952, - Iir_Kind_Reduction_Xnor_Operator => 956, - Iir_Kind_And_Operator => 961, - Iir_Kind_Or_Operator => 966, - Iir_Kind_Nand_Operator => 971, - Iir_Kind_Nor_Operator => 976, - Iir_Kind_Xor_Operator => 981, - Iir_Kind_Xnor_Operator => 986, - Iir_Kind_Equality_Operator => 991, - Iir_Kind_Inequality_Operator => 996, - Iir_Kind_Less_Than_Operator => 1001, - Iir_Kind_Less_Than_Or_Equal_Operator => 1006, - Iir_Kind_Greater_Than_Operator => 1011, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1016, - Iir_Kind_Match_Equality_Operator => 1021, - Iir_Kind_Match_Inequality_Operator => 1026, - Iir_Kind_Match_Less_Than_Operator => 1031, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1036, - Iir_Kind_Match_Greater_Than_Operator => 1041, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1046, - Iir_Kind_Sll_Operator => 1051, - Iir_Kind_Sla_Operator => 1056, - Iir_Kind_Srl_Operator => 1061, - Iir_Kind_Sra_Operator => 1066, - Iir_Kind_Rol_Operator => 1071, - Iir_Kind_Ror_Operator => 1076, - Iir_Kind_Addition_Operator => 1081, - Iir_Kind_Substraction_Operator => 1086, - Iir_Kind_Concatenation_Operator => 1091, - Iir_Kind_Multiplication_Operator => 1096, - Iir_Kind_Division_Operator => 1101, - Iir_Kind_Modulus_Operator => 1106, - Iir_Kind_Remainder_Operator => 1111, - Iir_Kind_Exponentiation_Operator => 1116, - Iir_Kind_Function_Call => 1124, - Iir_Kind_Aggregate => 1130, - Iir_Kind_Parenthesis_Expression => 1133, - Iir_Kind_Qualified_Expression => 1137, - Iir_Kind_Type_Conversion => 1142, - Iir_Kind_Allocator_By_Expression => 1146, - Iir_Kind_Allocator_By_Subtype => 1152, - Iir_Kind_Selected_Element => 1158, - Iir_Kind_Dereference => 1163, - Iir_Kind_Implicit_Dereference => 1168, - Iir_Kind_Slice_Name => 1175, - Iir_Kind_Indexed_Name => 1181, - Iir_Kind_Psl_Expression => 1183, - Iir_Kind_Sensitized_Process_Statement => 1203, - Iir_Kind_Process_Statement => 1223, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1234, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1245, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1257, - Iir_Kind_Concurrent_Assertion_Statement => 1265, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1272, - Iir_Kind_Psl_Assert_Statement => 1285, - Iir_Kind_Psl_Cover_Statement => 1298, - Iir_Kind_Block_Statement => 1311, - Iir_Kind_If_Generate_Statement => 1321, - Iir_Kind_Case_Generate_Statement => 1330, - Iir_Kind_For_Generate_Statement => 1339, - Iir_Kind_Component_Instantiation_Statement => 1349, - Iir_Kind_Psl_Default_Clock => 1353, - Iir_Kind_Simple_Simultaneous_Statement => 1360, - Iir_Kind_Generate_Statement_Body => 1371, - Iir_Kind_If_Generate_Else_Clause => 1376, - Iir_Kind_Simple_Signal_Assignment_Statement => 1385, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1394, - Iir_Kind_Null_Statement => 1398, - Iir_Kind_Assertion_Statement => 1405, - Iir_Kind_Report_Statement => 1411, - Iir_Kind_Wait_Statement => 1418, - Iir_Kind_Variable_Assignment_Statement => 1424, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1430, - Iir_Kind_Return_Statement => 1436, - Iir_Kind_For_Loop_Statement => 1445, - Iir_Kind_While_Loop_Statement => 1453, - Iir_Kind_Next_Statement => 1459, - Iir_Kind_Exit_Statement => 1465, - Iir_Kind_Case_Statement => 1473, - Iir_Kind_Procedure_Call_Statement => 1479, - Iir_Kind_If_Statement => 1488, - Iir_Kind_Elsif => 1493, - Iir_Kind_Character_Literal => 1500, - Iir_Kind_Simple_Name => 1507, - Iir_Kind_Selected_Name => 1515, - Iir_Kind_Operator_Symbol => 1520, - Iir_Kind_Selected_By_All_Name => 1525, - Iir_Kind_Parenthesis_Name => 1529, - Iir_Kind_External_Constant_Name => 1538, - Iir_Kind_External_Signal_Name => 1547, - Iir_Kind_External_Variable_Name => 1556, - Iir_Kind_Package_Pathname => 1559, - Iir_Kind_Absolute_Pathname => 1560, - Iir_Kind_Relative_Pathname => 1561, - Iir_Kind_Pathname_Element => 1565, - Iir_Kind_Base_Attribute => 1567, - Iir_Kind_Left_Type_Attribute => 1572, - Iir_Kind_Right_Type_Attribute => 1577, - Iir_Kind_High_Type_Attribute => 1582, - Iir_Kind_Low_Type_Attribute => 1587, - Iir_Kind_Ascending_Type_Attribute => 1592, - Iir_Kind_Image_Attribute => 1598, - Iir_Kind_Value_Attribute => 1604, - Iir_Kind_Pos_Attribute => 1610, - Iir_Kind_Val_Attribute => 1616, - Iir_Kind_Succ_Attribute => 1622, - Iir_Kind_Pred_Attribute => 1628, - Iir_Kind_Leftof_Attribute => 1634, - Iir_Kind_Rightof_Attribute => 1640, - Iir_Kind_Delayed_Attribute => 1648, - Iir_Kind_Stable_Attribute => 1656, - Iir_Kind_Quiet_Attribute => 1664, - Iir_Kind_Transaction_Attribute => 1672, - Iir_Kind_Event_Attribute => 1676, - Iir_Kind_Active_Attribute => 1680, - Iir_Kind_Last_Event_Attribute => 1684, - Iir_Kind_Last_Active_Attribute => 1688, - Iir_Kind_Last_Value_Attribute => 1692, - Iir_Kind_Driving_Attribute => 1696, - Iir_Kind_Driving_Value_Attribute => 1700, - Iir_Kind_Behavior_Attribute => 1700, - Iir_Kind_Structure_Attribute => 1700, - Iir_Kind_Simple_Name_Attribute => 1707, - Iir_Kind_Instance_Name_Attribute => 1712, - Iir_Kind_Path_Name_Attribute => 1717, - Iir_Kind_Left_Array_Attribute => 1724, - Iir_Kind_Right_Array_Attribute => 1731, - Iir_Kind_High_Array_Attribute => 1738, - Iir_Kind_Low_Array_Attribute => 1745, - Iir_Kind_Length_Array_Attribute => 1752, - Iir_Kind_Ascending_Array_Attribute => 1759, - Iir_Kind_Range_Array_Attribute => 1766, - Iir_Kind_Reverse_Range_Array_Attribute => 1773, - Iir_Kind_Attribute_Name => 1781 + Iir_Kind_Interface_Function_Declaration => 926, + Iir_Kind_Interface_Procedure_Declaration => 936, + Iir_Kind_Identity_Operator => 940, + Iir_Kind_Negation_Operator => 944, + Iir_Kind_Absolute_Operator => 948, + Iir_Kind_Not_Operator => 952, + Iir_Kind_Condition_Operator => 956, + Iir_Kind_Reduction_And_Operator => 960, + Iir_Kind_Reduction_Or_Operator => 964, + Iir_Kind_Reduction_Nand_Operator => 968, + Iir_Kind_Reduction_Nor_Operator => 972, + Iir_Kind_Reduction_Xor_Operator => 976, + Iir_Kind_Reduction_Xnor_Operator => 980, + Iir_Kind_And_Operator => 985, + Iir_Kind_Or_Operator => 990, + Iir_Kind_Nand_Operator => 995, + Iir_Kind_Nor_Operator => 1000, + Iir_Kind_Xor_Operator => 1005, + Iir_Kind_Xnor_Operator => 1010, + Iir_Kind_Equality_Operator => 1015, + Iir_Kind_Inequality_Operator => 1020, + Iir_Kind_Less_Than_Operator => 1025, + Iir_Kind_Less_Than_Or_Equal_Operator => 1030, + Iir_Kind_Greater_Than_Operator => 1035, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1040, + Iir_Kind_Match_Equality_Operator => 1045, + Iir_Kind_Match_Inequality_Operator => 1050, + Iir_Kind_Match_Less_Than_Operator => 1055, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1060, + Iir_Kind_Match_Greater_Than_Operator => 1065, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1070, + Iir_Kind_Sll_Operator => 1075, + Iir_Kind_Sla_Operator => 1080, + Iir_Kind_Srl_Operator => 1085, + Iir_Kind_Sra_Operator => 1090, + Iir_Kind_Rol_Operator => 1095, + Iir_Kind_Ror_Operator => 1100, + Iir_Kind_Addition_Operator => 1105, + Iir_Kind_Substraction_Operator => 1110, + Iir_Kind_Concatenation_Operator => 1115, + Iir_Kind_Multiplication_Operator => 1120, + Iir_Kind_Division_Operator => 1125, + Iir_Kind_Modulus_Operator => 1130, + Iir_Kind_Remainder_Operator => 1135, + Iir_Kind_Exponentiation_Operator => 1140, + Iir_Kind_Function_Call => 1148, + Iir_Kind_Aggregate => 1154, + Iir_Kind_Parenthesis_Expression => 1157, + Iir_Kind_Qualified_Expression => 1161, + Iir_Kind_Type_Conversion => 1166, + Iir_Kind_Allocator_By_Expression => 1170, + Iir_Kind_Allocator_By_Subtype => 1176, + Iir_Kind_Selected_Element => 1182, + Iir_Kind_Dereference => 1187, + Iir_Kind_Implicit_Dereference => 1192, + Iir_Kind_Slice_Name => 1199, + Iir_Kind_Indexed_Name => 1205, + Iir_Kind_Psl_Expression => 1207, + Iir_Kind_Sensitized_Process_Statement => 1227, + Iir_Kind_Process_Statement => 1247, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1258, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1269, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1281, + Iir_Kind_Concurrent_Assertion_Statement => 1289, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1296, + Iir_Kind_Psl_Assert_Statement => 1309, + Iir_Kind_Psl_Cover_Statement => 1322, + Iir_Kind_Block_Statement => 1335, + Iir_Kind_If_Generate_Statement => 1345, + Iir_Kind_Case_Generate_Statement => 1354, + Iir_Kind_For_Generate_Statement => 1363, + Iir_Kind_Component_Instantiation_Statement => 1373, + Iir_Kind_Psl_Default_Clock => 1377, + Iir_Kind_Simple_Simultaneous_Statement => 1384, + Iir_Kind_Generate_Statement_Body => 1395, + Iir_Kind_If_Generate_Else_Clause => 1400, + Iir_Kind_Simple_Signal_Assignment_Statement => 1409, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1418, + Iir_Kind_Null_Statement => 1422, + Iir_Kind_Assertion_Statement => 1429, + Iir_Kind_Report_Statement => 1435, + Iir_Kind_Wait_Statement => 1442, + Iir_Kind_Variable_Assignment_Statement => 1448, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1454, + Iir_Kind_Return_Statement => 1460, + Iir_Kind_For_Loop_Statement => 1469, + Iir_Kind_While_Loop_Statement => 1477, + Iir_Kind_Next_Statement => 1483, + Iir_Kind_Exit_Statement => 1489, + Iir_Kind_Case_Statement => 1497, + Iir_Kind_Procedure_Call_Statement => 1503, + Iir_Kind_If_Statement => 1512, + Iir_Kind_Elsif => 1517, + Iir_Kind_Character_Literal => 1524, + Iir_Kind_Simple_Name => 1531, + Iir_Kind_Selected_Name => 1539, + Iir_Kind_Operator_Symbol => 1544, + Iir_Kind_Selected_By_All_Name => 1549, + Iir_Kind_Parenthesis_Name => 1553, + Iir_Kind_External_Constant_Name => 1562, + Iir_Kind_External_Signal_Name => 1571, + Iir_Kind_External_Variable_Name => 1580, + Iir_Kind_Package_Pathname => 1583, + Iir_Kind_Absolute_Pathname => 1584, + Iir_Kind_Relative_Pathname => 1585, + Iir_Kind_Pathname_Element => 1589, + Iir_Kind_Base_Attribute => 1591, + Iir_Kind_Left_Type_Attribute => 1596, + Iir_Kind_Right_Type_Attribute => 1601, + Iir_Kind_High_Type_Attribute => 1606, + Iir_Kind_Low_Type_Attribute => 1611, + Iir_Kind_Ascending_Type_Attribute => 1616, + Iir_Kind_Image_Attribute => 1622, + Iir_Kind_Value_Attribute => 1628, + Iir_Kind_Pos_Attribute => 1634, + Iir_Kind_Val_Attribute => 1640, + Iir_Kind_Succ_Attribute => 1646, + Iir_Kind_Pred_Attribute => 1652, + Iir_Kind_Leftof_Attribute => 1658, + Iir_Kind_Rightof_Attribute => 1664, + Iir_Kind_Delayed_Attribute => 1672, + Iir_Kind_Stable_Attribute => 1680, + Iir_Kind_Quiet_Attribute => 1688, + Iir_Kind_Transaction_Attribute => 1696, + Iir_Kind_Event_Attribute => 1700, + Iir_Kind_Active_Attribute => 1704, + Iir_Kind_Last_Event_Attribute => 1708, + Iir_Kind_Last_Active_Attribute => 1712, + Iir_Kind_Last_Value_Attribute => 1716, + Iir_Kind_Driving_Attribute => 1720, + Iir_Kind_Driving_Value_Attribute => 1724, + Iir_Kind_Behavior_Attribute => 1724, + Iir_Kind_Structure_Attribute => 1724, + Iir_Kind_Simple_Name_Attribute => 1731, + Iir_Kind_Instance_Name_Attribute => 1736, + Iir_Kind_Path_Name_Attribute => 1741, + Iir_Kind_Left_Array_Attribute => 1748, + Iir_Kind_Right_Array_Attribute => 1755, + Iir_Kind_High_Array_Attribute => 1762, + Iir_Kind_Low_Array_Attribute => 1769, + Iir_Kind_Length_Array_Attribute => 1776, + Iir_Kind_Ascending_Array_Attribute => 1783, + Iir_Kind_Range_Array_Attribute => 1790, + Iir_Kind_Reverse_Range_Array_Attribute => 1797, + Iir_Kind_Attribute_Name => 1805 ); function Get_Fields (K : Iir_Kind) return Fields_Array @@ -6916,6 +6948,8 @@ package body Nodes_Meta is | Iir_Kind_Interface_File_Declaration | Iir_Kind_Interface_Type_Declaration | Iir_Kind_Interface_Package_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration | Iir_Kind_Sensitized_Process_Statement | Iir_Kind_Process_Statement | Iir_Kind_Concurrent_Simple_Signal_Assignment @@ -7029,6 +7063,7 @@ package body Nodes_Meta is | Iir_Kind_Interface_Signal_Declaration | Iir_Kind_Interface_File_Declaration | Iir_Kind_Interface_Type_Declaration + | Iir_Kind_Interface_Function_Declaration | Iir_Kind_Identity_Operator | Iir_Kind_Negation_Operator | Iir_Kind_Absolute_Operator @@ -7293,7 +7328,9 @@ package body Nodes_Meta is begin case K is when Iir_Kind_Function_Declaration - | Iir_Kind_Procedure_Declaration => + | Iir_Kind_Procedure_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => return True; when others => return False; @@ -7354,7 +7391,9 @@ package body Nodes_Meta is begin case K is when Iir_Kind_Function_Declaration - | Iir_Kind_Procedure_Declaration => + | Iir_Kind_Procedure_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => return True; when others => return False; @@ -7366,7 +7405,9 @@ package body Nodes_Meta is case K is when Iir_Kind_Enumeration_Literal | Iir_Kind_Function_Declaration - | Iir_Kind_Procedure_Declaration => + | Iir_Kind_Procedure_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => return True; when others => return False; @@ -7388,7 +7429,8 @@ package body Nodes_Meta is begin case K is when Iir_Kind_Enumeration_Literal - | Iir_Kind_Function_Declaration => + | Iir_Kind_Function_Declaration + | Iir_Kind_Interface_Function_Declaration => return True; when others => return False; @@ -7656,6 +7698,8 @@ package body Nodes_Meta is | Iir_Kind_Interface_File_Declaration | Iir_Kind_Interface_Type_Declaration | Iir_Kind_Interface_Package_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration | Iir_Kind_Sensitized_Process_Statement | Iir_Kind_Process_Statement | Iir_Kind_Concurrent_Simple_Signal_Assignment @@ -7787,6 +7831,8 @@ package body Nodes_Meta is | Iir_Kind_Interface_File_Declaration | Iir_Kind_Interface_Type_Declaration | Iir_Kind_Interface_Package_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration | Iir_Kind_Sensitized_Process_Statement | Iir_Kind_Process_Statement | Iir_Kind_Concurrent_Simple_Signal_Assignment @@ -8260,7 +8306,13 @@ package body Nodes_Meta is function Has_Resolution_Function_Flag (K : Iir_Kind) return Boolean is begin - return K = Iir_Kind_Function_Declaration; + case K is + when Iir_Kind_Function_Declaration + | Iir_Kind_Interface_Function_Declaration => + return True; + when others => + return False; + end case; end Has_Resolution_Function_Flag; function Has_Wait_State (K : Iir_Kind) return Boolean is @@ -8293,6 +8345,8 @@ package body Nodes_Meta is when Iir_Kind_Enumeration_Literal | Iir_Kind_Function_Declaration | Iir_Kind_Procedure_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration | Iir_Kind_Sensitized_Process_Statement | Iir_Kind_Process_Statement => return True; @@ -8303,7 +8357,13 @@ package body Nodes_Meta is function Has_Pure_Flag (K : Iir_Kind) return Boolean is begin - return K = Iir_Kind_Function_Declaration; + case K is + when Iir_Kind_Function_Declaration + | Iir_Kind_Interface_Function_Declaration => + return True; + when others => + return False; + end case; end Has_Pure_Flag; function Has_Foreign_Flag (K : Iir_Kind) return Boolean is @@ -8775,6 +8835,8 @@ package body Nodes_Meta is | Iir_Kind_Interface_File_Declaration | Iir_Kind_Interface_Type_Declaration | Iir_Kind_Interface_Package_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration | Iir_Kind_Sensitized_Process_Statement | Iir_Kind_Process_Statement | Iir_Kind_Concurrent_Simple_Signal_Assignment @@ -9635,7 +9697,9 @@ package body Nodes_Meta is case K is when Iir_Kind_Signature | Iir_Kind_Function_Declaration - | Iir_Kind_Procedure_Declaration => + | Iir_Kind_Procedure_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => return True; when others => return False; @@ -9778,7 +9842,9 @@ package body Nodes_Meta is | Iir_Kind_Interface_Variable_Declaration | Iir_Kind_Interface_Signal_Declaration | Iir_Kind_Interface_File_Declaration - | Iir_Kind_Interface_Type_Declaration => + | Iir_Kind_Interface_Type_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => return True; when others => return False; @@ -9902,7 +9968,13 @@ package body Nodes_Meta is function Has_Has_Pure (K : Iir_Kind) return Boolean is begin - return K = Iir_Kind_Function_Declaration; + case K is + when Iir_Kind_Function_Declaration + | Iir_Kind_Interface_Function_Declaration => + return True; + when others => + return False; + end case; end Has_Has_Pure; function Has_Has_Body (K : Iir_Kind) return Boolean is diff --git a/src/vhdl/sem_decls.adb b/src/vhdl/sem_decls.adb index 659c460fd..99523232f 100644 --- a/src/vhdl/sem_decls.adb +++ b/src/vhdl/sem_decls.adb @@ -391,6 +391,25 @@ package body Sem_Decls is Xref_Decl (Inter); end Sem_Interface_Package_Declaration; + function Create_Implicit_Interface_Function (Name : Name_Id; + Decl : Iir; + Interface_Chain : Iir; + Return_Type : Iir) + return Iir + is + Operation : Iir_Function_Declaration; + begin + Operation := Create_Iir (Iir_Kind_Interface_Function_Declaration); + Location_Copy (Operation, Decl); + Set_Parent (Operation, Get_Parent (Decl)); + Set_Interface_Declaration_Chain (Operation, Interface_Chain); + Set_Return_Type (Operation, Return_Type); + Set_Identifier (Operation, Name); + Set_Visible_Flag (Operation, True); + Compute_Subprogram_Hash (Operation); + return Operation; + end Create_Implicit_Interface_Function; + procedure Sem_Interface_Type_Declaration (Inter : Iir) is Def : Iir; @@ -412,15 +431,13 @@ package body Sem_Decls is Finters := Create_Anonymous_Interface (Def); Set_Chain (Finters, Create_Anonymous_Interface (Def)); - Op_Eq := Create_Implicit_Function + Op_Eq := Create_Implicit_Interface_Function (Std_Names.Name_Op_Equality, - Inter, Iir_Predefined_Interface_Type_Equality, - Finters, Std_Package.Boolean_Type_Definition); + Inter, Finters, Std_Package.Boolean_Type_Definition); - Op_Neq := Create_Implicit_Function + Op_Neq := Create_Implicit_Interface_Function (Std_Names.Name_Op_Inequality, - Inter, Iir_Predefined_Interface_Type_Inequality, - Finters, Std_Package.Boolean_Type_Definition); + Inter, Finters, Std_Package.Boolean_Type_Definition); Set_Interface_Type_Subprograms (Inter, Op_Eq); Set_Chain (Op_Eq, Op_Neq); diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb index e93532fb4..620931b24 100644 --- a/src/vhdl/sem_expr.adb +++ b/src/vhdl/sem_expr.adb @@ -915,20 +915,27 @@ package body Sem_Expr is end case; -- Staticness. - case Get_Implicit_Definition (Imp) is - when Iir_Predefined_Error => - raise Internal_Error; - when Iir_Predefined_Pure_Functions => - null; - when Iir_Predefined_Impure_Functions => - -- Predefined functions such as Now, Endfile are not static. + case Get_Kind (Imp) is + when Iir_Kind_Function_Declaration => + case Get_Implicit_Definition (Imp) is + when Iir_Predefined_Error => + raise Internal_Error; + when Iir_Predefined_Pure_Functions => + null; + when Iir_Predefined_Impure_Functions => + -- Predefined functions such as Now, Endfile are not static. + Staticness := None; + when Iir_Predefined_Explicit => + if Get_Pure_Flag (Imp) then + Staticness := Min (Staticness, Globally); + else + Staticness := None; + end if; + end case; + when Iir_Kind_Interface_Function_Declaration => Staticness := None; - when Iir_Predefined_Explicit => - if Get_Pure_Flag (Imp) then - Staticness := Min (Staticness, Globally); - else - Staticness := None; - end if; + when others => + Error_Kind ("set_function_call_staticness", Imp); end case; Set_Expr_Staticness (Expr, Staticness); end Set_Function_Call_Staticness; @@ -1116,6 +1123,10 @@ package body Sem_Expr is if Get_Purity_State (Callee) = Pure then return; end if; + when Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => + -- FIXME: how to compute sensitivity ? Recurse ? + return; when others => Error_Kind ("sem_call_all_sensitized_check", Callee); end case; @@ -1783,7 +1794,8 @@ package body Sem_Expr is Decl := Get_Non_Alias_Declaration (Interpretation); -- It is compatible with operand types ? - pragma Assert (Get_Kind (Decl) = Iir_Kind_Function_Declaration); + pragma Assert (Kind_In (Decl, Iir_Kind_Function_Declaration, + Iir_Kind_Interface_Function_Declaration)); -- LRM08 12.3 Visibility -- [...] or all visible declarations denote the same named entity. @@ -3685,6 +3697,9 @@ package body Sem_Expr is end if; if Is_Anonymous_Type_Definition (Arg) then Set_Allocator_Subtype (Expr, Get_Subtype_Indication (Expr)); + Set_Is_Ref (Expr, True); + else + Set_Is_Ref (Expr, False); end if; -- LRM93 7.3.6 diff --git a/src/vhdl/sem_inst.adb b/src/vhdl/sem_inst.adb index 5f9b04c92..80a7fe2f4 100644 --- a/src/vhdl/sem_inst.adb +++ b/src/vhdl/sem_inst.adb @@ -698,9 +698,45 @@ package body Sem_Inst is -- References to package specification (and its declarations) will -- be redirected to the package instantiation. Set_Instance (Pkg, Inst); - Set_Instance_On_Chain - (Get_Generic_Chain (Get_Package_Header (Pkg)), - Get_Generic_Chain (Get_Package_Header (Inst))); + declare + Pkg_Hdr : constant Iir := Get_Package_Header (Pkg); + Inst_Hdr : constant Iir := Get_Package_Header (Inst); + Pkg_El : Iir; + Inst_El : Iir; + Inter_El : Iir; + Inter : Iir; + begin + -- In the body, references to interface object are redirected to the + -- instantiated interface objects. + Pkg_El := Get_Generic_Chain (Pkg_Hdr); + Inst_El := Get_Generic_Chain (Inst_Hdr); + while Is_Valid (Pkg_El) loop + if Get_Kind (Pkg_El) in Iir_Kinds_Interface_Object_Declaration then + Set_Instance (Pkg_El, Inst_El); + end if; + Pkg_El := Get_Chain (Pkg_El); + Inst_El := Get_Chain (Inst_El); + end loop; + + -- In the body, references to interface type are substitued to the + -- mapped type. + Inst_El := Get_Generic_Map_Aspect_Chain (Inst_Hdr); + Inter_El := Get_Generic_Chain (Inst_Hdr); + while Is_Valid (Inst_El) loop + case Get_Kind (Inst_El) is + when Iir_Kind_Association_Element_Type => + Inter := Get_Association_Interface (Inst_El, Inter_El); + Set_Instance (Get_Type (Get_Origin (Inter)), + Get_Type (Get_Actual (Inst_El))); + when Iir_Kind_Association_Element_Package => + -- TODO. + raise Internal_Error; + when others => + null; + end case; + Next_Association_Interface (Inst_El, Inter_El); + end loop; + end; Set_Instance_On_Chain (Get_Declaration_Chain (Pkg), Get_Declaration_Chain (Inst)); diff --git a/src/vhdl/sem_scopes.adb b/src/vhdl/sem_scopes.adb index 8831d0538..0b62cff03 100644 --- a/src/vhdl/sem_scopes.adb +++ b/src/vhdl/sem_scopes.adb @@ -374,13 +374,17 @@ package body Sem_Scopes is case Get_Kind (Decl) is when Iir_Kind_Enumeration_Literal | Iir_Kind_Function_Declaration - | Iir_Kind_Procedure_Declaration => + | Iir_Kind_Procedure_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => return True; when Iir_Kind_Non_Object_Alias_Declaration => case Get_Kind (Get_Named_Entity (Get_Name (Decl))) is when Iir_Kind_Enumeration_Literal | Iir_Kind_Function_Declaration - | Iir_Kind_Procedure_Declaration => + | Iir_Kind_Procedure_Declaration + | Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => return True; when Iir_Kind_Non_Object_Alias_Declaration => raise Internal_Error; diff --git a/src/vhdl/sem_stmts.adb b/src/vhdl/sem_stmts.adb index 1c447dcd8..638e9ada3 100644 --- a/src/vhdl/sem_stmts.adb +++ b/src/vhdl/sem_stmts.adb @@ -1327,14 +1327,14 @@ package body Sem_Stmts is end; when Iir_Kind_For_Loop_Statement => declare - Iterator: Iir; + Iterator : constant Iir := + Get_Parameter_Specification (Stmt); begin -- LRM 10.1 Declarative region -- 9. A loop statement. Open_Declarative_Region; Set_Is_Within_Flag (Stmt, True); - Iterator := Get_Parameter_Specification (Stmt); Sem_Scopes.Add_Name (Iterator); Sem_Iterator (Iterator, None); Set_Visible_Flag (Iterator, True); @@ -1677,19 +1677,20 @@ package body Sem_Stmts is procedure Sem_For_Generate_Statement (Stmt : Iir) is - Param : Iir; + Param : constant Iir := Get_Parameter_Specification (Stmt); begin -- LRM93 10.1 Declarative region. -- 12. A generate statement. Open_Declarative_Region; Set_Is_Within_Flag (Stmt, True); - Param := Get_Parameter_Specification (Stmt); Sem_Scopes.Add_Name (Param); + -- LRM93 7.4.2 (Globally Static Primaries) -- 4. a generate parameter; Sem_Iterator (Param, Globally); Set_Visible_Flag (Param, True); + -- LRM93 9.7 -- The discrete range in a generation scheme of the first form must -- be a static discrete range; diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index 0d6f73e2b..eeb657da8 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -763,6 +763,7 @@ package body Trans.Chap2 is Info : Ortho_Info_Acc; Interface_List : O_Inter_List; Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack; + Bod : Iir; begin -- Skip uninstantiated package that have to be macro-expanded. if Get_Macro_Expanded_Flag (Decl) then @@ -805,6 +806,10 @@ package body Trans.Chap2 is Chap4.Translate_Generic_Chain (Header); end if; Chap4.Translate_Declaration_Chain (Decl); + Bod := Get_Package_Instantiation_Bodies_Chain (Decl); + if Is_Valid (Bod) then + Chap4.Translate_Declaration_Chain (Bod); + end if; if not Is_Nested then Info.Package_Elab_Var := Create_Var (Create_Var_Identifier ("ELABORATED"), Ghdl_Bool_Type); @@ -816,6 +821,10 @@ package body Trans.Chap2 is -- For nested package, this will be translated when translating -- subprograms. Chap4.Translate_Declaration_Chain_Subprograms (Decl); + Bod := Get_Package_Instantiation_Bodies_Chain (Decl); + if Is_Valid (Bod) then + Chap4.Translate_Declaration_Chain_Subprograms (Bod); + end if; end if; -- Declare elaborator for the body. @@ -837,8 +846,8 @@ package body Trans.Chap2 is Wki_Instance, Prev_Subprg_Instance); end if; - -- Declare elaborator for the spec. if not Is_Nested then + -- Declare elaborator for the spec. Start_Procedure_Decl (Interface_List, Create_Identifier ("ELAB_SPEC"), Global_Storage); Subprgs.Add_Subprg_Instance_Interfaces diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index c743cefa5..451dfcba6 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -5459,9 +5459,6 @@ package body Trans.Chap7 is when Iir_Predefined_Error | Iir_Predefined_Explicit => raise Internal_Error; - when Iir_Predefined_Interface_Type_Equality - | Iir_Predefined_Interface_Type_Inequality => - raise Internal_Error; when Iir_Predefined_Boolean_And | Iir_Predefined_Boolean_Or | Iir_Predefined_Boolean_Xor |