Explorar el Código

* improved cse
* better complexity calculation for subscript nodes with classes or interfaces

git-svn-id: branches/fpc_2_3@6451 -

florian hace 18 años
padre
commit
8746c1ebf2
Se han modificado 3 ficheros con 32 adiciones y 5 borrados
  1. 10 0
      compiler/ncal.pas
  2. 8 1
      compiler/nutils.pas
  3. 14 4
      compiler/optcse.pas

+ 10 - 0
compiler/ncal.pas

@@ -159,6 +159,7 @@ interface
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           function dogetcopy : tnode;override;
           procedure insertintolist(l : tnodelist);override;
+          function  pass_1 : tnode;override;
           procedure get_paratype;
           procedure insert_typeconv(do_count : boolean);
           procedure det_registers;
@@ -743,9 +744,18 @@ implementation
          result:=n;
       end;
 
+
     procedure tcallparanode.insertintolist(l : tnodelist);
+      begin
+      end;
+
 
+    function tcallparanode.pass_1 : tnode;
       begin
+        firstpass(left);
+        if assigned(right) then
+          firstpass(right);
+        result:=nil;
       end;
 
 

+ 8 - 1
compiler/nutils.pas

@@ -582,7 +582,14 @@ implementation
                     result := NODE_COMPLEXITY_INF;
                   exit;
                 end;
-              subscriptn,
+              subscriptn:
+                begin
+                  if is_class_or_interface(tunarynode(p).left.resultdef) then
+                    inc(result);
+                  if (result = NODE_COMPLEXITY_INF) then
+                    exit;
+                  p := tunarynode(p).left;
+                end;
               blockn:
                 p := tunarynode(p).left;
               derefn :

+ 14 - 4
compiler/optcse.pas

@@ -43,7 +43,8 @@ unit optcse;
       symtype,symdef;
 
     const
-      cseinvariant : set of tnodetype = [loadn,addn,muln,subn,divn,andn,orn,xorn,notn,vecn,derefn];
+      cseinvariant : set of tnodetype = [loadn,addn,muln,subn,divn,slashn,modn,andn,orn,xorn,notn,vecn,
+        derefn,equaln,unequaln,ltn,gtn,lten,gten,typeconvn,subscriptn];
 
     function searchsubdomain(var n:tnode; arg: pointer) : foreachnoderesult;
       begin
@@ -69,7 +70,7 @@ unit optcse;
     function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;
       begin
         { node worth to add? }
-        if node_complexity(n)>1 then
+        if (node_complexity(n)>1) and (tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) then
           begin
             plists(arg)^.nodelist.Add(n);
             plists(arg)^.locationlist.Add(@n);
@@ -88,7 +89,9 @@ unit optcse;
         i,j : aint;
         def : tstoreddef;
         nodes : tblocknode;
+        creates,
         statements : tstatementnode;
+        hp : ttempcreatenode;
       begin
         result:=fen_false;
         if n.nodetype in cseinvariant then
@@ -119,7 +122,10 @@ unit optcse;
                       if tnode(lists.nodelist[i]).isequal(tnode(lists.nodelist[j])) then
                         begin
                           if not(assigned(statements)) then
-                            nodes:=internalstatements(statements);
+                            begin
+                              nodes:=internalstatements(statements);
+                              addstatement(statements,internalstatements(creates));
+                            end;
 {$ifdef csedebug}
                           writeln('    ====     ');
                           printnode(output,tnode(lists.nodelist[i]));
@@ -140,7 +146,11 @@ unit optcse;
                             begin
                               templist[i]:=ctempcreatenode.create(def,def.size,tt_persistent,
                                 def.is_intregable or def.is_fpuregable);
-                              addstatement(statements,tnode(templist[i]));
+                              addstatement(creates,tnode(templist[i]));
+
+                              { properties can't be passed by var }
+                              hp:=ttempcreatenode(templist[i]);
+                              do_firstpass(tnode(hp));
 
                               addstatement(statements,cassignmentnode.create(ctemprefnode.create(ttempcreatenode(templist[i])),
                                 tnode(lists.nodelist[i])));