+ #QLvember work: stack frame optimization for m68k

git-svn-id: trunk@47629 -
This commit is contained in:
florian 2020-11-29 10:16:00 +00:00
parent 8192bf1b33
commit fbb2e63fea
2 changed files with 69 additions and 49 deletions

View File

@ -1868,6 +1868,8 @@ unit cgcpu;
begin
localsize:=align(localsize,4);
if current_procinfo.framepointer=NR_FRAME_POINTER_REG then
begin
if (localsize > high(smallint)) then
begin
list.concat(taicpu.op_reg_const(A_LINK,S_W,NR_FRAME_POINTER_REG,0));
@ -1875,6 +1877,13 @@ unit cgcpu;
end
else
list.concat(taicpu.op_reg_const(A_LINK,S_W,NR_FRAME_POINTER_REG,-localsize));
end
else
begin
if localsize<>0 then
list.concat(taicpu.op_const_reg(A_SUBA,S_L,localsize,NR_STACK_POINTER_REG));
current_procinfo.final_localsize:=localsize;
end;
end;
end;
@ -1890,6 +1899,8 @@ unit cgcpu;
if po_noreturn in current_procinfo.procdef.procoptions then
exit;
if not nostackframe then
begin
if current_procinfo.framepointer=NR_FRAME_POINTER_REG then
begin
list.concat(taicpu.op_reg(A_UNLK,S_NO,NR_FRAME_POINTER_REG));
@ -1943,6 +1954,15 @@ unit cgcpu;
else
list.concat(taicpu.op_none(A_RTS,S_NO));
end
else
begin
if parasize<>0 then
Internalerror(2020112901);
if current_procinfo.final_localsize<>0 then
list.concat(taicpu.op_const_reg(A_ADDA,S_L,current_procinfo.final_localsize,NR_STACK_POINTER_REG));
list.concat(taicpu.op_none(A_RTS,S_NO));
end;
end
else
begin
list.concat(taicpu.op_none(A_RTS,S_NO));

View File

@ -1046,7 +1046,7 @@ implementation
end;
{$if defined(i386) or defined(x86_64) or defined(arm) or defined(riscv32) or defined(riscv64)}
{$if defined(i386) or defined(x86_64) or defined(arm) or defined(riscv32) or defined(riscv64) or defined(m68k)}
const
exception_flags: array[boolean] of tprocinfoflags = (
[],
@ -1058,7 +1058,7 @@ implementation
begin
tg:=tgobjclass.create;
{$if defined(i386) or defined(x86_64) or defined(arm)}
{$if defined(i386) or defined(x86_64) or defined(arm) or defined(m68k)}
{$if defined(arm)}
{ frame and stack pointer must be always the same on arm thumb so it makes no
sense to fiddle with a frame pointer }
@ -1156,7 +1156,7 @@ implementation
{$endif defined(arm)}
end;
end;
{$endif defined(x86) or defined(arm)}
{$endif defined(x86) or defined(arm) or defined(m68k)}
{$if defined(xtensa)}
{ On xtensa, the stack frame size can be estimated to avoid using an extra frame pointer,
in case parameters are passed on the stack.