소스 검색

Fix a_load64_reg_ref and a_load64_ref_reg mips methods

(cherry picked from commit d18ff64ed7931161230f036170af3f7998d6611f)
Pierre Muller 2 년 전
부모
커밋
2640e77307
1개의 변경된 파일48개의 추가작업 그리고 45개의 파일을 삭제
  1. 48 45
      compiler/mips/cgcpu.pas

+ 48 - 45
compiler/mips/cgcpu.pas

@@ -1701,36 +1701,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));
@@ -1742,9 +1723,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));
@@ -1758,50 +1756,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));