* updated for removed lexlevel

This commit is contained in:
peter 2003-04-27 07:48:05 +00:00
parent 7f14891d66
commit a5e7f02527
6 changed files with 62 additions and 79 deletions

View File

@ -45,7 +45,7 @@ unit cpupi;
{ we push Flags and CS as long { we push Flags and CS as long
to cope with the IRETD to cope with the IRETD
and we save 6 register + 4 selectors } and we save 6 register + 4 selectors }
inc(procinfo.para_offset,8+6*4+4*2); inc(procdef.parast.datasize,8+6*4+4*2);
end; end;
begin begin
@ -53,7 +53,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.1 2002-08-17 09:23:44 florian Revision 1.2 2003-04-27 07:48:05 peter
* updated for removed lexlevel
Revision 1.1 2002/08/17 09:23:44 florian
* first part of procinfo rewrite * first part of procinfo rewrite
} }

View File

@ -65,30 +65,9 @@ unit cpupi;
procedure tppcprocinfo.after_header; procedure tppcprocinfo.after_header;
begin begin
procdef.parast.address_fixup:=0;
if assigned(procdef.parast) and (procdef.parast.symtablelevel>1) then
begin
procinfo.framepointer_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;
inc(procdef.parast.address_fixup,4);
end;
{ this value is necessary for nested procedures } { this value is necessary for nested procedures }
if assigned(procdef.localst) then if assigned(procdef.localst) then
procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16); procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
{
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(procdef.funcretsym).address+procdef.localst.address_fixup;
}
end; end;
procedure tppcprocinfo.after_pass1; procedure tppcprocinfo.after_pass1;
@ -134,7 +113,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.10 2003-04-26 11:31:00 florian Revision 1.11 2003-04-27 07:48:05 peter
* updated for removed lexlevel
Revision 1.10 2003/04/26 11:31:00 florian
* fixed the powerpc to work with the new function result handling * fixed the powerpc to work with the new function result handling
Revision 1.9 2003/04/24 11:24:00 florian Revision 1.9 2003/04/24 11:24:00 florian

View File

@ -77,7 +77,7 @@ implementation
hregister1,hregister2 : tregister; hregister1,hregister2 : tregister;
i : longint; i : longint;
begin begin
if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then if aktprocdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel) then
begin begin
{ pass the same framepointer as the current procedure got } { pass the same framepointer as the current procedure got }
hregister2.enum:=R_INTREGISTER; hregister2.enum:=R_INTREGISTER;
@ -87,7 +87,7 @@ implementation
end end
{ this is only true if the difference is one !! { this is only true if the difference is one !!
but it cannot be more !! } but it cannot be more !! }
else if (lexlevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then else if (aktprocdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
begin begin
{ pass the same framepointer as the current procedure got } { pass the same framepointer as the current procedure got }
hregister1.enum:=R_INTREGISTER; hregister1.enum:=R_INTREGISTER;
@ -96,17 +96,19 @@ implementation
hregister2.number:=NR_R11; hregister2.number:=NR_R11;
exprasmlist.concat(taicpu.op_reg_reg_const(A_ADDI,hregister2,hregister1,procinfo.framepointer_offset)); exprasmlist.concat(taicpu.op_reg_reg_const(A_ADDI,hregister2,hregister1,procinfo.framepointer_offset));
end end
else if (lexlevel>(tprocdef(procdefinition).parast.symtablelevel)) then else if (aktprocdef.parast.symtablelevel>(tprocdef(procdefinition).parast.symtablelevel)) then
begin begin
hregister1:=rg.getregisterint(exprasmlist,OS_ADDR); hregister1:=rg.getregisterint(exprasmlist,OS_ADDR);
reference_reset_base(href,procinfo.framepointer,procinfo.framepointer_offset); reference_reset_base(href,procinfo.framepointer,procinfo.framepointer_offset);
cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1); cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1);
for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do i:=aktprocdef.parast.symtablelevel;
while (i>tprocdef(procdefinition).parast.symtablelevel) do
begin begin
{we should get the correct frame_pointer_offset at each level {we should get the correct frame_pointer_offset at each level
how can we do this !!! } how can we do this !!! }
reference_reset_base(href,hregister2,procinfo.framepointer_offset); reference_reset_base(href,hregister2,procinfo.framepointer_offset);
cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1); cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1);
dec(i);
end; end;
hregister2.enum:=R_11; hregister2.enum:=R_11;
cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,hregister1,hregister2); cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,hregister1,hregister2);
@ -121,7 +123,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.7 2003-04-24 11:24:00 florian Revision 1.8 2003-04-27 07:48:05 peter
* updated for removed lexlevel
Revision 1.7 2003/04/24 11:24:00 florian
* fixed several issues with nested procedures * fixed several issues with nested procedures
Revision 1.6 2003/04/23 12:35:35 florian Revision 1.6 2003/04/23 12:35:35 florian

View File

@ -172,7 +172,7 @@ interface
if ((s[length(s)]<>'0') or (hs[1]<>'x')) and not(is_register(hs)) then if ((s[length(s)]<>'0') or (hs[1]<>'x')) and not(is_register(hs)) then
begin begin
if assigned(aktprocdef.localst) and if assigned(aktprocdef.localst) and
(lexlevel >= normal_function_level) then (aktprocdef.localst.symtablelevel >= normal_function_level) then
sym:=tsym(aktprocdef.localst.search(upper(hs))) sym:=tsym(aktprocdef.localst.search(upper(hs)))
else else
sym:=nil; sym:=nil;
@ -347,7 +347,10 @@ initialization
end. end.
{ {
$Log$ $Log$
Revision 1.11 2003-04-25 21:05:22 florian Revision 1.12 2003-04-27 07:48:05 peter
* updated for removed lexlevel
Revision 1.11 2003/04/25 21:05:22 florian
* fixed tfuncretsym stuff in powerpc specific part * fixed tfuncretsym stuff in powerpc specific part
Revision 1.10 2003/04/24 12:05:53 florian Revision 1.10 2003/04/24 12:05:53 florian

View File

@ -24,8 +24,8 @@ unit cpupi;
{$INCLUDE fpcdefs.inc} {$INCLUDE fpcdefs.inc}
interface interface
uses uses
cutils, cutils,
cgbase,cpuinfo; cgbase,cpuinfo;
type type
TSparcProcInfo=class(TProcInfo) TSparcProcInfo=class(TProcInfo)
{overall size of allocated stack space, currently this is used for the {overall size of allocated stack space, currently this is used for the
@ -50,47 +50,31 @@ stack frame.}
end; end;
implementation implementation
uses uses
tgobj,paramgr,symsym,systems; tgobj,paramgr,symsym,systems;
constructor TSparcprocinfo.create; constructor TSparcprocinfo.create;
begin begin
inherited create; inherited create;
maxpushedparasize:=0; maxpushedparasize:=0;
LocalSize:=(16+1)*4; LocalSize:=(16+1)*4;
{First 16 words are in the frame are used to save registers in case of a {First 16 words are in the frame are used to save registers in case of a
register overflow/underflow.The 17th word is used to save the address of register overflow/underflow.The 17th word is used to save the address of
the variable which will receive the return value of the called function} the variable which will receive the return value of the called function}
Return_Offset:=16*4; // Return_Offset:=16*4;
end; end;
procedure TSparcprocinfo.after_header;
begin procedure TSparcprocinfo.after_header;
{target_info.first_parm_offset should be (16+1)*4 as the return address pointer
is usually allocated even if return value is in register.}
procdef.parast.address_fixup:=target_info.first_parm_offset;
if assigned(procdef.localst)and(procdef.localst.symtablelevel>1)
then
begin begin
framepointer_offset:=procdef.parast.address_fixup; { this value is necessary for nested procedures }
inc(procdef.parast.address_fixup,4); if assigned(procdef.localst) then
procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
end; end;
if assigned(_class)
then
begin
selfpointer_offset:=procdef.parast.address_fixup;
inc(procdef.parast.address_fixup,4);
end;
{ 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 not(paramanager.ret_in_param(procdef.rettype.def,procdef.proccalloption))
then
return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
end;
procedure TSparcProcInfo.after_pass1; procedure TSparcProcInfo.after_pass1;
begin begin
with ProcDef do with ProcDef do
begin begin
{Reserve the stack for copying parameters passed into registers. By {Reserve the stack for copying parameters passed into registers. By
default we reserve space for the 6 input registers if the function had default we reserve space for the 6 input registers if the function had
less parameters. Otherwise, we allocate data sizeof parameters} less parameters. Otherwise, we allocate data sizeof parameters}
if parast.datasize>6*4 if parast.datasize>6*4
@ -98,20 +82,23 @@ procedure TSparcProcInfo.after_pass1;
localst.address_fixup:=parast.address_fixup+parast.datasize localst.address_fixup:=parast.address_fixup+parast.datasize
else else
procdef.localst.address_fixup:=parast.address_fixup+6*4; procdef.localst.address_fixup:=parast.address_fixup+6*4;
firsttemp_offset:=localst.address_fixup+localst.datasize; firsttemp_offset:=localst.address_fixup+localst.datasize;
with tg do with tg do
begin begin
SetFirstTemp(firsttemp_offset); SetFirstTemp(firsttemp_offset);
//LastTemp:=firsttemp_offset; //LastTemp:=firsttemp_offset;
end; end;
end; end;
end; end;
begin begin
cprocinfo:=TSparcProcInfo; cprocinfo:=TSparcProcInfo;
end. end.
{ {
$Log$ $Log$
Revision 1.12 2003-02-06 22:36:55 mazen Revision 1.13 2003-04-27 07:48:05 peter
* updated for removed lexlevel
Revision 1.12 2003/02/06 22:36:55 mazen
* fixing bug related to errornous program main entry stack frame * fixing bug related to errornous program main entry stack frame
Revision 1.11 2003/01/05 21:32:35 mazen Revision 1.11 2003/01/05 21:32:35 mazen

View File

@ -88,7 +88,7 @@ end;
{ consider it set function set if the offset was loaded } { consider it set function set if the offset was loaded }
if assigned(aktprocdef.funcretsym) and if assigned(aktprocdef.funcretsym) and
(pos(retstr,upper(s))>0) then (pos(retstr,upper(s))>0) then
tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned; tvarsym(aktprocdef.funcretsym).varstate:=vs_assigned;
s:=''; s:='';
end; end;
@ -97,7 +97,7 @@ end;
s:=''; s:='';
if assigned(aktprocdef.funcretsym) and if assigned(aktprocdef.funcretsym) and
is_fpu(aktprocdef.rettype.def) then is_fpu(aktprocdef.rettype.def) then
tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned; tvarsym(aktprocdef.funcretsym).varstate:=vs_assigned;
if (not is_void(aktprocdef.rettype.def)) then if (not is_void(aktprocdef.rettype.def)) then
retstr:=upper(tostr(procinfo.return_offset)+'('+std_reg2str[procinfo.framepointer.enum]+')') retstr:=upper(tostr(procinfo.return_offset)+'('+std_reg2str[procinfo.framepointer.enum]+')')
else else
@ -151,13 +151,13 @@ end;
paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) and paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) and
((pos('AX',upper(hs))>0) or ((pos('AX',upper(hs))>0) or
(pos('AL',upper(hs))>0)) then (pos('AL',upper(hs))>0)) then
tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned; tvarsym(aktprocdef.funcretsym).varstate:=vs_assigned;
if (s[length(s)]<>'%') and if (s[length(s)]<>'%') and
(s[length(s)]<>'$') and (s[length(s)]<>'$') and
((s[length(s)]<>'0') or (hs[1]<>'x')) then ((s[length(s)]<>'0') or (hs[1]<>'x')) then
begin begin
if assigned(aktprocdef.localst) and if assigned(aktprocdef.localst) and
(lexlevel >= normal_function_level) then (aktprocdef.localst.symtablelevel >= normal_function_level) then
sym:=tsym(aktprocdef.localst.search(upper(hs))) sym:=tsym(aktprocdef.localst.search(upper(hs)))
else else
sym:=nil; sym:=nil;
@ -247,7 +247,7 @@ end;
end end
else if upper(hs)='__SELF' then else if upper(hs)='__SELF' then
begin begin
if assigned(procinfo._class) then if assigned(aktprocdef._class) then
hs:=tostr(procinfo.selfpointer_offset)+ hs:=tostr(procinfo.selfpointer_offset)+
'('+std_reg2str[procinfo.framepointer.enum]+')' '('+std_reg2str[procinfo.framepointer.enum]+')'
else else
@ -264,7 +264,7 @@ end;
begin begin
{ complicate to check there } { complicate to check there }
{ we do it: } { we do it: }
if lexlevel>normal_function_level then if aktprocdef.parast.symtablelevel>normal_function_level then
hs:=tostr(procinfo.framepointer_offset)+ hs:=tostr(procinfo.framepointer_offset)+
'('+std_reg2str[procinfo.framepointer.enum]+')' '('+std_reg2str[procinfo.framepointer.enum]+')'
else else
@ -279,7 +279,7 @@ end;
end; end;
'{',';',#10,#13 : begin '{',';',#10,#13 : begin
if pos(retstr,s) > 0 then if pos(retstr,s) > 0 then
tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned; tvarsym(aktprocdef.funcretsym).varstate:=vs_assigned;
writeasmline; writeasmline;
c:=current_scanner.asmgetchar; c:=current_scanner.asmgetchar;
end; end;
@ -314,7 +314,10 @@ initialization
end. end.
{ {
$Log$ $Log$
Revision 1.5 2003-01-08 18:43:58 daniel Revision 1.6 2003-04-27 07:48:05 peter
* updated for removed lexlevel
Revision 1.5 2003/01/08 18:43:58 daniel
* Tregister changed into a record * Tregister changed into a record
Revision 1.4 2002/11/25 17:43:29 peter Revision 1.4 2002/11/25 17:43:29 peter