Skip to contentSkip to conversation

PPC: Add wrapper for target long DCR operations

PATCH Applied Alexander Graf 3 participants 8 messages Jan 1, 2010 – Feb 6, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PPC: Add wrapper for target long DCR operations

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

---
 target-ppc/cpu.h       |    2 ++
 target-ppc/helper.h    |    4 ++--
 target-ppc/op_helper.c |   10 ++++++++++
 target-ppc/translate.c |   12 ++++++------
 4 files changed, 20 insertions(+), 8 deletions(-)
target-ppc/cpu.h +2 -0
index d15bba1..60a8b68 100644
@@ -733,6 +733,8 @@ void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs);
 void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
+void helper_store_dcr (uint32_t dcrn, uint32_t val);
+uint32_t helper_load_dcr (uint32_t dcrn);
 
 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 
target-ppc/helper.h +2 -2
index 40d4ced..86f0af7 100644
@@ -359,8 +359,8 @@ DEF_HELPER_2(divo, tl, tl, tl)
 DEF_HELPER_2(divs, tl, tl, tl)
 DEF_HELPER_2(divso, tl, tl, tl)
 
-DEF_HELPER_1(load_dcr, i32, i32);
-DEF_HELPER_2(store_dcr, void, i32, i32)
+DEF_HELPER_1(load_dcr_tl, tl, tl);
+DEF_HELPER_2(store_dcr_tl, void, tl, tl)
 
 DEF_HELPER_1(load_dump_spr, void, i32)
 DEF_HELPER_1(store_dump_spr, void, i32)
target-ppc/op_helper.c +10 -0
index cea27f2..6c375d3 100644
@@ -1844,6 +1844,11 @@ uint32_t helper_load_dcr (uint32_t dcrn)
     return val;
 }
 
+target_ulong helper_load_dcr_tl (target_ulong dcrn)
+{
+    return (uint32_t)helper_load_dcr((uint32_t)dcrn);
+}
+
 void helper_store_dcr (uint32_t dcrn, uint32_t val)
 {
     if (unlikely(env->dcr_env == NULL)) {
@@ -1857,6 +1862,11 @@ void helper_store_dcr (uint32_t dcrn, uint32_t val)
     }
 }
 
+void helper_store_dcr_tl (target_ulong dcrn, target_ulong val)
+{
+    helper_store_dcr((uint32_t)dcrn, (uint32_t)val);
+}
+
 #if !defined(CONFIG_USER_ONLY)
 void helper_40x_rfci (void)
 {
target-ppc/translate.c +6 -6
index d4e81ce..d83d196 100644
@@ -5565,7 +5565,7 @@ static void gen_mfdcr(DisasContext *ctx)
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
     dcrn = tcg_const_tl(SPR(ctx->opcode));
-    gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], dcrn);
+    gen_helper_load_dcr_tl(cpu_gpr[rD(ctx->opcode)], dcrn);
     tcg_temp_free(dcrn);
 #endif
 }
@@ -5584,7 +5584,7 @@ static void gen_mtdcr(DisasContext *ctx)
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
     dcrn = tcg_const_tl(SPR(ctx->opcode));
-    gen_helper_store_dcr(dcrn, cpu_gpr[rS(ctx->opcode)]);
+    gen_helper_store_dcr_tl(dcrn, cpu_gpr[rS(ctx->opcode)]);
     tcg_temp_free(dcrn);
 #endif
 }
@@ -5602,7 +5602,7 @@ static void gen_mfdcrx(DisasContext *ctx)
     }
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
+    gen_helper_load_dcr_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 #endif
 }
@@ -5620,7 +5620,7 @@ static void gen_mtdcrx(DisasContext *ctx)
     }
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
+    gen_helper_store_dcr_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 #endif
 }
@@ -5630,7 +5630,7 @@ static void gen_mfdcrux(DisasContext *ctx)
 {
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
+    gen_helper_load_dcr_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 }
 
@@ -5639,7 +5639,7 @@ static void gen_mtdcrux(DisasContext *ctx)
 {
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
+    gen_helper_store_dcr_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 }
 
Signature · 1 line
1.6.0.2
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Alexander Graf

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

Happy new year,
Stefan

#2 lore raw
In reply to Alexander Graf
Quoted 63 lines · Alexander Graf

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

---
 target-ppc/cpu.h       |    2 ++
 target-ppc/helper.h    |    4 ++--
 target-ppc/op_helper.c |   10 ++++++++++
 target-ppc/translate.c |   12 ++++++------
 4 files changed, 20 insertions(+), 8 deletions(-)
target-ppc/cpu.h +2 -0
index d15bba1..60a8b68 100644
@@ -733,6 +733,8 @@ void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs);
 void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
+void helper_store_dcr (uint32_t dcrn, uint32_t val);
+uint32_t helper_load_dcr (uint32_t dcrn);
 
 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 
target-ppc/helper.h +2 -2
index 40d4ced..86f0af7 100644
@@ -359,8 +359,8 @@ DEF_HELPER_2(divo, tl, tl, tl)
 DEF_HELPER_2(divs, tl, tl, tl)
 DEF_HELPER_2(divso, tl, tl, tl)
 
-DEF_HELPER_1(load_dcr, i32, i32);
-DEF_HELPER_2(store_dcr, void, i32, i32)
+DEF_HELPER_1(load_dcr_tl, tl, tl);
+DEF_HELPER_2(store_dcr_tl, void, tl, tl)
 
 DEF_HELPER_1(load_dump_spr, void, i32)
 DEF_HELPER_1(store_dump_spr, void, i32)
target-ppc/op_helper.c +5 -0
index cea27f2..6c375d3 100644
@@ -1844,6 +1844,11 @@ uint32_t helper_load_dcr (uint32_t dcrn)
     return val;
 }
 
+target_ulong helper_load_dcr_tl (target_ulong dcrn)
+{
+    return (uint32_t)helper_load_dcr((uint32_t)dcrn);
+}
+
 void helper_store_dcr (uint32_t dcrn, uint32_t val)
 {
     if (unlikely(env->dcr_env == NULL)) {

target-ppc/op_helper.c void helper_store_dcr (uint32_t dcrn, uint32_t val) · line 1869

Quoted 8 lines
target-ppc/op_helper.c +5 -0
@@ -1857,6 +1862,11 @@ void helper_store_dcr (uint32_t dcrn, uint32_t val)
     }
 }
 
+void helper_store_dcr_tl (target_ulong dcrn, target_ulong val)
+{
+    helper_store_dcr((uint32_t)dcrn, (uint32_t)val);
+}
+

I do wonder why we need to keep the old helper_load_dcr() and helper_store_dcr() instead of modifying them directly. They doesn't seems to be used elsewhere.

Quoted 67 lines
target-ppc/op_helper.c +0 -0
 #if !defined(CONFIG_USER_ONLY)
 void helper_40x_rfci (void)
 {
target-ppc/translate.c +6 -6
index d4e81ce..d83d196 100644
@@ -5565,7 +5565,7 @@ static void gen_mfdcr(DisasContext *ctx)
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
     dcrn = tcg_const_tl(SPR(ctx->opcode));
-    gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], dcrn);
+    gen_helper_load_dcr_tl(cpu_gpr[rD(ctx->opcode)], dcrn);
     tcg_temp_free(dcrn);
 #endif
 }
@@ -5584,7 +5584,7 @@ static void gen_mtdcr(DisasContext *ctx)
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
     dcrn = tcg_const_tl(SPR(ctx->opcode));
-    gen_helper_store_dcr(dcrn, cpu_gpr[rS(ctx->opcode)]);
+    gen_helper_store_dcr_tl(dcrn, cpu_gpr[rS(ctx->opcode)]);
     tcg_temp_free(dcrn);
 #endif
 }
@@ -5602,7 +5602,7 @@ static void gen_mfdcrx(DisasContext *ctx)
     }
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
+    gen_helper_load_dcr_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 #endif
 }
@@ -5620,7 +5620,7 @@ static void gen_mtdcrx(DisasContext *ctx)
     }
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
+    gen_helper_store_dcr_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 #endif
 }
@@ -5630,7 +5630,7 @@ static void gen_mfdcrux(DisasContext *ctx)
 {
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
+    gen_helper_load_dcr_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 }
 
@@ -5639,7 +5639,7 @@ static void gen_mtdcrux(DisasContext *ctx)
 {
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-    gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
+    gen_helper_store_dcr_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
     /* Note: Rc update flag set leads to undefined state of Rc0 */
 }
 
Signature · 1 line
1.6.0.2
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#3 lore raw
Quoted 67 lines · Aurelien Jarno
Quoted 66 lines · Alexander Graf

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

---

target-ppc/cpu.h       |    2 ++
target-ppc/helper.h    |    4 ++--
target-ppc/op_helper.c |   10 ++++++++++
target-ppc/translate.c |   12 ++++++------
4 files changed, 20 insertions(+), 8 deletions(-)
target-ppc/cpu.h +2 -0
index d15bba1..60a8b68 100644
@@ -733,6 +733,8 @@ void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs);
 void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
+void helper_store_dcr (uint32_t dcrn, uint32_t val);
+uint32_t helper_load_dcr (uint32_t dcrn);
 
 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 
target-ppc/helper.h +2 -2
index 40d4ced..86f0af7 100644
@@ -359,8 +359,8 @@ DEF_HELPER_2(divo, tl, tl, tl)
 DEF_HELPER_2(divs, tl, tl, tl)
 DEF_HELPER_2(divso, tl, tl, tl)
 
-DEF_HELPER_1(load_dcr, i32, i32);
-DEF_HELPER_2(store_dcr, void, i32, i32)
+DEF_HELPER_1(load_dcr_tl, tl, tl);
+DEF_HELPER_2(store_dcr_tl, void, tl, tl)
 
 DEF_HELPER_1(load_dump_spr, void, i32)
 DEF_HELPER_1(store_dump_spr, void, i32)
target-ppc/op_helper.c +5 -0
index cea27f2..6c375d3 100644
@@ -1844,6 +1844,11 @@ uint32_t helper_load_dcr (uint32_t dcrn)
    return val;
 }
 
+target_ulong helper_load_dcr_tl (target_ulong dcrn)
+{
+    return (uint32_t)helper_load_dcr((uint32_t)dcrn);
+}
+
 void helper_store_dcr (uint32_t dcrn, uint32_t val)
 {
    if (unlikely(env->dcr_env == NULL)) {
@@ -1857,6 +1862,11 @@ void helper_store_dcr (uint32_t dcrn, uint32_t val)
    }
 }
 
Quoted 9 lines

target-ppc/op_helper.c void helper_store_dcr (uint32_t dcrn, uint32_t val) · line 1869

Quoted 5 lines
target-ppc/op_helper.c +5 -0
+void helper_store_dcr_tl (target_ulong dcrn, target_ulong val)
+{
+    helper_store_dcr((uint32_t)dcrn, (uint32_t)val);
+}
+

I do wonder why we need to keep the old helper_load_dcr() and helper_store_dcr() instead of modifying them directly. They doesn't seems to be used elsewhere.

Last time I checked they were used in hw/*ppc*.c. Maybe mangled through funny preprocessor or function callback logic. But maybe I'm wrong :).

Alex

#4 lore raw
Quoted 80 lines · Alexander Graf
Quoted 67 lines · Aurelien Jarno
Quoted 66 lines · Alexander Graf

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

---

target-ppc/cpu.h       |    2 ++
target-ppc/helper.h    |    4 ++--
target-ppc/op_helper.c |   10 ++++++++++
target-ppc/translate.c |   12 ++++++------
4 files changed, 20 insertions(+), 8 deletions(-)
target-ppc/cpu.h +2 -0
index d15bba1..60a8b68 100644
@@ -733,6 +733,8 @@ void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs);
 void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
+void helper_store_dcr (uint32_t dcrn, uint32_t val);
+uint32_t helper_load_dcr (uint32_t dcrn);
 
 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 
target-ppc/helper.h +2 -2
index 40d4ced..86f0af7 100644
@@ -359,8 +359,8 @@ DEF_HELPER_2(divo, tl, tl, tl)
 DEF_HELPER_2(divs, tl, tl, tl)
 DEF_HELPER_2(divso, tl, tl, tl)
 
-DEF_HELPER_1(load_dcr, i32, i32);
-DEF_HELPER_2(store_dcr, void, i32, i32)
+DEF_HELPER_1(load_dcr_tl, tl, tl);
+DEF_HELPER_2(store_dcr_tl, void, tl, tl)
 
 DEF_HELPER_1(load_dump_spr, void, i32)
 DEF_HELPER_1(store_dump_spr, void, i32)
target-ppc/op_helper.c +5 -0
index cea27f2..6c375d3 100644
@@ -1844,6 +1844,11 @@ uint32_t helper_load_dcr (uint32_t dcrn)
    return val;
 }
 
+target_ulong helper_load_dcr_tl (target_ulong dcrn)
+{
+    return (uint32_t)helper_load_dcr((uint32_t)dcrn);
+}
+
 void helper_store_dcr (uint32_t dcrn, uint32_t val)
 {
    if (unlikely(env->dcr_env == NULL)) {
@@ -1857,6 +1862,11 @@ void helper_store_dcr (uint32_t dcrn, uint32_t val)
    }
 }
 
Quoted 9 lines

target-ppc/op_helper.c void helper_store_dcr (uint32_t dcrn, uint32_t val) · line 1869

Quoted 5 lines
target-ppc/op_helper.c +5 -0
+void helper_store_dcr_tl (target_ulong dcrn, target_ulong val)
+{
+    helper_store_dcr((uint32_t)dcrn, (uint32_t)val);
+}
+

I do wonder why we need to keep the old helper_load_dcr() and helper_store_dcr() instead of modifying them directly. They doesn't seems to be used elsewhere.

Quoted 2 lines

Last time I checked they were used in hw/*ppc*.c. Maybe mangled through funny preprocessor or function callback logic. But maybe I'm wrong :).

I am not able to find them. I have tried to remove helper_load_dcr() and helper_store_dcr() from target-ppc/cpu.h and the code still compiles.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#5 lore raw
Quoted 81 lines · Aurelien Jarno
Quoted 80 lines · Alexander Graf
Quoted 76 lines · Aurelien Jarno
Quoted 63 lines · Alexander Graf

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

---

target-ppc/cpu.h       |    2 ++
target-ppc/helper.h    |    4 ++--
target-ppc/op_helper.c |   10 ++++++++++
target-ppc/translate.c |   12 ++++++------
4 files changed, 20 insertions(+), 8 deletions(-)
target-ppc/cpu.h +2 -0
index d15bba1..60a8b68 100644
@@ -733,6 +733,8 @@ void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs);
 void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
+void helper_store_dcr (uint32_t dcrn, uint32_t val);
+uint32_t helper_load_dcr (uint32_t dcrn);
 
 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 
target-ppc/helper.h +2 -2
index 40d4ced..86f0af7 100644
@@ -359,8 +359,8 @@ DEF_HELPER_2(divo, tl, tl, tl)
 DEF_HELPER_2(divs, tl, tl, tl)
 DEF_HELPER_2(divso, tl, tl, tl)
 
-DEF_HELPER_1(load_dcr, i32, i32);
-DEF_HELPER_2(store_dcr, void, i32, i32)
+DEF_HELPER_1(load_dcr_tl, tl, tl);
+DEF_HELPER_2(store_dcr_tl, void, tl, tl)
 
 DEF_HELPER_1(load_dump_spr, void, i32)
 DEF_HELPER_1(store_dump_spr, void, i32)
target-ppc/op_helper.c +5 -0
index cea27f2..6c375d3 100644
@@ -1844,6 +1844,11 @@ uint32_t helper_load_dcr (uint32_t dcrn)
   return val;
 }
 
+target_ulong helper_load_dcr_tl (target_ulong dcrn)
+{
+    return (uint32_t)helper_load_dcr((uint32_t)dcrn);
+}
+
 void helper_store_dcr (uint32_t dcrn, uint32_t val)
 {
   if (unlikely(env->dcr_env == NULL)) {

target-ppc/op_helper.c void helper_store_dcr (uint32_t dcrn, uint32_t val) · line 1869

Quoted 8 lines
target-ppc/op_helper.c +5 -0
@@ -1857,6 +1862,11 @@ void helper_store_dcr (uint32_t dcrn, uint32_t val)
   }
 }
 
+void helper_store_dcr_tl (target_ulong dcrn, target_ulong val)
+{
+    helper_store_dcr((uint32_t)dcrn, (uint32_t)val);
+}
+

I do wonder why we need to keep the old helper_load_dcr() and helper_store_dcr() instead of modifying them directly. They doesn't seems to be used elsewhere.

Quoted 5 lines
Quoted 2 lines

Last time I checked they were used in hw/*ppc*.c. Maybe mangled through funny preprocessor or function callback logic. But maybe I'm wrong :).

I am not able to find them. I have tried to remove helper_load_dcr() and helper_store_dcr() from target-ppc/cpu.h and the code still compiles.

Hm, right. The only references are to ppc_dcr_read and ppc_dcr_write. I guess the other helpers are superfluous then.

Alex

#6 lore raw
Quoted 84 lines · Alexander Graf
Quoted 81 lines · Aurelien Jarno
Quoted 80 lines · Alexander Graf
Quoted 76 lines · Aurelien Jarno
Quoted 63 lines · Alexander Graf

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

---

target-ppc/cpu.h       |    2 ++
target-ppc/helper.h    |    4 ++--
target-ppc/op_helper.c |   10 ++++++++++
target-ppc/translate.c |   12 ++++++------
4 files changed, 20 insertions(+), 8 deletions(-)
target-ppc/cpu.h +2 -0
index d15bba1..60a8b68 100644
@@ -733,6 +733,8 @@ void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs);
 void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
+void helper_store_dcr (uint32_t dcrn, uint32_t val);
+uint32_t helper_load_dcr (uint32_t dcrn);
 
 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 
target-ppc/helper.h +2 -2
index 40d4ced..86f0af7 100644
@@ -359,8 +359,8 @@ DEF_HELPER_2(divo, tl, tl, tl)
 DEF_HELPER_2(divs, tl, tl, tl)
 DEF_HELPER_2(divso, tl, tl, tl)
 
-DEF_HELPER_1(load_dcr, i32, i32);
-DEF_HELPER_2(store_dcr, void, i32, i32)
+DEF_HELPER_1(load_dcr_tl, tl, tl);
+DEF_HELPER_2(store_dcr_tl, void, tl, tl)
 
 DEF_HELPER_1(load_dump_spr, void, i32)
 DEF_HELPER_1(store_dump_spr, void, i32)
target-ppc/op_helper.c +5 -0
index cea27f2..6c375d3 100644
@@ -1844,6 +1844,11 @@ uint32_t helper_load_dcr (uint32_t dcrn)
   return val;
 }
 
+target_ulong helper_load_dcr_tl (target_ulong dcrn)
+{
+    return (uint32_t)helper_load_dcr((uint32_t)dcrn);
+}
+
 void helper_store_dcr (uint32_t dcrn, uint32_t val)
 {
   if (unlikely(env->dcr_env == NULL)) {

target-ppc/op_helper.c void helper_store_dcr (uint32_t dcrn, uint32_t val) · line 1869

Quoted 8 lines
target-ppc/op_helper.c +5 -0
@@ -1857,6 +1862,11 @@ void helper_store_dcr (uint32_t dcrn, uint32_t val)
   }
 }
 
+void helper_store_dcr_tl (target_ulong dcrn, target_ulong val)
+{
+    helper_store_dcr((uint32_t)dcrn, (uint32_t)val);
+}
+

I do wonder why we need to keep the old helper_load_dcr() and helper_store_dcr() instead of modifying them directly. They doesn't seems to be used elsewhere.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Last time I checked they were used in hw/*ppc*.c. Maybe mangled through funny preprocessor or function callback logic. But maybe I'm wrong :).

I am not able to find them. I have tried to remove helper_load_dcr() and helper_store_dcr() from target-ppc/cpu.h and the code still compiles.

Hm, right. The only references are to ppc_dcr_read and ppc_dcr_write. I guess the other helpers are superfluous then.

I have applied a patch to fix the problem.

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

Am 06.02.2010 um 17:15 schrieb Aurelien Jarno <[email protected]>:

Quoted 90 lines · Alexander Graf
Quoted 89 lines · Aurelien Jarno
Quoted 87 lines · Alexander Graf
Quoted 84 lines · Aurelien Jarno
Quoted 70 lines · Alexander Graf
Quoted 68 lines

The recent transition to always have the DCR helper functions take 32 bit values broke the PPC64 target, as tlong became 64 bits there.

This patch moves all translate.c callers to a _tl function that simply calls the uint32_t functions. That way we don't need to mess with TCG trying to pass registers as uint32_t variables to functions.

Fixes PPC64 build with --enable-debug-tcg

---

target-ppc/cpu.h       |    2 ++
target-ppc/helper.h    |    4 ++--
target-ppc/op_helper.c |   10 ++++++++++
target-ppc/translate.c |   12 ++++++------
4 files changed, 20 insertions(+), 8 deletions(-)
target-ppc/cpu.h +2 -0
index d15bba1..60a8b68 100644
@@ -733,6 +733,8 @@ void ppc_store_slb (CPUPPCState *env,  
 target_ulong rb, target_ulong rs);
 void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
+void helper_store_dcr (uint32_t dcrn, uint32_t val);
+uint32_t helper_load_dcr (uint32_t dcrn);
 
 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
target-ppc/helper.h +2 -2
index 40d4ced..86f0af7 100644
@@ -359,8 +359,8 @@ DEF_HELPER_2(divo, tl, tl, tl)
 DEF_HELPER_2(divs, tl, tl, tl)
 DEF_HELPER_2(divso, tl, tl, tl)
 
-DEF_HELPER_1(load_dcr, i32, i32);
-DEF_HELPER_2(store_dcr, void, i32, i32)
+DEF_HELPER_1(load_dcr_tl, tl, tl);
+DEF_HELPER_2(store_dcr_tl, void, tl, tl)
 
 DEF_HELPER_1(load_dump_spr, void, i32)
 DEF_HELPER_1(store_dump_spr, void, i32)
target-ppc/op_helper.c +5 -0
index cea27f2..6c375d3 100644
@@ -1844,6 +1844,11 @@ uint32_t helper_load_dcr (uint32_t dcrn)
  return val;
 }
 
+target_ulong helper_load_dcr_tl (target_ulong dcrn)
+{
+    return (uint32_t)helper_load_dcr((uint32_t)dcrn);
+}
+
 void helper_store_dcr (uint32_t dcrn, uint32_t val)
 {
  if (unlikely(env->dcr_env == NULL)) {
@@ -1857,6 +1862,11 @@ void helper_store_dcr (uint32_t dcrn,  
 uint32_t val)
  }
 }
 
Quoted 9 lines

target-ppc/op_helper.c void helper_store_dcr (uint32_t dcrn, uint32_t val) · line 1869

Quoted 5 lines
target-ppc/op_helper.c +5 -0
+void helper_store_dcr_tl (target_ulong dcrn, target_ulong val)
+{
+    helper_store_dcr((uint32_t)dcrn, (uint32_t)val);
+}
+

I do wonder why we need to keep the old helper_load_dcr() and helper_store_dcr() instead of modifying them directly. They doesn't seems to be used elsewhere.

Last time I checked they were used in hw/*ppc*.c. Maybe mangled through funny preprocessor or function callback logic. But maybe I'm wrong :).

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I am not able to find them. I have tried to remove helper_load_dcr() and helper_store_dcr() from target-ppc/cpu.h and the code still compiles.

Hm, right. The only references are to ppc_dcr_read and ppc_dcr_write. I guess the other helpers are superfluous then.

I have applied a patch to fix the problem.

Thanks a lot! Sorry I didn't get to it :(.

Alex