浏览代码

remove multiple pass2 calls. It is not supported anymore by all nodes (ttempcreatenode)

peter 20 年之前
父节点
当前提交
1b41aad3a0
共有 2 个文件被更改,包括 15 次插入37 次删除
  1. 10 33
      compiler/ncgld.pas
  2. 5 4
      compiler/pass_2.pas

+ 10 - 33
compiler/ncgld.pas

@@ -383,7 +383,6 @@ implementation
          otlabel,hlabel,oflabel : tasmlabel;
          otlabel,hlabel,oflabel : tasmlabel;
          fputyp : tfloattype;
          fputyp : tfloattype;
          href : treference;
          href : treference;
-         old_allow_multi_pass2,
          releaseright : boolean;
          releaseright : boolean;
          len : aint;
          len : aint;
          r:Tregister;
          r:Tregister;
@@ -400,6 +399,7 @@ implementation
           in most cases we can process first the right node which contains
           in most cases we can process first the right node which contains
           the most complex code. Exceptions for this are:
           the most complex code. Exceptions for this are:
             - result is in flags, loading left will then destroy the flags
             - result is in flags, loading left will then destroy the flags
+            - result is a jump, loading left must be already done before the jump is made
             - result need reference count, when left points to a value used in
             - result need reference count, when left points to a value used in
               right then decreasing the refcnt on left can possibly release
               right then decreasing the refcnt on left can possibly release
               the memory before right increased the refcnt, result is that an
               the memory before right increased the refcnt, result is that an
@@ -408,21 +408,9 @@ implementation
 
 
            But not when the result is in the flags, then
            But not when the result is in the flags, then
           loading the left node afterwards can destroy the flags.
           loading the left node afterwards can destroy the flags.
-
-          when the right node returns as LOC_JUMP then we will generate
-          the following code:
-
-          rightnode
-          true:
-            leftnode
-            assign 1
-          false:
-            leftnode
-            assign 0
         }
         }
-        if (right.expectloc<>LOC_FLAGS) and
-           ((right.expectloc=LOC_JUMP) or
-            (right.nodetype=calln) or
+        if not(right.expectloc in [LOC_FLAGS,LOC_JUMP]) and
+           ((right.nodetype=calln) or
             (right.resulttype.def.needs_inittable) or
             (right.resulttype.def.needs_inittable) or
             (right.registersint>=left.registersint)) then
             (right.registersint>=left.registersint)) then
          begin
          begin
@@ -439,10 +427,7 @@ implementation
            if codegenerror then
            if codegenerror then
              exit;
              exit;
 
 
-           { We skip the generation of the left node when it's a jump, see
-             explanation above }
-           if (right.location.loc<>LOC_JUMP) and
-              not(nf_concat_string in flags) then
+           if not(nf_concat_string in flags) then
             begin
             begin
               { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
               { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
               { can be false                                             }
               { can be false                                             }
@@ -509,7 +494,8 @@ implementation
             tcgtemprefnode(left).changelocation(right.location.reference);
             tcgtemprefnode(left).changelocation(right.location.reference);
           end
           end
         { shortstring assignments are handled separately }
         { shortstring assignments are handled separately }
-        else *) if is_shortstring(left.resulttype.def) then
+        else *)
+        if is_shortstring(left.resulttype.def) then
           begin
           begin
             {
             {
               we can get here only in the following situations
               we can get here only in the following situations
@@ -666,22 +652,10 @@ implementation
               LOC_JUMP :
               LOC_JUMP :
                 begin
                 begin
                   objectlibrary.getlabel(hlabel);
                   objectlibrary.getlabel(hlabel);
-                  { generate the leftnode for the true case, and
-                    release the location }
                   cg.a_label(exprasmlist,truelabel);
                   cg.a_label(exprasmlist,truelabel);
-                  secondpass(left);
-                  if codegenerror then
-                    exit;
                   cg.a_load_const_loc(exprasmlist,1,left.location);
                   cg.a_load_const_loc(exprasmlist,1,left.location);
                   cg.a_jmp_always(exprasmlist,hlabel);
                   cg.a_jmp_always(exprasmlist,hlabel);
-                  { generate the leftnode for the false case }
                   cg.a_label(exprasmlist,falselabel);
                   cg.a_label(exprasmlist,falselabel);
-                  old_allow_multi_pass2:=allow_multi_pass2;
-                  allow_multi_pass2:=true;
-                  secondpass(left);
-                  allow_multi_pass2:=old_allow_multi_pass2;
-                  if codegenerror then
-                    exit;
                   cg.a_load_const_loc(exprasmlist,0,left.location);
                   cg.a_load_const_loc(exprasmlist,0,left.location);
                   cg.a_label(exprasmlist,hlabel);
                   cg.a_label(exprasmlist,hlabel);
                 end;
                 end;
@@ -956,7 +930,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.139  2005-02-14 17:13:06  peter
+  Revision 1.140  2005-04-08 15:18:08  peter
+  remove multiple pass2 calls. It is not supported anymore by all nodes (ttempcreatenode)
+
+  Revision 1.139  2005/02/14 17:13:06  peter
     * truncate log
     * truncate log
 
 
   Revision 1.138  2005/02/13 19:57:15  florian
   Revision 1.138  2005/02/13 19:57:15  florian

+ 5 - 4
compiler/pass_2.pas

@@ -34,7 +34,6 @@ uses
        tflowcontrol = set of tenumflowcontrol;
        tflowcontrol = set of tenumflowcontrol;
 
 
     var
     var
-       allow_multi_pass2 : boolean;
        flowcontrol : tflowcontrol;
        flowcontrol : tflowcontrol;
 
 
 { produces the actual code }
 { produces the actual code }
@@ -169,8 +168,7 @@ implementation
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
             if (p.expectloc=LOC_INVALID) then
             if (p.expectloc=LOC_INVALID) then
               Comment(V_Warning,'ExpectLoc is not set before secondpass: '+nodetype2str[p.nodetype]);
               Comment(V_Warning,'ExpectLoc is not set before secondpass: '+nodetype2str[p.nodetype]);
-            if (not allow_multi_pass2) and
-               (p.location.loc<>LOC_INVALID) then
+            if (p.location.loc<>LOC_INVALID) then
               Comment(V_Warning,'Location.Loc is already set before secondpass: '+nodetype2str[p.nodetype]);
               Comment(V_Warning,'Location.Loc is already set before secondpass: '+nodetype2str[p.nodetype]);
             if (cs_asm_nodes in aktglobalswitches) then
             if (cs_asm_nodes in aktglobalswitches) then
               logsecond(p.nodetype,true);
               logsecond(p.nodetype,true);
@@ -215,7 +213,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.77  2005-02-14 17:13:07  peter
+  Revision 1.78  2005-04-08 15:18:08  peter
+  remove multiple pass2 calls. It is not supported anymore by all nodes (ttempcreatenode)
+
+  Revision 1.77  2005/02/14 17:13:07  peter
     * truncate log
     * truncate log
 
 
 }
 }