* handle stack parameters like delphi when using register calling conventions, resolves #8199

git-svn-id: trunk@6201 -
This commit is contained in:
florian 2007-01-26 17:38:46 +00:00
parent c0e9782da9
commit e923c6072d

View File

@ -503,12 +503,33 @@ unit cpupara;
varalign : longint;
pushaddr : boolean;
paraalign : shortint;
pass : byte;
begin
if paras.count=0 then
exit;
paraalign:=get_para_align(p.proccalloption);
{ Register parameters are assigned from left to right }
{ clean up here so we can later detect properly if a parameter has been
assigned or not
}
for i:=0 to paras.count-1 do
tparavarsym(paras[i]).paraloc[side].reset;
{ Register parameters are assigned from left to right,
stack parameters from right to left so assign first the
register parameters in a first pass, in the second
pass all unhandled parameters are done }
for pass:=1 to 2 do
begin
if pass=1 then
i:=0
else
i:=paras.count-1;
while true do
begin
hp:=tparavarsym(paras[i]);
if not(assigned(hp.paraloc[side].location)) then
begin
pushaddr:=push_addr_param(hp.varspez,hp.vardef,p.proccalloption);
if pushaddr then
begin
@ -520,7 +541,6 @@ unit cpupara;
paralen:=push_size(hp.varspez,hp.vardef,p.proccalloption);
paracgsize:=def_cgsize(hp.vardef);
end;
hp.paraloc[side].reset;
hp.paraloc[side].size:=paracgsize;
hp.paraloc[side].intsize:=paralen;
hp.paraloc[side].Alignment:=paraalign;
@ -540,14 +560,18 @@ unit cpupara;
not(hp.vardef.typ in [floatdef,recorddef,arraydef]) or
pushaddr
) then
begin
if pass=1 then
begin
paraloc:=hp.paraloc[side].add_location;
paraloc^.size:=paracgsize;
paraloc^.loc:=LOC_REGISTER;
paraloc^.register:=newreg(R_INTREGISTER,parasupregs[parareg],cgsize2subreg(paracgsize));
inc(parareg);
end;
end
else
if pass=2 then
begin
{ Copy to stack? }
if (use_fixed_stack) or
@ -603,6 +627,22 @@ unit cpupara;
end;
end;
end;
case pass of
1:
begin
if i=paras.count-1 then
break;
inc(i);
end;
2:
begin
if i=0 then
break;
dec(i);
end;
end;
end;
end;
end;