All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Pétrot" <frederic.petrot@univ-grenoble-alpes.fr>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: bin.meng@windriver.com, richard.henderson@linaro.org,
	f4bug@amsat.org, palmer@dabbelt.com,
	fabien.portas@grenoble-inp.org, alistair.francis@wdc.com,
	"Frédéric Pétrot" <frederic.petrot@univ-grenoble-alpes.fr>
Subject: [PATCH v8 06/18] target/riscv: array for the 64 upper bits of 128-bit registers
Date: Thu,  6 Jan 2022 22:00:56 +0100	[thread overview]
Message-ID: <20220106210108.138226-7-frederic.petrot@univ-grenoble-alpes.fr> (raw)
In-Reply-To: <20220106210108.138226-1-frederic.petrot@univ-grenoble-alpes.fr>

The upper 64-bit of the 128-bit registers have now a place inside
the cpu state structure, and are created as globals for future use.

Signed-off-by: Frédéric Pétrot <frederic.petrot@univ-grenoble-alpes.fr>
Co-authored-by: Fabien Portas <fabien.portas@grenoble-inp.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/cpu.h       |  2 ++
 target/riscv/cpu.c       |  9 +++++++++
 target/riscv/machine.c   | 20 ++++++++++++++++++++
 target/riscv/translate.c |  5 ++++-
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index dc10f27093..fa5d238530 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -112,6 +112,7 @@ FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 1, 1)
 
 struct CPURISCVState {
     target_ulong gpr[32];
+    target_ulong gprh[32]; /* 64 top bits of the 128-bit registers */
     uint64_t fpr[32]; /* assume both F and D extensions */
 
     /* vector coprocessor state. */
@@ -344,6 +345,7 @@ static inline bool riscv_feature(CPURISCVState *env, int feature)
 #include "cpu_user.h"
 
 extern const char * const riscv_int_regnames[];
+extern const char * const riscv_int_regnamesh[];
 extern const char * const riscv_fpr_regnames[];
 
 const char *riscv_cpu_get_trap_name(target_ulong cause, bool async);
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 29749e834f..7b8197db98 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -42,6 +42,15 @@ const char * const riscv_int_regnames[] = {
   "x28/t3",  "x29/t4", "x30/t5", "x31/t6"
 };
 
+const char * const riscv_int_regnamesh[] = {
+  "x0h/zeroh", "x1h/rah",  "x2h/sph",   "x3h/gph",   "x4h/tph",  "x5h/t0h",
+  "x6h/t1h",   "x7h/t2h",  "x8h/s0h",   "x9h/s1h",   "x10h/a0h", "x11h/a1h",
+  "x12h/a2h",  "x13h/a3h", "x14h/a4h",  "x15h/a5h",  "x16h/a6h", "x17h/a7h",
+  "x18h/s2h",  "x19h/s3h", "x20h/s4h",  "x21h/s5h",  "x22h/s6h", "x23h/s7h",
+  "x24h/s8h",  "x25h/s9h", "x26h/s10h", "x27h/s11h", "x28h/t3h", "x29h/t4h",
+  "x30h/t5h",  "x31h/t6h"
+};
+
 const char * const riscv_fpr_regnames[] = {
   "f0/ft0",   "f1/ft1",  "f2/ft2",   "f3/ft3",   "f4/ft4",  "f5/ft5",
   "f6/ft6",   "f7/ft7",  "f8/fs0",   "f9/fs1",   "f10/fa0", "f11/fa1",
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index ad8248ebfd..8af9caabf5 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -164,6 +164,25 @@ static const VMStateDescription vmstate_pointermasking = {
     }
 };
 
+static bool rv128_needed(void *opaque)
+{
+    RISCVCPU *cpu = opaque;
+    CPURISCVState *env = &cpu->env;
+
+    return env->misa_mxl_max == MXL_RV128;
+}
+
+static const VMStateDescription vmstate_rv128 = {
+    .name = "cpu/rv128",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = rv128_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINTTL_ARRAY(env.gprh, RISCVCPU, 32),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_riscv_cpu = {
     .name = "cpu",
     .version_id = 3,
@@ -218,6 +237,7 @@ const VMStateDescription vmstate_riscv_cpu = {
         &vmstate_hyper,
         &vmstate_vector,
         &vmstate_pointermasking,
+        &vmstate_rv128,
         NULL
     }
 };
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index c3b4950ad0..6c400e8452 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -33,7 +33,7 @@
 #include "internals.h"
 
 /* global register indices */
-static TCGv cpu_gpr[32], cpu_pc, cpu_vl, cpu_vstart;
+static TCGv cpu_gpr[32], cpu_gprh[32], cpu_pc, cpu_vl, cpu_vstart;
 static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */
 static TCGv load_res;
 static TCGv load_val;
@@ -858,10 +858,13 @@ void riscv_translate_init(void)
      * unless you specifically block reads/writes to reg 0.
      */
     cpu_gpr[0] = NULL;
+    cpu_gprh[0] = NULL;
 
     for (i = 1; i < 32; i++) {
         cpu_gpr[i] = tcg_global_mem_new(cpu_env,
             offsetof(CPURISCVState, gpr[i]), riscv_int_regnames[i]);
+        cpu_gprh[i] = tcg_global_mem_new(cpu_env,
+            offsetof(CPURISCVState, gprh[i]), riscv_int_regnamesh[i]);
     }
 
     for (i = 0; i < 32; i++) {
-- 
2.34.1



WARNING: multiple messages have this Message-ID (diff)
From: "Frédéric Pétrot" <frederic.petrot@univ-grenoble-alpes.fr>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: alistair.francis@wdc.com, richard.henderson@linaro.org,
	bin.meng@windriver.com, f4bug@amsat.org, palmer@dabbelt.com,
	fabien.portas@grenoble-inp.org,
	"Frédéric Pétrot" <frederic.petrot@univ-grenoble-alpes.fr>
Subject: [PATCH v8 06/18] target/riscv: array for the 64 upper bits of 128-bit registers
Date: Thu,  6 Jan 2022 22:00:56 +0100	[thread overview]
Message-ID: <20220106210108.138226-7-frederic.petrot@univ-grenoble-alpes.fr> (raw)
In-Reply-To: <20220106210108.138226-1-frederic.petrot@univ-grenoble-alpes.fr>

The upper 64-bit of the 128-bit registers have now a place inside
the cpu state structure, and are created as globals for future use.

Signed-off-by: Frédéric Pétrot <frederic.petrot@univ-grenoble-alpes.fr>
Co-authored-by: Fabien Portas <fabien.portas@grenoble-inp.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/cpu.h       |  2 ++
 target/riscv/cpu.c       |  9 +++++++++
 target/riscv/machine.c   | 20 ++++++++++++++++++++
 target/riscv/translate.c |  5 ++++-
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index dc10f27093..fa5d238530 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -112,6 +112,7 @@ FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 1, 1)
 
 struct CPURISCVState {
     target_ulong gpr[32];
+    target_ulong gprh[32]; /* 64 top bits of the 128-bit registers */
     uint64_t fpr[32]; /* assume both F and D extensions */
 
     /* vector coprocessor state. */
@@ -344,6 +345,7 @@ static inline bool riscv_feature(CPURISCVState *env, int feature)
 #include "cpu_user.h"
 
 extern const char * const riscv_int_regnames[];
+extern const char * const riscv_int_regnamesh[];
 extern const char * const riscv_fpr_regnames[];
 
 const char *riscv_cpu_get_trap_name(target_ulong cause, bool async);
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 29749e834f..7b8197db98 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -42,6 +42,15 @@ const char * const riscv_int_regnames[] = {
   "x28/t3",  "x29/t4", "x30/t5", "x31/t6"
 };
 
+const char * const riscv_int_regnamesh[] = {
+  "x0h/zeroh", "x1h/rah",  "x2h/sph",   "x3h/gph",   "x4h/tph",  "x5h/t0h",
+  "x6h/t1h",   "x7h/t2h",  "x8h/s0h",   "x9h/s1h",   "x10h/a0h", "x11h/a1h",
+  "x12h/a2h",  "x13h/a3h", "x14h/a4h",  "x15h/a5h",  "x16h/a6h", "x17h/a7h",
+  "x18h/s2h",  "x19h/s3h", "x20h/s4h",  "x21h/s5h",  "x22h/s6h", "x23h/s7h",
+  "x24h/s8h",  "x25h/s9h", "x26h/s10h", "x27h/s11h", "x28h/t3h", "x29h/t4h",
+  "x30h/t5h",  "x31h/t6h"
+};
+
 const char * const riscv_fpr_regnames[] = {
   "f0/ft0",   "f1/ft1",  "f2/ft2",   "f3/ft3",   "f4/ft4",  "f5/ft5",
   "f6/ft6",   "f7/ft7",  "f8/fs0",   "f9/fs1",   "f10/fa0", "f11/fa1",
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index ad8248ebfd..8af9caabf5 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -164,6 +164,25 @@ static const VMStateDescription vmstate_pointermasking = {
     }
 };
 
+static bool rv128_needed(void *opaque)
+{
+    RISCVCPU *cpu = opaque;
+    CPURISCVState *env = &cpu->env;
+
+    return env->misa_mxl_max == MXL_RV128;
+}
+
+static const VMStateDescription vmstate_rv128 = {
+    .name = "cpu/rv128",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = rv128_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINTTL_ARRAY(env.gprh, RISCVCPU, 32),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_riscv_cpu = {
     .name = "cpu",
     .version_id = 3,
@@ -218,6 +237,7 @@ const VMStateDescription vmstate_riscv_cpu = {
         &vmstate_hyper,
         &vmstate_vector,
         &vmstate_pointermasking,
+        &vmstate_rv128,
         NULL
     }
 };
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index c3b4950ad0..6c400e8452 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -33,7 +33,7 @@
 #include "internals.h"
 
 /* global register indices */
-static TCGv cpu_gpr[32], cpu_pc, cpu_vl, cpu_vstart;
+static TCGv cpu_gpr[32], cpu_gprh[32], cpu_pc, cpu_vl, cpu_vstart;
 static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */
 static TCGv load_res;
 static TCGv load_val;
@@ -858,10 +858,13 @@ void riscv_translate_init(void)
      * unless you specifically block reads/writes to reg 0.
      */
     cpu_gpr[0] = NULL;
+    cpu_gprh[0] = NULL;
 
     for (i = 1; i < 32; i++) {
         cpu_gpr[i] = tcg_global_mem_new(cpu_env,
             offsetof(CPURISCVState, gpr[i]), riscv_int_regnames[i]);
+        cpu_gprh[i] = tcg_global_mem_new(cpu_env,
+            offsetof(CPURISCVState, gprh[i]), riscv_int_regnamesh[i]);
     }
 
     for (i = 0; i < 32; i++) {
-- 
2.34.1



  parent reply	other threads:[~2022-01-06 21:08 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 21:00 [PATCH v8 00/18] Adding partial support for 128-bit riscv target Frédéric Pétrot
2022-01-06 21:00 ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 01/18] exec/memop: Adding signedness to quad definitions Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 02/18] exec/memop: Adding signed quad and octo defines Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 03/18] qemu/int128: addition of div/rem 128-bit operations Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 04/18] target/riscv: additional macros to check instruction support Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 05/18] target/riscv: separation of bitwise logic and arithmetic helpers Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:00 ` Frédéric Pétrot [this message]
2022-01-06 21:00   ` [PATCH v8 06/18] target/riscv: array for the 64 upper bits of 128-bit registers Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 07/18] target/riscv: setup everything for rv64 to support rv128 execution Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:24   ` Alistair Francis
2022-01-06 21:24     ` Alistair Francis
2022-01-07  6:23     ` Frédéric Pétrot
2022-01-07  6:23       ` Frédéric Pétrot
2022-01-07  6:47       ` Alistair Francis
2022-01-07  6:47         ` Alistair Francis
2022-01-07 16:46         ` Frédéric Pétrot
2022-01-07 16:46           ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 08/18] target/riscv: moving some insns close to similar insns Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 09/18] target/riscv: accessors to registers upper part and 128-bit load/store Frédéric Pétrot
2022-01-06 21:00   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 10/18] target/riscv: support for 128-bit bitwise instructions Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 11/18] target/riscv: support for 128-bit U-type instructions Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 12/18] target/riscv: support for 128-bit shift instructions Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 13/18] target/riscv: support for 128-bit arithmetic instructions Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 14/18] target/riscv: support for 128-bit M extension Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 15/18] target/riscv: adding high part of some csrs Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 16/18] target/riscv: helper functions to wrap calls to 128-bit csr insns Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 17/18] target/riscv: modification of the trans_csrxx for 128-bit support Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 18/18] target/riscv: actual functions to realize crs 128-bit insns Frédéric Pétrot
2022-01-06 21:01   ` Frédéric Pétrot
2022-01-09 22:06 ` [PATCH v8 00/18] Adding partial support for 128-bit riscv target Alistair Francis
2022-01-09 22:06   ` Alistair Francis

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=20220106210108.138226-7-frederic.petrot@univ-grenoble-alpes.fr \
    --to=frederic.petrot@univ-grenoble-alpes.fr \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=f4bug@amsat.org \
    --cc=fabien.portas@grenoble-inp.org \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@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.