瀏覽代碼

* Flags specific to TAddNode have been moved to their own field

J. Gareth "Curious Kit" Moreton 1 年之前
父節點
當前提交
b804fc5164

+ 1 - 1
compiler/i8086/n8086add.pas

@@ -137,7 +137,7 @@ interface
                     { pointer-pointer results in an integer }
                     if (rt=pointerconstn) then
                       begin
-                        if not(nf_has_pointerdiv in flags) then
+                        if not(anf_has_pointerdiv in addnodeflags) then
                           internalerror(2008030102);
                         { todo: implement pointer-pointer as well }
                         internalerror(2014040607);

+ 46 - 7
compiler/nadd.pas

@@ -32,12 +32,21 @@ interface
       node,symtype;
 
     type
+       TAddNodeFlag = (
+         anf_has_pointerdiv,
+         { the node shall be short boolean evaluated, this flag has priority over localswitches }
+         anf_short_bool
+       );
+
+       TAddNodeFlags = set of TAddNodeFlag;
+
        taddnode = class(tbinopnode)
        private
           resultrealdefderef: tderef;
           function pass_typecheck_internal:tnode;
        public
           resultrealdef : tdef;
+          addnodeflags: TAddNodeFlags;
           constructor create(tt : tnodetype;l,r : tnode);override;
           constructor create_internal(tt:tnodetype;l,r:tnode);
           constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
@@ -52,6 +61,9 @@ interface
     {$ifdef state_tracking}
           function track_state_pass(exec_known:boolean):boolean;override;
     {$endif}
+    {$ifdef DEBUG_NODE_XML}
+          procedure XMLPrintNodeInfo(var T: Text); override;
+    {$endif DEBUG_NODE_XML}
          protected
           { override the following if you want to implement }
           { parts explicitely in the code generator (JM)    }
@@ -140,7 +152,8 @@ implementation
       {$ifdef state_tracking}
       nstate,
       {$endif}
-      cpuinfo;
+      cpuinfo,
+      ppu;
 
 
 {*****************************************************************************
@@ -179,6 +192,7 @@ implementation
     constructor taddnode.create(tt : tnodetype;l,r : tnode);
       begin
          inherited create(tt,l,r);
+         addnodeflags := [];
       end;
 
 
@@ -192,6 +206,7 @@ implementation
     constructor taddnode.ppuload(t: tnodetype; ppufile: tcompilerppufile);
       begin
         inherited ppuload(t, ppufile);
+        ppufile.getset(tppuset1(addnodeflags));
         ppufile.getderef(resultrealdefderef);
       end;
 
@@ -199,7 +214,8 @@ implementation
     procedure taddnode.ppuwrite(ppufile: tcompilerppufile);
       begin
         inherited ppuwrite(ppufile);
-         ppufile.putderef(resultrealdefderef);
+        ppufile.putset(tppuset1(addnodeflags));
+        ppufile.putderef(resultrealdefderef);
       end;
 
 
@@ -736,7 +752,7 @@ implementation
                      { pointer-pointer results in an integer }
                      if (rt=pointerconstn) then
                        begin
-                         if not(nf_has_pointerdiv in flags) then
+                         if not(anf_has_pointerdiv in addnodeflags) then
                            internalerror(2008030101);
                          t := cpointerconstnode.create(qword(v),resultdef)
                        end
@@ -1657,7 +1673,7 @@ implementation
                             begin
                               { we need to copy the whole tree to force another pass_1 }
                               include(localswitches,cs_full_boolean_eval);
-                              exclude(flags,nf_short_bool);
+                              exclude(addnodeflags,anf_short_bool);
                               result:=getcopy;
                               exit;
                             end;
@@ -1874,6 +1890,7 @@ implementation
         n: taddnode;
       begin
         n:=taddnode(inherited dogetcopy);
+        n.addnodeflags := addnodeflags;
         n.resultrealdef:=resultrealdef;
         result:=n;
       end;
@@ -2237,7 +2254,7 @@ implementation
            begin
               { set for & and | operations in macpas mode: they only work on }
               { booleans, and always short circuit evaluation                }
-              if (nf_short_bool in flags) then
+              if (anf_short_bool in addnodeflags) then
                 begin
                   if not is_boolean(ld) then
                     begin
@@ -2759,11 +2776,11 @@ implementation
                     else
                       CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),ld.typename,rd.typename);
 
-                    if not(nf_has_pointerdiv in flags) and
+                    if not(anf_has_pointerdiv in addnodeflags) and
                       (tpointerdef(rd).pointeddef.size>1) then
                       begin
                         hp:=getcopy;
-                        include(hp.flags,nf_has_pointerdiv);
+                        include(taddnode(hp).addnodeflags, anf_has_pointerdiv);
                         result:=cmoddivnode.create(divn,hp,
                           cordconstnode.create(tpointerdef(rd).pointeddef.size,tpointerdef(rd).pointer_subtraction_result_type,false));
                       end;
@@ -4755,5 +4772,27 @@ implementation
         end;
     end;
 {$endif}
+{$ifdef DEBUG_NODE_XML}
+    procedure TAddNode.XMLPrintNodeInfo(var T: Text);
+      var
+        i: TAddNodeFlag;
+        First: Boolean;
+      begin
+        inherited XMLPrintNodeInfo(T);
+        First := True;
+        for i in addnodeflags do
+          begin
+            if First then
+              begin
+                Write(T, ' addnodeflags="', i);
+                First := False;
+              end
+            else
+              Write(T, ',', i)
+          end;
+        if not First then
+          Write(T, '"');
+      end;
+{$endif DEBUG_NODE_XML}
 
 end.

+ 1 - 1
compiler/ncgadd.pas

@@ -388,7 +388,7 @@ interface
           needed nodes unless full boolean evaluation is enabled }
         if (nodetype in [orn,andn]) and
            (not(cs_full_boolean_eval in current_settings.localswitches) or
-            (nf_short_bool in flags)) then
+            (anf_short_bool in addnodeflags)) then
           begin
             case nodetype of
               andn :

+ 1 - 5
compiler/node.pas

@@ -236,16 +236,12 @@ interface
          { tderefnode }
          nf_no_checkpointer,
 
-
          { tloadnode/ttypeconvnode }
          nf_absolute,
 
-         { taddnode }
+         { taddnode, but appears in typeconv nodes as well among other places }
          { if the result type of a node is currency, then this flag denotes, that the value is already mulitplied by 10000 }
          nf_is_currency,
-         nf_has_pointerdiv,
-         { the node shall be short boolean evaluated, this flag has priority over localswitches }
-         nf_short_bool,
 
          { tmoddivnode }
          nf_isomod,

+ 1 - 1
compiler/nutils.pas

@@ -1608,7 +1608,7 @@ implementation
 
     function doshortbooleval(p : tnode) : Boolean;
       begin
-        Result:=(p.nodetype in [orn,andn]) and ((nf_short_bool in taddnode(p).flags) or not(cs_full_boolean_eval in p.localswitches));
+        Result:=(p.nodetype in [orn,andn]) and ((anf_short_bool in taddnode(p).addnodeflags) or not(cs_full_boolean_eval in p.localswitches));
       end;
 
 

+ 8 - 2
compiler/optcse.pas

@@ -380,8 +380,14 @@ unit optcse;
                                 begin
                                   n.localswitches:=n.localswitches+(tbinarynode(n).left.localswitches*[cs_full_boolean_eval]);
                                   exclude(tbinarynode(n).left.localswitches,cs_full_boolean_eval);
-                                  tbinarynode(n).left.flags:=tbinarynode(n).left.flags+(n.flags*[nf_short_bool]);
-                                  exclude(n.Flags,nf_short_bool);
+                                  if (n.nodetype in [orn,andn]) then
+                                    begin
+                                      if (tbinarynode(n).left.nodetype in [orn,andn]) then
+                                        taddnode(tbinarynode(n).left).addnodeflags := taddnode(tbinarynode(n).left).addnodeflags +
+                                          (taddnode(n).addnodeflags * [anf_short_bool]);
+
+                                      exclude(taddnode(n).addnodeflags, anf_short_bool);
+                                    end;
                                 end;
 
                               hp2:=tbinarynode(tbinarynode(n).left).left;

+ 2 - 2
compiler/pexpr.pas

@@ -4829,14 +4829,14 @@ implementation
                  begin
                    p1:=caddnode.create(orn,p1,p2);
                    if (oldt = _PIPE) then
-                     include(p1.flags,nf_short_bool);
+                     include(taddnode(p1).addnodeflags,anf_short_bool);
                  end;
                _OP_AND,
                _AMPERSAND {macpas only} :
                  begin
                    p1:=caddnode.create(andn,p1,p2);
                    if (oldt = _AMPERSAND) then
-                     include(p1.flags,nf_short_bool);
+                     include(taddnode(p1).addnodeflags,anf_short_bool);
                  end;
                _OP_DIV :
                  p1:=cmoddivnode.create(divn,p1,p2);

+ 1 - 1
compiler/ppcgen/ngppcadd.pas

@@ -223,7 +223,7 @@ implementation
 
         if {$ifndef cpu64bitalu}(cgsize<>OS_64) and{$endif}
            (((cs_full_boolean_eval in current_settings.localswitches) and
-             not(nf_short_bool in flags)) or
+             not(anf_short_bool in addnodeflags)) or
             (nodetype in [unequaln,ltn,lten,gtn,gten,equaln,xorn])) then
           begin
             if left.nodetype in [ordconstn,realconstn] then

+ 1 - 1
compiler/wasm32/nwasmadd.pas

@@ -293,7 +293,7 @@ interface
       begin
         if (nodetype in [orn,andn]) and
            (not(cs_full_boolean_eval in current_settings.localswitches) or
-            (nf_short_bool in flags)) then
+            (anf_short_bool in addnodeflags)) then
         begin
           secondpass(left);
           thlcgwasm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location);

+ 1 - 1
compiler/x86/nx86add.pas

@@ -2240,7 +2240,7 @@ unit nx86add;
       begin
         if (nodetype in [orn,andn]) and
            (not(cs_full_boolean_eval in current_settings.localswitches) or
-          (nf_short_bool in flags)) then
+          (anf_short_bool in addnodeflags)) then
           inherited second_addboolean
         else if is_64bit(left.resultdef) then
           inherited