|
@@ -505,33 +505,57 @@ Implementation
|
|
|
hp1.free;
|
|
|
end;
|
|
|
|
|
|
- {
|
|
|
- This changes the very common
|
|
|
- mov r0, #0
|
|
|
- str r0, [...]
|
|
|
- mov r0, #0
|
|
|
- str r0, [...]
|
|
|
-
|
|
|
- and removes all superfluous mov instructions
|
|
|
+ {
|
|
|
+ optimize
|
|
|
+ mov rX, yyyy
|
|
|
+ ....
|
|
|
}
|
|
|
if (taicpu(p).ops = 2) and
|
|
|
- (taicpu(p).oper[1]^.typ = top_const) and
|
|
|
GetNextInstruction(p,hp1) then
|
|
|
begin
|
|
|
- while MatchInstruction(hp1, A_STR, [taicpu(p).condition], []) and
|
|
|
- MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
|
|
|
- GetNextInstruction(hp1, hp2) and
|
|
|
- MatchInstruction(hp2, A_MOV, [taicpu(p).condition], [PF_None]) and
|
|
|
- (taicpu(hp2).ops = 2) and
|
|
|
- MatchOperand(taicpu(hp2).oper[0]^, taicpu(p).oper[0]^) and
|
|
|
- MatchOperand(taicpu(hp2).oper[1]^, taicpu(p).oper[1]^) do
|
|
|
- begin
|
|
|
- asml.insertbefore(tai_comment.Create(strpnew('Peephole MovStrMov done')), hp2);
|
|
|
- GetNextInstruction(hp2,hp1);
|
|
|
- asml.remove(hp2);
|
|
|
- hp2.free;
|
|
|
- if not assigned(hp1) then break;
|
|
|
- end;
|
|
|
+ {
|
|
|
+ This changes the very common
|
|
|
+ mov r0, #0
|
|
|
+ str r0, [...]
|
|
|
+ mov r0, #0
|
|
|
+ str r0, [...]
|
|
|
+
|
|
|
+ and removes all superfluous mov instructions
|
|
|
+ }
|
|
|
+ if (taicpu(p).oper[1]^.typ = top_const) and
|
|
|
+ (taicpu(hp1).opcode=A_STR) then
|
|
|
+ while MatchInstruction(hp1, A_STR, [taicpu(p).condition], []) and
|
|
|
+ MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
|
|
|
+ GetNextInstruction(hp1, hp2) and
|
|
|
+ MatchInstruction(hp2, A_MOV, [taicpu(p).condition], [PF_None]) and
|
|
|
+ (taicpu(hp2).ops = 2) and
|
|
|
+ MatchOperand(taicpu(hp2).oper[0]^, taicpu(p).oper[0]^) and
|
|
|
+ MatchOperand(taicpu(hp2).oper[1]^, taicpu(p).oper[1]^) do
|
|
|
+ begin
|
|
|
+ asml.insertbefore(tai_comment.Create(strpnew('Peephole MovStrMov done')), hp2);
|
|
|
+ GetNextInstruction(hp2,hp1);
|
|
|
+ asml.remove(hp2);
|
|
|
+ hp2.free;
|
|
|
+ if not assigned(hp1) then break;
|
|
|
+ end
|
|
|
+ {
|
|
|
+ This removes the first mov from
|
|
|
+ mov rX,...
|
|
|
+ mov rX,...
|
|
|
+ }
|
|
|
+ else if taicpu(hp1).opcode=A_MOV then
|
|
|
+ while MatchInstruction(hp1, A_MOV, [taicpu(p).condition], [taicpu(p).oppostfix]) and
|
|
|
+ (taicpu(hp1).ops = 2) and
|
|
|
+ MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) do
|
|
|
+ begin
|
|
|
+ asml.insertbefore(tai_comment.Create(strpnew('Peephole MovMov done')), p);
|
|
|
+ asml.remove(p);
|
|
|
+ p.free;
|
|
|
+ p:=hp1;
|
|
|
+ GetNextInstruction(hp1,hp1);
|
|
|
+ if not assigned(hp1) then
|
|
|
+ break;
|
|
|
+ end;
|
|
|
end;
|
|
|
{
|
|
|
change
|