mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-07 00:59:33 +01:00
* fix filepositions
* insert spill temp allocations at the start of the proc
This commit is contained in:
parent
545f437740
commit
bf66a6e4ab
@ -685,6 +685,7 @@ implementation
|
|||||||
aktproccode.concatlist(templist);
|
aktproccode.concatlist(templist);
|
||||||
|
|
||||||
{ generate symbol and save end of header position }
|
{ generate symbol and save end of header position }
|
||||||
|
aktfilepos:=entrypos;
|
||||||
gen_proc_symbol(templist);
|
gen_proc_symbol(templist);
|
||||||
headertai:=tai(templist.last);
|
headertai:=tai(templist.last);
|
||||||
{ add entry code after header }
|
{ add entry code after header }
|
||||||
@ -694,6 +695,7 @@ implementation
|
|||||||
|
|
||||||
{ Free space in temp/registers for parast and localst, must be
|
{ Free space in temp/registers for parast and localst, must be
|
||||||
done after gen_entry_code }
|
done after gen_entry_code }
|
||||||
|
aktfilepos:=exitpos;
|
||||||
if current_procinfo.procdef.localst.symtabletype=localsymtable then
|
if current_procinfo.procdef.localst.symtabletype=localsymtable then
|
||||||
gen_free_localst(aktproccode,tlocalsymtable(current_procinfo.procdef.localst));
|
gen_free_localst(aktproccode,tlocalsymtable(current_procinfo.procdef.localst));
|
||||||
gen_free_parast(aktproccode,tparasymtable(current_procinfo.procdef.parast));
|
gen_free_parast(aktproccode,tparasymtable(current_procinfo.procdef.parast));
|
||||||
@ -718,7 +720,7 @@ implementation
|
|||||||
inc(spillingcounter);
|
inc(spillingcounter);
|
||||||
if spillingcounter>maxspillingcounter then
|
if spillingcounter>maxspillingcounter then
|
||||||
internalerror(200309041);
|
internalerror(200309041);
|
||||||
fastspill:=rg.spill_registers(aktproccode,rg.spillednodes);
|
fastspill:=rg.spill_registers(aktproccode,headertai,rg.spillednodes);
|
||||||
end;
|
end;
|
||||||
until (rg.spillednodes='') or not fastspill;
|
until (rg.spillednodes='') or not fastspill;
|
||||||
aktproccode.translate_registers(rg.colour);
|
aktproccode.translate_registers(rg.colour);
|
||||||
@ -734,13 +736,17 @@ implementation
|
|||||||
|
|
||||||
translate_regvars(aktproccode,rg.colour);
|
translate_regvars(aktproccode,rg.colour);
|
||||||
{ Add save and restore of used registers }
|
{ Add save and restore of used registers }
|
||||||
|
aktfilepos:=entrypos;
|
||||||
gen_save_used_regs(templist);
|
gen_save_used_regs(templist);
|
||||||
aktproccode.insertlistafter(headertai,templist);
|
aktproccode.insertlistafter(headertai,templist);
|
||||||
|
aktfilepos:=exitpos;
|
||||||
gen_restore_used_regs(aktproccode,usesacc,usesacchi,usesfpu);
|
gen_restore_used_regs(aktproccode,usesacc,usesacchi,usesfpu);
|
||||||
{ Add stack allocation code after header }
|
{ Add stack allocation code after header }
|
||||||
|
aktfilepos:=entrypos;
|
||||||
gen_stackalloc_code(templist);
|
gen_stackalloc_code(templist);
|
||||||
aktproccode.insertlistafter(headertai,templist);
|
aktproccode.insertlistafter(headertai,templist);
|
||||||
{ Add exit code at the end }
|
{ Add exit code at the end }
|
||||||
|
aktfilepos:=exitpos;
|
||||||
gen_exit_code(templist,false,usesacc,usesacchi);
|
gen_exit_code(templist,false,usesacc,usesacchi);
|
||||||
aktproccode.concatlist(templist);
|
aktproccode.concatlist(templist);
|
||||||
|
|
||||||
@ -1295,7 +1301,11 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.149 2003-09-23 17:56:06 peter
|
Revision 1.150 2003-09-25 16:19:32 peter
|
||||||
|
* fix filepositions
|
||||||
|
* insert spill temp allocations at the start of the proc
|
||||||
|
|
||||||
|
Revision 1.149 2003/09/23 17:56:06 peter
|
||||||
* locals and paras are allocated in the code generation
|
* locals and paras are allocated in the code generation
|
||||||
* tvarsym.localloc contains the location of para/local when
|
* tvarsym.localloc contains the location of para/local when
|
||||||
generating code for the current procedure
|
generating code for the current procedure
|
||||||
|
|||||||
@ -338,7 +338,7 @@ unit rgobj;
|
|||||||
procedure prepare_colouring;
|
procedure prepare_colouring;
|
||||||
procedure epilogue_colouring;
|
procedure epilogue_colouring;
|
||||||
procedure colour_registers;
|
procedure colour_registers;
|
||||||
function spill_registers(list:Taasmoutput;const regs_to_spill:string):boolean;
|
function spill_registers(list:Taasmoutput;headertai:tai;const regs_to_spill:string):boolean;
|
||||||
procedure add_edge(u,v:Tsuperregister);
|
procedure add_edge(u,v:Tsuperregister);
|
||||||
protected
|
protected
|
||||||
cpu_registers:byte;
|
cpu_registers:byte;
|
||||||
@ -2034,7 +2034,7 @@ unit rgobj;
|
|||||||
add_constraints(r);
|
add_constraints(r);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Trgobj.spill_registers(list:Taasmoutput;const regs_to_spill:string):boolean;
|
function Trgobj.spill_registers(list:Taasmoutput;headertai:tai;const regs_to_spill:string):boolean;
|
||||||
|
|
||||||
{Returns true if any help registers have been used.}
|
{Returns true if any help registers have been used.}
|
||||||
|
|
||||||
@ -2042,9 +2042,11 @@ unit rgobj;
|
|||||||
p,q:Tai;
|
p,q:Tai;
|
||||||
regs_to_spill_set:Tsuperregisterset;
|
regs_to_spill_set:Tsuperregisterset;
|
||||||
spill_temps:^Tspill_temp_list;
|
spill_temps:^Tspill_temp_list;
|
||||||
|
templist : taasmoutput;
|
||||||
supreg : tsuperregister;
|
supreg : tsuperregister;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
aktfilepos:=current_procinfo.entrypos;
|
||||||
spill_registers:=false;
|
spill_registers:=false;
|
||||||
unusedregsint:=[0..255];
|
unusedregsint:=[0..255];
|
||||||
fillchar(degree,sizeof(degree),0);
|
fillchar(degree,sizeof(degree),0);
|
||||||
@ -2059,16 +2061,22 @@ unit rgobj;
|
|||||||
new(spill_temps);
|
new(spill_temps);
|
||||||
fillchar(spill_temps^,sizeof(spill_temps^),0);
|
fillchar(spill_temps^,sizeof(spill_temps^),0);
|
||||||
regs_to_spill_set:=[];
|
regs_to_spill_set:=[];
|
||||||
|
{ Allocate temps and insert in front of the list }
|
||||||
|
templist:=taasmoutput.create;
|
||||||
for i:=1 to length(regs_to_spill) do
|
for i:=1 to length(regs_to_spill) do
|
||||||
begin
|
begin
|
||||||
{Alternative representation.}
|
{Alternative representation.}
|
||||||
include(regs_to_spill_set,Tsuperregister(regs_to_spill[i]));
|
include(regs_to_spill_set,Tsuperregister(regs_to_spill[i]));
|
||||||
{Clear all interferences of the spilled register.}
|
{Clear all interferences of the spilled register.}
|
||||||
clear_interferences(Tsuperregister(regs_to_spill[i]));
|
clear_interferences(Tsuperregister(regs_to_spill[i]));
|
||||||
{Get a temp for the spilled register.}
|
{Get a temp for the spilled register}
|
||||||
tg.gettemp(list,4,tt_noreuse,spill_temps^[Tsuperregister(regs_to_spill[i])]);
|
tg.gettemp(templist,4,tt_noreuse,spill_temps^[Tsuperregister(regs_to_spill[i])]);
|
||||||
end;
|
end;
|
||||||
p:=Tai(list.first);
|
list.insertlistafter(headertai,templist);
|
||||||
|
templist.free;
|
||||||
|
{ Walk through all instructions, we can start with the headertai,
|
||||||
|
because before the header tai is only symbols }
|
||||||
|
p:=headertai;
|
||||||
while assigned(p) do
|
while assigned(p) do
|
||||||
begin
|
begin
|
||||||
case p.typ of
|
case p.typ of
|
||||||
@ -2091,6 +2099,8 @@ unit rgobj;
|
|||||||
end;
|
end;
|
||||||
ait_instruction:
|
ait_instruction:
|
||||||
begin
|
begin
|
||||||
|
aktfilepos:=Taicpu_abstract(p).fileinfo
|
||||||
|
;
|
||||||
if Taicpu_abstract(p).spill_registers(list,@getregisterintinline,
|
if Taicpu_abstract(p).spill_registers(list,@getregisterintinline,
|
||||||
@ungetregisterintinline,
|
@ungetregisterintinline,
|
||||||
regs_to_spill_set,
|
regs_to_spill_set,
|
||||||
@ -2103,6 +2113,7 @@ unit rgobj;
|
|||||||
end;
|
end;
|
||||||
p:=Tai(p.next);
|
p:=Tai(p.next);
|
||||||
end;
|
end;
|
||||||
|
aktfilepos:=current_procinfo.exitpos;
|
||||||
for i:=1 to length(regs_to_spill) do
|
for i:=1 to length(regs_to_spill) do
|
||||||
begin
|
begin
|
||||||
tg.ungettemp(list,spill_temps^[Tsuperregister(regs_to_spill[i])]);
|
tg.ungettemp(list,spill_temps^[Tsuperregister(regs_to_spill[i])]);
|
||||||
@ -2225,7 +2236,11 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.76 2003-09-16 16:17:01 peter
|
Revision 1.77 2003-09-25 16:19:32 peter
|
||||||
|
* fix filepositions
|
||||||
|
* insert spill temp allocations at the start of the proc
|
||||||
|
|
||||||
|
Revision 1.76 2003/09/16 16:17:01 peter
|
||||||
* varspez in calls to push_addr_param
|
* varspez in calls to push_addr_param
|
||||||
|
|
||||||
Revision 1.75 2003/09/12 19:07:42 daniel
|
Revision 1.75 2003/09/12 19:07:42 daniel
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user