* several ppc/generic result offset related fixes. The "normal" result

offset seems now to be calculated correctly and a lot of duplicate
    calculations have been removed. Nested functions accessing the parent's
    function result don't work at all though :(
This commit is contained in:
Jonas Maebe 2003-04-05 21:09:31 +00:00
parent 092db52aca
commit ec71805aa8
4 changed files with 68 additions and 19 deletions

View File

@ -166,8 +166,10 @@ unit cgbase;
}
procedure after_pass1;virtual;
(* done by symtablestack.insertvardata() (JM)
{ sets the offset for a temp used by the result }
procedure set_result_offset;virtual;
*)
end;
pregvarinfo = ^tregvarinfo;
@ -422,28 +424,32 @@ implementation
{ !!!!! this means that we can not set the return value
in a subfunction !!!!! }
{ because we don't know yet where the address is }
if not is_void(aktprocdef.rettype.def) then
if not is_void(procdef.rettype.def) then
begin
if paramanager.ret_in_reg(aktprocdef.rettype.def,aktprocdef.proccalloption) then
if paramanager.ret_in_reg(procdef.rettype.def,procdef.proccalloption) then
begin
(* already done in symtable.pas:tlocalsymtable.insertvardata() (JM)
{ the space has been set in the local symtable }
procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address;
procinfo.return_offset:=tg.direction*tfuncretsym(procdef.funcretsym).address;
*)
if ((procinfo.flags and pi_operator)<>0) and
assigned(otsym) then
otsym.address:=tfuncretsym(aktprocdef.funcretsym).address;
otsym.address:=tfuncretsym(procdef.funcretsym).address;
rg.usedinproc := rg.usedinproc +
getfuncretusedregisters(aktprocdef.rettype.def,aktprocdef.proccalloption);
getfuncretusedregisters(procdef.rettype.def,procdef.proccalloption);
end;
end;
end;
(* already done in symtable.pas:tlocalsymtable.insertvardata() (JM)
procedure tprocinfo.set_result_offset;
begin
if paramanager.ret_in_reg(aktprocdef,procdef.proccalloption) then
procinfo.return_offset:=-tfuncretsym(procdef.funcretsym).address;
if paramanager.ret_in_reg(procdef.rettype.def,procdef.proccalloption) then
procinfo.return_offset:=tg.direction*tfuncretsym(procdef.funcretsym).address;
end;
*)
procedure tprocinfo.after_header;
@ -657,7 +663,13 @@ begin
end.
{
$Log$
Revision 1.38 2003-03-28 19:16:56 peter
Revision 1.39 2003-04-05 21:09:31 jonas
* several ppc/generic result offset related fixes. The "normal" result
offset seems now to be calculated correctly and a lot of duplicate
calculations have been removed. Nested functions accessing the parent's
function result don't work at all though :(
Revision 1.38 2003/03/28 19:16:56 peter
* generic constructor working for i386
* remove fixed self register
* esi added as address register for i386

View File

@ -84,28 +84,38 @@ unit cpupi;
{ this value is necessary for nested procedures }
if assigned(procdef.localst) then
procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
if assigned(aktprocdef.funcretsym) and
{
procdef.funcretsym isn't set here yet and besides,
symtable.insertvardata() already sets procinfo.return_offset! (JM)
if assigned(procdef.funcretsym) and
not(paramanager.ret_in_param(procdef.rettype.def,procdef.proccalloption)) then
procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
procinfo.return_offset:=tg.direction*tfuncretsym(procdef.funcretsym).address+procdef.localst.address_fixup;
}
end;
procedure tppcprocinfo.after_pass1;
var
ofs : aword;
begin
ofs:=align(maxpushedparasize,16)+LinkageAreaSize;
ofs:=align(maxpushedparasize+LinkageAreaSize,16);
inc(procdef.parast.address_fixup,ofs);
inc(procinfo.return_offset,ofs);
inc(procinfo.framepointer_offset,ofs);
inc(procinfo.selfpointer_offset,ofs);
inc(procdef.localst.address_fixup,ofs);
if cs_asm_source in aktglobalswitches then
aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: r1+'+tostr(procdef.parast.address_fixup))));
procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
{
Already done with an "inc" above now, not sure if it's correct (JM)
procdef.localst.address_fixup:=procdef.parast.address_fixup+procdef.parast.datasize;
if assigned(aktprocdef.funcretsym) and
Already done with an "inc" above, should be correct (JM)
if assigned(procdef.funcretsym) and
not(paramanager.ret_in_param(procdef.rettype.def,procdef.proccalloption)) then
procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
procinfo.return_offset:=tg.direction*tfuncretsym(procdef.funcretsym).address+procdef.localst.address_fixup;
}
if cs_asm_source in aktglobalswitches then
aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: r1+'+tostr(procdef.localst.address_fixup))));
@ -124,7 +134,13 @@ begin
end.
{
$Log$
Revision 1.6 2002-12-15 19:22:01 florian
Revision 1.7 2003-04-05 21:09:32 jonas
* several ppc/generic result offset related fixes. The "normal" result
offset seems now to be calculated correctly and a lot of duplicate
calculations have been removed. Nested functions accessing the parent's
function result don't work at all though :(
Revision 1.6 2002/12/15 19:22:01 florian
* fixed some crashes and a rte 201
Revision 1.5 2002/11/18 17:32:01 peter

View File

@ -117,7 +117,10 @@ implementation
symtablestack.insertvardata(aktprocdef.funcretsym);
akttokenpos:=storepos;
(* already done by
symtablestack.insertvardata(aktprocdef.funcretsym); above (JM)
procinfo.set_result_offset;
*)
{ insert result also if support is on }
if (m_result in aktmodeswitches) then
begin
@ -854,7 +857,13 @@ implementation
end.
{
$Log$
Revision 1.95 2003-04-02 16:11:34 peter
Revision 1.96 2003-04-05 21:09:31 jonas
* several ppc/generic result offset related fixes. The "normal" result
offset seems now to be calculated correctly and a lot of duplicate
calculations have been removed. Nested functions accessing the parent's
function result don't work at all though :(
Revision 1.95 2003/04/02 16:11:34 peter
* give error when exports is not supported
Revision 1.94 2003/03/12 22:43:38 jonas

View File

@ -288,7 +288,7 @@ implementation
gdb,
{$endif GDB}
{ codegen }
cgbase
cgbase,tgobj
;
@ -1332,9 +1332,15 @@ implementation
l:=tfuncretsym(sym).returntype.def.size;
varalign:=size_2_align(l);
varalign:=used_align(varalign,aktalignment.localalignmin,dataalignment);
{$ifdef powerpc}
{ on the powerpc, the local variables are accessed with a positiv offset }
tfuncretsym(sym).address:=align(datasize,varalign);
datasize:=tfuncretsym(sym).address+l;
{$else powerpc}
tfuncretsym(sym).address:=align(datasize+l,varalign);
datasize:=tfuncretsym(sym).address;
procinfo.return_offset:=-tfuncretsym(sym).address;
{$endif powerpc}
procinfo.return_offset:=tg.direction*tfuncretsym(sym).address;
end;
end;
end;
@ -2451,7 +2457,13 @@ implementation
end.
{
$Log$
Revision 1.91 2003-03-17 18:56:49 peter
Revision 1.92 2003-04-05 21:09:32 jonas
* several ppc/generic result offset related fixes. The "normal" result
offset seems now to be calculated correctly and a lot of duplicate
calculations have been removed. Nested functions accessing the parent's
function result don't work at all though :(
Revision 1.91 2003/03/17 18:56:49 peter
* ignore hints for default parameter values
Revision 1.90 2003/03/17 16:54:41 peter