Explorar el Código

Fix comparisons (aka usage of flag/CCR register)

m68k/aasmcpu.pas, taicpu.spilling_get_operation_type:
  * add all Sxx instructions as "operand_write" instructions

m68k/n68kadd.pas, t68kaddnode.getresflags:
  * use the correct operation in case of swapped nodes

m68k/cgcpu.pas, tcg68k.g_flags2reg:
  - don't move a 0 to the register, because this will CLR it and thus the flags won't be valid anymore...
  - NEG would have been the wrong operation (NOT would have been correct), but it isn't needed anyway...
  * simplify the method by handling the address register case only when necessary

git-svn-id: trunk@23383 -
svenbarth hace 12 años
padre
commit
ccecf2c13c
Se han modificado 3 ficheros con 24 adiciones y 52 borrados
  1. 2 1
      compiler/m68k/aasmcpu.pas
  2. 14 43
      compiler/m68k/cgcpu.pas
  3. 8 8
      compiler/m68k/n68kadd.pas

+ 2 - 1
compiler/m68k/aasmcpu.pas

@@ -528,7 +528,8 @@ type
             end;
             end;
           A_TST,A_CMP,A_CMPI:
           A_TST,A_CMP,A_CMPI:
             result:=operand_read;
             result:=operand_read;
-          A_CLR, A_SXX:
+          A_CLR, A_SXX, A_SEQ, A_SNE, A_SLT, A_SLE, A_SGT, A_SGE, A_SCS, A_SCC,
+          A_SMI, A_SPL, A_SF, A_ST, A_SVS, A_SVC, A_SHI, A_SLS:
             result:=operand_write;
             result:=operand_write;
           A_NEG, A_EXT, A_EXTB, A_NOT, A_NEGX:
           A_NEG, A_EXT, A_EXTB, A_NOT, A_NEGX:
             result:=operand_readwrite;
             result:=operand_readwrite;

+ 14 - 43
compiler/m68k/cgcpu.pas

@@ -1449,51 +1449,22 @@ unit cgcpu;
        begin
        begin
           { move to a Dx register? }
           { move to a Dx register? }
           if (isaddressregister(reg)) then
           if (isaddressregister(reg)) then
-            begin
-              hreg := getintregister(list,OS_INT);
-              a_load_const_reg(list,size,0,hreg);
-              ai:=Taicpu.Op_reg(A_Sxx,S_B,hreg);
-              ai.SetCondition(flags_to_cond(f));
-              list.concat(ai);
-
-              if (current_settings.cputype = cpu_ColdFire) then
-                begin
-                 { neg.b does not exist on the Coldfire
-                   so we need to sign extend the value
-                   before doing a neg.l
-                 }
-                 list.concat(taicpu.op_reg(A_EXTB,S_L,hreg));
-                 list.concat(taicpu.op_reg(A_NEG,S_L,hreg));
-                end
-              else
-                begin
-                  list.concat(taicpu.op_reg(A_NEG,S_B,hreg));
-                end;
-             instr:=taicpu.op_reg_reg(A_MOVE,S_L,hreg,reg);
-             add_move_instruction(instr);
-             list.concat(instr);
-            end
+            hreg:=getintregister(list,OS_INT)
           else
           else
-          begin
-            a_load_const_reg(list,size,0,reg);
-            ai:=Taicpu.Op_reg(A_Sxx,S_B,reg);
-            ai.SetCondition(flags_to_cond(f));
-            list.concat(ai);
+            hreg:=reg;
 
 
-            if (current_settings.cputype = cpu_ColdFire) then
-              begin
-                 { neg.b does not exist on the Coldfire
-                   so we need to sign extend the value
-                   before doing a neg.l
-                 }
-                 list.concat(taicpu.op_reg(A_EXTB,S_L,reg));
-                 list.concat(taicpu.op_reg(A_NEG,S_L,reg));
-              end
-            else
-              begin
-               list.concat(taicpu.op_reg(A_NEG,S_B,reg));
-              end;
-          end;
+          ai:=Taicpu.Op_reg(A_Sxx,S_B,hreg);
+          ai.SetCondition(flags_to_cond(f));
+          list.concat(ai);
+
+          list.concat(taicpu.op_reg(A_EXTB,S_L,hreg));
+
+          if hreg<>reg then
+            begin
+              instr:=taicpu.op_reg_reg(A_MOVE,S_L,hreg,reg);
+              add_move_instruction(instr);
+              list.concat(instr);
+            end;
        end;
        end;
 
 
 
 

+ 8 - 8
compiler/m68k/n68kadd.pas

@@ -267,10 +267,10 @@ implementation
              begin
              begin
                 if nf_swapped in flags then
                 if nf_swapped in flags then
                   case nodetype of
                   case nodetype of
-                     ltn : getresflags:=F_G;
-                     lten : getresflags:=F_GE;
-                     gtn : getresflags:=F_L;
-                     gten : getresflags:=F_LE;
+                     ltn : getresflags:=F_GE;
+                     lten : getresflags:=F_G;
+                     gtn : getresflags:=F_LE;
+                     gten : getresflags:=F_L;
                   end
                   end
                 else
                 else
                   case nodetype of
                   case nodetype of
@@ -284,10 +284,10 @@ implementation
              begin
              begin
                 if nf_swapped in flags then
                 if nf_swapped in flags then
                   case nodetype of
                   case nodetype of
-                     ltn : getresflags:=F_A;
-                     lten : getresflags:=F_AE;
-                     gtn : getresflags:=F_B;
-                     gten : getresflags:=F_BE;
+                     ltn : getresflags:=F_AE;
+                     lten : getresflags:=F_A;
+                     gtn : getresflags:=F_BE;
+                     gten : getresflags:=F_B;
                   end
                   end
                 else
                 else
                   case nodetype of
                   case nodetype of