Parcourir la source

+ factor out a cdynset unit

florian il y a 6 heures
Parent
commit
a35fe4698b

+ 214 - 0
compiler/cdynset.pas

@@ -0,0 +1,214 @@
+{
+    Dynamic set
+
+    Copyright (c) 2007-2026 by Florian Klaempfl
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit cdynset;
+
+{$i fpcdefs.inc}
+
+  interface
+
+    uses
+      globtype;
+
+    type
+      TDynSet = array of byte;
+      PDynSet = ^TDynSet;
+
+    { add e to s }
+    procedure DynSetInclude(var s : TDynSet;e : integer);
+
+    { add s to d }
+    procedure DynSetIncludeSet(var d : TDynSet;const s : TDynSet);
+
+    { remove s to d }
+    procedure DynSetExcludeSet(var d : TDynSet;const s : TDynSet);
+
+    { remove e from s }
+    procedure DynSetExclude(var s : TDynSet;e : integer);
+
+    { test if s contains e }
+    function DynSetIn(const s : TDynSet;e : integer) : boolean;
+
+    { d:=s1+s2; }
+    procedure DynSetUnion(var d : TDynSet;const s1,s2 : TDynSet);
+
+    { d:=s1*s2; }
+    procedure DynSetIntersect(var d : TDynSet;const s1,s2 : TDynSet);
+
+    { d:=s1-s2; }
+    procedure DynSetDiff(var d : TDynSet;const s1,s2 : TDynSet);
+
+    { s1<>s2; }
+    function DynSetNotEqual(const s1,s2 : TDynSet) : boolean;
+
+    { output DynSet }
+    procedure PrintDynSet(var f : text;s : TDynSet);
+
+  implementation
+
+    uses
+      cutils;
+
+    procedure DynSetInclude(var s : tDynset;e : integer);
+      var
+        e8 : Integer;
+      begin
+        e8:=e div 8;
+        if e8>high(s) then
+          SetLength(s,e8+1);
+        s[e8]:=s[e8] or (1 shl (e mod 8));
+      end;
+
+
+    procedure DynSetIncludeSet(var d : tDynset;const s : tDynset);
+      var
+        i : integer;
+      begin
+        if length(s)>length(d) then
+          SetLength(d,length(s));
+        for i:=0 to high(s) do
+          d[i]:=d[i] or s[i];
+      end;
+
+
+    procedure DynSetExcludeSet(var d : tDynset;const s : tDynset);
+      var
+        i : integer;
+      begin
+        if length(s)>length(d) then
+          SetLength(d,length(s));
+        for i:=0 to high(s) do
+          d[i]:=d[i] and not(s[i]);
+      end;
+
+
+    procedure DynSetExclude(var s : tDynset;e : integer);
+      var
+        e8 : Integer;
+      begin
+        e8:=e div 8;
+        if e8<=high(s) then
+          s[e8]:=s[e8] and not(1 shl (e mod 8));
+      end;
+
+
+    function DynSetIn(const s : tDynset;e : integer) : boolean;
+      var
+        e8 : Integer;
+      begin
+        e8:=e div 8;
+        if e8<=high(s) then
+          result:=(s[e8] and (1 shl (e mod 8)))<>0
+        else
+          result:=false;
+      end;
+
+
+    procedure DynSetUnion(var d : tDynset;const s1,s2 : tDynset);
+      var
+        i : integer;
+      begin
+        SetLength(d,max(Length(s1),Length(s2)));
+        for i:=0 to min(high(s1),high(s2)) do
+          d[i]:=s1[i] or s2[i];
+        if high(s1)<high(s2) then
+          for i:=high(s1)+1 to high(s2) do
+            d[i]:=s2[i]
+        else
+          for i:=high(s2)+1 to high(s1) do
+            d[i]:=s1[i];
+      end;
+
+
+    procedure DynSetIntersect(var d : tDynset;const s1,s2 : tDynset);
+      var
+        i : integer;
+      begin
+        SetLength(d,min(Length(s1),Length(s2)));
+        for i:=0 to high(d) do
+          d[i]:=s1[i] and s2[i];
+      end;
+
+
+    procedure DynSetDiff(var d : tDynset;const s1,s2 : tDynset);
+      var
+        i : integer;
+      begin
+        SetLength(d,length(s1));
+        for i:=0 to high(d) do
+          if i>high(s2) then
+            d[i]:=s1[i]
+          else
+            d[i]:=s1[i] and not(s2[i]);
+      end;
+
+
+    function DynSetNotEqual(const s1,s2 : tDynset) : boolean;
+      var
+        i : integer;
+      begin
+        result:=true;
+        { one set could be larger than the other }
+        if length(s1)>length(s2) then
+          begin
+            for i:=0 to high(s2) do
+              if s1[i]<>s2[i] then
+                exit;
+            { check remaining part being zero }
+            for i:=length(s2) to high(s1) do
+              if s1[i]<>0 then
+                exit;
+          end
+        else
+          begin
+            for i:=0 to high(s1) do
+              if s1[i]<>s2[i] then
+                exit;
+            { check remaining part being zero }
+            for i:=length(s1) to high(s2) do
+              if s2[i]<>0 then
+                exit;
+          end;
+        result:=false;
+      end;
+
+
+    procedure PrintDynSet(var f : text;s : TDynSet);
+      var
+        i : integer;
+        first : boolean;
+      begin
+        first:=true;
+        for i:=0 to Length(s)*8 do
+          begin
+            if DynSetIn(s,i) then
+              begin
+                if not(first) then
+                  write(f,',');
+                write(f,i);
+                first:=false;
+              end;
+          end;
+      end;
+
+
+end.
+

+ 3 - 181
compiler/optbase.pas

@@ -26,13 +26,13 @@ unit optbase;
   interface
 
     uses
-      globtype;
+      globtype,cdynset;
 
     type
       { this should maybe replaced by a spare set,
         using a dyn. array makes assignments cheap }
-      tdfaset = array of byte;
-      PDFASet = ^TDFASet;
+      tdfaset = TDynSet;
+      PDFASet = ^TDynSet;
 
       toptinfo = record
         { index of the current node inside the dfa sets }
@@ -52,184 +52,6 @@ unit optbase;
 
       poptinfo = ^toptinfo;
 
-    { basic set operations for dfa sets }
-
-    { add e to s }
-    procedure DFASetInclude(var s : tdfaset;e : integer);
-
-    { add s to d }
-    procedure DFASetIncludeSet(var d : tdfaset;const s : tdfaset);
-
-    { remove s to d }
-    procedure DFASetExcludeSet(var d : tdfaset;const s : tdfaset);
-
-    { remove e from s }
-    procedure DFASetExclude(var s : tdfaset;e : integer);
-
-    { test if s contains e }
-    function DFASetIn(const s : tdfaset;e : integer) : boolean;
-
-    { d:=s1+s2; }
-    procedure DFASetUnion(var d : tdfaset;const s1,s2 : tdfaset);
-
-    { d:=s1*s2; }
-    procedure DFASetIntersect(var d : tdfaset;const s1,s2 : tdfaset);
-
-    { d:=s1-s2; }
-    procedure DFASetDiff(var d : tdfaset;const s1,s2 : tdfaset);
-
-    { s1<>s2; }
-    function DFASetNotEqual(const s1,s2 : tdfaset) : boolean;
-
-    { output DFA set }
-    procedure PrintDFASet(var f : text;s : TDFASet);
-
   implementation
 
-    uses
-      cutils;
-
-    procedure DFASetInclude(var s : tdfaset;e : integer);
-      var
-        e8 : Integer;
-      begin
-        e8:=e div 8;
-        if e8>high(s) then
-          SetLength(s,e8+1);
-        s[e8]:=s[e8] or (1 shl (e mod 8));
-      end;
-
-
-    procedure DFASetIncludeSet(var d : tdfaset;const s : tdfaset);
-      var
-        i : integer;
-      begin
-        if length(s)>length(d) then
-          SetLength(d,length(s));
-        for i:=0 to high(s) do
-          d[i]:=d[i] or s[i];
-      end;
-
-
-    procedure DFASetExcludeSet(var d : tdfaset;const s : tdfaset);
-      var
-        i : integer;
-      begin
-        if length(s)>length(d) then
-          SetLength(d,length(s));
-        for i:=0 to high(s) do
-          d[i]:=d[i] and not(s[i]);
-      end;
-
-
-    procedure DFASetExclude(var s : tdfaset;e : integer);
-      var
-        e8 : Integer;
-      begin
-        e8:=e div 8;
-        if e8<=high(s) then
-          s[e8]:=s[e8] and not(1 shl (e mod 8));
-      end;
-
-
-    function DFASetIn(const s : tdfaset;e : integer) : boolean;
-      var
-        e8 : Integer;
-      begin
-        e8:=e div 8;
-        if e8<=high(s) then
-          result:=(s[e8] and (1 shl (e mod 8)))<>0
-        else
-          result:=false;
-      end;
-
-
-    procedure DFASetUnion(var d : tdfaset;const s1,s2 : tdfaset);
-      var
-        i : integer;
-      begin
-        SetLength(d,max(Length(s1),Length(s2)));
-        for i:=0 to min(high(s1),high(s2)) do
-          d[i]:=s1[i] or s2[i];
-        if high(s1)<high(s2) then
-          for i:=high(s1)+1 to high(s2) do
-            d[i]:=s2[i]
-        else
-          for i:=high(s2)+1 to high(s1) do
-            d[i]:=s1[i];
-      end;
-
-
-    procedure DFASetIntersect(var d : tdfaset;const s1,s2 : tdfaset);
-      var
-        i : integer;
-      begin
-        SetLength(d,min(Length(s1),Length(s2)));
-        for i:=0 to high(d) do
-          d[i]:=s1[i] and s2[i];
-      end;
-
-
-    procedure DFASetDiff(var d : tdfaset;const s1,s2 : tdfaset);
-      var
-        i : integer;
-      begin
-        SetLength(d,length(s1));
-        for i:=0 to high(d) do
-          if i>high(s2) then
-            d[i]:=s1[i]
-          else
-            d[i]:=s1[i] and not(s2[i]);
-      end;
-
-
-    function DFASetNotEqual(const s1,s2 : tdfaset) : boolean;
-      var
-        i : integer;
-      begin
-        result:=true;
-        { one set could be larger than the other }
-        if length(s1)>length(s2) then
-          begin
-            for i:=0 to high(s2) do
-              if s1[i]<>s2[i] then
-                exit;
-            { check remaining part being zero }
-            for i:=length(s2) to high(s1) do
-              if s1[i]<>0 then
-                exit;
-          end
-        else
-          begin
-            for i:=0 to high(s1) do
-              if s1[i]<>s2[i] then
-                exit;
-            { check remaining part being zero }
-            for i:=length(s1) to high(s2) do
-              if s2[i]<>0 then
-                exit;
-          end;
-        result:=false;
-      end;
-
-
-    procedure PrintDFASet(var f : text;s : TDFASet);
-      var
-        i : integer;
-        first : boolean;
-      begin
-        first:=true;
-        for i:=0 to Length(s)*8 do
-          begin
-            if DFASetIn(s,i) then
-              begin
-                if not(first) then
-                  write(f,',');
-                write(f,i);
-                first:=false;
-              end;
-          end;
-      end;
-
-
 end.

+ 2 - 2
compiler/optconstprop.pas

@@ -55,7 +55,7 @@ unit optconstprop;
   implementation
 
     uses
-      globtype, globals,
+      globtype,cdynset,globals,
       pass_1,procinfo,compinnr,
       symsym, symconst,
       nutils, nbas, ncnv, nld, nflw, ncal, ninl,
@@ -146,7 +146,7 @@ unit optconstprop;
                     { if it is a temprefn or its address is not taken in case of loadn }
                       ((tassignmentnode(arg).left.nodetype=temprefn) or not(tabstractvarsym(tloadnode(tassignmentnode(arg).left).symtableentry).addr_taken)) and
                       { and no definition in the loop? }
-                      not(DFASetIn(tfornode(n).t2.optinfo^.defsum,tassignmentnode(arg).left.optinfo^.index)) then
+                      not(DynSetIn(tfornode(n).t2.optinfo^.defsum,tassignmentnode(arg).left.optinfo^.index)) then
                       begin
                         result:=replaceBasicAssign(tfornode(n).t2, arg, tree_modified3);
                         tree_modified:=tree_modified or tree_modified3;

+ 4 - 4
compiler/optcse.pas

@@ -47,7 +47,7 @@ unit optcse;
   implementation
 
     uses
-      globtype,globals,
+      globtype,cdynset,globals,
       systems,
       cutils,cclasses,
       nutils,compinnr,
@@ -252,11 +252,11 @@ unit optcse;
             plists(arg)^.refs.Add(nil);
             plists(arg)^.equalto.Add(pointer(-1));
 
-            DFASetInclude(plists(arg)^.avail,plists(arg)^.nodelist.count-1);
+            DynSetInclude(plists(arg)^.avail,plists(arg)^.nodelist.count-1);
 
             for i:=0 to plists(arg)^.nodelist.count-2 do
               begin
-                if tnode(plists(arg)^.nodelist[i]).isequal(n) and DFASetIn(plists(arg)^.avail,i) then
+                if tnode(plists(arg)^.nodelist[i]).isequal(n) and DynSetIn(plists(arg)^.avail,i) then
                   begin
                     { use always the first occurrence }
                     if plists(arg)^.equalto[i]<>pointer(-1) then
@@ -282,7 +282,7 @@ unit optcse;
             firstleftend:=high(longint);
             recurseintobooleanchain(n.nodetype,n);
             for i:=firstleftend to plists(arg)^.nodelist.count-1 do
-              DFASetExclude(plists(arg)^.avail,i);
+              DynSetExclude(plists(arg)^.avail,i);
             result:=fen_norecurse_false;
           end;
 {$ifdef cpuhighleveltarget}

+ 2 - 2
compiler/optdeadstore.pas

@@ -36,7 +36,7 @@ unit optdeadstore;
   implementation
 
     uses
-      verbose,globtype,globals,
+      verbose,globtype,cdynset,globals,
       procinfo,pass_1,
       nutils,
       nbas,nld,
@@ -81,7 +81,7 @@ unit optdeadstore;
                     ((cs_opt_dead_values in current_settings.optimizerswitches) and not(might_have_sideeffects(a.right,[mhs_exceptions])))
                    ) then
                   begin
-                    redundant:=not(assigned(a.successor)) or not(DFASetIn(a.successor.optinfo^.life,a.left.optinfo^.index));
+                    redundant:=not(assigned(a.successor)) or not(DynSetIn(a.successor.optinfo^.life,a.left.optinfo^.index));
 
                     if redundant then
                       begin

+ 41 - 41
compiler/optdfa.pas

@@ -54,7 +54,7 @@ unit optdfa;
   implementation
 
     uses
-      globtype,
+      globtype,cdynset,
       systems,
       constexp,
       verbose,
@@ -122,7 +122,7 @@ unit optdfa;
               if assigned(ttempcreatenode(n).tempinfo^.tempinitcode) then
                 begin
                   pdfainfo(arg)^.map.Add(n);
-                  DFASetInclude(pdfainfo(arg)^.def^,n.optinfo^.index);
+                  DynSetInclude(pdfainfo(arg)^.def^,n.optinfo^.index);
                 end;
             end;
           temprefn,
@@ -131,13 +131,13 @@ unit optdfa;
               pdfainfo(arg)^.map.Add(n);
               if nf_modify in n.flags then
                 begin
-                  DFASetInclude(pdfainfo(arg)^.use^,n.optinfo^.index);
-                  DFASetInclude(pdfainfo(arg)^.def^,n.optinfo^.index)
+                  DynSetInclude(pdfainfo(arg)^.use^,n.optinfo^.index);
+                  DynSetInclude(pdfainfo(arg)^.def^,n.optinfo^.index)
                 end
               else if nf_write in n.flags then
-                DFASetInclude(pdfainfo(arg)^.def^,n.optinfo^.index)
+                DynSetInclude(pdfainfo(arg)^.def^,n.optinfo^.index)
               else
-                DFASetInclude(pdfainfo(arg)^.use^,n.optinfo^.index);
+                DynSetInclude(pdfainfo(arg)^.use^,n.optinfo^.index);
             end;
           else
             ;
@@ -189,14 +189,14 @@ unit optdfa;
         }
         procedure updatelifeinfo(n : tnode;const l : TDFASet);
           begin
-            if not DFASetNotEqual(l,n.optinfo^.life) then
+            if not DynSetNotEqual(l,n.optinfo^.life) then
               exit;
 {$ifdef DEBUG_DFA}
             if not(changed) then
               begin
                 writeln('Another DFA pass caused by: ',nodetype2str[n.nodetype],'(',n.fileinfo.line,',',n.fileinfo.column,')');
-                write('  Life info set was:     ');PrintDFASet(Output,n.optinfo^.life);writeln;
-                write('  Life info set will be: ');PrintDFASet(Output,l);writeln;
+                write('  Life info set was:     ');PrintDynSet(Output,n.optinfo^.life);writeln;
+                write('  Life info set will be: ');PrintDynSet(Output,l);writeln;
               end;
 {$endif DEBUG_DFA}
 
@@ -211,14 +211,14 @@ unit optdfa;
             if assigned(n.successor) then
               begin
                 { ensure we can access optinfo }
-                DFASetDiff(l,n.successor.optinfo^.life,n.optinfo^.def);
-                DFASetIncludeSet(l,n.optinfo^.use);
-                DFASetIncludeSet(l,n.optinfo^.life);
+                DynSetDiff(l,n.successor.optinfo^.life,n.optinfo^.def);
+                DynSetIncludeSet(l,n.optinfo^.use);
+                DynSetIncludeSet(l,n.optinfo^.life);
               end
             else
               begin
                 l:=n.optinfo^.use;
-                DFASetIncludeSet(l,n.optinfo^.life);
+                DynSetIncludeSet(l,n.optinfo^.life);
               end;
             updatelifeinfo(n,l);
           end;
@@ -264,17 +264,17 @@ unit optdfa;
 
                 { NB: this node should typically have empty def set }
                 if assigned(node.successor) then
-                  DFASetDiff(l,node.successor.optinfo^.life,node.optinfo^.def)
+                  DynSetDiff(l,node.successor.optinfo^.life,node.optinfo^.def)
                 else if assigned(resultnode) then
-                  DFASetDiff(l,resultnode.optinfo^.life,node.optinfo^.def)
+                  DynSetDiff(l,resultnode.optinfo^.life,node.optinfo^.def)
                 else
                   l:=nil;
 
                 { for repeat..until, node use set in included at the end of loop }
                 if not (lnf_testatbegin in twhilerepeatnode(node).loopflags) then
-                  DFASetIncludeSet(l,node.optinfo^.use);
+                  DynSetIncludeSet(l,node.optinfo^.use);
 
-                DFASetIncludeSet(l,node.optinfo^.life);
+                DynSetIncludeSet(l,node.optinfo^.life);
 
                 save:=node.optinfo^.life;
                 { to process body correctly, we need life info in place (because
@@ -291,10 +291,10 @@ unit optdfa;
                 l:=twhilerepeatnode(node).right.optinfo^.life;
                 if lnf_testatbegin in twhilerepeatnode(node).loopflags then
                   begin
-                    DFASetIncludeSet(l,node.optinfo^.use);
+                    DynSetIncludeSet(l,node.optinfo^.use);
                     { ... loop body could be skipped, so include life info of the successor node }
                     if assigned(node.successor) then
-                      DFASetIncludeSet(l,node.successor.optinfo^.life);
+                      DynSetIncludeSet(l,node.successor.optinfo^.life);
                   end;
 
                 UpdateLifeInfo(node,l);
@@ -333,7 +333,7 @@ unit optdfa;
                   optinfo might not be assigned
                 }
                 counteruse_after_loop:=assigned(tfornode(node).left.optinfo) and assigned(node.successor) and
-                  DFASetIn(node.successor.optinfo^.life,tfornode(node).left.optinfo^.index);
+                  DynSetIn(node.successor.optinfo^.life,tfornode(node).left.optinfo^.index);
 
                 if counteruse_after_loop then
                   begin
@@ -350,7 +350,7 @@ unit optdfa;
 
                 { take care of the successor }
                 if assigned(node.successor) then
-                  DFASetIncludeSet(l,node.successor.optinfo^.life);
+                  DynSetIncludeSet(l,node.successor.optinfo^.life);
 
                 { the counter variable is living as well inside the for loop
 
@@ -358,7 +358,7 @@ unit optdfa;
                   optinfo might not be assigned
                 }
                 if assigned(tfornode(node).left.optinfo) then
-                  DFASetInclude(l,tfornode(node).left.optinfo^.index);
+                  DynSetInclude(l,tfornode(node).left.optinfo^.index);
 
                 { force block node life info }
                 UpdateLifeInfo(tfornode(node).loopiteration,l);
@@ -371,7 +371,7 @@ unit optdfa;
                 { take care of the successor as it's possible that we don't have one execution of the body }
                 if (not(tfornode(node).right.nodetype=ordconstn) or not(tfornode(node).t1.nodetype=ordconstn)) and
                   assigned(node.successor) then
-                  DFASetIncludeSet(l,node.successor.optinfo^.life);
+                  DynSetIncludeSet(l,node.successor.optinfo^.life);
 
                 {
                   the counter variable is not living at the entry of the for node
@@ -380,11 +380,11 @@ unit optdfa;
                     optinfo might not be assigned
                 }
                 if assigned(tfornode(node).left.optinfo) then
-                  DFASetExclude(l,tfornode(node).left.optinfo^.index);
+                  DynSetExclude(l,tfornode(node).left.optinfo^.index);
 
                 { ... but it could be that left/right use it, so do this after
                   removing the def of the counter variable }
-                DFASetIncludeSet(l,node.optinfo^.use);
+                DynSetIncludeSet(l,node.optinfo^.use);
 
                 UpdateLifeInfo(node,l);
 
@@ -423,7 +423,7 @@ unit optdfa;
                 { ensure that we don't remove life info }
                 l:=node.optinfo^.life;
                 if assigned(node.successor) then
-                  DFASetIncludeSet(l,node.successor.optinfo^.life);
+                  DynSetIncludeSet(l,node.successor.optinfo^.life);
                 UpdateLifeInfo(node,l);
               end;
 
@@ -448,21 +448,21 @@ unit optdfa;
 
                 { get life info from then branch }
                 if assigned(tifnode(node).right) then
-                  DFASetIncludeSet(l,tifnode(node).right.optinfo^.life)
+                  DynSetIncludeSet(l,tifnode(node).right.optinfo^.life)
                 else if assigned(node.successor) then
-                  DFASetIncludeSet(l,node.successor.optinfo^.life);
+                  DynSetIncludeSet(l,node.successor.optinfo^.life);
 
                 { get life info from else branch }
                 if assigned(tifnode(node).t1) then
-                  DFASetIncludeSet(l,tifnode(node).t1.optinfo^.life)
+                  DynSetIncludeSet(l,tifnode(node).t1.optinfo^.life)
                 else if assigned(node.successor) then
-                  DFASetIncludeSet(l,node.successor.optinfo^.life);
+                  DynSetIncludeSet(l,node.successor.optinfo^.life);
 
                 { remove def info from the cond. expression }
-                DFASetExcludeSet(l,tifnode(node).optinfo^.def);
+                DynSetExcludeSet(l,tifnode(node).optinfo^.def);
 
                 { add use info from the cond. expression }
-                DFASetIncludeSet(l,tifnode(node).optinfo^.use);
+                DynSetIncludeSet(l,tifnode(node).optinfo^.use);
 
                 { finally, update the life info of the node }
                 UpdateLifeInfo(node,l);
@@ -491,25 +491,25 @@ unit optdfa;
 
                 { get life info from case branches }
                 for i:=0 to tcasenode(node).blocks.count-1 do
-                  DFASetIncludeSet(l,pcaseblock(tcasenode(node).blocks[i])^.statement.optinfo^.life);
+                  DynSetIncludeSet(l,pcaseblock(tcasenode(node).blocks[i])^.statement.optinfo^.life);
 
                 { get life info from else branch or the successor }
                 if assigned(tcasenode(node).elseblock) then
-                  DFASetIncludeSet(l,tcasenode(node).elseblock.optinfo^.life)
+                  DynSetIncludeSet(l,tcasenode(node).elseblock.optinfo^.life)
                 else if assigned(node.successor) then
                   begin
                     if is_ordinal(tcasenode(node).left.resultdef) then
                       begin
                         getrange(tcasenode(node).left.resultdef,lv,hv);
                         if tcasenode(node).labelcoverage<(hv-lv) then
-                          DFASetIncludeSet(l,node.successor.optinfo^.life);
+                          DynSetIncludeSet(l,node.successor.optinfo^.life);
                       end
                     else
-                      DFASetIncludeSet(l,node.successor.optinfo^.life);
+                      DynSetIncludeSet(l,node.successor.optinfo^.life);
                   end;
 
                 { add use info from the "case" expression }
-                DFASetIncludeSet(l,tcasenode(node).optinfo^.use);
+                DynSetIncludeSet(l,tcasenode(node).optinfo^.use);
 
                 { finally, update the life info of the node }
                 UpdateLifeInfo(node,l);
@@ -522,7 +522,7 @@ unit optdfa;
                 if assigned(node.successor) then
                   begin
                     l:=node.optinfo^.life;
-                    DFASetIncludeSet(l,node.successor.optinfo^.life);
+                    DynSetIncludeSet(l,node.successor.optinfo^.life);
                     UpdateLifeInfo(node,l);
                   end
                 else if assigned(resultnode) and (resultnode.nodetype<>nothingn) then
@@ -891,14 +891,14 @@ unit optdfa;
             exit;
           include(node.transientflags,tnf_processing);
 
-          if not(assigned(node.optinfo)) or not(DFASetIn(node.optinfo^.life,nodetosearch.optinfo^.index)) then
+          if not(assigned(node.optinfo)) or not(DynSetIn(node.optinfo^.life,nodetosearch.optinfo^.index)) then
             exit;
 
           { we do not need this info always, so try to safe some time here, CheckAndWarn
             takes a lot of time anyways }
           if not(node.nodetype in [statementn,blockn]) then
-            touchesnode:=DFASetIn(node.optinfo^.use,nodetosearch.optinfo^.index) or
-              DFASetIn(node.optinfo^.def,nodetosearch.optinfo^.index)
+            touchesnode:=DynSetIn(node.optinfo^.use,nodetosearch.optinfo^.index) or
+              DynSetIn(node.optinfo^.def,nodetosearch.optinfo^.index)
           else
             touchesnode:=false;
 

+ 4 - 4
compiler/optloop.pas

@@ -38,7 +38,7 @@ unit optloop;
   implementation
 
     uses
-      cutils,cclasses,compinnr,
+      cutils,cclasses,compinnr,cdynset,
       globtype,globals,constexp,
       verbose,
       symdef,symsym,
@@ -283,7 +283,7 @@ unit optloop;
                 { no aliasing? }
                 result:=(([nf_write,nf_modify]*expr.flags)=[]) and not(tabstractvarsym(tloadnode(expr).symtableentry).addr_taken) and
                 { no definition in the loop? }
-                  not(DFASetIn(tfornode(loop).t2.optinfo^.defsum,expr.optinfo^.index));
+                  not(DynSetIn(tfornode(loop).t2.optinfo^.defsum,expr.optinfo^.index));
             end;
           vecn:
             begin
@@ -670,8 +670,8 @@ unit optloop;
               Internalerror(2017122801);
             if not(assigned(tfornode(n).left.optinfo)) then
               exit;
-            if not(DFASetIn(tfornode(n).t2.optinfo^.usesum,tfornode(n).left.optinfo^.index)) and
-              not(DFASetIn(tfornode(n).t2.optinfo^.defsum,tfornode(n).left.optinfo^.index))  then
+            if not(DynSetIn(tfornode(n).t2.optinfo^.usesum,tfornode(n).left.optinfo^.index)) and
+              not(DynSetIn(tfornode(n).t2.optinfo^.defsum,tfornode(n).left.optinfo^.index))  then
               begin
                 { convert the loop from i:=a to b into i:=b-a+1 to 1 as this simplifies the
                   abort condition }

+ 8 - 8
compiler/optutils.pas

@@ -64,7 +64,7 @@ unit optutils;
   implementation
 
     uses
-      cutils,
+      cutils,cdynset,
       verbose,
       optbase,
       ncal,nbas,nflw,nutils,nset,ncon;
@@ -136,17 +136,17 @@ unit optutils;
         if assigned(n.optinfo) and ((n.optinfo^.life<>nil) or (n.optinfo^.use<>nil) or (n.optinfo^.def<>nil)) then
           begin
             write(text(arg^),nodetype2str[n.nodetype],'(',n.fileinfo.line,',',n.fileinfo.column,') Life: ');
-            PrintDFASet(text(arg^),n.optinfo^.life);
+            PrintDynSet(text(arg^),n.optinfo^.life);
             write(text(arg^),' Def: ');
-            PrintDFASet(text(arg^),n.optinfo^.def);
+            PrintDynSet(text(arg^),n.optinfo^.def);
             write(text(arg^),' Use: ');
-            PrintDFASet(text(arg^),n.optinfo^.use);
+            PrintDynSet(text(arg^),n.optinfo^.use);
             if assigned(n.successor) then
               write(text(arg^),' Successor: ',nodetype2str[n.successor.nodetype],'(',n.successor.fileinfo.line,',',n.successor.fileinfo.column,')')
             else
               write(text(arg^),' Successor: nil');
             write(text(arg^),' DefSum: ');
-            PrintDFASet(text(arg^),n.optinfo^.defsum);
+            PrintDynSet(text(arg^),n.optinfo^.defsum);
             writeln(text(arg^));
           end;
         result:=fen_false;
@@ -403,12 +403,12 @@ unit optutils;
       begin
         if assigned(n.optinfo) then
           begin
-            DFASetIncludeSet(defsum^,n.optinfo^.def);
+            DynSetIncludeSet(defsum^,n.optinfo^.def);
             { for nodes itself do not necessarily expose the definition of the counter as
               the counter might be undefined after the for loop, so include here the counter
               explicitly }
             if (n.nodetype=forn) and assigned(tfornode(n).left.optinfo) then
-              DFASetInclude(defsum^,tfornode(n).left.optinfo^.index);
+              DynSetInclude(defsum^,tfornode(n).left.optinfo^.index);
           end;
         Result:=fen_false;
       end;
@@ -476,7 +476,7 @@ unit optutils;
         usesum : PDFASet absolute arg;
       begin
         if assigned(n.optinfo) then
-          DFASetIncludeSet(usesum^,n.optinfo^.use);
+          DynSetIncludeSet(usesum^,n.optinfo^.use);
         Result:=fen_false;
       end;
 

+ 2 - 2
compiler/psub.pas

@@ -128,7 +128,7 @@ implementation
     uses
        sysutils,
        { common }
-       cutils, cmsgs,
+       cutils, cmsgs, cdynset,
        { global }
        globtype,tokens,verbose,comphook,constexp,
        systems,cpubase,aasmbase,aasmtai,
@@ -1242,7 +1242,7 @@ implementation
              for i:=0 to dfabuilder.nodemap.count-1 do
                begin
                  UserCode:=GetUserCode();
-                 if DFASetIn(UserCode.optinfo^.life,i) then
+                 if DynSetIn(UserCode.optinfo^.life,i) then
                    begin
                      { do not warn for certain parameters: }
                      if not((tnode(dfabuilder.nodemap[i]).nodetype=loadn) and (tloadnode(dfabuilder.nodemap[i]).symtableentry.typ=paravarsym) and