mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 17:29:11 +02:00
* factored out creating a single paraloc, so we can reuse it for creating
function return locations git-svn-id: trunk@30201 -
This commit is contained in:
parent
f0ee1a9ee3
commit
25340480b0
@ -54,6 +54,7 @@ type
|
|||||||
var curintreg, curfloatreg, curmmreg: tsuperregister; var
|
var curintreg, curfloatreg, curmmreg: tsuperregister; var
|
||||||
cur_stack_offset: aword; isVararg : boolean): longint;
|
cur_stack_offset: aword; isVararg : boolean): longint;
|
||||||
function parseparaloc(p: tparavarsym; const s: string): boolean; override;
|
function parseparaloc(p: tparavarsym; const s: string): boolean; override;
|
||||||
|
procedure create_paraloc_for_def(var para: TCGPara; varspez: tvarspez; paradef: tdef; var nextfloatreg, nextintreg: tsuperregister; var stack_offset: longint; const isVararg, forceintmem: boolean; const side: tcallercallee; const p: tabstractprocdef);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -258,22 +259,12 @@ function tppcparamanager.create_paraloc_info_intern(p: tabstractprocdef; side:
|
|||||||
var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset:
|
var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset:
|
||||||
aword; isVararg : boolean): longint;
|
aword; isVararg : boolean): longint;
|
||||||
var
|
var
|
||||||
fsym: tfieldvarsym;
|
|
||||||
stack_offset: longint;
|
stack_offset: longint;
|
||||||
paralen: aint;
|
|
||||||
nextintreg, nextfloatreg, nextmmreg : tsuperregister;
|
nextintreg, nextfloatreg, nextmmreg : tsuperregister;
|
||||||
tmpdef,
|
|
||||||
locdef,
|
|
||||||
paradef: tdef;
|
|
||||||
paraloc: pcgparalocation;
|
|
||||||
i: integer;
|
i: integer;
|
||||||
hp: tparavarsym;
|
hp: tparavarsym;
|
||||||
loc: tcgloc;
|
paraloc: pcgparalocation;
|
||||||
paracgsize: tcgsize;
|
delphi_nestedfp: boolean;
|
||||||
|
|
||||||
parashift : byte;
|
|
||||||
firstparaloc,
|
|
||||||
adjusttail: boolean;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF extdebug}
|
{$IFDEF extdebug}
|
||||||
@ -288,19 +279,16 @@ begin
|
|||||||
stack_offset := cur_stack_offset;
|
stack_offset := cur_stack_offset;
|
||||||
|
|
||||||
for i := 0 to paras.count - 1 do begin
|
for i := 0 to paras.count - 1 do begin
|
||||||
parashift := 0;
|
|
||||||
hp := tparavarsym(paras[i]);
|
hp := tparavarsym(paras[i]);
|
||||||
|
|
||||||
paradef := hp.vardef;
|
|
||||||
locdef := nil;
|
|
||||||
{ Syscall for Morphos can have already a paraloc set; not supported on ppc64 }
|
{ Syscall for Morphos can have already a paraloc set; not supported on ppc64 }
|
||||||
if (vo_has_explicit_paraloc in hp.varoptions) then begin
|
if (vo_has_explicit_paraloc in hp.varoptions) then begin
|
||||||
internalerror(200412153);
|
internalerror(200412153);
|
||||||
end;
|
end;
|
||||||
hp.paraloc[side].reset;
|
|
||||||
{ currently only support C-style array of const }
|
{ currently only support C-style array of const }
|
||||||
if (p.proccalloption in [pocall_cdecl, pocall_cppdecl]) and
|
if (p.proccalloption in [pocall_cdecl, pocall_cppdecl]) and
|
||||||
is_array_of_const(paradef) then begin
|
is_array_of_const(hp.vardef) then begin
|
||||||
paraloc := hp.paraloc[side].add_location;
|
paraloc := hp.paraloc[side].add_location;
|
||||||
{ hack: the paraloc must be valid, but is not actually used }
|
{ hack: the paraloc must be valid, but is not actually used }
|
||||||
paraloc^.loc := LOC_REGISTER;
|
paraloc^.loc := LOC_REGISTER;
|
||||||
@ -309,8 +297,35 @@ begin
|
|||||||
paraloc^.def := voidpointertype;
|
paraloc^.def := voidpointertype;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
delphi_nestedfp:=(vo_is_parentfp in hp.varoptions) and (po_delphi_nested_cc in p.procoptions);
|
||||||
|
create_paraloc_for_def(hp.paraloc[side], hp.varspez, hp.vardef,
|
||||||
|
nextfloatreg, nextintreg, stack_offset, isVararg, delphi_nestedfp, side, p);
|
||||||
|
end;
|
||||||
|
|
||||||
if push_addr_param(hp.varspez, paradef, p.proccalloption) then begin
|
curintreg := nextintreg;
|
||||||
|
curfloatreg := nextfloatreg;
|
||||||
|
curmmreg := nextmmreg;
|
||||||
|
cur_stack_offset := stack_offset;
|
||||||
|
result := stack_offset;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure tppcparamanager.create_paraloc_for_def(var para: TCGPara; varspez: tvarspez; paradef: tdef; var nextfloatreg, nextintreg: tsuperregister; var stack_offset: longint; const isVararg, forceintmem: boolean; const side: tcallercallee; const p: tabstractprocdef);
|
||||||
|
var
|
||||||
|
adjusttail: boolean;
|
||||||
|
firstparaloc: boolean;
|
||||||
|
paracgsize: tcgsize;
|
||||||
|
loc: tcgloc;
|
||||||
|
paraloc: pcgparalocation;
|
||||||
|
locdef,
|
||||||
|
tmpdef: tdef;
|
||||||
|
paralen: aint;
|
||||||
|
fsym: tfieldvarsym;
|
||||||
|
parashift: byte;
|
||||||
|
begin
|
||||||
|
locdef:=nil;
|
||||||
|
parashift := 0;
|
||||||
|
para.reset;
|
||||||
|
if push_addr_param(varspez, paradef, p.proccalloption) then begin
|
||||||
paradef := getpointerdef(paradef);
|
paradef := getpointerdef(paradef);
|
||||||
loc := LOC_REGISTER;
|
loc := LOC_REGISTER;
|
||||||
paracgsize := OS_ADDR;
|
paracgsize := OS_ADDR;
|
||||||
@ -321,11 +336,11 @@ begin
|
|||||||
else
|
else
|
||||||
paralen := tcgsize2size[def_cgsize(paradef)];
|
paralen := tcgsize2size[def_cgsize(paradef)];
|
||||||
if (paradef.typ = recorddef) and
|
if (paradef.typ = recorddef) and
|
||||||
(hp.varspez in [vs_value, vs_const]) then begin
|
(varspez in [vs_value, vs_const]) then begin
|
||||||
{ if a record has only one field and that field is }
|
{ if a record has only one field and that field is }
|
||||||
{ non-composite (not array or record), it must be }
|
{ non-composite (not array or record), it must be }
|
||||||
{ passed according to the rules of that type. }
|
{ passed according to the rules of that type. }
|
||||||
if tabstractrecordsymtable(tabstractrecorddef(hp.vardef).symtable).has_single_field(fsym) and
|
if tabstractrecordsymtable(tabstractrecorddef(paradef).symtable).has_single_field(fsym) and
|
||||||
((fsym.vardef.typ = floatdef) or
|
((fsym.vardef.typ = floatdef) or
|
||||||
(not(target_info.system in systems_aix) and
|
(not(target_info.system in systems_aix) and
|
||||||
(fsym.vardef.typ in [orddef, enumdef]))) then begin
|
(fsym.vardef.typ in [orddef, enumdef]))) then begin
|
||||||
@ -370,13 +385,13 @@ begin
|
|||||||
paracgsize := OS_32;
|
paracgsize := OS_32;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
hp.paraloc[side].alignment := std_param_align;
|
para.alignment := std_param_align;
|
||||||
hp.paraloc[side].size := paracgsize;
|
para.size := paracgsize;
|
||||||
hp.paraloc[side].intsize := paralen;
|
para.intsize := paralen;
|
||||||
hp.paraloc[side].def := paradef;
|
para.def := paradef;
|
||||||
if (paralen = 0) then
|
if (paralen = 0) then
|
||||||
if (paradef.typ = recorddef) then begin
|
if (paradef.typ = recorddef) then begin
|
||||||
paraloc := hp.paraloc[side].add_location;
|
paraloc := para.add_location;
|
||||||
paraloc^.loc := LOC_VOID;
|
paraloc^.loc := LOC_VOID;
|
||||||
end else
|
end else
|
||||||
internalerror(2005011310);
|
internalerror(2005011310);
|
||||||
@ -386,13 +401,12 @@ begin
|
|||||||
firstparaloc:=true;
|
firstparaloc:=true;
|
||||||
{ can become < 0 for e.g. 3-byte records }
|
{ can become < 0 for e.g. 3-byte records }
|
||||||
while (paralen > 0) do begin
|
while (paralen > 0) do begin
|
||||||
paraloc := hp.paraloc[side].add_location;
|
paraloc := para.add_location;
|
||||||
{ In case of po_delphi_nested_cc, the parent frame pointer
|
{ In case of po_delphi_nested_cc, the parent frame pointer
|
||||||
is always passed on the stack. }
|
is always passed on the stack. }
|
||||||
if (loc = LOC_REGISTER) and
|
if (loc = LOC_REGISTER) and
|
||||||
(nextintreg <= RS_R10) and
|
(nextintreg <= RS_R10) and
|
||||||
(not(vo_is_parentfp in hp.varoptions) or
|
not forceintmem then begin
|
||||||
not(po_delphi_nested_cc in p.procoptions)) then begin
|
|
||||||
paraloc^.loc := loc;
|
paraloc^.loc := loc;
|
||||||
paraloc^.shiftval := parashift;
|
paraloc^.shiftval := parashift;
|
||||||
|
|
||||||
@ -406,10 +420,11 @@ begin
|
|||||||
{ aix requires that record data (including partial data) stored in
|
{ aix requires that record data (including partial data) stored in
|
||||||
parameter registers is left-aligned. Other targets only do this if
|
parameter registers is left-aligned. Other targets only do this if
|
||||||
the total size of the parameter was > 8 bytes. }
|
the total size of the parameter was > 8 bytes. }
|
||||||
if (((target_info.system in systems_aix) and
|
if (target_info.endian=endian_big) and
|
||||||
|
((((target_info.system in systems_aix) and
|
||||||
(paradef.typ = recorddef)) or
|
(paradef.typ = recorddef)) or
|
||||||
adjusttail) and
|
adjusttail) and
|
||||||
(paralen < sizeof(aint)) then
|
(paralen < sizeof(aint))) then
|
||||||
begin
|
begin
|
||||||
paraloc^.shiftval := (sizeof(aint)-paralen)*(-8);
|
paraloc^.shiftval := (sizeof(aint)-paralen)*(-8);
|
||||||
paraloc^.size := OS_INT;
|
paraloc^.size := OS_INT;
|
||||||
@ -491,13 +506,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
curintreg := nextintreg;
|
|
||||||
curfloatreg := nextfloatreg;
|
|
||||||
curmmreg := nextmmreg;
|
|
||||||
cur_stack_offset := stack_offset;
|
|
||||||
result := stack_offset;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function tppcparamanager.create_varargs_paraloc_info(p: tabstractprocdef;
|
function tppcparamanager.create_varargs_paraloc_info(p: tabstractprocdef;
|
||||||
varargspara: tvarargsparalist): longint;
|
varargspara: tvarargsparalist): longint;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user