diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-11-07 07:56:03 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-11-07 07:56:03 +0100 |
commit | 1481610635b8e575c7b2560ada5e60f1f0a36636 (patch) | |
tree | baf1b11895405d9a96105c25f77b69900e2b266f /src/vhdl/translate/trans-chap4.adb | |
parent | 2fa7b0b43c485b5ee5731a867f6c13727d3ea1e0 (diff) | |
download | ghdl-1481610635b8e575c7b2560ada5e60f1f0a36636.tar.gz ghdl-1481610635b8e575c7b2560ada5e60f1f0a36636.tar.bz2 ghdl-1481610635b8e575c7b2560ada5e60f1f0a36636.zip |
vhdl/translate: handle predefined operators as conversion functions
Diffstat (limited to 'src/vhdl/translate/trans-chap4.adb')
-rw-r--r-- | src/vhdl/translate/trans-chap4.adb | 93 |
1 files changed, 54 insertions, 39 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), |