Parcourir la source

* loop node flags from node flags splitted

florian il y a 23 ans
Parent
commit
e8bb7d10c3
3 fichiers modifiés avec 46 ajouts et 26 suppressions
  1. 11 8
      compiler/ncgflw.pas
  2. 30 10
      compiler/nflw.pas
  3. 5 8
      compiler/node.pas

+ 11 - 8
compiler/ncgflw.pas

@@ -125,7 +125,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 nf_testatbegin in flags then
+         if lnf_testatbegin in loopflags then
            cg.a_jmp_always(exprasmlist,lcont);
 
          if not(cs_littlesize in aktglobalswitches) then
@@ -145,7 +145,7 @@ implementation
          cg.a_label(exprasmlist,lcont);
          otlabel:=truelabel;
          oflabel:=falselabel;
-         if nf_checknegate in flags then
+         if lnf_checknegate in loopflags then
           begin
             truelabel:=lbreak;
             falselabel:=lloop;
@@ -352,7 +352,7 @@ implementation
          secondpass(left);
          count_var_is_signed:=is_signed(t2.resulttype.def);
 
-         if nf_backward in flags then
+         if lnf_backward in loopflags then
            if count_var_is_signed then
              hcond:=OC_LT
            else
@@ -372,7 +372,7 @@ implementation
            end
          else
            begin
-             if nf_testatbegin in flags then
+             if lnf_testatbegin in loopflags then
                begin
                  cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
                    aword(tordconstnode(right).value),
@@ -380,7 +380,7 @@ implementation
                end;
            end;
 
-         if nf_backward in flags then
+         if lnf_backward in loopflags then
            hop:=OP_ADD
          else
            hop:=OP_SUB;
@@ -392,7 +392,7 @@ implementation
          cg.a_label(exprasmlist,l3);
 
          { according to count direction DEC or INC... }
-         if nf_backward in flags then
+         if lnf_backward in loopflags then
            hop:=OP_SUB
          else
            hop:=OP_ADD;
@@ -411,7 +411,7 @@ implementation
          { makes no problems there }
          rg.cleartempgen;
 
-         if nf_backward in flags then
+         if lnf_backward in loopflags then
            if count_var_is_signed then
              hcond:=OC_GT
            else
@@ -1247,7 +1247,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.44  2002-11-25 17:43:17  peter
+  Revision 1.45  2002-11-28 11:17:01  florian
+    * loop node flags from node flags splitted
+
+  Revision 1.44  2002/11/25 17:43:17  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 30 - 10
compiler/nflw.pas

@@ -35,9 +35,25 @@ interface
     {$endif}
        symppu,symtype,symbase,symdef,symsym;
 
+    type
+       { flags used by loop nodes }
+       tloopflags = (
+         { set if it is a for ... downto ... do loop }
+         lnf_backward,
+         { Do we need to parse childs to set var state? }
+         lnf_varstate,
+         { Do a test at the begin of the loop?}
+         lnf_testatbegin,
+         { Negate the loop test? }
+         lnf_checknegate);
+    const
+         { loop flags which must match to consider loop nodes equal regarding the flags }
+         loopflagsequal = [lnf_backward];
+
     type
        tloopnode = class(tbinarynode)
           t1,t2 : tnode;
+          loopflags : set of tloopflags;
           constructor create(tt : tnodetype;l,r,_t1,_t2 : tnode);virtual;
           destructor destroy;override;
           function getcopy : tnode;override;
@@ -322,6 +338,7 @@ implementation
       begin
         docompare :=
           inherited docompare(p) and
+          (loopflags*loopflagsequal=tloopnode(p).loopflags*loopflagsequal) and
           t1.isequal(tloopnode(p).t1) and
           t2.isequal(tloopnode(p).t2);
       end;
@@ -335,9 +352,9 @@ implementation
     begin
         inherited create(whilerepeatn,l,r,_t1,nil);
         if tab then
-            include(flags,nf_testatbegin);
+            include(loopflags, lnf_testatbegin);
         if cn then
-            include(flags,nf_checknegate);
+            include(loopflags,lnf_checknegate);
     end;
 
     function twhilerepeatnode.det_resulttype:tnode;
@@ -360,7 +377,7 @@ implementation
                 RunError(255);
 {$else}
                 {Symdif operator, in case you are wondering:}
-                flags:=flags >< [nf_checknegate];
+                loopflags:=loopflags >< [lnf_checknegate];
 {$endif}
             end;
          { loop instruction }
@@ -435,7 +452,7 @@ implementation
         done:=false;
         firsttest:=true;
         {For repeat until statements, first do a pass through the code.}
-        if not(nf_testatbegin in flags) then
+        if not(lnf_testatbegin in flags) then
             begin
                 code:=right.getcopy;
                 if code.track_state_pass(exec_known) then
@@ -635,8 +652,8 @@ implementation
       begin
          inherited create(forn,l,r,_t1,_t2);
          if back then
-           include(flags,nf_backward);
-         include(flags,nf_testatbegin);
+           include(loopflags,lnf_backward);
+         include(loopflags,lnf_testatbegin);
       end;
 
 {$ifdef var_notification}
@@ -664,14 +681,14 @@ implementation
          {Can we spare the first comparision?}
          if (right.nodetype=ordconstn) and (Tassignmentnode(left).right.nodetype=ordconstn) then
             if (
-                (nf_backward in flags) and
+                (lnf_backward in loopflags) and
                 (Tordconstnode(Tassignmentnode(left).right).value>=Tordconstnode(right).value)
                )
              or not(
-                    (nf_backward in flags) and
+                    (lnf_backward in loopflags) and
                     (Tordconstnode(Tassignmentnode(left).right).value<=Tordconstnode(right).value)
                    ) then
-                exclude(flags,nf_testatbegin);
+                exclude(loopflags,lnf_testatbegin);
 
          { save counter var }
          t2:=tassignmentnode(left).left.getcopy;
@@ -1412,7 +1429,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.56  2002-11-25 17:43:18  peter
+  Revision 1.57  2002-11-28 11:17:02  florian
+    * loop node flags from node flags splitted
+
+  Revision 1.56  2002/11/25 17:43:18  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 5 - 8
compiler/node.pas

@@ -227,12 +227,6 @@ interface
          { flags used by tcallparanode }
          nf_varargs_para,  { belongs this para to varargs }
 
-         { 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_testatbegin,{ Do a test at the begin of the loop?}
-         nf_checknegate,{ Negate the loop test?}
-
          { taddrnode }
          nf_procvarload,
 
@@ -282,7 +276,7 @@ interface
     const
        { contains the flags which must be equal for the equality }
        { of nodes                                                }
-       flagsequal : tnodeflagset = [nf_error,nf_static_call,nf_backward];
+       flagsequal : tnodeflagset = [nf_error,nf_static_call];
 
     type
        tnodelist = class
@@ -979,7 +973,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.44  2002-10-05 00:48:57  peter
+  Revision 1.45  2002-11-28 11:17:04  florian
+    * loop node flags from node flags splitted
+
+  Revision 1.44  2002/10/05 00:48:57  peter
     * support inherited; support for overload as it is handled by
       delphi. This is only for delphi mode as it is working is
       undocumented and hard to predict what is done