Skip to contentSkip to conversation

Fix qemu_ld64 on arm

PATCH Applied Pablo Virolainen 3 participants 5 messages Feb 24, 2009 – Mar 10, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix qemu_ld64 on arm

Emulating fldl on arm doesn't seem to work too well. It's the way qemu_ld64 is translated to arm instructions.

        tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
        tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);

Consider case where data_reg==0, data_reg2==1, and addr_reg==0. First load overwrited addr_reg. So let's put an if (data_ref==addr_reg).

tcg-target.c (working copy) renamed from tcg-target.c (revision 6642) +8 -2
Index: tcg-target.c
===================================================================
@@ -1011,8 +1011,14 @@
     case 3:
         /* TODO: use block load -
          * check that data_reg2 > data_reg or the other way */
-        tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
-        tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+
+        if (data_reg==addr_reg) {
+            tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+            tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
+        } else {
+            tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
+            tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+        }
         break;
     }
 #endif
#1 lore raw
Quoted 6 lines · Pablo Virolainen

Emulating fldl on arm doesn't seem to work too well. It's the way qemu_ld64 is translated to arm instructions.

       tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0); tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);

It seems you are using an old version of qemu. Taking a quick look at current svn, I think your patch is not needed anymore.

Laurent

Quoted 29 lines

Consider case where data_reg==0, data_reg2==1, and addr_reg==0. First load overwrited addr_reg. So let's put an if (data_ref==addr_reg).

Index: tcg-target.c
===================================================================

tcg-target.c        (working copy) renamed from tcg-target.c        (revision 6642) +0 -0
@@ -1011,8 +1011,14 @@

    case 3:
        /* TODO: use block load -
         * check that data_reg2 > data_reg or the other way */
-        tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
-        tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4); +
+        if (data_reg==addr_reg) {
+            tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+            tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
+        } else {
+            tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
+            tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+        }
        break;
    }
 #endif

#2 lore raw

Laurent Desnogues kirjoitti:

Quoted 10 lines
Quoted 5 lines · Pablo Virolainen

Emulating fldl on arm doesn't seem to work too well. It's the way qemu_ld64 is translated to arm instructions.

       tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
       tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);

It seems you are using an old version of qemu. Taking a quick look at current svn, I think your patch is not needed anymore.

So I should get the source from other source than
svn co svn://svn.savannah.nongnu.org/qemu/trunk ?

Pablo

#3 lore raw
Quoted 9 lines · Pablo Virolainen

Laurent Desnogues kirjoitti:

Quoted 8 lines
Quoted 5 lines · Pablo Virolainen

Emulating fldl on arm doesn't seem to work too well. It's the way qemu_ld64
is translated to arm instructions.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

      tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0); tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);

It seems you are using an old version of qemu.  Taking a quick look at current svn, I think your patch is not needed anymore.

So I should get the source from other source than
svn co svn://svn.savannah.nongnu.org/qemu/trunk ?

OK, I am gonna get some more coffee... I mistakenly thought you were talking about ARM front-end. Sorry for the confusion.

Your patch looks correct (but bear in mind, that I did not take more coffee and that I never played with ARM back-end).

Laurent

#4 lore raw
In reply to Pablo Virolainen
Quoted 10 lines · Pablo Virolainen

Emulating fldl on arm doesn't seem to work too well. It's the way qemu_ld64 is translated to arm instructions.

        tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
        tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);

Consider case where data_reg==0, data_reg2==1, and addr_reg==0. First load overwrited addr_reg. So let's put an if (data_ref==addr_reg).

Thanks, applied.

Quoted 24 lines

Index: tcg-target.c
===================================================================

tcg-target.c (working copy) renamed from tcg-target.c (revision 6642) +8 -2
@@ -1011,8 +1011,14 @@
     case 3:
         /* TODO: use block load -
          * check that data_reg2 > data_reg or the other way */
-        tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
-        tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+
+        if (data_reg==addr_reg) {
+            tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+            tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
+        } else {
+            tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
+            tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, 4);
+        }
         break;
     }
 #endif
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net