* turned {$ifdef cputargethasfixedstack} into "if use_fixed_stack"

* fixed i386 parameter passing of function calls nested in parameters
    of functions which also need the stack to pass poarameters

git-svn-id: trunk@2847 -
This commit is contained in:
Jonas Maebe 2006-03-10 23:44:04 +00:00
parent 41eba7dffe
commit fad5d59bd9
5 changed files with 48 additions and 44 deletions

View File

@ -194,8 +194,13 @@ uses
{$ifdef i386} {$ifdef i386}
result := (target_info.system = system_i386_darwin); result := (target_info.system = system_i386_darwin);
{$else i386} {$else i386}
{$ifdef cputargethasfixedstack}
result := true;
{$else cputargethasfixedstack}
result := false; result := false;
{$endif cputargethasfixedstack}
{$endif i386} {$endif i386}
end; end;
end. end.

View File

@ -618,7 +618,8 @@ unit cpupara;
begin begin
paraloc:=parasym.paraloc[callerside].location; paraloc:=parasym.paraloc[callerside].location;
{ No need for temps when value is pushed } { No need for temps when value is pushed }
if assigned(paraloc) and if not(use_fixed_stack) and
assigned(paraloc) and
(paraloc^.loc=LOC_REFERENCE) and (paraloc^.loc=LOC_REFERENCE) and
(paraloc^.reference.index=NR_STACK_POINTER_REG) then (paraloc^.reference.index=NR_STACK_POINTER_REG) then
duplicateparaloc(list,calloption,parasym,cgpara) duplicateparaloc(list,calloption,parasym,cgpara)

View File

@ -166,7 +166,8 @@ implementation
LOC_CREFERENCE : LOC_CREFERENCE :
begin begin
size:=align(left.resulttype.def.size,tempcgpara.alignment); size:=align(left.resulttype.def.size,tempcgpara.alignment);
if tempcgpara.location^.reference.index=NR_STACK_POINTER_REG then if (not use_fixed_stack) and
(tempcgpara.location^.reference.index=NR_STACK_POINTER_REG) then
cg.a_param_ref(exprasmlist,left.location.size,left.location.reference,tempcgpara) cg.a_param_ref(exprasmlist,left.location.size,left.location.reference,tempcgpara)
else else
begin begin
@ -696,10 +697,8 @@ implementation
callerparaloc, callerparaloc,
tmpparaloc : pcgparalocation; tmpparaloc : pcgparalocation;
sizeleft: aint; sizeleft: aint;
{$ifdef cputargethasfixedstack}
htempref, htempref,
href : treference; href : treference;
{$endif cputargethasfixedstack}
begin begin
{ copy all resources to the allocated registers } { copy all resources to the allocated registers }
ppn:=tcgcallparanode(left); ppn:=tcgcallparanode(left);
@ -750,37 +749,38 @@ implementation
end; end;
LOC_REFERENCE: LOC_REFERENCE:
begin begin
{$ifdef cputargethasfixedstack} if use_fixed_stack then
{ Can't have a data copied to the stack, every location begin
must contain a valid size field } { Can't have a data copied to the stack, every location
must contain a valid size field }
if (ppn.tempcgpara.size=OS_NO) and if (ppn.tempcgpara.size=OS_NO) and
((tmpparaloc^.loc<>LOC_REFERENCE) or ((tmpparaloc^.loc<>LOC_REFERENCE) or
assigned(tmpparaloc^.next)) then assigned(tmpparaloc^.next)) then
internalerror(200501281); internalerror(200501281);
reference_reset_base(href,callerparaloc^.reference.index,callerparaloc^.reference.offset); reference_reset_base(href,callerparaloc^.reference.index,callerparaloc^.reference.offset);
{ copy parameters in case they were moved to a temp. location because we've a fixed stack } { copy parameters in case they were moved to a temp. location because we've a fixed stack }
case tmpparaloc^.loc of case tmpparaloc^.loc of
LOC_REFERENCE: LOC_REFERENCE:
begin begin
reference_reset_base(htempref,tmpparaloc^.reference.index,tmpparaloc^.reference.offset); reference_reset_base(htempref,tmpparaloc^.reference.index,tmpparaloc^.reference.offset);
{ use concatcopy, because it can also be a float which fails when { use concatcopy, because it can also be a float which fails when
load_ref_ref is used } load_ref_ref is used }
if (ppn.tempcgpara.size <> OS_NO) then if (ppn.tempcgpara.size <> OS_NO) then
cg.g_concatcopy(exprasmlist,htempref,href,tcgsize2size[tmpparaloc^.size]) cg.g_concatcopy(exprasmlist,htempref,href,tcgsize2size[tmpparaloc^.size])
else else
cg.g_concatcopy(exprasmlist,htempref,href,sizeleft) cg.g_concatcopy(exprasmlist,htempref,href,sizeleft)
end; end;
LOC_REGISTER: LOC_REGISTER:
cg.a_load_reg_ref(exprasmlist,tmpparaloc^.size,tmpparaloc^.size,tmpparaloc^.register,href); cg.a_load_reg_ref(exprasmlist,tmpparaloc^.size,tmpparaloc^.size,tmpparaloc^.register,href);
LOC_FPUREGISTER: LOC_FPUREGISTER:
cg.a_loadfpu_reg_ref(exprasmlist,tmpparaloc^.size,tmpparaloc^.register,href); cg.a_loadfpu_reg_ref(exprasmlist,tmpparaloc^.size,tmpparaloc^.register,href);
LOC_MMREGISTER: LOC_MMREGISTER:
cg.a_loadmm_reg_ref(exprasmlist,tmpparaloc^.size,tmpparaloc^.size,tmpparaloc^.register,href,mms_movescalar); cg.a_loadmm_reg_ref(exprasmlist,tmpparaloc^.size,tmpparaloc^.size,tmpparaloc^.register,href,mms_movescalar);
else else
internalerror(200402081); internalerror(200402081);
end;
end; end;
{$endif cputargethasfixedstack}
end; end;
end; end;
dec(sizeleft,tcgsize2size[tmpparaloc^.size]); dec(sizeleft,tcgsize2size[tmpparaloc^.size]);

View File

@ -200,9 +200,8 @@ implementation
LOC_REFERENCE, LOC_REFERENCE,
LOC_CREFERENCE : LOC_CREFERENCE :
begin begin
{$ifdef cputargethasfixedstack} if use_fixed_stack then
location_freetemp(list,location); location_freetemp(list,location);
{$endif cputargethasfixedstack}
end; end;
else else
internalerror(2004110211); internalerror(2004110211);

View File

@ -251,9 +251,7 @@ implementation
procedure tparamanager.freeparaloc(list: taasmoutput; const cgpara: TCGPara); procedure tparamanager.freeparaloc(list: taasmoutput; const cgpara: TCGPara);
var var
paraloc : Pcgparalocation; paraloc : Pcgparalocation;
{$ifdef cputargethasfixedstack}
href : treference; href : treference;
{$endif cputargethasfixedstack}
begin begin
paraloc:=cgpara.location; paraloc:=cgpara.location;
while assigned(paraloc) do while assigned(paraloc) do
@ -282,13 +280,14 @@ implementation
LOC_REFERENCE, LOC_REFERENCE,
LOC_CREFERENCE : LOC_CREFERENCE :
begin begin
{$ifdef cputargethasfixedstack} if use_fixed_stack then
{ don't use reference_reset_base, because that will depend on cgobj } begin
fillchar(href,sizeof(href),0); { don't use reference_reset_base, because that will depend on cgobj }
href.base:=paraloc^.reference.index; fillchar(href,sizeof(href),0);
href.offset:=paraloc^.reference.offset; href.base:=paraloc^.reference.index;
tg.ungettemp(list,href); href.offset:=paraloc^.reference.offset;
{$endif cputargethasfixedstack} tg.ungettemp(list,href);
end;
end; end;
else else
internalerror(2004110212); internalerror(2004110212);