mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-26 21:11:46 +01:00
* Adding register allocation order
This commit is contained in:
parent
05a15df3c2
commit
49e539ac8d
@ -64,6 +64,9 @@ unit cgobj;
|
|||||||
{ basic routines }
|
{ basic routines }
|
||||||
constructor create;
|
constructor create;
|
||||||
|
|
||||||
|
procedure init_register_allocators;virtual;abstract;
|
||||||
|
procedure done_register_allocators;virtual;abstract;
|
||||||
|
|
||||||
{ returns the tcgsize corresponding with the size of reg }
|
{ returns the tcgsize corresponding with the size of reg }
|
||||||
class function reg_cgsize(const reg: tregister) : tcgsize; virtual;
|
class function reg_cgsize(const reg: tregister) : tcgsize; virtual;
|
||||||
|
|
||||||
@ -1536,7 +1539,10 @@ finalization
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.119 2003-09-07 22:09:34 peter
|
Revision 1.120 2003-09-09 20:59:27 daniel
|
||||||
|
* Adding register allocation order
|
||||||
|
|
||||||
|
Revision 1.119 2003/09/07 22:09:34 peter
|
||||||
* preparations for different default calling conventions
|
* preparations for different default calling conventions
|
||||||
* various RA fixes
|
* various RA fixes
|
||||||
|
|
||||||
|
|||||||
@ -38,8 +38,6 @@ unit rgcpu;
|
|||||||
trgcpu = class(trgobj)
|
trgcpu = class(trgobj)
|
||||||
fpuvaroffset : byte;
|
fpuvaroffset : byte;
|
||||||
|
|
||||||
constructor create;override;
|
|
||||||
|
|
||||||
{ to keep the same allocation order as with the old routines }
|
{ to keep the same allocation order as with the old routines }
|
||||||
procedure add_constraints(reg:Tregister);override;
|
procedure add_constraints(reg:Tregister);override;
|
||||||
|
|
||||||
@ -87,13 +85,6 @@ unit rgcpu;
|
|||||||
{ trgcpu }
|
{ trgcpu }
|
||||||
{************************************************************************}
|
{************************************************************************}
|
||||||
|
|
||||||
constructor Trgcpu.create;
|
|
||||||
begin
|
|
||||||
inherited create;
|
|
||||||
cpu_registers:=6;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure Trgcpu.add_constraints(reg:Tregister);
|
procedure Trgcpu.add_constraints(reg:Tregister);
|
||||||
var
|
var
|
||||||
supreg : tsuperregister;
|
supreg : tsuperregister;
|
||||||
@ -250,12 +241,14 @@ unit rgcpu;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
crgobj:=trgcpu;
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.33 2003-09-07 22:09:35 peter
|
Revision 1.34 2003-09-09 20:59:27 daniel
|
||||||
|
* Adding register allocation order
|
||||||
|
|
||||||
|
Revision 1.33 2003/09/07 22:09:35 peter
|
||||||
* preparations for different default calling conventions
|
* preparations for different default calling conventions
|
||||||
* various RA fixes
|
* various RA fixes
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ implementation
|
|||||||
globals,verbose,fmodule,finput,fppu,
|
globals,verbose,fmodule,finput,fppu,
|
||||||
symconst,symbase,symtype,symdef,symsym,symtable,
|
symconst,symbase,symtype,symdef,symsym,symtable,
|
||||||
aasmbase,aasmtai,aasmcpu,
|
aasmbase,aasmtai,aasmcpu,
|
||||||
cgbase,cpuinfo,rgobj,
|
cgbase,cpuinfo,cgobj,
|
||||||
ncgutil,
|
ncgutil,
|
||||||
link,assemble,import,export,gendef,ppu,comprsrc,
|
link,assemble,import,export,gendef,ppu,comprsrc,
|
||||||
cresstr,cpubase,
|
cresstr,cpubase,
|
||||||
@ -727,7 +727,7 @@ implementation
|
|||||||
current_module.procinfo:=current_procinfo;
|
current_module.procinfo:=current_procinfo;
|
||||||
current_procinfo.procdef:=pd;
|
current_procinfo.procdef:=pd;
|
||||||
{ start register allocator }
|
{ start register allocator }
|
||||||
rg:=crgobj.create;
|
cg.init_register_allocators;
|
||||||
{ return procdef }
|
{ return procdef }
|
||||||
create_main_proc:=pd;
|
create_main_proc:=pd;
|
||||||
end;
|
end;
|
||||||
@ -741,7 +741,7 @@ implementation
|
|||||||
not(current_procinfo.procdef=pd) then
|
not(current_procinfo.procdef=pd) then
|
||||||
internalerror(200304276);
|
internalerror(200304276);
|
||||||
{ remove register allocator }
|
{ remove register allocator }
|
||||||
rg.free;
|
cg.done_register_allocators;
|
||||||
{ remove procinfo }
|
{ remove procinfo }
|
||||||
current_module.procinfo:=nil;
|
current_module.procinfo:=nil;
|
||||||
current_procinfo.free;
|
current_procinfo.free;
|
||||||
@ -1471,7 +1471,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.123 2003-09-09 15:55:44 peter
|
Revision 1.124 2003-09-09 20:59:27 daniel
|
||||||
|
* Adding register allocation order
|
||||||
|
|
||||||
|
Revision 1.123 2003/09/09 15:55:44 peter
|
||||||
* use register with least interferences in spillregister
|
* use register with least interferences in spillregister
|
||||||
|
|
||||||
Revision 1.122 2003/09/07 22:09:35 peter
|
Revision 1.122 2003/09/07 22:09:35 peter
|
||||||
|
|||||||
@ -89,7 +89,7 @@ implementation
|
|||||||
scanner,
|
scanner,
|
||||||
pbase,pstatmnt,pdecl,pdecsub,pexports,
|
pbase,pstatmnt,pdecl,pdecsub,pexports,
|
||||||
{ codegen }
|
{ codegen }
|
||||||
tgobj,rgobj,
|
tgobj,rgobj,cgobj,
|
||||||
ncgutil,regvars
|
ncgutil,regvars
|
||||||
{$ifndef NOOPT}
|
{$ifndef NOOPT}
|
||||||
{$ifdef i386}
|
{$ifdef i386}
|
||||||
@ -610,7 +610,7 @@ implementation
|
|||||||
tg.setfirsttemp(firsttemp_offset);
|
tg.setfirsttemp(firsttemp_offset);
|
||||||
|
|
||||||
{ Create register allocator }
|
{ Create register allocator }
|
||||||
rg:=crgobj.create;
|
cg.init_register_allocators;
|
||||||
|
|
||||||
{$warning FIXME!!}
|
{$warning FIXME!!}
|
||||||
{ FIXME!! If a procedure contains assembler blocks (or is pure assembler), }
|
{ FIXME!! If a procedure contains assembler blocks (or is pure assembler), }
|
||||||
@ -757,7 +757,7 @@ implementation
|
|||||||
remove_from_symtablestack;
|
remove_from_symtablestack;
|
||||||
|
|
||||||
{ restore }
|
{ restore }
|
||||||
rg.free;
|
cg.done_register_allocators;
|
||||||
templist.free;
|
templist.free;
|
||||||
rg:=oldrg;
|
rg:=oldrg;
|
||||||
aktmaxfpuregisters:=oldaktmaxfpuregisters;
|
aktmaxfpuregisters:=oldaktmaxfpuregisters;
|
||||||
@ -1315,7 +1315,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.143 2003-09-09 15:55:44 peter
|
Revision 1.144 2003-09-09 20:59:27 daniel
|
||||||
|
* Adding register allocation order
|
||||||
|
|
||||||
|
Revision 1.143 2003/09/09 15:55:44 peter
|
||||||
* use register with least interferences in spillregister
|
* use register with least interferences in spillregister
|
||||||
|
|
||||||
Revision 1.142 2003/09/07 22:09:35 peter
|
Revision 1.142 2003/09/07 22:09:35 peter
|
||||||
|
|||||||
@ -162,6 +162,7 @@ unit rgobj;
|
|||||||
{ contain all registers of type "xxx" that aren't currently }
|
{ contain all registers of type "xxx" that aren't currently }
|
||||||
{ allocated }
|
{ allocated }
|
||||||
lastintreg,maxintreg:Tsuperregister;
|
lastintreg,maxintreg:Tsuperregister;
|
||||||
|
usable_registers:string[32];
|
||||||
unusedregsint,usableregsint:Tsuperregisterset;
|
unusedregsint,usableregsint:Tsuperregisterset;
|
||||||
unusedregsaddr,usableregsaddr:Tsuperregisterset;
|
unusedregsaddr,usableregsaddr:Tsuperregisterset;
|
||||||
unusedregsfpu,usableregsfpu : Tsuperregisterset;
|
unusedregsfpu,usableregsfpu : Tsuperregisterset;
|
||||||
@ -193,7 +194,7 @@ unit rgobj;
|
|||||||
{ tries to hold the amount of times which the current tree is processed }
|
{ tries to hold the amount of times which the current tree is processed }
|
||||||
t_times: longint;
|
t_times: longint;
|
||||||
|
|
||||||
constructor create;virtual;
|
constructor create(Acpu_registers:byte;const Ausable:string);
|
||||||
destructor destroy;virtual;
|
destructor destroy;virtual;
|
||||||
|
|
||||||
{# Allocate a general purpose register
|
{# Allocate a general purpose register
|
||||||
@ -396,8 +397,6 @@ unit rgobj;
|
|||||||
reg_not_saved = $7fffffff;
|
reg_not_saved = $7fffffff;
|
||||||
|
|
||||||
var
|
var
|
||||||
{# This is the class instance used to access the register allocator class }
|
|
||||||
crgobj : trgobjclass;
|
|
||||||
rg : trgobj;
|
rg : trgobj;
|
||||||
|
|
||||||
{ trerefence handling }
|
{ trerefence handling }
|
||||||
@ -461,7 +460,8 @@ unit rgobj;
|
|||||||
globals,verbose,
|
globals,verbose,
|
||||||
cgobj,tgobj,regvars;
|
cgobj,tgobj,regvars;
|
||||||
|
|
||||||
constructor Trgobj.create;
|
constructor Trgobj.create(Acpu_registers:byte;const Ausable:string);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
used_in_proc_int := [];
|
used_in_proc_int := [];
|
||||||
used_in_proc_other:=[];
|
used_in_proc_other:=[];
|
||||||
@ -469,7 +469,7 @@ unit rgobj;
|
|||||||
resetusableregisters;
|
resetusableregisters;
|
||||||
lastintreg:=0;
|
lastintreg:=0;
|
||||||
maxintreg:=first_int_imreg;
|
maxintreg:=first_int_imreg;
|
||||||
cpu_registers:=0;
|
cpu_registers:=Acpu_registers;
|
||||||
unusedregsint:=[0..254]; { 255 (RS_INVALID) can't be used }
|
unusedregsint:=[0..254]; { 255 (RS_INVALID) can't be used }
|
||||||
unusedregsfpu:=usableregsfpu;
|
unusedregsfpu:=usableregsfpu;
|
||||||
unusedregsmm:=usableregsmm;
|
unusedregsmm:=usableregsmm;
|
||||||
@ -486,6 +486,7 @@ unit rgobj;
|
|||||||
by 255.}
|
by 255.}
|
||||||
fillchar(movelist,sizeof(movelist),0);
|
fillchar(movelist,sizeof(movelist),0);
|
||||||
worklist_moves:=Tlinkedlist.create;
|
worklist_moves:=Tlinkedlist.create;
|
||||||
|
usable_registers:=Ausable;
|
||||||
abtlist:='';
|
abtlist:='';
|
||||||
fillchar(colour,sizeof(colour),RS_INVALID);
|
fillchar(colour,sizeof(colour),RS_INVALID);
|
||||||
end;
|
end;
|
||||||
@ -1668,7 +1669,7 @@ unit rgobj;
|
|||||||
|
|
||||||
var adj:Pstring;
|
var adj:Pstring;
|
||||||
i,j,k:byte;
|
i,j,k:byte;
|
||||||
n,a:Tsuperregister;
|
n,a,c:Tsuperregister;
|
||||||
adj_colours,colourednodes:set of Tsuperregister;
|
adj_colours,colourednodes:set of Tsuperregister;
|
||||||
w:char;
|
w:char;
|
||||||
|
|
||||||
@ -1698,16 +1699,19 @@ unit rgobj;
|
|||||||
{Assume a spill by default...}
|
{Assume a spill by default...}
|
||||||
spillednodes:=spillednodes+char(n);
|
spillednodes:=spillednodes+char(n);
|
||||||
{Search for a colour not in this list.}
|
{Search for a colour not in this list.}
|
||||||
for k:=first_int_supreg to last_int_supreg do
|
for k:=1 to length(usable_registers) do
|
||||||
if not(k in adj_colours) then
|
begin
|
||||||
begin
|
c:=Tsuperregister(usable_registers[k]);
|
||||||
colour[n]:=k;
|
if not(c in adj_colours) then
|
||||||
dec(spillednodes[0]); {Colour found: no spill.}
|
begin
|
||||||
include(colourednodes,n);
|
colour[n]:=c;
|
||||||
if n in used_in_proc_int then
|
dec(spillednodes[0]); {Colour found: no spill.}
|
||||||
include(used_in_proc_int,k);
|
include(colourednodes,n);
|
||||||
break;
|
if n in used_in_proc_int then
|
||||||
end;
|
include(used_in_proc_int,c);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
{Finally colour the nodes that were coalesced.}
|
{Finally colour the nodes that were coalesced.}
|
||||||
for i:=1 to length(coalescednodes) do
|
for i:=1 to length(coalescednodes) do
|
||||||
@ -2213,16 +2217,14 @@ unit rgobj;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
initialization
|
|
||||||
{ This check is required because rgcpu is initialized before rgobj
|
|
||||||
when compiling with FPC 1.0.x (PFV) }
|
|
||||||
if not assigned(crgobj) then
|
|
||||||
crgobj:=trgobj;
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.72 2003-09-09 15:55:44 peter
|
Revision 1.73 2003-09-09 20:59:27 daniel
|
||||||
|
* Adding register allocation order
|
||||||
|
|
||||||
|
Revision 1.72 2003/09/09 15:55:44 peter
|
||||||
* use register with least interferences in spillregister
|
* use register with least interferences in spillregister
|
||||||
|
|
||||||
Revision 1.71 2003/09/07 22:09:35 peter
|
Revision 1.71 2003/09/07 22:09:35 peter
|
||||||
|
|||||||
@ -37,6 +37,9 @@ unit cgx86;
|
|||||||
type
|
type
|
||||||
tcgx86 = class(tcg)
|
tcgx86 = class(tcg)
|
||||||
|
|
||||||
|
procedure init_register_allocators;override;
|
||||||
|
procedure done_register_allocators;override;
|
||||||
|
|
||||||
{ passing parameters, per default the parameter is pushed }
|
{ passing parameters, per default the parameter is pushed }
|
||||||
{ nr gives the number of the parameter (enumerated from }
|
{ nr gives the number of the parameter (enumerated from }
|
||||||
{ left to right), this allows to move the parameter to }
|
{ left to right), this allows to move the parameter to }
|
||||||
@ -163,6 +166,18 @@ unit cgx86;
|
|||||||
This is private property, keep out! :)
|
This is private property, keep out! :)
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
|
procedure Tcgx86.init_register_allocators;
|
||||||
|
|
||||||
|
begin
|
||||||
|
rg:=Trgcpu.create(6,#0#1#2#3#4#5);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Tcgx86.done_register_allocators;
|
||||||
|
|
||||||
|
begin
|
||||||
|
rg.free;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure tcgx86.sizes2load(s1,s2 : tcgsize; var op: tasmop; var s3: topsize);
|
procedure tcgx86.sizes2load(s1,s2 : tcgsize; var op: tasmop; var s3: topsize);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -1557,7 +1572,10 @@ unit cgx86;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.61 2003-09-07 22:09:35 peter
|
Revision 1.62 2003-09-09 20:59:27 daniel
|
||||||
|
* Adding register allocation order
|
||||||
|
|
||||||
|
Revision 1.61 2003/09/07 22:09:35 peter
|
||||||
* preparations for different default calling conventions
|
* preparations for different default calling conventions
|
||||||
* various RA fixes
|
* various RA fixes
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user