Browse Source

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

J. Gareth "Curious Kit" Moreton 1 year ago
parent
commit
c21a0f0654
3 changed files with 75 additions and 11 deletions
  1. 74 7
      compiler/nmat.pas
  2. 0 3
      compiler/node.pas
  3. 1 1
      compiler/pexpr.pas

+ 74 - 7
compiler/nmat.pas

@@ -26,13 +26,27 @@ unit nmat;
 interface
 
     uses
-       node;
+       node,symtype;
 
     type
+       TModDivNodeFlag = (
+         mdnf_isomod
+       );
+
+       TModDivNodeFlags = set of TModDivNodeFlag;
+
        tmoddivnode = class(tbinopnode)
+          moddivnodeflags: TModDivNodeFlags;
+          constructor create(t:tnodetype;l,r : tnode); override;
+          constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
+          procedure ppuwrite(ppufile:tcompilerppufile);override;
           function pass_1 : tnode;override;
           function pass_typecheck:tnode;override;
           function simplify(forinline : boolean) : tnode;override;
+          function dogetcopy : tnode;override;
+    {$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)    }
@@ -97,17 +111,39 @@ implementation
       systems,
       verbose,globals,cutils,compinnr,
       globtype,constexp,
-      symconst,symtype,symdef,symcpu,
+      symconst,symdef,symcpu,
       defcmp,defutil,
       htypechk,pass_1,
       cgbase,
       ncon,ncnv,ncal,nadd,nld,nbas,nflw,ninl,
-      nutils;
+      nutils,ppu;
 
 {****************************************************************************
                               TMODDIVNODE
  ****************************************************************************}
 
+
+    constructor tmoddivnode.create(t:tnodetype;l,r : tnode);
+      begin
+        inherited create(t, l, r);
+        moddivnodeflags := [];
+      end;
+
+
+    constructor tmoddivnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
+      begin
+        inherited ppuload(t, ppufile);
+        ppufile.getset(tppuset1(moddivnodeflags));
+      end;
+
+
+    procedure tmoddivnode.ppuwrite(ppufile:tcompilerppufile);
+      begin
+        inherited ppuwrite(ppufile);
+        ppufile.putset(tppuset1(moddivnodeflags));
+      end;
+
+
     function tmoddivnode.simplify(forinline : boolean):tnode;
       var
         rv,lv : tconstexprint;
@@ -149,7 +185,7 @@ implementation
                 left:=nil;
                 exit;
               end;
-            if (nf_isomod in flags) and
+            if (mdnf_isomod in moddivnodeflags) and
               (rv<=0) then
                begin
                  Message(cg_e_mod_only_defined_for_pos_quotient);
@@ -186,7 +222,7 @@ implementation
 
                 case nodetype of
                   modn:
-                    if nf_isomod in flags then
+                    if mdnf_isomod in moddivnodeflags then
                       begin
                         if lv>=0 then
                           result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false)
@@ -208,6 +244,16 @@ implementation
       end;
 
 
+    function tmoddivnode.dogetcopy: tnode;
+      var
+        n: tmoddivnode;
+      begin
+        n:=tmoddivnode(inherited dogetcopy);
+        n.moddivnodeflags := moddivnodeflags;
+        result:=n;
+      end;
+
+
     function tmoddivnode.use_moddiv64bitint_helper: boolean;
       begin
         { not with an ifdef around the call to this routine, because e.g. the
@@ -412,7 +458,7 @@ implementation
             result:=hp;
           end;
 
-         if (nodetype=modn) and (nf_isomod in flags) then
+         if (nodetype=modn) and (mdnf_isomod in moddivnodeflags) then
            begin
              result:=internalstatements(statements);
              else_block:=internalstatements(else_statements);
@@ -722,7 +768,28 @@ implementation
          expectloc:=LOC_REGISTER;
       end;
 
-
+{$ifdef DEBUG_NODE_XML}
+    procedure TModDivNode.XMLPrintNodeInfo(var T: Text);
+      var
+        i: TModDivNodeFlag;
+        First: Boolean;
+      begin
+        inherited XMLPrintNodeInfo(T);
+        First := True;
+        for i in moddivnodeflags do
+          begin
+            if First then
+              begin
+                Write(T, ' moddivnodeflags="', i);
+                First := False;
+              end
+            else
+              Write(T, ',', i)
+          end;
+        if not First then
+          Write(T, '"');
+      end;
+{$endif DEBUG_NODE_XML}
 
 {****************************************************************************
                               TSHLSHRNODE

+ 0 - 3
compiler/node.pas

@@ -243,9 +243,6 @@ interface
          { if the result type of a node is currency, then this flag denotes, that the value is already mulitplied by 10000 }
          nf_is_currency,
 
-         { tmoddivnode }
-         nf_isomod,
-
          { tassignmentnode }
          nf_assign_done_in_right,
 

+ 1 - 1
compiler/pexpr.pas

@@ -4846,7 +4846,7 @@ implementation
                  begin
                    p1:=cmoddivnode.create(modn,p1,p2);
                    if m_isolike_mod in current_settings.modeswitches then
-                     include(p1.flags,nf_isomod);
+                     include(tmoddivnode(p1).moddivnodeflags,mdnf_isomod);
                  end;
                _OP_SHL :
                  p1:=cshlshrnode.create(shln,p1,p2);