mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-10 14:18:34 +02:00
+ DebugMsg based debugging for the mips(el) assembler optimizer
git-svn-id: trunk@35890 -
This commit is contained in:
parent
8983879aeb
commit
6af656aaed
@ -25,6 +25,8 @@ unit aoptcpu;
|
|||||||
|
|
||||||
{$i fpcdefs.inc}
|
{$i fpcdefs.inc}
|
||||||
|
|
||||||
|
{ $define DEBUG_AOPTCPU}
|
||||||
|
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -44,6 +46,9 @@ unit aoptcpu;
|
|||||||
procedure PeepHoleOptPass2; override;
|
procedure PeepHoleOptPass2; override;
|
||||||
function RegLoadedWithNewValue(reg : tregister; hp : tai) : boolean; override;
|
function RegLoadedWithNewValue(reg : tregister; hp : tai) : boolean; override;
|
||||||
function InstructionLoadsFromReg(const reg : TRegister; const hp : tai) : boolean; override;
|
function InstructionLoadsFromReg(const reg : TRegister; const hp : tai) : boolean; override;
|
||||||
|
|
||||||
|
{ outputs a debug message into the assembler file }
|
||||||
|
procedure DebugMsg(const s: string; p: tai);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
@ -130,7 +135,19 @@ unit aoptcpu;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TCpuAsmOptimizer.InstructionLoadsFromReg(const reg: TRegister; const hp: tai): boolean;
|
{$ifdef DEBUG_AOPTCPU}
|
||||||
|
procedure TCpuAsmOptimizer.DebugMsg(const s: string;p : tai);
|
||||||
|
begin
|
||||||
|
asml.insertbefore(tai_comment.Create(strpnew(s)), p);
|
||||||
|
end;
|
||||||
|
{$else DEBUG_AOPTCPU}
|
||||||
|
procedure TCpuAsmOptimizer.DebugMsg(const s: string;p : tai);inline;
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
{$endif DEBUG_AOPTCPU}
|
||||||
|
|
||||||
|
|
||||||
|
function TCpuAsmOptimizer.InstructionLoadsFromReg(const reg: TRegister; const hp: tai): boolean;
|
||||||
var
|
var
|
||||||
p: taicpu;
|
p: taicpu;
|
||||||
i: longint;
|
i: longint;
|
||||||
@ -258,6 +275,7 @@ unit aoptcpu;
|
|||||||
|
|
||||||
{ finally get rid of the mov }
|
{ finally get rid of the mov }
|
||||||
taicpu(p).loadreg(0,taicpu(next).oper[0]^.reg);
|
taicpu(p).loadreg(0,taicpu(next).oper[0]^.reg);
|
||||||
|
DebugMsg('Peephole: Move removed 1',next);
|
||||||
asml.remove(next);
|
asml.remove(next);
|
||||||
next.free;
|
next.free;
|
||||||
result:=true;
|
result:=true;
|
||||||
@ -280,6 +298,7 @@ unit aoptcpu;
|
|||||||
assigned(FindRegAlloc(taicpu(p).oper[0]^.reg,tai(p.next))) then
|
assigned(FindRegAlloc(taicpu(p).oper[0]^.reg,tai(p.next))) then
|
||||||
begin
|
begin
|
||||||
taicpu(p).loadreg(0,taicpu(next).oper[0]^.reg);
|
taicpu(p).loadreg(0,taicpu(next).oper[0]^.reg);
|
||||||
|
DebugMsg('Peephole: Move removed 2',next);
|
||||||
asml.remove(next);
|
asml.remove(next);
|
||||||
next.free;
|
next.free;
|
||||||
result:=true;
|
result:=true;
|
||||||
@ -299,6 +318,7 @@ unit aoptcpu;
|
|||||||
if result then
|
if result then
|
||||||
begin
|
begin
|
||||||
next.loadreg(0,taicpu(p).oper[1]^.reg);
|
next.loadreg(0,taicpu(p).oper[1]^.reg);
|
||||||
|
DebugMsg('Peephole: Move removed 3',p);
|
||||||
asml.remove(p);
|
asml.remove(p);
|
||||||
p.free;
|
p.free;
|
||||||
p:=next;
|
p:=next;
|
||||||
@ -317,6 +337,7 @@ unit aoptcpu;
|
|||||||
if result then
|
if result then
|
||||||
begin
|
begin
|
||||||
next.oper[1]^.ref^.base:=taicpu(p).oper[1]^.reg;
|
next.oper[1]^.ref^.base:=taicpu(p).oper[1]^.reg;
|
||||||
|
DebugMsg('Peephole: Move removed 4',p);
|
||||||
asml.remove(p);
|
asml.remove(p);
|
||||||
p.free;
|
p.free;
|
||||||
p:=next;
|
p:=next;
|
||||||
|
Loading…
Reference in New Issue
Block a user