|
@@ -61,9 +61,6 @@ Type
|
|
end;
|
|
end;
|
|
|
|
|
|
TCpuThumb2AsmOptimizer = class(TCpuAsmOptimizer)
|
|
TCpuThumb2AsmOptimizer = class(TCpuAsmOptimizer)
|
|
- private
|
|
|
|
- function RegAllocated(hp: tai; areg: TRegister): boolean;
|
|
|
|
- public
|
|
|
|
{ uses the same constructor as TAopObj }
|
|
{ uses the same constructor as TAopObj }
|
|
function PeepHoleOptPass1Cpu(var p: tai): boolean; override;
|
|
function PeepHoleOptPass1Cpu(var p: tai): boolean; override;
|
|
procedure PeepHoleOptPass2;override;
|
|
procedure PeepHoleOptPass2;override;
|
|
@@ -1748,28 +1745,6 @@ Implementation
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
- function TCpuThumb2AsmOptimizer.RegAllocated(hp: tai; areg: TRegister): boolean;
|
|
|
|
- var
|
|
|
|
- p: tai;
|
|
|
|
- begin
|
|
|
|
- result := true;
|
|
|
|
- p := hp;
|
|
|
|
- while assigned(p) do
|
|
|
|
- begin
|
|
|
|
- if (p.typ=ait_regalloc) and
|
|
|
|
- (tai_regalloc(p).reg = areg) then
|
|
|
|
- begin
|
|
|
|
- if tai_regalloc(p).ratype = ra_alloc then
|
|
|
|
- exit(false)
|
|
|
|
- else if tai_regalloc(p).ratype = ra_dealloc then
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- p := tai(p.Next);
|
|
|
|
- end;
|
|
|
|
- result := false;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
function TCpuThumb2AsmOptimizer.PeepHoleOptPass1Cpu(var p: tai): boolean;
|
|
function TCpuThumb2AsmOptimizer.PeepHoleOptPass1Cpu(var p: tai): boolean;
|
|
var
|
|
var
|
|
hp : taicpu;
|
|
hp : taicpu;
|
|
@@ -1833,16 +1808,22 @@ Implementation
|
|
(taicpu(p).oper[1]^.typ=top_const) and
|
|
(taicpu(p).oper[1]^.typ=top_const) and
|
|
(taicpu(p).oper[1]^.val >= 0) and
|
|
(taicpu(p).oper[1]^.val >= 0) and
|
|
(taicpu(p).oper[1]^.val < 256) and
|
|
(taicpu(p).oper[1]^.val < 256) and
|
|
- (not RegAllocated(p, NR_DEFAULTFLAGS)) then
|
|
|
|
|
|
+ (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
|
|
begin
|
|
begin
|
|
|
|
+ asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ asml.InsertAfter(tai_regalloc.dealloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ IncludeRegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs);
|
|
taicpu(p).oppostfix:=PF_S;
|
|
taicpu(p).oppostfix:=PF_S;
|
|
result:=true;
|
|
result:=true;
|
|
end
|
|
end
|
|
else if (p.typ=ait_instruction) and
|
|
else if (p.typ=ait_instruction) and
|
|
- MatchInstruction(p, A_MVN, [], [PF_None]) and
|
|
|
|
|
|
+ MatchInstruction(p, A_MVN, [C_None], [PF_None]) and
|
|
(taicpu(p).oper[1]^.typ=top_reg) and
|
|
(taicpu(p).oper[1]^.typ=top_reg) and
|
|
- (not RegAllocated(p, NR_DEFAULTFLAGS)) then
|
|
|
|
|
|
+ (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
|
|
begin
|
|
begin
|
|
|
|
+ asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ asml.InsertAfter(tai_regalloc.dealloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ IncludeRegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs);
|
|
taicpu(p).oppostfix:=PF_S;
|
|
taicpu(p).oppostfix:=PF_S;
|
|
result:=true;
|
|
result:=true;
|
|
end
|
|
end
|
|
@@ -1854,8 +1835,11 @@ Implementation
|
|
(taicpu(p).oper[2]^.typ=top_const) and
|
|
(taicpu(p).oper[2]^.typ=top_const) and
|
|
(taicpu(p).oper[2]^.val >= 0) and
|
|
(taicpu(p).oper[2]^.val >= 0) and
|
|
(taicpu(p).oper[2]^.val < 256) and
|
|
(taicpu(p).oper[2]^.val < 256) and
|
|
- (not RegAllocated(p, NR_DEFAULTFLAGS)) then
|
|
|
|
|
|
+ (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
|
|
begin
|
|
begin
|
|
|
|
+ asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ asml.InsertAfter(tai_regalloc.dealloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ IncludeRegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs);
|
|
taicpu(p).loadconst(1,taicpu(p).oper[2]^.val);
|
|
taicpu(p).loadconst(1,taicpu(p).oper[2]^.val);
|
|
taicpu(p).oppostfix:=PF_S;
|
|
taicpu(p).oppostfix:=PF_S;
|
|
taicpu(p).ops := 2;
|
|
taicpu(p).ops := 2;
|
|
@@ -1866,8 +1850,11 @@ Implementation
|
|
(taicpu(p).ops = 3) and
|
|
(taicpu(p).ops = 3) and
|
|
MatchOperand(taicpu(p).oper[0]^, taicpu(p).oper[1]^) and
|
|
MatchOperand(taicpu(p).oper[0]^, taicpu(p).oper[1]^) and
|
|
(taicpu(p).oper[2]^.typ=top_reg) and
|
|
(taicpu(p).oper[2]^.typ=top_reg) and
|
|
- (not RegAllocated(p, NR_DEFAULTFLAGS)) then
|
|
|
|
|
|
+ (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
|
|
begin
|
|
begin
|
|
|
|
+ asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ asml.InsertAfter(tai_regalloc.dealloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ IncludeRegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs);
|
|
taicpu(p).ops := 2;
|
|
taicpu(p).ops := 2;
|
|
taicpu(p).loadreg(1,taicpu(p).oper[2]^.reg);
|
|
taicpu(p).loadreg(1,taicpu(p).oper[2]^.reg);
|
|
taicpu(p).oppostfix:=PF_S;
|
|
taicpu(p).oppostfix:=PF_S;
|
|
@@ -1877,8 +1864,11 @@ Implementation
|
|
MatchInstruction(p, [A_AND,A_ORR,A_EOR], [], [PF_None,PF_S]) and
|
|
MatchInstruction(p, [A_AND,A_ORR,A_EOR], [], [PF_None,PF_S]) and
|
|
(taicpu(p).ops = 3) and
|
|
(taicpu(p).ops = 3) and
|
|
MatchOperand(taicpu(p).oper[0]^, taicpu(p).oper[2]^) and
|
|
MatchOperand(taicpu(p).oper[0]^, taicpu(p).oper[2]^) and
|
|
- (not RegAllocated(p, NR_DEFAULTFLAGS)) then
|
|
|
|
|
|
+ (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
|
|
begin
|
|
begin
|
|
|
|
+ asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ asml.InsertAfter(tai_regalloc.dealloc(NR_DEFAULTFLAGS,p), p);
|
|
|
|
+ IncludeRegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs);
|
|
taicpu(p).oppostfix:=PF_S;
|
|
taicpu(p).oppostfix:=PF_S;
|
|
taicpu(p).ops := 2;
|
|
taicpu(p).ops := 2;
|
|
result:=true;
|
|
result:=true;
|