Sfoglia il codice sorgente

o overhaul-base.patch by J. Gareth Moreton, base for further patches
+ some inline directives added
+ some functions exported from units

git-svn-id: trunk@42722 -

florian 6 anni fa
parent
commit
9230ae5aab
4 ha cambiato i file con 27 aggiunte e 6 eliminazioni
  1. 1 1
      compiler/aopt.pas
  2. 1 1
      compiler/aoptbase.pas
  3. 9 0
      compiler/aoptobj.pas
  4. 16 4
      compiler/aoptutils.pas

+ 1 - 1
compiler/aopt.pas

@@ -53,9 +53,9 @@ Unit aopt;
         { Builds a table with the locations of the labels in the TAsmList.
           Also fixes some RegDeallocs like "# %eax released; push (%eax)"  }
         Procedure BuildLabelTableAndFixRegAlloc;
-        procedure clear;
       protected
         procedure pass_1;
+        procedure clear;
       End;
       TAsmOptimizerClass = class of TAsmOptimizer;
 

+ 1 - 1
compiler/aoptbase.pas

@@ -176,7 +176,7 @@ unit aoptbase;
   End;
 
 
-  function labelCanBeSkipped(p: tai_label): boolean;
+  function labelCanBeSkipped(p: tai_label): boolean; inline;
   begin
     labelCanBeSkipped := not(p.labsym.is_used) or (p.labsym.labeltype<>alt_jump);
   end;

+ 9 - 0
compiler/aoptobj.pas

@@ -371,6 +371,15 @@ Unit AoptObj;
 
        Function ArrayRefsEq(const r1, r2: TReference): Boolean;
 
+       { Returns a pointer to the operand that contains the destination label }
+       function JumpTargetOp(ai: taicpu): poper;
+
+       { Returns True if hp is any jump to a label }
+       function IsJumpToLabel(hp: taicpu): boolean;
+
+       { Returns True if hp is an unconditional jump to a label }
+       function IsJumpToLabelUncond(hp: taicpu): boolean;
+
     { ***************************** Implementation **************************** }
 
   Implementation

+ 16 - 4
compiler/aoptutils.pas

@@ -38,22 +38,29 @@ unit aoptutils;
     { skips all labels and returns the next "real" instruction }
     function SkipLabels(hp: tai; var hp2: tai): boolean;
 
+    { sets hp2 to hp and returns True if hp is not nil }
+    function SetAndTest(const hp: tai; out hp2: tai): Boolean;
+
   implementation
 
-    function MatchOpType(const p : taicpu; type0: toptype) : Boolean;
+    uses
+      aasmbase;
+
+
+    function MatchOpType(const p : taicpu; type0: toptype) : Boolean; inline;
       begin
         Result:=(p.ops=1) and (p.oper[0]^.typ=type0);
       end;
 
 
-    function MatchOpType(const p : taicpu; type0,type1 : toptype) : Boolean;
+    function MatchOpType(const p : taicpu; type0,type1 : toptype) : Boolean; inline;
       begin
         Result:=(p.ops=2) and (p.oper[0]^.typ=type0) and (p.oper[1]^.typ=type1);
       end;
 
 
 {$if max_operands>2}
-    function MatchOpType(const p : taicpu; type0,type1,type2 : toptype) : Boolean;
+    function MatchOpType(const p : taicpu; type0,type1,type2 : toptype) : Boolean; inline;
       begin
         Result:=(p.ops=3) and (p.oper[0]^.typ=type0) and (p.oper[1]^.typ=type1) and (p.oper[2]^.typ=type2);
       end;
@@ -78,6 +85,11 @@ unit aoptutils;
           end;
       end;
 
+    { sets hp2 to hp and returns True if hp is not nil }
+    function SetAndTest(const hp: tai; out hp2: tai): Boolean; inline;
+      begin
+        hp2 := hp;
+        Result := Assigned(hp);
+      end;
 
 end.
-