* x86-64: adjust stack by push/pop if possible

git-svn-id: trunk@45476 -
This commit is contained in:
florian 2020-05-23 17:50:13 +00:00
parent d2879f5bb9
commit 8f0a3cfce7
2 changed files with 18 additions and 6 deletions

View File

@ -3146,9 +3146,16 @@ unit cgx86;
var
href : treference;
begin
reference_reset_base(href,NR_STACK_POINTER_REG,-a,ctempposinvalid,0,[]);
{ normally, lea is a better choice than a sub to adjust the stack pointer }
list.concat(Taicpu.op_ref_reg(A_LEA,TCGSize2OpSize[OS_ADDR],href,NR_STACK_POINTER_REG));
{$ifdef x86_64}
if localsize=8 then
list.concat(Taicpu.op_reg(A_PUSH,TCGSize2OpSize[OS_ADDR],NR_RAX))
else
{$endif x86_64}
begin
reference_reset_base(href,NR_STACK_POINTER_REG,-a,ctempposinvalid,0,[]);
{ normally, lea is a better choice than a sub to adjust the stack pointer }
list.concat(Taicpu.op_ref_reg(A_LEA,TCGSize2OpSize[OS_ADDR],href,NR_STACK_POINTER_REG));
end;
end;
{$ifdef x86}

View File

@ -353,9 +353,14 @@ unit cgcpu;
var
href : treference;
begin
reference_reset_base(href,NR_STACK_POINTER_REG,a,ctempposinvalid,0,[]);
{ normally, lea is a better choice than an add }
list.concat(Taicpu.op_ref_reg(A_LEA,TCGSize2OpSize[OS_ADDR],href,NR_STACK_POINTER_REG));
if a=8 then
list.concat(Taicpu.op_reg(A_POP,TCGSize2OpSize[OS_ADDR],NR_RCX))
else
begin
reference_reset_base(href,NR_STACK_POINTER_REG,a,ctempposinvalid,0,[]);
{ normally, lea is a better choice than an add }
list.concat(Taicpu.op_ref_reg(A_LEA,TCGSize2OpSize[OS_ADDR],href,NR_STACK_POINTER_REG));
end;
end;
var