mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:09:20 +02:00
* parameter alignment fixes
This commit is contained in:
parent
8457961ba6
commit
3a92a2a25a
@ -138,7 +138,7 @@ interface
|
|||||||
{ directory where the utils can be found (options -FD) }
|
{ directory where the utils can be found (options -FD) }
|
||||||
utilsdirectory : dirstr;
|
utilsdirectory : dirstr;
|
||||||
{ targetname specific prefix used by these utils (options -XP<path>) }
|
{ targetname specific prefix used by these utils (options -XP<path>) }
|
||||||
utilsprefix : dirstr;
|
utilsprefix : dirstr;
|
||||||
|
|
||||||
{ some flags for global compiler switches }
|
{ some flags for global compiler switches }
|
||||||
do_build,
|
do_build,
|
||||||
@ -1513,8 +1513,6 @@ implementation
|
|||||||
b.recordalignmin:=l
|
b.recordalignmin:=l
|
||||||
else if tok='RECORDMAX' then
|
else if tok='RECORDMAX' then
|
||||||
b.recordalignmax:=l
|
b.recordalignmax:=l
|
||||||
else if tok='PARAALIGN' then
|
|
||||||
b.paraalign:=l
|
|
||||||
else { Error }
|
else { Error }
|
||||||
UpdateAlignmentStr:=false;
|
UpdateAlignmentStr:=false;
|
||||||
until false;
|
until false;
|
||||||
@ -1528,6 +1526,7 @@ implementation
|
|||||||
var_align := used_align(siz,aktalignment.varalignmin,aktalignment.varalignmax);
|
var_align := used_align(siz,aktalignment.varalignmin,aktalignment.varalignmax);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function const_align(siz: longint): longint;
|
function const_align(siz: longint): longint;
|
||||||
begin
|
begin
|
||||||
siz := size_2_align(siz);
|
siz := size_2_align(siz);
|
||||||
@ -1611,7 +1610,7 @@ implementation
|
|||||||
|
|
||||||
{ Utils directory }
|
{ Utils directory }
|
||||||
utilsdirectory:='';
|
utilsdirectory:='';
|
||||||
utilsprefix:='';
|
utilsprefix:='';
|
||||||
|
|
||||||
{ Search Paths }
|
{ Search Paths }
|
||||||
librarysearchpath:=TSearchPathList.Create;
|
librarysearchpath:=TSearchPathList.Create;
|
||||||
@ -1707,7 +1706,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.106 2003-10-03 14:16:48 marco
|
Revision 1.107 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.106 2003/10/03 14:16:48 marco
|
||||||
* -XP<prefix> support
|
* -XP<prefix> support
|
||||||
|
|
||||||
Revision 1.105 2003/10/02 21:16:18 peter
|
Revision 1.105 2003/10/02 21:16:18 peter
|
||||||
|
@ -44,6 +44,7 @@ unit cpupara;
|
|||||||
ti386paramanager = class(tparamanager)
|
ti386paramanager = class(tparamanager)
|
||||||
function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;override;
|
function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;override;
|
||||||
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
|
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
|
||||||
|
function get_para_align(calloption : tproccalloption):byte;override;
|
||||||
function get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;override;
|
function get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;override;
|
||||||
function get_volatile_registers_fpu(calloption : tproccalloption):tsuperregisterset;override;
|
function get_volatile_registers_fpu(calloption : tproccalloption):tsuperregisterset;override;
|
||||||
function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;override;
|
function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;override;
|
||||||
@ -141,6 +142,20 @@ unit cpupara;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function ti386paramanager.get_para_align(calloption : tproccalloption):byte;
|
||||||
|
begin
|
||||||
|
if calloption=pocall_oldfpccall then
|
||||||
|
begin
|
||||||
|
if target_info.system in [system_i386_go32v2,system_i386_watcom] then
|
||||||
|
result:=2
|
||||||
|
else
|
||||||
|
result:=4;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result:=std_param_align;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ti386paramanager.get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;
|
function ti386paramanager.get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;
|
||||||
begin
|
begin
|
||||||
case calloption of
|
case calloption of
|
||||||
@ -266,6 +281,7 @@ unit cpupara;
|
|||||||
else
|
else
|
||||||
paraloc.size:=def_cgsize(hp.paratype.def);
|
paraloc.size:=def_cgsize(hp.paratype.def);
|
||||||
paraloc.loc:=LOC_REFERENCE;
|
paraloc.loc:=LOC_REFERENCE;
|
||||||
|
paraloc.alignment:=p.paraalign;
|
||||||
paraloc.reference.index:=NR_FRAME_POINTER_REG;
|
paraloc.reference.index:=NR_FRAME_POINTER_REG;
|
||||||
l:=push_size(hp.paratyp,hp.paratype.def,p.proccalloption);
|
l:=push_size(hp.paratyp,hp.paratype.def,p.proccalloption);
|
||||||
varalign:=size_2_align(l);
|
varalign:=size_2_align(l);
|
||||||
@ -304,6 +320,7 @@ unit cpupara;
|
|||||||
paraloc.size:=OS_ADDR
|
paraloc.size:=OS_ADDR
|
||||||
else
|
else
|
||||||
paraloc.size:=def_cgsize(hp.paratype.def);
|
paraloc.size:=def_cgsize(hp.paratype.def);
|
||||||
|
paraloc.alignment:=p.paraalign;
|
||||||
is_64bit:=(paraloc.size in [OS_64,OS_S64,OS_F64]);
|
is_64bit:=(paraloc.size in [OS_64,OS_S64,OS_F64]);
|
||||||
{
|
{
|
||||||
EAX
|
EAX
|
||||||
@ -326,6 +343,7 @@ unit cpupara;
|
|||||||
subreg:=R_SUBWHOLE
|
subreg:=R_SUBWHOLE
|
||||||
else
|
else
|
||||||
subreg:=cgsize2subreg(paraloc.size);
|
subreg:=cgsize2subreg(paraloc.size);
|
||||||
|
paraloc.alignment:=p.paraalign;
|
||||||
paraloc.register:=newreg(R_INTREGISTER,parasupregs[parareg],subreg);
|
paraloc.register:=newreg(R_INTREGISTER,parasupregs[parareg],subreg);
|
||||||
inc(parareg);
|
inc(parareg);
|
||||||
end
|
end
|
||||||
@ -381,7 +399,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.35 2003-10-01 20:34:49 peter
|
Revision 1.36 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.35 2003/10/01 20:34:49 peter
|
||||||
* procinfo unit contains tprocinfo
|
* procinfo unit contains tprocinfo
|
||||||
* cginfo renamed to cgbase
|
* cginfo renamed to cgbase
|
||||||
* moved cgmessage to verbose
|
* moved cgmessage to verbose
|
||||||
|
@ -33,20 +33,36 @@ unit cpupi;
|
|||||||
|
|
||||||
type
|
type
|
||||||
ti386procinfo = class(tcgprocinfo)
|
ti386procinfo = class(tcgprocinfo)
|
||||||
|
function calc_stackframe_size:longint;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
cutils,
|
||||||
|
globals,
|
||||||
|
tgobj,
|
||||||
procinfo;
|
procinfo;
|
||||||
|
|
||||||
|
function ti386procinfo.calc_stackframe_size:longint;
|
||||||
|
begin
|
||||||
|
{ align to 4 bytes at least
|
||||||
|
otherwise all those subl $2,%esp are meaningless PM }
|
||||||
|
result:=Align(tg.direction*tg.lasttemp,min(aktalignment.localalignmin,4));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
cprocinfo:=ti386procinfo;
|
cprocinfo:=ti386procinfo;
|
||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.14 2003-10-01 20:34:49 peter
|
Revision 1.15 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.14 2003/10/01 20:34:49 peter
|
||||||
* procinfo unit contains tprocinfo
|
* procinfo unit contains tprocinfo
|
||||||
* cginfo renamed to cgbase
|
* cginfo renamed to cgbase
|
||||||
* moved cgmessage to verbose
|
* moved cgmessage to verbose
|
||||||
|
@ -160,7 +160,7 @@ interface
|
|||||||
procedure insert_typeconv(do_count : boolean);
|
procedure insert_typeconv(do_count : boolean);
|
||||||
procedure det_registers;
|
procedure det_registers;
|
||||||
procedure firstcallparan(do_count : boolean);
|
procedure firstcallparan(do_count : boolean);
|
||||||
procedure secondcallparan(calloption:tproccalloption;alignment:byte);virtual;abstract;
|
procedure secondcallparan;virtual;abstract;
|
||||||
function docompare(p: tnode): boolean; override;
|
function docompare(p: tnode): boolean; override;
|
||||||
procedure printnodetree(var t:text);override;
|
procedure printnodetree(var t:text);override;
|
||||||
end;
|
end;
|
||||||
@ -2544,7 +2544,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.187 2003-10-03 14:44:38 peter
|
Revision 1.188 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.187 2003/10/03 14:44:38 peter
|
||||||
* fix IE when callnode was firstpassed twice
|
* fix IE when callnode was firstpassed twice
|
||||||
|
|
||||||
Revision 1.186 2003/10/02 21:13:46 peter
|
Revision 1.186 2003/10/02 21:13:46 peter
|
||||||
|
@ -37,9 +37,9 @@ interface
|
|||||||
tempparaloc : tparalocation;
|
tempparaloc : tparalocation;
|
||||||
procedure allocate_tempparaloc;
|
procedure allocate_tempparaloc;
|
||||||
procedure push_addr_para;
|
procedure push_addr_para;
|
||||||
procedure push_value_para(calloption:tproccalloption;alignment:byte);
|
procedure push_value_para;
|
||||||
public
|
public
|
||||||
procedure secondcallparan(calloption:tproccalloption;alignment:byte);override;
|
procedure secondcallparan;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
tcgcallnode = class(tcallnode)
|
tcgcallnode = class(tcallnode)
|
||||||
@ -120,10 +120,11 @@ implementation
|
|||||||
location_release(exprasmlist,left.location);
|
location_release(exprasmlist,left.location);
|
||||||
allocate_tempparaloc;
|
allocate_tempparaloc;
|
||||||
cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
|
cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
|
||||||
|
inc(pushedparasize,POINTER_SIZE);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tcgcallparanode.push_value_para(calloption:tproccalloption;alignment:byte);
|
procedure tcgcallparanode.push_value_para;
|
||||||
var
|
var
|
||||||
href : treference;
|
href : treference;
|
||||||
{$ifdef i386}
|
{$ifdef i386}
|
||||||
@ -173,7 +174,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if tempparaloc.loc<>LOC_REFERENCE then
|
if tempparaloc.loc<>LOC_REFERENCE then
|
||||||
internalerror(200309291);
|
internalerror(200309291);
|
||||||
size:=align(tfloatdef(left.resulttype.def).size,alignment);
|
size:=align(tfloatdef(left.resulttype.def).size,aktcallnode.procdefinition.paraalign);
|
||||||
inc(pushedparasize,size);
|
inc(pushedparasize,size);
|
||||||
cg.g_stackpointer_alloc(exprasmlist,size);
|
cg.g_stackpointer_alloc(exprasmlist,size);
|
||||||
reference_reset_base(href,NR_STACK_POINTER_REG,0);
|
reference_reset_base(href,NR_STACK_POINTER_REG,0);
|
||||||
@ -182,12 +183,12 @@ implementation
|
|||||||
LOC_REFERENCE,
|
LOC_REFERENCE,
|
||||||
LOC_CREFERENCE :
|
LOC_CREFERENCE :
|
||||||
begin
|
begin
|
||||||
sizetopush:=align(left.resulttype.def.size,alignment);
|
sizetopush:=align(left.resulttype.def.size,aktcallnode.procdefinition.paraalign);
|
||||||
tempreference:=left.location.reference;
|
tempreference:=left.location.reference;
|
||||||
inc(tempreference.offset,sizetopush);
|
inc(tempreference.offset,sizetopush);
|
||||||
while (sizetopush>0) do
|
while (sizetopush>0) do
|
||||||
begin
|
begin
|
||||||
if sizetopush>=4 then
|
if (sizetopush>=4) or (aktcallnode.procdefinition.paraalign>=4) then
|
||||||
begin
|
begin
|
||||||
cgsize:=OS_32;
|
cgsize:=OS_32;
|
||||||
inc(pushedparasize,4);
|
inc(pushedparasize,4);
|
||||||
@ -224,7 +225,8 @@ implementation
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{ copy the value on the stack or use normal parameter push? }
|
{ copy the value on the stack or use normal parameter push? }
|
||||||
if paramanager.copy_value_on_stack(paraitem.paratyp,left.resulttype.def,calloption) then
|
if paramanager.copy_value_on_stack(paraitem.paratyp,left.resulttype.def,
|
||||||
|
aktcallnode.procdefinition.proccalloption) then
|
||||||
begin
|
begin
|
||||||
location_release(exprasmlist,left.location);
|
location_release(exprasmlist,left.location);
|
||||||
allocate_tempparaloc;
|
allocate_tempparaloc;
|
||||||
@ -234,7 +236,7 @@ implementation
|
|||||||
if not (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
|
if not (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
|
||||||
internalerror(200204241);
|
internalerror(200204241);
|
||||||
{ push on stack }
|
{ push on stack }
|
||||||
size:=align(left.resulttype.def.size,alignment);
|
size:=align(left.resulttype.def.size,aktcallnode.procdefinition.paraalign);
|
||||||
inc(pushedparasize,size);
|
inc(pushedparasize,size);
|
||||||
cg.g_stackpointer_alloc(exprasmlist,size);
|
cg.g_stackpointer_alloc(exprasmlist,size);
|
||||||
reference_reset_base(href,NR_STACK_POINTER_REG,0);
|
reference_reset_base(href,NR_STACK_POINTER_REG,0);
|
||||||
@ -278,7 +280,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
location_release(exprasmlist,left.location);
|
location_release(exprasmlist,left.location);
|
||||||
allocate_tempparaloc;
|
allocate_tempparaloc;
|
||||||
inc(pushedparasize,alignment);
|
inc(pushedparasize,aktcallnode.procdefinition.paraalign);
|
||||||
(*
|
(*
|
||||||
if calloption=pocall_inline then
|
if calloption=pocall_inline then
|
||||||
begin
|
begin
|
||||||
@ -323,7 +325,7 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure tcgcallparanode.secondcallparan(calloption:tproccalloption;alignment:byte);
|
procedure tcgcallparanode.secondcallparan;
|
||||||
var
|
var
|
||||||
otlabel,
|
otlabel,
|
||||||
oflabel : tasmlabel;
|
oflabel : tasmlabel;
|
||||||
@ -334,8 +336,8 @@ implementation
|
|||||||
|
|
||||||
{ push from left to right if specified }
|
{ push from left to right if specified }
|
||||||
if assigned(right) and
|
if assigned(right) and
|
||||||
(calloption in pushleftright_pocalls) then
|
(aktcallnode.procdefinition.proccalloption in pushleftright_pocalls) then
|
||||||
tcallparanode(right).secondcallparan(calloption,alignment);
|
tcallparanode(right).secondcallparan;
|
||||||
|
|
||||||
otlabel:=truelabel;
|
otlabel:=truelabel;
|
||||||
oflabel:=falselabel;
|
oflabel:=falselabel;
|
||||||
@ -346,10 +348,11 @@ implementation
|
|||||||
{ handle varargs first, because defcoll is not valid }
|
{ handle varargs first, because defcoll is not valid }
|
||||||
if (nf_varargs_para in flags) then
|
if (nf_varargs_para in flags) then
|
||||||
begin
|
begin
|
||||||
if paramanager.push_addr_param(vs_value,left.resulttype.def,calloption) then
|
if paramanager.push_addr_param(vs_value,left.resulttype.def,
|
||||||
|
aktcallnode.procdefinition.proccalloption) then
|
||||||
push_addr_para
|
push_addr_para
|
||||||
else
|
else
|
||||||
push_value_para(calloption,alignment);
|
push_value_para;
|
||||||
end
|
end
|
||||||
{ hidden parameters }
|
{ hidden parameters }
|
||||||
else if paraitem.is_hidden then
|
else if paraitem.is_hidden then
|
||||||
@ -358,10 +361,11 @@ implementation
|
|||||||
by address for implicit hidden parameters }
|
by address for implicit hidden parameters }
|
||||||
if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) or
|
if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) or
|
||||||
(not(left.resulttype.def.deftype in [pointerdef,classrefdef]) and
|
(not(left.resulttype.def.deftype in [pointerdef,classrefdef]) and
|
||||||
paramanager.push_addr_param(paraitem.paratyp,paraitem.paratype.def,calloption)) then
|
paramanager.push_addr_param(paraitem.paratyp,paraitem.paratype.def,
|
||||||
|
aktcallnode.procdefinition.proccalloption)) then
|
||||||
push_addr_para
|
push_addr_para
|
||||||
else
|
else
|
||||||
push_value_para(calloption,alignment);
|
push_value_para;
|
||||||
end
|
end
|
||||||
{ filter array of const c styled args }
|
{ filter array of const c styled args }
|
||||||
else if is_array_of_const(left.resulttype.def) and (nf_cargs in left.flags) then
|
else if is_array_of_const(left.resulttype.def) and (nf_cargs in left.flags) then
|
||||||
@ -398,7 +402,8 @@ implementation
|
|||||||
paraitem.is_hidden and
|
paraitem.is_hidden and
|
||||||
(left.resulttype.def.deftype in [pointerdef,classrefdef])
|
(left.resulttype.def.deftype in [pointerdef,classrefdef])
|
||||||
) and
|
) and
|
||||||
paramanager.push_addr_param(paraitem.paratyp,paraitem.paratype.def,calloption)) then
|
paramanager.push_addr_param(paraitem.paratyp,paraitem.paratype.def,
|
||||||
|
aktcallnode.procdefinition.proccalloption)) then
|
||||||
begin
|
begin
|
||||||
{ Check for passing a constant to var,out parameter }
|
{ Check for passing a constant to var,out parameter }
|
||||||
if (paraitem.paratyp in [vs_var,vs_out]) and
|
if (paraitem.paratyp in [vs_var,vs_out]) and
|
||||||
@ -416,7 +421,7 @@ implementation
|
|||||||
push_addr_para;
|
push_addr_para;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
push_value_para(calloption,alignment);
|
push_value_para;
|
||||||
end;
|
end;
|
||||||
truelabel:=otlabel;
|
truelabel:=otlabel;
|
||||||
falselabel:=oflabel;
|
falselabel:=oflabel;
|
||||||
@ -428,8 +433,8 @@ implementation
|
|||||||
|
|
||||||
{ push from right to left }
|
{ push from right to left }
|
||||||
if assigned(right) and
|
if assigned(right) and
|
||||||
not(calloption in pushleftright_pocalls) then
|
not(aktcallnode.procdefinition.proccalloption in pushleftright_pocalls) then
|
||||||
tcallparanode(right).secondcallparan(calloption,alignment);
|
tcallparanode(right).secondcallparan;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -624,7 +629,6 @@ implementation
|
|||||||
iolabel : tasmlabel;
|
iolabel : tasmlabel;
|
||||||
{ help reference pointer }
|
{ help reference pointer }
|
||||||
href : treference;
|
href : treference;
|
||||||
para_alignment,
|
|
||||||
pop_size : longint;
|
pop_size : longint;
|
||||||
pvreg,
|
pvreg,
|
||||||
vmtreg,vmtreg2 : tregister;
|
vmtreg,vmtreg2 : tregister;
|
||||||
@ -712,12 +716,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
|
|
||||||
para_alignment:=4
|
|
||||||
else
|
|
||||||
para_alignment:=aktalignment.paraalign;
|
|
||||||
|
|
||||||
regs_to_alloc:=paramanager.get_volatile_registers_int(procdefinition.proccalloption);
|
regs_to_alloc:=paramanager.get_volatile_registers_int(procdefinition.proccalloption);
|
||||||
regs_to_push_other:=paramanager.get_volatile_registers_fpu(procdefinition.proccalloption);
|
regs_to_push_other:=paramanager.get_volatile_registers_fpu(procdefinition.proccalloption);
|
||||||
|
|
||||||
@ -753,7 +751,7 @@ implementation
|
|||||||
oldaktcallnode:=aktcallnode;
|
oldaktcallnode:=aktcallnode;
|
||||||
aktcallnode:=self;
|
aktcallnode:=self;
|
||||||
if assigned(left) then
|
if assigned(left) then
|
||||||
tcallparanode(left).secondcallparan(procdefinition.proccalloption,procdefinition.paraalign);
|
tcallparanode(left).secondcallparan;
|
||||||
aktcallnode:=oldaktcallnode;
|
aktcallnode:=oldaktcallnode;
|
||||||
|
|
||||||
{ Align stack if required }
|
{ Align stack if required }
|
||||||
@ -1161,7 +1159,7 @@ implementation
|
|||||||
oldaktcallnode:=aktcallnode;
|
oldaktcallnode:=aktcallnode;
|
||||||
aktcallnode:=self;
|
aktcallnode:=self;
|
||||||
if assigned(left) then
|
if assigned(left) then
|
||||||
tcallparanode(left).secondcallparan(procdefinition.proccalloption,0);
|
tcallparanode(left).secondcallparan;
|
||||||
aktcallnode:=oldaktcallnode;
|
aktcallnode:=oldaktcallnode;
|
||||||
|
|
||||||
// rg.saveotherregvars(exprasmlist,regs_to_push_other);
|
// rg.saveotherregvars(exprasmlist,regs_to_push_other);
|
||||||
@ -1309,7 +1307,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.123 2003-10-01 20:34:48 peter
|
Revision 1.124 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.123 2003/10/01 20:34:48 peter
|
||||||
* procinfo unit contains tprocinfo
|
* procinfo unit contains tprocinfo
|
||||||
* cginfo renamed to cgbase
|
* cginfo renamed to cgbase
|
||||||
* moved cgmessage to verbose
|
* moved cgmessage to verbose
|
||||||
|
@ -70,6 +70,7 @@ unit paramgr;
|
|||||||
@param(list Current assembler list)
|
@param(list Current assembler list)
|
||||||
@param(nr Parameter number of routine, starting from 1)
|
@param(nr Parameter number of routine, starting from 1)
|
||||||
}
|
}
|
||||||
|
function get_para_align(calloption : tproccalloption):byte;virtual;
|
||||||
function get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;virtual;
|
function get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;virtual;
|
||||||
function get_volatile_registers_fpu(calloption : tproccalloption):tsuperregisterset;virtual;
|
function get_volatile_registers_fpu(calloption : tproccalloption):tsuperregisterset;virtual;
|
||||||
function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;virtual;abstract;
|
function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;virtual;abstract;
|
||||||
@ -248,6 +249,12 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tparamanager.get_para_align(calloption : tproccalloption):byte;
|
||||||
|
begin
|
||||||
|
result:=std_param_align;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tparamanager.get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;
|
function tparamanager.get_volatile_registers_int(calloption : tproccalloption):tsuperregisterset;
|
||||||
begin
|
begin
|
||||||
result:=[];
|
result:=[];
|
||||||
@ -411,7 +418,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.58 2003-10-01 20:34:49 peter
|
Revision 1.59 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.58 2003/10/01 20:34:49 peter
|
||||||
* procinfo unit contains tprocinfo
|
* procinfo unit contains tprocinfo
|
||||||
* cginfo renamed to cgbase
|
* cginfo renamed to cgbase
|
||||||
* moved cgmessage to verbose
|
* moved cgmessage to verbose
|
||||||
|
@ -967,7 +967,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
Message1(parser_w_not_supported_for_inline,'array of const');
|
Message1(parser_w_not_supported_for_inline,'array of const');
|
||||||
Message(parser_w_inlining_disabled);
|
Message(parser_w_inlining_disabled);
|
||||||
pd.proccalloption:=pocall_default;
|
pd.set_calloption(pocall_default);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
hp:=tparaitem(hp.next);
|
hp:=tparaitem(hp.next);
|
||||||
@ -1583,7 +1583,7 @@ const
|
|||||||
proccalloptionStr[pd.proccalloption],
|
proccalloptionStr[pd.proccalloption],
|
||||||
proccalloptionStr[proc_direcdata[p].pocall]);
|
proccalloptionStr[proc_direcdata[p].pocall]);
|
||||||
end;
|
end;
|
||||||
pd.proccalloption:=proc_direcdata[p].pocall;
|
pd.set_calloption(proc_direcdata[p].pocall);
|
||||||
include(pd.procoptions,po_hascallingconvention);
|
include(pd.procoptions,po_hascallingconvention);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1647,7 +1647,7 @@ const
|
|||||||
begin
|
begin
|
||||||
{ set the default calling convention if none provided }
|
{ set the default calling convention if none provided }
|
||||||
if not(po_hascallingconvention in pd.procoptions) then
|
if not(po_hascallingconvention in pd.procoptions) then
|
||||||
pd.proccalloption:=aktdefproccall
|
pd.set_calloption(aktdefproccall)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if pd.proccalloption=pocall_none then
|
if pd.proccalloption=pocall_none then
|
||||||
@ -1670,8 +1670,6 @@ const
|
|||||||
end;
|
end;
|
||||||
{ check C cdecl para types }
|
{ check C cdecl para types }
|
||||||
pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_c_para,nil);
|
pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_c_para,nil);
|
||||||
{ Adjust alignment to match cdecl or stdcall }
|
|
||||||
pd.paraalign:=std_param_align;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pocall_cppdecl :
|
pocall_cppdecl :
|
||||||
@ -1683,16 +1681,6 @@ const
|
|||||||
tprocdef(pd).setmangledname(target_info.Cprefix+tprocdef(pd).cplusplusmangledname);
|
tprocdef(pd).setmangledname(target_info.Cprefix+tprocdef(pd).cplusplusmangledname);
|
||||||
{ check C cdecl para types }
|
{ check C cdecl para types }
|
||||||
pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_c_para,nil);
|
pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_c_para,nil);
|
||||||
{ Adjust alignment to match cdecl or stdcall }
|
|
||||||
pd.paraalign:=std_param_align;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
pocall_stdcall :
|
|
||||||
begin
|
|
||||||
if (pd.deftype=procdef) then
|
|
||||||
begin
|
|
||||||
{ Adjust alignment to match cdecl or stdcall }
|
|
||||||
pd.paraalign:=std_param_align;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pocall_compilerproc :
|
pocall_compilerproc :
|
||||||
@ -1701,30 +1689,17 @@ const
|
|||||||
internalerror(200110232);
|
internalerror(200110232);
|
||||||
tprocdef(pd).setmangledname(lower(tprocdef(pd).procsym.name));
|
tprocdef(pd).setmangledname(lower(tprocdef(pd).procsym.name));
|
||||||
end;
|
end;
|
||||||
pocall_register :
|
|
||||||
begin
|
|
||||||
{ Adjust alignment to match cdecl or stdcall }
|
|
||||||
pd.paraalign:=std_param_align;
|
|
||||||
end;
|
|
||||||
pocall_far16 :
|
pocall_far16 :
|
||||||
begin
|
begin
|
||||||
{ Temporary stub, must be rewritten to support OS/2 far16 }
|
{ Temporary stub, must be rewritten to support OS/2 far16 }
|
||||||
Message1(parser_w_proc_directive_ignored,'FAR16');
|
Message1(parser_w_proc_directive_ignored,'FAR16');
|
||||||
end;
|
end;
|
||||||
pocall_palmossyscall :
|
|
||||||
begin
|
|
||||||
if (pd.deftype=procdef) then
|
|
||||||
begin
|
|
||||||
{ Adjust positions of args for cdecl or stdcall }
|
|
||||||
pd.paraalign:=std_param_align;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
pocall_inline :
|
pocall_inline :
|
||||||
begin
|
begin
|
||||||
if not(cs_support_inline in aktmoduleswitches) then
|
if not(cs_support_inline in aktmoduleswitches) then
|
||||||
begin
|
begin
|
||||||
Message(parser_e_proc_inline_not_supported);
|
Message(parser_e_proc_inline_not_supported);
|
||||||
pd.proccalloption:=pocall_default;
|
pd.set_calloption(pocall_default);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2151,7 +2126,10 @@ const
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.143 2003-10-02 21:13:09 peter
|
Revision 1.144 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.143 2003/10/02 21:13:09 peter
|
||||||
* procvar directive parsing fixes
|
* procvar directive parsing fixes
|
||||||
|
|
||||||
Revision 1.142 2003/10/01 19:05:33 peter
|
Revision 1.142 2003/10/01 19:05:33 peter
|
||||||
|
@ -199,15 +199,8 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
function tprocinfo.calc_stackframe_size:longint;
|
function tprocinfo.calc_stackframe_size:longint;
|
||||||
var
|
|
||||||
_align : longint;
|
|
||||||
begin
|
begin
|
||||||
{ align to 4 bytes at least
|
result:=Align(tg.direction*tg.lasttemp,aktalignment.localalignmin);
|
||||||
otherwise all those subl $2,%esp are meaningless PM }
|
|
||||||
_align:=target_info.alignment.localalignmin;
|
|
||||||
if _align<4 then
|
|
||||||
_align:=4;
|
|
||||||
result:=Align(tg.direction*tg.lasttemp,_align);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -227,7 +220,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2003-10-01 20:34:49 peter
|
Revision 1.2 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.1 2003/10/01 20:34:49 peter
|
||||||
* procinfo unit contains tprocinfo
|
* procinfo unit contains tprocinfo
|
||||||
* cginfo renamed to cgbase
|
* cginfo renamed to cgbase
|
||||||
* moved cgmessage to verbose
|
* moved cgmessage to verbose
|
||||||
|
@ -440,6 +440,7 @@ interface
|
|||||||
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
||||||
procedure deref;override;
|
procedure deref;override;
|
||||||
procedure releasemem;
|
procedure releasemem;
|
||||||
|
procedure set_calloption(calloption:tproccalloption);
|
||||||
function concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
|
function concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
|
||||||
function insertpara(const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
|
function insertpara(const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
|
||||||
procedure removepara(currpara:tparaitem);
|
procedure removepara(currpara:tparaitem);
|
||||||
@ -3093,7 +3094,7 @@ implementation
|
|||||||
parast.defowner:=self;
|
parast.defowner:=self;
|
||||||
parast.next:=owner;
|
parast.next:=owner;
|
||||||
para:=TLinkedList.Create;
|
para:=TLinkedList.Create;
|
||||||
paraalign:=aktalignment.paraalign;
|
paraalign:=std_param_align;
|
||||||
minparacount:=0;
|
minparacount:=0;
|
||||||
maxparacount:=0;
|
maxparacount:=0;
|
||||||
proctypeoption:=potype_none;
|
proctypeoption:=potype_none;
|
||||||
@ -3133,6 +3134,14 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tabstractprocdef.set_calloption(calloption:tproccalloption);
|
||||||
|
begin
|
||||||
|
proccalloption:=calloption;
|
||||||
|
{ Update parameter alignment }
|
||||||
|
paraalign:=paramanager.get_para_align(proccalloption);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tabstractprocdef.concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
|
function tabstractprocdef.concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
|
||||||
var
|
var
|
||||||
hp : TParaItem;
|
hp : TParaItem;
|
||||||
@ -5900,7 +5909,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.169 2003-10-02 21:19:42 peter
|
Revision 1.170 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.169 2003/10/02 21:19:42 peter
|
||||||
* protected visibility fixes
|
* protected visibility fixes
|
||||||
|
|
||||||
Revision 1.168 2003/10/01 20:34:49 peter
|
Revision 1.168 2003/10/01 20:34:49 peter
|
||||||
|
@ -186,7 +186,6 @@ interface
|
|||||||
varalignmax,
|
varalignmax,
|
||||||
localalignmin,
|
localalignmin,
|
||||||
localalignmax,
|
localalignmax,
|
||||||
paraalign,
|
|
||||||
recordalignmin,
|
recordalignmin,
|
||||||
recordalignmax,
|
recordalignmax,
|
||||||
maxCrecordalign : longint;
|
maxCrecordalign : longint;
|
||||||
@ -489,8 +488,6 @@ begin
|
|||||||
if (localalignmax=0) or
|
if (localalignmax=0) or
|
||||||
((s.localalignmax>0) and (s.localalignmax<localalignmax)) then
|
((s.localalignmax>0) and (s.localalignmax<localalignmax)) then
|
||||||
localalignmax:=s.localalignmax;
|
localalignmax:=s.localalignmax;
|
||||||
if s.paraalign>paraalign then
|
|
||||||
paraalign:=s.paraalign;
|
|
||||||
if s.recordalignmin>recordalignmin then
|
if s.recordalignmin>recordalignmin then
|
||||||
recordalignmin:=s.recordalignmin;
|
recordalignmin:=s.recordalignmin;
|
||||||
if (recordalignmax=0) or
|
if (recordalignmax=0) or
|
||||||
@ -696,7 +693,10 @@ finalization
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.69 2003-10-02 21:17:08 peter
|
Revision 1.70 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.69 2003/10/02 21:17:08 peter
|
||||||
* use as,ld,ar instead of asw,ldw,arw for win32
|
* use as,ld,ar instead of asw,ldw,arw for win32
|
||||||
|
|
||||||
Revision 1.68 2003/09/05 17:41:13 florian
|
Revision 1.68 2003/09/05 17:41:13 florian
|
||||||
|
@ -347,7 +347,7 @@ unit cgx86;
|
|||||||
OS_8,OS_S8,
|
OS_8,OS_S8,
|
||||||
OS_16,OS_S16:
|
OS_16,OS_S16:
|
||||||
begin
|
begin
|
||||||
if target_info.alignment.paraalign = 2 then
|
if locpara.alignment = 2 then
|
||||||
list.concat(taicpu.op_reg(A_PUSH,S_W,rg.makeregsize(r,OS_16)))
|
list.concat(taicpu.op_reg(A_PUSH,S_W,rg.makeregsize(r,OS_16)))
|
||||||
else
|
else
|
||||||
list.concat(taicpu.op_reg(A_PUSH,S_L,rg.makeregsize(r,OS_32)));
|
list.concat(taicpu.op_reg(A_PUSH,S_L,rg.makeregsize(r,OS_32)));
|
||||||
@ -379,7 +379,7 @@ unit cgx86;
|
|||||||
case size of
|
case size of
|
||||||
OS_8,OS_S8,OS_16,OS_S16:
|
OS_8,OS_S8,OS_16,OS_S16:
|
||||||
begin
|
begin
|
||||||
if target_info.alignment.paraalign = 2 then
|
if locpara.alignment = 2 then
|
||||||
list.concat(taicpu.op_const(A_PUSH,S_W,a))
|
list.concat(taicpu.op_const(A_PUSH,S_W,a))
|
||||||
else
|
else
|
||||||
list.concat(taicpu.op_const(A_PUSH,S_L,a));
|
list.concat(taicpu.op_const(A_PUSH,S_L,a));
|
||||||
@ -412,7 +412,7 @@ unit cgx86;
|
|||||||
OS_8,OS_S8,
|
OS_8,OS_S8,
|
||||||
OS_16,OS_S16:
|
OS_16,OS_S16:
|
||||||
begin
|
begin
|
||||||
if target_info.alignment.paraalign = 2 then
|
if locpara.alignment = 2 then
|
||||||
pushsize:=OS_16
|
pushsize:=OS_16
|
||||||
else
|
else
|
||||||
pushsize:=OS_32;
|
pushsize:=OS_32;
|
||||||
@ -1601,7 +1601,10 @@ unit cgx86;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.71 2003-10-03 14:45:37 peter
|
Revision 1.72 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.71 2003/10/03 14:45:37 peter
|
||||||
* save ESP after pusha and restore before popa for save all registers
|
* save ESP after pusha and restore before popa for save all registers
|
||||||
|
|
||||||
Revision 1.70 2003/10/01 20:34:51 peter
|
Revision 1.70 2003/10/01 20:34:51 peter
|
||||||
|
@ -263,6 +263,7 @@ uses
|
|||||||
tparalocation = packed record
|
tparalocation = packed record
|
||||||
size : TCGSize;
|
size : TCGSize;
|
||||||
loc : TCGLoc;
|
loc : TCGLoc;
|
||||||
|
alignment : byte;
|
||||||
case TCGLoc of
|
case TCGLoc of
|
||||||
LOC_REFERENCE : (reference : tparareference);
|
LOC_REFERENCE : (reference : tparareference);
|
||||||
{ segment in reference at the same place as in loc_register }
|
{ segment in reference at the same place as in loc_register }
|
||||||
@ -558,7 +559,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.22 2003-10-01 20:34:51 peter
|
Revision 1.23 2003-10-03 22:00:33 peter
|
||||||
|
* parameter alignment fixes
|
||||||
|
|
||||||
|
Revision 1.22 2003/10/01 20:34:51 peter
|
||||||
* procinfo unit contains tprocinfo
|
* procinfo unit contains tprocinfo
|
||||||
* cginfo renamed to cgbase
|
* cginfo renamed to cgbase
|
||||||
* moved cgmessage to verbose
|
* moved cgmessage to verbose
|
||||||
|
Loading…
Reference in New Issue
Block a user