mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:39:25 +02:00
PascalScript: ppc, fix stack align
git-svn-id: trunk@39531 -
This commit is contained in:
parent
eda22758a1
commit
936fd56eea
@ -9,6 +9,10 @@
|
|||||||
{$fatal This code is 32bit specific at the moment!}
|
{$fatal This code is 32bit specific at the moment!}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
// FPC does not always push a copy of r3 - r10 to the stack (24(r1) - 52(r1)
|
||||||
|
// The API states that the space must be reserved, if the regiser contents are not placed there.
|
||||||
|
{$define NeedRegCopyOnStack}
|
||||||
|
|
||||||
const
|
const
|
||||||
rtINT = 0;
|
rtINT = 0;
|
||||||
rtINT64 = 1;
|
rtINT64 = 1;
|
||||||
@ -182,6 +186,11 @@ var
|
|||||||
{ add a dword to stack }
|
{ add a dword to stack }
|
||||||
procedure addstackdword(value: dword);
|
procedure addstackdword(value: dword);
|
||||||
begin
|
begin
|
||||||
|
{$ifndef NeedRegCopyOnStack}
|
||||||
|
if stindex = 0 then begin
|
||||||
|
stindex := 56; // leave empty space for registers on stack
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
setlength(st, stindex+4);
|
setlength(st, stindex+4);
|
||||||
pdword(@st[stindex])^ := value;
|
pdword(@st[stindex])^ := value;
|
||||||
inc(stindex, 4);
|
inc(stindex, 4);
|
||||||
@ -190,6 +199,11 @@ var
|
|||||||
{ add a float to stack }
|
{ add a float to stack }
|
||||||
procedure addstackfloat(value: pointer; size: integer);
|
procedure addstackfloat(value: pointer; size: integer);
|
||||||
begin
|
begin
|
||||||
|
{$ifndef NeedRegCopyOnStack}
|
||||||
|
if stindex = 0 then begin
|
||||||
|
stindex := 56; // leave empty space for registers on stack
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
setlength(st, stindex + (size * 4));
|
setlength(st, stindex + (size * 4));
|
||||||
if size = 1
|
if size = 1
|
||||||
then psingle(@st[stindex])^ := single(value^)
|
then psingle(@st[stindex])^ := single(value^)
|
||||||
@ -204,7 +218,9 @@ var
|
|||||||
then begin
|
then begin
|
||||||
rint[rindex] := value;
|
rint[rindex] := value;
|
||||||
inc(rindex);
|
inc(rindex);
|
||||||
//addstackdword(value);
|
{$ifdef NeedRegCopyOnStack}
|
||||||
|
addstackdword(value);
|
||||||
|
{$endif}
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
addstackdword(value);
|
addstackdword(value);
|
||||||
@ -221,7 +237,9 @@ var
|
|||||||
else rfloat[findex] := double(value^);
|
else rfloat[findex] := double(value^);
|
||||||
inc(findex);
|
inc(findex);
|
||||||
inc(rindex, size);
|
inc(rindex, size);
|
||||||
//addstackfloat(value, size);
|
{$ifdef NeedRegCopyOnStack}
|
||||||
|
addstackfloat(value, size);
|
||||||
|
{$endif}
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
addstackfloat(value, size);
|
addstackfloat(value, size);
|
||||||
@ -236,7 +254,11 @@ begin
|
|||||||
|
|
||||||
rindex := 1;
|
rindex := 1;
|
||||||
findex := 1;
|
findex := 1;
|
||||||
|
{$ifdef NeedRegCopyOnStack}
|
||||||
stindex := 24;
|
stindex := 24;
|
||||||
|
{$else}
|
||||||
|
stindex := 0; // do not create a stack, if only registers are used
|
||||||
|
{$endif}
|
||||||
setlength(st, stindex);
|
setlength(st, stindex);
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
@ -309,6 +331,11 @@ begin
|
|||||||
end; { else }
|
end; { else }
|
||||||
end; { for }
|
end; { for }
|
||||||
|
|
||||||
|
if (stindex mod 16) <> 0 then begin
|
||||||
|
stindex := stindex + 16 - (stindex mod 16);
|
||||||
|
setlength(st, stindex);
|
||||||
|
end;
|
||||||
|
|
||||||
if not assigned(res)
|
if not assigned(res)
|
||||||
then begin
|
then begin
|
||||||
ppcasmcall(rint, rfloat, address, st, stindex, rtINT); { ignore return }
|
ppcasmcall(rint, rfloat, address, st, stindex, rtINT); { ignore return }
|
||||||
|
Loading…
Reference in New Issue
Block a user