All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Gao <gaosong@loongson.cn>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org
Subject: [RFC PATCH v2 01/44] target/loongarch: Add LSX data type VReg
Date: Tue, 28 Mar 2023 11:05:48 +0800	[thread overview]
Message-ID: <20230328030631.3117129-2-gaosong@loongson.cn> (raw)
In-Reply-To: <20230328030631.3117129-1-gaosong@loongson.cn>

Signed-off-by: Song Gao <gaosong@loongson.cn>
---
 linux-user/loongarch64/signal.c |  4 ++--
 target/loongarch/cpu.c          |  2 +-
 target/loongarch/cpu.h          | 31 +++++++++++++++++++++++++++++-
 target/loongarch/gdbstub.c      |  4 ++--
 target/loongarch/machine.c      | 34 ++++++++++++++++++++++++++++++++-
 5 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signal.c
index 7c7afb652e..bb8efb1172 100644
--- a/linux-user/loongarch64/signal.c
+++ b/linux-user/loongarch64/signal.c
@@ -128,7 +128,7 @@ static void setup_sigframe(CPULoongArchState *env,
 
     fpu_ctx = (struct target_fpu_context *)(info + 1);
     for (i = 0; i < 32; ++i) {
-        __put_user(env->fpr[i], &fpu_ctx->regs[i]);
+        __put_user(env->fpr[i].vreg.D(0), &fpu_ctx->regs[i]);
     }
     __put_user(read_fcc(env), &fpu_ctx->fcc);
     __put_user(env->fcsr0, &fpu_ctx->fcsr);
@@ -193,7 +193,7 @@ static void restore_sigframe(CPULoongArchState *env,
         uint64_t fcc;
 
         for (i = 0; i < 32; ++i) {
-            __get_user(env->fpr[i], &fpu_ctx->regs[i]);
+            __get_user(env->fpr[i].vreg.D(0), &fpu_ctx->regs[i]);
         }
         __get_user(fcc, &fpu_ctx->fcc);
         write_fcc(env, fcc);
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 97e6579f6a..18b41221a6 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -656,7 +656,7 @@ void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags)
     /* fpr */
     if (flags & CPU_DUMP_FPU) {
         for (i = 0; i < 32; i++) {
-            qemu_fprintf(f, " %s %016" PRIx64, fregnames[i], env->fpr[i]);
+            qemu_fprintf(f, " %s %016" PRIx64, fregnames[i], env->fpr[i].vreg.D(0));
             if ((i & 3) == 3) {
                 qemu_fprintf(f, "\n");
             }
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index e11c875188..6e5fa6a01d 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -8,6 +8,7 @@
 #ifndef LOONGARCH_CPU_H
 #define LOONGARCH_CPU_H
 
+#include "qemu/int128.h"
 #include "exec/cpu-defs.h"
 #include "fpu/softfloat-types.h"
 #include "hw/registerfields.h"
@@ -241,6 +242,34 @@ FIELD(TLB_MISC, ASID, 1, 10)
 FIELD(TLB_MISC, VPPN, 13, 35)
 FIELD(TLB_MISC, PS, 48, 6)
 
+#define LSX_LEN   (128)
+typedef union VReg {
+    int8_t   B[LSX_LEN / 8];
+    int16_t  H[LSX_LEN / 16];
+    int32_t  W[LSX_LEN / 32];
+    int64_t  D[LSX_LEN / 64];
+    Int128   Q[LSX_LEN / 128];
+}VReg;
+
+typedef union fpr_t fpr_t;
+union fpr_t {
+    VReg  vreg;
+};
+
+#if  HOST_BIG_ENDIAN
+#define B(x)  B[15 - (x)]
+#define H(x)  H[7 - (x)]
+#define W(x)  W[3 - (x)]
+#define D(x)  D[1 - (x)]
+#define Q(x)  Q[x]
+#else
+#define B(x)  B[x]
+#define H(x)  H[x]
+#define W(x)  W[x]
+#define D(x)  D[x]
+#define Q(x)  Q[x]
+#endif
+
 struct LoongArchTLB {
     uint64_t tlb_misc;
     /* Fields corresponding to CSR_TLBELO0/1 */
@@ -253,7 +282,7 @@ typedef struct CPUArchState {
     uint64_t gpr[32];
     uint64_t pc;
 
-    uint64_t fpr[32];
+    fpr_t fpr[32];
     float_status fp_status;
     bool cf[8];
 
diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c
index fa3e034d15..0752fff924 100644
--- a/target/loongarch/gdbstub.c
+++ b/target/loongarch/gdbstub.c
@@ -69,7 +69,7 @@ static int loongarch_gdb_get_fpu(CPULoongArchState *env,
                                  GByteArray *mem_buf, int n)
 {
     if (0 <= n && n < 32) {
-        return gdb_get_reg64(mem_buf, env->fpr[n]);
+        return gdb_get_reg64(mem_buf, env->fpr[n].vreg.D(0));
     } else if (n == 32) {
         uint64_t val = read_fcc(env);
         return gdb_get_reg64(mem_buf, val);
@@ -85,7 +85,7 @@ static int loongarch_gdb_set_fpu(CPULoongArchState *env,
     int length = 0;
 
     if (0 <= n && n < 32) {
-        env->fpr[n] = ldq_p(mem_buf);
+        env->fpr[n].vreg.D(0) = ldq_p(mem_buf);
         length = 8;
     } else if (n == 32) {
         uint64_t val = ldq_p(mem_buf);
diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
index b1e523ea72..54e67e63bc 100644
--- a/target/loongarch/machine.c
+++ b/target/loongarch/machine.c
@@ -33,7 +33,39 @@ const VMStateDescription vmstate_loongarch_cpu = {
 
         VMSTATE_UINTTL_ARRAY(env.gpr, LoongArchCPU, 32),
         VMSTATE_UINTTL(env.pc, LoongArchCPU),
-        VMSTATE_UINT64_ARRAY(env.fpr, LoongArchCPU, 32),
+        VMSTATE_INT64(env.fpr[0].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[1].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[2].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[3].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[4].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[5].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[6].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[7].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[8].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[9].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[10].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[11].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[12].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[13].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[14].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[15].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[16].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[17].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[18].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[19].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[20].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[21].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[22].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[23].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[24].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[25].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[26].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[27].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[28].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[29].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[30].vreg.D(0), LoongArchCPU),
+        VMSTATE_INT64(env.fpr[31].vreg.D(0), LoongArchCPU),
+
         VMSTATE_UINT32(env.fcsr0, LoongArchCPU),
         VMSTATE_BOOL_ARRAY(env.cf, LoongArchCPU, 8),
 
-- 
2.31.1



  reply	other threads:[~2023-03-28  3:08 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28  3:05 [RFC PATCH v2 00/44] Add LoongArch LSX instructions Song Gao
2023-03-28  3:05 ` Song Gao [this message]
2023-03-28 19:56   ` [RFC PATCH v2 01/44] target/loongarch: Add LSX data type VReg Richard Henderson
2023-03-29  2:28     ` gaosong
2023-03-28  3:05 ` [RFC PATCH v2 02/44] target/loongarch: CPUCFG support LSX Song Gao
2023-03-28 19:33   ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 03/44] target/loongarch: meson.build support build LSX Song Gao
2023-03-28 19:35   ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 04/44] target/loongarch: Add CHECK_SXE maccro for check LSX enable Song Gao
2023-03-28 19:42   ` Richard Henderson
2023-03-29  2:28     ` gaosong
2023-03-28  3:05 ` [RFC PATCH v2 05/44] target/loongarch: Implement vadd/vsub Song Gao
2023-03-28 19:50   ` Richard Henderson
2023-03-28 19:59   ` Richard Henderson
2023-03-29  9:59     ` gaosong
2023-03-29 15:22       ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 06/44] target/loongarch: Implement vaddi/vsubi Song Gao
2023-03-28 19:58   ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 07/44] target/loongarch: Implement vneg Song Gao
2023-03-28 20:02   ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 08/44] target/loongarch: Implement vsadd/vssub Song Gao
2023-03-28 20:03   ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 09/44] target/loongarch: Implement vhaddw/vhsubw Song Gao
2023-03-28 20:17   ` Richard Henderson
2023-03-29  3:24     ` gaosong
2023-03-29 15:25       ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 10/44] target/loongarch: Implement vaddw/vsubw Song Gao
2023-03-28 20:28   ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 11/44] target/loongarch: Implement vavg/vavgr Song Gao
2023-03-28 20:31   ` Richard Henderson
2023-03-28  3:05 ` [RFC PATCH v2 12/44] target/loongarch: Implement vabsd Song Gao
2023-03-28 20:32   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 13/44] target/loongarch: Implement vadda Song Gao
2023-03-28 20:33   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 14/44] target/loongarch: Implement vmax/vmin Song Gao
2023-03-28 20:39   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 15/44] target/loongarch: Implement vmul/vmuh/vmulw{ev/od} Song Gao
2023-03-28 20:46   ` Richard Henderson
2023-04-06 12:09     ` gaosong
2023-04-06 16:52       ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 16/44] target/loongarch: Implement vmadd/vmsub/vmaddw{ev/od} Song Gao
2023-03-28 20:50   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 17/44] target/loongarch: Implement vdiv/vmod Song Gao
2023-03-28 20:52   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 18/44] target/loongarch: Implement vsat Song Gao
2023-04-01  5:03   ` Richard Henderson
2023-04-03 12:55     ` gaosong
2023-04-03 20:13       ` Richard Henderson
2023-04-04  2:11         ` gaosong
2023-04-04  3:46           ` Richard Henderson
2023-04-19  9:31     ` Song Gao
2023-04-19 11:06       ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 19/44] target/loongarch: Implement vexth Song Gao
2023-04-01  5:07   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 20/44] target/loongarch: Implement vsigncov Song Gao
2023-04-01  5:11   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 21/44] target/loongarch: Implement vmskltz/vmskgez/vmsknz Song Gao
2023-04-01  5:20   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 22/44] target/loongarch: Implement LSX logic instructions Song Gao
2023-04-01  5:31   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 23/44] target/loongarch: Implement vsll vsrl vsra vrotr Song Gao
2023-04-01  5:38   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 24/44] target/loongarch: Implement vsllwil vextl Song Gao
2023-04-01  5:40   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 25/44] target/loongarch: Implement vsrlr vsrar Song Gao
2023-04-01  5:42   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 26/44] target/loongarch: Implement vsrln vsran Song Gao
2023-04-01  5:46   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 27/44] target/loongarch: Implement vsrlrn vsrarn Song Gao
2023-04-01  5:53   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 28/44] target/loongarch: Implement vssrln vssran Song Gao
2023-04-02  3:26   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 29/44] target/loongarch: Implement vssrlrn vssrarn Song Gao
2023-04-02  3:31   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 30/44] target/loongarch: Implement vclo vclz Song Gao
2023-04-02  3:34   ` Richard Henderson
2023-04-07  7:40     ` gaosong
2023-04-07 16:46       ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 31/44] target/loongarch: Implement vpcnt Song Gao
2023-04-02  3:35   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 32/44] target/loongarch: Implement vbitclr vbitset vbitrev Song Gao
2023-04-02  5:14   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 33/44] target/loongarch: Implement vfrstp Song Gao
2023-04-02  5:17   ` Richard Henderson
2023-04-03  2:27     ` gaosong
2023-03-28  3:06 ` [RFC PATCH v2 34/44] target/loongarch: Implement LSX fpu arith instructions Song Gao
2023-04-02  5:19   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 35/44] target/loongarch: Implement LSX fpu fcvt instructions Song Gao
2023-04-02  5:22   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 36/44] target/loongarch: Implement vseq vsle vslt Song Gao
2023-04-02  5:27   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 37/44] target/loongarch: Implement vfcmp Song Gao
2023-04-04  0:47   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 38/44] target/loongarch: Implement vbitsel vset Song Gao
2023-04-04  1:03   ` Richard Henderson
2023-04-11 11:37     ` gaosong
2023-04-12  6:53       ` Richard Henderson
2023-04-13  2:53         ` gaosong
2023-04-13 10:06           ` Richard Henderson
2023-04-14  3:22             ` gaosong
2023-04-14  3:47               ` gaosong
2023-03-28  3:06 ` [RFC PATCH v2 39/44] target/loongarch: Implement vinsgr2vr vpickve2gr vreplgr2vr Song Gao
2023-04-04  1:09   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 40/44] target/loongarch: Implement vreplve vpack vpick Song Gao
2023-04-04  1:17   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 41/44] target/loongarch: Implement vilvl vilvh vextrins vshuf Song Gao
2023-04-04  1:31   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 42/44] target/loongarch: Implement vld vst Song Gao
2023-04-04  3:35   ` Richard Henderson
2023-03-28  3:06 ` [RFC PATCH v2 43/44] target/loongarch: Implement vldi Song Gao
2023-04-04  3:39   ` Richard Henderson
2023-04-18  9:03     ` Song Gao
2023-03-28  3:06 ` [RFC PATCH v2 44/44] target/loongarch: Use {set/get}_gpr replace to cpu_fpr Song Gao
2023-04-04  3:44   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230328030631.3117129-2-gaosong@loongson.cn \
    --to=gaosong@loongson.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.