Răsfoiți Sursa

* New UpdateUsedRegsBetween utility subroutine

J. Gareth "Curious Kit" Moreton 3 ani în urmă
părinte
comite
9ee672f9eb
1 a modificat fișierele cu 19 adăugiri și 0 ștergeri
  1. 19 0
      compiler/aoptobj.pas

+ 19 - 0
compiler/aoptobj.pas

@@ -274,6 +274,10 @@ Unit AoptObj;
         Procedure UpdateUsedRegs(p : Tai);
         class procedure UpdateUsedRegs(var Regs: TAllUsedRegs; p: Tai); static;
 
+        { UpdateUsedRegsBetween updates the given TUsedRegs from p1 to p2 exclusive, calling GetNextInstruction
+          to move between instructions and sending p1.Next to UpdateUsedRegs }
+        class procedure UpdateUsedRegsBetween(var Regs: TAllUsedRegs; p1, p2: Tai); static;
+
         { If UpdateUsedRegsAndOptimize has read ahead, the result is one before
           the next valid entry (so "p.Next" returns what's expected).  If no
           reading ahead happened, then the result is equal to p. }
@@ -1118,6 +1122,21 @@ Unit AoptObj;
         end;
 
 
+      class procedure TAOptObj.UpdateUsedRegsBetween(var Regs: TAllUsedRegs; p1, p2: Tai); static;
+        var
+          i : TRegisterType;
+        begin
+          while (p1 <> p2) do
+            begin
+              for i:=low(TRegisterType) to high(TRegisterType) do
+                Regs[i].Update(tai(p1.Next));
+
+              if not GetNextInstruction(p1, p1) then
+                InternalError(2022010701);
+            end;
+        end;
+
+
       function TAOptObj.CopyUsedRegs(var dest: TAllUsedRegs): boolean;
       var
         i : TRegisterType;