[PATCH 42/61] target/arm: Add raw_read128, raw_write128

Richard Henderson posted 61 patches 1 month ago
[PATCH 42/61] target/arm: Add raw_read128, raw_write128
Posted by Richard Henderson 1 month ago
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/cpregs.h |  5 +++++
 target/arm/helper.c | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
index 90f14dbb18..0d8c45b60c 100644
--- a/target/arm/cpregs.h
+++ b/target/arm/cpregs.h
@@ -21,6 +21,7 @@
 #ifndef TARGET_ARM_CPREGS_H
 #define TARGET_ARM_CPREGS_H
 
+#include "qemu/int128.h"
 #include "hw/registerfields.h"
 #include "exec/memop.h"
 #include "target/arm/kvm-consts.h"
@@ -1065,6 +1066,10 @@ uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri);
 /* CPWriteFn that just writes the value to ri->fieldoffset */
 void raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value);
 
+/* Likewise for 128-bit fields. */
+Int128 raw_read128(CPUARMState *env, const ARMCPRegInfo *opaque);
+void raw_write128(CPUARMState *env, const ARMCPRegInfo *opaque, Int128 value);
+
 /*
  * CPResetFn that does nothing, for use if no reset is required even
  * if fieldoffset is non zero.
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 18af67742d..7568b78c49 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -59,6 +59,8 @@ int compare_u64(const void *a, const void *b)
     (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
 #define CPREG_FIELD64(env, ri) \
     (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
+#define CPREG_FIELD128(env, ri) \
+    (*(Int128 *)((char *)(env) + (ri)->fieldoffset))
 
 uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri)
 {
@@ -88,8 +90,23 @@ void raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
     }
 }
 
+Int128 raw_read128(CPUARMState *env, const ARMCPRegInfo *ri)
+{
+    assert(ri->type & ARM_CP_128BIT);
+    assert(ri->fieldoffset);
+    return CPREG_FIELD128(env, ri);
+}
+
+void raw_write128(CPUARMState *env, const ARMCPRegInfo *ri, Int128 value)
+{
+    assert(ri->type & ARM_CP_128BIT);
+    assert(ri->fieldoffset);
+    CPREG_FIELD128(env, ri) = value;
+}
+
 #undef CPREG_FIELD32
 #undef CPREG_FIELD64
+#undef CPREG_FIELD128
 
 static void *raw_ptr(CPUARMState *env, const ARMCPRegInfo *ri)
 {
-- 
2.43.0
Re: [PATCH 42/61] target/arm: Add raw_read128, raw_write128
Posted by Manos Pitsidianakis 3 weeks, 6 days ago
On Wed, 27 Aug 2025 04:04, Richard Henderson <richard.henderson@linaro.org> wrote:
>Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>

> target/arm/cpregs.h |  5 +++++
> target/arm/helper.c | 17 +++++++++++++++++
> 2 files changed, 22 insertions(+)
>
>diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
>index 90f14dbb18..0d8c45b60c 100644
>--- a/target/arm/cpregs.h
>+++ b/target/arm/cpregs.h
>@@ -21,6 +21,7 @@
> #ifndef TARGET_ARM_CPREGS_H
> #define TARGET_ARM_CPREGS_H
> 
>+#include "qemu/int128.h"
> #include "hw/registerfields.h"
> #include "exec/memop.h"
> #include "target/arm/kvm-consts.h"
>@@ -1065,6 +1066,10 @@ uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri);
> /* CPWriteFn that just writes the value to ri->fieldoffset */
> void raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value);
> 
>+/* Likewise for 128-bit fields. */
>+Int128 raw_read128(CPUARMState *env, const ARMCPRegInfo *opaque);
>+void raw_write128(CPUARMState *env, const ARMCPRegInfo *opaque, Int128 value);
>+
> /*
>  * CPResetFn that does nothing, for use if no reset is required even
>  * if fieldoffset is non zero.
>diff --git a/target/arm/helper.c b/target/arm/helper.c
>index 18af67742d..7568b78c49 100644
>--- a/target/arm/helper.c
>+++ b/target/arm/helper.c
>@@ -59,6 +59,8 @@ int compare_u64(const void *a, const void *b)
>     (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
> #define CPREG_FIELD64(env, ri) \
>     (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
>+#define CPREG_FIELD128(env, ri) \
>+    (*(Int128 *)((char *)(env) + (ri)->fieldoffset))
> 
> uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri)
> {
>@@ -88,8 +90,23 @@ void raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
>     }
> }
> 
>+Int128 raw_read128(CPUARMState *env, const ARMCPRegInfo *ri)
>+{
>+    assert(ri->type & ARM_CP_128BIT);
>+    assert(ri->fieldoffset);
>+    return CPREG_FIELD128(env, ri);
>+}
>+
>+void raw_write128(CPUARMState *env, const ARMCPRegInfo *ri, Int128 value)
>+{
>+    assert(ri->type & ARM_CP_128BIT);
>+    assert(ri->fieldoffset);
>+    CPREG_FIELD128(env, ri) = value;
>+}
>+
> #undef CPREG_FIELD32
> #undef CPREG_FIELD64
>+#undef CPREG_FIELD128
> 
> static void *raw_ptr(CPUARMState *env, const ARMCPRegInfo *ri)
> {
>-- 
>2.43.0
>
>