mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 09:59:08 +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;
|
||||||
|
|
||||||
|
|
||||||
@ -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