mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 14:09:17 +02:00
+ TAOptBase.SuperRegistersEqual
+ properly implemented TAOptObj.PrePeepHoleOpts + properly implemented TAOptObj.PeepHoleOptPass2 git-svn-id: trunk@33654 -
This commit is contained in:
parent
2e9ed396b4
commit
cfd49ec708
@ -101,6 +101,10 @@ unit aoptbase;
|
|||||||
|
|
||||||
{ returns true if hp loads a value from reg }
|
{ returns true if hp loads a value from reg }
|
||||||
function InstructionLoadsFromReg(const reg : TRegister; const hp : tai) : boolean; Virtual;
|
function InstructionLoadsFromReg(const reg : TRegister; const hp : tai) : boolean; Virtual;
|
||||||
|
|
||||||
|
{ compares reg1 and reg2 having the same type and being the same super registers
|
||||||
|
so the register size is neglected }
|
||||||
|
function SuperRegistersEqual(reg1,reg2 : TRegister) : Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function labelCanBeSkipped(p: tai_label): boolean;
|
function labelCanBeSkipped(p: tai_label): boolean;
|
||||||
@ -305,6 +309,12 @@ unit aoptbase;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TAOptBase.SuperRegistersEqual(reg1,reg2 : TRegister) : Boolean;
|
||||||
|
Begin
|
||||||
|
Result:=(getregtype(reg1) = getregtype(reg2)) and
|
||||||
|
(getsupreg(reg1) = getsupreg(Reg2));
|
||||||
|
end;
|
||||||
|
|
||||||
{ ******************* Processor dependent stuff *************************** }
|
{ ******************* Processor dependent stuff *************************** }
|
||||||
|
|
||||||
Function TAOptBase.RegMaxSize(Reg: TRegister): TRegister;
|
Function TAOptBase.RegMaxSize(Reg: TRegister): TRegister;
|
||||||
|
@ -346,7 +346,9 @@ Unit AoptObj;
|
|||||||
|
|
||||||
{ processor dependent methods }
|
{ processor dependent methods }
|
||||||
// if it returns true, perform a "continue"
|
// if it returns true, perform a "continue"
|
||||||
|
function PrePeepHoleOptsCpu(var p: tai): boolean; virtual;
|
||||||
function PeepHoleOptPass1Cpu(var p: tai): boolean; virtual;
|
function PeepHoleOptPass1Cpu(var p: tai): boolean; virtual;
|
||||||
|
function PeepHoleOptPass2Cpu(var p: tai): boolean; virtual;
|
||||||
function PostPeepHoleOptsCpu(var p: tai): boolean; virtual;
|
function PostPeepHoleOptsCpu(var p: tai): boolean; virtual;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -1080,8 +1082,7 @@ Unit AoptObj;
|
|||||||
(StartPai.typ = ait_regAlloc) Then
|
(StartPai.typ = ait_regAlloc) Then
|
||||||
Begin
|
Begin
|
||||||
if (tai_regalloc(StartPai).ratype=ra_alloc) and
|
if (tai_regalloc(StartPai).ratype=ra_alloc) and
|
||||||
(getregtype(tai_regalloc(StartPai).Reg) = getregtype(Reg)) and
|
SuperRegistersEqual(tai_regalloc(StartPai).Reg,Reg) then
|
||||||
(getsupreg(tai_regalloc(StartPai).Reg) = getsupreg(Reg)) then
|
|
||||||
begin
|
begin
|
||||||
Result:=tai_regalloc(StartPai);
|
Result:=tai_regalloc(StartPai);
|
||||||
exit;
|
exit;
|
||||||
@ -1178,7 +1179,7 @@ Unit AoptObj;
|
|||||||
|
|
||||||
{$push}
|
{$push}
|
||||||
{$r-}
|
{$r-}
|
||||||
function tAOptObj.getlabelwithsym(sym: tasmlabel): tai;
|
function TAOptObj.getlabelwithsym(sym: tasmlabel): tai;
|
||||||
begin
|
begin
|
||||||
if (int64(sym.labelnr) >= int64(labelinfo^.lowlabel)) and
|
if (int64(sym.labelnr) >= int64(labelinfo^.lowlabel)) and
|
||||||
(int64(sym.labelnr) <= int64(labelinfo^.highlabel)) then { range check, a jump can go past an assembler block! }
|
(int64(sym.labelnr) <= int64(labelinfo^.highlabel)) then { range check, a jump can go past an assembler block! }
|
||||||
@ -1342,7 +1343,19 @@ Unit AoptObj;
|
|||||||
|
|
||||||
|
|
||||||
procedure TAOptObj.PrePeepHoleOpts;
|
procedure TAOptObj.PrePeepHoleOpts;
|
||||||
|
var
|
||||||
|
p: tai;
|
||||||
begin
|
begin
|
||||||
|
p := BlockStart;
|
||||||
|
ClearUsedRegs;
|
||||||
|
while (p <> BlockEnd) Do
|
||||||
|
begin
|
||||||
|
UpdateUsedRegs(tai(p.next));
|
||||||
|
if PrePeepHoleOptsCpu(p) then
|
||||||
|
continue;
|
||||||
|
UpdateUsedRegs(p);
|
||||||
|
p:=tai(p.next);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1400,10 +1413,10 @@ Unit AoptObj;
|
|||||||
no-line-info-start/end etc }
|
no-line-info-start/end etc }
|
||||||
if hp1.typ<>ait_marker then
|
if hp1.typ<>ait_marker then
|
||||||
begin
|
begin
|
||||||
{$if defined(SPARC) or defined(MIPS) }
|
{$if defined(SPARC) or defined(MIPS) }
|
||||||
if (hp1.typ=ait_instruction) and (taicpu(hp1).is_jmp) then
|
if (hp1.typ=ait_instruction) and (taicpu(hp1).is_jmp) then
|
||||||
RemoveDelaySlot(hp1);
|
RemoveDelaySlot(hp1);
|
||||||
{$endif SPARC or MIPS }
|
{$endif SPARC or MIPS }
|
||||||
asml.remove(hp1);
|
asml.remove(hp1);
|
||||||
hp1.free;
|
hp1.free;
|
||||||
stoploop:=false;
|
stoploop:=false;
|
||||||
@ -1423,9 +1436,9 @@ Unit AoptObj;
|
|||||||
(p<>blockstart) then
|
(p<>blockstart) then
|
||||||
begin
|
begin
|
||||||
tasmlabel(JumpTargetOp(taicpu(p))^.ref^.symbol).decrefs;
|
tasmlabel(JumpTargetOp(taicpu(p))^.ref^.symbol).decrefs;
|
||||||
{$if defined(SPARC) or defined(MIPS)}
|
{$if defined(SPARC) or defined(MIPS)}
|
||||||
RemoveDelaySlot(p);
|
RemoveDelaySlot(p);
|
||||||
{$endif SPARC or MIPS}
|
{$endif SPARC or MIPS}
|
||||||
hp2:=tai(hp1.next);
|
hp2:=tai(hp1.next);
|
||||||
asml.remove(p);
|
asml.remove(p);
|
||||||
p.free;
|
p.free;
|
||||||
@ -1451,15 +1464,15 @@ Unit AoptObj;
|
|||||||
FindLabel(tasmlabel(JumpTargetOp(taicpu(p))^.ref^.symbol), hp2) then
|
FindLabel(tasmlabel(JumpTargetOp(taicpu(p))^.ref^.symbol), hp2) then
|
||||||
begin
|
begin
|
||||||
if (taicpu(p).opcode=aopt_condjmp)
|
if (taicpu(p).opcode=aopt_condjmp)
|
||||||
{$if defined(arm) or defined(aarch64)}
|
{$if defined(arm) or defined(aarch64)}
|
||||||
and (taicpu(p).condition<>C_None)
|
and (taicpu(p).condition<>C_None)
|
||||||
{$endif arm or aarch64}
|
{$endif arm or aarch64}
|
||||||
{$if defined(aarch64)}
|
{$if defined(aarch64)}
|
||||||
{ can't have conditional branches to
|
{ can't have conditional branches to
|
||||||
global labels on AArch64, because the
|
global labels on AArch64, because the
|
||||||
offset may become too big }
|
offset may become too big }
|
||||||
and (tasmlabel(JumpTargetOp(taicpu(hp1))^.ref^.symbol).bind=AB_LOCAL)
|
and (tasmlabel(JumpTargetOp(taicpu(hp1))^.ref^.symbol).bind=AB_LOCAL)
|
||||||
{$endif aarch64}
|
{$endif aarch64}
|
||||||
then
|
then
|
||||||
begin
|
begin
|
||||||
taicpu(p).condition:=inverse_cond(taicpu(p).condition);
|
taicpu(p).condition:=inverse_cond(taicpu(p).condition);
|
||||||
@ -1470,9 +1483,9 @@ Unit AoptObj;
|
|||||||
|
|
||||||
taicpu(p).oper[0]^.ref^.symbol.increfs;
|
taicpu(p).oper[0]^.ref^.symbol.increfs;
|
||||||
}
|
}
|
||||||
{$if defined(SPARC) or defined(MIPS)}
|
{$if defined(SPARC) or defined(MIPS)}
|
||||||
RemoveDelaySlot(hp1);
|
RemoveDelaySlot(hp1);
|
||||||
{$endif SPARC or MIPS}
|
{$endif SPARC or MIPS}
|
||||||
asml.remove(hp1);
|
asml.remove(hp1);
|
||||||
hp1.free;
|
hp1.free;
|
||||||
stoploop:=false;
|
stoploop:=false;
|
||||||
@ -1504,7 +1517,19 @@ Unit AoptObj;
|
|||||||
|
|
||||||
|
|
||||||
procedure TAOptObj.PeepHoleOptPass2;
|
procedure TAOptObj.PeepHoleOptPass2;
|
||||||
|
var
|
||||||
|
p: tai;
|
||||||
begin
|
begin
|
||||||
|
p := BlockStart;
|
||||||
|
ClearUsedRegs;
|
||||||
|
while (p <> BlockEnd) Do
|
||||||
|
begin
|
||||||
|
UpdateUsedRegs(tai(p.next));
|
||||||
|
if PeepHoleOptPass2Cpu(p) then
|
||||||
|
continue;
|
||||||
|
UpdateUsedRegs(p);
|
||||||
|
p:=tai(p.next);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1525,12 +1550,24 @@ Unit AoptObj;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TAOptObj.PrePeepHoleOptsCpu(var p : tai) : boolean;
|
||||||
|
begin
|
||||||
|
result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TAOptObj.PeepHoleOptPass1Cpu(var p: tai): boolean;
|
function TAOptObj.PeepHoleOptPass1Cpu(var p: tai): boolean;
|
||||||
begin
|
begin
|
||||||
result := false;
|
result := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TAOptObj.PeepHoleOptPass2Cpu(var p : tai) : boolean;
|
||||||
|
begin
|
||||||
|
result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TAOptObj.PostPeepHoleOptsCpu(var p: tai): boolean;
|
function TAOptObj.PostPeepHoleOptsCpu(var p: tai): boolean;
|
||||||
begin
|
begin
|
||||||
result := false;
|
result := false;
|
||||||
|
Loading…
Reference in New Issue
Block a user