From 15c0b633ab7d611ce6c20c35a08d2a0202ece4fd Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 26 Apr 2003 11:30:59 +0000 Subject: [PATCH] * fixed the powerpc to work with the new function result handling --- compiler/powerpc/cpupara.pas | 11 ++-- compiler/powerpc/cpupi.pas | 15 +++--- compiler/pstatmnt.pas | 99 ++++++++++++++++++++---------------- 3 files changed, 67 insertions(+), 58 deletions(-) diff --git a/compiler/powerpc/cpupara.pas b/compiler/powerpc/cpupara.pas index 6eec42107b..d828e56f0b 100644 --- a/compiler/powerpc/cpupara.pas +++ b/compiler/powerpc/cpupara.pas @@ -157,12 +157,6 @@ unit cpupara; nextfloatreg.enum:=R_F1; nextmmreg.enum:=R_M1; stack_offset:=0; - { pointer for structured results ? } - if not is_void(p.rettype.def) then - begin - if not(ret_in_reg(p.rettype.def,p.proccalloption)) then - inc(nextintreg.number,NR_R1-NR_R0); - end; { frame pointer for nested procedures? } { inc(nextintreg); } @@ -301,7 +295,10 @@ begin end. { $Log$ - Revision 1.26 2003-04-23 12:35:35 florian + Revision 1.27 2003-04-26 11:30:59 florian + * fixed the powerpc to work with the new function result handling + + Revision 1.26 2003/04/23 12:35:35 florian * fixed several issues with powerpc + applied a patch from Jonas for nested function calls (PowerPC only) * ... diff --git a/compiler/powerpc/cpupi.pas b/compiler/powerpc/cpupi.pas index ac02c1f23d..2e9837421a 100644 --- a/compiler/powerpc/cpupi.pas +++ b/compiler/powerpc/cpupi.pas @@ -71,11 +71,8 @@ unit cpupi; procinfo.framepointer_offset:=procdef.parast.address_fixup; inc(procdef.parast.address_fixup,4); end; - if paramanager.ret_in_param(procdef.rettype.def,procdef.proccalloption) then - begin - procinfo.return_offset:=procdef.parast.address_fixup; - inc(procdef.parast.address_fixup,4); - end; + if assigned(procinfo.procdef.funcretsym) then + procinfo.return_offset:=tvarsym(procinfo.procdef.funcretsym).address+tvarsym(procinfo.procdef.funcretsym).owner.address_fixup; if assigned(_class) then begin procinfo.selfpointer_offset:=procdef.parast.address_fixup; @@ -102,7 +99,6 @@ unit cpupi; begin 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); if cs_asm_source in aktglobalswitches then @@ -110,6 +106,8 @@ unit cpupi; // 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(procinfo.procdef.funcretsym) then + procinfo.return_offset:=tvarsym(procinfo.procdef.funcretsym).address+tvarsym(procinfo.procdef.funcretsym).owner.address_fixup; { Already done with an "inc" above, should be correct (JM) @@ -136,7 +134,10 @@ begin end. { $Log$ - Revision 1.9 2003-04-24 11:24:00 florian + Revision 1.10 2003-04-26 11:31:00 florian + * fixed the powerpc to work with the new function result handling + + Revision 1.9 2003/04/24 11:24:00 florian * fixed several issues with nested procedures Revision 1.8 2003/04/06 16:39:11 jonas diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index 883ff8a86b..a671e849d8 100644 --- a/compiler/pstatmnt.pas +++ b/compiler/pstatmnt.pas @@ -398,41 +398,43 @@ implementation (p.resulttype.def.deftype in [objectdef,recorddef]) then begin case p.resulttype.def.deftype of - objectdef : begin - obj:=tobjectdef(p.resulttype.def); - symtab:=twithsymtable.Create(obj,obj.symtable.symsearch); - withsymtable:=symtab; - if (p.nodetype=loadn) and - (tloadnode(p).symtable=aktprocdef.localst) then - twithsymtable(symtab).direct_with:=true; - twithsymtable(symtab).withrefnode:=p; - levelcount:=1; - obj:=obj.childof; - while assigned(obj) do - begin - symtab.next:=twithsymtable.create(obj,obj.symtable.symsearch); - symtab:=symtab.next; - if (p.nodetype=loadn) and - (tloadnode(p).symtable=aktprocdef.localst) then - twithsymtable(symtab).direct_with:=true; - twithsymtable(symtab).withrefnode:=p; - obj:=obj.childof; - inc(levelcount); - end; - symtab.next:=symtablestack; - symtablestack:=withsymtable; - end; - recorddef : begin - symtab:=trecorddef(p.resulttype.def).symtable; - levelcount:=1; - withsymtable:=twithsymtable.create(trecorddef(p.resulttype.def),symtab.symsearch); - if (p.nodetype=loadn) and - (tloadnode(p).symtable=aktprocdef.localst) then - twithsymtable(withsymtable).direct_with:=true; - twithsymtable(withsymtable).withrefnode:=p; - withsymtable.next:=symtablestack; - symtablestack:=withsymtable; - end; + objectdef : + begin + obj:=tobjectdef(p.resulttype.def); + symtab:=twithsymtable.Create(obj,obj.symtable.symsearch); + withsymtable:=symtab; + if (p.nodetype=loadn) and + (tloadnode(p).symtable=aktprocdef.localst) then + twithsymtable(symtab).direct_with:=true; + twithsymtable(symtab).withrefnode:=p; + levelcount:=1; + obj:=obj.childof; + while assigned(obj) do + begin + symtab.next:=twithsymtable.create(obj,obj.symtable.symsearch); + symtab:=symtab.next; + if (p.nodetype=loadn) and + (tloadnode(p).symtable=aktprocdef.localst) then + twithsymtable(symtab).direct_with:=true; + twithsymtable(symtab).withrefnode:=p; + obj:=obj.childof; + inc(levelcount); + end; + symtab.next:=symtablestack; + symtablestack:=withsymtable; + end; + recorddef : + begin + symtab:=trecorddef(p.resulttype.def).symtable; + levelcount:=1; + withsymtable:=twithsymtable.create(trecorddef(p.resulttype.def),symtab.symsearch); + if (p.nodetype=loadn) and + (tloadnode(p).symtable=aktprocdef.localst) then + twithsymtable(withsymtable).direct_with:=true; + twithsymtable(withsymtable).withrefnode:=p; + withsymtable.next:=symtablestack; + symtablestack:=withsymtable; + end; end; if token=_COMMA then begin @@ -1011,9 +1013,6 @@ implementation parafixup, i : longint; begin - { we don't need to allocate space for the locals } - aktprocdef.localst.datasize:=0; - procinfo.firsttemp_offset:=0; { replace framepointer with stackpointer } procinfo.framepointer.enum:=R_INTREGISTER; procinfo.framepointer.number:=NR_STACK_POINTER_REG; @@ -1095,18 +1094,27 @@ implementation (vm, i386, vm only currently) } if (po_assembler in aktprocdef.procoptions) and +{$ifndef powerpc} + { is this really necessary??? } (aktprocdef.parast.datasize=0) and +{$endif powerpc} (aktprocdef.localst.datasize=aktprocdef.rettype.def.size) and (aktprocdef.owner.symtabletype<>objectsymtable) and (not assigned(aktprocdef.funcretsym) or (tvarsym(aktprocdef.funcretsym).refcount<=1)) and - not(paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption)) and - (target_cpu in [cpu_i386,cpu_m68k,cpu_vm]) + not(paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption)) then + begin + { we don't need to allocate space for the locals } + aktprocdef.localst.datasize:=0; + procinfo.firsttemp_offset:=0; + { only for cpus with different frame- and stack pointer the code must be changed } + if (NR_STACK_POINTER_REG<>NR_FRAME_POINTER_REG) {$ifdef CHECKFORPUSH} - and not(UsesPush(tasmnode(p))) + and not(UsesPush(tasmnode(p))) {$endif CHECKFORPUSH} - then - OptimizeFramePointer(tasmnode(p)); + then + OptimizeFramePointer(tasmnode(p)); + end; { Flag the result as assigned when it is returned in a register. @@ -1125,7 +1133,10 @@ implementation end. { $Log$ - Revision 1.91 2003-04-25 20:59:34 peter + Revision 1.92 2003-04-26 11:30:59 florian + * fixed the powerpc to work with the new function result handling + + Revision 1.91 2003/04/25 20:59:34 peter * removed funcretn,funcretsym, function result is now in varsym and aliases for result and function name are added using absolutesym * vs_hidden parameter for funcret passed in parameter