mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 21:09:07 +02:00
+ store references to global variables in registers if benefical (currrently used for aarch64 only)
This commit is contained in:
parent
2cf68f6dbf
commit
5921fa9a62
@ -596,6 +596,17 @@ unit optcse;
|
|||||||
tconstentries = array of tconstentry;
|
tconstentries = array of tconstentry;
|
||||||
pconstentries = ^tconstentries;
|
pconstentries = ^tconstentries;
|
||||||
|
|
||||||
|
function CSEOnReference(n : tnode) : Boolean;
|
||||||
|
begin
|
||||||
|
Result:=(n.nodetype=loadn) and (tloadnode(n).symtableentry.typ=staticvarsym)
|
||||||
|
and ((vo_is_thread_var in tstaticvarsym(tloadnode(n).symtableentry).varoptions)
|
||||||
|
{$if defined(aarch64)}
|
||||||
|
or (not(tabstractvarsym(tloadnode(n).symtableentry).is_regvar(false)))
|
||||||
|
{$endif defined(aarch64)}
|
||||||
|
);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function collectconsts(var n:tnode; arg: pointer) : foreachnoderesult;
|
function collectconsts(var n:tnode; arg: pointer) : foreachnoderesult;
|
||||||
var
|
var
|
||||||
consts: pconstentries;
|
consts: pconstentries;
|
||||||
@ -610,9 +621,7 @@ unit optcse;
|
|||||||
and use_vectorfpu(n.resultdef)
|
and use_vectorfpu(n.resultdef)
|
||||||
{$endif x86}
|
{$endif x86}
|
||||||
) or
|
) or
|
||||||
((n.nodetype=loadn) and (tloadnode(n).symtableentry.typ=staticvarsym) and
|
CSEOnReference(n) then
|
||||||
(vo_is_thread_var in tstaticvarsym(tloadnode(n).symtableentry).varoptions)
|
|
||||||
) then
|
|
||||||
begin
|
begin
|
||||||
found:=false;
|
found:=false;
|
||||||
i:=0;
|
i:=0;
|
||||||
@ -647,9 +656,8 @@ unit optcse;
|
|||||||
result:=fen_true;
|
result:=fen_true;
|
||||||
if tnode(pconstentry(arg)^.valuenode).isequal(n) then
|
if tnode(pconstentry(arg)^.valuenode).isequal(n) then
|
||||||
begin
|
begin
|
||||||
{ threadvar, so we took the address? }
|
{ shall we take the address? }
|
||||||
if (pconstentry(arg)^.valuenode.nodetype=loadn) and (tloadnode(pconstentry(arg)^.valuenode).symtableentry.typ=staticvarsym) and
|
if CSEOnReference(pconstentry(arg)^.valuenode) then
|
||||||
(vo_is_thread_var in tstaticvarsym(tloadnode(pconstentry(arg)^.valuenode).symtableentry).varoptions) then
|
|
||||||
begin
|
begin
|
||||||
hp:=ctypeconvnode.create_internal(cderefnode.create(ctemprefnode.create(pconstentry(arg)^.temp)),pconstentry(arg)^.valuenode.resultdef);
|
hp:=ctypeconvnode.create_internal(cderefnode.create(ctemprefnode.create(pconstentry(arg)^.temp)),pconstentry(arg)^.valuenode.resultdef);
|
||||||
ttypeconvnode(hp).left.fileinfo:=n.fileinfo;
|
ttypeconvnode(hp).left.fileinfo:=n.fileinfo;
|
||||||
@ -666,10 +674,8 @@ unit optcse;
|
|||||||
|
|
||||||
|
|
||||||
function do_consttovar(var rootnode : tnode) : tnode;
|
function do_consttovar(var rootnode : tnode) : tnode;
|
||||||
|
|
||||||
var
|
var
|
||||||
constentries : tconstentries;
|
constentries : tconstentries;
|
||||||
|
|
||||||
Procedure QuickSort(L, R : Longint);
|
Procedure QuickSort(L, R : Longint);
|
||||||
var
|
var
|
||||||
I, J, P: Longint;
|
I, J, P: Longint;
|
||||||
@ -783,8 +789,7 @@ unit optcse;
|
|||||||
foreachnodestatic(pm_postprocess,rootnode,@replaceconsts,@constentries[i]);
|
foreachnodestatic(pm_postprocess,rootnode,@replaceconsts,@constentries[i]);
|
||||||
inc(fpu_regs_assigned);
|
inc(fpu_regs_assigned);
|
||||||
end
|
end
|
||||||
else if (constentries[i].valuenode.nodetype=loadn) and (tloadnode(constentries[i].valuenode).symtableentry.typ=staticvarsym) and
|
else if CSEOnReference(constentries[i].valuenode) and
|
||||||
(vo_is_thread_var in tstaticvarsym(tloadnode(constentries[i].valuenode).symtableentry).varoptions) and
|
|
||||||
{ if there is a call, we need most likely to save/restore a register }
|
{ if there is a call, we need most likely to save/restore a register }
|
||||||
((constentries[i].weight>2) or
|
((constentries[i].weight>2) or
|
||||||
((constentries[i].weight>1) and not(pi_do_call in current_procinfo.flags)))
|
((constentries[i].weight>1) and not(pi_do_call in current_procinfo.flags)))
|
||||||
|
Loading…
Reference in New Issue
Block a user