Browse Source

* Fix 64-bit OP_ADD and OP_SUB operations (no overflow support yet)

git-svn-id: trunk@22225 -
pierre 13 years ago
parent
commit
9ad6285fe2
1 changed files with 12 additions and 6 deletions
  1. 12 6
      compiler/mips/cgcpu.pas

+ 12 - 6
compiler/mips/cgcpu.pas

@@ -2089,10 +2089,13 @@ begin
     OP_ADD:
     OP_ADD:
       begin
       begin
         tmpreg1 := cg.GetIntRegister(list,OS_S32);
         tmpreg1 := cg.GetIntRegister(list,OS_S32);
-        list.concat(taicpu.op_reg_reg_reg(A_ADDU, regdst.reglo, regsrc2.reglo, regsrc1.reglo));
-        list.concat(taicpu.op_reg_reg_reg(A_SLTU, tmpreg1, regdst.reglo, regsrc2.reglo));
+        tmpreg2 := cg.GetIntRegister(list,OS_S32);
+        // destreg.reglo could be regsrc1.reglo or regsrc2.reglo
+        list.concat(taicpu.op_reg_reg_reg(A_ADDU, tmpreg1, regsrc2.reglo, regsrc1.reglo));
+        list.concat(taicpu.op_reg_reg_reg(A_SLTU, tmpreg2, tmpreg1, regsrc2.reglo));
+        list.concat(taicpu.op_reg_reg(A_MOVE, regdst.reglo, tmpreg1));
         list.concat(taicpu.op_reg_reg_reg(A_ADDU, regdst.reghi, regsrc2.reghi, regsrc1.reghi));
         list.concat(taicpu.op_reg_reg_reg(A_ADDU, regdst.reghi, regsrc2.reghi, regsrc1.reghi));
-        list.concat(taicpu.op_reg_reg_reg(A_ADDU, regdst.reghi, regdst.reghi, tmpreg1));
+        list.concat(taicpu.op_reg_reg_reg(A_ADDU, regdst.reghi, regdst.reghi, tmpreg2));
         exit;
         exit;
       end;
       end;
     OP_AND:
     OP_AND:
@@ -2110,10 +2113,13 @@ begin
     OP_SUB:
     OP_SUB:
     begin
     begin
         tmpreg1 := cg.GetIntRegister(list,OS_S32);
         tmpreg1 := cg.GetIntRegister(list,OS_S32);
-        list.concat(taicpu.op_reg_reg_reg(A_SUBU, regdst.reglo, regsrc2.reglo, regsrc1.reglo));
-        list.concat(taicpu.op_reg_reg_reg(A_SLTU, tmpreg1, regsrc2.reglo, regdst.reglo));
+        tmpreg2 := cg.GetIntRegister(list,OS_S32);
+        // destreg.reglo could be regsrc1.reglo or regsrc2.reglo
+        list.concat(taicpu.op_reg_reg_reg(A_SUBU,tmpreg1, regsrc2.reglo, regsrc1.reglo));
+        list.concat(taicpu.op_reg_reg_reg(A_SLTU, tmpreg2, regsrc2.reglo, regsrc1.reglo));
+        list.concat(taicpu.op_reg_reg(A_MOVE, regdst.reglo, tmpreg1));
+        list.concat(taicpu.op_reg_reg_reg(A_ADDU, regsrc1.reghi, regsrc1.reghi, tmpreg2));
         list.concat(taicpu.op_reg_reg_reg(A_SUBU, regdst.reghi, regsrc2.reghi, regsrc1.reghi));
         list.concat(taicpu.op_reg_reg_reg(A_SUBU, regdst.reghi, regsrc2.reghi, regsrc1.reghi));
-        list.concat(taicpu.op_reg_reg_reg(A_SUBU, regdst.reghi, regdst.reghi, tmpreg1));
         exit;
         exit;
     end;
     end;
     OP_XOR:
     OP_XOR: