mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-10 08:59:29 +01:00
* call firstpass before allocation and codegeneration is started
* move leftover code from pass_2.generatecode() to psub
This commit is contained in:
parent
1953a4a4f2
commit
9e66b09843
@ -37,10 +37,6 @@ uses
|
||||
allow_multi_pass2 : boolean;
|
||||
flowcontrol : tflowcontrol;
|
||||
|
||||
{ produces assembler for the expression in variable p }
|
||||
{ and produces an assembler node at the end }
|
||||
procedure generatecode(var p : tnode);
|
||||
|
||||
{ produces the actual code }
|
||||
function do_secondpass(var p : tnode) : boolean;
|
||||
procedure secondpass(var p : tnode);
|
||||
@ -210,78 +206,15 @@ implementation
|
||||
do_secondpass:=codegenerror;
|
||||
end;
|
||||
|
||||
procedure clearrefs(p : tnamedindexitem;arg:pointer);
|
||||
|
||||
begin
|
||||
if (tsym(p).typ=varsym) then
|
||||
if tvarsym(p).refs>1 then
|
||||
tvarsym(p).refs:=1;
|
||||
end;
|
||||
|
||||
procedure generatecode(var p : tnode);
|
||||
begin
|
||||
flowcontrol:=[];
|
||||
{ when size optimization only count occurrence }
|
||||
if cs_littlesize in aktglobalswitches then
|
||||
cg.t_times:=1
|
||||
else
|
||||
{ reference for repetition is 100 }
|
||||
cg.t_times:=100;
|
||||
{ clear register count }
|
||||
symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
|
||||
symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
|
||||
{ firstpass everything }
|
||||
do_firstpass(p);
|
||||
|
||||
{ after pass 1, we should have all necessary information to set the temp. start location }
|
||||
current_procinfo.set_first_temp_offset;
|
||||
{ only do secondpass if there are no errors }
|
||||
if ErrorCount=0 then
|
||||
begin
|
||||
{ caller paraloc info is also necessary in the stackframe_entry }
|
||||
{ code of the ppc (and possibly other processors) }
|
||||
if not current_procinfo.procdef.has_paraloc_info then
|
||||
begin
|
||||
paramanager.create_paraloc_info(current_procinfo.procdef,callerside);
|
||||
current_procinfo.procdef.has_paraloc_info:=true;
|
||||
end;
|
||||
|
||||
{ process register variable stuff (JM) }
|
||||
{ assign_regvars(p);}
|
||||
{ load_regvars(current_procinfo.aktentrycode,p);}
|
||||
|
||||
{ for the i386 it must be done in genexitcode because it has }
|
||||
{ to add 'fstp' instructions when using fpu regvars and those }
|
||||
{ must come after the "exitlabel" (JM) }
|
||||
{$ifndef i386}
|
||||
{ cleanup_regvars(current_procinfo.aktexitcode);}
|
||||
{$endif i386}
|
||||
|
||||
{ current_procinfo.allocate_framepointer_reg;}
|
||||
|
||||
do_secondpass(p);
|
||||
|
||||
{$ifdef EXTDEBUG}
|
||||
{
|
||||
for sr:=first_int_imreg to last_int_imreg do
|
||||
if not(sr in rg.unusedregsint) then
|
||||
Comment(V_Warning,'Register '+std_regname(newreg(R_INTREGISTER,sr,R_SUBNONE))+' not released');
|
||||
}
|
||||
{$endif EXTDEBUG}
|
||||
|
||||
{$ifdef i386}
|
||||
if assigned(current_procinfo.procdef) then
|
||||
current_procinfo.procdef.fpu_used:=p.registersfpu;
|
||||
{$endif i386}
|
||||
|
||||
end;
|
||||
current_procinfo.aktproccode.concatlist(exprasmlist);
|
||||
end;
|
||||
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.72 2003-10-19 01:34:30 florian
|
||||
Revision 1.73 2003-10-30 16:22:40 peter
|
||||
* call firstpass before allocation and codegeneration is started
|
||||
* move leftover code from pass_2.generatecode() to psub
|
||||
|
||||
Revision 1.72 2003/10/19 01:34:30 florian
|
||||
* some ppc stuff fixed
|
||||
* memory leak fixed
|
||||
|
||||
|
||||
@ -566,6 +566,14 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure clearrefs(p : tnamedindexitem;arg:pointer);
|
||||
begin
|
||||
if (tsym(p).typ=varsym) then
|
||||
if tvarsym(p).refs>1 then
|
||||
tvarsym(p).refs:=1;
|
||||
end;
|
||||
|
||||
|
||||
procedure tcgprocinfo.generate_code;
|
||||
var
|
||||
oldprocinfo : tprocinfo;
|
||||
@ -605,6 +613,24 @@ implementation
|
||||
{ add parast/localst to symtablestack }
|
||||
add_to_symtablestack;
|
||||
|
||||
{ when size optimization only count occurrence }
|
||||
if cs_littlesize in aktglobalswitches then
|
||||
cg.t_times:=1
|
||||
else
|
||||
{ reference for repetition is 100 }
|
||||
cg.t_times:=100;
|
||||
|
||||
{ clear register count }
|
||||
symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
|
||||
symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
|
||||
|
||||
{ firstpass everything }
|
||||
flowcontrol:=[];
|
||||
do_firstpass(code);
|
||||
|
||||
{ only do secondpass if there are no errors }
|
||||
if ErrorCount=0 then
|
||||
begin
|
||||
{ set the start offset to the start of the temp area in the stack }
|
||||
tg:=ttgobj.create;
|
||||
|
||||
@ -631,8 +657,20 @@ implementation
|
||||
aktfilepos:=entrypos;
|
||||
gen_load_para_value(templist);
|
||||
|
||||
{ generate code for the body }
|
||||
generatecode(code);
|
||||
{ caller paraloc info is also necessary in the stackframe_entry
|
||||
code of the ppc (and possibly other processors) }
|
||||
if not procdef.has_paraloc_info then
|
||||
begin
|
||||
paramanager.create_paraloc_info(procdef,callerside);
|
||||
procdef.has_paraloc_info:=true;
|
||||
end;
|
||||
|
||||
{ generate code for the node tree }
|
||||
do_secondpass(code);
|
||||
current_procinfo.aktproccode.concatlist(exprasmlist);
|
||||
{$ifdef i386}
|
||||
procdef.fpu_used:=code.registersfpu;
|
||||
{$endif i386}
|
||||
|
||||
{ The position of the loadpara_asmnode is now known }
|
||||
aktproccode.insertlistafter(loadpara_asmnode.currenttai,templist);
|
||||
@ -719,8 +757,6 @@ implementation
|
||||
*)
|
||||
end;
|
||||
|
||||
{$warning fixme translate_regvars}
|
||||
{ translate_regvars(aktproccode,rg.colour);}
|
||||
{ Add save and restore of used registers }
|
||||
aktfilepos:=entrypos;
|
||||
gen_save_used_regs(templist);
|
||||
@ -767,6 +803,7 @@ implementation
|
||||
tg.free;
|
||||
cg.done_register_allocators;
|
||||
tg:=nil;
|
||||
end;
|
||||
|
||||
{ restore symtablestack }
|
||||
remove_from_symtablestack;
|
||||
@ -1266,7 +1303,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.167 2003-10-24 17:40:23 peter
|
||||
Revision 1.168 2003-10-30 16:22:40 peter
|
||||
* call firstpass before allocation and codegeneration is started
|
||||
* move leftover code from pass_2.generatecode() to psub
|
||||
|
||||
Revision 1.167 2003/10/24 17:40:23 peter
|
||||
* cleanup of the entry and exit code insertion
|
||||
|
||||
Revision 1.166 2003/10/21 15:14:33 peter
|
||||
|
||||
@ -235,6 +235,7 @@ unit rgobj;
|
||||
procedure translate_registers(list:Taasmoutput);
|
||||
{# Adds an interference edge.}
|
||||
procedure add_edge(u,v:Tsuperregister);
|
||||
procedure check_unreleasedregs;
|
||||
|
||||
unusedregs : Tsuperregisterset;
|
||||
|
||||
@ -1801,10 +1802,29 @@ implementation
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure Trgobj.check_unreleasedregs;
|
||||
{$ifdef EXTDEBUG}
|
||||
var
|
||||
sr : tsuperregister;
|
||||
{$endif EXTDEBUG}
|
||||
begin
|
||||
{$ifdef EXTDEBUG}
|
||||
for sr:=first_imaginary to maxreg-1 do
|
||||
if not(supregset_in(unusedregs,sr)) then
|
||||
Comment(V_Warning,'Register '+std_regname(newreg(R_INTREGISTER,sr,R_SUBNONE))+' not released');
|
||||
{$endif EXTDEBUG}
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.92 2003-10-29 21:29:14 jonas
|
||||
Revision 1.93 2003-10-30 16:22:40 peter
|
||||
* call firstpass before allocation and codegeneration is started
|
||||
* move leftover code from pass_2.generatecode() to psub
|
||||
|
||||
Revision 1.92 2003/10/29 21:29:14 jonas
|
||||
* some ALLOWDUPREG improvements
|
||||
|
||||
Revision 1.91 2003/10/21 15:15:36 peter
|
||||
|
||||
@ -310,9 +310,11 @@ unit cgx86;
|
||||
|
||||
begin
|
||||
{ Int }
|
||||
rgint.check_unreleasedregs;
|
||||
rgint.do_register_allocation(list,headertai);
|
||||
rgint.translate_registers(list);
|
||||
{ SSE }
|
||||
rgmm.check_unreleasedregs;
|
||||
rgmm.do_register_allocation(list,headertai);
|
||||
rgmm.translate_registers(list);
|
||||
end;
|
||||
@ -1735,7 +1737,11 @@ unit cgx86;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.84 2003-10-29 21:24:14 jonas
|
||||
Revision 1.85 2003-10-30 16:22:40 peter
|
||||
* call firstpass before allocation and codegeneration is started
|
||||
* move leftover code from pass_2.generatecode() to psub
|
||||
|
||||
Revision 1.84 2003/10/29 21:24:14 jonas
|
||||
+ support for fpu temp parameters
|
||||
+ saving/restoring of fpu register before/after a procedure call
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user