qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 1/1] target/riscv: rvv: Use wider accesses for unit stride


From: Richard Henderson
Subject: Re: [PATCH v6 1/1] target/riscv: rvv: Use wider accesses for unit stride load/store
Date: Wed, 18 Dec 2024 09:59:13 -0600
User-agent: Mozilla Thunderbird

On 12/18/24 08:29, Craig Blackmore wrote:
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -31,6 +31,12 @@
  #include "vector_internals.h"
  #include <math.h>
+#if CONFIG_TCG && !HOST_BIG_ENDIAN
+#include "trace.h"
+#include "../accel/tcg/internal-common.h"
+#include "../accel/tcg/ldst_atomicity.c.inc"
+#endif

No, you cannot include random bits of accel/tcg/ into target/ code.


+#define GEN_VEXT_LDST_ATOMIC_HOST(SIZE, TYPE, MEMOP)                         \
+static inline QEMU_ALWAYS_INLINE void                                        \
+vext_ldst_atom_##SIZE##_host(CPURISCVState *env, void *vd,                   \
+                             uint32_t byte_offset, void *host, bool is_load, \
+                             uintptr_t ra)                                   \
+{                                                                            \
+    TYPE *vd_ptr = (TYPE *) (vd + byte_offset);                              \
+    if (is_load) {                                                           \
+        *vd_ptr = load_atom_##SIZE(env_cpu(env), ra, host, MEMOP);           \
+    } else {                                                                 \
+        store_atom_##SIZE(env_cpu(env), ra, host, MEMOP, *vd_ptr);           \
+    }                                                                        \
+}                                                                            \
+
+GEN_VEXT_LDST_ATOMIC_HOST(2, uint16_t, MO_16)
+GEN_VEXT_LDST_ATOMIC_HOST(4, uint32_t, MO_32)
+GEN_VEXT_LDST_ATOMIC_HOST(8, uint64_t, MO_64)
+GEN_VEXT_LDST_ATOMIC_HOST(16, Int128, MO_128)
+#endif

I was suggesting use of "qemu/atomic.h", which would just be

    *vd_ptr = qatomic_read_nocheck(ptr);
else
    qatomic_set_nocheck(ptr, *vd_ptr);

for types up til uint32_t.

Add an ifdef for CONFIG_ATOMIC64 and you can use uint64_t.

Get that working before tackling Int128.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]