Browse Source

* patch by J. Gareth Moreton: x86 JccMovJmpMov2MovSetcc improvement, resolves #38761

git-svn-id: trunk@49402 -
florian 4 năm trước cách đây
mục cha
commit
bae583118a

+ 19 - 0
compiler/aoptutils.pas

@@ -35,6 +35,10 @@ unit aoptutils;
     function MatchOpType(const p : taicpu; type0,type1,type2 : toptype) : Boolean;
 {$endif max_operands>2}
 
+    { skips all alignment fields and returns the next label (or non-align).
+      returns immediately with true if hp is a label }
+    function SkipAligns(hp: tai; out hp2: tai): boolean;
+
     { skips all labels and returns the next "real" instruction }
     function SkipLabels(hp: tai; out hp2: tai): boolean;
 
@@ -67,6 +71,21 @@ unit aoptutils;
 {$endif max_operands>2}
 
 
+    { skips all alignment fields and returns the next label (or non-align).
+      Returns immediately with True if hp is a label }
+    function SkipAligns(hp: tai; out hp2: tai): boolean;
+      begin
+        while assigned(hp) and
+              (hp.typ in SkipInstr + [ait_label,ait_align]) Do
+          begin
+            { Check that the label is actually live }
+            if (hp.typ = ait_label) and tai_label(hp).labsym.is_used then
+              Break;
+            hp := tai(hp.next);
+          end;
+        SkipAligns := SetAndTest(hp, hp2);
+      end;
+
     { skips all labels and returns the next "real" instruction }
     function SkipLabels(hp: tai; out hp2: tai): boolean;
       begin

+ 2 - 0
compiler/i386/aoptcpu.pas

@@ -189,6 +189,8 @@ unit aoptcpu;
                   Result:=OptPass1SHLSAL(p);
                 A_SUB:
                   Result:=OptPass1Sub(p);
+                A_Jcc:
+                  Result:=OptPass1Jcc(p);
                 A_MOVAPD,
                 A_MOVAPS,
                 A_MOVUPD,

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 743 - 190
compiler/x86/aoptx86.pas


+ 15 - 0
compiler/x86/cpubase.pas

@@ -340,6 +340,7 @@ topsize2memsize: array[topsize] of integer =
     function reg2opsize(r:Tregister):topsize;
     function reg_cgsize(const reg: tregister): tcgsize;
     function is_calljmp(o:tasmop):boolean;
+    function is_calljmpuncond(o:tasmop):boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
     procedure inverse_flags(var f: TResFlags);
     function flags_to_cond(const f: TResFlags) : TAsmCond;
     function is_segment_reg(r:tregister):boolean;
@@ -577,6 +578,20 @@ implementation
       end;
 
 
+    function is_calljmpuncond(o:tasmop):boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
+      begin
+        case o of
+          A_CALL,
+          A_JMP,
+          A_LCALL,
+          A_LJMP:
+            is_calljmpuncond:=true;
+          else
+            is_calljmpuncond:=false;
+        end;
+      end;
+
+
     procedure inverse_flags(var f: TResFlags);
       const
         inv_flags: array[TResFlags] of TResFlags =

+ 2 - 0
compiler/x86_64/aoptcpu.pas

@@ -145,6 +145,8 @@ uses
                   Result:=OptPass1PXor(p);
                 A_TEST:
                   Result:=OptPass1Test(p);
+                A_Jcc:
+                  Result:=OptPass1Jcc(p);
                 else
                   ;
               end;

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác