[PATCH v2 15/23] target/riscv: Pass MemOpIdx to vext_ldst_us

Richard Henderson <[email protected]>
Newsgroups org.nongnu.qemu-riscv,org.nongnu.qemu-devel
Message-ID <[email protected]>
Use mmu data passed in with VDATA.

Signed-off-by: Richard Henderson <[email protected]>
---
 target/riscv/tcg/vector_helper.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/target/riscv/tcg/vector_helper.c b/target/riscv/tcg/vector_helper.c
index 76990894e5..9b0c3f70c2 100644
--- a/target/riscv/tcg/vector_helper.c
+++ b/target/riscv/tcg/vector_helper.c
@@ -158,6 +158,19 @@ static inline void vext_set_elem_mask(void *v0, int index,
     ((uint64_t *)v0)[idx] = deposit64(old, pos, 1, value);
 }
 
+static inline MemOpIdx vext_oi(uint32_t desc, MemOp memop)
+{
+    uint32_t data = simd_data(desc);
+
+    if (FIELD_EX32(simd_data(desc), VDATA, BSWAP)) {
+        memop |= MO_BSWAP;
+    }
+    if (FIELD_EX32(simd_data(desc), VDATA, ALIGN)) {
+        memop |= MO_ALIGN;
+    }
+    return make_memop_idx(memop, FIELD_EX32(data, VDATA, MEM_IDX));
+}
+
 static inline MemOpIdx vext_make_memop_idx(CPURISCVState *env, size_t size)
 {
     int mmu_idx = riscv_env_mmu_index(env, false);
@@ -406,12 +419,12 @@ vext_ldst_us_notail(void *vd, target_ulong base, CPURISCVState *env,
                     uint32_t max_elems, bool vma,
                     vext_ldst_elem_fn_tlb *ldst_tlb,
                     vext_ldst_elem_fn_host *ldst_host,
-                    uintptr_t ra, bool is_load)
+                    uintptr_t ra, bool is_load, MemOpIdx oi)
 {
     target_ulong elems, addr, last, last_in_page, page_split;
     uint32_t esz = 1 << log2_esz;
     uint32_t msize = nf * esz;
-    int mmu_index = riscv_env_mmu_index(env, false);
+    int mmu_index = get_mmuidx(oi);
     MMUAccessType access_type = is_load ? MMU_DATA_LOAD : MMU_DATA_STORE;
     uint32_t i = env->vstart;
     void *host;
@@ -505,7 +518,8 @@ vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc,
     uint32_t max_elems = vext_max_elems(desc, log2_esz);
 
     vext_ldst_us_notail(vd, base, env, log2_esz, vext_nf(desc), evl, max_elems,
-                        vext_vma(desc), ldst_tlb, ldst_host, ra, is_load);
+                        vext_vma(desc), ldst_tlb, ldst_host, ra, is_load,
+                        vext_oi(desc, log2_esz));
 
     env->vstart = 0;
     vext_set_tail_elems_1s(evl, vd, desc, nf, 1 << log2_esz, max_elems);
@@ -947,7 +961,8 @@ vext_ldst_whole(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc,
     uint32_t evl = (riscv_cpu_cfg(env)->vlenb * vext_nf(desc)) >> log2_esz;
 
     vext_ldst_us_notail(vd, base, env, log2_esz, 1, evl, evl, false,
-                        ldst_tlb, ldst_host, ra, is_load);
+                        ldst_tlb, ldst_host, ra, is_load,
+                        vext_oi(desc, log2_esz));
     env->vstart = 0;
 }
 
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.