Browse Source

* ag386bin doesn't destroy the aasmoutput lists anymore

peter 26 years ago
parent
commit
176f1d4cd8
2 changed files with 153 additions and 52 deletions
  1. 9 2
      compiler/aasm.pas
  2. 144 50
      compiler/ag386bin.pas

+ 9 - 2
compiler/aasm.pas

@@ -271,6 +271,10 @@ type
          function getlasttaifilepos : pfileposinfo;
          function getlasttaifilepos : pfileposinfo;
        end;
        end;
 
 
+    const
+    { maximum of aasmoutput lists there will be }
+      maxoutputlists = 10;
+
     var
     var
     { temporary lists }
     { temporary lists }
       exprasmlist,
       exprasmlist,
@@ -279,7 +283,7 @@ type
       debuglist,consts,
       debuglist,consts,
       importssection,exportssection,
       importssection,exportssection,
       resourcesection,rttilist         : paasmoutput;
       resourcesection,rttilist         : paasmoutput;
-  { asm symbol list }
+    { asm symbol list }
       asmsymbollist : pasmsymbollist;
       asmsymbollist : pasmsymbollist;
 
 
     const
     const
@@ -896,7 +900,10 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.51  1999-06-02 22:43:57  pierre
+  Revision 1.52  1999-07-03 00:26:01  peter
+    * ag386bin doesn't destroy the aasmoutput lists anymore
+
+  Revision 1.51  1999/06/02 22:43:57  pierre
    * previous wrong log corrected
    * previous wrong log corrected
 
 
   Revision 1.50  1999/06/02 22:25:24  pierre
   Revision 1.50  1999/06/02 22:25:24  pierre

+ 144 - 50
compiler/ag386bin.pas

@@ -39,11 +39,18 @@ unit ag386bin;
 
 
       pi386binasmlist=^ti386binasmlist;
       pi386binasmlist=^ti386binasmlist;
       ti386binasmlist=object
       ti386binasmlist=object
-        constructor init(t:togtype);
+        SmartAsm : boolean;
+        constructor init(t:togtype;smart:boolean);
         destructor  done;
         destructor  done;
         procedure WriteBin;
         procedure WriteBin;
       private
       private
-        currpass : byte;
+        { the aasmoutput lists that need to be processed }
+        lists        : byte;
+        list         : array[1..maxoutputlists] of paasmoutput;
+        { current processing }
+        currlistidx  : byte;
+        currlist     : paasmoutput;
+        currpass     : byte;
 {$ifdef GDB}
 {$ifdef GDB}
         n_line       : byte;     { different types of source lines }
         n_line       : byte;     { different types of source lines }
         linecount,
         linecount,
@@ -62,7 +69,8 @@ unit ag386bin;
         function  TreePass0(hp:pai):pai;
         function  TreePass0(hp:pai):pai;
         function  TreePass1(hp:pai):pai;
         function  TreePass1(hp:pai):pai;
         function  TreePass2(hp:pai):pai;
         function  TreePass2(hp:pai):pai;
-        procedure writetree(p:paasmoutput);
+        procedure writetree;
+        procedure writetreesmart;
       end;
       end;
 
 
   implementation
   implementation
@@ -401,12 +409,25 @@ unit ag386bin;
              ait_instruction :
              ait_instruction :
                objectalloc^.sectionalloc(pai386(hp)^.Pass1(objectalloc^.sectionsize));
                objectalloc^.sectionalloc(pai386(hp)^.Pass1(objectalloc^.sectionsize));
              ait_cut :
              ait_cut :
-               begin
-                 objectalloc^.resetsections;
-                 objectalloc^.setsection(lastsec);
-               end;
+               if SmartAsm then
+                begin
+                  objectalloc^.resetsections;
+                  objectalloc^.setsection(lastsec);
+                end;
            end;
            end;
            hp:=pai(hp^.next);
            hp:=pai(hp^.next);
+
+         { maybe end of list }
+           if not assigned(hp) then
+            begin
+              if currlistidx<lists then
+               begin
+                 inc(currlistidx);
+                 currlist:=list[currlistidx];
+                 hp:=pai(currlist^.first);
+               end;
+            end;
+
          end;
          end;
         TreePass0:=hp;
         TreePass0:=hp;
       end;
       end;
@@ -545,7 +566,8 @@ unit ag386bin;
              ait_direct :
              ait_direct :
                Message(asmw_f_direct_not_supported);
                Message(asmw_f_direct_not_supported);
              ait_cut :
              ait_cut :
-               break;
+               if SmartAsm then
+                break;
            end;
            end;
            hp:=pai(hp^.next);
            hp:=pai(hp^.next);
          end;
          end;
@@ -676,7 +698,8 @@ unit ag386bin;
                stabslastfileinfo.line:=0;
                stabslastfileinfo.line:=0;
 {$endif}
 {$endif}
              ait_cut :
              ait_cut :
-               break;
+               if SmartAsm then
+                break;
            end;
            end;
            hp:=pai(hp^.next);
            hp:=pai(hp^.next);
          end;
          end;
@@ -684,15 +707,79 @@ unit ag386bin;
       end;
       end;
 
 
 
 
-    procedure ti386binasmlist.writetree(p:paasmoutput);
+    procedure ti386binasmlist.writetree;
+      var
+        hp : pai;
+      begin
+        objectalloc^.setsection(sec_code);
+        objectoutput^.defaultsection(sec_code);
+
+        { Pass 1 }
+        currpass:=1;
+{$ifdef GDB}
+        StartFileLineInfo;
+{$endif GDB}
+        { start with list 1 }
+        currlistidx:=1;
+        currlist:=list[currlistidx];
+        hp:=pai(currlist^.first);
+        while assigned(hp) do
+         begin
+           hp:=TreePass1(hp);
+         { maybe end of list }
+           if not assigned(hp) then
+            begin
+              if currlistidx<lists then
+               begin
+                 inc(currlistidx);
+                 currlist:=list[currlistidx];
+                 hp:=pai(currlist^.first);
+               end
+              else
+               break;
+            end;
+          end;
+        { set section sizes }
+        objectoutput^.setsectionsizes(objectalloc^.secsize);
+
+      { Pass 2 }
+        currpass:=2;
+{$ifdef GDB}
+        StartFileLineInfo;
+{$endif GDB}
+        { start with list 1 }
+        currlistidx:=1;
+        currlist:=list[currlistidx];
+        hp:=pai(currlist^.first);
+        while assigned(hp) do
+         begin
+           hp:=TreePass2(hp);
+         { maybe end of list }
+           if not assigned(hp) then
+            begin
+              if currlistidx<lists then
+               begin
+                 inc(currlistidx);
+                 currlist:=list[currlistidx];
+                 hp:=pai(currlist^.first);
+               end
+              else
+               break;
+            end;
+          end;
+      end;
+
+
+    procedure ti386binasmlist.writetreesmart;
       var
       var
         hp,hp1 : pai;
         hp,hp1 : pai;
       begin
       begin
-        if not assigned(p) then
-         exit;
         objectalloc^.setsection(sec_code);
         objectalloc^.setsection(sec_code);
         objectoutput^.defaultsection(sec_code);
         objectoutput^.defaultsection(sec_code);
-        hp:=pai(p^.first);
+        { start with list 1 }
+        currlistidx:=1;
+        currlist:=list[currlistidx];
+        hp:=pai(currlist^.first);
         while assigned(hp) do
         while assigned(hp) do
          begin
          begin
          { Pass 1 }
          { Pass 1 }
@@ -709,46 +796,50 @@ unit ag386bin;
 {$ifdef GDB}
 {$ifdef GDB}
            StartFileLineInfo;
            StartFileLineInfo;
 {$endif GDB}
 {$endif GDB}
-           hp1:=TreePass2(hp);
+           hp:=TreePass2(hp);
 
 
-         { if assigned then we have a ait_cut }
-           hp:=hp1;
-           if assigned(hp) then
+         { maybe end of list }
+           if not assigned(hp) then
             begin
             begin
-              if hp^.typ<>ait_cut then
-               internalerror(3334443);
-              { write the current objectfile }
-              objectoutput^.donewriting;
-              { start the writing again }
-              objectoutput^.initwriting;
-              { we will start a new objectfile so reset everything }
-              ResetAsmsymbolList;
-              objectalloc^.resetsections;
-              { avoid empty files }
-              while assigned(hp^.next) and
-                    (pai(hp^.next)^.typ in [ait_marker,ait_comment,ait_section,ait_cut]) do
+              if currlistidx<lists then
                begin
                begin
-                 if pai(hp^.next)^.typ=ait_section then
-                   begin
-                     objectalloc^.setsection(pai_section(hp^.next)^.sec);
-                     objectoutput^.defaultsection(pai_section(hp^.next)^.sec);
-                   end;
-                 hp:=pai(hp^.next);
-               end;
+                 inc(currlistidx);
+                 currlist:=list[currlistidx];
+                 hp:=pai(currlist^.first);
+               end
+              else
+               break;
+            end;
+
+           { write the current objectfile }
+           objectoutput^.donewriting;
+           { start the writing again }
+           objectoutput^.initwriting;
+           { we will start a new objectfile so reset everything }
+           ResetAsmsymbolList;
+           objectalloc^.resetsections;
+           { avoid empty files }
+           while assigned(hp^.next) and
+                 (pai(hp^.next)^.typ in [ait_marker,ait_comment,ait_section,ait_cut]) do
+            begin
+              if pai(hp^.next)^.typ=ait_section then
+                begin
+                  objectalloc^.setsection(pai_section(hp^.next)^.sec);
+                  objectoutput^.defaultsection(pai_section(hp^.next)^.sec);
+                end;
               hp:=pai(hp^.next);
               hp:=pai(hp^.next);
             end;
             end;
+           hp:=pai(hp^.next);
          end;
          end;
       end;
       end;
 
 
 
 
     procedure ti386binasmlist.writebin;
     procedure ti386binasmlist.writebin;
-      var
-        mylist : paasmoutput;
 
 
         procedure addlist(p:paasmoutput);
         procedure addlist(p:paasmoutput);
         begin
         begin
-          mylist^.concat(new(pai_section,init(sec_code)));
-          mylist^.concatlist(p);
+          inc(lists);
+          list[lists]:=p;
         end;
         end;
 
 
       begin
       begin
@@ -765,8 +856,6 @@ unit ag386bin;
         objectoutput^.initwriting;
         objectoutput^.initwriting;
         objectoutput^.defaultsection(sec_code);
         objectoutput^.defaultsection(sec_code);
 
 
-        new(mylist,init);
-
         if cs_debuginfo in aktmoduleswitches then
         if cs_debuginfo in aktmoduleswitches then
           addlist(debuglist);
           addlist(debuglist);
         addlist(codesegment);
         addlist(codesegment);
@@ -781,27 +870,29 @@ unit ag386bin;
         if assigned(resourcesection) then
         if assigned(resourcesection) then
           addlist(resourcesection);
           addlist(resourcesection);
 
 
-        WriteTree(mylist);
-
-        dispose(mylist,done);
+        if SmartAsm then
+          writetreesmart
+        else
+          writetree;
 
 
         objectoutput^.donewriting;
         objectoutput^.donewriting;
       end;
       end;
 
 
 
 
-    constructor ti386binasmlist.init(t:togtype);
+    constructor ti386binasmlist.init(t:togtype;smart:boolean);
       begin
       begin
         case t of
         case t of
           og_none :
           og_none :
             Message(asmw_f_no_binary_writer_selected);
             Message(asmw_f_no_binary_writer_selected);
           og_dbg :
           og_dbg :
-            objectoutput:=new(pdbgoutput,init);
+            objectoutput:=new(pdbgoutput,init(smart));
           og_coff :
           og_coff :
-            objectoutput:=new(pdjgppcoffoutput,init);
+            objectoutput:=new(pdjgppcoffoutput,init(smart));
           og_pecoff :
           og_pecoff :
-            objectoutput:=new(pwin32coffoutput,init);
+            objectoutput:=new(pwin32coffoutput,init(smart));
         end;
         end;
         objectalloc:=new(pobjectalloc,init);
         objectalloc:=new(pobjectalloc,init);
+        SmartAsm:=smart;
         currpass:=0;
         currpass:=0;
       end;
       end;
 
 
@@ -815,7 +906,10 @@ unit ag386bin;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.17  1999-06-10 23:52:34  pierre
+  Revision 1.18  1999-07-03 00:26:02  peter
+    * ag386bin doesn't destroy the aasmoutput lists anymore
+
+  Revision 1.17  1999/06/10 23:52:34  pierre
    * merged from fixes branch
    * merged from fixes branch
 
 
   Revision 1.16.2.1  1999/06/10 23:33:35  pierre
   Revision 1.16.2.1  1999/06/10 23:33:35  pierre