mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 00:09:32 +02:00
+ patch by J. Gareth Moreton: new method TAOptObj.CanDoJumpOpts and arm specific implementation
git-svn-id: trunk@43519 -
This commit is contained in:
parent
f505822ab5
commit
da54d0e8f7
@ -401,6 +401,9 @@ Unit AoptObj;
|
||||
function OptimizeConditionalJump(CJLabel: TAsmLabel; var p: tai; hp1: tai; var stoploop: Boolean): Boolean;
|
||||
{$endif JVM}
|
||||
|
||||
{ Function to determine if the jump optimisations can be performed }
|
||||
function CanDoJumpOpts: Boolean; virtual;
|
||||
|
||||
{ Jump/label optimisation entry method }
|
||||
function DoJumpOptimizations(var p: tai; var stoploop: Boolean): Boolean;
|
||||
|
||||
@ -2105,6 +2108,13 @@ Unit AoptObj;
|
||||
end;
|
||||
|
||||
|
||||
function TAOptObj.CanDoJumpOpts: Boolean;
|
||||
begin
|
||||
{ Always allow by default }
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
|
||||
function TAOptObj.DoJumpOptimizations(var p: tai; var stoploop: Boolean): Boolean;
|
||||
var
|
||||
hp1, hp2: tai;
|
||||
@ -2356,8 +2366,10 @@ Unit AoptObj;
|
||||
procedure TAOptObj.PeepHoleOptPass1;
|
||||
var
|
||||
p,hp1,hp2,hp3 : tai;
|
||||
stoploop, FirstInstruction: boolean;
|
||||
stoploop, FirstInstruction, JumpOptsAvailable: boolean;
|
||||
begin
|
||||
JumpOptsAvailable := CanDoJumpOpts();
|
||||
|
||||
StartPoint := BlockStart;
|
||||
|
||||
repeat
|
||||
@ -2379,25 +2391,19 @@ Unit AoptObj;
|
||||
InsertLLItem(tai(p.Previous),p,tai_comment.create(strpnew(GetAllocationString(UsedRegs))));
|
||||
{$endif DEBUG_OPTALLOC}
|
||||
|
||||
{ Handle Jmp Optimizations first }
|
||||
{$if defined(ARM)}
|
||||
{ Cannot perform these jump optimisations if the ARM architecture has 16-bit thumb codes }
|
||||
if not (
|
||||
(current_settings.instructionset = is_thumb) and not(CPUARM_HAS_THUMB2 in cpu_capabilities[current_settings.cputype])
|
||||
) then
|
||||
{$endif defined(ARM)}
|
||||
if DoJumpOptimizations(p, stoploop) then
|
||||
begin
|
||||
UpdateUsedRegs(p);
|
||||
if FirstInstruction then
|
||||
{ Update StartPoint, since the old p was removed;
|
||||
don't set FirstInstruction to False though, as
|
||||
the new p might get removed too. }
|
||||
StartPoint := p;
|
||||
{ Handle jump optimizations first }
|
||||
if JumpOptsAvailable and DoJumpOptimizations(p, stoploop) then
|
||||
begin
|
||||
UpdateUsedRegs(p);
|
||||
if FirstInstruction then
|
||||
{ Update StartPoint, since the old p was removed;
|
||||
don't set FirstInstruction to False though, as
|
||||
the new p might get removed too. }
|
||||
StartPoint := p;
|
||||
|
||||
if (p.typ = ait_instruction) and IsJumpToLabel(taicpu(p)) then
|
||||
Continue;
|
||||
end;
|
||||
if (p.typ = ait_instruction) and IsJumpToLabel(taicpu(p)) then
|
||||
Continue;
|
||||
end;
|
||||
|
||||
if PeepHoleOptPass1Cpu(p) then
|
||||
begin
|
||||
|
@ -34,6 +34,9 @@ uses cgbase, cgutils, cpubase, aasmtai, aasmcpu,aopt, aoptobj;
|
||||
|
||||
Type
|
||||
TCpuAsmOptimizer = class(TAsmOptimizer)
|
||||
{ Can't be done in some cases due to the limited range of jumps }
|
||||
function CanDoJumpOpts: Boolean; override;
|
||||
|
||||
{ uses the same constructor as TAopObj }
|
||||
function PeepHoleOptPass1Cpu(var p: tai): boolean; override;
|
||||
procedure PeepHoleOptPass2;override;
|
||||
@ -379,6 +382,16 @@ Implementation
|
||||
end;
|
||||
{$endif DEBUG_AOPTCPU}
|
||||
|
||||
|
||||
function TCpuAsmOptimizer.CanDoJumpOpts: Boolean;
|
||||
begin
|
||||
{ Cannot perform these jump optimisations if the ARM architecture has 16-bit thumb codes }
|
||||
Result := not (
|
||||
(current_settings.instructionset = is_thumb) and not (CPUARM_HAS_THUMB2 in cpu_capabilities[current_settings.cputype])
|
||||
);
|
||||
end;
|
||||
|
||||
|
||||
function TCpuAsmOptimizer.RemoveSuperfluousMove(const p: tai; movp: tai; const optimizer: string):boolean;
|
||||
var
|
||||
alloc,
|
||||
|
Loading…
Reference in New Issue
Block a user