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.adb93
-rw-r--r--src/vhdl/translate/trans-chap7.adb20
-rw-r--r--src/vhdl/translate/trans-chap7.ads4
3 files changed, 73 insertions, 44 deletions
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index a536fb07c..18f9546a7 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -3030,53 +3030,68 @@ package body Trans.Chap4 is
-- Create result value.
Subprg_Info := Get_Info (Func);
- if Subprg_Info.Use_Stack2 then
- Create_Temp_Stack2_Mark;
- end if;
-
- if Subprg_Info.Res_Interface /= O_Dnode_Null then
- -- Composite result.
- -- If we need to allocate, do it before starting the call!
+ if Subprg_Info = null
+ and then
+ Get_Implicit_Definition (Func) in Iir_Predefined_Operators
+ then
+ -- An implicit operation like not, "-", abs.
declare
- Res_Type : constant Iir := Get_Return_Type (Func);
- Res_Info : constant Type_Info_Acc := Get_Info (Res_Type);
+ Op : constant ON_Op_Kind := Chap7.Get_ON_Op (Func);
+ pragma Assert (Op /= ON_Nil);
begin
- Res := Create_Temp (Res_Info);
- if Res_Info.Type_Mode /= Type_Mode_Fat_Array then
- Chap4.Allocate_Complex_Object
- (Res_Type, Alloc_Stack, Res);
- end if;
+ E := New_Monadic_Op (Op, R);
+ Res := E2M (E, Get_Info (Out_Type), Mode_Value);
+
end;
- end if;
+ else
+ if Subprg_Info.Use_Stack2 then
+ Create_Temp_Stack2_Mark;
+ end if;
- -- Call conversion function.
- Start_Association (Constr, Subprg_Info.Subprg_Node);
+ if Subprg_Info.Res_Interface /= O_Dnode_Null then
+ -- Composite result.
+ -- If we need to allocate, do it before starting the call!
+ declare
+ Res_Type : constant Iir := Get_Return_Type (Func);
+ Res_Info : constant Type_Info_Acc := Get_Info (Res_Type);
+ begin
+ Res := Create_Temp (Res_Info);
+ if Res_Info.Type_Mode /= Type_Mode_Fat_Array then
+ Chap4.Allocate_Complex_Object
+ (Res_Type, Alloc_Stack, Res);
+ end if;
+ end;
+ end if;
- if Subprg_Info.Res_Interface /= O_Dnode_Null then
- -- Composite result.
- New_Association (Constr, M2E (Res));
- end if;
+ -- Call conversion function.
+ Start_Association (Constr, Subprg_Info.Subprg_Node);
- if Obj /= Null_Iir then
- -- Protected object.
- New_Association
- (Constr,
- New_Value (New_Selected_Acc_Value
- (New_Obj (Var_Data),
- Conv_Info.Method_Object)));
- else
- Subprgs.Add_Subprg_Instance_Assoc
- (Constr, Subprg_Info.Subprg_Instance);
- end if;
+ if Subprg_Info.Res_Interface /= O_Dnode_Null then
+ -- Composite result.
+ New_Association (Constr, M2E (Res));
+ end if;
- New_Association (Constr, R);
+ if Obj /= Null_Iir then
+ -- Protected object.
+ New_Association
+ (Constr,
+ New_Value (New_Selected_Acc_Value
+ (New_Obj (Var_Data),
+ Conv_Info.Method_Object)));
+ else
+ Subprgs.Add_Subprg_Instance_Assoc
+ (Constr, Subprg_Info.Subprg_Instance);
+ end if;
- if Subprg_Info.Res_Interface /= O_Dnode_Null then
- -- Composite result.
- New_Procedure_Call (Constr);
- E := M2E (Res);
- else
- E := New_Function_Call (Constr);
+ New_Association (Constr, R);
+
+ if Subprg_Info.Res_Interface /= O_Dnode_Null then
+ -- Composite result.
+ New_Procedure_Call (Constr);
+ E := M2E (Res);
+ else
+ E := New_Function_Call (Constr);
+ end if;
end if;
Res := E2M
(Chap7.Translate_Implicit_Conv (E, Get_Return_Type (Func),
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index b9be2c390..be3cc3758 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -1108,7 +1108,7 @@ package body Trans.Chap7 is
end Translate_Implicit_Conv;
type Predefined_To_Onop_Type is
- array (Iir_Predefined_Functions) of ON_Op_Kind;
+ array (Iir_Predefined_Pure_Functions) of ON_Op_Kind;
Predefined_To_Onop : constant Predefined_To_Onop_Type :=
(Iir_Predefined_Boolean_Or => ON_Or,
Iir_Predefined_Boolean_Not => ON_Not,
@@ -1170,16 +1170,29 @@ package body Trans.Chap7 is
others => ON_Nil);
+ function Get_ON_Op (Imp : Iir) return ON_Op_Kind
+ is
+ Kind : constant Iir_Predefined_Functions :=
+ Get_Implicit_Definition (Imp);
+ begin
+ if Kind in Iir_Predefined_Pure_Functions then
+ return Predefined_To_Onop (Kind);
+ else
+ return ON_Nil;
+ end if;
+ end Get_ON_Op;
+
function Translate_Shortcircuit_Operator
(Imp : Iir_Function_Declaration; Left, Right : Iir) return O_Enode
is
+ Kind : constant Iir_Predefined_Functions :=
+ Get_Implicit_Definition (Imp);
Rtype : Iir;
Res : O_Dnode;
Res_Type : O_Tnode;
If_Blk : O_If_Block;
Val : Integer;
V : O_Cnode;
- Kind : Iir_Predefined_Functions;
Invert : Boolean;
begin
Rtype := Get_Return_Type (Imp);
@@ -1188,7 +1201,6 @@ package body Trans.Chap7 is
Open_Temp;
New_Assign_Stmt (New_Obj (Res), Chap7.Translate_Expression (Left));
Close_Temp;
- Kind := Get_Implicit_Definition (Imp);
-- Short cut: RIGHT is the result (and must be evaluated) iff
-- LEFT is equal to VAL (ie '0' or false for 0, '1' or true for 1).
@@ -2511,7 +2523,7 @@ package body Trans.Chap7 is
Right_Tree := Translate_Expression (Right, Right_Type);
end if;
- Op := Predefined_To_Onop (Kind);
+ Op := Get_ON_Op (Imp);
if Op /= ON_Nil then
case Op is
when ON_Eq
diff --git a/src/vhdl/translate/trans-chap7.ads b/src/vhdl/translate/trans-chap7.ads
index acb028c87..ac69c8893 100644
--- a/src/vhdl/translate/trans-chap7.ads
+++ b/src/vhdl/translate/trans-chap7.ads
@@ -150,7 +150,9 @@ package Trans.Chap7 is
return Iir;
function Translate_Lib_Operator (Left, Right : O_Enode; Func : O_Dnode)
- return O_Enode;
+ return O_Enode;
+
+ function Get_ON_Op (Imp : Iir) return ON_Op_Kind;
private
type Implicit_Subprogram_Infos is record
Arr_Eq_Info : Operator_Info_Acc;