From 8b8a7868238e7757551e6337f287cda22e232ce3 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 7 Apr 2013 13:42:06 +0000 Subject: [PATCH] * moved ARM/x86 ifdef'ed code from ncgcal to virtual methods git-svn-id: trunk@24179 - --- compiler/arm/narmcal.pas | 11 +++++++-- compiler/ncgcal.pas | 52 +++++++++++----------------------------- compiler/x86/nx86cal.pas | 17 ++++++++++++- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/compiler/arm/narmcal.pas b/compiler/arm/narmcal.pas index 18bca8fa47..8f4ac1ab17 100644 --- a/compiler/arm/narmcal.pas +++ b/compiler/arm/narmcal.pas @@ -38,8 +38,8 @@ implementation uses verbose,globtype,globals,aasmdata, symconst, - cgbase,cpuinfo, - ncgutil, + cgbase,cgutils,cpuinfo, + ncgutil,tgobj, systems; procedure tarmcallnode.set_result_location(realresdef: tstoreddef); @@ -64,6 +64,13 @@ implementation internalerror(2010053008); end end + else if (resultdef.typ=floatdef) and + (location.loc=LOC_REGISTER) and + (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) then + begin + location_reset_ref(location,LOC_REFERENCE,location.size,resultdef.alignment); + tg.gethltemp(current_asmdata.CurrAsmList,resultdef,resultdef.size,tt_normal,location.reference); + end else inherited; end; diff --git a/compiler/ncgcal.pas b/compiler/ncgcal.pas index 8b666661c8..675a99b79a 100644 --- a/compiler/ncgcal.pas +++ b/compiler/ncgcal.pas @@ -103,9 +103,6 @@ implementation cgbase,pass_2, aasmbase,aasmtai,aasmdata, nbas,nmem,nld,ncnv,nutils, -{$ifdef x86} - cga,cgx86,aasmcpu, -{$endif x86} ncgutil, cgobj,tgobj,hlcgobj, procinfo, @@ -477,42 +474,21 @@ implementation else realresdef:=tstoreddef(typedef); -{$ifdef x86} - if (retloc.location^.loc=LOC_FPUREGISTER) then - begin - tcgx86(cg).inc_fpu_stack; - location_reset(location,LOC_FPUREGISTER,retloc.location^.size); - location.register:=retloc.location^.register; - end - else -{$endif x86} - begin - { get a tlocation that can hold the return value that's currently in - the the return value's tcgpara } - set_result_location(realresdef); + { get a tlocation that can hold the return value that's currently in + the return value's tcgpara } + set_result_location(realresdef); - { Do not move the physical register to a virtual one in case - the return value is not used, because if the virtual one is - then mapped to the same register as the physical one, we will - end up with two deallocs of this register (one inserted here, - one inserted by the register allocator), which unbalances the - register allocation information. The return register(s) will - be freed by location_free() in release_unused_return_value - (mantis #13536). } - if (cnf_return_value_used in callnodeflags) or - assigned(funcretnode) then - begin - hlcg.gen_load_cgpara_loc(current_asmdata.CurrAsmList,realresdef,retloc,location,false); -{$ifdef arm} - if (resultdef.typ=floatdef) and - (location.loc=LOC_REGISTER) and - (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) then - begin - hlcg.location_force_mem(current_asmdata.CurrAsmList,location,resultdef); - end; -{$endif arm} - end; - end; + { Do not move the physical register to a virtual one in case + the return value is not used, because if the virtual one is + then mapped to the same register as the physical one, we will + end up with two deallocs of this register (one inserted here, + one inserted by the register allocator), which unbalances the + register allocation information. The return register(s) will + be freed by location_free() in release_unused_return_value + (mantis #13536). } + if (cnf_return_value_used in callnodeflags) or + assigned(funcretnode) then + hlcg.gen_load_cgpara_loc(current_asmdata.CurrAsmList,realresdef,retloc,location,false); { copy value to the final location if this was already provided to the callnode. This must be done after the call node, because the location can diff --git a/compiler/x86/nx86cal.pas b/compiler/x86/nx86cal.pas index fa0437300d..1e3cdcefe7 100644 --- a/compiler/x86/nx86cal.pas +++ b/compiler/x86/nx86cal.pas @@ -28,6 +28,7 @@ interface { $define AnsiStrRef} uses + symdef, ncgcal; type @@ -37,6 +38,7 @@ interface tx86callnode = class(tcgcallnode) protected procedure do_release_unused_return_value;override; + procedure set_result_location(realresdef: tstoreddef);override; end; @@ -44,7 +46,7 @@ implementation uses cgobj, - cgbase,cpubase,cgx86,cga; + cgbase,cgutils,cpubase,cgx86,cga; {***************************************************************************** @@ -66,4 +68,17 @@ implementation end; + procedure tx86callnode.set_result_location(realresdef: tstoreddef); + begin + if (retloc.location^.loc=LOC_FPUREGISTER) then + begin + tcgx86(cg).inc_fpu_stack; + location_reset(location,LOC_FPUREGISTER,retloc.location^.size); + location.register:=retloc.location^.register; + end + else + inherited set_result_location(realresdef); + end; + + end.