Explorar o código

* set successor properly for for-nodes
+ CalcDefSum

git-svn-id: trunk@11804 -

florian %!s(int64=17) %!d(string=hai) anos
pai
achega
61dbf89bdb
Modificáronse 2 ficheiros con 30 adicións e 0 borrados
  1. 2 0
      compiler/optbase.pas
  2. 28 0
      compiler/optutils.pas

+ 2 - 0
compiler/optbase.pas

@@ -37,9 +37,11 @@ unit optbase;
       toptinfo = record
         { index of the current node inside the dfa sets, aword(-1) if no entry }
         index : aword;
+        { dfa }
         def : tdfaset;
         use : tdfaset;
         life : tdfaset;
+        defsum : tdfaset;
       end;
 
       poptinfo = ^toptinfo;

+ 28 - 0
compiler/optutils.pas

@@ -41,6 +41,11 @@ unit optutils;
     procedure SetNodeSucessors(p : tnode);
     procedure PrintDFAInfo(var f : text;p : tnode);
     procedure PrintIndexedNodeSet(var f : text;s : TIndexedNodeSet);
+    { determines the optinfo.defsum field for the given node
+      this field contains a sum of all expressions defined by
+      all child expressions reachable through p
+    }
+    procedure CalcDefSum(p : tnode);
 
   implementation
 
@@ -189,6 +194,7 @@ unit optutils;
                 DoSet(tfornode(p).t2,p);
                 Breakstack.Delete(Breakstack.Count-1);
                 Continuestack.Delete(Continuestack.Count-1);
+                p.successor:=succ;
               end;
             breakn:
               begin
@@ -295,5 +301,27 @@ unit optutils;
         Breakstack.Free;
       end;
 
+    var
+      sum : TDFASet;
+
+    function adddef(var n: tnode; arg: pointer): foreachnoderesult;
+      begin
+        if assigned(n.optinfo) then
+          DFASetIncludeSet(sum,n.optinfo^.def);
+        Result:=fen_false;
+      end;
+
+
+    procedure CalcDefSum(p : tnode);
+      begin
+        p.allocoptinfo;
+        if not assigned(p.optinfo^.defsum) then
+          begin
+            sum:=nil;
+            foreachnodestatic(pm_postprocess,p,@adddef,nil);
+            p.optinfo^.defsum:=sum;
+          end;
+      end;
+
 end.