mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 14:08:09 +02:00
+ m68k: JSR, RTS to JMP optimization
git-svn-id: trunk@47740 -
This commit is contained in:
parent
5682783489
commit
a849e51a3c
@ -48,7 +48,7 @@ unit aoptcpu;
|
||||
Implementation
|
||||
|
||||
uses
|
||||
cutils, aasmcpu, cgutils, globals, verbose, cpuinfo, itcpugas;
|
||||
cutils, aasmcpu, cgutils, globtype, globals, verbose, cpuinfo, itcpugas;
|
||||
|
||||
{ Range check must be disabled explicitly as conversions between signed and unsigned
|
||||
32-bit values are done without explicit typecasts }
|
||||
@ -88,6 +88,14 @@ unit aoptcpu;
|
||||
end
|
||||
end;
|
||||
|
||||
function MatchInstruction(const instr: tai; const op: TAsmOp; const opsize: topsizes): boolean;
|
||||
begin
|
||||
result :=
|
||||
(instr.typ = ait_instruction) and
|
||||
(taicpu(instr).opcode = op) and
|
||||
((opsize = []) or (taicpu(instr).opsize in opsize));
|
||||
end;
|
||||
|
||||
function TCpuAsmOptimizer.MaybeRealConstOperSimplify(var p: tai): boolean;
|
||||
var
|
||||
tmpint64: int64;
|
||||
@ -386,6 +394,19 @@ unit aoptcpu;
|
||||
taicpu(p).ops:=2;
|
||||
result:=true;
|
||||
end;
|
||||
A_JSR:
|
||||
begin
|
||||
if (cs_opt_level4 in current_settings.optimizerswitches) and
|
||||
GetNextInstruction(p,next) and
|
||||
MatchInstruction(next,A_RTS,[S_NO]) then
|
||||
begin
|
||||
DebugMsg('Optimizer: JSR, RTS to JMP',p);
|
||||
taicpu(p).opcode:=A_JMP;
|
||||
asml.remove(next);
|
||||
next.free;
|
||||
result:=true;
|
||||
end;
|
||||
end;
|
||||
{ CMP #0,<ea> equals to TST <ea>, just shorter and TST is more flexible anyway }
|
||||
A_CMP,A_CMPI:
|
||||
if (taicpu(p).oper[0]^.typ = top_const) and
|
||||
|
@ -158,6 +158,8 @@ unit cpubase;
|
||||
{ S_FX = Extended type }
|
||||
topsize = (S_NO,S_B,S_W,S_L,S_FS,S_FD,S_FX,S_IQ);
|
||||
|
||||
TOpSizes = set of topsize;
|
||||
|
||||
{*****************************************************************************
|
||||
Constants
|
||||
*****************************************************************************}
|
||||
|
Loading…
Reference in New Issue
Block a user