From cc44a19af553bd90a1beee345cc9ef4ee0b17610 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 19 Nov 2005 17:31:35 +0000 Subject: [PATCH] * use stmw/lmw when saving/restoring a lot of registers, to reduce generated code size and thus instruction cache pressure. git-svn-id: trunk@1785 - --- compiler/powerpc/cgcpu.pas | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/compiler/powerpc/cgcpu.pas b/compiler/powerpc/cgcpu.pas index 9c49618cdb..f1bcba07ea 100644 --- a/compiler/powerpc/cgcpu.pas +++ b/compiler/powerpc/cgcpu.pas @@ -1197,8 +1197,20 @@ const if regcounter2 in rg[R_INTREGISTER].used_in_proc then begin usesgpr:=true; - a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter2,R_SUBNONE),href); - dec(href.offset,4); + if (regcounter2 <= RS_R22) or + ((cs_littlesize in aktglobalswitches) and + { with RS_R30 it's also already smaller, but too big a speed trade-off to make } + (regcounter2 <= RS_R29)) then + begin + dec(href.offset,(RS_R31-regcounter2+1)*sizeof(aint)); + list.concat(taicpu.op_reg_ref(A_STMW,newreg(R_INTREGISTER,regcounter2,R_SUBNONE),href)); + break; + end + else + begin + a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter2,R_SUBNONE),href); + dec(href.offset,4); + end; end; end; { @@ -1338,8 +1350,20 @@ const if regcounter2 in rg[R_INTREGISTER].used_in_proc then begin usesgpr:=true; - a_load_ref_reg(list,OS_INT,OS_INT,href,newreg(R_INTREGISTER,regcounter2,R_SUBNONE)); - dec(href.offset,4); + if (regcounter2 <= RS_R22) or + ((cs_littlesize in aktglobalswitches) and + { with RS_R30 it's also already smaller, but too big a speed trade-off to make } + (regcounter2 <= RS_R29)) then + begin + dec(href.offset,(RS_R31-regcounter2+1)*sizeof(aint)); + list.concat(taicpu.op_reg_ref(A_LMW,newreg(R_INTREGISTER,regcounter2,R_SUBNONE),href)); + break; + end + else + begin + a_load_ref_reg(list,OS_INT,OS_INT,href,newreg(R_INTREGISTER,regcounter2,R_SUBNONE)); + dec(href.offset,4); + end; end; end;