2
0
Эх сурвалжийг харах

* State tracker work
* The whilen and repeatn are now completely unified into whilerepeatn. This
allows the state tracker to change while nodes automatically into
repeat nodes.
* Resulttypepass improvements to the notn. 'not not a' is optimized away and
'not(a>b)' is optimized into 'a<=b'.
* Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
by removing the notn and later switchting the true and falselabels. The
same is done with 'repeat until not a'.

daniel 23 жил өмнө
parent
commit
399036f1c2

+ 29 - 3
compiler/nadd.pas

@@ -35,7 +35,7 @@ interface
           function pass_1 : tnode;override;
           function det_resulttype:tnode;override;
 	{$ifdef state_tracking}
-	  procedure track_state_pass(exec_known:boolean);override;
+	  function track_state_pass(exec_known:boolean):boolean;override;
 	{$endif}
          protected
           { override the following if you want to implement }
@@ -1624,20 +1624,35 @@ implementation
       end;
 
 {$ifdef state_tracking}
-    procedure Taddnode.track_state_pass(exec_known:boolean);
+    function Taddnode.track_state_pass(exec_known:boolean):boolean;
 
     var factval:Tnode;
     
     begin
+	track_state_pass:=false;
+	if left.track_state_pass(exec_known) then
+	    begin
+		track_state_pass:=true;
+		left.resulttype.def:=nil;
+		do_resulttypepass(left);
+	    end;
 	factval:=aktstate.find_fact(left);
 	if factval<>nil then
 	    begin
+		track_state_pass:=true;
 	        left.destroy;
 	        left:=factval.getcopy;
 	    end;
+	if right.track_state_pass(exec_known) then
+	    begin
+		track_state_pass:=true;
+		right.resulttype.def:=nil;
+		do_resulttypepass(right);
+	    end;
 	factval:=aktstate.find_fact(right);
 	if factval<>nil then
 	    begin
+		track_state_pass:=true;
 	        right.destroy;
 	        right:=factval.getcopy;
 	    end;
@@ -1649,7 +1664,18 @@ begin
 end.
 {
   $Log$
-  Revision 1.52  2002-07-14 18:00:43  daniel
+  Revision 1.53  2002-07-19 11:41:34  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.52  2002/07/14 18:00:43  daniel
   + Added the beginning of a state tracker. This will track the values of
     variables through procedures and optimize things away.
 

+ 17 - 4
compiler/nbas.pas

@@ -70,7 +70,7 @@ interface
           function pass_1 : tnode;override;
           function det_resulttype:tnode;override;
 {$ifdef state_tracking}
-	  procedure track_state_pass(exec_known:boolean);override;
+	  function track_state_pass(exec_known:boolean):boolean;override;
 {$endif state_tracking}
        end;
        tblocknodeclass = class of tblocknode;
@@ -437,15 +437,17 @@ implementation
       end;
 
 {$ifdef state_tracking}
-      procedure Tblocknode.track_state_pass(exec_known:boolean);
+      function Tblocknode.track_state_pass(exec_known:boolean):boolean;
       
       var hp:Tstatementnode;
       
       begin
+        track_state_pass:=false;
         hp:=Tstatementnode(left);
 	while assigned(hp) do
 	    begin
-		hp.right.track_state_pass(exec_known);
+		if hp.right.track_state_pass(exec_known) then
+		    track_state_pass:=true;
 		hp:=Tstatementnode(hp.left);
 	    end;
       end;
@@ -692,7 +694,18 @@ begin
 end.
 {
   $Log$
-  Revision 1.28  2002-07-14 18:00:43  daniel
+  Revision 1.29  2002-07-19 11:41:35  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.28  2002/07/14 18:00:43  daniel
   + Added the beginning of a state tracker. This will track the values of
     variables through procedures and optimize things away.
 

+ 22 - 3
compiler/ncal.pas

@@ -67,7 +67,7 @@ interface
           function  pass_1 : tnode;override;
           function  det_resulttype:tnode;override;
        {$ifdef state_tracking}
-          procedure track_state_pass(exec_known:boolean);override;
+          function track_state_pass(exec_known:boolean):boolean;override;
        {$endif state_tracking}
           function  docompare(p: tnode): boolean; override;
           procedure set_procvar(procvar:tnode);
@@ -1783,20 +1783,28 @@ implementation
       end;
 
 {$ifdef state_tracking}
-    procedure Tcallnode.track_state_pass(exec_known:boolean);
+    function Tcallnode.track_state_pass(exec_known:boolean):boolean;
     
     var hp:Tcallparanode;
 	value:Tnode;
     
     begin
+	track_state_pass:=false;
 	hp:=Tcallparanode(left);
 	while assigned(hp) do
 	    begin
+		if left.track_state_pass(exec_known) then
+		    begin
+			left.resulttype.def:=nil;
+			do_resulttypepass(left);
+		    end;
 		value:=aktstate.find_fact(hp.left);
 		if value<>nil then
 		    begin
+			track_state_pass:=true;
 			hp.left.destroy;
 			hp.left:=value.getcopy;
+			do_resulttypepass(hp.left);
 		    end;
 		hp:=Tcallparanode(hp.right);
 	    end;
@@ -1896,7 +1904,18 @@ begin
 end.
 {
   $Log$
-  Revision 1.81  2002-07-15 18:03:14  florian
+  Revision 1.82  2002-07-19 11:41:35  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.81  2002/07/15 18:03:14  florian
     * readded removed changes
 
   Revision 1.79  2002/07/11 14:41:27  florian

+ 19 - 9
compiler/ncgflw.pas

@@ -101,7 +101,7 @@ implementation
          load_all_regvars(exprasmlist);
          { handling code at the end as it is much more efficient, and makes
            while equal to repeat loop, only the end true/false is swapped (PFV) }
-         if nodetype=whilen then
+         if testatbegin then
            cg.a_jmp_always(exprasmlist,lcont);
 
          { align loop target }
@@ -119,20 +119,19 @@ implementation
          cg.a_label(exprasmlist,lcont);
          otlabel:=truelabel;
          oflabel:=falselabel;
-         if nodetype=whilen then
+         if checknegate then
           begin
-            truelabel:=lloop;
-            falselabel:=lbreak;
+            truelabel:=lbreak;
+            falselabel:=lloop;
           end
-         { repeatn }
          else
           begin
-            truelabel:=lbreak;
-            falselabel:=lloop;
+            truelabel:=lloop;
+            falselabel:=lbreak;
           end;
          rg.cleartempgen;
          secondpass(left);
-
+	 
          maketojumpbool(exprasmlist,left,lr_load_regvars);
          cg.a_label(exprasmlist,lbreak);
          truelabel:=otlabel;
@@ -629,7 +628,18 @@ begin
 end.
 {
   $Log$
-  Revision 1.22  2002-07-04 20:43:01  florian
+  Revision 1.23  2002-07-19 11:41:35  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.22  2002/07/04 20:43:01  florian
     * first x86-64 patches
 
   Revision 1.21  2002/07/01 18:46:22  peter

+ 70 - 21
compiler/nflw.pas

@@ -45,10 +45,12 @@ interface
        end;
 
        twhilerepeatnode = class(tloopnode)
+	  testatbegin,checknegate:boolean;
+          constructor create(l,r,_t1:Tnode;tab,cn:boolean);virtual;
           function det_resulttype:tnode;override;
           function pass_1 : tnode;override;
 {$ifdef state_tracking}
-	  procedure track_state_pass(exec_known:boolean);override;
+	  function track_state_pass(exec_known:boolean):boolean;override;
 {$endif}
        end;
        twhilerepeatnodeclass = class of twhilerepeatnode;
@@ -198,10 +200,13 @@ implementation
          case t of
             ifn:
                p:=cifnode.create(l,r,n1);
-            repeatn:
-               p:=cwhilerepeatnode.create(repeatn,l,r,n1,nil);
-            whilen:
-               p:=cwhilerepeatnode.create(whilen,l,r,n1,nil);
+	    whilerepeatn:
+    	       if back then
+	          {Repeat until.}	        
+        	  p:=cwhilerepeatnode.create(l,r,n1,false,true)
+	       else
+	          {While do.}
+                  p:=cwhilerepeatnode.create(l,r,n1,true,false);
             forn:
                p:=cfornode.create(l,r,n1,nil,back);
          end;
@@ -274,12 +279,31 @@ implementation
                                TWHILEREPEATNODE
 *****************************************************************************}
 
+    constructor Twhilerepeatnode.create(l,r,_t1:Tnode;tab,cn:boolean);
+
+    begin
+	inherited create(whilerepeatn,l,r,_t1,nil);
+	testatbegin:=tab;
+	checknegate:=cn;
+    end;
+
     function twhilerepeatnode.det_resulttype:tnode;
+      var
+         t:Tunarynode;
       begin
          result:=nil;
          resulttype:=voidtype;
 
          resulttypepass(left);
+	 {A not node can be removed.}
+	 if left.nodetype=notn then
+	    begin
+		t:=Tunarynode(left);
+		left:=Tunarynode(left).left;
+		t.left:=nil;
+		t.destroy;
+		checknegate:=not checknegate;
+	    end;
          { loop instruction }
          if assigned(right) then
            resulttypepass(right);
@@ -337,33 +361,44 @@ implementation
       end;
 
 {$ifdef state_tracking}
-    procedure Twhilerepeatnode.track_state_pass(exec_known:boolean);
-
+    function Twhilerepeatnode.track_state_pass(exec_known:boolean):boolean;
+    
     var condition:Tnode;
 	code:Tnode;
 	done:boolean;
 	value:boolean;
-
+    
     begin
+	track_state_pass:=false;
 	done:=false;
+	writeln('Oeps!');
 	repeat
 	    condition:=left.getcopy;
-	    condition.track_state_pass(exec_known);
-	    {Force new resulttype pass.}
-	    condition.resulttype.def:=nil;
-	    do_resulttypepass(condition);
+	    if condition.track_state_pass(exec_known) then
+		begin
+		    track_state_pass:=true;
+		    {Force new resulttype pass.}
+		    condition.resulttype.def:=nil;
+		    do_resulttypepass(condition);
+		end;
 	    code:=right.getcopy;
 	    if is_constboolnode(condition) then
 		begin
 		    value:=Tordconstnode(condition).value<>0;
 		    if value then
-			code.track_state_pass(exec_known)
+			begin
+			    if code.track_state_pass(exec_known) then
+				track_state_pass:=true;
+			end
 		    else
 		        done:=true;
 		end
 	    else
-		{Remove any modified variables from the state.}
-		code.track_state_pass(false);
+		begin
+		    {Remove any modified variables from the state.}
+		    code.track_state_pass(false);
+		    done:=true;
+		end;
 	    code.destroy;
 	    condition.destroy;
 	until done;
@@ -372,14 +407,17 @@ implementation
 	    begin
 	        ...
 	    end;
-
+	 
 	 When the loop is done, we do know that i<10 = false.
 	}
 	condition:=left.getcopy;
-        condition.track_state_pass(exec_known);
-	{Force new resulttype pass.}
-        condition.resulttype.def:=nil;
-	do_resulttypepass(condition);
+        if condition.track_state_pass(exec_known) then
+	    begin
+		track_state_pass:=true;
+		{Force new resulttype pass.}
+    		condition.resulttype.def:=nil;
+		do_resulttypepass(condition);
+	    end;
 	aktstate.store_fact(condition,cordconstnode.create(0,booltype));
     end;
 {$endif}
@@ -1166,7 +1204,18 @@ begin
 end.
 {
   $Log$
-  Revision 1.37  2002-07-16 13:57:02  florian
+  Revision 1.38  2002-07-19 11:41:35  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.37  2002/07/16 13:57:02  florian
     * raise takes now a void pointer as at and frame address
       instead of a longint
 

+ 16 - 5
compiler/nld.pas

@@ -58,7 +58,7 @@ interface
           function pass_1 : tnode;override;
           function det_resulttype:tnode;override;
        {$ifdef state_tracking}
-          procedure track_state_pass(exec_known:boolean);override;
+          function track_state_pass(exec_known:boolean):boolean;override;
        {$endif state_tracking}
           function docompare(p: tnode): boolean; override;
        end;
@@ -578,14 +578,15 @@ implementation
       end;
 
 {$ifdef state_tracking}
-    procedure Tassignmentnode.track_state_pass(exec_known:boolean);
+    function Tassignmentnode.track_state_pass(exec_known:boolean):boolean;
     
     var se:Tstate_entry;
 
     begin
+	track_state_pass:=false;
 	if exec_known then
 	    begin
-		right.track_state_pass(exec_known);
+		track_state_pass:=right.track_state_pass(exec_known);
 		{Force a new resulttype pass.}
 		right.resulttype.def:=nil;
 		do_resulttypepass(right);
@@ -597,7 +598,6 @@ implementation
     end;
 {$endif}
 
-
 {*****************************************************************************
                                  TFUNCRETNODE
 *****************************************************************************}
@@ -983,7 +983,18 @@ begin
 end.
 {
   $Log$
-  Revision 1.45  2002-07-15 18:03:15  florian
+  Revision 1.46  2002-07-19 11:41:36  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.45  2002/07/15 18:03:15  florian
     * readded removed changes
 
   Revision 1.43  2002/07/11 14:41:28  florian

+ 53 - 2
compiler/nmat.pas

@@ -58,6 +58,9 @@ interface
           constructor create(expr : tnode);virtual;
           function pass_1 : tnode;override;
           function det_resulttype:tnode;override;
+       {$ifdef state_tracking}
+	  function track_state_pass(exec_known:boolean):boolean;override;
+	{$endif}
        end;
        tnotnodeclass = class of tnotnode;
 
@@ -515,6 +518,9 @@ implementation
                                TNOTNODE
  ****************************************************************************}
 
+    const boolean_reverse:array[ltn..unequaln] of Tnodetype=
+	(gten,gtn,lten,ltn,unequaln,equaln);
+
     constructor tnotnode.create(expr : tnode);
 
       begin
@@ -533,6 +539,28 @@ implementation
          if codegenerror then
            exit;
 
+         resulttype:=left.resulttype;
+
+	 {Try optmimizing ourself away.}
+	 if left.nodetype=notn then
+	    begin
+		{Double not. Remove both.}
+		t:=Tnotnode(left).left;
+		Tnotnode(left).left:=nil;
+		left:=t;
+		result:=t;
+		exit;
+	    end;
+	 if left.nodetype in [ltn,lten,equaln,unequaln,gtn,gten] then
+	    begin
+		{Not of boolean expression. Turn around the operator and remove
+		 the not.}
+		result:=left;
+		left.nodetype:=boolean_reverse[left.nodetype];
+		left:=nil;
+		exit;
+	    end;
+
          { constant folding }
          if (left.nodetype=ordconstn) then
            begin
@@ -572,7 +600,6 @@ implementation
               exit;
            end;
 
-         resulttype:=left.resulttype;
          if is_boolean(resulttype.def) then
            begin
            end
@@ -669,6 +696,19 @@ implementation
               location.loc:=LOC_REGISTER;
            end
       end;
+      
+{$ifdef state_tracking}
+    function Tnotnode.track_state_pass(exec_known:boolean):boolean;
+    
+    begin
+	track_state_pass:=true;
+	if left.track_state_pass(exec_known) then
+	    begin
+		left.resulttype.def:=nil;
+		do_resulttypepass(left);
+	    end;
+    end;
+{$endif}
 
 begin
    cmoddivnode:=tmoddivnode;
@@ -678,7 +718,18 @@ begin
 end.
 {
   $Log$
-  Revision 1.34  2002-05-18 13:34:10  peter
+  Revision 1.35  2002-07-19 11:41:36  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.34  2002/05/18 13:34:10  peter
     * readded missing revisions
 
   Revision 1.33  2002/05/16 19:46:39  carl

+ 40 - 26
compiler/node.pas

@@ -94,34 +94,35 @@ interface
           ifn,       {An if statement.}
           breakn,         {A break statement.}
           continuen,       {A continue statement.}
-          repeatn,       {A repeat until block.}
-          whilen,         {A while do statement.}
-          forn,     {A for loop.}
-          exitn,           {An exit statement.}
-          withn,           {A with statement.}
-          casen,           {A case statement.}
-          labeln,         {A label.}
-          goton,           {A goto statement.}
-          tryexceptn,      {A try except block.}
-          raisen,         {A raise statement.}
-          tryfinallyn,     {A try finally statement.}
-          onn,       { for an on statement in exception code }
-          isn,       {Represents the is operator.}
-          asn,       {Represents the as typecast.}
-          caretn,         {Represents the ^ operator.}
-          failn,           {Represents the fail statement.}
-          starstarn,       {Represents the ** operator exponentiation }
-          procinlinen,     {Procedures that can be inlined }
+(*          repeatn,       {A repeat until block.}
+          whilen,         {A while do statement.}*)
+	  whilerepeatn,     {A while or repeat statement.}
+          forn,     	    {A for loop.}
+          exitn,            {An exit statement.}
+          withn,            {A with statement.}
+          casen,            {A case statement.}
+          labeln,           {A label.}
+          goton,            {A goto statement.}
+          tryexceptn,       {A try except block.}
+          raisen,           {A raise statement.}
+          tryfinallyn,      {A try finally statement.}
+          onn,              {For an on statement in exception code.}
+          isn,              {Represents the is operator.}
+          asn,              {Represents the as typecast.}
+          caretn,           {Represents the ^ operator.}
+          failn,            {Represents the fail statement.}
+          starstarn,        {Represents the ** operator exponentiation }
+          procinlinen,      {Procedures that can be inlined }
           arrayconstructorn, {Construction node for [...] parsing}
           arrayconstructorrangen, {Range element to allow sets in array construction tree}
-          tempn,     { for temps in the result/firstpass }
-          temprefn,  { references to temps }
+          tempn,            { for temps in the result/firstpass }
+          temprefn,         { references to temps }
           { added for optimizations where we cannot suppress }
           addoptn,
           nothingn,
           loadvmtn,
           guidconstn,
-          rttin       { rtti information so they can be accessed in result/firstpass }
+          rttin		    {Rtti information so they can be accessed in result/firstpass.}
        );
 
       const
@@ -179,8 +180,9 @@ interface
           'ifn',
           'breakn',
           'continuen',
-          'repeatn',
-          'whilen',
+(*          'repeatn',
+          'whilen',*)
+	  'whilerepeatn',
           'forn',
           'exitn',
           'withn',
@@ -332,7 +334,7 @@ interface
 {$ifdef state_tracking}
 	  { Does optimizations by keeping track of the variable states
 	    in a procedure }
-	  procedure track_state_pass(exec_known:boolean);virtual;
+	  function track_state_pass(exec_known:boolean):boolean;virtual;
 {$endif}
           procedure det_temp;virtual;abstract;
 
@@ -522,9 +524,10 @@ implementation
       end;
 
 {$ifdef state_tracking}
-    procedure Tnode.track_state_pass(exec_known:boolean);
+    function Tnode.track_state_pass(exec_known:boolean):boolean;
     
     begin
+	track_state_pass:=false;
     end;
 {$endif state_tracking}
 
@@ -818,7 +821,18 @@ implementation
 end.
 {
   $Log$
-  Revision 1.29  2002-07-14 18:00:44  daniel
+  Revision 1.30  2002-07-19 11:41:36  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.29  2002/07/14 18:00:44  daniel
   + Added the beginning of a state tracker. This will track the values of
     variables through procedures and optimize things away.
 

+ 27 - 2
compiler/pass_1.pas

@@ -52,6 +52,9 @@ implementation
 {$ifdef extdebug}
       htypechk,
 {$endif extdebug}
+{$ifdef state_tracking}
+      nstate,
+{$endif}
       tgobj
       ;
 
@@ -162,9 +165,9 @@ implementation
                  aktfilepos:=oldpos;
                  codegenerror:=codegenerror or oldcodegenerror;
                end;
-              { first pass }
               if not(nf_error in p.flags) then
                begin
+                 { first pass }
                  aktfilepos:=p.fileinfo;
                  aktlocalswitches:=p.localswitches;
                  hp:=p.pass_1;
@@ -194,6 +197,15 @@ implementation
       begin
          codegenerror:=false;
          firstpass(p);
+	     {$ifdef state_tracking}
+	         writeln('TRACKSTART');
+		 writeln('before');
+		        writenode(p);
+	    	        do_track_state_pass(p);
+		writeln('after');
+			writenode(p);
+		writeln('TRACKDONE');
+	     {$endif}
          do_firstpass:=codegenerror;
       end;
       
@@ -201,14 +213,27 @@ implementation
      procedure do_track_state_pass(p:Tnode);
      
      begin
+        aktstate:=Tstate_storage.create;
         p.track_state_pass(true);
+	aktstate.destroy;
      end;
 {$endif}
 
 end.
 {
   $Log$
-  Revision 1.25  2002-07-14 18:00:44  daniel
+  Revision 1.26  2002-07-19 11:41:36  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.25  2002/07/14 18:00:44  daniel
   + Added the beginning of a state tracker. This will track the values of
     variables through procedures and optimize things away.
 

+ 15 - 3
compiler/pass_2.pas

@@ -117,8 +117,9 @@ implementation
              'ifn',  {ifn}
              'breakn',      {breakn}
              'continuen',   {continuen}
-             '_while_REPEAT', {repeatn}
-             '_WHILE_repeat', {whilen}
+(*             '_while_REPEAT', {repeatn}
+             '_WHILE_repeat', {whilen}*)
+	     'while_repeat', {whilerepeatn}
              'for',  {forn}
              'exitn',       {exitn}
              'with',        {withn}
@@ -322,7 +323,18 @@ implementation
 end.
 {
   $Log$
-  Revision 1.31  2002-07-01 18:46:25  peter
+  Revision 1.32  2002-07-19 11:41:36  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.31  2002/07/01 18:46:25  peter
     * internal linker
     * reorganized aasm layer
 

+ 14 - 3
compiler/pstatmnt.pas

@@ -344,7 +344,7 @@ implementation
 
          first:=cblocknode.create(first);
          p_e:=comp_expr(true);
-         repeat_statement:=genloopnode(repeatn,p_e,first,nil,false);
+         repeat_statement:=genloopnode(whilerepeatn,p_e,first,nil,true);
       end;
 
 
@@ -358,7 +358,7 @@ implementation
          p_e:=comp_expr(true);
          consume(_DO);
          p_a:=statement;
-         while_statement:=genloopnode(whilen,p_e,p_a,nil,false);
+         while_statement:=genloopnode(whilerepeatn,p_e,p_a,nil,false);
       end;
 
 
@@ -1231,7 +1231,18 @@ implementation
 end.
 {
   $Log$
-  Revision 1.62  2002-07-16 15:34:20  florian
+  Revision 1.63  2002-07-19 11:41:36  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.62  2002/07/16 15:34:20  florian
     * exit is now a syssym instead of a keyword
 
   Revision 1.61  2002/07/11 14:41:28  florian

+ 16 - 3
compiler/psub.pas

@@ -248,7 +248,7 @@ implementation
          aktbreaklabel:=nil;
          aktcontinuelabel:=nil;
     {$ifdef state_tracking}
-	 aktstate:=Tstate_storage.create;
+{	 aktstate:=Tstate_storage.create;}
     {$endif state_tracking}
 
          { insert symtables for the class, by only if it is no nested function }
@@ -320,7 +320,9 @@ implementation
             aktprocdef.forwarddef:=false;
 
 {$ifdef state_tracking}
+{	    writenode(code);
 	    do_track_state_pass(code);
+	    writenode(code);}
 {$endif}
 
              { only generate the code if no type errors are found, else
@@ -456,7 +458,7 @@ implementation
          aktmaxfpuregisters:=oldaktmaxfpuregisters;
 
     {$ifdef state_tracking}
-	 aktstate.destroy;
+{	 aktstate.destroy;}
     {$endif state_tracking}
          { restore filepos, the switches are already set }
          aktfilepos:=savepos;
@@ -829,7 +831,18 @@ implementation
 end.
 {
   $Log$
-  Revision 1.59  2002-07-15 18:03:15  florian
+  Revision 1.60  2002-07-19 11:41:36  daniel
+  * State tracker work
+  * The whilen and repeatn are now completely unified into whilerepeatn. This
+    allows the state tracker to change while nodes automatically into
+    repeat nodes.
+  * Resulttypepass improvements to the notn. 'not not a' is optimized away and
+    'not(a>b)' is optimized into 'a<=b'.
+  * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
+    by removing the notn and later switchting the true and falselabels. The
+    same is done with 'repeat until not a'.
+
+  Revision 1.59  2002/07/15 18:03:15  florian
     * readded removed changes
 
   Revision 1.57  2002/07/11 14:41:28  florian