* moved call to resetusableregs to compile_proc_body (put it right before the

reset of the temp generator) so the optimizer can know which registers are
    regvars
This commit is contained in:
Jonas Maebe 2000-02-04 14:54:17 +00:00
parent 705b7cb752
commit 16e46c496c
2 changed files with 57 additions and 38 deletions

View File

@ -458,7 +458,7 @@ implementation
end; end;
var var
{ the array ranges are overestimated !!! } { the array ranges are oveestimated !!! }
{ max(maxvarregs,maxfpuvarregs) would be } { max(maxvarregs,maxfpuvarregs) would be }
{ enough } { enough }
regvars : array[1..maxvarregs+maxfpuvarregs] of pvarsym; regvars : array[1..maxvarregs+maxfpuvarregs] of pvarsym;
@ -467,32 +467,40 @@ implementation
parasym : boolean; parasym : boolean;
procedure searchregvars(p : pnamedindexobject); procedure searchregvars(p : pnamedindexobject);
var var
i,j,k : longint; i,j,k : longint;
begin begin
if (psym(p)^.typ=varsym) and (vo_regable in pvarsym(p)^.varoptions) then if (psym(p)^.typ=varsym) and (vo_regable in pvarsym(p)^.varoptions) then
begin begin
j:=pvarsym(p)^.refs; { walk through all momentary register variables }
{ parameter get a less value }
if parasym then
begin
if cs_littlesize in aktglobalswitches then
dec(j,1)
else
dec(j,100);
end;
for i:=1 to maxvarregs do for i:=1 to maxvarregs do
begin begin
if (regvars[i]=nil) or ((j>regvars_refs[i]) and (j>0)) then { free register ? }
if regvars[i]=nil then
begin
regvars[i]:=pvarsym(p);
regvars_para[i]:=parasym;
break;
end;
{ else throw out a variable ? }
j:=pvarsym(p)^.refs;
{ parameter get a less value }
if parasym then
begin
if cs_littlesize in aktglobalswitches then
dec(j,1)
else
dec(j,100);
end;
if (j>regvars_refs[i]) and (j>0) then
begin begin
for k:=maxvarregs-1 downto i do for k:=maxvarregs-1 downto i do
begin begin
regvars[k+1]:=regvars[k]; regvars[k+1]:=regvars[k];
regvars_para[k+1]:=regvars_para[k]; regvars_para[k+1]:=regvars_para[k];
regvars_refs[k+1]:=regvars_refs[k];
end; end;
{ calc the new refs
pvarsym(p)^.refs:=j; }
regvars[i]:=pvarsym(p); regvars[i]:=pvarsym(p);
regvars_para[i]:=parasym; regvars_para[i]:=parasym;
regvars_refs[i]:=j; regvars_refs[i]:=j;
@ -506,30 +514,38 @@ implementation
procedure searchfpuregvars(p : pnamedindexobject); procedure searchfpuregvars(p : pnamedindexobject);
var var
i,j,k : longint; i,j,k : longint;
begin begin
if (psym(p)^.typ=varsym) and (vo_fpuregable in pvarsym(p)^.varoptions) then if (psym(p)^.typ=varsym) and (vo_fpuregable in pvarsym(p)^.varoptions) then
begin begin
j:=pvarsym(p)^.refs; { walk through all momentary register variables }
{ parameter get a less value }
if parasym then
begin
if cs_littlesize in aktglobalswitches then
dec(j,1)
else
dec(j,100);
end;
for i:=1 to maxfpuvarregs do for i:=1 to maxfpuvarregs do
begin begin
{ free register ? }
if regvars[i]=nil then
begin
regvars[i]:=pvarsym(p);
regvars_para[i]:=parasym;
break;
end;
{ else throw out a variable ? } { else throw out a variable ? }
j:=pvarsym(p)^.refs;
{ parameter get a less value }
if parasym then
begin
if cs_littlesize in aktglobalswitches then
dec(j,1)
else
dec(j,100);
end;
if (j>regvars_refs[i]) and (j>0) then if (j>regvars_refs[i]) and (j>0) then
begin begin
for k:=maxfpuvarregs-1 downto i do for k:=maxfpuvarregs-1 downto i do
begin begin
regvars[k+1]:=regvars[k]; regvars[k+1]:=regvars[k];
regvars_para[k+1]:=regvars_para[k]; regvars_para[k+1]:=regvars_para[k];
regvars_refs[k+1]:=regvars_refs[k];
end; end;
{ calc the new refs
pvarsym(p)^.refs:=j; }
regvars[i]:=pvarsym(p); regvars[i]:=pvarsym(p);
regvars_para[i]:=parasym; regvars_para[i]:=parasym;
regvars_refs[i]:=j; regvars_refs[i]:=j;
@ -607,7 +623,7 @@ implementation
end; end;
*) *)
{ $ifdef dummy} { $ifdef dummy}
if (p^.registers32<maxvarregs) then if (p^.registers32<4) then
begin begin
for i:=1 to maxvarregs do for i:=1 to maxvarregs do
regvars[i]:=nil; regvars[i]:=nil;
@ -627,13 +643,12 @@ implementation
{ it is nonsens, to copy the variable to } { it is nonsens, to copy the variable to }
{ a register because we need then much } { a register because we need then much }
{ too pushes ? } { too pushes ? }
{
if reg_pushes[varregs[i]]>=regvars[i]^.refs then if reg_pushes[varregs[i]]>=regvars[i]^.refs then
begin begin
regvars[i]:=nil; regvars[i]:=nil;
goto nextreg; goto nextreg;
end; end;
}
{ register is no longer available for } { register is no longer available for }
{ expressions } { expressions }
{ search the register which is the most } { search the register which is the most }
@ -710,9 +725,6 @@ implementation
{ dummy } { dummy }
regsize:=S_W; regsize:=S_W;
end; end;
if cs_asm_source in aktglobalswitches then
procinfo^.aktentrycode^.insert(new(pai_asm_comment,init(strpnew(tostr(p^.registers32)+
' registers necessary to evaluate expressions'))));
for i:=1 to maxvarregs do for i:=1 to maxvarregs do
begin begin
if assigned(regvars[i]) then if assigned(regvars[i]) then
@ -828,8 +840,6 @@ implementation
if assigned(procinfo^.def) then if assigned(procinfo^.def) then
procinfo^.def^.fpu_used:=p^.registersfpu; procinfo^.def^.fpu_used:=p^.registersfpu;
{ all registers can be used again }
resetusableregisters;
end; end;
procinfo^.aktproccode^.concatlist(exprasmlist); procinfo^.aktproccode^.concatlist(exprasmlist);
make_const_global:=false; make_const_global:=false;
@ -838,8 +848,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.53 2000-02-04 08:47:10 florian Revision 1.54 2000-02-04 14:54:17 jonas
* better register variable allocation in -Or mode * moved call to resetusableregs to compile_proc_body (put it right before the
reset of the temp generator) so the optimizer can know which registers are
regvars
Revision 1.52 2000/01/22 15:58:12 jonas Revision 1.52 2000/01/22 15:58:12 jonas
* forgot to commit a procedure for -dlogsecondpass the last time * forgot to commit a procedure for -dlogsecondpass the last time
@ -966,4 +978,4 @@ end.
Revision 1.21 1999/05/17 21:57:11 florian Revision 1.21 1999/05/17 21:57:11 florian
* new temporary ansistring handling * new temporary ansistring handling
} }

View File

@ -1647,6 +1647,8 @@ begin
aktprocsym^.definition^.localst:=nil; aktprocsym^.definition^.localst:=nil;
end; end;
{ all registers can be used again }
resetusableregisters;
{ only now we can remove the temps } { only now we can remove the temps }
resettempgen; resettempgen;
@ -1967,7 +1969,12 @@ end.
{ {
$Log$ $Log$
Revision 1.44 2000-01-28 23:17:53 florian Revision 1.45 2000-02-04 14:54:17 jonas
* moved call to resetusableregs to compile_proc_body (put it right before the
reset of the temp generator) so the optimizer can know which registers are
regvars
Revision 1.44 2000/01/28 23:17:53 florian
* virtual XXXX; support for objects, only if -dWITHDMT is defined * virtual XXXX; support for objects, only if -dWITHDMT is defined
Revision 1.43 2000/01/21 22:06:16 florian Revision 1.43 2000/01/21 22:06:16 florian
@ -2104,4 +2111,4 @@ end.
* all tokens now start with an underscore * all tokens now start with an underscore
* PowerPC compiles!! * PowerPC compiles!!
} }