Browse Source

Fix a_load64_reg_ref and a_load64_ref_reg mips methods

Pierre Muller 2 years ago
parent
commit
d18ff64ed7
1 changed files with 48 additions and 45 deletions
  1. 48 45
      compiler/mips/cgcpu.pas

+ 48 - 45
compiler/mips/cgcpu.pas

@@ -1761,36 +1761,17 @@ var
   tmpreg: tregister;
   incr: shortint;
 begin
-  if target_info.endian = endian_big then
-    begin
-      tmpreg := reg.reglo;
-      reg.reglo := reg.reghi;
-      reg.reghi := tmpreg;
-    end;
   tmpref := ref;
   tcgmips(cg).make_simple_ref(list,tmpref);
   if (ref.alignment <4) then
     begin
-      if target_info.endian = endian_big then
+      if target_info.endian = endian_little then
         begin
-          inc(tmpref.offset,3);
+          inc(tmpref.offset,7);
 	  incr:=-1;
 	end
       else
         incr:=1;
-      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8));
-      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8));
-      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8));
-      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      if target_info.endian = endian_big then
-        inc(tmpref.offset,7);
       list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref));
       Inc(tmpref.offset,incr);
       list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8));
@@ -1802,9 +1783,26 @@ begin
       list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8));
       list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref));
       Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
+      Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8));
+      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
+      Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8));
+      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
+      Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8));
+      list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref));
+      Inc(tmpref.offset,incr);
     end
   else
     begin
+      if target_info.endian = endian_big then
+        begin
+          tmpreg := reg.reglo;
+          reg.reglo := reg.reghi;
+          reg.reghi := tmpreg;
+        end;
       list.concat(taicpu.op_reg_ref(A_SW,reg.reglo,tmpref));
       Inc(tmpref.offset, 4);
       list.concat(taicpu.op_reg_ref(A_SW,reg.reghi,tmpref));
@@ -1818,50 +1816,55 @@ var
   tmpreg: tregister;
   incr: shortint;
 begin
-  if target_info.endian = endian_big then
-    begin
-      tmpreg := reg.reglo;
-      reg.reglo := reg.reghi;
-      reg.reghi := tmpreg;
-    end;
   tmpref := ref;
   tcgmips(cg).make_simple_ref(list,tmpref);
   if (ref.alignment <4) then
     begin
-      if target_info.endian = endian_big then
+      tmpreg:=cg.getintregister(list,OS_INT);
+      if target_info.endian = endian_little then
         begin
-          inc(tmpref.offset,3);
+          inc(tmpref.offset,7);
 	  incr:=-1;
 	end
       else
         incr:=1;
-      list.concat(taicpu.op_reg_ref(A_LBU,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reglo,reg.reglo,8));
-      list.concat(taicpu.op_reg_ref(A_LBU,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reglo,reg.reglo,8));
-      list.concat(taicpu.op_reg_ref(A_LBU,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reglo,reg.reglo,8));
-      list.concat(taicpu.op_reg_ref(A_LBU,reg.reglo,tmpref));
-      Inc(tmpref.offset,incr);
-      if target_info.endian = endian_big then
-        inc(tmpref.offset,7);
       list.concat(taicpu.op_reg_ref(A_LBU,reg.reghi,tmpref));
       Inc(tmpref.offset,incr);
       list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reghi,reg.reghi,8));
-      list.concat(taicpu.op_reg_ref(A_LBU,reg.reghi,tmpref));
+      list.concat(taicpu.op_reg_ref(A_LBU,tmpreg,tmpref));
+      list.concat(taicpu.op_reg_reg_reg(A_ADDU,reg.reghi,reg.reghi,tmpreg));
       Inc(tmpref.offset,incr);
       list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reghi,reg.reghi,8));
-      list.concat(taicpu.op_reg_ref(A_LBU,reg.reghi,tmpref));
+      list.concat(taicpu.op_reg_ref(A_LBU,tmpreg,tmpref));
+      list.concat(taicpu.op_reg_reg_reg(A_ADDU,reg.reghi,reg.reghi,tmpreg));
       Inc(tmpref.offset,incr);
       list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reghi,reg.reghi,8));
-      list.concat(taicpu.op_reg_ref(A_LBU,reg.reghi,tmpref));
+      list.concat(taicpu.op_reg_ref(A_LBU,tmpreg,tmpref));
+      list.concat(taicpu.op_reg_reg_reg(A_ADDU,reg.reghi,reg.reghi,tmpreg));
+      Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_ref(A_LBU,reg.reglo,tmpref));
+      Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reglo,reg.reglo,8));
+      list.concat(taicpu.op_reg_ref(A_LBU,tmpreg,tmpref));
+      list.concat(taicpu.op_reg_reg_reg(A_ADDU,reg.reglo,reg.reglo,tmpreg));
+      Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reglo,reg.reglo,8));
+      list.concat(taicpu.op_reg_ref(A_LBU,tmpreg,tmpref));
+      list.concat(taicpu.op_reg_reg_reg(A_ADDU,reg.reglo,reg.reglo,tmpreg));
+      Inc(tmpref.offset,incr);
+      list.concat(taicpu.op_reg_reg_const(A_SLL,reg.reglo,reg.reglo,8));
+      list.concat(taicpu.op_reg_ref(A_LBU,tmpreg,tmpref));
+      list.concat(taicpu.op_reg_reg_reg(A_ADDU,reg.reglo,reg.reglo,tmpreg));
       Inc(tmpref.offset,incr);
     end
   else
     begin
+      if target_info.endian = endian_big then
+        begin
+          tmpreg := reg.reglo;
+          reg.reglo := reg.reghi;
+          reg.reghi := tmpreg;
+        end;
       list.concat(taicpu.op_reg_ref(A_LW,reg.reglo,tmpref));
       Inc(tmpref.offset, 4);
       list.concat(taicpu.op_reg_ref(A_LW,reg.reghi,tmpref));