Преглед изворни кода

* reworked usage of tcgnotnode.handle_locjump

git-svn-id: trunk@46275 -
florian пре 5 година
родитељ
комит
28f25b2df0

+ 1 - 1
compiler/aarch64/ncpumat.pas

@@ -214,9 +214,9 @@ implementation
 
     procedure taarch64notnode.second_boolean;
       begin
+        secondpass(left);
         if not handle_locjump then
           begin
-            secondpass(left);
             case left.location.loc of
               LOC_FLAGS :
                 begin

+ 1 - 4
compiler/arm/narmmat.pas

@@ -315,12 +315,9 @@ implementation
       var
         tmpreg : TRegister;
       begin
-        { if the location is LOC_JUMP, we do the secondpass after the
-          labels are allocated
-        }
+        secondpass(left);
         if not handle_locjump then
           begin
-            secondpass(left);
             case left.location.loc of
               LOC_FLAGS :
                 begin

+ 1 - 1
compiler/avr/navrmat.pas

@@ -63,9 +63,9 @@ implementation
         i : longint;
         falselabel,truelabel,skiplabel: TAsmLabel;
       begin
+        secondpass(left);
         if not handle_locjump then
           begin
-            secondpass(left);
             { short code? }
             if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG]) and
               (left.location.sreg.bitlen=1) then

+ 1 - 1
compiler/m68k/n68kmat.pas

@@ -76,9 +76,9 @@ implementation
         hreg: tregister;
         opsize : tcgsize;
       begin
+        secondpass(left);
         if not handle_locjump then
           begin
-            secondpass(left);
             opsize:=def_cgsize(resultdef);
 
             if ((left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and needs_unaligned(left.location.reference.alignment,opsize)) then

+ 21 - 21
compiler/mips/ncpumat.pas

@@ -241,31 +241,31 @@ procedure tMIPSELnotnode.second_boolean;
 var
   tmpreg : TRegister;
 begin
+  secondpass(left);
   if not handle_locjump then
-  begin
-    secondpass(left);
-    case left.location.loc of
-      LOC_REGISTER, LOC_CREGISTER, LOC_REFERENCE, LOC_CREFERENCE,
-      LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF:
-      begin
-        hlcg.location_force_reg(current_asmdata.CurrAsmList, left.location, left.resultdef, left.resultdef, True);
-        location_reset(location,LOC_FLAGS,OS_NO);
-        location.resflags.reg2:=NR_R0;
-        location.resflags.cond:=OC_EQ;
-        if is_64bit(resultdef) then
-          begin
-            tmpreg:=cg.GetIntRegister(current_asmdata.CurrAsmList,OS_INT);
-            { OR low and high parts together }
-            current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_OR,tmpreg,left.location.register64.reglo,left.location.register64.reghi));
-            location.resflags.reg1:=tmpreg;
-          end
+    begin
+      case left.location.loc of
+        LOC_REGISTER, LOC_CREGISTER, LOC_REFERENCE, LOC_CREFERENCE,
+        LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF:
+        begin
+          hlcg.location_force_reg(current_asmdata.CurrAsmList, left.location, left.resultdef, left.resultdef, True);
+          location_reset(location,LOC_FLAGS,OS_NO);
+          location.resflags.reg2:=NR_R0;
+          location.resflags.cond:=OC_EQ;
+          if is_64bit(resultdef) then
+            begin
+              tmpreg:=cg.GetIntRegister(current_asmdata.CurrAsmList,OS_INT);
+              { OR low and high parts together }
+              current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_OR,tmpreg,left.location.register64.reglo,left.location.register64.reghi));
+              location.resflags.reg1:=tmpreg;
+            end
+          else
+            location.resflags.reg1:=left.location.register;
+        end;
         else
-          location.resflags.reg1:=left.location.register;
+          internalerror(2003042401);
       end;
-      else
-        internalerror(2003042401);
     end;
-  end;
 end;
 
 

+ 1 - 3
compiler/ncgmat.pas

@@ -656,11 +656,9 @@ implementation
 
     function tcgnotnode.handle_locjump: boolean;
       begin
-        result:=(left.expectloc=LOC_JUMP);
+        result:=left.location.loc=LOC_JUMP;
         if result then
           begin
-            secondpass(left);
-
             if is_constboolnode(left) then
               internalerror(2014010101);
             if left.location.loc<>LOC_JUMP then

+ 3 - 4
compiler/powerpc/nppcmat.pas

@@ -515,11 +515,12 @@ implementation
       var
          tmpreg: tregister;
       begin
-         if is_boolean(resultdef) then
+        secondpass(left);
+        if is_boolean(resultdef) then
           begin
             if not handle_locjump then
               begin
-                secondpass(left);
+                { handle_locjump does call secondpass }
                 case left.location.loc of
                   LOC_FLAGS :
                     begin
@@ -555,7 +556,6 @@ implementation
           end
          else if is_64bitint(left.resultdef) then
            begin
-             secondpass(left);
              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
              location_copy(location,left.location);
              { perform the NOT operation }
@@ -566,7 +566,6 @@ implementation
            end
          else
            begin
-             secondpass(left);
              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
              location_copy(location,left.location);
              location.loc := LOC_REGISTER;

+ 2 - 2
compiler/powerpc64/nppcmat.pas

@@ -377,11 +377,12 @@ end;
 procedure tppcnotnode.pass_generate_code;
 
 begin
+  secondpass(left);
   if is_boolean(resultdef) then
   begin
     if not handle_locjump then
     begin
-      secondpass(left);
+      { handle_locjump does call secondpass }
       case left.location.loc of
         LOC_FLAGS:
           begin
@@ -408,7 +409,6 @@ begin
   end
   else
   begin
-    secondpass(left);
     hlcg.location_force_reg(current_asmdata.CurrAsmList, left.location,
       left.resultdef, left.resultdef, true);
     location_copy(location, left.location);

+ 1 - 1
compiler/riscv32/nrv32mat.pas

@@ -63,9 +63,9 @@ implementation
       var
         tlabel, flabel: tasmlabel;
       begin
+        secondpass(left);
         if not handle_locjump then
           begin
-            secondpass(left);
             case left.location.loc of
               LOC_FLAGS :
                 begin

+ 1 - 1
compiler/riscv64/nrv64mat.pas

@@ -67,9 +67,9 @@ implementation
       var
         tlabel, flabel: tasmlabel;
       begin
+        secondpass(left);
         if not handle_locjump then
           begin
-            secondpass(left);
             case left.location.loc of
               LOC_FLAGS :
                 begin

+ 1 - 1
compiler/sparcgen/ncpumat.pas

@@ -449,9 +449,9 @@ implementation
 
     procedure tsparcnotnode.second_boolean;
       begin
+        secondpass(left);
         if not handle_locjump then
           begin
-            secondpass(left);
             case left.location.loc of
               LOC_FLAGS :
                 begin

+ 1 - 4
compiler/x86/nx86mat.pas

@@ -247,12 +247,9 @@ interface
       begin
         opsize:=def_cgsize(resultdef);
 
+        secondpass(left);
         if not handle_locjump then
          begin
-           { the second pass could change the location of left }
-           { if it is a register variable, so we've to do      }
-           { this before the case statement                    }
-           secondpass(left);
            case left.location.loc of
              LOC_FLAGS :
                begin

+ 1 - 5
compiler/z80/nz80mat.pas

@@ -59,13 +59,9 @@ implementation
       var
         i: Integer;
       begin
+        secondpass(left);
         if not handle_locjump then
           begin
-            { the second pass could change the location of left }
-            { if it is a register variable, so we've to do      }
-            { this before the case statement                    }
-            secondpass(left);
-
             if left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
               hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
             case left.location.loc of