Browse Source

+ tempalloc
+ -at to show temp alloc info in .s file

peter 26 years ago
parent
commit
61eee61f9a

+ 7 - 3
compiler/aasm.pas

@@ -64,8 +64,8 @@ unit aasm;
           ait_force_line,
           ait_force_line,
           ait_stab_function_name,
           ait_stab_function_name,
           ait_cut, { used to split into tiny assembler files }
           ait_cut, { used to split into tiny assembler files }
-          ait_regalloc,
-          ait_regdealloc,
+          ait_regalloc, { for register,temp allocation debugging }
+          ait_tempalloc,
           ait_marker,
           ait_marker,
           { never used, makes insertation of new ait_ easier to type }
           { never used, makes insertation of new ait_ easier to type }
           ait_dummy);
           ait_dummy);
@@ -1013,7 +1013,11 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  1999-04-14 09:14:44  peter
+  Revision 1.39  1999-04-16 11:49:36  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.38  1999/04/14 09:14:44  peter
     * first things to store the symbol/def number in the ppu
     * first things to store the symbol/def number in the ppu
 
 
   Revision 1.37  1999/03/10 13:25:42  pierre
   Revision 1.37  1999/03/10 13:25:42  pierre

+ 7 - 3
compiler/ag386int.pas

@@ -391,8 +391,8 @@ unit ag386int;
                        AsmWritePChar(pai_asm_comment(hp)^.str);
                        AsmWritePChar(pai_asm_comment(hp)^.str);
                        AsmLn;
                        AsmLn;
                      End;
                      End;
-     ait_regalloc,
-    ait_regdealloc :;
+       ait_regalloc,
+       ait_tempalloc : ;
        ait_section : begin
        ait_section : begin
                        if LastSec<>sec_none then
                        if LastSec<>sec_none then
                         AsmWriteLn('_'+ait_section2masmstr[LastSec]+#9#9'ENDS');
                         AsmWriteLn('_'+ait_section2masmstr[LastSec]+#9#9'ENDS');
@@ -795,7 +795,11 @@ ait_stab_function_name : ;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.31  1999-04-16 10:00:55  pierre
+  Revision 1.32  1999-04-16 11:49:39  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.31  1999/04/16 10:00:55  pierre
     + ifdef USE_OP3 code :
     + ifdef USE_OP3 code :
       added all missing op_... constructors for tai386 needed
       added all missing op_... constructors for tai386 needed
       for SHRD,SHLD and IMUL code in assembler readers
       for SHRD,SHLD and IMUL code in assembler readers

+ 7 - 3
compiler/ag386nsm.pas

@@ -402,8 +402,8 @@ unit ag386nsm;
                        AsmWritePChar(pai_asm_comment(hp)^.str);
                        AsmWritePChar(pai_asm_comment(hp)^.str);
                        AsmLn;
                        AsmLn;
                      End;
                      End;
-      ait_regalloc,
-    ait_regdealloc :;
+       ait_regalloc,
+       ait_tempalloc : ;
        ait_section : begin
        ait_section : begin
                        if pai_section(hp)^.sec<>sec_none then
                        if pai_section(hp)^.sec<>sec_none then
                         begin
                         begin
@@ -740,7 +740,11 @@ ait_stab_function_name : ;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  1999-04-16 10:00:56  pierre
+  Revision 1.27  1999-04-16 11:49:40  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.26  1999/04/16 10:00:56  pierre
     + ifdef USE_OP3 code :
     + ifdef USE_OP3 code :
       added all missing op_... constructors for tai386 needed
       added all missing op_... constructors for tai386 needed
       for SHRD,SHLD and IMUL code in assembler readers
       for SHRD,SHLD and IMUL code in assembler readers

+ 59 - 49
compiler/daopt386.pas

@@ -87,7 +87,7 @@ Const
 {$ifdef GDB}
 {$ifdef GDB}
   ,ait_stabs, ait_stabn, ait_stab_function_name
   ,ait_stabs, ait_stabn, ait_stab_function_name
 {$endif GDB}
 {$endif GDB}
-  ,ait_regalloc, ait_regdealloc
+  ,ait_regalloc,ait_tempalloc
   ];
   ];
 
 
 {the maximum number of things (registers, memory, ...) a single instruction
 {the maximum number of things (registers, memory, ...) a single instruction
@@ -756,26 +756,29 @@ Begin
 End;
 End;
 
 
 Function FindRegAlloc(Reg: TRegister; StartPai: Pai): Boolean;
 Function FindRegAlloc(Reg: TRegister; StartPai: Pai): Boolean;
-{Returns true if a ait_regalloc object for Reg is found in the block of Pai's
+{Returns true if a ait_alloc object for Reg is found in the block of Pai's
  starting with StartPai and ending with the next "real" instruction}
  starting with StartPai and ending with the next "real" instruction}
-Var TmpResult: Boolean;
 Begin
 Begin
-  TmpResult := False;
+  FindRegAlloc:=False;
   Repeat
   Repeat
     While Assigned(StartPai) And
     While Assigned(StartPai) And
-          ((StartPai^.typ in (SkipInstr - [ait_RegAlloc])) Or
+          ((StartPai^.typ in (SkipInstr - [ait_regAlloc])) Or
            ((StartPai^.typ = ait_label) and
            ((StartPai^.typ = ait_label) and
             Not(Pai_Label(StartPai)^.l^.Is_Used))) Do
             Not(Pai_Label(StartPai)^.l^.Is_Used))) Do
       StartPai := Pai(StartPai^.Next);
       StartPai := Pai(StartPai^.Next);
     If Assigned(StartPai) And
     If Assigned(StartPai) And
-       (StartPai^.typ = ait_RegAlloc) Then
+       (StartPai^.typ = ait_regAlloc) and (PairegAlloc(StartPai)^.allocation) Then
       Begin
       Begin
-        TmpResult := (PaiRegAlloc(StartPai)^.Reg = Reg);
+        if PairegAlloc(StartPai)^.Reg = Reg then
+         begin
+           FindRegAlloc:=true;
+           exit;
+         end;
         StartPai := Pai(StartPai^.Next);
         StartPai := Pai(StartPai^.Next);
-      End;
-  Until Not(Assigned(StartPai)) Or
-        Not(StartPai^.typ in SkipInstr) or TmpResult;
-  FindRegAlloc := TmpResult;
+      End
+    else
+      exit;
+  Until false;
 End;
 End;
 
 
 Procedure BuildLabelTableAndFixRegAlloc(AsmL: PAasmOutput; Var LabelTable: PLabelTable; LowLabel: Longint;
 Procedure BuildLabelTableAndFixRegAlloc(AsmL: PAasmOutput; Var LabelTable: PLabelTable; LowLabel: Longint;
@@ -802,45 +805,48 @@ Begin
                   ait_Label:
                   ait_Label:
                     If Pai_Label(p)^.l^.is_used Then
                     If Pai_Label(p)^.l^.is_used Then
                       LabelTable^[Pai_Label(p)^.l^.nb-LowLabel].PaiObj := p;
                       LabelTable^[Pai_Label(p)^.l^.nb-LowLabel].PaiObj := p;
-                  ait_RegAlloc:
-                    Begin
-                      If Not(PaiRegAlloc(p)^.Reg in UsedRegs) Then
-                        UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg]
-                      Else
+                  ait_regAlloc:
+                     begin
+                       if PairegAlloc(p)^.Allocation then
+                        Begin
+                          If Not(PaiRegAlloc(p)^.Reg in UsedRegs) Then
+                            UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg]
+                          Else
+                            Begin
+                              hp1 := p;
+                              hp2 := nil;
+                              While GetLastInstruction(hp1, hp1) And
+                                    Not(RegInInstruction(PaiRegAlloc(p)^.Reg, hp1)) Do
+                                hp2 := hp1;
+                             If hp2 <> nil Then
+                               Begin
+                                 hp1 := New(PaiRegAlloc, DeAlloc(PaiRegAlloc(p)^.Reg));
+                                 InsertLLItem(AsmL, Pai(hp2^.previous), hp2, hp1);
+                               End;
+                            End;
+                        End
+                       else
                         Begin
                         Begin
+                          UsedRegs := UsedRegs - [PaiRegAlloc(p)^.Reg];
                           hp1 := p;
                           hp1 := p;
                           hp2 := nil;
                           hp2 := nil;
-                          While GetLastInstruction(hp1, hp1) And
-                                Not(RegInInstruction(PaiRegAlloc(p)^.Reg, hp1)) Do
+                          While Not(FindRegAlloc(PaiRegAlloc(p)^.Reg, Pai(hp1^.Next))) And
+                                GetNextInstruction(hp1, hp1) And
+                                RegInInstruction(PaiRegAlloc(p)^.Reg, hp1) Do
                             hp2 := hp1;
                             hp2 := hp1;
-                         If hp2 <> nil Then
-                           Begin
-                             hp1 := New(PaiRegDeAlloc, Init(PaiRegAlloc(p)^.Reg));
-                             InsertLLItem(AsmL, Pai(hp2^.previous), hp2, hp1);
-                           End;
-                        End;
-                    End;
-                  ait_RegDeAlloc:
-                    Begin
-                      UsedRegs := UsedRegs - [PaiRegDeAlloc(p)^.Reg];
-                      hp1 := p;
-                      hp2 := nil;
-                      While Not(FindRegAlloc(PaiRegDeAlloc(p)^.Reg, Pai(hp1^.Next))) And
-                            GetNextInstruction(hp1, hp1) And
-                            RegInInstruction(PaiRegDeAlloc(p)^.Reg, hp1) Do
-                        hp2 := hp1;
-                      If hp2 <> nil Then
-                        Begin
-                          hp1 := Pai(p^.previous);
-                          AsmL^.Remove(p);
-                          InsertLLItem(AsmL, hp2, Pai(hp2^.Next), p);
-                          p := hp1;
+                          If hp2 <> nil Then
+                            Begin
+                              hp1 := Pai(p^.previous);
+                              AsmL^.Remove(p);
+                              InsertLLItem(AsmL, hp2, Pai(hp2^.Next), p);
+                              p := hp1;
+                            End;
                         End;
                         End;
-                    End;
+                     end;
                 End;
                 End;
                 P := Pai(p^.Next);
                 P := Pai(p^.Next);
                 While Assigned(p) And
                 While Assigned(p) And
-                      (p^.typ in (SkipInstr - [ait_regdealloc,ait_regalloc])) Do
+                      (p^.typ in (SkipInstr - [ait_regalloc])) Do
                   P := Pai(P^.Next);
                   P := Pai(P^.Next);
               End;
               End;
 {$IfDef TP}
 {$IfDef TP}
@@ -1240,17 +1246,17 @@ Procedure UpdateUsedRegs(Var UsedRegs: TRegSet; p: Pai);
 Begin
 Begin
   Repeat
   Repeat
     While Assigned(p) And
     While Assigned(p) And
-          ((p^.typ in (SkipInstr - [ait_RegAlloc, ait_RegDealloc])) or
+          ((p^.typ in (SkipInstr - [ait_RegAlloc])) or
            ((p^.typ = ait_label) And
            ((p^.typ = ait_label) And
             Not(Pai_Label(p)^.l^.is_used))) Do
             Not(Pai_Label(p)^.l^.is_used))) Do
          p := Pai(p^.next);
          p := Pai(p^.next);
     While Assigned(p) And
     While Assigned(p) And
-          (p^.typ in [ait_RegAlloc, ait_RegDealloc]) Do
+          (p^.typ=ait_RegAlloc) Do
       Begin
       Begin
-        Case p^.typ Of
-          ait_RegAlloc: UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg];
-          ait_regdealloc: UsedRegs := UsedRegs - [PaiRegDeAlloc(p)^.Reg];
-        End;
+        if pairegalloc(p)^.allocation then
+          UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg]
+        else
+          UsedRegs := UsedRegs - [PaiRegAlloc(p)^.Reg];
         p := pai(p^.next);
         p := pai(p^.next);
       End;
       End;
   Until Not(Assigned(p)) Or
   Until Not(Assigned(p)) Or
@@ -2227,7 +2233,11 @@ End.
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.39  1999-02-26 00:48:18  peter
+ Revision 1.40  1999-04-16 11:49:41  peter
+   + tempalloc
+   + -at to show temp alloc info in .s file
+
+ Revision 1.39  1999/02/26 00:48:18  peter
    * assembler writers fixed for ag386bin
    * assembler writers fixed for ag386bin
 
 
  Revision 1.38  1999/02/25 21:02:34  peter
  Revision 1.38  1999/02/25 21:02:34  peter

+ 7 - 2
compiler/globtype.pas

@@ -66,7 +66,8 @@ interface
          { debugger }
          { debugger }
          cs_gdb_dbx,cs_gdb_gsym,cs_gdb_heaptrc,
          cs_gdb_dbx,cs_gdb_gsym,cs_gdb_heaptrc,
          { assembling }
          { assembling }
-         cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,cs_asm_regalloc,
+         cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
+         cs_asm_regalloc,cs_asm_tempalloc,
          { linking }
          { linking }
          cs_link_extern,cs_link_shared,cs_link_static,cs_link_deffile
          cs_link_extern,cs_link_shared,cs_link_static,cs_link_deffile
        );
        );
@@ -108,7 +109,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  1999-04-10 16:15:01  peter
+  Revision 1.6  1999-04-16 11:49:42  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.5  1999/04/10 16:15:01  peter
     * fixed browcol
     * fixed browcol
     + -ar to show regalloc info in .s file
     + -ar to show regalloc info in .s file
 
 

+ 48 - 19
compiler/i386.pas

@@ -1,4 +1,4 @@
-{                                                   
+{
     $Id$
     $Id$
     Copyright (c) 1995-98 by Florian Klaempfl
     Copyright (c) 1995-98 by Florian Klaempfl
 
 
@@ -381,21 +381,23 @@ unit i386;
        end;
        end;
 
 
        pairegalloc = ^tairegalloc;
        pairegalloc = ^tairegalloc;
-
        tairegalloc = object(tai)
        tairegalloc = object(tai)
-          reg : tregister;
-          constructor init(r : tregister);
+          allocation : boolean;
+          reg        : tregister;
+          constructor alloc(r : tregister);
+          constructor dealloc(r : tregister);
        end;
        end;
 
 
-       pairegdealloc = ^tairegdealloc;
-
-       tairegdealloc = object(tai)
-          reg : tregister;
-          constructor init(r : tregister);
+       paitempalloc = ^taitempalloc;
+       taitempalloc = object(tai)
+          allocation : boolean;
+          temppos,
+          tempsize   : longint;
+          constructor alloc(pos,size:longint);
+          constructor dealloc(pos,size:longint);
        end;
        end;
 
 
        pai386 = ^tai386;
        pai386 = ^tai386;
-
        tai386 = object(tai)
        tai386 = object(tai)
           opcode : tasmop;
           opcode : tasmop;
           opsize:topsize;
           opsize:topsize;
@@ -1399,22 +1401,45 @@ unit i386;
                        objects for register de/allocation
                        objects for register de/allocation
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tairegalloc.init(r : tregister);
 
 
+    constructor tairegalloc.alloc(r : tregister);
       begin
       begin
-         inherited init;
-         typ:=ait_regalloc;
-         reg:=r;
+        inherited init;
+        typ:=ait_regalloc;
+        allocation:=true;
+        reg:=r;
       end;
       end;
 
 
-    constructor tairegdealloc.init(r : tregister);
 
 
+    constructor tairegalloc.dealloc(r : tregister);
       begin
       begin
-         inherited init;
-         typ:=ait_regdealloc;
-         reg:=r;
+        inherited init;
+        typ:=ait_regalloc;
+        allocation:=false;
+        reg:=r;
+      end;
+
+
+    constructor taitempalloc.alloc(pos,size:longint);
+      begin
+        inherited init;
+        typ:=ait_tempalloc;
+        allocation:=true;
+        temppos:=pos;
+        tempsize:=size;
+      end;
+
+
+    constructor taitempalloc.dealloc(pos,size:longint);
+      begin
+        inherited init;
+        typ:=ait_tempalloc;
+        allocation:=false;
+        temppos:=pos;
+        tempsize:=size;
       end;
       end;
 
 
+
 {****************************************************************************
 {****************************************************************************
                              TAI386
                              TAI386
  ****************************************************************************}
  ****************************************************************************}
@@ -2041,7 +2066,11 @@ Begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.40  1999-04-16 10:00:57  pierre
+  Revision 1.41  1999-04-16 11:49:43  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.40  1999/04/16 10:00:57  pierre
     + ifdef USE_OP3 code :
     + ifdef USE_OP3 code :
       added all missing op_... constructors for tai386 needed
       added all missing op_... constructors for tai386 needed
       for SHRD,SHLD and IMUL code in assembler readers
       for SHRD,SHLD and IMUL code in assembler readers

+ 8 - 3
compiler/temp_gen.pas

@@ -27,7 +27,7 @@ unit temp_gen;
     uses
     uses
 {$ifdef i386}
 {$ifdef i386}
 {$ifdef ag386bin}
 {$ifdef ag386bin}
-      i386base,
+      i386base,i386asm,
 {$else}
 {$else}
       i386,
       i386,
 {$endif}
 {$endif}
@@ -236,6 +236,7 @@ unit temp_gen;
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
          tl^.posinfo:=aktfilepos;
          tl^.posinfo:=aktfilepos;
 {$endif}
 {$endif}
+         exprasmlist^.concat(new(paitempalloc,alloc(ofs,size)));
          gettempofsize:=ofs;
          gettempofsize:=ofs;
       end;
       end;
 
 
@@ -424,7 +425,7 @@ unit temp_gen;
            size:=size+(4-(size mod 4));
            size:=size+(4-(size mod 4));
          if size = 0 then
          if size = 0 then
            exit;
            exit;
-
+         exprasmlist^.concat(new(paitempalloc,dealloc(pos,size)));
          if pos<=lastoccupied then
          if pos<=lastoccupied then
            if pos=lastoccupied then
            if pos=lastoccupied then
              begin
              begin
@@ -635,7 +636,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  1999-04-14 09:10:46  peter
+  Revision 1.17  1999-04-16 11:49:45  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.16  1999/04/14 09:10:46  peter
     * fixed tempansi which set wrong pos in free temp
     * fixed tempansi which set wrong pos in free temp
 
 
   Revision 1.15  1999/04/09 13:05:45  pierre
   Revision 1.15  1999/04/09 13:05:45  pierre

+ 11 - 7
compiler/tgeni386.pas

@@ -214,7 +214,7 @@ implementation
               unused:=unused+[r];
               unused:=unused+[r];
               inc(usablereg32);
               inc(usablereg32);
            end;
            end;
-         exprasmlist^.concat(new(pairegdealloc,init(r)));
+         exprasmlist^.concat(new(pairegalloc,dealloc(r)));
       end;
       end;
 
 
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
@@ -287,28 +287,28 @@ implementation
               unused:=unused-[R_EAX];
               unused:=unused-[R_EAX];
               usedinproc:=usedinproc or ($80 shr byte(R_EAX));
               usedinproc:=usedinproc or ($80 shr byte(R_EAX));
               getregister32:=R_EAX;
               getregister32:=R_EAX;
-              exprasmlist^.concat(new(pairegalloc,init(R_EAX)));
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EAX)));
            end
            end
          else if R_EDX in unused then
          else if R_EDX in unused then
            begin
            begin
               unused:=unused-[R_EDX];
               unused:=unused-[R_EDX];
               usedinproc:=usedinproc or ($80 shr byte(R_EDX));
               usedinproc:=usedinproc or ($80 shr byte(R_EDX));
               getregister32:=R_EDX;
               getregister32:=R_EDX;
-              exprasmlist^.concat(new(pairegalloc,init(R_EDX)));
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDX)));
            end
            end
          else if R_EBX in unused then
          else if R_EBX in unused then
            begin
            begin
               unused:=unused-[R_EBX];
               unused:=unused-[R_EBX];
               usedinproc:=usedinproc or ($80 shr byte(R_EBX));
               usedinproc:=usedinproc or ($80 shr byte(R_EBX));
               getregister32:=R_EBX;
               getregister32:=R_EBX;
-              exprasmlist^.concat(new(pairegalloc,init(R_EBX)));
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EBX)));
            end
            end
          else if R_ECX in unused then
          else if R_ECX in unused then
            begin
            begin
               unused:=unused-[R_ECX];
               unused:=unused-[R_ECX];
               usedinproc:=usedinproc or ($80 shr byte(R_ECX));
               usedinproc:=usedinproc or ($80 shr byte(R_ECX));
               getregister32:=R_ECX;
               getregister32:=R_ECX;
-              exprasmlist^.concat(new(pairegalloc,init(R_ECX)));
+              exprasmlist^.concat(new(pairegalloc,alloc(R_ECX)));
            end
            end
          else internalerror(10);
          else internalerror(10);
       end;
       end;
@@ -322,7 +322,7 @@ implementation
               unused:=unused-[r];
               unused:=unused-[r];
               usedinproc:=usedinproc or ($80 shr byte(r));
               usedinproc:=usedinproc or ($80 shr byte(r));
               getexplicitregister32:=R_ECX;
               getexplicitregister32:=R_ECX;
-              exprasmlist^.concat(new(pairegalloc,init(r)));
+              exprasmlist^.concat(new(pairegalloc,alloc(r)));
               getexplicitregister32:=r;
               getexplicitregister32:=r;
            end
            end
          else
          else
@@ -373,7 +373,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  1999-02-25 21:02:55  peter
+  Revision 1.21  1999-04-16 11:49:47  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.20  1999/02/25 21:02:55  peter
     * ag386bin updates
     * ag386bin updates
     + coff writer
     + coff writer