Browse Source

* seperate OPTimizer INFO pointer field in tai object

Jonas Maebe 26 years ago
parent
commit
460464ff24
2 changed files with 50 additions and 45 deletions
  1. 7 1
      compiler/aasm.pas
  2. 43 44
      compiler/csopt386.pas

+ 7 - 1
compiler/aasm.pas

@@ -95,6 +95,8 @@ unit aasm;
        pai = ^tai;
        pai = ^tai;
        tai = object(tlinkedlist_item)
        tai = object(tlinkedlist_item)
           typ      : tait;
           typ      : tait;
+         {pointer to record with optimizer info about this tai object}
+          optinfo: pointer;
           fileinfo : tfileposinfo;
           fileinfo : tfileposinfo;
           constructor init;
           constructor init;
        end;
        end;
@@ -351,6 +353,7 @@ uses
 
 
     constructor tai.init;
     constructor tai.init;
       begin
       begin
+        optinfo := nil;
         fileinfo:=aktfilepos;
         fileinfo:=aktfilepos;
       end;
       end;
 
 
@@ -1006,7 +1009,10 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.42  1999-05-06 09:05:05  peter
+  Revision 1.43  1999-05-08 20:38:02  jonas
+    * seperate OPTimizer INFO pointer field in tai object
+
+  Revision 1.42  1999/05/06 09:05:05  peter
     * generic write_float and str_float
     * generic write_float and str_float
     * fixed constant float conversions
     * fixed constant float conversions
 
 

+ 43 - 44
compiler/csopt386.pas

@@ -79,7 +79,7 @@ Begin {CheckSequence}
   RegCounter := R_EAX;
   RegCounter := R_EAX;
   GetLastInstruction(p, PrevNonRemovablePai);
   GetLastInstruction(p, PrevNonRemovablePai);
   While (RegCounter <= R_EDI) And
   While (RegCounter <= R_EDI) And
-        (PPaiProp(PrevNonRemovablePai^.fileinfo.line)^.Regs[RegCounter].Typ <> Con_Ref) Do
+        (PPaiProp(PrevNonRemovablePai^.OptInfo)^.Regs[RegCounter].Typ <> Con_Ref) Do
     Inc(RegCounter);
     Inc(RegCounter);
   While (RegCounter <= R_EDI) Do
   While (RegCounter <= R_EDI) Do
     Begin
     Begin
@@ -89,9 +89,9 @@ Begin {CheckSequence}
       RegInfo.New2OldReg[ProcInfo.FramePointer] := ProcInfo.FramePointer;
       RegInfo.New2OldReg[ProcInfo.FramePointer] := ProcInfo.FramePointer;
       RegInfo.New2OldReg[R_ESP] := R_ESP;
       RegInfo.New2OldReg[R_ESP] := R_ESP;
       Found := 0;
       Found := 0;
-      hp2 := PPaiProp(PrevNonRemovablePai^.fileinfo.line)^.Regs[RegCounter].StartMod;
-      If (PrevNonRemovablePai <> PPaiProp(PrevNonRemovablePai^.fileinfo.line)^.Regs[RegCounter].StartMod)
-        Then OldNrOfMods := PPaiProp(PrevNonRemovablePai^.fileinfo.line)^.Regs[RegCounter].NrOfMods
+      hp2 := PPaiProp(PrevNonRemovablePai^.OptInfo)^.Regs[RegCounter].StartMod;
+      If (PrevNonRemovablePai <> PPaiProp(PrevNonRemovablePai^.OptInfo)^.Regs[RegCounter].StartMod)
+        Then OldNrOfMods := PPaiProp(PrevNonRemovablePai^.OptInfo)^.Regs[RegCounter].NrOfMods
         Else OldNrOfMods := 1;
         Else OldNrOfMods := 1;
       hp3 := p;
       hp3 := p;
       While (Found <> OldNrOfMods) And
       While (Found <> OldNrOfMods) And
@@ -150,7 +150,7 @@ Begin {CheckSequence}
                          Begin
                          Begin
                            TmpResult := False;
                            TmpResult := False;
                            If (Found > 0) Then
                            If (Found > 0) Then
-                             Found := PPaiProp(Pai(p)^.fileinfo.line)^.Regs[Reg].NrOfMods
+                             Found := PPaiProp(Pai(p)^.OptInfo)^.Regs[Reg].NrOfMods
                          End
                          End
                    End
                    End
                  Else
                  Else
@@ -168,7 +168,7 @@ Begin {CheckSequence}
                          Begin
                          Begin
                            TmpResult := False;
                            TmpResult := False;
                            If (Found > 0) Then
                            If (Found > 0) Then
-                             Found := PPaiProp(Pai(p)^.fileinfo.line)^.Regs[Reg].NrOfMods
+                             Found := PPaiProp(Pai(p)^.OptInfo)^.Regs[Reg].NrOfMods
                          End
                          End
                    End
                    End
              Else *)
              Else *)
@@ -183,7 +183,7 @@ Begin {CheckSequence}
   and that it was equal (otherwise CheckSequence would have returned false
   and that it was equal (otherwise CheckSequence would have returned false
   and the instruction wouldn't have been removed). If this "If found > 0"
   and the instruction wouldn't have been removed). If this "If found > 0"
   check is left out, incorrect optimizations are performed.}
   check is left out, incorrect optimizations are performed.}
-                    Found := PPaiProp(Pai(p)^.fileinfo.line)^.Regs[Reg].NrOfMods
+                    Found := PPaiProp(Pai(p)^.OptInfo)^.Regs[Reg].NrOfMods
                 End
                 End
           End
           End
         Else TmpResult := True;
         Else TmpResult := True;
@@ -203,9 +203,9 @@ Begin {CheckSequence}
       Repeat
       Repeat
         Inc(RegCounter);
         Inc(RegCounter);
       Until (RegCounter > R_EDI) or
       Until (RegCounter > R_EDI) or
-            ((PPaiProp(PrevNonRemovablePai^.fileinfo.line)^.Regs[RegCounter].Typ = Con_Ref) {And
+            ((PPaiProp(PrevNonRemovablePai^.OptInfo)^.Regs[RegCounter].Typ = Con_Ref) {And
              ((Regcounter = Reg) Or
              ((Regcounter = Reg) Or
-              Not(PaiInSequence(p, PPaiProp(PrevNonRemovablePai^.fileinfo.line)^.Regs[RegCounter]))) }
+              Not(PaiInSequence(p, PPaiProp(PrevNonRemovablePai^.OptInfo)^.Regs[RegCounter]))) }
             );
             );
     End;
     End;
   If (HighFound > 0) And
   If (HighFound > 0) And
@@ -249,8 +249,8 @@ Begin
           Begin
           Begin
             Case Pai386(p)^.opcode Of
             Case Pai386(p)^.opcode Of
               A_CLD: If GetLastInstruction(p, hp1) And
               A_CLD: If GetLastInstruction(p, hp1) And
-                        (PPaiProp(hp1^.fileinfo.line)^.DirFlag = F_NotSet) Then
-                       PPaiProp(Pai(p)^.fileinfo.line)^.CanBeRemoved := True;
+                        (PPaiProp(hp1^.OptInfo)^.DirFlag = F_NotSet) Then
+                       PPaiProp(Pai(p)^.OptInfo)^.CanBeRemoved := True;
               A_MOV, A_MOVZX, A_MOVSX:
               A_MOV, A_MOVZX, A_MOVSX:
                 Begin
                 Begin
                   Case Pai386(p)^.oper[0].typ Of
                   Case Pai386(p)^.oper[0].typ Of
@@ -261,7 +261,7 @@ Begin
                       End;}
                       End;}
                     Top_Ref:
                     Top_Ref:
                       Begin {destination is always a register in this case}
                       Begin {destination is always a register in this case}
-                        With PPaiProp(p^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)] Do
+                        With PPaiProp(p^.OptInfo)^.Regs[Reg32(Pai386(p)^.oper[1].reg)] Do
                           Begin
                           Begin
                             If GetLastInstruction (p, hp1) And
                             If GetLastInstruction (p, hp1) And
                               (hp1^.typ <> ait_marker) Then
                               (hp1^.typ <> ait_marker) Then
@@ -295,7 +295,7 @@ Begin
                                                 RegInInstruction(Reg32(Pai386(hp2)^.oper[1].reg), p))
                                                 RegInInstruction(Reg32(Pai386(hp2)^.oper[1].reg), p))
                                            Then hp1 := p;
                                            Then hp1 := p;
 {$ifndef noremove}
 {$ifndef noremove}
-                                         PPaiProp(p^.fileinfo.line)^.CanBeRemoved := True;
+                                         PPaiProp(p^.OptInfo)^.CanBeRemoved := True;
 {$endif noremove}
 {$endif noremove}
                                          Inc(Cnt2);
                                          Inc(Cnt2);
                                          GetNextInstruction(p, p);
                                          GetNextInstruction(p, p);
@@ -344,7 +344,6 @@ Begin
                                                                     {old reg          new reg}
                                                                     {old reg          new reg}
                                                       RegInfo.New2OldReg[RegCounter], RegCounter));
                                                       RegInfo.New2OldReg[RegCounter], RegCounter));
                                                hp3^.fileinfo := hp2^.fileinfo;
                                                hp3^.fileinfo := hp2^.fileinfo;
-                                               hp3^.fileinfo.line := PPaiProp(hp2^.fileinfo.line)^.LineSave;
                                                InsertLLItem(AsmL, Pai(hp2^.previous), hp2, hp3);
                                                InsertLLItem(AsmL, Pai(hp2^.previous), hp2, hp3);
                                              End
                                              End
                                            Else
                                            Else
@@ -354,7 +353,7 @@ Begin
   is reloaded)}
   is reloaded)}
                                              Begin
                                              Begin
  {load Cnt2 with the total number of instructions of this sequence}
  {load Cnt2 with the total number of instructions of this sequence}
-                                               Cnt2 := PPaiProp(hp4^.fileinfo.line)^.
+                                               Cnt2 := PPaiProp(hp4^.OptInfo)^.
                                                        Regs[RegInfo.New2OldReg[RegCounter]].NrOfMods;
                                                        Regs[RegInfo.New2OldReg[RegCounter]].NrOfMods;
  {sometimes, a register can not be removed from a sequence, because it's
  {sometimes, a register can not be removed from a sequence, because it's
   still used afterwards:
   still used afterwards:
@@ -373,10 +372,10 @@ Begin
                                                hp3 := hp2;
                                                hp3 := hp2;
                                                For Cnt := 1 to Pred(Cnt2) Do
                                                For Cnt := 1 to Pred(Cnt2) Do
                                                  GetNextInstruction(hp3, hp3);
                                                  GetNextInstruction(hp3, hp3);
-                                               TmpState := PPaiProp(hp3^.fileinfo.line)^.Regs[RegCounter].WState;
+                                               TmpState := PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState;
                                                GetNextInstruction(hp3, hp3);
                                                GetNextInstruction(hp3, hp3);
-                                               If (TmpState <> PPaiProp(hp3^.fileinfo.line)^.Regs[RegCounter].WState) Or
-                                                  Not(RegCounter in PPaiProp(hp3^.fileinfo.line)^.UsedRegs) Then
+                                               If (TmpState <> PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState) Or
+                                                  Not(RegCounter in PPaiProp(hp3^.OptInfo)^.UsedRegs) Then
                                                  Begin
                                                  Begin
 {$ifdef csdebug}
 {$ifdef csdebug}
              Writeln('Cnt2: ',Cnt2);
              Writeln('Cnt2: ',Cnt2);
@@ -388,30 +387,30 @@ Begin
                                                    For Cnt := 1 to Cnt2 Do
                                                    For Cnt := 1 to Cnt2 Do
                                                      Begin
                                                      Begin
  {save the WState of the last pai object of the sequence for later use}
  {save the WState of the last pai object of the sequence for later use}
-                                                       TmpState := PPaiProp(hp3^.fileinfo.line)^.Regs[RegCounter].WState;
+                                                       TmpState := PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState;
 {$ifdef csdebug}
 {$ifdef csdebug}
              hp5 := new(pai_asm_comment,init(strpnew('WState for '+att_reg2str[Regcounter]+': '
              hp5 := new(pai_asm_comment,init(strpnew('WState for '+att_reg2str[Regcounter]+': '
                                                       +tostr(tmpstate))));
                                                       +tostr(tmpstate))));
              InsertLLItem(AsmL, hp3, pai(hp3^.next), hp5);
              InsertLLItem(AsmL, hp3, pai(hp3^.next), hp5);
 {$endif csdebug}
 {$endif csdebug}
-                                                       PPaiProp(hp3^.fileinfo.line)^.Regs[RegCounter] :=
-                                                         PPaiProp(hp4^.fileinfo.line)^.Regs[RegCounter];
+                                                       PPaiProp(hp3^.OptInfo)^.Regs[RegCounter] :=
+                                                         PPaiProp(hp4^.OptInfo)^.Regs[RegCounter];
                                                        GetNextInstruction(hp3, hp3);
                                                        GetNextInstruction(hp3, hp3);
                                                      End;
                                                      End;
  {here, hp3 = p = Pai object right after the sequence, TmpState = WState of
  {here, hp3 = p = Pai object right after the sequence, TmpState = WState of
   RegCounter at the last Pai object of the sequence}
   RegCounter at the last Pai object of the sequence}
                                                    GetLastInstruction(hp3, hp3);
                                                    GetLastInstruction(hp3, hp3);
                                                    While GetNextInstruction(hp3, hp3) And
                                                    While GetNextInstruction(hp3, hp3) And
-                                                         (PPaiProp(hp3^.fileinfo.line)^.Regs[RegCounter].WState
+                                                         (PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState
                                                           = TmpState) Do
                                                           = TmpState) Do
 {$ifdef csdebug}
 {$ifdef csdebug}
         begin
         begin
              hp5 := new(pai_asm_comment,init(strpnew('WState for '+att_reg2str[Regcounter]+': '+
              hp5 := new(pai_asm_comment,init(strpnew('WState for '+att_reg2str[Regcounter]+': '+
-                                                      tostr(PPaiProp(hp3^.fileinfo.line)^.Regs[RegCounter].WState))));
+                                                      tostr(PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState))));
              InsertLLItem(AsmL, hp3, pai(hp3^.next), hp5);
              InsertLLItem(AsmL, hp3, pai(hp3^.next), hp5);
 {$endif csdebug}
 {$endif csdebug}
-                                                     PPaiProp(hp3^.fileinfo.line)^.Regs[RegCounter] :=
-                                                       PPaiProp(hp4^.fileinfo.line)^.Regs[RegCounter];
+                                                     PPaiProp(hp3^.OptInfo)^.Regs[RegCounter] :=
+                                                       PPaiProp(hp4^.OptInfo)^.Regs[RegCounter];
 {$ifdef csdebug}
 {$ifdef csdebug}
         end;
         end;
 {$endif csdebug}
 {$endif csdebug}
@@ -425,7 +424,7 @@ Begin
                                                    For Cnt := 1 to Cnt2 Do
                                                    For Cnt := 1 to Cnt2 Do
                                                      Begin
                                                      Begin
                                                        If RegModifiedByInstruction(RegCounter, hp3)
                                                        If RegModifiedByInstruction(RegCounter, hp3)
-                                                         Then PPaiProp(hp3^.fileinfo.line)^.CanBeRemoved := False;
+                                                         Then PPaiProp(hp3^.OptInfo)^.CanBeRemoved := False;
                                                        GetNextInstruction(hp3, hp3);
                                                        GetNextInstruction(hp3, hp3);
                                                      End;
                                                      End;
                                                  End;
                                                  End;
@@ -442,9 +441,9 @@ Begin
                                    End
                                    End
                                  Else
                                  Else
                                    If (Cnt > 0) And
                                    If (Cnt > 0) And
-                                      (PPaiProp(p^.fileinfo.line)^.
+                                      (PPaiProp(p^.OptInfo)^.
                                         Regs[Reg32(Pai386(p)^.oper[1].reg)].Typ = Con_Ref) And
                                         Regs[Reg32(Pai386(p)^.oper[1].reg)].Typ = Con_Ref) And
-                                      (PPaiProp(p^.fileinfo.line)^.CanBeRemoved) Then
+                                      (PPaiProp(p^.OptInfo)^.CanBeRemoved) Then
                                      Begin
                                      Begin
                                        hp2 := p;
                                        hp2 := p;
                                        Cnt2 := 1;
                                        Cnt2 := 1;
@@ -452,7 +451,7 @@ Begin
                                          Begin
                                          Begin
                                            If RegInInstruction(Pai386(hp2)^.oper[1].reg, p) Or
                                            If RegInInstruction(Pai386(hp2)^.oper[1].reg, p) Or
                                               RegInInstruction(Reg32(Pai386(hp2)^.oper[1].reg), p) Then
                                               RegInInstruction(Reg32(Pai386(hp2)^.oper[1].reg), p) Then
-                                             PPaiProp(p^.fileinfo.line)^.CanBeRemoved := False;
+                                             PPaiProp(p^.OptInfo)^.CanBeRemoved := False;
                                            Inc(Cnt2);
                                            Inc(Cnt2);
                                            GetNextInstruction(p, p);
                                            GetNextInstruction(p, p);
                                          End;
                                          End;
@@ -466,10 +465,10 @@ Begin
                           Top_Reg:
                           Top_Reg:
                             Begin
                             Begin
                               If GetLastInstruction(p, hp1) Then
                               If GetLastInstruction(p, hp1) Then
-                                With PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)] Do
+                                With PPaiProp(hp1^.OptInfo)^.Regs[Reg32(Pai386(p)^.oper[1].reg)] Do
                                   If (Typ = Con_Const) And
                                   If (Typ = Con_Const) And
                                      (StartMod = p) Then
                                      (StartMod = p) Then
-                                    PPaiProp(p^.fileinfo.line)^.CanBeRemoved := True;
+                                    PPaiProp(p^.OptInfo)^.CanBeRemoved := True;
                             End;
                             End;
 {                          Top_Ref:;}
 {                          Top_Ref:;}
                         End;
                         End;
@@ -477,17 +476,17 @@ Begin
                   End;
                   End;
                 End;
                 End;
               A_STD: If GetLastInstruction(p, hp1) And
               A_STD: If GetLastInstruction(p, hp1) And
-                        (PPaiProp(hp1^.fileinfo.line)^.DirFlag = F_Set) Then
-                        PPaiProp(Pai(p)^.fileinfo.line)^.CanBeRemoved := True;
+                        (PPaiProp(hp1^.OptInfo)^.DirFlag = F_Set) Then
+                        PPaiProp(Pai(p)^.OptInfo)^.CanBeRemoved := True;
               A_XOR:
               A_XOR:
                 Begin
                 Begin
                   If (Pai386(p)^.oper[0].typ = top_reg) And
                   If (Pai386(p)^.oper[0].typ = top_reg) And
                      (Pai386(p)^.oper[0].typ = top_reg) And
                      (Pai386(p)^.oper[0].typ = top_reg) And
                      (Pai386(p)^.oper[1].reg = Pai386(p)^.oper[1].reg) And
                      (Pai386(p)^.oper[1].reg = Pai386(p)^.oper[1].reg) And
                      GetLastInstruction(p, hp1) And
                      GetLastInstruction(p, hp1) And
-                     (PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)].typ = con_const) And
-                     (PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)].StartMod = nil)
-                    Then PPaiProp(p^.fileinfo.line)^.CanBeRemoved := True
+                     (PPaiProp(hp1^.OptInfo)^.Regs[Reg32(Pai386(p)^.oper[1].reg)].typ = con_const) And
+                     (PPaiProp(hp1^.OptInfo)^.Regs[Reg32(Pai386(p)^.oper[1].reg)].StartMod = nil)
+                    Then PPaiProp(p^.OptInfo)^.CanBeRemoved := True
                 End
                 End
             End
             End
           End;
           End;
@@ -511,11 +510,11 @@ Begin
   While (p <> Last) Do
   While (p <> Last) Do
     Begin
     Begin
 {$ifndef noinstremove}
 {$ifndef noinstremove}
-      If PPaiProp(p^.fileinfo.line)^.CanBeRemoved
+      If PPaiProp(p^.OptInfo)^.CanBeRemoved
         Then
         Then
           Begin
           Begin
 {$IfDef TP}
 {$IfDef TP}
-            Dispose(PPaiProp(p^.fileinfo.line));
+            Dispose(PPaiProp(p^.OptInfo));
 {$EndIf}
 {$EndIf}
             GetNextInstruction(p, hp1);
             GetNextInstruction(p, hp1);
             AsmL^.Remove(p);
             AsmL^.Remove(p);
@@ -527,12 +526,9 @@ Begin
 {$endif noinstremove}
 {$endif noinstremove}
           Begin
           Begin
 {$IfDef TP}
 {$IfDef TP}
-            TmpLine := PPaiProp(p^.fileinfo.line)^.linesave;
-            Dispose(PPaiProp(p^.fileinfo.line));
-            p^.fileinfo.line := TmpLine;
-{$Else TP}
-            p^.fileinfo.line := PPaiProp(p^.fileinfo.line)^.linesave;
+            Dispose(PPaiProp(p^.OptInfo));
 {$EndIf TP}
 {$EndIf TP}
+            p^.OptInfo := nil;
             GetNextInstruction(p, p);
             GetNextInstruction(p, p);
             Inc(InstrCnt);
             Inc(InstrCnt);
           End;
           End;
@@ -552,7 +548,10 @@ End.
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.20  1999-05-01 13:24:19  peter
+ Revision 1.21  1999-05-08 20:38:03  jonas
+   * seperate OPTimizer INFO pointer field in tai object
+
+ Revision 1.20  1999/05/01 13:24:19  peter
    * merged nasm compiler
    * merged nasm compiler
    * old asm moved to oldasm/
    * old asm moved to oldasm/