aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/translate
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl/translate')
-rw-r--r--src/vhdl/translate/trans-chap4.adb63
-rw-r--r--src/vhdl/translate/trans-chap6.adb3
-rw-r--r--src/vhdl/translate/trans-chap7.adb41
-rw-r--r--src/vhdl/translate/trans-chap8.adb3
-rw-r--r--src/vhdl/translate/trans-rtis.adb8
-rw-r--r--src/vhdl/translate/trans.adb2
-rw-r--r--src/vhdl/translate/translation.adb20
7 files changed, 64 insertions, 76 deletions
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 3083e421c..b6f1c66b2 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -2041,9 +2041,10 @@ package body Trans.Chap4 is
while El /= Null_Iir loop
case Get_Kind (El) is
when Iir_Kind_Procedure_Declaration
- | Iir_Kind_Function_Declaration =>
+ | Iir_Kind_Function_Declaration =>
-- Translate interfaces.
- if (not Flag_Discard_Unused or else Get_Use_Flag (El))
+ if not Is_Implicit_Subprogram (El)
+ and then (not Flag_Discard_Unused or else Get_Use_Flag (El))
and then not Is_Second_Subprogram_Specification (El)
then
Info := Add_Info (El, Kind_Subprg);
@@ -2057,9 +2058,6 @@ package body Trans.Chap4 is
when Iir_Kind_Function_Body
| Iir_Kind_Procedure_Body =>
null;
- when Iir_Kind_Implicit_Function_Declaration
- | Iir_Kind_Implicit_Procedure_Declaration =>
- null;
when others =>
Translate_Declaration (El);
end case;
@@ -2076,11 +2074,30 @@ package body Trans.Chap4 is
while El /= Null_Iir loop
case Get_Kind (El) is
when Iir_Kind_Procedure_Declaration
- | Iir_Kind_Function_Declaration =>
- -- Translate only if used.
- if Get_Info (El) /= null then
- Chap2.Translate_Subprogram_Declaration (El);
- Translate_Resolution_Function (El);
+ | Iir_Kind_Function_Declaration =>
+ if Is_Implicit_Subprogram (El) then
+ if Flag_Discard_Unused_Implicit
+ and then not Get_Use_Flag (El)
+ then
+ case Get_Implicit_Definition (El) is
+ when Iir_Predefined_Array_Equality
+ | Iir_Predefined_Array_Greater
+ | Iir_Predefined_Record_Equality =>
+ -- Used implicitly in case statement or other
+ -- predefined equality.
+ Chap7.Translate_Implicit_Subprogram (El, Infos);
+ when others =>
+ null;
+ end case;
+ else
+ Chap7.Translate_Implicit_Subprogram (El, Infos);
+ end if;
+ else
+ -- Translate only if used.
+ if Get_Info (El) /= null then
+ Chap2.Translate_Subprogram_Declaration (El);
+ Translate_Resolution_Function (El);
+ end if;
end if;
when Iir_Kind_Function_Body
| Iir_Kind_Procedure_Body =>
@@ -2103,24 +2120,6 @@ package body Trans.Chap4 is
when Iir_Kind_Protected_Type_Body =>
Chap3.Translate_Protected_Type_Body (El);
Chap3.Translate_Protected_Type_Body_Subprograms (El);
- when Iir_Kind_Implicit_Function_Declaration
- | Iir_Kind_Implicit_Procedure_Declaration =>
- if Flag_Discard_Unused_Implicit
- and then not Get_Use_Flag (El)
- then
- case Get_Implicit_Definition (El) is
- when Iir_Predefined_Array_Equality
- | Iir_Predefined_Array_Greater
- | Iir_Predefined_Record_Equality =>
- -- Used implicitly in case statement or other
- -- predefined equality.
- Chap7.Translate_Implicit_Subprogram (El, Infos);
- when others =>
- null;
- end case;
- else
- Chap7.Translate_Implicit_Subprogram (El, Infos);
- end if;
when others =>
null;
end case;
@@ -2186,17 +2185,15 @@ package body Trans.Chap4 is
when Iir_Kind_Function_Declaration
| Iir_Kind_Procedure_Declaration =>
- if Get_Info (Decl) /= null then
+ if not Is_Implicit_Subprogram (Decl)
+ and then Get_Info (Decl) /= null
+ then
Chap2.Elab_Subprogram_Interfaces (Decl);
end if;
when Iir_Kind_Function_Body
| Iir_Kind_Procedure_Body =>
null;
- when Iir_Kind_Implicit_Function_Declaration
- | Iir_Kind_Implicit_Procedure_Declaration =>
- null;
-
when Iir_Kind_Stable_Attribute
| Iir_Kind_Quiet_Attribute
| Iir_Kind_Transaction_Attribute =>
diff --git a/src/vhdl/translate/trans-chap6.adb b/src/vhdl/translate/trans-chap6.adb
index 35544cff1..eb8303693 100644
--- a/src/vhdl/translate/trans-chap6.adb
+++ b/src/vhdl/translate/trans-chap6.adb
@@ -998,8 +998,7 @@ package body Trans.Chap6 is
Obj : Iir;
Assoc_Chain : Iir;
begin
- if Get_Kind (Imp) = Iir_Kind_Implicit_Function_Declaration
- then
+ if Is_Implicit_Subprogram (Imp) then
-- FIXME : to be done
raise Internal_Error;
else
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 67ea81106..bcee1264d 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -1060,8 +1060,7 @@ package body Trans.Chap7 is
others => ON_Nil);
function Translate_Shortcut_Operator
- (Imp : Iir_Implicit_Function_Declaration; Left, Right : Iir)
- return O_Enode
+ (Imp : Iir_Function_Declaration; Left, Right : Iir) return O_Enode
is
Rtype : Iir;
Res : O_Dnode;
@@ -1137,8 +1136,7 @@ package body Trans.Chap7 is
end Translate_Lib_Operator;
function Translate_Predefined_Lib_Operator
- (Left, Right : O_Enode; Func : Iir_Implicit_Function_Declaration)
- return O_Enode
+ (Left, Right : O_Enode; Func : Iir_Function_Declaration) return O_Enode
is
Info : constant Subprg_Info_Acc := Get_Info (Func);
Constr : O_Assoc_List;
@@ -1226,7 +1224,8 @@ package body Trans.Chap7 is
begin
if Get_Kind (E) = Iir_Kind_Concatenation_Operator then
Imp := Get_Implementation (E);
- if Get_Kind (Imp) = Iir_Kind_Implicit_Function_Declaration
+ if (Get_Implicit_Definition (Imp)
+ in Iir_Predefined_Concat_Functions)
and then Get_Return_Type (Imp) = Expr_Type
then
Walk_Concat (Imp, Get_Left (E), Get_Right (E));
@@ -1237,7 +1236,8 @@ package body Trans.Chap7 is
-- Note that associations are always 'simple': no formal, no
-- default expression in implicit declarations.
Imp := Get_Implementation (E);
- if Get_Kind (Imp) = Iir_Kind_Implicit_Function_Declaration
+ if (Get_Implicit_Definition (Imp)
+ in Iir_Predefined_Concat_Functions)
and then Get_Return_Type (Imp) = Expr_Type
then
Assocs := Get_Parameter_Association_Chain (E);
@@ -2123,7 +2123,7 @@ package body Trans.Chap7 is
end Translate_Predefined_Std_Ulogic_Array_Match;
function Translate_Predefined_Operator
- (Imp : Iir_Implicit_Function_Declaration;
+ (Imp : Iir_Function_Declaration;
Left, Right : Iir;
Res_Type : Iir;
Loc : Iir)
@@ -4018,7 +4018,7 @@ package body Trans.Chap7 is
when Iir_Kinds_Dyadic_Operator =>
Imp := Get_Implementation (Expr);
- if Get_Kind (Imp) = Iir_Kind_Implicit_Function_Declaration then
+ if Is_Implicit_Subprogram (Imp) then
return Translate_Predefined_Operator
(Imp, Get_Left (Expr), Get_Right (Expr), Res_Type, Expr);
else
@@ -4027,7 +4027,7 @@ package body Trans.Chap7 is
end if;
when Iir_Kinds_Monadic_Operator =>
Imp := Get_Implementation (Expr);
- if Get_Kind (Imp) = Iir_Kind_Implicit_Function_Declaration then
+ if Is_Implicit_Subprogram (Imp) then
return Translate_Predefined_Operator
(Imp, Get_Operand (Expr), Null_Iir, Res_Type, Expr);
else
@@ -4039,8 +4039,7 @@ package body Trans.Chap7 is
declare
Assoc_Chain : Iir;
begin
- if Get_Kind (Imp) = Iir_Kind_Implicit_Function_Declaration
- then
+ if Is_Implicit_Subprogram (Imp) then
declare
Left, Right : Iir;
begin
@@ -4590,17 +4589,12 @@ package body Trans.Chap7 is
begin
El := Get_Chain (Get_Type_Declarator (Base_Type));
while El /= Null_Iir loop
- case Get_Kind (El) is
- when Iir_Kind_Implicit_Function_Declaration
- | Iir_Kind_Implicit_Procedure_Declaration =>
- if Get_Implicit_Definition (El) = Imp then
- return El;
- else
- El := Get_Chain (El);
- end if;
- when others =>
- raise Internal_Error;
- end case;
+ pragma Assert (Is_Implicit_Subprogram (El));
+ if Get_Implicit_Definition (El) = Imp then
+ return El;
+ else
+ El := Get_Chain (El);
+ end if;
end loop;
raise Internal_Error;
end Find_Predefined_Function;
@@ -5594,7 +5588,8 @@ package body Trans.Chap7 is
end if;
case Kind is
- when Iir_Predefined_Error =>
+ when Iir_Predefined_Error
+ | Iir_Predefined_None =>
raise Internal_Error;
when Iir_Predefined_Boolean_And
| Iir_Predefined_Boolean_Or
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb
index 8f63e7827..07bf43cf4 100644
--- a/src/vhdl/translate/trans-chap8.adb
+++ b/src/vhdl/translate/trans-chap8.adb
@@ -2912,8 +2912,7 @@ package body Trans.Chap8 is
Imp : constant Iir := Get_Implementation (Call);
begin
Canon.Canon_Subprogram_Call (Call);
- if Get_Kind (Imp) = Iir_Kind_Implicit_Procedure_Declaration
- then
+ if Is_Implicit_Subprogram (Imp) then
Translate_Implicit_Procedure_Call (Call);
else
Translate_Procedure_Call (Call);
diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb
index 9bdc7a96d..fe7032c4a 100644
--- a/src/vhdl/translate/trans-rtis.adb
+++ b/src/vhdl/translate/trans-rtis.adb
@@ -1961,9 +1961,7 @@ package body Trans.Rtis is
null;
when Iir_Kind_Component_Declaration =>
null;
- when Iir_Kind_Implicit_Function_Declaration
- | Iir_Kind_Implicit_Procedure_Declaration
- | Iir_Kind_Function_Declaration
+ when Iir_Kind_Function_Declaration
| Iir_Kind_Procedure_Declaration =>
-- FIXME: to be added (for foreign).
null;
@@ -2128,9 +2126,7 @@ package body Trans.Rtis is
end;
when Iir_Kind_Component_Declaration =>
Generate_Component_Declaration (Decl);
- when Iir_Kind_Implicit_Function_Declaration
- | Iir_Kind_Implicit_Procedure_Declaration
- | Iir_Kind_Function_Declaration
+ when Iir_Kind_Function_Declaration
| Iir_Kind_Procedure_Declaration =>
-- FIXME: to be added (for foreign).
null;
diff --git a/src/vhdl/translate/trans.adb b/src/vhdl/translate/trans.adb
index 4c913006e..e23357ee8 100644
--- a/src/vhdl/translate/trans.adb
+++ b/src/vhdl/translate/trans.adb
@@ -1338,7 +1338,7 @@ package body Trans is
Info.T := Ortho_Info_Type_Array_Init;
Free_Type_Info (Info);
end if;
- when Iir_Kind_Implicit_Function_Declaration =>
+ when Iir_Kind_Function_Declaration =>
case Get_Implicit_Definition (I) is
when Iir_Predefined_Bit_Array_Match_Equality
| Iir_Predefined_Bit_Array_Match_Inequality =>
diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb
index 977e01f00..42ffbab6e 100644
--- a/src/vhdl/translate/translation.adb
+++ b/src/vhdl/translate/translation.adb
@@ -1810,15 +1810,17 @@ package body Translation is
Decl := Get_Chain (Decl);
Chap7.Init_Implicit_Subprogram_Infos (Infos);
+
+ -- Implicit subprograms are immediately follow the type declaration.
while Decl /= Null_Iir loop
- case Get_Kind (Decl) is
- when Iir_Kind_Implicit_Function_Declaration
- | Iir_Kind_Implicit_Procedure_Declaration =>
- Chap7.Translate_Implicit_Subprogram (Decl, Infos);
- Decl := Get_Chain (Decl);
- when others =>
- exit;
- end case;
+ if Get_Kind (Decl) in Iir_Kinds_Subprogram_Declaration
+ and then Is_Implicit_Subprogram (Decl)
+ then
+ Chap7.Translate_Implicit_Subprogram (Decl, Infos);
+ Decl := Get_Chain (Decl);
+ else
+ exit;
+ end if;
end loop;
end Translate_Type_Implicit_Subprograms;
@@ -1902,7 +1904,7 @@ package body Translation is
Decl := Get_Chain (Decl);
when Iir_Kind_Attribute_Declaration =>
Decl := Get_Chain (Decl);
- when Iir_Kind_Implicit_Function_Declaration =>
+ when Iir_Kind_Function_Declaration =>
case Get_Implicit_Definition (Decl) is
when Iir_Predefined_Now_Function =>
null;