mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 04:39:34 +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 }
|
||||
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;
|
||||
|
||||
function labelCanBeSkipped(p: tai_label): boolean;
|
||||
@ -305,6 +309,12 @@ unit aoptbase;
|
||||
end;
|
||||
|
||||
|
||||
function TAOptBase.SuperRegistersEqual(reg1,reg2 : TRegister) : Boolean;
|
||||
Begin
|
||||
Result:=(getregtype(reg1) = getregtype(reg2)) and
|
||||
(getsupreg(reg1) = getsupreg(Reg2));
|
||||
end;
|
||||
|
||||
{ ******************* Processor dependent stuff *************************** }
|
||||
|
||||
Function TAOptBase.RegMaxSize(Reg: TRegister): TRegister;
|
||||
|
@ -346,7 +346,9 @@ Unit AoptObj;
|
||||
|
||||
{ processor dependent methods }
|
||||
// if it returns true, perform a "continue"
|
||||
function PrePeepHoleOptsCpu(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;
|
||||
End;
|
||||
|
||||
@ -1080,8 +1082,7 @@ Unit AoptObj;
|
||||
(StartPai.typ = ait_regAlloc) Then
|
||||
Begin
|
||||
if (tai_regalloc(StartPai).ratype=ra_alloc) and
|
||||
(getregtype(tai_regalloc(StartPai).Reg) = getregtype(Reg)) and
|
||||
(getsupreg(tai_regalloc(StartPai).Reg) = getsupreg(Reg)) then
|
||||
SuperRegistersEqual(tai_regalloc(StartPai).Reg,Reg) then
|
||||
begin
|
||||
Result:=tai_regalloc(StartPai);
|
||||
exit;
|
||||
@ -1178,7 +1179,7 @@ Unit AoptObj;
|
||||
|
||||
{$push}
|
||||
{$r-}
|
||||
function tAOptObj.getlabelwithsym(sym: tasmlabel): tai;
|
||||
function TAOptObj.getlabelwithsym(sym: tasmlabel): tai;
|
||||
begin
|
||||
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! }
|
||||
@ -1342,7 +1343,19 @@ Unit AoptObj;
|
||||
|
||||
|
||||
procedure TAOptObj.PrePeepHoleOpts;
|
||||
var
|
||||
p: tai;
|
||||
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;
|
||||
|
||||
|
||||
@ -1504,7 +1517,19 @@ Unit AoptObj;
|
||||
|
||||
|
||||
procedure TAOptObj.PeepHoleOptPass2;
|
||||
var
|
||||
p: tai;
|
||||
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;
|
||||
|
||||
|
||||
@ -1525,12 +1550,24 @@ Unit AoptObj;
|
||||
end;
|
||||
|
||||
|
||||
function TAOptObj.PrePeepHoleOptsCpu(var p : tai) : boolean;
|
||||
begin
|
||||
result := false;
|
||||
end;
|
||||
|
||||
|
||||
function TAOptObj.PeepHoleOptPass1Cpu(var p: tai): boolean;
|
||||
begin
|
||||
result := false;
|
||||
end;
|
||||
|
||||
|
||||
function TAOptObj.PeepHoleOptPass2Cpu(var p : tai) : boolean;
|
||||
begin
|
||||
result := false;
|
||||
end;
|
||||
|
||||
|
||||
function TAOptObj.PostPeepHoleOptsCpu(var p: tai): boolean;
|
||||
begin
|
||||
result := false;
|
||||
|
Loading…
Reference in New Issue
Block a user