PPC: Depend behavior of cmp instructions only on instruction encoding
PATCH v2 1/1 PPC: Depend behavior of cmp instructions only on instruction encoding
When running an L=1 cmp instruction on a 64bit PPC CPU with SF off, it still behaves identical to what it does when SF is on. Remove the implicit difference in the code.
Also, on most 32bit CPUs we should always treat the compare as 32bit compare, as the CPU will ignore the L bit. This is not true for e500mc, but that's up for a different patch.
---
v1 -> v2:
- ignore L bit
--- target-ppc/translate.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-)
target-ppc/translate.c +16 -16
@@ -675,48 +675,48 @@ static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg)/* cmp */ static void gen_cmp (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], -1 ,crfD (ctx->opcode)); - }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmp (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)],1 ,crfD (ctx->opcode)); + }else { +gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], +1 ,crfD (ctx->opcode)); } }/* cmpi */ static void gen_cmpi (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],SIMM (ctx->opcode), -1 ,crfD (ctx->opcode)); - }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmpi (cpu_gpr[rA (ctx->opcode)],SIMM (ctx->opcode),1 ,crfD (ctx->opcode)); + }else { +gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],SIMM (ctx->opcode), +1 ,crfD (ctx->opcode)); } }/* cmpl */ static void gen_cmpl (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], -0 ,crfD (ctx->opcode)); - }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmp (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)],0 ,crfD (ctx->opcode)); + }else { +gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], +0 ,crfD (ctx->opcode)); } }/* cmpli */ static void gen_cmpli (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],UIMM (ctx->opcode), -0 ,crfD (ctx->opcode)); - }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmpi (cpu_gpr[rA (ctx->opcode)],UIMM (ctx->opcode),0 ,crfD (ctx->opcode)); + }else { +gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],UIMM (ctx->opcode), +0 ,crfD (ctx->opcode)); } }
Signature · 1 line
1.6.0.2
Quoted 80 lines · Alexander Graf
When running an L=1 cmp instruction on a 64bit PPC CPU with SF off, it still behaves identical to what it does when SF is on. Remove the implicit difference in the code.
Also, on most 32bit CPUs we should always treat the compare as 32bit compare, as the CPU will ignore the L bit. This is not true for e500mc, but that's up for a different patch.
Reported-by Torbjorn Granlund <[email protected]>Reviewed-by Richard Henderson <[email protected]>Signed-off-by Alexander Graf <[email protected]>---
v1 -> v2:
- ignore L bit
--- target-ppc/translate.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-)target-ppc/translate.c +12
-15@@ -675,48 +675,48 @@ static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg)/* cmp */ static void gen_cmp (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], -1 ,crfD (ctx->opcode)); - }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmp (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)],1 ,crfD (ctx->opcode)); + }else { +gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], +1 ,crfD (ctx->opcode)); } }/* cmpi */ static void gen_cmpi (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],SIMM (ctx->opcode), -1 ,crfD (ctx->opcode)); - }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmpi (cpu_gpr[rA (ctx->opcode)],SIMM (ctx->opcode),1 ,crfD (ctx->opcode)); + }else { +gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],SIMM (ctx->opcode), +1 ,crfD (ctx->opcode)); } }/* cmpl */ static void gen_cmpl (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], -0 ,crfD (ctx->opcode)); - }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmp (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)],0 ,crfD (ctx->opcode)); + }else { +gen_op_cmp32 (cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], +0 ,crfD (ctx->opcode)); } }/* cmpli */ static void gen_cmpli (DisasContext *ctx) { -if (NARROW_MODE (ctx) || !(ctx->opcode &0x00200000 )) { -gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],UIMM (ctx->opcode), -0 ,crfD (ctx->opcode));
target-ppc/translate.c static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg) · line 722
Quoted 10 lines
target-ppc/translate.c +4
-1- }else { +if ((ctx->opcode &0x00200000 ) && (ctx->insns_flags &PPC_64B )) {gen_op_cmpi (cpu_gpr[rA (ctx->opcode)],UIMM (ctx->opcode),0 ,crfD (ctx->opcode)); + }else { +gen_op_cmpi32 (cpu_gpr[rA (ctx->opcode)],UIMM (ctx->opcode), +0 ,crfD (ctx->opcode)); } }
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net