From 4065483a5038e1387d6f0b779c13911f5cf93cfb Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Mon, 10 Mar 2014 09:01:05 +0000 Subject: [PATCH] * completed thlcgobj.location_force_fpureg(), use it everywhere and removed ncgutil/thlcg2ll.location_force_fpureg() git-svn-id: trunk@27071 - --- compiler/arm/narmadd.pas | 8 ++++---- compiler/arm/narminl.pas | 2 +- compiler/arm/narmmat.pas | 2 +- compiler/hlcg2ll.pas | 6 ------ compiler/hlcgobj.pas | 2 +- compiler/m68k/n68kadd.pas | 8 ++++---- compiler/mips/ncpuadd.pas | 10 +++++----- compiler/mips/ncpuinln.pas | 4 ++-- compiler/mips/ncpumat.pas | 2 +- compiler/ncgcnv.pas | 4 ++-- compiler/ncgutil.pas | 26 -------------------------- compiler/ppcgen/ngppcadd.pas | 4 ++-- compiler/ppcgen/ngppcinl.pas | 6 +++--- compiler/sparc/ncpuadd.pas | 10 +++++----- compiler/sparc/ncpucnv.pas | 2 +- compiler/sparc/ncpuinln.pas | 4 ++-- compiler/sparc/ncpumat.pas | 2 +- compiler/x86/nx86add.pas | 6 +++--- compiler/x86/nx86inl.pas | 2 +- 19 files changed, 39 insertions(+), 71 deletions(-) diff --git a/compiler/arm/narmadd.pas b/compiler/arm/narmadd.pas index 3ed09096da..75dd560163 100644 --- a/compiler/arm/narmadd.pas +++ b/compiler/arm/narmadd.pas @@ -142,8 +142,8 @@ interface begin { force fpureg as location, left right doesn't matter as both will be in a fpureg } - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); - location_force_fpureg(current_asmdata.CurrAsmList,right.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true); location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef)); location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size); @@ -258,8 +258,8 @@ interface begin { force fpureg as location, left right doesn't matter as both will be in a fpureg } - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); - location_force_fpureg(current_asmdata.CurrAsmList,right.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true); cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS); if nodetype in [equaln,unequaln] then diff --git a/compiler/arm/narminl.pas b/compiler/arm/narminl.pas index a540cd63f5..f95ccdf609 100644 --- a/compiler/arm/narminl.pas +++ b/compiler/arm/narminl.pas @@ -75,7 +75,7 @@ implementation fpu_fpa10, fpu_fpa11: begin - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); location_copy(location,left.location); if left.location.loc=LOC_CFPUREGISTER then begin diff --git a/compiler/arm/narmmat.pas b/compiler/arm/narmmat.pas index 251989786a..efc373eb07 100644 --- a/compiler/arm/narmmat.pas +++ b/compiler/arm/narmmat.pas @@ -401,7 +401,7 @@ implementation fpu_fpa10, fpu_fpa11: begin - location_force_fpureg(current_asmdata.CurrAsmList,left.location,false); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,false); location:=left.location; current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_const(A_RSF, location.register,left.location.register,0), diff --git a/compiler/hlcg2ll.pas b/compiler/hlcg2ll.pas index 22c07ec202..71fd9fac6d 100644 --- a/compiler/hlcg2ll.pas +++ b/compiler/hlcg2ll.pas @@ -310,7 +310,6 @@ unit hlcg2ll; procedure g_local_unwind(list: TAsmList; l: TAsmLabel);override; procedure location_force_reg(list:TAsmList;var l:tlocation;src_size,dst_size:tdef;maybeconst:boolean);override; - procedure location_force_fpureg(list:TAsmList;var l: tlocation;size: tdef;maybeconst:boolean);override; procedure location_force_mem(list:TAsmList;var l:tlocation;size:tdef);override; procedure location_force_mmregscalar(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override; // procedure location_force_mmreg(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override; @@ -1214,11 +1213,6 @@ implementation location_freetemp(list,oldloc); end; - procedure thlcg2ll.location_force_fpureg(list: TAsmList; var l: tlocation; size: tdef; maybeconst: boolean); - begin - ncgutil.location_force_fpureg(list,l,maybeconst); - end; - procedure thlcg2ll.location_force_mem(list: TAsmList; var l: tlocation; size: tdef); var r: treference; diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas index e53f800da4..1fab9de754 100644 --- a/compiler/hlcgobj.pas +++ b/compiler/hlcgobj.pas @@ -3669,7 +3669,7 @@ implementation begin { if it's in an mm register, store to memory first } if (l.loc in [LOC_MMREGISTER,LOC_CMMREGISTER]) then - internalerror(2011012903); + location_force_mem(list,l,size); reg:=getfpuregister(list,size); a_loadfpu_loc_reg(list,size,size,l,reg); location_freetemp(list,l); diff --git a/compiler/m68k/n68kadd.pas b/compiler/m68k/n68kadd.pas index 5f7bf8e050..18c93e67bc 100644 --- a/compiler/m68k/n68kadd.pas +++ b/compiler/m68k/n68kadd.pas @@ -406,8 +406,8 @@ implementation swapleftright; // put both operands in a register - location_force_fpureg(current_asmdata.CurrAsmList,right.location,true); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); // initialize de result if not cmpop then @@ -454,8 +454,8 @@ implementation } { force fpureg as location, left right doesn't matter as both will be in a fpureg } - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); - location_force_fpureg(current_asmdata.CurrAsmList,right.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true); location_reset(location,LOC_FLAGS,OS_NO); location.resflags:=getresflags(true); diff --git a/compiler/mips/ncpuadd.pas b/compiler/mips/ncpuadd.pas index 7e0b486eec..e1c17336e4 100644 --- a/compiler/mips/ncpuadd.pas +++ b/compiler/mips/ncpuadd.pas @@ -63,7 +63,7 @@ uses procinfo, symconst,symdef, ncon, nset, nadd, - ncgutil, cgobj; + ncgutil, hlcgobj, cgobj; {***************************************************************************** tmipsaddnode @@ -210,8 +210,8 @@ begin { force fpureg as location, left right doesn't matter as both will be in a fpureg } - location_force_fpureg(current_asmdata.CurrAsmList, left.location, True); - location_force_fpureg(current_asmdata.CurrAsmList, right.location, True); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList, left.location, left.resultdef, True); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList, right.location, right.resultdef, True); location_reset(location, LOC_FPUREGISTER, def_cgsize(resultdef)); location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size); @@ -271,8 +271,8 @@ begin if nf_swapped in flags then swapleftright; - location_force_fpureg(current_asmdata.CurrAsmList, left.location, True); - location_force_fpureg(current_asmdata.CurrAsmList, right.location, True); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList, left.location, left.resultdef, True); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList, right.location, right.resultdef, True); location_reset(location, LOC_JUMP, OS_NO); op:=ops_cmpfloat[left.location.size=OS_F64,nodetype]; diff --git a/compiler/mips/ncpuinln.pas b/compiler/mips/ncpuinln.pas index f333d236db..447c05c0b7 100644 --- a/compiler/mips/ncpuinln.pas +++ b/compiler/mips/ncpuinln.pas @@ -53,7 +53,7 @@ uses cgbase, pass_2, cpubase, paramgr, nbas, ncon, ncal, ncnv, nld, - ncgutil, cgobj, cgutils; + hlcgobj, ncgutil, cgobj, cgutils; {***************************************************************************** tMIPSELinlinenode @@ -62,7 +62,7 @@ uses procedure tMIPSELinlinenode.load_fpu_location; begin secondpass(left); - location_force_fpureg(current_asmdata.CurrAsmList, left.location, True); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList, left.location, left.resultdef, True); location_copy(location, left.location); if left.location.loc = LOC_CFPUREGISTER then begin diff --git a/compiler/mips/ncpumat.pas b/compiler/mips/ncpumat.pas index 5056da855d..57d4da0e7a 100644 --- a/compiler/mips/ncpumat.pas +++ b/compiler/mips/ncpumat.pas @@ -270,7 +270,7 @@ end; procedure TMIPSunaryminusnode.second_float; begin secondpass(left); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef)); location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size); case location.size of diff --git a/compiler/ncgcnv.pas b/compiler/ncgcnv.pas index 42016b89c2..3d3b8048da 100644 --- a/compiler/ncgcnv.pas +++ b/compiler/ncgcnv.pas @@ -421,7 +421,7 @@ interface (left.location.size in [OS_F80,OS_C64]) then begin if (left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then - location_force_fpureg(current_asmdata.CurrAsmList,left.location,false); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,false); { round them down to the proper precision } tg.gethltemp(current_asmdata.currasmlist,resultdef,resultdef.size,tt_normal,tr); cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,tr); @@ -479,7 +479,7 @@ interface case expectloc of LOC_FPUREGISTER: begin - location_force_fpureg(current_asmdata.CurrAsmList,left.location,false); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,false); location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size); cg.a_loadfpu_reg_reg(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,location.register); end; diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index b58bc2c194..225db34b61 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -60,7 +60,6 @@ interface procedure maketojumpbool(list:TAsmList; p : tnode; loadregvars: tloadregvars); // procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset); - procedure location_force_fpureg(list:TAsmList;var l: tlocation;maybeconst:boolean); procedure location_force_mmreg(list:TAsmList;var l: tlocation;maybeconst:boolean); procedure location_allocate_register(list:TAsmList;out l: tlocation;def: tdef;constant: boolean); @@ -486,31 +485,6 @@ implementation *****************************************************************************} - procedure location_force_fpureg(list:TAsmList;var l: tlocation;maybeconst:boolean); - var - reg : tregister; - href : treference; - begin - if (l.loc<>LOC_FPUREGISTER) and - ((l.loc<>LOC_CFPUREGISTER) or (not maybeconst)) then - begin - { if it's in an mm register, store to memory first } - if (l.loc in [LOC_MMREGISTER,LOC_CMMREGISTER]) then - begin - tg.GetTemp(list,tcgsize2size[l.size],tcgsize2size[l.size],tt_normal,href); - cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,href,mms_movescalar); - location_reset_ref(l,LOC_REFERENCE,l.size,0); - l.reference:=href; - end; - reg:=cg.getfpuregister(list,l.size); - cg.a_loadfpu_loc_reg(list,l.size,l,reg); - location_freetemp(list,l); - location_reset(l,LOC_FPUREGISTER,l.size); - l.register:=reg; - end; - end; - - procedure register_maybe_adjust_setbase(list: TAsmList; var l: tlocation; setbase: aint); var tmpreg: tregister; diff --git a/compiler/ppcgen/ngppcadd.pas b/compiler/ppcgen/ngppcadd.pas index e6b34869b8..f43ec6a812 100644 --- a/compiler/ppcgen/ngppcadd.pas +++ b/compiler/ppcgen/ngppcadd.pas @@ -341,8 +341,8 @@ implementation swapleftright; // put both operands in a register - location_force_fpureg(current_asmdata.CurrAsmList,right.location,true); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); // initialize de result if not cmpop then diff --git a/compiler/ppcgen/ngppcinl.pas b/compiler/ppcgen/ngppcinl.pas index 78b06e5708..0aeb49b761 100644 --- a/compiler/ppcgen/ngppcinl.pas +++ b/compiler/ppcgen/ngppcinl.pas @@ -60,7 +60,7 @@ implementation defutil, cgbase,pass_2, cpuinfo,ncgutil, - cgutils,cgobj,rgobj,tgobj; + hlcgobj,cgutils,cgobj,rgobj,tgobj; {***************************************************************************** @@ -122,7 +122,7 @@ implementation begin location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef)); secondpass(left); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); location.loc := LOC_FPUREGISTER; location.register := cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64); end; @@ -178,7 +178,7 @@ implementation if (current_settings.cputype < cpu_PPC970) then internalerror(2007020910); secondpass(left); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); tmpreg:=cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64); current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,tmpreg, left.location.register)); diff --git a/compiler/sparc/ncpuadd.pas b/compiler/sparc/ncpuadd.pas index 9a5a8b11f4..12faca4876 100644 --- a/compiler/sparc/ncpuadd.pas +++ b/compiler/sparc/ncpuadd.pas @@ -56,7 +56,7 @@ interface cgbase,cgcpu,cgutils, cpupara, ncon,nset,nadd, - ncgutil,cgobj; + hlcgobj, ncgutil,cgobj; {***************************************************************************** TSparcAddNode @@ -170,8 +170,8 @@ interface { force fpureg as location, left right doesn't matter as both will be in a fpureg } - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); - location_force_fpureg(current_asmdata.CurrAsmList,right.location,(left.location.loc<>LOC_CFPUREGISTER)); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,(left.location.loc<>LOC_CFPUREGISTER)); location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef)); if left.location.loc<>LOC_CFPUREGISTER then @@ -227,8 +227,8 @@ interface { force fpureg as location, left right doesn't matter as both will be in a fpureg } - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); - location_force_fpureg(current_asmdata.CurrAsmList,right.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true); location_reset(location,LOC_FLAGS,OS_NO); location.resflags:=getfpuresflags; diff --git a/compiler/sparc/ncpucnv.pas b/compiler/sparc/ncpucnv.pas index 87b4728834..fd73cca8b9 100644 --- a/compiler/sparc/ncpucnv.pas +++ b/compiler/sparc/ncpucnv.pas @@ -217,7 +217,7 @@ implementation op : tasmop; begin location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef)); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,false); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,false); { Convert value in fpu register from integer to float } op:=conv_op[tfloatdef(resultdef).floattype,tfloatdef(left.resultdef).floattype]; if op=A_NONE then diff --git a/compiler/sparc/ncpuinln.pas b/compiler/sparc/ncpuinln.pas index 2d81e05da8..83a1afc37c 100644 --- a/compiler/sparc/ncpuinln.pas +++ b/compiler/sparc/ncpuinln.pas @@ -51,7 +51,7 @@ implementation cgbase,pass_2, cpubase,paramgr, nbas,ncon,ncal,ncnv,nld, - ncgutil,cgobj,cgutils; + hlcgobj,ncgutil,cgobj,cgutils; {***************************************************************************** tsparcinlinenode @@ -60,7 +60,7 @@ implementation procedure tsparcinlinenode.load_fpu_location; begin secondpass(left); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); location_copy(location,left.location); if left.location.loc=LOC_CFPUREGISTER then begin diff --git a/compiler/sparc/ncpumat.pas b/compiler/sparc/ncpumat.pas index 682f0cad52..79a70879b9 100644 --- a/compiler/sparc/ncpumat.pas +++ b/compiler/sparc/ncpumat.pas @@ -293,7 +293,7 @@ implementation procedure tsparcunaryminusnode.second_float; begin secondpass(left); - location_force_fpureg(current_asmdata.CurrAsmList,left.location,true); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef)); location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size); case location.size of diff --git a/compiler/x86/nx86add.pas b/compiler/x86/nx86add.pas index a70ceb5033..80906a68fd 100644 --- a/compiler/x86/nx86add.pas +++ b/compiler/x86/nx86add.pas @@ -241,9 +241,9 @@ unit nx86add; begin if (force_fpureg) then begin - location_force_fpureg(current_asmdata.CurrAsmList,right.location,false); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,false); if (left.location.loc<>LOC_FPUREGISTER) then - location_force_fpureg(current_asmdata.CurrAsmList,left.location,false) + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,false) else { left was on the stack => swap } toggleflag(nf_swapped); @@ -253,7 +253,7 @@ unit nx86add; else if (left.location.loc<>LOC_FPUREGISTER) then begin if (force_fpureg) then - location_force_fpureg(current_asmdata.CurrAsmList,left.location,false) + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,false) end else begin diff --git a/compiler/x86/nx86inl.pas b/compiler/x86/nx86inl.pas index 8ba4486fc5..f7e417e758 100644 --- a/compiler/x86/nx86inl.pas +++ b/compiler/x86/nx86inl.pas @@ -281,7 +281,7 @@ implementation LOC_MMREGISTER,LOC_CMMREGISTER: begin location:=lnode.location; - location_force_fpureg(current_asmdata.CurrAsmList,location,false); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,location,resultdef,false); end; else internalerror(309991);