mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 23:19:24 +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
|
||||
cur_stack_offset: aword; isVararg : boolean): longint;
|
||||
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;
|
||||
|
||||
implementation
|
||||
@ -258,22 +259,12 @@ function tppcparamanager.create_paraloc_info_intern(p: tabstractprocdef; side:
|
||||
var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset:
|
||||
aword; isVararg : boolean): longint;
|
||||
var
|
||||
fsym: tfieldvarsym;
|
||||
stack_offset: longint;
|
||||
paralen: aint;
|
||||
nextintreg, nextfloatreg, nextmmreg : tsuperregister;
|
||||
tmpdef,
|
||||
locdef,
|
||||
paradef: tdef;
|
||||
paraloc: pcgparalocation;
|
||||
i: integer;
|
||||
hp: tparavarsym;
|
||||
loc: tcgloc;
|
||||
paracgsize: tcgsize;
|
||||
|
||||
parashift : byte;
|
||||
firstparaloc,
|
||||
adjusttail: boolean;
|
||||
paraloc: pcgparalocation;
|
||||
delphi_nestedfp: boolean;
|
||||
|
||||
begin
|
||||
{$IFDEF extdebug}
|
||||
@ -288,19 +279,16 @@ begin
|
||||
stack_offset := cur_stack_offset;
|
||||
|
||||
for i := 0 to paras.count - 1 do begin
|
||||
parashift := 0;
|
||||
hp := tparavarsym(paras[i]);
|
||||
|
||||
paradef := hp.vardef;
|
||||
locdef := nil;
|
||||
{ Syscall for Morphos can have already a paraloc set; not supported on ppc64 }
|
||||
if (vo_has_explicit_paraloc in hp.varoptions) then begin
|
||||
internalerror(200412153);
|
||||
end;
|
||||
hp.paraloc[side].reset;
|
||||
|
||||
{ currently only support C-style array of const }
|
||||
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;
|
||||
{ hack: the paraloc must be valid, but is not actually used }
|
||||
paraloc^.loc := LOC_REGISTER;
|
||||
@ -309,8 +297,35 @@ begin
|
||||
paraloc^.def := voidpointertype;
|
||||
break;
|
||||
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);
|
||||
loc := LOC_REGISTER;
|
||||
paracgsize := OS_ADDR;
|
||||
@ -321,11 +336,11 @@ begin
|
||||
else
|
||||
paralen := tcgsize2size[def_cgsize(paradef)];
|
||||
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 }
|
||||
{ non-composite (not array or record), it must be }
|
||||
{ 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
|
||||
(not(target_info.system in systems_aix) and
|
||||
(fsym.vardef.typ in [orddef, enumdef]))) then begin
|
||||
@ -370,13 +385,13 @@ begin
|
||||
paracgsize := OS_32;
|
||||
end;
|
||||
|
||||
hp.paraloc[side].alignment := std_param_align;
|
||||
hp.paraloc[side].size := paracgsize;
|
||||
hp.paraloc[side].intsize := paralen;
|
||||
hp.paraloc[side].def := paradef;
|
||||
para.alignment := std_param_align;
|
||||
para.size := paracgsize;
|
||||
para.intsize := paralen;
|
||||
para.def := paradef;
|
||||
if (paralen = 0) then
|
||||
if (paradef.typ = recorddef) then begin
|
||||
paraloc := hp.paraloc[side].add_location;
|
||||
paraloc := para.add_location;
|
||||
paraloc^.loc := LOC_VOID;
|
||||
end else
|
||||
internalerror(2005011310);
|
||||
@ -386,13 +401,12 @@ begin
|
||||
firstparaloc:=true;
|
||||
{ can become < 0 for e.g. 3-byte records }
|
||||
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
|
||||
is always passed on the stack. }
|
||||
if (loc = LOC_REGISTER) and
|
||||
(nextintreg <= RS_R10) and
|
||||
(not(vo_is_parentfp in hp.varoptions) or
|
||||
not(po_delphi_nested_cc in p.procoptions)) then begin
|
||||
not forceintmem then begin
|
||||
paraloc^.loc := loc;
|
||||
paraloc^.shiftval := parashift;
|
||||
|
||||
@ -406,10 +420,11 @@ begin
|
||||
{ aix requires that record data (including partial data) stored in
|
||||
parameter registers is left-aligned. Other targets only do this if
|
||||
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
|
||||
adjusttail) and
|
||||
(paralen < sizeof(aint)) then
|
||||
(paralen < sizeof(aint))) then
|
||||
begin
|
||||
paraloc^.shiftval := (sizeof(aint)-paralen)*(-8);
|
||||
paraloc^.size := OS_INT;
|
||||
@ -491,13 +506,6 @@ begin
|
||||
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;
|
||||
varargspara: tvarargsparalist): longint;
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user