Skip to contentSkip to conversation

PPC64: Add support for ldbrx and stdbrx instructions

PATCH In review David Gibson 5 participants 7 messages Feb 8, 2012 – Feb 9, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PPC64: Add support for ldbrx and stdbrx instructions

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

---
 target-ppc/translate.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
target-ppc/translate.c +30 -0
index b2780db..bb06b2b 100644
@@ -2897,6 +2897,18 @@ static inline void gen_qemu_ld32ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
 }
 GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER);
 
+#if defined(TARGET_PPC64)
+/* ldbrx */
+static inline void gen_qemu_ld64ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
+{
+    tcg_gen_qemu_ld64(arg1, arg2, ctx->mem_idx);
+    if (likely(!ctx->le_mode)) {
+        tcg_gen_bswap64_tl(arg1, arg1);
+    }
+}
+GEN_LDX(ldbr, ld64ur, 0x14, 0x10, PPC_64B);
+#endif  /* TARGET_PPC64 */
+
 /* sthbrx */
 static inline void gen_qemu_st16r(DisasContext *ctx, TCGv arg1, TCGv arg2)
 {
@@ -2927,6 +2939,22 @@ static inline void gen_qemu_st32r(DisasContext *ctx, TCGv arg1, TCGv arg2)
 }
 GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER);
 
+#if defined(TARGET_PPC64)
+/* stdbrx */
+static inline void gen_qemu_st64r(DisasContext *ctx, TCGv arg1, TCGv arg2)
+{
+    if (likely(!ctx->le_mode)) {
+        TCGv t0 = tcg_temp_new();
+        tcg_gen_bswap64_tl(t0, arg1);
+        tcg_gen_qemu_st64(t0, arg2, ctx->mem_idx);
+        tcg_temp_free(t0);
+    } else {
+        tcg_gen_qemu_st64(arg1, arg2, ctx->mem_idx);
+    }
+}
+GEN_STX(stdbr, st64r, 0x14, 0x14, PPC_64B);
+#endif  /* TARGET_PPC64 */
+
 /***                    Integer load and store multiple                    ***/
 
 /* lmw */
@@ -8849,6 +8877,7 @@ GEN_LDUX(lwa, ld32s, 0x15, 0x0B, PPC_64B)
 GEN_LDX(lwa, ld32s, 0x15, 0x0A, PPC_64B)
 GEN_LDUX(ld, ld64, 0x15, 0x01, PPC_64B)
 GEN_LDX(ld, ld64, 0x15, 0x00, PPC_64B)
+GEN_LDX(ldbr, ld64ur, 0x14, 0x10, PPC_64B)
 #endif
 GEN_LDX(lhbr, ld16ur, 0x16, 0x18, PPC_INTEGER)
 GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER)
@@ -8878,6 +8907,7 @@ GEN_STS(stw, st32, 0x04, PPC_INTEGER)
 #if defined(TARGET_PPC64)
 GEN_STUX(std, st64, 0x15, 0x05, PPC_64B)
 GEN_STX(std, st64, 0x15, 0x04, PPC_64B)
+GEN_STX(stdbr, st64r, 0x14, 0x14, PPC_64B)
 #endif
 GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER)
 GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER)
Signature · 1 line
1.7.8.3
#1 lore raw
Quoted 9 lines · David Gibson

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

---
 target-ppc/translate.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

I seem to recall that POWER5 machine i had access to didn't have ld/stdbrx while CBE did have it (or was it the other way around?) so question is - is PPC_64B sufficient?

[..snip..]

Quoted 11 lines

GEN_LDX(lhbr, ld16ur, 0x16, 0x18, PPC_INTEGER)
GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER)

target-ppc/translate.c +1 -0
@@ -8878,6 +8907,7 @@ GEN_STS(stw, st32, 0x04, PPC_INTEGER)
 #if defined(TARGET_PPC64)
 GEN_STUX(std, st64, 0x15, 0x05, PPC_64B)
 GEN_STX(std, st64, 0x15, 0x04, PPC_64B)
+GEN_STX(stdbr, st64r, 0x14, 0x14, PPC_64B)
 #endif
 GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER)
 GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER)
Signature · 1 line
mailto:[email protected]
#2 lore raw
Quoted 7 lines · malc
Quoted 5 lines · David Gibson

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

Quoted 8 lines
Quoted 4 lines
---
 target-ppc/translate.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

I seem to recall that POWER5 machine i had access to didn't have ld/stdbrx while CBE did have it (or was it the other way around?) so question is - is PPC_64B sufficient?

Ah, I think it's not. I think I spotted that before, but then forgot about it. Thanks for the reminder.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw

Am Wed, 8 Feb 2012 21:48:40 +1100
schrieb David Gibson <[email protected]>:

Quoted 13 lines · malc
Quoted 12 lines · David Gibson
Quoted 10 lines

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

---
 target-ppc/translate.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
Quoted 6 lines
Quoted 3 lines

I seem to recall that POWER5 machine i had access to didn't have ld/stdbrx while CBE did have it (or was it the other way around?) so question is - is PPC_64B sufficient?

Ah, I think it's not. I think I spotted that before, but then forgot about it. Thanks for the reminder.

Maybe it's a better idea to use PPC_64BX here? ... but that flag seems to be missing in POWERPC_INSNS_POWER7... David, could PPC_64BX also be included in that flag list?

Thomas

#4 lore raw
Quoted 20 lines · Thomas Huth

Am Wed, 8 Feb 2012 21:48:40 +1100
schrieb David Gibson <[email protected]>:

Quoted 17 lines · malc
Quoted 15 lines · David Gibson
Quoted 10 lines

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

---
 target-ppc/translate.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

I seem to recall that POWER5 machine i had access to didn't have ld/stdbrx while CBE did have it (or was it the other way around?) so question is - is PPC_64B sufficient?

Quoted 6 lines
Quoted 2 lines

Ah, I think it's not. I think I spotted that before, but then forgot about it. Thanks for the reminder.

Maybe it's a better idea to use PPC_64BX here? ... but that flag seems to be missing in POWERPC_INSNS_POWER7... David, could PPC_64BX also be included in that flag list?

Um.. what exactly do you mean by 64BX?

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw

Am Thu, 9 Feb 2012 11:26:09 +1100
schrieb David Gibson <[email protected]>:

Quoted 21 lines · Thomas Huth
Quoted 20 lines

Am Wed, 8 Feb 2012 21:48:40 +1100
schrieb David Gibson <[email protected]>:

Quoted 17 lines · malc
Quoted 15 lines · David Gibson
Quoted 10 lines

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

---
 target-ppc/translate.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

I seem to recall that POWER5 machine i had access to didn't have ld/stdbrx while CBE did have it (or was it the other way around?) so question is - is PPC_64B sufficient?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Ah, I think it's not. I think I spotted that before, but then forgot about it. Thanks for the reminder.

Maybe it's a better idea to use PPC_64BX here? ... but that flag seems to be missing in POWERPC_INSNS_POWER7... David, could PPC_64BX also be included in that flag list?

Um.. what exactly do you mean by 64BX?

There is a definition in target-ppc/cpu.h:

    /*   New 64 bits extensions (PowerPC 2.0x)     */
    PPC_64BX           = 0x0000000000000040ULL,

According to the comment, I thought the PPC_64BX might be designed for new 64-bit instructions?

Thomas

#6 lore raw
Quoted 34 lines · Thomas Huth

Am Thu, 9 Feb 2012 11:26:09 +1100
schrieb David Gibson <[email protected]>:

Quoted 21 lines · Thomas Huth
Quoted 20 lines

Am Wed, 8 Feb 2012 21:48:40 +1100
schrieb David Gibson <[email protected]>:

Quoted 17 lines · malc
Quoted 15 lines · David Gibson
Quoted 10 lines

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

---
target-ppc/translate.c | 30 ++++++++++++++++++++++++++++++

1 files changed, 30 insertions(+), 0 deletions(-)

I seem to recall that POWER5 machine i had access to didn't have ld/stdbrx while CBE did have it (or was it the other way around?) so question is - is PPC_64B sufficient?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Ah, I think it's not. I think I spotted that before, but then forgot about it. Thanks for the reminder.

Maybe it's a better idea to use PPC_64BX here? ... but that flag seems to be missing in POWERPC_INSNS_POWER7... David, could PPC_64BX also be included in that flag list?

Um.. what exactly do you mean by 64BX?

Quoted 7 lines

There is a definition in target-ppc/cpu.h:

   /*   New 64 bits extensions (PowerPC 2.0x)     */
   PPC_64BX           = 0x0000000000000040ULL,

According to the comment, I thought the PPC_64BX might be designed for new 64-bit instructions?

Well, we need to be a bit more specific here to know what we're implementing. The flag above just indicates the lq opcode:

target-ppc/translate.c:GEN_HANDLER(lq, 0x38, 0xFF, 0xFF, 0x00000000, PPC_64BX),

So how about we create a new PPC2 flag for BRX and add that in POWER7 INSNS? If you could find out if Cell also supports these instructions, that'd be great. I don't have a 2.05 spec handy and 2.04 doesn't implement it yet.

Alex