* parameter handling updated

This commit is contained in:
mazen 2002-11-03 20:22:40 +00:00
parent e1d6662005
commit f170b21371
4 changed files with 53 additions and 44 deletions

View File

@ -1315,6 +1315,7 @@ implementation
{ move register parameters which aren't regable into memory }
{ we do this after init_paras because it saves some code in init_paras if parameters are in register }
{ instead in memory }
{$IFNDEF SPARC}
hp:=tparaitem(procinfo.procdef.para.first);
while assigned(hp) do
begin
@ -1352,6 +1353,7 @@ implementation
end;
hp:=tparaitem(hp.next);
end;
{$ENDIF SPARC}
end;
if (not inlined) then
@ -1846,7 +1848,10 @@ implementation
end.
{
$Log$
Revision 1.56 2002-10-16 19:01:43 peter
Revision 1.57 2002-11-03 20:22:40 mazen
* parameter handling updated
Revision 1.56 2002/10/16 19:01:43 peter
+ $IMPLICITEXCEPTIONS switch to turn on/off generation of the
implicit exception frames for procedures with initialized variables
and for constructors. The default is on for compatibility

View File

@ -1,12 +1,4 @@
{*****************************************************************************}
{ File : cgcpu.pas }
{ Author : Mazen NEIFER }
{ Project : Free Pascal Compiler (FPC) }
{ Creation date : 2002\04\26 }
{ Licence : GPL }
{ Bug report : mazen.neifer.01@supaero.org }
{*****************************************************************************}
{
{******************************************************************************
$Id$
Copyright (c) 1998-2000 by Florian Klaempfl
@ -24,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program;if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************}
*****************************************************************************}
UNIT cgcpu;
{This unit implements the code generator for the SPARC architecture}
{$INCLUDE fpcdefs.inc}
@ -108,7 +100,7 @@ IMPLEMENTATION
USES
globtype,globals,verbose,systems,cutils,
symdef,symsym,defbase,paramgr,
rgobj,tgobj,rgcpu;
rgobj,tgobj,rgcpu,cpupi;
{ we implement the following routines because otherwise we can't }
{ instantiate the class since it's abstract }
procedure tcgSPARC.a_param_reg(list:TAasmOutput;size:tcgsize;r:tregister;CONST LocPara:TParaLocation);
@ -815,34 +807,22 @@ procedure tcgSPARC.g_flags2reg(list:TAasmOutput;Size:TCgSize;CONST f:tresflags;r
{ *********** entry/exit code and address loading ************ }
procedure tcgSPARC.g_stackframe_entry(list:TAasmOutput;localsize:LongInt);
procedure tcgSPARC.g_stackframe_entry(list:TAasmOutput;LocalSize:LongInt);
var
href:TReference;
i:integer;
again:tasmlabel;
begin
{According the the SPARC ABI the standard stack frame must include :
* 16 word save for the in and local registers in case of overflow/underflow.
this save area always must exist at the %o6+0,
* software conventions requires space for the aggregate return value pointer, even if the word is not used,
* althogh the first six words of arguments reside in registers, the standard
stack frame reserves space for them. Arguments beond the sixth reside on the
stack as in the Intel architecture,
* other areas depend on the compiler and the code being compiled. The
standard calling sequence does not define a maximum stack frame size, nor does
it restrict how a language system uses the "unspecified" areas of the standard
stack frame.}
Dec(LocalSize,(16+1+5)*4);
{Althogh the SPARC architecture require only word alignment, software
convention and the operating system require every stack frame to be double word
aligned}
LocalSize:=(LocalSize+3)and $FFFFFFFC;
{Execute the SAVE instruction to get a new register window and get a new stack
frame. In the "SAVE %i6,size,%i6" the first %i6 is related to the state before
execution of the SAVE instrucion so it is the caller %i6, when the %i6 after
execution of that instrucion is the called function stack pointer}
LocalSize:=(LocalSize+7)and $FFFFFFF8;
{Execute the SAVE instruction to get a new register window and create a new
stack frame. In the "SAVE %i6,size,%i6" the first %i6 is related to the state
before execution of the SAVE instrucion so it is the caller %i6, when the %i6
after execution of that instruction is the called function stack pointer}
with list do
concat(Taicpu.Op_reg_const_reg(A_SAVE,S_SW,Stack_Pointer_Reg,localsize,Stack_Pointer_Reg));
concat(Taicpu.Op_reg_const_reg(A_SAVE,S_SW,Stack_Pointer_Reg,LocalSize,Stack_Pointer_Reg));
end;
procedure tcgSPARC.g_restore_frame_pointer(list:TAasmOutput);
begin
@ -1274,7 +1254,10 @@ BEGIN
END.
{
$Log$
Revision 1.19 2002-10-28 20:59:17 mazen
Revision 1.20 2002-11-03 20:22:40 mazen
* parameter handling updated
Revision 1.19 2002/10/28 20:59:17 mazen
* TOpSize values changed S_L --> S_SW
Revision 1.18 2002/10/22 13:43:01 mazen

View File

@ -31,6 +31,7 @@ type
(which must be an integer parameter)
@param(nr Parameter number of routine, starting from 1)}
function GetIntParaLoc(nr:longint):TParaLocation;override;
{Creates location information related to the parameter of the function}
procedure create_param_loc_info(p:TAbstractProcDef);override;
{Returns the location where the invisible parameter for structured function
results will be passed.}
@ -282,7 +283,10 @@ begin
end.
{
$Log$
Revision 1.8 2002-10-13 21:46:07 mazen
Revision 1.9 2002-11-03 20:22:40 mazen
* parameter handling updated
Revision 1.8 2002/10/13 21:46:07 mazen
* assembler output format fixed
Revision 1.7 2002/10/10 19:57:51 mazen

View File

@ -34,6 +34,17 @@ type
{max of space need for parameters, currently used by the PowerPC port only}
maxpushedparasize:aword;
constructor create;override;
{According the the SPARC ABI the standard stack frame must include :
* 16 word save for the in and local registers in case of overflow/underflow.
this save area always must exist at the %o6+0,
* software conventions requires space for the aggregate return value pointer, even if the word is not used,
* althogh the first six words of arguments reside in registers, the standard
stack frame reserves space for them. Arguments beond the sixth reside on the
stack as in the Intel architecture,
* other areas depend on the compiler and the code being compiled. The
standard calling sequence does not define a maximum stack frame size, nor does
it restrict how a language system uses the "unspecified" areas of the standard
stack frame.}
procedure after_header;override;
procedure after_pass1;override;
end;
@ -50,26 +61,32 @@ constructor TSparcprocinfo.create;
end;
procedure TSparcprocinfo.after_header;
begin
{ this value is necessary for nested procedures }
procdef.localst.address_fixup:=align(procdef.parast.datasize,16);
{Reserve the stack for copying parameters passeѕ into registers}
procdef.parast.address_fixup:=(16+1)*4;
end;
procedure TSparcprocinfo.after_pass1;
procedure TSparcProcInfo.after_pass1;
begin
procdef.parast.address_fixup:=align(maxpushedparasize,16);
WriteLn('Parameter copies start at: %i6+'+tostr(procdef.parast.address_fixup));
procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
WriteLn(strpnew('Locals start at: %o6+'+tostr(procdef.localst.address_fixup)));
procinfo.firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
WriteLn('Temp. space start: %o6+'+tostr(procinfo.firsttemp_offset));
if(procdef.parast.datasize>6*4)
then
procdef.localst.address_fixup:=procdef.parast.datasize+(16+1)*4
else
procdef.localst.address_fixup:=6*4+(16+1)*4;
procinfo.firsttemp_offset:=procdef.localst.address_fixup+procdef.localst.datasize;
WriteLn('Parameter copies start at: %i6-'+tostr(procdef.parast.address_fixup));
WriteLn('Locals start at: %o6-'+tostr(procdef.localst.address_fixup));
WriteLn('Temp. space start: %o6-'+tostr(procinfo.firsttemp_offset));
tg.firsttemp:=procinfo.firsttemp_offset;
tg.lasttemp:=procinfo.firsttemp_offset;
end;
begin
cprocinfo:=TSparcprocinfo;
cprocinfo:=TSparcProcInfo;
end.
{
$Log$
Revision 1.4 2002-10-20 19:01:38 mazen
Revision 1.5 2002-11-03 20:22:40 mazen
* parameter handling updated
Revision 1.4 2002/10/20 19:01:38 mazen
+ op_raddr_reg and op_caddr_reg added to fix functions prologue
Revision 1.3 2002/10/10 15:10:39 mazen