[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/14] target/riscv: Split out the vill from vtype
From: |
LIU Zhiwei |
Subject: |
[PATCH v2 12/14] target/riscv: Split out the vill from vtype |
Date: |
Wed, 10 Nov 2021 15:04:50 +0800 |
We need not specially process vtype when XLEN changes.
Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
target/riscv/cpu.h | 1 +
target/riscv/csr.c | 15 ++++++++++++++-
target/riscv/machine.c | 1 +
target/riscv/vector_helper.c | 7 ++-----
4 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 73d7aa9ad7..e67531deab 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -121,6 +121,7 @@ struct CPURISCVState {
target_ulong vl;
target_ulong vstart;
target_ulong vtype;
+ target_ulong vill;
target_ulong pc;
target_ulong load_res;
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index 59e368f004..33e342f529 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -286,7 +286,20 @@ static RISCVException write_fcsr(CPURISCVState *env, int
csrno,
static RISCVException read_vtype(CPURISCVState *env, int csrno,
target_ulong *val)
{
- *val = env->vtype;
+ target_ulong vill;
+ switch (cpu_get_xl(env)) {
+ case MXL_RV32:
+ vill = env->vill << 31;
+ break;
+#ifdef TARGET_RISCV64
+ case MXL_RV64:
+ vill = env->vill << 63;
+ break;
+#endif
+ default:
+ g_assert_not_reached();
+ }
+ *val = vill | env->vtype;
return RISCV_EXCP_NONE;
}
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index 19e982d3f0..cc4dda4b93 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -104,6 +104,7 @@ static const VMStateDescription vmstate_vector = {
VMSTATE_UINTTL(env.vl, RISCVCPU),
VMSTATE_UINTTL(env.vstart, RISCVCPU),
VMSTATE_UINTTL(env.vtype, RISCVCPU),
+ VMSTATE_UINTTL(env.vill, RISCVCPU),
VMSTATE_END_OF_LIST()
}
};
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index 51bcf63d65..7d7b554789 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -45,11 +45,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong
s1,
}
if ((sew > cpu->cfg.elen) || vill || (ediv != 0) || (reserved != 0)) {
/* only set vill bit. */
- if (xlen < TARGET_LONG_BITS) {
- env->vtype = FIELD_DP64(0, VTYPE, VILL_XLEN32, 1);
- } else {
- env->vtype = FIELD_DP64(0, VTYPE, VILL, 1);
- }
+ env->vill = 1;
+ env->vtype = 0;
env->vl = 0;
env->vstart = 0;
return 0;
--
2.25.1
[PATCH v2 13/14] target/riscv: Don't save pc when exception return, LIU Zhiwei, 2021/11/10
[PATCH v2 14/14] target/riscv: Enable uxl field write, LIU Zhiwei, 2021/11/10