[PATCH v2 03/23] target/riscv: Split out vext_ldst_nf_host

Richard Henderson <[email protected]>
Newsgroups org.nongnu.qemu-riscv,org.nongnu.qemu-devel
Message-ID <[email protected]>
Provide a helper that calls ldst_host for all NF vectors.

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

diff --git a/target/riscv/tcg/vector_helper.c b/target/riscv/tcg/vector_helper.c
index b04d461c08..6108cf3a6c 100644
--- a/target/riscv/tcg/vector_helper.c
+++ b/target/riscv/tcg/vector_helper.c
@@ -337,6 +337,15 @@ static void vext_set_nf_elems_1s(void *vd, uint32_t i, uint32_t nf,
     }
 }
 
+static void vext_ldst_nf_host(void *vd, void *host, uint32_t i, uint32_t nf,
+                              uint32_t esz, uint32_t max_elems,
+                              vext_ldst_elem_fn_host *ldst_host)
+{
+    for (uint32_t k = 0; k < nf; k++, host += esz) {
+        ldst_host(vd, i + k * max_elems, host);
+    }
+}
+
 static void vext_ldst_nf_tlb(CPURISCVState *env, void *vd, target_ulong addr,
                              uint32_t i, uint32_t nf,
                              uint32_t esz, uint32_t max_elems,
@@ -419,7 +428,7 @@ vext_page_ldst_us(CPURISCVState *env, void *vd, target_ulong addr,
                   vext_ldst_elem_fn_host *ldst_host, uintptr_t ra)
 {
     void *host;
-    int i, k, flags;
+    int flags;
     uint32_t esz = 1 << log2_esz;
     uint32_t size = (elems * nf) << log2_esz;
     uint32_t msize = nf * esz;
@@ -450,13 +459,9 @@ vext_page_ldst_us(CPURISCVState *env, void *vd, target_ulong addr,
             vext_continuous_ldst_host(env, ldst_host, vd, evl, env->vstart,
                                       host, esz, is_load);
         } else {
-            for (i = env->vstart; i < evl; ++i) {
-                k = 0;
-                while (k < nf) {
-                    ldst_host(vd, i + k * max_elems, host);
-                    host += esz;
-                    k++;
-                }
+            for (uint32_t i = env->vstart; i < evl; ++i) {
+                vext_ldst_nf_host(vd, host, i, nf, esz, max_elems, ldst_host);
+                host += msize;
             }
         }
         env->vstart += elems;
@@ -465,7 +470,7 @@ vext_page_ldst_us(CPURISCVState *env, void *vd, target_ulong addr,
             vext_continuous_ldst_tlb(env, ldst_tlb, vd, evl, addr, env->vstart,
                                    ra, esz, is_load);
         } else {
-            for (i = env->vstart; i < evl; env->vstart = ++i) {
+            for (uint32_t i = env->vstart; i < evl; env->vstart = ++i) {
                 vext_ldst_nf_tlb(env, vd, addr, i, nf, esz,
                                  max_elems, ldst_tlb, ra);
                 addr += msize;
-- 
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.