Skip to contentSkip to conversation

tci: Add implementation of rotl_i64, rotr_i64

PATCH In review Stefan Weil 3 participants 6 messages Sep 4, 2013 – Sep 9, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tci: Add implementation of rotl_i64, rotr_i64

It is used by qemu-ppc64 when running Debian's busybox-static.

---

This patch is also useful for QEMU 1.6.

 tcg/tci/tcg-target.c |    1 -
 tci.c                |   10 +++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
tcg/tci/tcg-target.c +0 -1
index 233ab3b..4976bec 100644
@@ -670,7 +670,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
     case INDEX_op_shl_i64:
     case INDEX_op_shr_i64:
     case INDEX_op_sar_i64:
-        /* TODO: Implementation of rotl_i64, rotr_i64 missing in tci.c. */
     case INDEX_op_rotl_i64:     /* Optional (TCG_TARGET_HAS_rot_i64). */
     case INDEX_op_rotr_i64:     /* Optional (TCG_TARGET_HAS_rot_i64). */
         tcg_out_r(s, args[0]);
tci.c +9 -1
index 18c888e..94b7851 100644
@@ -952,8 +952,16 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
             break;
 #if TCG_TARGET_HAS_rot_i64
         case INDEX_op_rotl_i64:
+            t0 = *tb_ptr++;
+            t1 = tci_read_ri64(&tb_ptr);
+            t2 = tci_read_ri64(&tb_ptr);
+            tci_write_reg64(t0, (t1 << t2) | (t1 >> (64 - t2)));
+            break;
         case INDEX_op_rotr_i64:
-            TODO();
+            t0 = *tb_ptr++;
+            t1 = tci_read_ri64(&tb_ptr);
+            t2 = tci_read_ri64(&tb_ptr);
+            tci_write_reg64(t0, (t1 >> t2) | (t1 << (64 - t2)));
             break;
 #endif
 #if TCG_TARGET_HAS_deposit_i64
Signature · 1 line
1.7.10.4
#1 lore raw

Am 04.09.2013 22:49, schrieb Stefan Weil:

Quoted 6 lines

It is used by qemu-ppc64 when running Debian's busybox-static.

---

This patch is also useful for QEMU 1.6.

... so I should have added qemu-stable. Done now.

Quoted 39 lines
 tcg/tci/tcg-target.c |    1 -
 tci.c                |   10 +++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
tcg/tci/tcg-target.c +0 -1
index 233ab3b..4976bec 100644
@@ -670,7 +670,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
     case INDEX_op_shl_i64:
     case INDEX_op_shr_i64:
     case INDEX_op_sar_i64:
-        /* TODO: Implementation of rotl_i64, rotr_i64 missing in tci.c. */
     case INDEX_op_rotl_i64:     /* Optional (TCG_TARGET_HAS_rot_i64). */
     case INDEX_op_rotr_i64:     /* Optional (TCG_TARGET_HAS_rot_i64). */
         tcg_out_r(s, args[0]);
tci.c +9 -1
index 18c888e..94b7851 100644
@@ -952,8 +952,16 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
             break;
 #if TCG_TARGET_HAS_rot_i64
         case INDEX_op_rotl_i64:
+            t0 = *tb_ptr++;
+            t1 = tci_read_ri64(&tb_ptr);
+            t2 = tci_read_ri64(&tb_ptr);
+            tci_write_reg64(t0, (t1 << t2) | (t1 >> (64 - t2)));
+            break;
         case INDEX_op_rotr_i64:
-            TODO();
+            t0 = *tb_ptr++;
+            t1 = tci_read_ri64(&tb_ptr);
+            t2 = tci_read_ri64(&tb_ptr);
+            tci_write_reg64(t0, (t1 >> t2) | (t1 << (64 - t2)));
             break;
 #endif
 #if TCG_TARGET_HAS_deposit_i64
#2 lore raw
Quoted 10 lines · Stefan Weil

Am 04.09.2013 22:49, schrieb Stefan Weil:

Quoted 6 lines

It is used by qemu-ppc64 when running Debian's busybox-static.

---

This patch is also useful for QEMU 1.6.

... so I should have added qemu-stable. Done now.

Why is it needed for qemu-stable? It should only improve performance, as these two ops are not mandatory ops. In general I don't think we should have performance improvements in a stable minor release (unless of course it's a big regression from previous).

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#3 lore raw

Am 09.09.2013 16:53, schrieb Aurelien Jarno:

Quoted 7 lines · Stefan Weil
Quoted 6 lines

Am 04.09.2013 22:49, schrieb Stefan Weil:

Quoted 5 lines

It is used by qemu-ppc64 when running Debian's busybox-static.

---

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This patch is also useful for QEMU 1.6.

... so I should have added qemu-stable. Done now.

Why is it needed for qemu-stable? It should only improve performance, as these two ops are not mandatory ops. In general I don't think we should have performance improvements in a stable minor release (unless of course it's a big regression from previous).

Hi Aurelien,

tci has always set TCG_TARGET_HAS_rot_i64, and target-ppc64 uses the rotl_i64 and rotr_i64 TCG opcodes.

The old implementation just triggered a TODO assertion. That's how I implemented TCI: I started with TODO assertions for all opcodes and replaced them by real code as soon as I got a test case which used them. Now I have a test case :-)

=> It's not a performance issue, but fixes a fatal assertion. => It should be used in 1.6.

Regards,
Stefan

#4 lore raw
Quoted 18 lines · Stefan Weil

Am 09.09.2013 16:53, schrieb Aurelien Jarno:

Quoted 7 lines · Stefan Weil
Quoted 6 lines

Am 04.09.2013 22:49, schrieb Stefan Weil:

Quoted 5 lines

It is used by qemu-ppc64 when running Debian's busybox-static.

---

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This patch is also useful for QEMU 1.6.

... so I should have added qemu-stable. Done now.

Why is it needed for qemu-stable? It should only improve performance, as these two ops are not mandatory ops. In general I don't think we should have performance improvements in a stable minor release (unless of course it's a big regression from previous).

Hi Aurelien,

Quoted 7 lines

tci has always set TCG_TARGET_HAS_rot_i64, and target-ppc64 uses the rotl_i64 and rotr_i64 TCG opcodes.

The old implementation just triggered a TODO assertion. That's how I implemented TCI: I started with TODO assertions for all opcodes and replaced them by real code as soon as I got a test case which used them. Now I have a test case :-)

Ok, so it might be a good idea to review the remaining non-implemented optional ops and to disable them to avoid that in the future.

Quoted 3 lines

=> It's not a performance issue, but fixes a fatal assertion. => It should be used in 1.6.

It should probably also be used in older versions, as rotl and rotr have been used by various targets for a few years (at least since version 0.10.0, probably even before).

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net