mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-17 20:19:25 +02:00
m68k: very early optimizer implementation experiments
git-svn-id: trunk@27862 -
This commit is contained in:
parent
639a59df92
commit
df7af34de9
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
Copyright (c) 1998-2004 by Jonas Maebe
|
Copyright (c) 1998-2014 by the Free Pascal development team
|
||||||
|
|
||||||
This unit calls the optimization procedures to optimize the assembler
|
This unit calls the optimization procedures to optimize the assembler
|
||||||
code for sparc
|
code for m68k
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -28,14 +28,47 @@ unit aoptcpu;
|
|||||||
Interface
|
Interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
cpubase, aoptobj, aoptcpub, aopt;
|
cpubase, aoptobj, aoptcpub, aopt, aasmtai;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TCpuAsmOptimizer = class(TAsmOptimizer)
|
TCpuAsmOptimizer = class(TAsmOptimizer)
|
||||||
|
function PeepHoleOptPass1Cpu(var p: tai): boolean; override;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
cutils, aasmcpu;
|
||||||
|
|
||||||
|
function TCpuAsmOptimizer.PeepHoleOptPass1Cpu(var p: tai): boolean;
|
||||||
|
var
|
||||||
|
next: tai;
|
||||||
|
begin
|
||||||
|
result:=false;
|
||||||
|
case p.typ of
|
||||||
|
ait_instruction:
|
||||||
|
begin
|
||||||
|
//asml.insertbefore(tai_comment.Create(strpnew('pass1 called for instr')), p);
|
||||||
|
|
||||||
|
{ LEA (Ax),Ax is a NOP if src and dest reg is equal, so remove it. }
|
||||||
|
if getnextinstruction(p,next) and (taicpu(p).opcode = A_LEA) and
|
||||||
|
(not assigned(taicpu(p).oper[0]^.ref^.symbol)) and
|
||||||
|
(((taicpu(p).oper[0]^.ref^.base = taicpu(p).oper[1]^.reg) and
|
||||||
|
(taicpu(p).oper[0]^.ref^.index = NR_NO)) or
|
||||||
|
((taicpu(p).oper[0]^.ref^.index = taicpu(p).oper[1]^.reg) and
|
||||||
|
(taicpu(p).oper[0]^.ref^.base = NR_NO))) and
|
||||||
|
(taicpu(p).oper[0]^.ref^.offset = 0) then
|
||||||
|
begin
|
||||||
|
//asml.insertbefore(tai_comment.Create(strpnew('LEA (Ax),Ax removed')), p);
|
||||||
|
asml.remove(p);
|
||||||
|
p.free;
|
||||||
|
p:=next;
|
||||||
|
result:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
casmoptimizer:=TCpuAsmOptimizer;
|
casmoptimizer:=TCpuAsmOptimizer;
|
||||||
end.
|
end.
|
||||||
|
@ -70,6 +70,14 @@ implementation
|
|||||||
{$ifndef NoDbgDwarf}
|
{$ifndef NoDbgDwarf}
|
||||||
,dbgdwarf
|
,dbgdwarf
|
||||||
{$endif NoDbgDwarf}
|
{$endif NoDbgDwarf}
|
||||||
|
|
||||||
|
{**************************************
|
||||||
|
Optimizer
|
||||||
|
**************************************}
|
||||||
|
|
||||||
|
{$ifndef NOOPT}
|
||||||
|
, aoptcpu
|
||||||
|
{$endif NOOPT}
|
||||||
;
|
;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user