accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code()
cover accel/tcg: Remove some MO_TE uses in cpu_ld{uw, l, q}_code()
Hi Richard,
Quick attempt to remove MO_TE uses for fixed-endianness targets.
For the other targets I started to propagate MemOp in the call chain, but since IIUC it is constant, I wonder if it isn't simpler to have a CPUClass::code_endian_mo field, set once with a target_big_endian() call. I can post another RFC to show, WDYT?
Regards,
Phil.
Philippe Mathieu-Daudé (5):
accel/tcg: Add endianness variants of cpu_ld{uw,l,q}_code() target/alpha: Use little-endian variant of cpu_ldl_code() target/loongarch: Use little-endian variant of cpu_ldl_code() target/sparc: Use big-endian variant of cpu_ldl_code() target/s390x: Use big-endian variant of cpu_ld{uw,l}_code()
include/accel/tcg/cpu-ldst.h | 43 +++++++++++++++++++++++++++++----- target/alpha/mem_helper.c | 2 +- target/loongarch/tcg/tcg_cpu.c | 2 +- target/s390x/tcg/mem_helper.c | 6 ++--- target/sparc/int32_helper.c | 2 +- 5 files changed, 43 insertions(+), 12 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/5 accel/tcg: Add endianness variants of cpu_ld{uw, l, q}_code()
Allow target with fixed-endianness to not use the MO_TE definition.
--- include/accel/tcg/cpu-ldst.h | 43 +++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-)
include/accel/tcg/cpu-ldst.h +37 -6
@@ -481,25 +481,56 @@ static inline uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr)return cpu_ldb_code_mmu (env, addr, oi,0 ); } -static inline uint32_t cpu_lduw_code (CPUArchState *env,abi_ptr addr) +static inline uint32_t cpu_lduw_le_code (CPUArchState *env,abi_ptr addr) {CPUState *cs =env_cpu (env); -MemOpIdx oi =make_memop_idx (MO_TEUW ,cpu_mmu_index (cs, true)); +MemOpIdx oi =make_memop_idx (MO_LEUW ,cpu_mmu_index (cs, true));return cpu_ldw_code_mmu (env, addr, oi,0 ); } -static inline uint32_t cpu_ldl_code (CPUArchState *env,abi_ptr addr) +static inline uint32_t cpu_ldl_le_code (CPUArchState *env,abi_ptr addr) {CPUState *cs =env_cpu (env); -MemOpIdx oi =make_memop_idx (MO_TEUL ,cpu_mmu_index (cs, true)); +MemOpIdx oi =make_memop_idx (MO_LEUL ,cpu_mmu_index (cs, true));return cpu_ldl_code_mmu (env, addr, oi,0 ); } -static inline uint64_t cpu_ldq_code (CPUArchState *env,abi_ptr addr) +static inline uint64_t cpu_ldq_le_code (CPUArchState *env,abi_ptr addr) {CPUState *cs =env_cpu (env); -MemOpIdx oi =make_memop_idx (MO_TEUQ ,cpu_mmu_index (cs, true)); +MemOpIdx oi =make_memop_idx (MO_LEUQ ,cpu_mmu_index (cs, true));return cpu_ldq_code_mmu (env, addr, oi,0 ); } +static inline uint32_t cpu_lduw_be_code (CPUArchState *env,abi_ptr addr) +{ +CPUState *cs =env_cpu (env); +MemOpIdx oi =make_memop_idx (MO_BEUW ,cpu_mmu_index (cs, true)); +return cpu_ldw_code_mmu (env, addr, oi,0 ); +} + +static inline uint32_t cpu_ldl_be_code (CPUArchState *env,abi_ptr addr) +{ +CPUState *cs =env_cpu (env); +MemOpIdx oi =make_memop_idx (MO_BEUL ,cpu_mmu_index (cs, true)); +return cpu_ldl_code_mmu (env, addr, oi,0 ); +} + +static inline uint64_t cpu_ldq_be_code (CPUArchState *env,abi_ptr addr) +{ +CPUState *cs =env_cpu (env); +MemOpIdx oi =make_memop_idx (MO_BEUQ ,cpu_mmu_index (cs, true)); +return cpu_ldq_code_mmu (env, addr, oi,0 ); +} + +#if TARGET_BIG_ENDIAN +# define cpu_lduw_code cpu_lduw_be_code +# define cpu_ldl_code cpu_ldl_be_code +# define cpu_ldq_code cpu_ldq_be_code +#else +# define cpu_lduw_code cpu_lduw_le_code +# define cpu_ldl_code cpu_ldl_le_code +# define cpu_ldq_code cpu_ldq_le_code +#endif +#endif /* ACCEL_TCG_CPU_LDST_H */
Signature · 1 line
2.51.0
PATCH 2/5 target/alpha: Use little-endian variant of cpu_ldl_code()
In reply to Philippe Mathieu-DaudéAlpha is always little-endian.
--- target/alpha/mem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/alpha/mem_helper.c +1 -1
@@ -30,7 +30,7 @@ static void do_unaligned_access(CPUAlphaState *env, vaddr addr, uintptr_t retaddcpu_restore_state (env_cpu (env), retaddr); pc = env->pc; - insn =cpu_ldl_code (env, pc); + insn =cpu_ldl_le_code (env, pc); env->trap_arg0 = addr; env->trap_arg1 = insn >>26 ;/* opcode */
Signature · 1 line
2.51.0
PATCH 3/5 target/loongarch: Use little-endian variant of cpu_ldl_code()
In reply to Philippe Mathieu-DaudéLoongArch is always little-endian.
--- target/loongarch/tcg/tcg_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/loongarch/tcg/tcg_cpu.c +1 -1
@@ -140,7 +140,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) }if (update_badinstr) { - env->CSR_BADI =cpu_ldl_code (env, env->pc); + env->CSR_BADI =cpu_ldl_le_code (env, env->pc); }/* Save PLV and IE */
Signature · 1 line
2.51.0
PATCH 4/5 target/sparc: Use big-endian variant of cpu_ldl_code()
In reply to Philippe Mathieu-DaudéSPARC is always big-endian.
--- target/sparc/int32_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/sparc/int32_helper.c +1 -1
@@ -151,7 +151,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)if (!env->fsr_qne) { env->fsr_qne =FSR_QNE ; env->fq.s.addr = env->pc; - env->fq.s.insn =cpu_ldl_code (env, env->pc); + env->fq.s.insn =cpu_ldl_be_code (env, env->pc); } env->pc = env->npc; env->npc = env->npc +4 ;
Signature · 1 line
2.51.0
PATCH 5/5 target/s390x: Use big-endian variant of cpu_ld{uw, l}_code()
In reply to Philippe Mathieu-DaudéS390x is always big-endian.
--- target/s390x/tcg/mem_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/s390x/tcg/mem_helper.c +3 -3
@@ -2437,7 +2437,7 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } - insn =cpu_lduw_code (env, addr); + insn =cpu_lduw_be_code (env, addr); opc = insn >>8 ;/* Or in the contents of R1[56:63]. */
@@ -2449,10 +2449,10 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)case 2 :break ;case 4 : - insn |= (uint64_t )cpu_lduw_code (env, addr +2 ) <<32 ; + insn |= (uint64_t )cpu_lduw_be_code (env, addr +2 ) <<32 ;break ;case 6 : - insn |= (uint64_t )(uint32_t )cpu_ldl_code (env, addr +2 ) <<16 ; + insn |= (uint64_t )(uint32_t )cpu_ldl_be_code (env, addr +2 ) <<16 ;break ;default :g_assert_not_reached ();
Signature · 1 line
2.51.0
Quoted 9 lines · Philippe Mathieu-Daudé
Hi Richard,
Quick attempt to remove
MO_TEuses for fixed-endianness targets.For the other targets I started to propagate MemOp in the call chain, but since IIUC it is constant, I wonder if it isn't simpler to have a
CPUClass::code_endian_mofield, set once with atarget_big_endian()call. I can post another RFC to show, WDYT?
Not needed, figured a simpler way, posted as v2.