Browse Source

* fix RegInInstruction
+ introduce generic RegModifiedByInstruction

git-svn-id: trunk@20472 -

florian 13 years ago
parent
commit
8278271b4e
1 changed files with 10 additions and 3 deletions
  1. 10 3
      compiler/aoptbase.pas

+ 10 - 3
compiler/aoptbase.pas

@@ -53,6 +53,8 @@ unit aoptbase;
         { returns true if register Reg is used in the reference Ref }
         { returns true if register Reg is used in the reference Ref }
         Function RegInRef(Reg: TRegister; Const Ref: TReference): Boolean;
         Function RegInRef(Reg: TRegister; Const Ref: TReference): Boolean;
 
 
+        function RegModifiedByInstruction(Reg: TRegister; p1: tai): boolean;virtual;
+
         { returns true if the references are completely equal }
         { returns true if the references are completely equal }
         {Function RefsEqual(Const R1, R2: TReference): Boolean;}
         {Function RefsEqual(Const R1, R2: TReference): Boolean;}
 
 
@@ -113,11 +115,11 @@ unit aoptbase;
     Begin
     Begin
       TmpResult := False;
       TmpResult := False;
       Count := 0;
       Count := 0;
-      If (p1.typ = ait_instruction) Then
+      If (p1.typ = ait_instruction) and assigned(TInstr(p1).oper[0]) Then
         Repeat
         Repeat
-          TmpResult := RegInOp(Reg, PInstr(p1)^.oper[Count]^);
+          TmpResult := RegInOp(Reg, TInstr(p1).oper[Count]^);
           Inc(Count)
           Inc(Count)
-        Until (Count = MaxOps) or TmpResult;
+        Until (TInstr(p1).oper[Count]=nil) or (Count = MaxOps) or TmpResult;
       RegInInstruction := TmpResult
       RegInInstruction := TmpResult
     End;
     End;
 
 
@@ -141,6 +143,11 @@ unit aoptbase;
   {$endif RefsHaveIndexReg}
   {$endif RefsHaveIndexReg}
   End;
   End;
 
 
+  Function TAOptBase.RegModifiedByInstruction(Reg: TRegister; p1: tai): Boolean;
+  Begin
+    Result:=true;
+  End;
+
   function labelCanBeSkipped(p: tai_label): boolean;
   function labelCanBeSkipped(p: tai_label): boolean;
   begin
   begin
     labelCanBeSkipped := not(p.labsym.is_used) or (p.labsym.labeltype<>alt_jump);
     labelCanBeSkipped := not(p.labsym.is_used) or (p.labsym.labeltype<>alt_jump);