Răsfoiți Sursa

+ RegUsedBetween

git-svn-id: trunk@22182 -
florian 13 ani în urmă
părinte
comite
0c08ae8553
1 a modificat fișierele cu 14 adăugiri și 0 ștergeri
  1. 14 0
      compiler/aoptbase.pas

+ 14 - 0
compiler/aoptbase.pas

@@ -89,6 +89,8 @@ unit aoptbase;
         { create a paicpu Object that loads the contents of reg1 into reg2 }
         Function a_load_reg_reg(reg1, reg2: TRegister): taicpu; Virtual; Abstract;
 
+        { returns true if reg is used by any instruction between p1 and p2 }
+        Function RegUsedBetween(reg: TRegister; p1, p2: tai): Boolean;
     end;
 
     function labelCanBeSkipped(p: tai_label): boolean;
@@ -241,6 +243,18 @@ unit aoptbase;
   End;
 
 
+  Function TAOptBase.RegUsedBetween(reg : TRegister;p1,p2 : tai) : Boolean;
+  Begin
+    Result:=false;
+    while assigned(p1) and assigned(p2) and GetNextInstruction(p1,p1) and (p1<>p2) do
+      if RegInInstruction(reg,p1) then
+        begin
+          Result:=true;
+          exit;
+        end;
+  end;
+
+
   { ******************* Processor dependent stuff *************************** }
 
   Function TAOptBase.RegMaxSize(Reg: TRegister): TRegister;