[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 19/78] target/riscv: rvv-1.0: configure instructions
From: |
frank . chang |
Subject: |
[PATCH v8 19/78] target/riscv: rvv-1.0: configure instructions |
Date: |
Fri, 15 Oct 2021 15:45:21 +0800 |
From: Frank Chang <frank.chang@sifive.com>
Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
target/riscv/insn_trans/trans_rvv.c.inc | 64 +++++++++++--------------
target/riscv/vector_helper.c | 14 +++++-
2 files changed, 41 insertions(+), 37 deletions(-)
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc
b/target/riscv/insn_trans/trans_rvv.c.inc
index ddea578d0ba..ddc5f602768 100644
--- a/target/riscv/insn_trans/trans_rvv.c.inc
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
@@ -120,59 +120,51 @@ static bool require_noover(const int8_t dst, const int8_t
dst_lmul,
return !is_overlapped(dst, dst_size, src, src_size);
}
-static bool trans_vsetvl(DisasContext *ctx, arg_vsetvl *a)
+static bool do_vsetvl(DisasContext *s, int rd, int rs1, TCGv s2)
{
- TCGv s1, s2, dst;
+ TCGv s1, dst;
- if (!require_rvv(ctx) || !has_ext(ctx, RVV)) {
+ if (!require_rvv(s) || !has_ext(s, RVV)) {
return false;
}
- s2 = get_gpr(ctx, a->rs2, EXT_ZERO);
- dst = dest_gpr(ctx, a->rd);
+ dst = dest_gpr(s, rd);
- /* Using x0 as the rs1 register specifier, encodes an infinite AVL */
- if (a->rs1 == 0) {
+ if (rd == 0 && rs1 == 0) {
+ s1 = tcg_temp_new();
+ tcg_gen_mov_tl(s1, cpu_vl);
+ } else if (rs1 == 0) {
/* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */
s1 = tcg_constant_tl(RV_VLEN_MAX);
} else {
- s1 = get_gpr(ctx, a->rs1, EXT_ZERO);
+ s1 = get_gpr(s, rs1, EXT_ZERO);
}
- gen_helper_vsetvl(dst, cpu_env, s1, s2);
- gen_set_gpr(ctx, a->rd, dst);
- mark_vs_dirty(ctx);
- tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn);
- lookup_and_goto_ptr(ctx);
- ctx->base.is_jmp = DISAS_NORETURN;
- return true;
-}
+ gen_helper_vsetvl(dst, cpu_env, s1, s2);
+ gen_set_gpr(s, rd, dst);
+ mark_vs_dirty(s);
-static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a)
-{
- TCGv s1, s2, dst;
+ tcg_gen_movi_tl(cpu_pc, s->pc_succ_insn);
+ lookup_and_goto_ptr(s);
+ s->base.is_jmp = DISAS_NORETURN;
- if (!require_rvv(ctx) || !has_ext(ctx, RVV)) {
- return false;
+ if (rd == 0 && rs1 == 0) {
+ tcg_temp_free(s1);
}
- s2 = tcg_constant_tl(a->zimm);
- dst = dest_gpr(ctx, a->rd);
+ return true;
+}
- /* Using x0 as the rs1 register specifier, encodes an infinite AVL */
- if (a->rs1 == 0) {
- /* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */
- s1 = tcg_constant_tl(RV_VLEN_MAX);
- } else {
- s1 = get_gpr(ctx, a->rs1, EXT_ZERO);
- }
- gen_helper_vsetvl(dst, cpu_env, s1, s2);
- gen_set_gpr(ctx, a->rd, dst);
- mark_vs_dirty(ctx);
+static bool trans_vsetvl(DisasContext *s, arg_vsetvl *a)
+{
+ TCGv s2 = get_gpr(s, a->rs2, EXT_ZERO);
+ return do_vsetvl(s, a->rd, a->rs1, s2);
+}
- gen_goto_tb(ctx, 0, ctx->pc_succ_insn);
- ctx->base.is_jmp = DISAS_NORETURN;
- return true;
+static bool trans_vsetvli(DisasContext *s, arg_vsetvli *a)
+{
+ TCGv s2 = tcg_constant_tl(a->zimm);
+ return do_vsetvl(s, a->rd, a->rs1, s2);
}
/* vector register offset from env */
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index bf976d364f1..78fae782840 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -31,12 +31,24 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env,
target_ulong s1,
{
int vlmax, vl;
RISCVCPU *cpu = env_archcpu(env);
+ uint64_t lmul = FIELD_EX64(s2, VTYPE, VLMUL);
uint16_t sew = 8 << FIELD_EX64(s2, VTYPE, VSEW);
uint8_t ediv = FIELD_EX64(s2, VTYPE, VEDIV);
bool vill = FIELD_EX64(s2, VTYPE, VILL);
target_ulong reserved = FIELD_EX64(s2, VTYPE, RESERVED);
- if ((sew > cpu->cfg.elen) || vill || (ediv != 0) || (reserved != 0)) {
+ if (lmul & 4) {
+ /* Fractional LMUL. */
+ if (lmul == 4 ||
+ cpu->cfg.elen >> (8 - lmul) < sew) {
+ vill = true;
+ }
+ }
+
+ if ((sew > cpu->cfg.elen)
+ || vill
+ || (ediv != 0)
+ || (reserved != 0)) {
/* only set vill bit. */
env->vtype = FIELD_DP64(0, VTYPE, VILL, 1);
env->vl = 0;
--
2.25.1
- [PATCH v8 11/78] target/riscv: rvv-1.0: check MSTATUS_VS when accessing vector csr registers, (continued)
- [PATCH v8 11/78] target/riscv: rvv-1.0: check MSTATUS_VS when accessing vector csr registers, frank . chang, 2021/10/15
- [PATCH v8 12/78] target/riscv: rvv-1.0: remove MLEN calculations, frank . chang, 2021/10/15
- [PATCH v8 13/78] target/riscv: rvv-1.0: add fractional LMUL, frank . chang, 2021/10/15
- [PATCH v8 17/78] target/riscv: rvv:1.0: add translation-time nan-box helper function, frank . chang, 2021/10/15
- [PATCH v8 14/78] target/riscv: rvv-1.0: add VMA and VTA, frank . chang, 2021/10/15
- [PATCH 18/76] target/riscv: rvv-1.0: configure instructions, frank . chang, 2021/10/15
- [PATCH v8 18/78] target/riscv: rvv-1.0: remove amo operations instructions, frank . chang, 2021/10/15
- [PATCH v8 15/78] target/riscv: rvv-1.0: update check functions, frank . chang, 2021/10/15
- [PATCH v8 16/78] target/riscv: introduce more imm value modes in translator functions, frank . chang, 2021/10/15
- [PATCH v8 19/78] target/riscv: rvv-1.0: configure instructions,
frank . chang <=
- [PATCH 19/76] target/riscv: rvv-1.0: stride load and store instructions, frank . chang, 2021/10/15
- [PATCH 20/76] target/riscv: rvv-1.0: index load and store instructions, frank . chang, 2021/10/15
- [PATCH v8 20/78] target/riscv: rvv-1.0: stride load and store instructions, frank . chang, 2021/10/15
- [PATCH 21/76] target/riscv: rvv-1.0: fix address index overflow bug of indexed load/store insns, frank . chang, 2021/10/15
- [PATCH 22/76] target/riscv: rvv-1.0: fault-only-first unit stride load, frank . chang, 2021/10/15
- [PATCH v8 22/78] target/riscv: rvv-1.0: fix address index overflow bug of indexed load/store insns, frank . chang, 2021/10/15
- [PATCH v8 21/78] target/riscv: rvv-1.0: index load and store instructions, frank . chang, 2021/10/15
- [PATCH 23/76] target/riscv: rvv-1.0: amo operations, frank . chang, 2021/10/15
- [PATCH v8 23/78] target/riscv: rvv-1.0: fault-only-first unit stride load, frank . chang, 2021/10/15
- [PATCH v8 24/78] target/riscv: rvv-1.0: load/store whole register instructions, frank . chang, 2021/10/15