helper_msa_ld_d() and helper_msa_st_d() use the legacy
cpu_ldq_data_ra() / cpu_stq_data_ra() accessors, whose endianness
is fixed at build time by TARGET_BIG_ENDIAN. All other MSA load
and store helpers check the vCPU endianness at runtime via
mips_env_is_bigendian().

Do the same for the doubleword variants, so they keep working
when the vCPU endianness differs from the build-time default.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
We have a better conversion of the runtime helpers by
translation which allows to respect atomicity, but the
series isn't yet ready, so meanwhile this patch is useful
enough.
---
 target/mips/tcg/msa_helper.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/target/mips/tcg/msa_helper.c b/target/mips/tcg/msa_helper.c
index fb76524ba081..1919ce6be9eb 100644
--- a/target/mips/tcg/msa_helper.c
+++ b/target/mips/tcg/msa_helper.c
@@ -8300,8 +8300,13 @@ void HELPER(msa_ld_d)(CPUMIPSState *env, uint32_t wd,
     uintptr_t ra = GETPC();
     uint64_t d0, d1;
 
-    d0 = cpu_ldq_data_ra(env, addr + 0, ra);
-    d1 = cpu_ldq_data_ra(env, addr + 8, ra);
+    if (mips_env_is_bigendian(env)) {
+        d0 = cpu_ldq_be_data_ra(env, addr + 0, ra);
+        d1 = cpu_ldq_be_data_ra(env, addr + 8, ra);
+    } else {
+        d0 = cpu_ldq_le_data_ra(env, addr + 0, ra);
+        d1 = cpu_ldq_le_data_ra(env, addr + 8, ra);
+    }
     pwd->d[0] = d0;
     pwd->d[1] = d1;
 }
@@ -8389,6 +8394,11 @@ void HELPER(msa_st_d)(CPUMIPSState *env, uint32_t wd,
 
     ensure_writable_pages(env, addr, mmu_idx, GETPC());
 
-    cpu_stq_data_ra(env, addr + 0, pwd->d[0], ra);
-    cpu_stq_data_ra(env, addr + 8, pwd->d[1], ra);
+    if (mips_env_is_bigendian(env)) {
+        cpu_stq_be_data_ra(env, addr + 0, pwd->d[0], ra);
+        cpu_stq_be_data_ra(env, addr + 8, pwd->d[1], ra);
+    } else {
+        cpu_stq_le_data_ra(env, addr + 0, pwd->d[0], ra);
+        cpu_stq_le_data_ra(env, addr + 8, pwd->d[1], ra);
+    }
 }
-- 
2.55.0


Reply via email to