Browse Source

* Changed booleans into flags

daniel 23 years ago
parent
commit
0af1f3883c
3 changed files with 34 additions and 25 deletions
  1. 7 4
      compiler/ncgflw.pas
  2. 19 18
      compiler/nflw.pas
  3. 8 3
      compiler/node.pas

+ 7 - 4
compiler/ncgflw.pas

@@ -101,7 +101,7 @@ implementation
          load_all_regvars(exprasmlist);
          load_all_regvars(exprasmlist);
          { handling code at the end as it is much more efficient, and makes
          { 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) }
            while equal to repeat loop, only the end true/false is swapped (PFV) }
-         if testatbegin then
+         if nf_testatbegin in flags then
            cg.a_jmp_always(exprasmlist,lcont);
            cg.a_jmp_always(exprasmlist,lcont);
 
 
 	 if not(cs_littlesize in aktglobalswitches) then
 	 if not(cs_littlesize in aktglobalswitches) then
@@ -121,7 +121,7 @@ implementation
          cg.a_label(exprasmlist,lcont);
          cg.a_label(exprasmlist,lcont);
          otlabel:=truelabel;
          otlabel:=truelabel;
          oflabel:=falselabel;
          oflabel:=falselabel;
-         if checknegate then
+         if nf_checknegate in flags then
           begin
           begin
             truelabel:=lbreak;
             truelabel:=lbreak;
             falselabel:=lloop;
             falselabel:=lloop;
@@ -349,7 +349,7 @@ implementation
            end
            end
          else
          else
            begin
            begin
-             if testatbegin then
+             if nf_testatbegin in flags then
                begin
                begin
                  cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
                  cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
                    aword(tordconstnode(right).value),
                    aword(tordconstnode(right).value),
@@ -627,7 +627,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.27  2002-07-20 12:54:53  daniel
+  Revision 1.28  2002-07-21 06:58:49  daniel
+  * Changed booleans into flags
+
+  Revision 1.27  2002/07/20 12:54:53  daniel
   * Optimized the code generated for for nodes. The shootout/nestloop benchmark
   * Optimized the code generated for for nodes. The shootout/nestloop benchmark
     now runs 5% faster on my computer.
     now runs 5% faster on my computer.
 
 

+ 19 - 18
compiler/nflw.pas

@@ -45,7 +45,6 @@ interface
        end;
        end;
 
 
        twhilerepeatnode = class(tloopnode)
        twhilerepeatnode = class(tloopnode)
-	  testatbegin,checknegate:boolean;
           constructor create(l,r,_t1:Tnode;tab,cn:boolean);virtual;
           constructor create(l,r,_t1:Tnode;tab,cn:boolean);virtual;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
@@ -63,7 +62,6 @@ interface
        tifnodeclass = class of tifnode;
        tifnodeclass = class of tifnode;
 
 
        tfornode = class(tloopnode)
        tfornode = class(tloopnode)
-	  testatbegin:boolean;
           constructor create(l,r,_t1,_t2 : tnode;back : boolean);virtual;
           constructor create(l,r,_t1,_t2 : tnode;back : boolean);virtual;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
@@ -284,8 +282,10 @@ implementation
 
 
     begin
     begin
 	inherited create(whilerepeatn,l,r,_t1,nil);
 	inherited create(whilerepeatn,l,r,_t1,nil);
-	testatbegin:=tab;
-	checknegate:=cn;
+	if tab then
+	    include(flags,nf_testatbegin);
+	if cn then
+	    include(flags,nf_checknegate);
     end;
     end;
 
 
     function twhilerepeatnode.det_resulttype:tnode;
     function twhilerepeatnode.det_resulttype:tnode;
@@ -303,7 +303,8 @@ implementation
 		left:=Tunarynode(left).left;
 		left:=Tunarynode(left).left;
 		t.left:=nil;
 		t.left:=nil;
 		t.destroy;
 		t.destroy;
-		checknegate:=not checknegate;
+		{Symdif operator, in case you are wondering:}
+		flags:=flags >< [nf_checknegate];
 	    end;
 	    end;
          { loop instruction }
          { loop instruction }
          if assigned(right) then
          if assigned(right) then
@@ -377,7 +378,7 @@ implementation
 	done:=false;
 	done:=false;
 	firsttest:=true;
 	firsttest:=true;
 	{For repeat until statements, first do a pass through the code.}
 	{For repeat until statements, first do a pass through the code.}
-	if not testatbegin then
+	if not(nf_testatbegin in flags) then
 	    begin
 	    begin
 		code:=right.getcopy;
 		code:=right.getcopy;
 		if code.track_state_pass(exec_known) then
 		if code.track_state_pass(exec_known) then
@@ -406,10 +407,7 @@ implementation
 		begin
 		begin
 		    {Try to turn a while loop into a repeat loop.}
 		    {Try to turn a while loop into a repeat loop.}
 		    if firsttest then
 		    if firsttest then
-			begin
-			testatbegin:=false;
-			    writeln('while->repeat');
-			end;
+			exclude(flags,testatbegin);
 		    value:=(Tordconstnode(condition).value<>0) xor checknegate;
 		    value:=(Tordconstnode(condition).value<>0) xor checknegate;
 		    if value then
 		    if value then
 			begin
 			begin
@@ -581,7 +579,7 @@ implementation
          inherited create(forn,l,r,_t1,_t2);
          inherited create(forn,l,r,_t1,_t2);
          if back then
          if back then
            include(flags,nf_backward);
            include(flags,nf_backward);
-	 testatbegin:=true;
+	 include(flags,nf_testatbegin);
       end;
       end;
 
 
 
 
@@ -600,12 +598,12 @@ implementation
            end;
            end;
 
 
 	 {Can we spare the first comparision?}
 	 {Can we spare the first comparision?}
-         if right.nodetype=ordconstn then
-            if Tassignmentnode(left).right.nodetype=ordconstn then
-        	testatbegin:=not(((nf_backward in flags) and
-                 (Tordconstnode(Tassignmentnode(left).right).value>=Tordconstnode(right).value))
-                 or (not(nf_backward in flags) and
-                 (Tordconstnode(Tassignmentnode(left).right).value<=Tordconstnode(right).value)));
+         if (right.nodetype=ordconstn) and (Tassignmentnode(left).right.nodetype=ordconstn) then
+    	    if not(((nf_backward in flags) and
+             (Tordconstnode(Tassignmentnode(left).right).value>=Tordconstnode(right).value))
+             or (not(nf_backward in flags) and
+             (Tordconstnode(Tassignmentnode(left).right).value<=Tordconstnode(right).value))) then
+	        exclude(flags,nf_testatbegin);
 
 
          { save counter var }
          { save counter var }
          t2:=tassignmentnode(left).left.getcopy;
          t2:=tassignmentnode(left).left.getcopy;
@@ -1246,7 +1244,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.43  2002-07-20 11:57:54  florian
+  Revision 1.44  2002-07-21 06:58:49  daniel
+  * Changed booleans into flags
+
+  Revision 1.43  2002/07/20 11:57:54  florian
     * types.pas renamed to defbase.pas because D6 contains a types
     * types.pas renamed to defbase.pas because D6 contains a types
       unit so this would conflicts if D6 programms are compiled
       unit so this would conflicts if D6 programms are compiled
     + Willamette/SSE2 instructions to assembler added
     + Willamette/SSE2 instructions to assembler added

+ 8 - 3
compiler/node.pas

@@ -225,8 +225,10 @@ interface
          nf_varargs_para,  { belongs this para to varargs }
          nf_varargs_para,  { belongs this para to varargs }
 
 
          { flags used by loop nodes }
          { flags used by loop nodes }
-         nf_backward,  { set if it is a for ... downto ... do loop }
-         nf_varstate,  { do we need to parse childs to set var state }
+         nf_backward,	{ set if it is a for ... downto ... do loop }
+         nf_varstate,   { do we need to parse childs to set var state }
+	 nf_testatbegin,{ Do a test at the begin of the loop?}
+	 nf_checknegate,{ Negate the loop test?}
 
 
          { taddrnode }
          { taddrnode }
          nf_procvarload,
          nf_procvarload,
@@ -821,7 +823,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.30  2002-07-19 11:41:36  daniel
+  Revision 1.31  2002-07-21 06:58:49  daniel
+  * Changed booleans into flags
+
+  Revision 1.30  2002/07/19 11:41:36  daniel
   * State tracker work
   * State tracker work
   * The whilen and repeatn are now completely unified into whilerepeatn. This
   * The whilen and repeatn are now completely unified into whilerepeatn. This
     allows the state tracker to change while nodes automatically into
     allows the state tracker to change while nodes automatically into