|
@@ -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;
|
|
|
-
|
|
|
- if (p.typ = ait_instruction) and IsJumpToLabel(taicpu(p)) then
|
|
|
- Continue;
|
|
|
- end;
|
|
|
+ { 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 PeepHoleOptPass1Cpu(p) then
|
|
|
begin
|