* abstractprocdef.para_size needs alignment parameter

* secondcallparan gets para_alignment size instead of dword_align
This commit is contained in:
peter 2000-01-26 12:02:29 +00:00
parent c8469b68ea
commit 62df907953
5 changed files with 60 additions and 44 deletions

View File

@ -29,7 +29,7 @@ interface
symtable,tree; symtable,tree;
procedure secondcallparan(var p : ptree;defcoll : pparaitem; procedure secondcallparan(var p : ptree;defcoll : pparaitem;
push_from_left_to_right,inlined,dword_align : boolean;para_offset : longint); push_from_left_to_right,inlined : boolean;para_alignment,para_offset : longint);
procedure secondcalln(var p : ptree); procedure secondcalln(var p : ptree);
procedure secondprocinline(var p : ptree); procedure secondprocinline(var p : ptree);
@ -52,7 +52,7 @@ implementation
*****************************************************************************} *****************************************************************************}
procedure secondcallparan(var p : ptree;defcoll : pparaitem; procedure secondcallparan(var p : ptree;defcoll : pparaitem;
push_from_left_to_right,inlined,dword_align : boolean;para_offset : longint); push_from_left_to_right,inlined : boolean;para_alignment,para_offset : longint);
procedure maybe_push_high; procedure maybe_push_high;
begin begin
@ -74,15 +74,18 @@ implementation
var var
otlabel,oflabel : pasmlabel; otlabel,oflabel : pasmlabel;
align : longint;
{ temporary variables: } { temporary variables: }
tempdeftype : tdeftype; tempdeftype : tdeftype;
r : preference; r : preference;
begin begin
{ set default para_alignment to target_os.stackalignment }
if para_alignment=0 then
para_alignment:=target_os.stackalignment;
{ push from left to right if specified } { push from left to right if specified }
if push_from_left_to_right and assigned(p^.right) then if push_from_left_to_right and assigned(p^.right) then
secondcallparan(p^.right,pparaitem(defcoll^.next),push_from_left_to_right, secondcallparan(p^.right,pparaitem(defcoll^.next),push_from_left_to_right,
inlined,dword_align,para_offset); inlined,para_alignment,para_offset);
otlabel:=truelabel; otlabel:=truelabel;
oflabel:=falselabel; oflabel:=falselabel;
getlabel(truelabel); getlabel(truelabel);
@ -194,10 +197,7 @@ implementation
end end
else else
begin begin
align:=target_os.stackalignment; push_value_para(p^.left,inlined,para_offset,para_alignment);
if dword_align then
align:=4;
push_value_para(p^.left,inlined,para_offset,align);
end; end;
end; end;
truelabel:=otlabel; truelabel:=otlabel;
@ -205,7 +205,7 @@ implementation
{ push from right to left } { push from right to left }
if not push_from_left_to_right and assigned(p^.right) then if not push_from_left_to_right and assigned(p^.right) then
secondcallparan(p^.right,pparaitem(defcoll^.next),push_from_left_to_right, secondcallparan(p^.right,pparaitem(defcoll^.next),push_from_left_to_right,
inlined,dword_align,para_offset); inlined,para_alignment,para_offset);
end; end;
@ -239,6 +239,7 @@ implementation
pp,params : ptree; pp,params : ptree;
inlined : boolean; inlined : boolean;
inlinecode : ptree; inlinecode : ptree;
para_alignment,
para_offset : longint; para_offset : longint;
{ instruction for alignement correction } { instruction for alignement correction }
{ corr : paicpu;} { corr : paicpu;}
@ -261,6 +262,12 @@ implementation
unusedregisters:=unused; unusedregisters:=unused;
usablecount:=usablereg32; usablecount:=usablereg32;
if (pocall_cdecl in p^.procdefinition^.proccalloptions) or
(pocall_stdcall in p^.procdefinition^.proccalloptions) then
para_alignment:=4
else
para_alignment:=target_os.stackalignment;
if not assigned(p^.procdefinition) then if not assigned(p^.procdefinition) then
exit; exit;
if (pocall_inline in p^.procdefinition^.proccalloptions) then if (pocall_inline in p^.procdefinition^.proccalloptions) then
@ -343,7 +350,7 @@ implementation
if i>0 then if i>0 then
inc(pop_size,4-i); inc(pop_size,4-i);
{ This parasize aligned on 4 ? } { This parasize aligned on 4 ? }
i:=p^.procdefinition^.para_size and 3; i:=p^.procdefinition^.para_size(para_alignment) and 3;
if i>0 then if i>0 then
inc(pop_size,4-i); inc(pop_size,4-i);
{ insert the opcode and update pushedparasize } { insert the opcode and update pushedparasize }
@ -396,17 +403,11 @@ implementation
if assigned(p^.right) then if assigned(p^.right) then
secondcallparan(p^.left,pparaitem(pabstractprocdef(p^.right^.resulttype)^.para^.first), secondcallparan(p^.left,pparaitem(pabstractprocdef(p^.right^.resulttype)^.para^.first),
(pocall_leftright in p^.procdefinition^.proccalloptions), (pocall_leftright in p^.procdefinition^.proccalloptions),
inlined, inlined,para_alignment,para_offset)
(pocall_cdecl in p^.procdefinition^.proccalloptions) or
(pocall_stdcall in p^.procdefinition^.proccalloptions),
para_offset)
else else
secondcallparan(p^.left,pparaitem(p^.procdefinition^.para^.first), secondcallparan(p^.left,pparaitem(p^.procdefinition^.para^.first),
(pocall_leftright in p^.procdefinition^.proccalloptions), (pocall_leftright in p^.procdefinition^.proccalloptions),
inlined, inlined,para_alignment,para_offset);
(pocall_cdecl in p^.procdefinition^.proccalloptions) or
(pocall_stdcall in p^.procdefinition^.proccalloptions),
para_offset);
end; end;
params:=p^.left; params:=p^.left;
p^.left:=nil; p^.left:=nil;
@ -1332,7 +1333,11 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.121 2000-01-23 18:50:07 peter Revision 1.122 2000-01-26 12:02:29 peter
* abstractprocdef.para_size needs alignment parameter
* secondcallparan gets para_alignment size instead of dword_align
Revision 1.121 2000/01/23 18:50:07 peter
* fixed missing push esi for constructor calling * fixed missing push esi for constructor calling
Revision 1.120 2000/01/21 22:06:16 florian Revision 1.120 2000/01/21 22:06:16 florian

View File

@ -338,7 +338,7 @@ implementation
else else
if (is_chararray(hp^.resulttype)) then if (is_chararray(hp^.resulttype)) then
dummycoll.paratype.setdef(openchararraydef); dummycoll.paratype.setdef(openchararraydef);
secondcallparan(hp,@dummycoll,false,false,false,0); secondcallparan(hp,@dummycoll,false,false,0,0);
if ft=ft_typed then if ft=ft_typed then
never_copy_const_param:=false; never_copy_const_param:=false;
end; end;
@ -382,7 +382,7 @@ implementation
hp^.right:=nil; hp^.right:=nil;
dummycoll.paratype.setdef(hp^.resulttype); dummycoll.paratype.setdef(hp^.resulttype);
dummycoll.paratyp:=vs_value; dummycoll.paratyp:=vs_value;
secondcallparan(hp,@dummycoll,false,false,false,0); secondcallparan(hp,@dummycoll,false,false,0,0);
hp^.right:=node; hp^.right:=node;
if codegenerror then if codegenerror then
exit; exit;
@ -400,7 +400,7 @@ implementation
hp^.right:=nil; hp^.right:=nil;
dummycoll.paratype.setdef(hp^.resulttype); dummycoll.paratype.setdef(hp^.resulttype);
dummycoll.paratyp:=vs_value; dummycoll.paratyp:=vs_value;
secondcallparan(hp,@dummycoll,false,false,false,0); secondcallparan(hp,@dummycoll,false,false,0,0);
hp^.right:=node; hp^.right:=node;
if pararesult^.deftype<>floatdef then if pararesult^.deftype<>floatdef then
CGMessage(parser_e_illegal_colon_qualifier); CGMessage(parser_e_illegal_colon_qualifier);
@ -562,7 +562,7 @@ implementation
else else
dummycoll.paratype.setdef(hp^.resulttype); dummycoll.paratype.setdef(hp^.resulttype);
procedureprefix:='FPC_'+pstringdef(hp^.resulttype)^.stringtypname+'_'; procedureprefix:='FPC_'+pstringdef(hp^.resulttype)^.stringtypname+'_';
secondcallparan(hp,@dummycoll,false,false,false,0); secondcallparan(hp,@dummycoll,false,false,0,0);
if codegenerror then if codegenerror then
exit; exit;
@ -584,9 +584,7 @@ implementation
begin begin
dummycoll.paratype.setdef(hp^.resulttype); dummycoll.paratype.setdef(hp^.resulttype);
dummycoll.paratyp:=vs_value; dummycoll.paratyp:=vs_value;
secondcallparan(hp,@dummycoll,false secondcallparan(hp,@dummycoll,false,false,0,0);
,false,false,0
);
if codegenerror then if codegenerror then
exit; exit;
disposetree(hp); disposetree(hp);
@ -603,9 +601,7 @@ implementation
begin begin
dummycoll.paratype.setdef(hp^.resulttype); dummycoll.paratype.setdef(hp^.resulttype);
dummycoll.paratyp:=vs_value; dummycoll.paratyp:=vs_value;
secondcallparan(hp,@dummycoll,false secondcallparan(hp,@dummycoll,false,false,0,0);
,false,false,0
);
if codegenerror then if codegenerror then
exit; exit;
disposetree(hp); disposetree(hp);
@ -629,9 +625,7 @@ implementation
{ last arg longint or real } { last arg longint or real }
dummycoll.paratype.setdef(hp^.resulttype); dummycoll.paratype.setdef(hp^.resulttype);
dummycoll.paratyp:=vs_value; dummycoll.paratyp:=vs_value;
secondcallparan(hp,@dummycoll,false secondcallparan(hp,@dummycoll,false,false,0,0);
,false,false,0
);
if codegenerror then if codegenerror then
exit; exit;
@ -701,7 +695,7 @@ implementation
{load and push the address of the destination} {load and push the address of the destination}
dummycoll.paratyp:=vs_var; dummycoll.paratyp:=vs_var;
dummycoll.paratype.setdef(dest_para^.resulttype); dummycoll.paratype.setdef(dest_para^.resulttype);
secondcallparan(dest_para,@dummycoll,false,false,false,0); secondcallparan(dest_para,@dummycoll,false,false,0,0);
if codegenerror then if codegenerror then
exit; exit;
@ -715,7 +709,7 @@ implementation
Begin Begin
dummycoll.paratyp:=vs_var; dummycoll.paratyp:=vs_var;
dummycoll.paratype.setdef(code_para^.resulttype); dummycoll.paratype.setdef(code_para^.resulttype);
secondcallparan(code_para,@dummycoll,false,false,false,0); secondcallparan(code_para,@dummycoll,false,false,0,0);
if codegenerror then if codegenerror then
exit; exit;
Disposetree(code_para); Disposetree(code_para);
@ -730,7 +724,7 @@ implementation
{node = first parameter = string} {node = first parameter = string}
dummycoll.paratyp:=vs_const; dummycoll.paratyp:=vs_const;
dummycoll.paratype.setdef(node^.resulttype); dummycoll.paratype.setdef(node^.resulttype);
secondcallparan(node,@dummycoll,false,false,false,0); secondcallparan(node,@dummycoll,false,false,0,0);
if codegenerror then if codegenerror then
exit; exit;
@ -1513,7 +1507,11 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.91 2000-01-24 20:11:10 florian Revision 1.92 2000-01-26 12:02:29 peter
* abstractprocdef.para_size needs alignment parameter
* secondcallparan gets para_alignment size instead of dword_align
Revision 1.91 2000/01/24 20:11:10 florian
* internalerror 10 for inlined math functions fixed * internalerror 10 for inlined math functions fixed
Revision 1.90 2000/01/09 23:16:05 peter Revision 1.90 2000/01/09 23:16:05 peter
@ -1659,4 +1657,4 @@ end.
* some fixes for qword * some fixes for qword
* start of register calling conventions * start of register calling conventions
} }

View File

@ -2372,7 +2372,7 @@
end; end;
function tabstractprocdef.para_size : longint; function tabstractprocdef.para_size(alignsize:longint) : longint;
var var
pdc : pparaitem; pdc : pparaitem;
l : longint; l : longint;
@ -2387,8 +2387,9 @@
vs_const : if push_addr_param(pdc^.paratype.def) then vs_const : if push_addr_param(pdc^.paratype.def) then
inc(l,target_os.size_of_pointer) inc(l,target_os.size_of_pointer)
else else
inc(l,align(pdc^.paratype.def^.size,target_os.stackalignment)); inc(l,pdc^.paratype.def^.size);
end; end;
l:=align(l,alignsize);
pdc:=pparaitem(pdc^.next); pdc:=pparaitem(pdc^.next);
end; end;
para_size:=l; para_size:=l;
@ -3858,7 +3859,11 @@ Const local_symtable_index : longint = $8001;
{ {
$Log$ $Log$
Revision 1.188 2000-01-23 16:35:31 peter Revision 1.189 2000-01-26 12:02:29 peter
* abstractprocdef.para_size needs alignment parameter
* secondcallparan gets para_alignment size instead of dword_align
Revision 1.188 2000/01/23 16:35:31 peter
* localbrowser loading of absolute fixed. It needed a symtablestack * localbrowser loading of absolute fixed. It needed a symtablestack
which was not setup correctly which was not setup correctly

View File

@ -346,7 +346,7 @@
procedure write;virtual; procedure write;virtual;
procedure deref;virtual; procedure deref;virtual;
procedure concatpara(tt:ttype;vsp : tvarspez); procedure concatpara(tt:ttype;vsp : tvarspez);
function para_size : longint; function para_size(alignsize:longint) : longint;
function demangled_paras : string; function demangled_paras : string;
function proccalloption2str : string; function proccalloption2str : string;
procedure test_if_fpu_result; procedure test_if_fpu_result;
@ -528,7 +528,11 @@
{ {
$Log$ $Log$
Revision 1.50 2000-01-07 01:14:40 peter Revision 1.51 2000-01-26 12:02:30 peter
* abstractprocdef.para_size needs alignment parameter
* secondcallparan gets para_alignment size instead of dword_align
Revision 1.50 2000/01/07 01:14:40 peter
* updated copyright to 2000 * updated copyright to 2000
Revision 1.49 2000/01/03 19:26:04 peter Revision 1.49 2000/01/03 19:26:04 peter

View File

@ -1298,7 +1298,7 @@ unit tree;
p^.inlineprocsym:=callp^.symtableprocentry; p^.inlineprocsym:=callp^.symtableprocentry;
p^.retoffset:=-4; { less dangerous as zero (PM) } p^.retoffset:=-4; { less dangerous as zero (PM) }
p^.para_offset:=0; p^.para_offset:=0;
p^.para_size:=p^.inlineprocsym^.definition^.para_size; p^.para_size:=p^.inlineprocsym^.definition^.para_size(target_os.stackalignment);
if ret_in_param(p^.inlineprocsym^.definition^.rettype.def) then if ret_in_param(p^.inlineprocsym^.definition^.rettype.def) then
p^.para_size:=p^.para_size+target_os.size_of_pointer; p^.para_size:=p^.para_size+target_os.size_of_pointer;
{ copy args } { copy args }
@ -1918,7 +1918,11 @@ unit tree;
end. end.
{ {
$Log$ $Log$
Revision 1.109 2000-01-09 23:16:07 peter Revision 1.110 2000-01-26 12:02:30 peter
* abstractprocdef.para_size needs alignment parameter
* secondcallparan gets para_alignment size instead of dword_align
Revision 1.109 2000/01/09 23:16:07 peter
* added st_default stringtype * added st_default stringtype
* genstringconstnode extended with stringtype parameter using st_default * genstringconstnode extended with stringtype parameter using st_default
will do the old behaviour will do the old behaviour