* only use r12 as frame pointer in the entry code for ppc if necessary

git-svn-id: trunk@2086 -
This commit is contained in:
Jonas Maebe 2005-12-31 10:54:09 +00:00
parent 6c30925e04
commit c423e23bb4
4 changed files with 20 additions and 30 deletions

View File

@ -127,7 +127,11 @@ implementation
regvars,dwarf,dbgbase, regvars,dwarf,dbgbase,
pass_1,pass_2, pass_1,pass_2,
ncon,nld,nutils, ncon,nld,nutils,
tgobj,cgobj; tgobj,cgobj
{$ifdef powerpc}
, cpupi
{$endif}
;
{***************************************************************************** {*****************************************************************************
@ -1502,7 +1506,8 @@ implementation
{$ifdef powerpc} {$ifdef powerpc}
{ unget the register that contains the stack pointer before the procedure entry, } { unget the register that contains the stack pointer before the procedure entry, }
{ which is used to access the parameters in their original callee-side location } { which is used to access the parameters in their original callee-side location }
cg.a_reg_dealloc(list,NR_R12); if (tppcprocinfo(current_procinfo).needs_frame_pointer) then
cg.a_reg_dealloc(list,NR_R12);
{$endif powerpc} {$endif powerpc}
{$ifdef powerpc64} {$ifdef powerpc64}
{ unget the register that contains the stack pointer before the procedure entry, } { unget the register that contains the stack pointer before the procedure entry, }

View File

@ -1097,15 +1097,9 @@ const
usesgpr := firstregint <> 32; usesgpr := firstregint <> 32;
usesfpr := firstregfpu <> 32; usesfpr := firstregfpu <> 32;
{ !!! always allocate space for all registers for now !!! } if (tppcprocinfo(current_procinfo).needs_frame_pointer) then
{ if usesfpr or usesgpr then }
if (localsize <> 0) and
{ check is imperfect, is actualy only necessary if there are }
{ parameters to copy }
(tppcprocinfo(current_procinfo).uses_stack_temps) then
begin begin
a_reg_alloc(list,NR_R12); a_reg_alloc(list,NR_R12);
{ save end of fpr save area }
list.concat(taicpu.op_reg_reg(A_MR,NR_R12,NR_STACK_POINTER_REG)); list.concat(taicpu.op_reg_reg(A_MR,NR_R12,NR_STACK_POINTER_REG));
end; end;
end; end;
@ -1163,20 +1157,11 @@ const
a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter,R_SUBNONE),href); a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter,R_SUBNONE),href);
dec(href.offset,4); dec(href.offset,4);
end; end;
{
r.enum:=R_INTREGISTER;
r.:=;
reference_reset_base(href,NR_R12,-((NR_R31-firstreggpr) shr 8+1)*4);
list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
}
end; end;
{ see "!!! always allocate space for all registers for now !!!" above }
{ done in ncgutil because it may only be released after the parameters } { done in ncgutil because it may only be released after the parameters }
{ have been moved to their final resting place } { have been moved to their final resting place }
{ if usesfpr or usesgpr then } { if (tppcprocinfo(current_procinfo).needs_frame_pointer) then }
{ a_reg_dealloc(list,NR_R12); } { a_reg_dealloc(list,NR_R12); }

View File

@ -54,7 +54,8 @@ unit cpupara;
uses uses
verbose,systems, verbose,systems,
defutil, defutil,
cgutils; cgutils,
procinfo,cpupi;
function tppcparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset; function tppcparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
@ -507,7 +508,10 @@ unit cpupara;
if (side = callerside) then if (side = callerside) then
paraloc^.reference.index:=NR_STACK_POINTER_REG paraloc^.reference.index:=NR_STACK_POINTER_REG
else else
paraloc^.reference.index:=NR_R12; begin
paraloc^.reference.index:=NR_R12;
tppcprocinfo(current_procinfo).needs_frame_pointer := true;
end;
paraloc^.reference.offset:=stack_offset; paraloc^.reference.offset:=stack_offset;
inc(stack_offset,align(paralen,4)); inc(stack_offset,align(paralen,4));
paralen := 0; paralen := 0;

View File

@ -43,11 +43,12 @@ unit cpupi;
function uses_stack_temps: boolean; function uses_stack_temps: boolean;
private private
start_temp_offset: aint;
first_save_int_reg, first_save_fpu_reg: tsuperregister; first_save_int_reg, first_save_fpu_reg: tsuperregister;
public public
property get_first_save_int_reg: tsuperregister read first_save_int_reg; property get_first_save_int_reg: tsuperregister read first_save_int_reg;
property get_first_save_fpu_reg: tsuperregister read first_save_fpu_reg; property get_first_save_fpu_reg: tsuperregister read first_save_fpu_reg;
needs_frame_pointer: boolean;
end; end;
@ -66,9 +67,9 @@ unit cpupi;
begin begin
inherited create(aparent); inherited create(aparent);
maxpushedparasize:=0; maxpushedparasize:=0;
start_temp_offset:=-1;
first_save_int_reg:=-1; first_save_int_reg:=-1;
first_save_fpu_reg:=-1; first_save_fpu_reg:=-1;
needs_frame_pointer:=false;
end; end;
@ -88,19 +89,16 @@ unit cpupi;
internalerror(200402191); internalerror(200402191);
end; end;
tg.setfirsttemp(ofs); tg.setfirsttemp(ofs);
start_temp_offset := ofs;
end end
else else
begin begin
locals := 0; locals := 0;
start_temp_offset := 0;
current_procinfo.procdef.localst.foreach_static(@count_locals,@locals); current_procinfo.procdef.localst.foreach_static(@count_locals,@locals);
if locals <> 0 then if locals <> 0 then
begin begin
{ at 0(r1), the previous value of r1 will be stored } { at 0(r1), the previous value of r1 will be stored }
tg.setfirsttemp(4); tg.setfirsttemp(4);
start_temp_offset := 4; end
end;
end; end;
end; end;
@ -137,9 +135,7 @@ unit cpupi;
function tppcprocinfo.uses_stack_temps: boolean; function tppcprocinfo.uses_stack_temps: boolean;
begin begin
if (start_temp_offset = -1) then result := tg.firsttemp <> tg.lasttemp;
internalerror(200512301);
result := start_temp_offset <> tg.lasttemp;
end; end;