1 | The following changes since commit 553cf5d7c47bee05a3dec9461c1f8430316d516b: | 1 | The following changes since commit ad10b4badc1dd5b28305f9b9f1168cf0aa3ae946: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20200626' into staging (2020-06-26 18:22:36 +0100) | 3 | Merge tag 'pull-error-2024-05-27' of https://repo.or.cz/qemu/armbru into staging (2024-05-27 06:40:42 -0700) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20200626-1 | 7 | https://github.com/alistair23/qemu.git tags/pull-riscv-to-apply-20240528 |
8 | 8 | ||
9 | for you to fetch changes up to b39d59434ea10649fdb9e0a339c30c76e38c5e17: | 9 | for you to fetch changes up to 1806da76cb81088ea026ca3441551782b850e393: |
10 | 10 | ||
11 | target/riscv: configure and turn on vector extension from command line (2020-06-26 14:22:15 -0700) | 11 | target/riscv: raise an exception when CSRRS/CSRRC writes a read-only CSR (2024-05-28 12:20:27 +1000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | This PR contains two patches to improve PLIC support in QEMU. | 14 | RISC-V PR for 9.1 |
15 | 15 | ||
16 | The rest of the PR is adding support for the v0.7.1 RISC-V vector | 16 | * APLICs add child earlier than realize |
17 | extensions. This is experimental support as the vector extensions are | 17 | * Fix exposure of Zkr |
18 | still in a draft state. | 18 | * Raise exceptions on wrs.nto |
19 | * Implement SBI debug console (DBCN) calls for KVM | ||
20 | * Support 64-bit addresses for initrd | ||
21 | * Change RISCV_EXCP_SEMIHOST exception number to 63 | ||
22 | * Tolerate KVM disable ext errors | ||
23 | * Set tval in breakpoints | ||
24 | * Add support for Zve32x extension | ||
25 | * Add support for Zve64x extension | ||
26 | * Relax vector register check in RISCV gdbstub | ||
27 | * Fix the element agnostic Vector function problem | ||
28 | * Fix Zvkb extension config | ||
29 | * Implement dynamic establishment of custom decoder | ||
30 | * Add th.sxstatus CSR emulation | ||
31 | * Fix Zvfhmin checking for vfwcvt.f.f.v and vfncvt.f.f.w instructions | ||
32 | * Check single width operator for vector fp widen instructions | ||
33 | * Check single width operator for vfncvt.rod.f.f.w | ||
34 | * Remove redudant SEW checking for vector fp narrow/widen instructions | ||
35 | * Prioritize pmp errors in raise_mmu_exception() | ||
36 | * Do not set mtval2 for non guest-page faults | ||
37 | * Remove experimental prefix from "B" extension | ||
38 | * Fixup CBO extension register calculation | ||
39 | * Fix the hart bit setting of AIA | ||
40 | * Fix reg_width in ricsv_gen_dynamic_vector_feature() | ||
41 | * Decode all of the pmpcfg and pmpaddr CSRs | ||
42 | * Raise an exception when CSRRS/CSRRC writes a read-only CSR | ||
19 | 43 | ||
20 | ---------------------------------------------------------------- | 44 | ---------------------------------------------------------------- |
21 | Jessica Clarke (2): | 45 | Alexei Filippov (1): |
22 | riscv: plic: Honour source priorities | 46 | target/riscv: do not set mtval2 for non guest-page faults |
23 | riscv: plic: Add a couple of mising sifive_plic_update calls | ||
24 | 47 | ||
25 | LIU Zhiwei (61): | 48 | Alistair Francis (2): |
26 | target/riscv: add vector extension field in CPURISCVState | 49 | target/riscv: rvzicbo: Fixup CBO extension register calculation |
27 | target/riscv: implementation-defined constant parameters | 50 | disas/riscv: Decode all of the pmpcfg and pmpaddr CSRs |
28 | target/riscv: support vector extension csr | ||
29 | target/riscv: add vector configure instruction | ||
30 | target/riscv: add an internals.h header | ||
31 | target/riscv: add vector stride load and store instructions | ||
32 | target/riscv: add vector index load and store instructions | ||
33 | target/riscv: add fault-only-first unit stride load | ||
34 | target/riscv: add vector amo operations | ||
35 | target/riscv: vector single-width integer add and subtract | ||
36 | target/riscv: vector widening integer add and subtract | ||
37 | target/riscv: vector integer add-with-carry / subtract-with-borrow instructions | ||
38 | target/riscv: vector bitwise logical instructions | ||
39 | target/riscv: vector single-width bit shift instructions | ||
40 | target/riscv: vector narrowing integer right shift instructions | ||
41 | target/riscv: vector integer comparison instructions | ||
42 | target/riscv: vector integer min/max instructions | ||
43 | target/riscv: vector single-width integer multiply instructions | ||
44 | target/riscv: vector integer divide instructions | ||
45 | target/riscv: vector widening integer multiply instructions | ||
46 | target/riscv: vector single-width integer multiply-add instructions | ||
47 | target/riscv: vector widening integer multiply-add instructions | ||
48 | target/riscv: vector integer merge and move instructions | ||
49 | target/riscv: vector single-width saturating add and subtract | ||
50 | target/riscv: vector single-width averaging add and subtract | ||
51 | target/riscv: vector single-width fractional multiply with rounding and saturation | ||
52 | target/riscv: vector widening saturating scaled multiply-add | ||
53 | target/riscv: vector single-width scaling shift instructions | ||
54 | target/riscv: vector narrowing fixed-point clip instructions | ||
55 | target/riscv: vector single-width floating-point add/subtract instructions | ||
56 | target/riscv: vector widening floating-point add/subtract instructions | ||
57 | target/riscv: vector single-width floating-point multiply/divide instructions | ||
58 | target/riscv: vector widening floating-point multiply | ||
59 | target/riscv: vector single-width floating-point fused multiply-add instructions | ||
60 | target/riscv: vector widening floating-point fused multiply-add instructions | ||
61 | target/riscv: vector floating-point square-root instruction | ||
62 | target/riscv: vector floating-point min/max instructions | ||
63 | target/riscv: vector floating-point sign-injection instructions | ||
64 | target/riscv: vector floating-point compare instructions | ||
65 | target/riscv: vector floating-point classify instructions | ||
66 | target/riscv: vector floating-point merge instructions | ||
67 | target/riscv: vector floating-point/integer type-convert instructions | ||
68 | target/riscv: widening floating-point/integer type-convert instructions | ||
69 | target/riscv: narrowing floating-point/integer type-convert instructions | ||
70 | target/riscv: vector single-width integer reduction instructions | ||
71 | target/riscv: vector wideing integer reduction instructions | ||
72 | target/riscv: vector single-width floating-point reduction instructions | ||
73 | target/riscv: vector widening floating-point reduction instructions | ||
74 | target/riscv: vector mask-register logical instructions | ||
75 | target/riscv: vector mask population count vmpopc | ||
76 | target/riscv: vmfirst find-first-set mask bit | ||
77 | target/riscv: set-X-first mask bit | ||
78 | target/riscv: vector iota instruction | ||
79 | target/riscv: vector element index instruction | ||
80 | target/riscv: integer extract instruction | ||
81 | target/riscv: integer scalar move instruction | ||
82 | target/riscv: floating-point scalar move instructions | ||
83 | target/riscv: vector slide instructions | ||
84 | target/riscv: vector register gather instruction | ||
85 | target/riscv: vector compress instruction | ||
86 | target/riscv: configure and turn on vector extension from command line | ||
87 | 51 | ||
88 | target/riscv/cpu.h | 82 +- | 52 | Andrew Jones (2): |
89 | target/riscv/cpu_bits.h | 15 + | 53 | target/riscv/kvm: Fix exposure of Zkr |
90 | target/riscv/helper.h | 1069 +++++++ | 54 | target/riscv: Raise exceptions on wrs.nto |
91 | target/riscv/internals.h | 41 + | ||
92 | target/riscv/insn32-64.decode | 11 + | ||
93 | target/riscv/insn32.decode | 372 +++ | ||
94 | hw/riscv/sifive_plic.c | 20 +- | ||
95 | target/riscv/cpu.c | 50 + | ||
96 | target/riscv/csr.c | 75 +- | ||
97 | target/riscv/fpu_helper.c | 33 +- | ||
98 | target/riscv/insn_trans/trans_rvv.inc.c | 2888 ++++++++++++++++++ | ||
99 | target/riscv/translate.c | 27 +- | ||
100 | target/riscv/vector_helper.c | 4899 +++++++++++++++++++++++++++++++ | ||
101 | target/riscv/Makefile.objs | 2 +- | ||
102 | 14 files changed, 9534 insertions(+), 50 deletions(-) | ||
103 | create mode 100644 target/riscv/internals.h | ||
104 | create mode 100644 target/riscv/insn_trans/trans_rvv.inc.c | ||
105 | create mode 100644 target/riscv/vector_helper.c | ||
106 | 55 | ||
56 | Cheng Yang (1): | ||
57 | hw/riscv/boot.c: Support 64-bit address for initrd | ||
58 | |||
59 | Christoph Müllner (1): | ||
60 | riscv: thead: Add th.sxstatus CSR emulation | ||
61 | |||
62 | Clément Léger (1): | ||
63 | target/riscv: change RISCV_EXCP_SEMIHOST exception number to 63 | ||
64 | |||
65 | Daniel Henrique Barboza (6): | ||
66 | target/riscv/kvm: implement SBI debug console (DBCN) calls | ||
67 | target/riscv/kvm: tolerate KVM disable ext errors | ||
68 | target/riscv/debug: set tval=pc in breakpoint exceptions | ||
69 | trans_privileged.c.inc: set (m|s)tval on ebreak breakpoint | ||
70 | target/riscv: prioritize pmp errors in raise_mmu_exception() | ||
71 | riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature() | ||
72 | |||
73 | Huang Tao (2): | ||
74 | target/riscv: Fix the element agnostic function problem | ||
75 | target/riscv: Implement dynamic establishment of custom decoder | ||
76 | |||
77 | Jason Chien (3): | ||
78 | target/riscv: Add support for Zve32x extension | ||
79 | target/riscv: Add support for Zve64x extension | ||
80 | target/riscv: Relax vector register check in RISCV gdbstub | ||
81 | |||
82 | Max Chou (4): | ||
83 | target/riscv: rvv: Fix Zvfhmin checking for vfwcvt.f.f.v and vfncvt.f.f.w instructions | ||
84 | target/riscv: rvv: Check single width operator for vector fp widen instructions | ||
85 | target/riscv: rvv: Check single width operator for vfncvt.rod.f.f.w | ||
86 | target/riscv: rvv: Remove redudant SEW checking for vector fp narrow/widen instructions | ||
87 | |||
88 | Rob Bradford (1): | ||
89 | target/riscv: Remove experimental prefix from "B" extension | ||
90 | |||
91 | Yangyu Chen (1): | ||
92 | target/riscv/cpu.c: fix Zvkb extension config | ||
93 | |||
94 | Yong-Xuan Wang (1): | ||
95 | target/riscv/kvm.c: Fix the hart bit setting of AIA | ||
96 | |||
97 | Yu-Ming Chang (1): | ||
98 | target/riscv: raise an exception when CSRRS/CSRRC writes a read-only CSR | ||
99 | |||
100 | yang.zhang (1): | ||
101 | hw/intc/riscv_aplic: APLICs should add child earlier than realize | ||
102 | |||
103 | MAINTAINERS | 1 + | ||
104 | target/riscv/cpu.h | 11 ++ | ||
105 | target/riscv/cpu_bits.h | 2 +- | ||
106 | target/riscv/cpu_cfg.h | 2 + | ||
107 | target/riscv/helper.h | 1 + | ||
108 | target/riscv/sbi_ecall_interface.h | 17 +++ | ||
109 | target/riscv/tcg/tcg-cpu.h | 15 +++ | ||
110 | disas/riscv.c | 65 +++++++++- | ||
111 | hw/intc/riscv_aplic.c | 8 +- | ||
112 | hw/riscv/boot.c | 4 +- | ||
113 | target/riscv/cpu.c | 10 +- | ||
114 | target/riscv/cpu_helper.c | 37 +++--- | ||
115 | target/riscv/csr.c | 71 +++++++++-- | ||
116 | target/riscv/debug.c | 3 + | ||
117 | target/riscv/gdbstub.c | 8 +- | ||
118 | target/riscv/kvm/kvm-cpu.c | 157 ++++++++++++++++++++++++- | ||
119 | target/riscv/op_helper.c | 17 ++- | ||
120 | target/riscv/tcg/tcg-cpu.c | 50 +++++--- | ||
121 | target/riscv/th_csr.c | 79 +++++++++++++ | ||
122 | target/riscv/translate.c | 31 +++-- | ||
123 | target/riscv/vector_internals.c | 22 ++++ | ||
124 | target/riscv/insn_trans/trans_privileged.c.inc | 2 + | ||
125 | target/riscv/insn_trans/trans_rvv.c.inc | 46 +++++--- | ||
126 | target/riscv/insn_trans/trans_rvzawrs.c.inc | 29 +++-- | ||
127 | target/riscv/insn_trans/trans_rvzicbo.c.inc | 16 ++- | ||
128 | target/riscv/meson.build | 1 + | ||
129 | 26 files changed, 596 insertions(+), 109 deletions(-) | ||
130 | create mode 100644 target/riscv/th_csr.c | ||
131 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: "yang.zhang" <yang.zhang@hexintek.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Since only root APLICs can have hw IRQ lines, aplic->parent should |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | be initialized first. |
5 | Message-id: 20200623215920.2594-60-zhiwei_liu@c-sky.com | 5 | |
6 | Fixes: e8f79343cf ("hw/intc: Add RISC-V AIA APLIC device emulation") | ||
7 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
8 | Signed-off-by: yang.zhang <yang.zhang@hexintek.com> | ||
9 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
10 | Message-ID: <20240409014445.278-1-gaoshanliukou@163.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 12 | --- |
8 | target/riscv/helper.h | 9 +++ | 13 | hw/intc/riscv_aplic.c | 8 ++++---- |
9 | target/riscv/insn32.decode | 3 + | 14 | 1 file changed, 4 insertions(+), 4 deletions(-) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 78 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 60 +++++++++++++++++++ | ||
12 | 4 files changed, 150 insertions(+) | ||
13 | 15 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 16 | diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 18 | --- a/hw/intc/riscv_aplic.c |
17 | +++ b/target/riscv/helper.h | 19 | +++ b/hw/intc/riscv_aplic.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vslide1down_vx_b, void, ptr, ptr, tl, ptr, env, i32) | 20 | @@ -XXX,XX +XXX,XX @@ DeviceState *riscv_aplic_create(hwaddr addr, hwaddr size, |
19 | DEF_HELPER_6(vslide1down_vx_h, void, ptr, ptr, tl, ptr, env, i32) | 21 | qdev_prop_set_bit(dev, "msimode", msimode); |
20 | DEF_HELPER_6(vslide1down_vx_w, void, ptr, ptr, tl, ptr, env, i32) | 22 | qdev_prop_set_bit(dev, "mmode", mmode); |
21 | DEF_HELPER_6(vslide1down_vx_d, void, ptr, ptr, tl, ptr, env, i32) | 23 | |
22 | + | 24 | + if (parent) { |
23 | +DEF_HELPER_6(vrgather_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | 25 | + riscv_aplic_add_child(parent, dev); |
24 | +DEF_HELPER_6(vrgather_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vrgather_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vrgather_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vrgather_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vrgather_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vrgather_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vrgather_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
31 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/riscv/insn32.decode | ||
34 | +++ b/target/riscv/insn32.decode | ||
35 | @@ -XXX,XX +XXX,XX @@ vslide1up_vx 001110 . ..... ..... 110 ..... 1010111 @r_vm | ||
36 | vslidedown_vx 001111 . ..... ..... 100 ..... 1010111 @r_vm | ||
37 | vslidedown_vi 001111 . ..... ..... 011 ..... 1010111 @r_vm | ||
38 | vslide1down_vx 001111 . ..... ..... 110 ..... 1010111 @r_vm | ||
39 | +vrgather_vv 001100 . ..... ..... 000 ..... 1010111 @r_vm | ||
40 | +vrgather_vx 001100 . ..... ..... 100 ..... 1010111 @r_vm | ||
41 | +vrgather_vi 001100 . ..... ..... 011 ..... 1010111 @r_vm | ||
42 | |||
43 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
44 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
45 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
48 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
49 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVI_TRANS(vslideup_vi, 1, vslideup_vx, slideup_check) | ||
50 | GEN_OPIVX_TRANS(vslidedown_vx, opivx_check) | ||
51 | GEN_OPIVX_TRANS(vslide1down_vx, opivx_check) | ||
52 | GEN_OPIVI_TRANS(vslidedown_vi, 1, vslidedown_vx, opivx_check) | ||
53 | + | ||
54 | +/* Vector Register Gather Instruction */ | ||
55 | +static bool vrgather_vv_check(DisasContext *s, arg_rmrr *a) | ||
56 | +{ | ||
57 | + return (vext_check_isa_ill(s) && | ||
58 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
59 | + vext_check_reg(s, a->rd, false) && | ||
60 | + vext_check_reg(s, a->rs1, false) && | ||
61 | + vext_check_reg(s, a->rs2, false) && | ||
62 | + (a->rd != a->rs2) && (a->rd != a->rs1)); | ||
63 | +} | ||
64 | + | ||
65 | +GEN_OPIVV_TRANS(vrgather_vv, vrgather_vv_check) | ||
66 | + | ||
67 | +static bool vrgather_vx_check(DisasContext *s, arg_rmrr *a) | ||
68 | +{ | ||
69 | + return (vext_check_isa_ill(s) && | ||
70 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
71 | + vext_check_reg(s, a->rd, false) && | ||
72 | + vext_check_reg(s, a->rs2, false) && | ||
73 | + (a->rd != a->rs2)); | ||
74 | +} | ||
75 | + | ||
76 | +/* vrgather.vx vd, vs2, rs1, vm # vd[i] = (x[rs1] >= VLMAX) ? 0 : vs2[rs1] */ | ||
77 | +static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a) | ||
78 | +{ | ||
79 | + if (!vrgather_vx_check(s, a)) { | ||
80 | + return false; | ||
81 | + } | 26 | + } |
82 | + | 27 | + |
83 | + if (a->vm && s->vl_eq_vlmax) { | 28 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
84 | + int vlmax = s->vlen / s->mlen; | 29 | |
85 | + TCGv_i64 dest = tcg_temp_new_i64(); | 30 | if (!is_kvm_aia(msimode)) { |
86 | + | 31 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr); |
87 | + if (a->rs1 == 0) { | 32 | } |
88 | + vec_element_loadi(s, dest, a->rs2, 0); | 33 | |
89 | + } else { | 34 | - if (parent) { |
90 | + vec_element_loadx(s, dest, a->rs2, cpu_gpr[a->rs1], vlmax); | 35 | - riscv_aplic_add_child(parent, dev); |
91 | + } | 36 | - } |
92 | + | 37 | - |
93 | + tcg_gen_gvec_dup_i64(s->sew, vreg_ofs(s, a->rd), | 38 | if (!msimode) { |
94 | + MAXSZ(s), MAXSZ(s), dest); | 39 | for (i = 0; i < num_harts; i++) { |
95 | + tcg_temp_free_i64(dest); | 40 | CPUState *cpu = cpu_by_arch_id(hartid_base + i); |
96 | + } else { | ||
97 | + static gen_helper_opivx * const fns[4] = { | ||
98 | + gen_helper_vrgather_vx_b, gen_helper_vrgather_vx_h, | ||
99 | + gen_helper_vrgather_vx_w, gen_helper_vrgather_vx_d | ||
100 | + }; | ||
101 | + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s); | ||
102 | + } | ||
103 | + return true; | ||
104 | +} | ||
105 | + | ||
106 | +/* vrgather.vi vd, vs2, imm, vm # vd[i] = (imm >= VLMAX) ? 0 : vs2[imm] */ | ||
107 | +static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a) | ||
108 | +{ | ||
109 | + if (!vrgather_vx_check(s, a)) { | ||
110 | + return false; | ||
111 | + } | ||
112 | + | ||
113 | + if (a->vm && s->vl_eq_vlmax) { | ||
114 | + if (a->rs1 >= s->vlen / s->mlen) { | ||
115 | + tcg_gen_gvec_dup_imm(SEW64, vreg_ofs(s, a->rd), | ||
116 | + MAXSZ(s), MAXSZ(s), 0); | ||
117 | + } else { | ||
118 | + tcg_gen_gvec_dup_mem(s->sew, vreg_ofs(s, a->rd), | ||
119 | + endian_ofs(s, a->rs2, a->rs1), | ||
120 | + MAXSZ(s), MAXSZ(s)); | ||
121 | + } | ||
122 | + } else { | ||
123 | + static gen_helper_opivx * const fns[4] = { | ||
124 | + gen_helper_vrgather_vx_b, gen_helper_vrgather_vx_h, | ||
125 | + gen_helper_vrgather_vx_w, gen_helper_vrgather_vx_d | ||
126 | + }; | ||
127 | + return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s, 1); | ||
128 | + } | ||
129 | + return true; | ||
130 | +} | ||
131 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/riscv/vector_helper.c | ||
134 | +++ b/target/riscv/vector_helper.c | ||
135 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_b, uint8_t, H1, clearb) | ||
136 | GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_h, uint16_t, H2, clearh) | ||
137 | GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_w, uint32_t, H4, clearl) | ||
138 | GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_d, uint64_t, H8, clearq) | ||
139 | + | ||
140 | +/* Vector Register Gather Instruction */ | ||
141 | +#define GEN_VEXT_VRGATHER_VV(NAME, ETYPE, H, CLEAR_FN) \ | ||
142 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
143 | + CPURISCVState *env, uint32_t desc) \ | ||
144 | +{ \ | ||
145 | + uint32_t mlen = vext_mlen(desc); \ | ||
146 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
147 | + uint32_t vm = vext_vm(desc); \ | ||
148 | + uint32_t vl = env->vl; \ | ||
149 | + uint32_t index, i; \ | ||
150 | + \ | ||
151 | + for (i = 0; i < vl; i++) { \ | ||
152 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
153 | + continue; \ | ||
154 | + } \ | ||
155 | + index = *((ETYPE *)vs1 + H(i)); \ | ||
156 | + if (index >= vlmax) { \ | ||
157 | + *((ETYPE *)vd + H(i)) = 0; \ | ||
158 | + } else { \ | ||
159 | + *((ETYPE *)vd + H(i)) = *((ETYPE *)vs2 + H(index)); \ | ||
160 | + } \ | ||
161 | + } \ | ||
162 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
163 | +} | ||
164 | + | ||
165 | +/* vd[i] = (vs1[i] >= VLMAX) ? 0 : vs2[vs1[i]]; */ | ||
166 | +GEN_VEXT_VRGATHER_VV(vrgather_vv_b, uint8_t, H1, clearb) | ||
167 | +GEN_VEXT_VRGATHER_VV(vrgather_vv_h, uint16_t, H2, clearh) | ||
168 | +GEN_VEXT_VRGATHER_VV(vrgather_vv_w, uint32_t, H4, clearl) | ||
169 | +GEN_VEXT_VRGATHER_VV(vrgather_vv_d, uint64_t, H8, clearq) | ||
170 | + | ||
171 | +#define GEN_VEXT_VRGATHER_VX(NAME, ETYPE, H, CLEAR_FN) \ | ||
172 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
173 | + CPURISCVState *env, uint32_t desc) \ | ||
174 | +{ \ | ||
175 | + uint32_t mlen = vext_mlen(desc); \ | ||
176 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
177 | + uint32_t vm = vext_vm(desc); \ | ||
178 | + uint32_t vl = env->vl; \ | ||
179 | + uint32_t index = s1, i; \ | ||
180 | + \ | ||
181 | + for (i = 0; i < vl; i++) { \ | ||
182 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
183 | + continue; \ | ||
184 | + } \ | ||
185 | + if (index >= vlmax) { \ | ||
186 | + *((ETYPE *)vd + H(i)) = 0; \ | ||
187 | + } else { \ | ||
188 | + *((ETYPE *)vd + H(i)) = *((ETYPE *)vs2 + H(index)); \ | ||
189 | + } \ | ||
190 | + } \ | ||
191 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
192 | +} | ||
193 | + | ||
194 | +/* vd[i] = (x[rs1] >= VLMAX) ? 0 : vs2[rs1] */ | ||
195 | +GEN_VEXT_VRGATHER_VX(vrgather_vx_b, uint8_t, H1, clearb) | ||
196 | +GEN_VEXT_VRGATHER_VX(vrgather_vx_h, uint16_t, H2, clearh) | ||
197 | +GEN_VEXT_VRGATHER_VX(vrgather_vx_w, uint32_t, H4, clearl) | ||
198 | +GEN_VEXT_VRGATHER_VX(vrgather_vx_d, uint64_t, H8, clearq) | ||
199 | -- | 41 | -- |
200 | 2.27.0 | 42 | 2.45.1 |
201 | |||
202 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Andrew Jones <ajones@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | The Zkr extension may only be exposed to KVM guests if the VMM |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | implements the SEED CSR. Use the same implementation as TCG. |
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 5 | |
6 | Message-id: 20200623215920.2594-25-zhiwei_liu@c-sky.com | 6 | Without this patch, running with a KVM which does not forward the |
7 | SEED CSR access to QEMU will result in an ILL exception being | ||
8 | injected into the guest (this results in Linux guests crashing on | ||
9 | boot). And, when running with a KVM which does forward the access, | ||
10 | QEMU will crash, since QEMU doesn't know what to do with the exit. | ||
11 | |||
12 | Fixes: 3108e2f1c69d ("target/riscv/kvm: update KVM exts to Linux 6.8") | ||
13 | Signed-off-by: Andrew Jones <ajones@ventanamicro.com> | ||
14 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
15 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
16 | Message-ID: <20240422134605.534207-2-ajones@ventanamicro.com> | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
8 | --- | 18 | --- |
9 | target/riscv/helper.h | 33 ++ | 19 | target/riscv/cpu.h | 3 +++ |
10 | target/riscv/insn32.decode | 10 + | 20 | target/riscv/csr.c | 18 ++++++++++++++---- |
11 | target/riscv/insn_trans/trans_rvv.inc.c | 16 + | 21 | target/riscv/kvm/kvm-cpu.c | 25 +++++++++++++++++++++++++ |
12 | target/riscv/vector_helper.c | 385 ++++++++++++++++++++++++ | 22 | 3 files changed, 42 insertions(+), 4 deletions(-) |
13 | 4 files changed, 444 insertions(+) | ||
14 | 23 | ||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 24 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/riscv/helper.h | 26 | --- a/target/riscv/cpu.h |
18 | +++ b/target/riscv/helper.h | 27 | +++ b/target/riscv/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vmv_v_x_b, void, ptr, i64, env, i32) | 28 | @@ -XXX,XX +XXX,XX @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops); |
20 | DEF_HELPER_4(vmv_v_x_h, void, ptr, i64, env, i32) | 29 | |
21 | DEF_HELPER_4(vmv_v_x_w, void, ptr, i64, env, i32) | 30 | void riscv_cpu_register_gdb_regs_for_features(CPUState *cs); |
22 | DEF_HELPER_4(vmv_v_x_d, void, ptr, i64, env, i32) | 31 | |
32 | +target_ulong riscv_new_csr_seed(target_ulong new_value, | ||
33 | + target_ulong write_mask); | ||
23 | + | 34 | + |
24 | +DEF_HELPER_6(vsaddu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | 35 | uint8_t satp_mode_max_from_map(uint32_t map); |
25 | +DEF_HELPER_6(vsaddu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | 36 | const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit); |
26 | +DEF_HELPER_6(vsaddu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | 37 | |
27 | +DEF_HELPER_6(vsaddu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | 38 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c |
28 | +DEF_HELPER_6(vsadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vsadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vsadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vsadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vssubu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vssubu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vssubu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vssubu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vssub_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vssub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vssub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vssub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vsaddu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vsaddu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vsaddu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vsaddu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vsadd_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vsadd_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vsadd_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vsadd_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vssubu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vssubu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vssubu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vssubu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vssub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vssub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vssub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vssub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
57 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/target/riscv/insn32.decode | 40 | --- a/target/riscv/csr.c |
59 | +++ b/target/riscv/insn32.decode | 41 | +++ b/target/riscv/csr.c |
60 | @@ -XXX,XX +XXX,XX @@ vmv_v_i 010111 1 00000 ..... 011 ..... 1010111 @r2 | 42 | @@ -XXX,XX +XXX,XX @@ static RISCVException write_upmbase(CPURISCVState *env, int csrno, |
61 | vmerge_vvm 010111 0 ..... ..... 000 ..... 1010111 @r_vm_0 | 43 | #endif |
62 | vmerge_vxm 010111 0 ..... ..... 100 ..... 1010111 @r_vm_0 | 44 | |
63 | vmerge_vim 010111 0 ..... ..... 011 ..... 1010111 @r_vm_0 | 45 | /* Crypto Extension */ |
64 | +vsaddu_vv 100000 . ..... ..... 000 ..... 1010111 @r_vm | 46 | -static RISCVException rmw_seed(CPURISCVState *env, int csrno, |
65 | +vsaddu_vx 100000 . ..... ..... 100 ..... 1010111 @r_vm | 47 | - target_ulong *ret_value, |
66 | +vsaddu_vi 100000 . ..... ..... 011 ..... 1010111 @r_vm | 48 | - target_ulong new_value, |
67 | +vsadd_vv 100001 . ..... ..... 000 ..... 1010111 @r_vm | 49 | - target_ulong write_mask) |
68 | +vsadd_vx 100001 . ..... ..... 100 ..... 1010111 @r_vm | 50 | +target_ulong riscv_new_csr_seed(target_ulong new_value, |
69 | +vsadd_vi 100001 . ..... ..... 011 ..... 1010111 @r_vm | 51 | + target_ulong write_mask) |
70 | +vssubu_vv 100010 . ..... ..... 000 ..... 1010111 @r_vm | 52 | { |
71 | +vssubu_vx 100010 . ..... ..... 100 ..... 1010111 @r_vm | 53 | uint16_t random_v; |
72 | +vssub_vv 100011 . ..... ..... 000 ..... 1010111 @r_vm | 54 | Error *random_e = NULL; |
73 | +vssub_vx 100011 . ..... ..... 100 ..... 1010111 @r_vm | 55 | @@ -XXX,XX +XXX,XX @@ static RISCVException rmw_seed(CPURISCVState *env, int csrno, |
74 | 56 | rval = random_v | SEED_OPST_ES16; | |
75 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 57 | } |
76 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 58 | |
77 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 59 | + return rval; |
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
80 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a) | ||
82 | GEN_OPIVV_TRANS(vmerge_vvm, opivv_vadc_check) | ||
83 | GEN_OPIVX_TRANS(vmerge_vxm, opivx_vadc_check) | ||
84 | GEN_OPIVI_TRANS(vmerge_vim, 0, vmerge_vxm, opivx_vadc_check) | ||
85 | + | ||
86 | +/* | ||
87 | + *** Vector Fixed-Point Arithmetic Instructions | ||
88 | + */ | ||
89 | + | ||
90 | +/* Vector Single-Width Saturating Add and Subtract */ | ||
91 | +GEN_OPIVV_TRANS(vsaddu_vv, opivv_check) | ||
92 | +GEN_OPIVV_TRANS(vsadd_vv, opivv_check) | ||
93 | +GEN_OPIVV_TRANS(vssubu_vv, opivv_check) | ||
94 | +GEN_OPIVV_TRANS(vssub_vv, opivv_check) | ||
95 | +GEN_OPIVX_TRANS(vsaddu_vx, opivx_check) | ||
96 | +GEN_OPIVX_TRANS(vsadd_vx, opivx_check) | ||
97 | +GEN_OPIVX_TRANS(vssubu_vx, opivx_check) | ||
98 | +GEN_OPIVX_TRANS(vssub_vx, opivx_check) | ||
99 | +GEN_OPIVI_TRANS(vsaddu_vi, 1, vsaddu_vx, opivx_check) | ||
100 | +GEN_OPIVI_TRANS(vsadd_vi, 0, vsadd_vx, opivx_check) | ||
101 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/riscv/vector_helper.c | ||
104 | +++ b/target/riscv/vector_helper.c | ||
105 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VMERGE_VX(vmerge_vxm_b, int8_t, H1, clearb) | ||
106 | GEN_VEXT_VMERGE_VX(vmerge_vxm_h, int16_t, H2, clearh) | ||
107 | GEN_VEXT_VMERGE_VX(vmerge_vxm_w, int32_t, H4, clearl) | ||
108 | GEN_VEXT_VMERGE_VX(vmerge_vxm_d, int64_t, H8, clearq) | ||
109 | + | ||
110 | +/* | ||
111 | + *** Vector Fixed-Point Arithmetic Instructions | ||
112 | + */ | ||
113 | + | ||
114 | +/* Vector Single-Width Saturating Add and Subtract */ | ||
115 | + | ||
116 | +/* | ||
117 | + * As fixed point instructions probably have round mode and saturation, | ||
118 | + * define common macros for fixed point here. | ||
119 | + */ | ||
120 | +typedef void opivv2_rm_fn(void *vd, void *vs1, void *vs2, int i, | ||
121 | + CPURISCVState *env, int vxrm); | ||
122 | + | ||
123 | +#define OPIVV2_RM(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ | ||
124 | +static inline void \ | ||
125 | +do_##NAME(void *vd, void *vs1, void *vs2, int i, \ | ||
126 | + CPURISCVState *env, int vxrm) \ | ||
127 | +{ \ | ||
128 | + TX1 s1 = *((T1 *)vs1 + HS1(i)); \ | ||
129 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
130 | + *((TD *)vd + HD(i)) = OP(env, vxrm, s2, s1); \ | ||
131 | +} | 60 | +} |
132 | + | 61 | + |
133 | +static inline void | 62 | +static RISCVException rmw_seed(CPURISCVState *env, int csrno, |
134 | +vext_vv_rm_1(void *vd, void *v0, void *vs1, void *vs2, | 63 | + target_ulong *ret_value, |
135 | + CPURISCVState *env, | 64 | + target_ulong new_value, |
136 | + uint32_t vl, uint32_t vm, uint32_t mlen, int vxrm, | 65 | + target_ulong write_mask) |
137 | + opivv2_rm_fn *fn) | ||
138 | +{ | 66 | +{ |
139 | + for (uint32_t i = 0; i < vl; i++) { | 67 | + target_ulong rval; |
140 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
141 | + continue; | ||
142 | + } | ||
143 | + fn(vd, vs1, vs2, i, env, vxrm); | ||
144 | + } | ||
145 | +} | ||
146 | + | 68 | + |
147 | +static inline void | 69 | + rval = riscv_new_csr_seed(new_value, write_mask); |
148 | +vext_vv_rm_2(void *vd, void *v0, void *vs1, void *vs2, | 70 | + |
149 | + CPURISCVState *env, | 71 | if (ret_value) { |
150 | + uint32_t desc, uint32_t esz, uint32_t dsz, | 72 | *ret_value = rval; |
151 | + opivv2_rm_fn *fn, clear_fn *clearfn) | 73 | } |
74 | diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/target/riscv/kvm/kvm-cpu.c | ||
77 | +++ b/target/riscv/kvm/kvm-cpu.c | ||
78 | @@ -XXX,XX +XXX,XX @@ static int kvm_riscv_handle_sbi(CPUState *cs, struct kvm_run *run) | ||
79 | return ret; | ||
80 | } | ||
81 | |||
82 | +static int kvm_riscv_handle_csr(CPUState *cs, struct kvm_run *run) | ||
152 | +{ | 83 | +{ |
153 | + uint32_t vlmax = vext_maxsz(desc) / esz; | 84 | + target_ulong csr_num = run->riscv_csr.csr_num; |
154 | + uint32_t mlen = vext_mlen(desc); | 85 | + target_ulong new_value = run->riscv_csr.new_value; |
155 | + uint32_t vm = vext_vm(desc); | 86 | + target_ulong write_mask = run->riscv_csr.write_mask; |
156 | + uint32_t vl = env->vl; | 87 | + int ret = 0; |
157 | + | 88 | + |
158 | + switch (env->vxrm) { | 89 | + switch (csr_num) { |
159 | + case 0: /* rnu */ | 90 | + case CSR_SEED: |
160 | + vext_vv_rm_1(vd, v0, vs1, vs2, | 91 | + run->riscv_csr.ret_value = riscv_new_csr_seed(new_value, write_mask); |
161 | + env, vl, vm, mlen, 0, fn); | ||
162 | + break; | 92 | + break; |
163 | + case 1: /* rne */ | 93 | + default: |
164 | + vext_vv_rm_1(vd, v0, vs1, vs2, | 94 | + qemu_log_mask(LOG_UNIMP, |
165 | + env, vl, vm, mlen, 1, fn); | 95 | + "%s: un-handled CSR EXIT for CSR %lx\n", |
166 | + break; | 96 | + __func__, csr_num); |
167 | + case 2: /* rdn */ | 97 | + ret = -1; |
168 | + vext_vv_rm_1(vd, v0, vs1, vs2, | ||
169 | + env, vl, vm, mlen, 2, fn); | ||
170 | + break; | ||
171 | + default: /* rod */ | ||
172 | + vext_vv_rm_1(vd, v0, vs1, vs2, | ||
173 | + env, vl, vm, mlen, 3, fn); | ||
174 | + break; | 98 | + break; |
175 | + } | 99 | + } |
176 | + | 100 | + |
177 | + clearfn(vd, vl, vl * dsz, vlmax * dsz); | 101 | + return ret; |
178 | +} | 102 | +} |
179 | + | 103 | + |
180 | +/* generate helpers for fixed point instructions with OPIVV format */ | 104 | int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) |
181 | +#define GEN_VEXT_VV_RM(NAME, ESZ, DSZ, CLEAR_FN) \ | 105 | { |
182 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | 106 | int ret = 0; |
183 | + CPURISCVState *env, uint32_t desc) \ | 107 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) |
184 | +{ \ | 108 | case KVM_EXIT_RISCV_SBI: |
185 | + vext_vv_rm_2(vd, v0, vs1, vs2, env, desc, ESZ, DSZ, \ | 109 | ret = kvm_riscv_handle_sbi(cs, run); |
186 | + do_##NAME, CLEAR_FN); \ | 110 | break; |
187 | +} | 111 | + case KVM_EXIT_RISCV_CSR: |
188 | + | 112 | + ret = kvm_riscv_handle_csr(cs, run); |
189 | +static inline uint8_t saddu8(CPURISCVState *env, int vxrm, uint8_t a, uint8_t b) | ||
190 | +{ | ||
191 | + uint8_t res = a + b; | ||
192 | + if (res < a) { | ||
193 | + res = UINT8_MAX; | ||
194 | + env->vxsat = 0x1; | ||
195 | + } | ||
196 | + return res; | ||
197 | +} | ||
198 | + | ||
199 | +static inline uint16_t saddu16(CPURISCVState *env, int vxrm, uint16_t a, | ||
200 | + uint16_t b) | ||
201 | +{ | ||
202 | + uint16_t res = a + b; | ||
203 | + if (res < a) { | ||
204 | + res = UINT16_MAX; | ||
205 | + env->vxsat = 0x1; | ||
206 | + } | ||
207 | + return res; | ||
208 | +} | ||
209 | + | ||
210 | +static inline uint32_t saddu32(CPURISCVState *env, int vxrm, uint32_t a, | ||
211 | + uint32_t b) | ||
212 | +{ | ||
213 | + uint32_t res = a + b; | ||
214 | + if (res < a) { | ||
215 | + res = UINT32_MAX; | ||
216 | + env->vxsat = 0x1; | ||
217 | + } | ||
218 | + return res; | ||
219 | +} | ||
220 | + | ||
221 | +static inline uint64_t saddu64(CPURISCVState *env, int vxrm, uint64_t a, | ||
222 | + uint64_t b) | ||
223 | +{ | ||
224 | + uint64_t res = a + b; | ||
225 | + if (res < a) { | ||
226 | + res = UINT64_MAX; | ||
227 | + env->vxsat = 0x1; | ||
228 | + } | ||
229 | + return res; | ||
230 | +} | ||
231 | + | ||
232 | +RVVCALL(OPIVV2_RM, vsaddu_vv_b, OP_UUU_B, H1, H1, H1, saddu8) | ||
233 | +RVVCALL(OPIVV2_RM, vsaddu_vv_h, OP_UUU_H, H2, H2, H2, saddu16) | ||
234 | +RVVCALL(OPIVV2_RM, vsaddu_vv_w, OP_UUU_W, H4, H4, H4, saddu32) | ||
235 | +RVVCALL(OPIVV2_RM, vsaddu_vv_d, OP_UUU_D, H8, H8, H8, saddu64) | ||
236 | +GEN_VEXT_VV_RM(vsaddu_vv_b, 1, 1, clearb) | ||
237 | +GEN_VEXT_VV_RM(vsaddu_vv_h, 2, 2, clearh) | ||
238 | +GEN_VEXT_VV_RM(vsaddu_vv_w, 4, 4, clearl) | ||
239 | +GEN_VEXT_VV_RM(vsaddu_vv_d, 8, 8, clearq) | ||
240 | + | ||
241 | +typedef void opivx2_rm_fn(void *vd, target_long s1, void *vs2, int i, | ||
242 | + CPURISCVState *env, int vxrm); | ||
243 | + | ||
244 | +#define OPIVX2_RM(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ | ||
245 | +static inline void \ | ||
246 | +do_##NAME(void *vd, target_long s1, void *vs2, int i, \ | ||
247 | + CPURISCVState *env, int vxrm) \ | ||
248 | +{ \ | ||
249 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
250 | + *((TD *)vd + HD(i)) = OP(env, vxrm, s2, (TX1)(T1)s1); \ | ||
251 | +} | ||
252 | + | ||
253 | +static inline void | ||
254 | +vext_vx_rm_1(void *vd, void *v0, target_long s1, void *vs2, | ||
255 | + CPURISCVState *env, | ||
256 | + uint32_t vl, uint32_t vm, uint32_t mlen, int vxrm, | ||
257 | + opivx2_rm_fn *fn) | ||
258 | +{ | ||
259 | + for (uint32_t i = 0; i < vl; i++) { | ||
260 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
261 | + continue; | ||
262 | + } | ||
263 | + fn(vd, s1, vs2, i, env, vxrm); | ||
264 | + } | ||
265 | +} | ||
266 | + | ||
267 | +static inline void | ||
268 | +vext_vx_rm_2(void *vd, void *v0, target_long s1, void *vs2, | ||
269 | + CPURISCVState *env, | ||
270 | + uint32_t desc, uint32_t esz, uint32_t dsz, | ||
271 | + opivx2_rm_fn *fn, clear_fn *clearfn) | ||
272 | +{ | ||
273 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
274 | + uint32_t mlen = vext_mlen(desc); | ||
275 | + uint32_t vm = vext_vm(desc); | ||
276 | + uint32_t vl = env->vl; | ||
277 | + | ||
278 | + switch (env->vxrm) { | ||
279 | + case 0: /* rnu */ | ||
280 | + vext_vx_rm_1(vd, v0, s1, vs2, | ||
281 | + env, vl, vm, mlen, 0, fn); | ||
282 | + break; | 113 | + break; |
283 | + case 1: /* rne */ | 114 | default: |
284 | + vext_vx_rm_1(vd, v0, s1, vs2, | 115 | qemu_log_mask(LOG_UNIMP, "%s: un-handled exit reason %d\n", |
285 | + env, vl, vm, mlen, 1, fn); | 116 | __func__, run->exit_reason); |
286 | + break; | ||
287 | + case 2: /* rdn */ | ||
288 | + vext_vx_rm_1(vd, v0, s1, vs2, | ||
289 | + env, vl, vm, mlen, 2, fn); | ||
290 | + break; | ||
291 | + default: /* rod */ | ||
292 | + vext_vx_rm_1(vd, v0, s1, vs2, | ||
293 | + env, vl, vm, mlen, 3, fn); | ||
294 | + break; | ||
295 | + } | ||
296 | + | ||
297 | + clearfn(vd, vl, vl * dsz, vlmax * dsz); | ||
298 | +} | ||
299 | + | ||
300 | +/* generate helpers for fixed point instructions with OPIVX format */ | ||
301 | +#define GEN_VEXT_VX_RM(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
302 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ | ||
303 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
304 | +{ \ | ||
305 | + vext_vx_rm_2(vd, v0, s1, vs2, env, desc, ESZ, DSZ, \ | ||
306 | + do_##NAME, CLEAR_FN); \ | ||
307 | +} | ||
308 | + | ||
309 | +RVVCALL(OPIVX2_RM, vsaddu_vx_b, OP_UUU_B, H1, H1, saddu8) | ||
310 | +RVVCALL(OPIVX2_RM, vsaddu_vx_h, OP_UUU_H, H2, H2, saddu16) | ||
311 | +RVVCALL(OPIVX2_RM, vsaddu_vx_w, OP_UUU_W, H4, H4, saddu32) | ||
312 | +RVVCALL(OPIVX2_RM, vsaddu_vx_d, OP_UUU_D, H8, H8, saddu64) | ||
313 | +GEN_VEXT_VX_RM(vsaddu_vx_b, 1, 1, clearb) | ||
314 | +GEN_VEXT_VX_RM(vsaddu_vx_h, 2, 2, clearh) | ||
315 | +GEN_VEXT_VX_RM(vsaddu_vx_w, 4, 4, clearl) | ||
316 | +GEN_VEXT_VX_RM(vsaddu_vx_d, 8, 8, clearq) | ||
317 | + | ||
318 | +static inline int8_t sadd8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) | ||
319 | +{ | ||
320 | + int8_t res = a + b; | ||
321 | + if ((res ^ a) & (res ^ b) & INT8_MIN) { | ||
322 | + res = a > 0 ? INT8_MAX : INT8_MIN; | ||
323 | + env->vxsat = 0x1; | ||
324 | + } | ||
325 | + return res; | ||
326 | +} | ||
327 | + | ||
328 | +static inline int16_t sadd16(CPURISCVState *env, int vxrm, int16_t a, int16_t b) | ||
329 | +{ | ||
330 | + int16_t res = a + b; | ||
331 | + if ((res ^ a) & (res ^ b) & INT16_MIN) { | ||
332 | + res = a > 0 ? INT16_MAX : INT16_MIN; | ||
333 | + env->vxsat = 0x1; | ||
334 | + } | ||
335 | + return res; | ||
336 | +} | ||
337 | + | ||
338 | +static inline int32_t sadd32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) | ||
339 | +{ | ||
340 | + int32_t res = a + b; | ||
341 | + if ((res ^ a) & (res ^ b) & INT32_MIN) { | ||
342 | + res = a > 0 ? INT32_MAX : INT32_MIN; | ||
343 | + env->vxsat = 0x1; | ||
344 | + } | ||
345 | + return res; | ||
346 | +} | ||
347 | + | ||
348 | +static inline int64_t sadd64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
349 | +{ | ||
350 | + int64_t res = a + b; | ||
351 | + if ((res ^ a) & (res ^ b) & INT64_MIN) { | ||
352 | + res = a > 0 ? INT64_MAX : INT64_MIN; | ||
353 | + env->vxsat = 0x1; | ||
354 | + } | ||
355 | + return res; | ||
356 | +} | ||
357 | + | ||
358 | +RVVCALL(OPIVV2_RM, vsadd_vv_b, OP_SSS_B, H1, H1, H1, sadd8) | ||
359 | +RVVCALL(OPIVV2_RM, vsadd_vv_h, OP_SSS_H, H2, H2, H2, sadd16) | ||
360 | +RVVCALL(OPIVV2_RM, vsadd_vv_w, OP_SSS_W, H4, H4, H4, sadd32) | ||
361 | +RVVCALL(OPIVV2_RM, vsadd_vv_d, OP_SSS_D, H8, H8, H8, sadd64) | ||
362 | +GEN_VEXT_VV_RM(vsadd_vv_b, 1, 1, clearb) | ||
363 | +GEN_VEXT_VV_RM(vsadd_vv_h, 2, 2, clearh) | ||
364 | +GEN_VEXT_VV_RM(vsadd_vv_w, 4, 4, clearl) | ||
365 | +GEN_VEXT_VV_RM(vsadd_vv_d, 8, 8, clearq) | ||
366 | + | ||
367 | +RVVCALL(OPIVX2_RM, vsadd_vx_b, OP_SSS_B, H1, H1, sadd8) | ||
368 | +RVVCALL(OPIVX2_RM, vsadd_vx_h, OP_SSS_H, H2, H2, sadd16) | ||
369 | +RVVCALL(OPIVX2_RM, vsadd_vx_w, OP_SSS_W, H4, H4, sadd32) | ||
370 | +RVVCALL(OPIVX2_RM, vsadd_vx_d, OP_SSS_D, H8, H8, sadd64) | ||
371 | +GEN_VEXT_VX_RM(vsadd_vx_b, 1, 1, clearb) | ||
372 | +GEN_VEXT_VX_RM(vsadd_vx_h, 2, 2, clearh) | ||
373 | +GEN_VEXT_VX_RM(vsadd_vx_w, 4, 4, clearl) | ||
374 | +GEN_VEXT_VX_RM(vsadd_vx_d, 8, 8, clearq) | ||
375 | + | ||
376 | +static inline uint8_t ssubu8(CPURISCVState *env, int vxrm, uint8_t a, uint8_t b) | ||
377 | +{ | ||
378 | + uint8_t res = a - b; | ||
379 | + if (res > a) { | ||
380 | + res = 0; | ||
381 | + env->vxsat = 0x1; | ||
382 | + } | ||
383 | + return res; | ||
384 | +} | ||
385 | + | ||
386 | +static inline uint16_t ssubu16(CPURISCVState *env, int vxrm, uint16_t a, | ||
387 | + uint16_t b) | ||
388 | +{ | ||
389 | + uint16_t res = a - b; | ||
390 | + if (res > a) { | ||
391 | + res = 0; | ||
392 | + env->vxsat = 0x1; | ||
393 | + } | ||
394 | + return res; | ||
395 | +} | ||
396 | + | ||
397 | +static inline uint32_t ssubu32(CPURISCVState *env, int vxrm, uint32_t a, | ||
398 | + uint32_t b) | ||
399 | +{ | ||
400 | + uint32_t res = a - b; | ||
401 | + if (res > a) { | ||
402 | + res = 0; | ||
403 | + env->vxsat = 0x1; | ||
404 | + } | ||
405 | + return res; | ||
406 | +} | ||
407 | + | ||
408 | +static inline uint64_t ssubu64(CPURISCVState *env, int vxrm, uint64_t a, | ||
409 | + uint64_t b) | ||
410 | +{ | ||
411 | + uint64_t res = a - b; | ||
412 | + if (res > a) { | ||
413 | + res = 0; | ||
414 | + env->vxsat = 0x1; | ||
415 | + } | ||
416 | + return res; | ||
417 | +} | ||
418 | + | ||
419 | +RVVCALL(OPIVV2_RM, vssubu_vv_b, OP_UUU_B, H1, H1, H1, ssubu8) | ||
420 | +RVVCALL(OPIVV2_RM, vssubu_vv_h, OP_UUU_H, H2, H2, H2, ssubu16) | ||
421 | +RVVCALL(OPIVV2_RM, vssubu_vv_w, OP_UUU_W, H4, H4, H4, ssubu32) | ||
422 | +RVVCALL(OPIVV2_RM, vssubu_vv_d, OP_UUU_D, H8, H8, H8, ssubu64) | ||
423 | +GEN_VEXT_VV_RM(vssubu_vv_b, 1, 1, clearb) | ||
424 | +GEN_VEXT_VV_RM(vssubu_vv_h, 2, 2, clearh) | ||
425 | +GEN_VEXT_VV_RM(vssubu_vv_w, 4, 4, clearl) | ||
426 | +GEN_VEXT_VV_RM(vssubu_vv_d, 8, 8, clearq) | ||
427 | + | ||
428 | +RVVCALL(OPIVX2_RM, vssubu_vx_b, OP_UUU_B, H1, H1, ssubu8) | ||
429 | +RVVCALL(OPIVX2_RM, vssubu_vx_h, OP_UUU_H, H2, H2, ssubu16) | ||
430 | +RVVCALL(OPIVX2_RM, vssubu_vx_w, OP_UUU_W, H4, H4, ssubu32) | ||
431 | +RVVCALL(OPIVX2_RM, vssubu_vx_d, OP_UUU_D, H8, H8, ssubu64) | ||
432 | +GEN_VEXT_VX_RM(vssubu_vx_b, 1, 1, clearb) | ||
433 | +GEN_VEXT_VX_RM(vssubu_vx_h, 2, 2, clearh) | ||
434 | +GEN_VEXT_VX_RM(vssubu_vx_w, 4, 4, clearl) | ||
435 | +GEN_VEXT_VX_RM(vssubu_vx_d, 8, 8, clearq) | ||
436 | + | ||
437 | +static inline int8_t ssub8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) | ||
438 | +{ | ||
439 | + int8_t res = a - b; | ||
440 | + if ((res ^ a) & (a ^ b) & INT8_MIN) { | ||
441 | + res = a > 0 ? INT8_MAX : INT8_MIN; | ||
442 | + env->vxsat = 0x1; | ||
443 | + } | ||
444 | + return res; | ||
445 | +} | ||
446 | + | ||
447 | +static inline int16_t ssub16(CPURISCVState *env, int vxrm, int16_t a, int16_t b) | ||
448 | +{ | ||
449 | + int16_t res = a - b; | ||
450 | + if ((res ^ a) & (a ^ b) & INT16_MIN) { | ||
451 | + res = a > 0 ? INT16_MAX : INT16_MIN; | ||
452 | + env->vxsat = 0x1; | ||
453 | + } | ||
454 | + return res; | ||
455 | +} | ||
456 | + | ||
457 | +static inline int32_t ssub32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) | ||
458 | +{ | ||
459 | + int32_t res = a - b; | ||
460 | + if ((res ^ a) & (a ^ b) & INT32_MIN) { | ||
461 | + res = a > 0 ? INT32_MAX : INT32_MIN; | ||
462 | + env->vxsat = 0x1; | ||
463 | + } | ||
464 | + return res; | ||
465 | +} | ||
466 | + | ||
467 | +static inline int64_t ssub64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
468 | +{ | ||
469 | + int64_t res = a - b; | ||
470 | + if ((res ^ a) & (a ^ b) & INT64_MIN) { | ||
471 | + res = a > 0 ? INT64_MAX : INT64_MIN; | ||
472 | + env->vxsat = 0x1; | ||
473 | + } | ||
474 | + return res; | ||
475 | +} | ||
476 | + | ||
477 | +RVVCALL(OPIVV2_RM, vssub_vv_b, OP_SSS_B, H1, H1, H1, ssub8) | ||
478 | +RVVCALL(OPIVV2_RM, vssub_vv_h, OP_SSS_H, H2, H2, H2, ssub16) | ||
479 | +RVVCALL(OPIVV2_RM, vssub_vv_w, OP_SSS_W, H4, H4, H4, ssub32) | ||
480 | +RVVCALL(OPIVV2_RM, vssub_vv_d, OP_SSS_D, H8, H8, H8, ssub64) | ||
481 | +GEN_VEXT_VV_RM(vssub_vv_b, 1, 1, clearb) | ||
482 | +GEN_VEXT_VV_RM(vssub_vv_h, 2, 2, clearh) | ||
483 | +GEN_VEXT_VV_RM(vssub_vv_w, 4, 4, clearl) | ||
484 | +GEN_VEXT_VV_RM(vssub_vv_d, 8, 8, clearq) | ||
485 | + | ||
486 | +RVVCALL(OPIVX2_RM, vssub_vx_b, OP_SSS_B, H1, H1, ssub8) | ||
487 | +RVVCALL(OPIVX2_RM, vssub_vx_h, OP_SSS_H, H2, H2, ssub16) | ||
488 | +RVVCALL(OPIVX2_RM, vssub_vx_w, OP_SSS_W, H4, H4, ssub32) | ||
489 | +RVVCALL(OPIVX2_RM, vssub_vx_d, OP_SSS_D, H8, H8, ssub64) | ||
490 | +GEN_VEXT_VX_RM(vssub_vx_b, 1, 1, clearb) | ||
491 | +GEN_VEXT_VX_RM(vssub_vx_h, 2, 2, clearh) | ||
492 | +GEN_VEXT_VX_RM(vssub_vx_w, 4, 4, clearl) | ||
493 | +GEN_VEXT_VX_RM(vssub_vx_d, 8, 8, clearq) | ||
494 | -- | 117 | -- |
495 | 2.27.0 | 118 | 2.45.1 |
496 | |||
497 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Andrew Jones <ajones@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Implementing wrs.nto to always just return is consistent with the |
4 | specification, as the instruction is permitted to terminate the | ||
5 | stall for any reason, but it's not useful for virtualization, where | ||
6 | we'd like the guest to trap to the hypervisor in order to allow | ||
7 | scheduling of the lock holding VCPU. Change to always immediately | ||
8 | raise exceptions when the appropriate conditions are present, | ||
9 | otherwise continue to just return. Note, immediately raising | ||
10 | exceptions is also consistent with the specification since the | ||
11 | time limit that should expire prior to the exception is | ||
12 | implementation-specific. | ||
13 | |||
14 | Signed-off-by: Andrew Jones <ajones@ventanamicro.com> | ||
15 | Reviewed-by: Christoph Müllner <christoph.muellner@vrull.eu> | ||
16 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 17 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Message-ID: <20240424142808.62936-2-ajones@ventanamicro.com> |
6 | Message-id: 20200623215920.2594-11-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 19 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
8 | --- | 20 | --- |
9 | target/riscv/helper.h | 25 ++ | 21 | target/riscv/helper.h | 1 + |
10 | target/riscv/insn32.decode | 10 + | 22 | target/riscv/op_helper.c | 11 ++++++++ |
11 | target/riscv/insn_trans/trans_rvv.inc.c | 291 ++++++++++++++++++++++++ | 23 | target/riscv/insn_trans/trans_rvzawrs.c.inc | 29 ++++++++++++++------- |
12 | target/riscv/vector_helper.c | 183 +++++++++++++++ | 24 | 3 files changed, 32 insertions(+), 9 deletions(-) |
13 | 4 files changed, 509 insertions(+) | ||
14 | 25 | ||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 26 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/riscv/helper.h | 28 | --- a/target/riscv/helper.h |
18 | +++ b/target/riscv/helper.h | 29 | +++ b/target/riscv/helper.h |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vamominw_v_w, void, ptr, ptr, tl, ptr, env, i32) | 30 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(csrrw_i128, tl, env, int, tl, tl, tl, tl) |
20 | DEF_HELPER_6(vamomaxw_v_w, void, ptr, ptr, tl, ptr, env, i32) | 31 | DEF_HELPER_1(sret, tl, env) |
21 | DEF_HELPER_6(vamominuw_v_w, void, ptr, ptr, tl, ptr, env, i32) | 32 | DEF_HELPER_1(mret, tl, env) |
22 | DEF_HELPER_6(vamomaxuw_v_w, void, ptr, ptr, tl, ptr, env, i32) | 33 | DEF_HELPER_1(wfi, void, env) |
23 | + | 34 | +DEF_HELPER_1(wrs_nto, void, env) |
24 | +DEF_HELPER_6(vadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | 35 | DEF_HELPER_1(tlb_flush, void, env) |
25 | +DEF_HELPER_6(vadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | 36 | DEF_HELPER_1(tlb_flush_all, void, env) |
26 | +DEF_HELPER_6(vadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | 37 | /* Native Debug */ |
27 | +DEF_HELPER_6(vadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | 38 | diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c |
28 | +DEF_HELPER_6(vsub_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vadd_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vadd_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vadd_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vadd_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vsub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vsub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vsub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vsub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vrsub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vrsub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vrsub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vrsub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_FLAGS_4(vec_rsubs8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | ||
45 | +DEF_HELPER_FLAGS_4(vec_rsubs16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | ||
46 | +DEF_HELPER_FLAGS_4(vec_rsubs32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | ||
47 | +DEF_HELPER_FLAGS_4(vec_rsubs64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | ||
48 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
49 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/target/riscv/insn32.decode | 40 | --- a/target/riscv/op_helper.c |
51 | +++ b/target/riscv/insn32.decode | 41 | +++ b/target/riscv/op_helper.c |
52 | @@ -XXX,XX +XXX,XX @@ | 42 | @@ -XXX,XX +XXX,XX @@ void helper_wfi(CPURISCVState *env) |
53 | &u imm rd | 43 | } |
54 | &shift shamt rs1 rd | 44 | } |
55 | &atomic aq rl rs2 rs1 rd | 45 | |
56 | +&rmrr vm rd rs1 rs2 | 46 | +void helper_wrs_nto(CPURISCVState *env) |
57 | &rwdvm vm wd rd rs1 rs2 | ||
58 | &r2nfvm vm rd rs1 nf | ||
59 | &rnfvm vm rd rs1 rs2 nf | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | ||
62 | @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | ||
63 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | ||
64 | +@r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | ||
65 | @r_wdvm ..... wd:1 vm:1 ..... ..... ... ..... ....... &rwdvm %rs2 %rs1 %rd | ||
66 | @r2_zimm . zimm:11 ..... ... ..... ....... %rs1 %rd | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ vamominuw_v 11000 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
69 | vamomaxuw_v 11100 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
70 | |||
71 | # *** new major opcode OP-V *** | ||
72 | +vadd_vv 000000 . ..... ..... 000 ..... 1010111 @r_vm | ||
73 | +vadd_vx 000000 . ..... ..... 100 ..... 1010111 @r_vm | ||
74 | +vadd_vi 000000 . ..... ..... 011 ..... 1010111 @r_vm | ||
75 | +vsub_vv 000010 . ..... ..... 000 ..... 1010111 @r_vm | ||
76 | +vsub_vx 000010 . ..... ..... 100 ..... 1010111 @r_vm | ||
77 | +vrsub_vx 000011 . ..... ..... 100 ..... 1010111 @r_vm | ||
78 | +vrsub_vi 000011 . ..... ..... 011 ..... 1010111 @r_vm | ||
79 | + | ||
80 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
81 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
82 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
85 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
86 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_TRANS(vamomaxd_v, 15, rwdvm, amo_op, amo_check) | ||
87 | GEN_VEXT_TRANS(vamominud_v, 16, rwdvm, amo_op, amo_check) | ||
88 | GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) | ||
89 | #endif | ||
90 | + | ||
91 | +/* | ||
92 | + *** Vector Integer Arithmetic Instructions | ||
93 | + */ | ||
94 | +#define MAXSZ(s) (s->vlen >> (3 - s->lmul)) | ||
95 | + | ||
96 | +static bool opivv_check(DisasContext *s, arg_rmrr *a) | ||
97 | +{ | 47 | +{ |
98 | + return (vext_check_isa_ill(s) && | 48 | + if (env->virt_enabled && (env->priv == PRV_S || env->priv == PRV_U) && |
99 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | 49 | + get_field(env->hstatus, HSTATUS_VTW) && |
100 | + vext_check_reg(s, a->rd, false) && | 50 | + !get_field(env->mstatus, MSTATUS_TW)) { |
101 | + vext_check_reg(s, a->rs2, false) && | 51 | + riscv_raise_exception(env, RISCV_EXCP_VIRT_INSTRUCTION_FAULT, GETPC()); |
102 | + vext_check_reg(s, a->rs1, false)); | 52 | + } else if (env->priv != PRV_M && get_field(env->mstatus, MSTATUS_TW)) { |
103 | +} | 53 | + riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); |
104 | + | ||
105 | +typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t, | ||
106 | + uint32_t, uint32_t, uint32_t); | ||
107 | + | ||
108 | +static inline bool | ||
109 | +do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn, | ||
110 | + gen_helper_gvec_4_ptr *fn) | ||
111 | +{ | ||
112 | + TCGLabel *over = gen_new_label(); | ||
113 | + if (!opivv_check(s, a)) { | ||
114 | + return false; | ||
115 | + } | ||
116 | + | ||
117 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
118 | + | ||
119 | + if (a->vm && s->vl_eq_vlmax) { | ||
120 | + gvec_fn(s->sew, vreg_ofs(s, a->rd), | ||
121 | + vreg_ofs(s, a->rs2), vreg_ofs(s, a->rs1), | ||
122 | + MAXSZ(s), MAXSZ(s)); | ||
123 | + } else { | ||
124 | + uint32_t data = 0; | ||
125 | + | ||
126 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
127 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
128 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
129 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), | ||
130 | + vreg_ofs(s, a->rs1), vreg_ofs(s, a->rs2), | ||
131 | + cpu_env, 0, s->vlen / 8, data, fn); | ||
132 | + } | ||
133 | + gen_set_label(over); | ||
134 | + return true; | ||
135 | +} | ||
136 | + | ||
137 | +/* OPIVV with GVEC IR */ | ||
138 | +#define GEN_OPIVV_GVEC_TRANS(NAME, SUF) \ | ||
139 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
140 | +{ \ | ||
141 | + static gen_helper_gvec_4_ptr * const fns[4] = { \ | ||
142 | + gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ | ||
143 | + gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ | ||
144 | + }; \ | ||
145 | + return do_opivv_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ | ||
146 | +} | ||
147 | + | ||
148 | +GEN_OPIVV_GVEC_TRANS(vadd_vv, add) | ||
149 | +GEN_OPIVV_GVEC_TRANS(vsub_vv, sub) | ||
150 | + | ||
151 | +typedef void gen_helper_opivx(TCGv_ptr, TCGv_ptr, TCGv, TCGv_ptr, | ||
152 | + TCGv_env, TCGv_i32); | ||
153 | + | ||
154 | +static bool opivx_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, uint32_t vm, | ||
155 | + gen_helper_opivx *fn, DisasContext *s) | ||
156 | +{ | ||
157 | + TCGv_ptr dest, src2, mask; | ||
158 | + TCGv src1; | ||
159 | + TCGv_i32 desc; | ||
160 | + uint32_t data = 0; | ||
161 | + | ||
162 | + TCGLabel *over = gen_new_label(); | ||
163 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
164 | + | ||
165 | + dest = tcg_temp_new_ptr(); | ||
166 | + mask = tcg_temp_new_ptr(); | ||
167 | + src2 = tcg_temp_new_ptr(); | ||
168 | + src1 = tcg_temp_new(); | ||
169 | + gen_get_gpr(src1, rs1); | ||
170 | + | ||
171 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
172 | + data = FIELD_DP32(data, VDATA, VM, vm); | ||
173 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
174 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
175 | + | ||
176 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
177 | + tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, vs2)); | ||
178 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
179 | + | ||
180 | + fn(dest, mask, src1, src2, cpu_env, desc); | ||
181 | + | ||
182 | + tcg_temp_free_ptr(dest); | ||
183 | + tcg_temp_free_ptr(mask); | ||
184 | + tcg_temp_free_ptr(src2); | ||
185 | + tcg_temp_free(src1); | ||
186 | + tcg_temp_free_i32(desc); | ||
187 | + gen_set_label(over); | ||
188 | + return true; | ||
189 | +} | ||
190 | + | ||
191 | +static bool opivx_check(DisasContext *s, arg_rmrr *a) | ||
192 | +{ | ||
193 | + return (vext_check_isa_ill(s) && | ||
194 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
195 | + vext_check_reg(s, a->rd, false) && | ||
196 | + vext_check_reg(s, a->rs2, false)); | ||
197 | +} | ||
198 | + | ||
199 | +typedef void GVecGen2sFn(unsigned, uint32_t, uint32_t, TCGv_i64, | ||
200 | + uint32_t, uint32_t); | ||
201 | + | ||
202 | +static inline bool | ||
203 | +do_opivx_gvec(DisasContext *s, arg_rmrr *a, GVecGen2sFn *gvec_fn, | ||
204 | + gen_helper_opivx *fn) | ||
205 | +{ | ||
206 | + if (!opivx_check(s, a)) { | ||
207 | + return false; | ||
208 | + } | ||
209 | + | ||
210 | + if (a->vm && s->vl_eq_vlmax) { | ||
211 | + TCGv_i64 src1 = tcg_temp_new_i64(); | ||
212 | + TCGv tmp = tcg_temp_new(); | ||
213 | + | ||
214 | + gen_get_gpr(tmp, a->rs1); | ||
215 | + tcg_gen_ext_tl_i64(src1, tmp); | ||
216 | + gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), | ||
217 | + src1, MAXSZ(s), MAXSZ(s)); | ||
218 | + | ||
219 | + tcg_temp_free_i64(src1); | ||
220 | + tcg_temp_free(tmp); | ||
221 | + return true; | ||
222 | + } | ||
223 | + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s); | ||
224 | +} | ||
225 | + | ||
226 | +/* OPIVX with GVEC IR */ | ||
227 | +#define GEN_OPIVX_GVEC_TRANS(NAME, SUF) \ | ||
228 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
229 | +{ \ | ||
230 | + static gen_helper_opivx * const fns[4] = { \ | ||
231 | + gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ | ||
232 | + gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ | ||
233 | + }; \ | ||
234 | + return do_opivx_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ | ||
235 | +} | ||
236 | + | ||
237 | +GEN_OPIVX_GVEC_TRANS(vadd_vx, adds) | ||
238 | +GEN_OPIVX_GVEC_TRANS(vsub_vx, subs) | ||
239 | + | ||
240 | +static void gen_vec_rsub8_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
241 | +{ | ||
242 | + tcg_gen_vec_sub8_i64(d, b, a); | ||
243 | +} | ||
244 | + | ||
245 | +static void gen_vec_rsub16_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
246 | +{ | ||
247 | + tcg_gen_vec_sub8_i64(d, b, a); | ||
248 | +} | ||
249 | + | ||
250 | +static void gen_rsub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) | ||
251 | +{ | ||
252 | + tcg_gen_sub_i32(ret, arg2, arg1); | ||
253 | +} | ||
254 | + | ||
255 | +static void gen_rsub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) | ||
256 | +{ | ||
257 | + tcg_gen_sub_i64(ret, arg2, arg1); | ||
258 | +} | ||
259 | + | ||
260 | +static void gen_rsub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) | ||
261 | +{ | ||
262 | + tcg_gen_sub_vec(vece, r, b, a); | ||
263 | +} | ||
264 | + | ||
265 | +static void tcg_gen_gvec_rsubs(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
266 | + TCGv_i64 c, uint32_t oprsz, uint32_t maxsz) | ||
267 | +{ | ||
268 | + static const GVecGen2s rsub_op[4] = { | ||
269 | + { .fni8 = gen_vec_rsub8_i64, | ||
270 | + .fniv = gen_rsub_vec, | ||
271 | + .fno = gen_helper_vec_rsubs8, | ||
272 | + .vece = MO_8 }, | ||
273 | + { .fni8 = gen_vec_rsub16_i64, | ||
274 | + .fniv = gen_rsub_vec, | ||
275 | + .fno = gen_helper_vec_rsubs16, | ||
276 | + .vece = MO_16 }, | ||
277 | + { .fni4 = gen_rsub_i32, | ||
278 | + .fniv = gen_rsub_vec, | ||
279 | + .fno = gen_helper_vec_rsubs32, | ||
280 | + .vece = MO_32 }, | ||
281 | + { .fni8 = gen_rsub_i64, | ||
282 | + .fniv = gen_rsub_vec, | ||
283 | + .fno = gen_helper_vec_rsubs64, | ||
284 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
285 | + .vece = MO_64 }, | ||
286 | + }; | ||
287 | + | ||
288 | + tcg_debug_assert(vece <= MO_64); | ||
289 | + tcg_gen_gvec_2s(dofs, aofs, oprsz, maxsz, c, &rsub_op[vece]); | ||
290 | +} | ||
291 | + | ||
292 | +GEN_OPIVX_GVEC_TRANS(vrsub_vx, rsubs) | ||
293 | + | ||
294 | +static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm, | ||
295 | + gen_helper_opivx *fn, DisasContext *s, int zx) | ||
296 | +{ | ||
297 | + TCGv_ptr dest, src2, mask; | ||
298 | + TCGv src1; | ||
299 | + TCGv_i32 desc; | ||
300 | + uint32_t data = 0; | ||
301 | + | ||
302 | + TCGLabel *over = gen_new_label(); | ||
303 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
304 | + | ||
305 | + dest = tcg_temp_new_ptr(); | ||
306 | + mask = tcg_temp_new_ptr(); | ||
307 | + src2 = tcg_temp_new_ptr(); | ||
308 | + if (zx) { | ||
309 | + src1 = tcg_const_tl(imm); | ||
310 | + } else { | ||
311 | + src1 = tcg_const_tl(sextract64(imm, 0, 5)); | ||
312 | + } | ||
313 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
314 | + data = FIELD_DP32(data, VDATA, VM, vm); | ||
315 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
316 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
317 | + | ||
318 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
319 | + tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, vs2)); | ||
320 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
321 | + | ||
322 | + fn(dest, mask, src1, src2, cpu_env, desc); | ||
323 | + | ||
324 | + tcg_temp_free_ptr(dest); | ||
325 | + tcg_temp_free_ptr(mask); | ||
326 | + tcg_temp_free_ptr(src2); | ||
327 | + tcg_temp_free(src1); | ||
328 | + tcg_temp_free_i32(desc); | ||
329 | + gen_set_label(over); | ||
330 | + return true; | ||
331 | +} | ||
332 | + | ||
333 | +typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t, | ||
334 | + uint32_t, uint32_t); | ||
335 | + | ||
336 | +static inline bool | ||
337 | +do_opivi_gvec(DisasContext *s, arg_rmrr *a, GVecGen2iFn *gvec_fn, | ||
338 | + gen_helper_opivx *fn, int zx) | ||
339 | +{ | ||
340 | + if (!opivx_check(s, a)) { | ||
341 | + return false; | ||
342 | + } | ||
343 | + | ||
344 | + if (a->vm && s->vl_eq_vlmax) { | ||
345 | + if (zx) { | ||
346 | + gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), | ||
347 | + extract64(a->rs1, 0, 5), MAXSZ(s), MAXSZ(s)); | ||
348 | + } else { | ||
349 | + gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), | ||
350 | + sextract64(a->rs1, 0, 5), MAXSZ(s), MAXSZ(s)); | ||
351 | + } | ||
352 | + } else { | ||
353 | + return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s, zx); | ||
354 | + } | ||
355 | + return true; | ||
356 | +} | ||
357 | + | ||
358 | +/* OPIVI with GVEC IR */ | ||
359 | +#define GEN_OPIVI_GVEC_TRANS(NAME, ZX, OPIVX, SUF) \ | ||
360 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
361 | +{ \ | ||
362 | + static gen_helper_opivx * const fns[4] = { \ | ||
363 | + gen_helper_##OPIVX##_b, gen_helper_##OPIVX##_h, \ | ||
364 | + gen_helper_##OPIVX##_w, gen_helper_##OPIVX##_d, \ | ||
365 | + }; \ | ||
366 | + return do_opivi_gvec(s, a, tcg_gen_gvec_##SUF, \ | ||
367 | + fns[s->sew], ZX); \ | ||
368 | +} | ||
369 | + | ||
370 | +GEN_OPIVI_GVEC_TRANS(vadd_vi, 0, vadd_vx, addi) | ||
371 | + | ||
372 | +static void tcg_gen_gvec_rsubi(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
373 | + int64_t c, uint32_t oprsz, uint32_t maxsz) | ||
374 | +{ | ||
375 | + TCGv_i64 tmp = tcg_const_i64(c); | ||
376 | + tcg_gen_gvec_rsubs(vece, dofs, aofs, tmp, oprsz, maxsz); | ||
377 | + tcg_temp_free_i64(tmp); | ||
378 | +} | ||
379 | + | ||
380 | +GEN_OPIVI_GVEC_TRANS(vrsub_vi, 0, vrsub_vx, rsubi) | ||
381 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
382 | index XXXXXXX..XXXXXXX 100644 | ||
383 | --- a/target/riscv/vector_helper.c | ||
384 | +++ b/target/riscv/vector_helper.c | ||
385 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO(vamominw_v_w, int32_t, int32_t, idx_w, clearl) | ||
386 | GEN_VEXT_AMO(vamomaxw_v_w, int32_t, int32_t, idx_w, clearl) | ||
387 | GEN_VEXT_AMO(vamominuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
388 | GEN_VEXT_AMO(vamomaxuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
389 | + | ||
390 | +/* | ||
391 | + *** Vector Integer Arithmetic Instructions | ||
392 | + */ | ||
393 | + | ||
394 | +/* expand macro args before macro */ | ||
395 | +#define RVVCALL(macro, ...) macro(__VA_ARGS__) | ||
396 | + | ||
397 | +/* (TD, T1, T2, TX1, TX2) */ | ||
398 | +#define OP_SSS_B int8_t, int8_t, int8_t, int8_t, int8_t | ||
399 | +#define OP_SSS_H int16_t, int16_t, int16_t, int16_t, int16_t | ||
400 | +#define OP_SSS_W int32_t, int32_t, int32_t, int32_t, int32_t | ||
401 | +#define OP_SSS_D int64_t, int64_t, int64_t, int64_t, int64_t | ||
402 | + | ||
403 | +/* operation of two vector elements */ | ||
404 | +typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); | ||
405 | + | ||
406 | +#define OPIVV2(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ | ||
407 | +static void do_##NAME(void *vd, void *vs1, void *vs2, int i) \ | ||
408 | +{ \ | ||
409 | + TX1 s1 = *((T1 *)vs1 + HS1(i)); \ | ||
410 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
411 | + *((TD *)vd + HD(i)) = OP(s2, s1); \ | ||
412 | +} | ||
413 | +#define DO_SUB(N, M) (N - M) | ||
414 | +#define DO_RSUB(N, M) (M - N) | ||
415 | + | ||
416 | +RVVCALL(OPIVV2, vadd_vv_b, OP_SSS_B, H1, H1, H1, DO_ADD) | ||
417 | +RVVCALL(OPIVV2, vadd_vv_h, OP_SSS_H, H2, H2, H2, DO_ADD) | ||
418 | +RVVCALL(OPIVV2, vadd_vv_w, OP_SSS_W, H4, H4, H4, DO_ADD) | ||
419 | +RVVCALL(OPIVV2, vadd_vv_d, OP_SSS_D, H8, H8, H8, DO_ADD) | ||
420 | +RVVCALL(OPIVV2, vsub_vv_b, OP_SSS_B, H1, H1, H1, DO_SUB) | ||
421 | +RVVCALL(OPIVV2, vsub_vv_h, OP_SSS_H, H2, H2, H2, DO_SUB) | ||
422 | +RVVCALL(OPIVV2, vsub_vv_w, OP_SSS_W, H4, H4, H4, DO_SUB) | ||
423 | +RVVCALL(OPIVV2, vsub_vv_d, OP_SSS_D, H8, H8, H8, DO_SUB) | ||
424 | + | ||
425 | +static void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2, | ||
426 | + CPURISCVState *env, uint32_t desc, | ||
427 | + uint32_t esz, uint32_t dsz, | ||
428 | + opivv2_fn *fn, clear_fn *clearfn) | ||
429 | +{ | ||
430 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
431 | + uint32_t mlen = vext_mlen(desc); | ||
432 | + uint32_t vm = vext_vm(desc); | ||
433 | + uint32_t vl = env->vl; | ||
434 | + uint32_t i; | ||
435 | + | ||
436 | + for (i = 0; i < vl; i++) { | ||
437 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
438 | + continue; | ||
439 | + } | ||
440 | + fn(vd, vs1, vs2, i); | ||
441 | + } | ||
442 | + clearfn(vd, vl, vl * dsz, vlmax * dsz); | ||
443 | +} | ||
444 | + | ||
445 | +/* generate the helpers for OPIVV */ | ||
446 | +#define GEN_VEXT_VV(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
447 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, \ | ||
448 | + void *vs2, CPURISCVState *env, \ | ||
449 | + uint32_t desc) \ | ||
450 | +{ \ | ||
451 | + do_vext_vv(vd, v0, vs1, vs2, env, desc, ESZ, DSZ, \ | ||
452 | + do_##NAME, CLEAR_FN); \ | ||
453 | +} | ||
454 | + | ||
455 | +GEN_VEXT_VV(vadd_vv_b, 1, 1, clearb) | ||
456 | +GEN_VEXT_VV(vadd_vv_h, 2, 2, clearh) | ||
457 | +GEN_VEXT_VV(vadd_vv_w, 4, 4, clearl) | ||
458 | +GEN_VEXT_VV(vadd_vv_d, 8, 8, clearq) | ||
459 | +GEN_VEXT_VV(vsub_vv_b, 1, 1, clearb) | ||
460 | +GEN_VEXT_VV(vsub_vv_h, 2, 2, clearh) | ||
461 | +GEN_VEXT_VV(vsub_vv_w, 4, 4, clearl) | ||
462 | +GEN_VEXT_VV(vsub_vv_d, 8, 8, clearq) | ||
463 | + | ||
464 | +typedef void opivx2_fn(void *vd, target_long s1, void *vs2, int i); | ||
465 | + | ||
466 | +/* | ||
467 | + * (T1)s1 gives the real operator type. | ||
468 | + * (TX1)(T1)s1 expands the operator type of widen or narrow operations. | ||
469 | + */ | ||
470 | +#define OPIVX2(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ | ||
471 | +static void do_##NAME(void *vd, target_long s1, void *vs2, int i) \ | ||
472 | +{ \ | ||
473 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
474 | + *((TD *)vd + HD(i)) = OP(s2, (TX1)(T1)s1); \ | ||
475 | +} | ||
476 | + | ||
477 | +RVVCALL(OPIVX2, vadd_vx_b, OP_SSS_B, H1, H1, DO_ADD) | ||
478 | +RVVCALL(OPIVX2, vadd_vx_h, OP_SSS_H, H2, H2, DO_ADD) | ||
479 | +RVVCALL(OPIVX2, vadd_vx_w, OP_SSS_W, H4, H4, DO_ADD) | ||
480 | +RVVCALL(OPIVX2, vadd_vx_d, OP_SSS_D, H8, H8, DO_ADD) | ||
481 | +RVVCALL(OPIVX2, vsub_vx_b, OP_SSS_B, H1, H1, DO_SUB) | ||
482 | +RVVCALL(OPIVX2, vsub_vx_h, OP_SSS_H, H2, H2, DO_SUB) | ||
483 | +RVVCALL(OPIVX2, vsub_vx_w, OP_SSS_W, H4, H4, DO_SUB) | ||
484 | +RVVCALL(OPIVX2, vsub_vx_d, OP_SSS_D, H8, H8, DO_SUB) | ||
485 | +RVVCALL(OPIVX2, vrsub_vx_b, OP_SSS_B, H1, H1, DO_RSUB) | ||
486 | +RVVCALL(OPIVX2, vrsub_vx_h, OP_SSS_H, H2, H2, DO_RSUB) | ||
487 | +RVVCALL(OPIVX2, vrsub_vx_w, OP_SSS_W, H4, H4, DO_RSUB) | ||
488 | +RVVCALL(OPIVX2, vrsub_vx_d, OP_SSS_D, H8, H8, DO_RSUB) | ||
489 | + | ||
490 | +static void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2, | ||
491 | + CPURISCVState *env, uint32_t desc, | ||
492 | + uint32_t esz, uint32_t dsz, | ||
493 | + opivx2_fn fn, clear_fn *clearfn) | ||
494 | +{ | ||
495 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
496 | + uint32_t mlen = vext_mlen(desc); | ||
497 | + uint32_t vm = vext_vm(desc); | ||
498 | + uint32_t vl = env->vl; | ||
499 | + uint32_t i; | ||
500 | + | ||
501 | + for (i = 0; i < vl; i++) { | ||
502 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
503 | + continue; | ||
504 | + } | ||
505 | + fn(vd, s1, vs2, i); | ||
506 | + } | ||
507 | + clearfn(vd, vl, vl * dsz, vlmax * dsz); | ||
508 | +} | ||
509 | + | ||
510 | +/* generate the helpers for OPIVX */ | ||
511 | +#define GEN_VEXT_VX(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
512 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ | ||
513 | + void *vs2, CPURISCVState *env, \ | ||
514 | + uint32_t desc) \ | ||
515 | +{ \ | ||
516 | + do_vext_vx(vd, v0, s1, vs2, env, desc, ESZ, DSZ, \ | ||
517 | + do_##NAME, CLEAR_FN); \ | ||
518 | +} | ||
519 | + | ||
520 | +GEN_VEXT_VX(vadd_vx_b, 1, 1, clearb) | ||
521 | +GEN_VEXT_VX(vadd_vx_h, 2, 2, clearh) | ||
522 | +GEN_VEXT_VX(vadd_vx_w, 4, 4, clearl) | ||
523 | +GEN_VEXT_VX(vadd_vx_d, 8, 8, clearq) | ||
524 | +GEN_VEXT_VX(vsub_vx_b, 1, 1, clearb) | ||
525 | +GEN_VEXT_VX(vsub_vx_h, 2, 2, clearh) | ||
526 | +GEN_VEXT_VX(vsub_vx_w, 4, 4, clearl) | ||
527 | +GEN_VEXT_VX(vsub_vx_d, 8, 8, clearq) | ||
528 | +GEN_VEXT_VX(vrsub_vx_b, 1, 1, clearb) | ||
529 | +GEN_VEXT_VX(vrsub_vx_h, 2, 2, clearh) | ||
530 | +GEN_VEXT_VX(vrsub_vx_w, 4, 4, clearl) | ||
531 | +GEN_VEXT_VX(vrsub_vx_d, 8, 8, clearq) | ||
532 | + | ||
533 | +void HELPER(vec_rsubs8)(void *d, void *a, uint64_t b, uint32_t desc) | ||
534 | +{ | ||
535 | + intptr_t oprsz = simd_oprsz(desc); | ||
536 | + intptr_t i; | ||
537 | + | ||
538 | + for (i = 0; i < oprsz; i += sizeof(uint8_t)) { | ||
539 | + *(uint8_t *)(d + i) = (uint8_t)b - *(uint8_t *)(a + i); | ||
540 | + } | 54 | + } |
541 | +} | 55 | +} |
542 | + | 56 | + |
543 | +void HELPER(vec_rsubs16)(void *d, void *a, uint64_t b, uint32_t desc) | 57 | void helper_tlb_flush(CPURISCVState *env) |
58 | { | ||
59 | CPUState *cs = env_cpu(env); | ||
60 | diff --git a/target/riscv/insn_trans/trans_rvzawrs.c.inc b/target/riscv/insn_trans/trans_rvzawrs.c.inc | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/riscv/insn_trans/trans_rvzawrs.c.inc | ||
63 | +++ b/target/riscv/insn_trans/trans_rvzawrs.c.inc | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
66 | */ | ||
67 | |||
68 | -static bool trans_wrs(DisasContext *ctx) | ||
69 | +static bool trans_wrs_sto(DisasContext *ctx, arg_wrs_sto *a) | ||
70 | { | ||
71 | if (!ctx->cfg_ptr->ext_zawrs) { | ||
72 | return false; | ||
73 | @@ -XXX,XX +XXX,XX @@ static bool trans_wrs(DisasContext *ctx) | ||
74 | return true; | ||
75 | } | ||
76 | |||
77 | -#define GEN_TRANS_WRS(insn) \ | ||
78 | -static bool trans_ ## insn(DisasContext *ctx, arg_ ## insn *a) \ | ||
79 | -{ \ | ||
80 | - (void)a; \ | ||
81 | - return trans_wrs(ctx); \ | ||
82 | -} | ||
83 | +static bool trans_wrs_nto(DisasContext *ctx, arg_wrs_nto *a) | ||
544 | +{ | 84 | +{ |
545 | + intptr_t oprsz = simd_oprsz(desc); | 85 | + if (!ctx->cfg_ptr->ext_zawrs) { |
546 | + intptr_t i; | 86 | + return false; |
87 | + } | ||
88 | |||
89 | -GEN_TRANS_WRS(wrs_nto) | ||
90 | -GEN_TRANS_WRS(wrs_sto) | ||
91 | + /* | ||
92 | + * Depending on the mode of execution, mstatus.TW and hstatus.VTW, wrs.nto | ||
93 | + * should raise an exception when the implementation-specific bounded time | ||
94 | + * limit has expired. Our time limit is zero, so we either return | ||
95 | + * immediately, as does our implementation of wrs.sto, or raise an | ||
96 | + * exception, as handled by the wrs.nto helper. | ||
97 | + */ | ||
98 | +#ifndef CONFIG_USER_ONLY | ||
99 | + gen_helper_wrs_nto(tcg_env); | ||
100 | +#endif | ||
547 | + | 101 | + |
548 | + for (i = 0; i < oprsz; i += sizeof(uint16_t)) { | 102 | + /* We only get here when helper_wrs_nto() doesn't raise an exception. */ |
549 | + *(uint16_t *)(d + i) = (uint16_t)b - *(uint16_t *)(a + i); | 103 | + return trans_wrs_sto(ctx, NULL); |
550 | + } | ||
551 | +} | ||
552 | + | ||
553 | +void HELPER(vec_rsubs32)(void *d, void *a, uint64_t b, uint32_t desc) | ||
554 | +{ | ||
555 | + intptr_t oprsz = simd_oprsz(desc); | ||
556 | + intptr_t i; | ||
557 | + | ||
558 | + for (i = 0; i < oprsz; i += sizeof(uint32_t)) { | ||
559 | + *(uint32_t *)(d + i) = (uint32_t)b - *(uint32_t *)(a + i); | ||
560 | + } | ||
561 | +} | ||
562 | + | ||
563 | +void HELPER(vec_rsubs64)(void *d, void *a, uint64_t b, uint32_t desc) | ||
564 | +{ | ||
565 | + intptr_t oprsz = simd_oprsz(desc); | ||
566 | + intptr_t i; | ||
567 | + | ||
568 | + for (i = 0; i < oprsz; i += sizeof(uint64_t)) { | ||
569 | + *(uint64_t *)(d + i) = b - *(uint64_t *)(a + i); | ||
570 | + } | ||
571 | +} | 104 | +} |
572 | -- | 105 | -- |
573 | 2.27.0 | 106 | 2.45.1 |
574 | 107 | ||
575 | 108 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | SBI defines a Debug Console extension "DBCN" that will, in time, replace |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | the legacy console putchar and getchar SBI extensions. |
5 | Message-id: 20200623215920.2594-53-zhiwei_liu@c-sky.com | 5 | |
6 | The appeal of the DBCN extension is that it allows multiple bytes to be | ||
7 | read/written in the SBI console in a single SBI call. | ||
8 | |||
9 | As far as KVM goes, the DBCN calls are forwarded by an in-kernel KVM | ||
10 | module to userspace. But this will only happens if the KVM module | ||
11 | actually supports this SBI extension and we activate it. | ||
12 | |||
13 | We'll check for DBCN support during init time, checking if get-reg-list | ||
14 | is advertising KVM_RISCV_SBI_EXT_DBCN. In that case, we'll enable it via | ||
15 | kvm_set_one_reg() during kvm_arch_init_vcpu(). | ||
16 | |||
17 | Finally, change kvm_riscv_handle_sbi() to handle the incoming calls for | ||
18 | SBI_EXT_DBCN, reading and writing as required. | ||
19 | |||
20 | A simple KVM guest with 'earlycon=sbi', running in an emulated RISC-V | ||
21 | host, takes around 20 seconds to boot without using DBCN. With this | ||
22 | patch we're taking around 14 seconds to boot due to the speed-up in the | ||
23 | terminal output. There's no change in boot time if the guest isn't | ||
24 | using earlycon. | ||
25 | |||
26 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
27 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
28 | Message-ID: <20240425155012.581366-1-dbarboza@ventanamicro.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 29 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 30 | --- |
8 | target/riscv/helper.h | 4 ++ | 31 | target/riscv/sbi_ecall_interface.h | 17 +++++ |
9 | target/riscv/insn32.decode | 3 ++ | 32 | target/riscv/kvm/kvm-cpu.c | 111 +++++++++++++++++++++++++++++ |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 28 +++++++++++ | 33 | 2 files changed, 128 insertions(+) |
11 | target/riscv/vector_helper.c | 63 +++++++++++++++++++++++++ | 34 | |
12 | 4 files changed, 98 insertions(+) | 35 | diff --git a/target/riscv/sbi_ecall_interface.h b/target/riscv/sbi_ecall_interface.h |
13 | |||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 37 | --- a/target/riscv/sbi_ecall_interface.h |
17 | +++ b/target/riscv/helper.h | 38 | +++ b/target/riscv/sbi_ecall_interface.h |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 39 | @@ -XXX,XX +XXX,XX @@ |
19 | DEF_HELPER_4(vmpopc_m, tl, ptr, ptr, env, i32) | 40 | |
20 | 41 | /* clang-format off */ | |
21 | DEF_HELPER_4(vmfirst_m, tl, ptr, ptr, env, i32) | 42 | |
22 | + | 43 | +#define SBI_SUCCESS 0 |
23 | +DEF_HELPER_5(vmsbf_m, void, ptr, ptr, ptr, env, i32) | 44 | +#define SBI_ERR_FAILED -1 |
24 | +DEF_HELPER_5(vmsif_m, void, ptr, ptr, ptr, env, i32) | 45 | +#define SBI_ERR_NOT_SUPPORTED -2 |
25 | +DEF_HELPER_5(vmsof_m, void, ptr, ptr, ptr, env, i32) | 46 | +#define SBI_ERR_INVALID_PARAM -3 |
26 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 47 | +#define SBI_ERR_DENIED -4 |
48 | +#define SBI_ERR_INVALID_ADDRESS -5 | ||
49 | +#define SBI_ERR_ALREADY_AVAILABLE -6 | ||
50 | +#define SBI_ERR_ALREADY_STARTED -7 | ||
51 | +#define SBI_ERR_ALREADY_STOPPED -8 | ||
52 | +#define SBI_ERR_NO_SHMEM -9 | ||
53 | + | ||
54 | /* SBI Extension IDs */ | ||
55 | #define SBI_EXT_0_1_SET_TIMER 0x0 | ||
56 | #define SBI_EXT_0_1_CONSOLE_PUTCHAR 0x1 | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | #define SBI_EXT_IPI 0x735049 | ||
59 | #define SBI_EXT_RFENCE 0x52464E43 | ||
60 | #define SBI_EXT_HSM 0x48534D | ||
61 | +#define SBI_EXT_DBCN 0x4442434E | ||
62 | |||
63 | /* SBI function IDs for BASE extension */ | ||
64 | #define SBI_EXT_BASE_GET_SPEC_VERSION 0x0 | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | #define SBI_EXT_HSM_HART_STOP 0x1 | ||
67 | #define SBI_EXT_HSM_HART_GET_STATUS 0x2 | ||
68 | |||
69 | +/* SBI function IDs for DBCN extension */ | ||
70 | +#define SBI_EXT_DBCN_CONSOLE_WRITE 0x0 | ||
71 | +#define SBI_EXT_DBCN_CONSOLE_READ 0x1 | ||
72 | +#define SBI_EXT_DBCN_CONSOLE_WRITE_BYTE 0x2 | ||
73 | + | ||
74 | #define SBI_HSM_HART_STATUS_STARTED 0x0 | ||
75 | #define SBI_HSM_HART_STATUS_STOPPED 0x1 | ||
76 | #define SBI_HSM_HART_STATUS_START_PENDING 0x2 | ||
77 | diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | 78 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/riscv/insn32.decode | 79 | --- a/target/riscv/kvm/kvm-cpu.c |
29 | +++ b/target/riscv/insn32.decode | 80 | +++ b/target/riscv/kvm/kvm-cpu.c |
30 | @@ -XXX,XX +XXX,XX @@ vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | 81 | @@ -XXX,XX +XXX,XX @@ static KVMCPUConfig kvm_v_vlenb = { |
31 | vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | 82 | KVM_REG_RISCV_VECTOR_CSR_REG(vlenb) |
32 | vmpopc_m 010100 . ..... ----- 010 ..... 1010111 @r2_vm | 83 | }; |
33 | vmfirst_m 010101 . ..... ----- 010 ..... 1010111 @r2_vm | 84 | |
34 | +vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm | 85 | +static KVMCPUConfig kvm_sbi_dbcn = { |
35 | +vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm | 86 | + .name = "sbi_dbcn", |
36 | +vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | 87 | + .kvm_reg_id = KVM_REG_RISCV | KVM_REG_SIZE_U64 | |
37 | 88 | + KVM_REG_RISCV_SBI_EXT | KVM_RISCV_SBI_EXT_DBCN | |
38 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
39 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
40 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
43 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool trans_vmfirst_m(DisasContext *s, arg_rmr *a) | ||
45 | } | ||
46 | return false; | ||
47 | } | ||
48 | + | ||
49 | +/* vmsbf.m set-before-first mask bit */ | ||
50 | +/* vmsif.m set-includ-first mask bit */ | ||
51 | +/* vmsof.m set-only-first mask bit */ | ||
52 | +#define GEN_M_TRANS(NAME) \ | ||
53 | +static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ | ||
54 | +{ \ | ||
55 | + if (vext_check_isa_ill(s)) { \ | ||
56 | + uint32_t data = 0; \ | ||
57 | + gen_helper_gvec_3_ptr *fn = gen_helper_##NAME; \ | ||
58 | + TCGLabel *over = gen_new_label(); \ | ||
59 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
60 | + \ | ||
61 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
62 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
63 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
64 | + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), \ | ||
65 | + vreg_ofs(s, 0), vreg_ofs(s, a->rs2), \ | ||
66 | + cpu_env, 0, s->vlen / 8, data, fn); \ | ||
67 | + gen_set_label(over); \ | ||
68 | + return true; \ | ||
69 | + } \ | ||
70 | + return false; \ | ||
71 | +} | ||
72 | + | ||
73 | +GEN_M_TRANS(vmsbf_m) | ||
74 | +GEN_M_TRANS(vmsif_m) | ||
75 | +GEN_M_TRANS(vmsof_m) | ||
76 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/riscv/vector_helper.c | ||
79 | +++ b/target/riscv/vector_helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ target_ulong HELPER(vmfirst_m)(void *v0, void *vs2, CPURISCVState *env, | ||
81 | } | ||
82 | return -1LL; | ||
83 | } | ||
84 | + | ||
85 | +enum set_mask_type { | ||
86 | + ONLY_FIRST = 1, | ||
87 | + INCLUDE_FIRST, | ||
88 | + BEFORE_FIRST, | ||
89 | +}; | 89 | +}; |
90 | + | 90 | + |
91 | +static void vmsetm(void *vd, void *v0, void *vs2, CPURISCVState *env, | 91 | static void kvm_riscv_update_cpu_cfg_isa_ext(RISCVCPU *cpu, CPUState *cs) |
92 | + uint32_t desc, enum set_mask_type type) | 92 | { |
93 | CPURISCVState *env = &cpu->env; | ||
94 | @@ -XXX,XX +XXX,XX @@ static int uint64_cmp(const void *a, const void *b) | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | +static void kvm_riscv_check_sbi_dbcn_support(RISCVCPU *cpu, | ||
99 | + KVMScratchCPU *kvmcpu, | ||
100 | + struct kvm_reg_list *reglist) | ||
93 | +{ | 101 | +{ |
94 | + uint32_t mlen = vext_mlen(desc); | 102 | + struct kvm_reg_list *reg_search; |
95 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; | 103 | + |
96 | + uint32_t vm = vext_vm(desc); | 104 | + reg_search = bsearch(&kvm_sbi_dbcn.kvm_reg_id, reglist->reg, reglist->n, |
97 | + uint32_t vl = env->vl; | 105 | + sizeof(uint64_t), uint64_cmp); |
98 | + int i; | 106 | + |
99 | + bool first_mask_bit = false; | 107 | + if (reg_search) { |
100 | + | 108 | + kvm_sbi_dbcn.supported = true; |
101 | + for (i = 0; i < vl; i++) { | ||
102 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
103 | + continue; | ||
104 | + } | ||
105 | + /* write a zero to all following active elements */ | ||
106 | + if (first_mask_bit) { | ||
107 | + vext_set_elem_mask(vd, mlen, i, 0); | ||
108 | + continue; | ||
109 | + } | ||
110 | + if (vext_elem_mask(vs2, mlen, i)) { | ||
111 | + first_mask_bit = true; | ||
112 | + if (type == BEFORE_FIRST) { | ||
113 | + vext_set_elem_mask(vd, mlen, i, 0); | ||
114 | + } else { | ||
115 | + vext_set_elem_mask(vd, mlen, i, 1); | ||
116 | + } | ||
117 | + } else { | ||
118 | + if (type == ONLY_FIRST) { | ||
119 | + vext_set_elem_mask(vd, mlen, i, 0); | ||
120 | + } else { | ||
121 | + vext_set_elem_mask(vd, mlen, i, 1); | ||
122 | + } | ||
123 | + } | ||
124 | + } | ||
125 | + for (; i < vlmax; i++) { | ||
126 | + vext_set_elem_mask(vd, mlen, i, 0); | ||
127 | + } | 109 | + } |
128 | +} | 110 | +} |
129 | + | 111 | + |
130 | +void HELPER(vmsbf_m)(void *vd, void *v0, void *vs2, CPURISCVState *env, | 112 | static void kvm_riscv_read_vlenb(RISCVCPU *cpu, KVMScratchCPU *kvmcpu, |
131 | + uint32_t desc) | 113 | struct kvm_reg_list *reglist) |
114 | { | ||
115 | @@ -XXX,XX +XXX,XX @@ static void kvm_riscv_init_multiext_cfg(RISCVCPU *cpu, KVMScratchCPU *kvmcpu) | ||
116 | if (riscv_has_ext(&cpu->env, RVV)) { | ||
117 | kvm_riscv_read_vlenb(cpu, kvmcpu, reglist); | ||
118 | } | ||
119 | + | ||
120 | + kvm_riscv_check_sbi_dbcn_support(cpu, kvmcpu, reglist); | ||
121 | } | ||
122 | |||
123 | static void riscv_init_kvm_registers(Object *cpu_obj) | ||
124 | @@ -XXX,XX +XXX,XX @@ static int kvm_vcpu_set_machine_ids(RISCVCPU *cpu, CPUState *cs) | ||
125 | return ret; | ||
126 | } | ||
127 | |||
128 | +static int kvm_vcpu_enable_sbi_dbcn(RISCVCPU *cpu, CPUState *cs) | ||
132 | +{ | 129 | +{ |
133 | + vmsetm(vd, v0, vs2, env, desc, BEFORE_FIRST); | 130 | + target_ulong reg = 1; |
131 | + | ||
132 | + if (!kvm_sbi_dbcn.supported) { | ||
133 | + return 0; | ||
134 | + } | ||
135 | + | ||
136 | + return kvm_set_one_reg(cs, kvm_sbi_dbcn.kvm_reg_id, ®); | ||
134 | +} | 137 | +} |
135 | + | 138 | + |
136 | +void HELPER(vmsif_m)(void *vd, void *v0, void *vs2, CPURISCVState *env, | 139 | int kvm_arch_init_vcpu(CPUState *cs) |
137 | + uint32_t desc) | 140 | { |
141 | int ret = 0; | ||
142 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
143 | kvm_riscv_update_cpu_misa_ext(cpu, cs); | ||
144 | kvm_riscv_update_cpu_cfg_isa_ext(cpu, cs); | ||
145 | |||
146 | + ret = kvm_vcpu_enable_sbi_dbcn(cpu, cs); | ||
147 | + | ||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | @@ -XXX,XX +XXX,XX @@ bool kvm_arch_stop_on_emulation_error(CPUState *cs) | ||
152 | return true; | ||
153 | } | ||
154 | |||
155 | +static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run) | ||
138 | +{ | 156 | +{ |
139 | + vmsetm(vd, v0, vs2, env, desc, INCLUDE_FIRST); | 157 | + g_autofree uint8_t *buf = NULL; |
158 | + RISCVCPU *cpu = RISCV_CPU(cs); | ||
159 | + target_ulong num_bytes; | ||
160 | + uint64_t addr; | ||
161 | + unsigned char ch; | ||
162 | + int ret; | ||
163 | + | ||
164 | + switch (run->riscv_sbi.function_id) { | ||
165 | + case SBI_EXT_DBCN_CONSOLE_READ: | ||
166 | + case SBI_EXT_DBCN_CONSOLE_WRITE: | ||
167 | + num_bytes = run->riscv_sbi.args[0]; | ||
168 | + | ||
169 | + if (num_bytes == 0) { | ||
170 | + run->riscv_sbi.ret[0] = SBI_SUCCESS; | ||
171 | + run->riscv_sbi.ret[1] = 0; | ||
172 | + break; | ||
173 | + } | ||
174 | + | ||
175 | + addr = run->riscv_sbi.args[1]; | ||
176 | + | ||
177 | + /* | ||
178 | + * Handle the case where a 32 bit CPU is running in a | ||
179 | + * 64 bit addressing env. | ||
180 | + */ | ||
181 | + if (riscv_cpu_mxl(&cpu->env) == MXL_RV32) { | ||
182 | + addr |= (uint64_t)run->riscv_sbi.args[2] << 32; | ||
183 | + } | ||
184 | + | ||
185 | + buf = g_malloc0(num_bytes); | ||
186 | + | ||
187 | + if (run->riscv_sbi.function_id == SBI_EXT_DBCN_CONSOLE_READ) { | ||
188 | + ret = qemu_chr_fe_read_all(serial_hd(0)->be, buf, num_bytes); | ||
189 | + if (ret < 0) { | ||
190 | + error_report("SBI_EXT_DBCN_CONSOLE_READ: error when " | ||
191 | + "reading chardev"); | ||
192 | + exit(1); | ||
193 | + } | ||
194 | + | ||
195 | + cpu_physical_memory_write(addr, buf, ret); | ||
196 | + } else { | ||
197 | + cpu_physical_memory_read(addr, buf, num_bytes); | ||
198 | + | ||
199 | + ret = qemu_chr_fe_write_all(serial_hd(0)->be, buf, num_bytes); | ||
200 | + if (ret < 0) { | ||
201 | + error_report("SBI_EXT_DBCN_CONSOLE_WRITE: error when " | ||
202 | + "writing chardev"); | ||
203 | + exit(1); | ||
204 | + } | ||
205 | + } | ||
206 | + | ||
207 | + run->riscv_sbi.ret[0] = SBI_SUCCESS; | ||
208 | + run->riscv_sbi.ret[1] = ret; | ||
209 | + break; | ||
210 | + case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE: | ||
211 | + ch = run->riscv_sbi.args[0]; | ||
212 | + ret = qemu_chr_fe_write(serial_hd(0)->be, &ch, sizeof(ch)); | ||
213 | + | ||
214 | + if (ret < 0) { | ||
215 | + error_report("SBI_EXT_DBCN_CONSOLE_WRITE_BYTE: error when " | ||
216 | + "writing chardev"); | ||
217 | + exit(1); | ||
218 | + } | ||
219 | + | ||
220 | + run->riscv_sbi.ret[0] = SBI_SUCCESS; | ||
221 | + run->riscv_sbi.ret[1] = 0; | ||
222 | + break; | ||
223 | + default: | ||
224 | + run->riscv_sbi.ret[0] = SBI_ERR_NOT_SUPPORTED; | ||
225 | + } | ||
140 | +} | 226 | +} |
141 | + | 227 | + |
142 | +void HELPER(vmsof_m)(void *vd, void *v0, void *vs2, CPURISCVState *env, | 228 | static int kvm_riscv_handle_sbi(CPUState *cs, struct kvm_run *run) |
143 | + uint32_t desc) | 229 | { |
144 | +{ | 230 | int ret = 0; |
145 | + vmsetm(vd, v0, vs2, env, desc, ONLY_FIRST); | 231 | @@ -XXX,XX +XXX,XX @@ static int kvm_riscv_handle_sbi(CPUState *cs, struct kvm_run *run) |
146 | +} | 232 | } |
233 | ret = 0; | ||
234 | break; | ||
235 | + case SBI_EXT_DBCN: | ||
236 | + kvm_riscv_handle_sbi_dbcn(cs, run); | ||
237 | + break; | ||
238 | default: | ||
239 | qemu_log_mask(LOG_UNIMP, | ||
240 | "%s: un-handled SBI EXIT, specific reasons is %lu\n", | ||
147 | -- | 241 | -- |
148 | 2.27.0 | 242 | 2.45.1 |
149 | |||
150 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Cheng Yang <yangcheng.work@foxmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Use qemu_fdt_setprop_u64() instead of qemu_fdt_setprop_cell() |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | to set the address of initrd in FDT to support 64-bit address. |
5 | |||
6 | Signed-off-by: Cheng Yang <yangcheng.work@foxmail.com> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
6 | Message-id: 20200623215920.2594-38-zhiwei_liu@c-sky.com | 8 | Message-ID: <tencent_A4482251DD0890F312758FA6B33F60815609@qq.com> |
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
8 | --- | 10 | --- |
9 | target/riscv/helper.h | 13 ++++++++++++ | 11 | hw/riscv/boot.c | 4 ++-- |
10 | target/riscv/insn32.decode | 4 ++++ | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
11 | target/riscv/insn_trans/trans_rvv.inc.c | 6 ++++++ | ||
12 | target/riscv/vector_helper.c | 27 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 50 insertions(+) | ||
14 | 13 | ||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 14 | diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/riscv/helper.h | 16 | --- a/hw/riscv/boot.c |
18 | +++ b/target/riscv/helper.h | 17 | +++ b/hw/riscv/boot.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfwnmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | 18 | @@ -XXX,XX +XXX,XX @@ static void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry) |
20 | DEF_HELPER_5(vfsqrt_v_h, void, ptr, ptr, ptr, env, i32) | 19 | /* Some RISC-V machines (e.g. opentitan) don't have a fdt. */ |
21 | DEF_HELPER_5(vfsqrt_v_w, void, ptr, ptr, ptr, env, i32) | 20 | if (fdt) { |
22 | DEF_HELPER_5(vfsqrt_v_d, void, ptr, ptr, ptr, env, i32) | 21 | end = start + size; |
23 | + | 22 | - qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", start); |
24 | +DEF_HELPER_6(vfmin_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | 23 | - qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", end); |
25 | +DEF_HELPER_6(vfmin_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | 24 | + qemu_fdt_setprop_u64(fdt, "/chosen", "linux,initrd-start", start); |
26 | +DEF_HELPER_6(vfmin_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | 25 | + qemu_fdt_setprop_u64(fdt, "/chosen", "linux,initrd-end", end); |
27 | +DEF_HELPER_6(vfmax_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | 26 | } |
28 | +DEF_HELPER_6(vfmax_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfmax_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfmin_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfmin_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfmin_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vfmax_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vfmax_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vfmax_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
36 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/riscv/insn32.decode | ||
39 | +++ b/target/riscv/insn32.decode | ||
40 | @@ -XXX,XX +XXX,XX @@ vfwmsac_vf 111110 . ..... ..... 101 ..... 1010111 @r_vm | ||
41 | vfwnmsac_vv 111111 . ..... ..... 001 ..... 1010111 @r_vm | ||
42 | vfwnmsac_vf 111111 . ..... ..... 101 ..... 1010111 @r_vm | ||
43 | vfsqrt_v 100011 . ..... 00000 001 ..... 1010111 @r2_vm | ||
44 | +vfmin_vv 000100 . ..... ..... 001 ..... 1010111 @r_vm | ||
45 | +vfmin_vf 000100 . ..... ..... 101 ..... 1010111 @r_vm | ||
46 | +vfmax_vv 000110 . ..... ..... 001 ..... 1010111 @r_vm | ||
47 | +vfmax_vf 000110 . ..... ..... 101 ..... 1010111 @r_vm | ||
48 | |||
49 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
50 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
51 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
54 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ | ||
56 | } | 27 | } |
57 | 28 | ||
58 | GEN_OPFV_TRANS(vfsqrt_v, opfv_check) | ||
59 | + | ||
60 | +/* Vector Floating-Point MIN/MAX Instructions */ | ||
61 | +GEN_OPFVV_TRANS(vfmin_vv, opfvv_check) | ||
62 | +GEN_OPFVV_TRANS(vfmax_vv, opfvv_check) | ||
63 | +GEN_OPFVF_TRANS(vfmin_vf, opfvf_check) | ||
64 | +GEN_OPFVF_TRANS(vfmax_vf, opfvf_check) | ||
65 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/riscv/vector_helper.c | ||
68 | +++ b/target/riscv/vector_helper.c | ||
69 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVV1, vfsqrt_v_d, OP_UU_D, H8, H8, float64_sqrt) | ||
70 | GEN_VEXT_V_ENV(vfsqrt_v_h, 2, 2, clearh) | ||
71 | GEN_VEXT_V_ENV(vfsqrt_v_w, 4, 4, clearl) | ||
72 | GEN_VEXT_V_ENV(vfsqrt_v_d, 8, 8, clearq) | ||
73 | + | ||
74 | +/* Vector Floating-Point MIN/MAX Instructions */ | ||
75 | +RVVCALL(OPFVV2, vfmin_vv_h, OP_UUU_H, H2, H2, H2, float16_minnum) | ||
76 | +RVVCALL(OPFVV2, vfmin_vv_w, OP_UUU_W, H4, H4, H4, float32_minnum) | ||
77 | +RVVCALL(OPFVV2, vfmin_vv_d, OP_UUU_D, H8, H8, H8, float64_minnum) | ||
78 | +GEN_VEXT_VV_ENV(vfmin_vv_h, 2, 2, clearh) | ||
79 | +GEN_VEXT_VV_ENV(vfmin_vv_w, 4, 4, clearl) | ||
80 | +GEN_VEXT_VV_ENV(vfmin_vv_d, 8, 8, clearq) | ||
81 | +RVVCALL(OPFVF2, vfmin_vf_h, OP_UUU_H, H2, H2, float16_minnum) | ||
82 | +RVVCALL(OPFVF2, vfmin_vf_w, OP_UUU_W, H4, H4, float32_minnum) | ||
83 | +RVVCALL(OPFVF2, vfmin_vf_d, OP_UUU_D, H8, H8, float64_minnum) | ||
84 | +GEN_VEXT_VF(vfmin_vf_h, 2, 2, clearh) | ||
85 | +GEN_VEXT_VF(vfmin_vf_w, 4, 4, clearl) | ||
86 | +GEN_VEXT_VF(vfmin_vf_d, 8, 8, clearq) | ||
87 | + | ||
88 | +RVVCALL(OPFVV2, vfmax_vv_h, OP_UUU_H, H2, H2, H2, float16_maxnum) | ||
89 | +RVVCALL(OPFVV2, vfmax_vv_w, OP_UUU_W, H4, H4, H4, float32_maxnum) | ||
90 | +RVVCALL(OPFVV2, vfmax_vv_d, OP_UUU_D, H8, H8, H8, float64_maxnum) | ||
91 | +GEN_VEXT_VV_ENV(vfmax_vv_h, 2, 2, clearh) | ||
92 | +GEN_VEXT_VV_ENV(vfmax_vv_w, 4, 4, clearl) | ||
93 | +GEN_VEXT_VV_ENV(vfmax_vv_d, 8, 8, clearq) | ||
94 | +RVVCALL(OPFVF2, vfmax_vf_h, OP_UUU_H, H2, H2, float16_maxnum) | ||
95 | +RVVCALL(OPFVF2, vfmax_vf_w, OP_UUU_W, H4, H4, float32_maxnum) | ||
96 | +RVVCALL(OPFVF2, vfmax_vf_d, OP_UUU_D, H8, H8, float64_maxnum) | ||
97 | +GEN_VEXT_VF(vfmax_vf_h, 2, 2, clearh) | ||
98 | +GEN_VEXT_VF(vfmax_vf_w, 4, 4, clearl) | ||
99 | +GEN_VEXT_VF(vfmax_vf_d, 8, 8, clearq) | ||
100 | -- | 29 | -- |
101 | 2.27.0 | 30 | 2.45.1 |
102 | |||
103 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Clément Léger <cleger@rivosinc.com> |
---|---|---|---|
2 | 2 | ||
3 | The v0.7.1 specification does not define vector status within mstatus. | 3 | The current semihost exception number (16) is a reserved number (range |
4 | A future revision will define the privileged portion of the vector status. | 4 | [16-17]). The upcoming double trap specification uses that number for |
5 | the double trap exception. Since the privileged spec (Table 22) defines | ||
6 | ranges for custom uses change the semihosting exception number to 63 | ||
7 | which belongs to the range [48-63] in order to avoid any future | ||
8 | collisions with reserved exception. | ||
5 | 9 | ||
6 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 10 | Signed-off-by: Clément Léger <cleger@rivosinc.com> |
11 | |||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Message-ID: <20240422135840.1959967-1-cleger@rivosinc.com> |
9 | Message-id: 20200623215920.2594-4-zhiwei_liu@c-sky.com | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 14 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
11 | --- | 15 | --- |
12 | target/riscv/cpu_bits.h | 15 +++++++++ | 16 | target/riscv/cpu_bits.h | 2 +- |
13 | target/riscv/csr.c | 75 ++++++++++++++++++++++++++++++++++++++++- | 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 2 files changed, 89 insertions(+), 1 deletion(-) | ||
15 | 18 | ||
16 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | 19 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/riscv/cpu_bits.h | 21 | --- a/target/riscv/cpu_bits.h |
19 | +++ b/target/riscv/cpu_bits.h | 22 | +++ b/target/riscv/cpu_bits.h |
20 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ typedef enum RISCVException { |
21 | #define FSR_NXA (FPEXC_NX << FSR_AEXC_SHIFT) | 24 | RISCV_EXCP_INST_PAGE_FAULT = 0xc, /* since: priv-1.10.0 */ |
22 | #define FSR_AEXC (FSR_NVA | FSR_OFA | FSR_UFA | FSR_DZA | FSR_NXA) | 25 | RISCV_EXCP_LOAD_PAGE_FAULT = 0xd, /* since: priv-1.10.0 */ |
23 | 26 | RISCV_EXCP_STORE_PAGE_FAULT = 0xf, /* since: priv-1.10.0 */ | |
24 | +/* Vector Fixed-Point round model */ | 27 | - RISCV_EXCP_SEMIHOST = 0x10, |
25 | +#define FSR_VXRM_SHIFT 9 | 28 | RISCV_EXCP_INST_GUEST_PAGE_FAULT = 0x14, |
26 | +#define FSR_VXRM (0x3 << FSR_VXRM_SHIFT) | 29 | RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT = 0x15, |
27 | + | 30 | RISCV_EXCP_VIRT_INSTRUCTION_FAULT = 0x16, |
28 | +/* Vector Fixed-Point saturation flag */ | 31 | RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT = 0x17, |
29 | +#define FSR_VXSAT_SHIFT 8 | 32 | + RISCV_EXCP_SEMIHOST = 0x3f, |
30 | +#define FSR_VXSAT (0x1 << FSR_VXSAT_SHIFT) | 33 | } RISCVException; |
31 | + | 34 | |
32 | /* Control and Status Registers */ | 35 | #define RISCV_EXCP_INT_FLAG 0x80000000 |
33 | |||
34 | /* User Trap Setup */ | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | #define CSR_FRM 0x002 | ||
37 | #define CSR_FCSR 0x003 | ||
38 | |||
39 | +/* User Vector CSRs */ | ||
40 | +#define CSR_VSTART 0x008 | ||
41 | +#define CSR_VXSAT 0x009 | ||
42 | +#define CSR_VXRM 0x00a | ||
43 | +#define CSR_VL 0xc20 | ||
44 | +#define CSR_VTYPE 0xc21 | ||
45 | + | ||
46 | /* User Timers and Counters */ | ||
47 | #define CSR_CYCLE 0xc00 | ||
48 | #define CSR_TIME 0xc01 | ||
49 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/riscv/csr.c | ||
52 | +++ b/target/riscv/csr.c | ||
53 | @@ -XXX,XX +XXX,XX @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops) | ||
54 | static int fs(CPURISCVState *env, int csrno) | ||
55 | { | ||
56 | #if !defined(CONFIG_USER_ONLY) | ||
57 | + /* loose check condition for fcsr in vector extension */ | ||
58 | + if ((csrno == CSR_FCSR) && (env->misa & RVV)) { | ||
59 | + return 0; | ||
60 | + } | ||
61 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
62 | return -1; | ||
63 | } | ||
64 | @@ -XXX,XX +XXX,XX @@ static int fs(CPURISCVState *env, int csrno) | ||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | +static int vs(CPURISCVState *env, int csrno) | ||
69 | +{ | ||
70 | + if (env->misa & RVV) { | ||
71 | + return 0; | ||
72 | + } | ||
73 | + return -1; | ||
74 | +} | ||
75 | + | ||
76 | static int ctr(CPURISCVState *env, int csrno) | ||
77 | { | ||
78 | #if !defined(CONFIG_USER_ONLY) | ||
79 | @@ -XXX,XX +XXX,XX @@ static int read_fcsr(CPURISCVState *env, int csrno, target_ulong *val) | ||
80 | #endif | ||
81 | *val = (riscv_cpu_get_fflags(env) << FSR_AEXC_SHIFT) | ||
82 | | (env->frm << FSR_RD_SHIFT); | ||
83 | + if (vs(env, csrno) >= 0) { | ||
84 | + *val |= (env->vxrm << FSR_VXRM_SHIFT) | ||
85 | + | (env->vxsat << FSR_VXSAT_SHIFT); | ||
86 | + } | ||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | @@ -XXX,XX +XXX,XX @@ static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) | ||
91 | env->mstatus |= MSTATUS_FS; | ||
92 | #endif | ||
93 | env->frm = (val & FSR_RD) >> FSR_RD_SHIFT; | ||
94 | + if (vs(env, csrno) >= 0) { | ||
95 | + env->vxrm = (val & FSR_VXRM) >> FSR_VXRM_SHIFT; | ||
96 | + env->vxsat = (val & FSR_VXSAT) >> FSR_VXSAT_SHIFT; | ||
97 | + } | ||
98 | riscv_cpu_set_fflags(env, (val & FSR_AEXC) >> FSR_AEXC_SHIFT); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | +static int read_vtype(CPURISCVState *env, int csrno, target_ulong *val) | ||
103 | +{ | ||
104 | + *val = env->vtype; | ||
105 | + return 0; | ||
106 | +} | ||
107 | + | ||
108 | +static int read_vl(CPURISCVState *env, int csrno, target_ulong *val) | ||
109 | +{ | ||
110 | + *val = env->vl; | ||
111 | + return 0; | ||
112 | +} | ||
113 | + | ||
114 | +static int read_vxrm(CPURISCVState *env, int csrno, target_ulong *val) | ||
115 | +{ | ||
116 | + *val = env->vxrm; | ||
117 | + return 0; | ||
118 | +} | ||
119 | + | ||
120 | +static int write_vxrm(CPURISCVState *env, int csrno, target_ulong val) | ||
121 | +{ | ||
122 | + env->vxrm = val; | ||
123 | + return 0; | ||
124 | +} | ||
125 | + | ||
126 | +static int read_vxsat(CPURISCVState *env, int csrno, target_ulong *val) | ||
127 | +{ | ||
128 | + *val = env->vxsat; | ||
129 | + return 0; | ||
130 | +} | ||
131 | + | ||
132 | +static int write_vxsat(CPURISCVState *env, int csrno, target_ulong val) | ||
133 | +{ | ||
134 | + env->vxsat = val; | ||
135 | + return 0; | ||
136 | +} | ||
137 | + | ||
138 | +static int read_vstart(CPURISCVState *env, int csrno, target_ulong *val) | ||
139 | +{ | ||
140 | + *val = env->vstart; | ||
141 | + return 0; | ||
142 | +} | ||
143 | + | ||
144 | +static int write_vstart(CPURISCVState *env, int csrno, target_ulong val) | ||
145 | +{ | ||
146 | + env->vstart = val; | ||
147 | + return 0; | ||
148 | +} | ||
149 | + | ||
150 | /* User Timers and Counters */ | ||
151 | static int read_instret(CPURISCVState *env, int csrno, target_ulong *val) | ||
152 | { | ||
153 | @@ -XXX,XX +XXX,XX @@ static riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { | ||
154 | [CSR_FFLAGS] = { fs, read_fflags, write_fflags }, | ||
155 | [CSR_FRM] = { fs, read_frm, write_frm }, | ||
156 | [CSR_FCSR] = { fs, read_fcsr, write_fcsr }, | ||
157 | - | ||
158 | + /* Vector CSRs */ | ||
159 | + [CSR_VSTART] = { vs, read_vstart, write_vstart }, | ||
160 | + [CSR_VXSAT] = { vs, read_vxsat, write_vxsat }, | ||
161 | + [CSR_VXRM] = { vs, read_vxrm, write_vxrm }, | ||
162 | + [CSR_VL] = { vs, read_vl }, | ||
163 | + [CSR_VTYPE] = { vs, read_vtype }, | ||
164 | /* User Timers and Counters */ | ||
165 | [CSR_CYCLE] = { ctr, read_instret }, | ||
166 | [CSR_INSTRET] = { ctr, read_instret }, | ||
167 | -- | 36 | -- |
168 | 2.27.0 | 37 | 2.45.1 |
169 | 38 | ||
170 | 39 | diff view generated by jsdifflib |
1 | From: Jessica Clarke <jrtc27@jrtc27.com> | 1 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Claiming an interrupt and changing the source priority both potentially | 3 | Running a KVM guest using a 6.9-rc3 kernel, in a 6.8 host that has zkr |
4 | affect whether an interrupt is pending, thus we must re-compute xEIP. | 4 | enabled, will fail with a kernel oops SIGILL right at the start. The |
5 | Note that we don't put the sifive_plic_update inside sifive_plic_claim | 5 | reason is that we can't expose zkr without implementing the SEED CSR. |
6 | so that the logging of a claim (and the resulting IRQ) happens before | 6 | Disabling zkr in the guest would be a workaround, but if the KVM doesn't |
7 | the state update, making the causal effect clear, and that we drop the | 7 | allow it we'll error out and never boot. |
8 | explicit call to sifive_plic_print_state when claiming since | ||
9 | sifive_plic_update already does that automatically at the end for us. | ||
10 | 8 | ||
11 | This can result in both spurious interrupt storms if you fail to | 9 | In hindsight this is too strict. If we keep proceeding, despite not |
12 | complete an IRQ before enabling interrupts (and no other actions occur | 10 | disabling the extension in the KVM vcpu, we'll not add the extension in |
13 | that result in a call to sifive_plic_update), but also more importantly | 11 | the riscv,isa. The guest kernel will be unaware of the extension, i.e. |
14 | lost interrupts if a disabled interrupt is pending and then becomes | 12 | it doesn't matter if the KVM vcpu has it enabled underneath or not. So |
15 | enabled. | 13 | it's ok to keep booting in this case. |
16 | 14 | ||
17 | Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> | 15 | Change our current logic to not error out if we fail to disable an |
18 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 16 | extension in kvm_set_one_reg(), but show a warning and keep booting. It |
19 | Message-id: 20200618210649.22451-1-jrtc27@jrtc27.com | 17 | is important to throw a warning because we must make the user aware that |
20 | Message-Id: <20200618210649.22451-1-jrtc27@jrtc27.com> | 18 | the extension is still available in the vcpu, meaning that an |
19 | ill-behaved guest can ignore the riscv,isa settings and use the | ||
20 | extension. | ||
21 | |||
22 | The case we're handling happens with an EINVAL error code. If we fail to | ||
23 | disable the extension in KVM for any other reason, error out. | ||
24 | |||
25 | We'll also keep erroring out when we fail to enable an extension in KVM, | ||
26 | since adding the extension in riscv,isa at this point will cause a guest | ||
27 | malfunction because the extension isn't enabled in the vcpu. | ||
28 | |||
29 | Suggested-by: Andrew Jones <ajones@ventanamicro.com> | ||
30 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
31 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
32 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
33 | Message-ID: <20240422171425.333037-2-dbarboza@ventanamicro.com> | ||
21 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 34 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
22 | --- | 35 | --- |
23 | hw/riscv/sifive_plic.c | 3 ++- | 36 | target/riscv/kvm/kvm-cpu.c | 12 ++++++++---- |
24 | 1 file changed, 2 insertions(+), 1 deletion(-) | 37 | 1 file changed, 8 insertions(+), 4 deletions(-) |
25 | 38 | ||
26 | diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c | 39 | diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c |
27 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/riscv/sifive_plic.c | 41 | --- a/target/riscv/kvm/kvm-cpu.c |
29 | +++ b/hw/riscv/sifive_plic.c | 42 | +++ b/target/riscv/kvm/kvm-cpu.c |
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t sifive_plic_read(void *opaque, hwaddr addr, unsigned size) | 43 | @@ -XXX,XX +XXX,XX @@ static void kvm_riscv_update_cpu_cfg_isa_ext(RISCVCPU *cpu, CPUState *cs) |
31 | plic->addr_config[addrid].hartid, | 44 | reg = kvm_cpu_cfg_get(cpu, multi_ext_cfg); |
32 | mode_to_char(plic->addr_config[addrid].mode), | 45 | ret = kvm_set_one_reg(cs, id, ®); |
33 | value); | 46 | if (ret != 0) { |
34 | - sifive_plic_print_state(plic); | 47 | - error_report("Unable to %s extension %s in KVM, error %d", |
35 | } | 48 | - reg ? "enable" : "disable", |
36 | + sifive_plic_update(plic); | 49 | - multi_ext_cfg->name, ret); |
37 | return value; | 50 | - exit(EXIT_FAILURE); |
51 | + if (!reg && ret == -EINVAL) { | ||
52 | + warn_report("KVM cannot disable extension %s", | ||
53 | + multi_ext_cfg->name); | ||
54 | + } else { | ||
55 | + error_report("Unable to enable extension %s in KVM, error %d", | ||
56 | + multi_ext_cfg->name, ret); | ||
57 | + exit(EXIT_FAILURE); | ||
58 | + } | ||
38 | } | 59 | } |
39 | } | 60 | } |
40 | @@ -XXX,XX +XXX,XX @@ static void sifive_plic_write(void *opaque, hwaddr addr, uint64_t value, | 61 | } |
41 | qemu_log("plic: write priority: irq=%d priority=%d\n", | ||
42 | irq, plic->source_priority[irq]); | ||
43 | } | ||
44 | + sifive_plic_update(plic); | ||
45 | return; | ||
46 | } else if (addr >= plic->pending_base && /* 1 bit per source */ | ||
47 | addr < plic->pending_base + (plic->num_sources >> 3)) | ||
48 | -- | 62 | -- |
49 | 2.27.0 | 63 | 2.45.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | We're not setting (s/m)tval when triggering breakpoints of type 2 |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | (mcontrol) and 6 (mcontrol6). According to the debug spec section |
5 | Message-id: 20200623215920.2594-59-zhiwei_liu@c-sky.com | 5 | 5.7.12, "Match Control Type 6": |
6 | |||
7 | "The Privileged Spec says that breakpoint exceptions that occur on | ||
8 | instruction fetches, loads, or stores update the tval CSR with either | ||
9 | zero or the faulting virtual address. The faulting virtual address for | ||
10 | an mcontrol6 trigger with action = 0 is the address being accessed and | ||
11 | which caused that trigger to fire." | ||
12 | |||
13 | A similar text is also found in the Debug spec section 5.7.11 w.r.t. | ||
14 | mcontrol. | ||
15 | |||
16 | Note that what we're doing ATM is not violating the spec, but it's | ||
17 | simple enough to set mtval/stval and it makes life easier for any | ||
18 | software that relies on this info. | ||
19 | |||
20 | Given that we always use action = 0, save the faulting address for the | ||
21 | mcontrol and mcontrol6 trigger breakpoints into env->badaddr, which is | ||
22 | used as as scratch area for traps with address information. 'tval' is | ||
23 | then set during riscv_cpu_do_interrupt(). | ||
24 | |||
25 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
26 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
27 | Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> | ||
28 | Message-ID: <20240416230437.1869024-2-dbarboza@ventanamicro.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 29 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 30 | --- |
8 | target/riscv/helper.h | 17 ++++ | 31 | target/riscv/cpu_helper.c | 1 + |
9 | target/riscv/insn32.decode | 6 ++ | 32 | target/riscv/debug.c | 3 +++ |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 18 ++++ | 33 | 2 files changed, 4 insertions(+) |
11 | target/riscv/vector_helper.c | 114 ++++++++++++++++++++++++ | ||
12 | 4 files changed, 155 insertions(+) | ||
13 | 34 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 35 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 37 | --- a/target/riscv/cpu_helper.c |
17 | +++ b/target/riscv/helper.h | 38 | +++ b/target/riscv/cpu_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vid_v_b, void, ptr, ptr, env, i32) | 39 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs) |
19 | DEF_HELPER_4(vid_v_h, void, ptr, ptr, env, i32) | 40 | tval = env->bins; |
20 | DEF_HELPER_4(vid_v_w, void, ptr, ptr, env, i32) | 41 | break; |
21 | DEF_HELPER_4(vid_v_d, void, ptr, ptr, env, i32) | 42 | case RISCV_EXCP_BREAKPOINT: |
22 | + | 43 | + tval = env->badaddr; |
23 | +DEF_HELPER_6(vslideup_vx_b, void, ptr, ptr, tl, ptr, env, i32) | 44 | if (cs->watchpoint_hit) { |
24 | +DEF_HELPER_6(vslideup_vx_h, void, ptr, ptr, tl, ptr, env, i32) | 45 | tval = cs->watchpoint_hit->hitaddr; |
25 | +DEF_HELPER_6(vslideup_vx_w, void, ptr, ptr, tl, ptr, env, i32) | 46 | cs->watchpoint_hit = NULL; |
26 | +DEF_HELPER_6(vslideup_vx_d, void, ptr, ptr, tl, ptr, env, i32) | 47 | diff --git a/target/riscv/debug.c b/target/riscv/debug.c |
27 | +DEF_HELPER_6(vslidedown_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vslidedown_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vslidedown_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vslidedown_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vslide1up_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vslide1up_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vslide1up_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vslide1up_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vslide1down_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vslide1down_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vslide1down_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vslide1down_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
40 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/riscv/insn32.decode | 49 | --- a/target/riscv/debug.c |
42 | +++ b/target/riscv/insn32.decode | 50 | +++ b/target/riscv/debug.c |
43 | @@ -XXX,XX +XXX,XX @@ vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r | 51 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs) |
44 | vmv_s_x 001101 1 00000 ..... 110 ..... 1010111 @r2 | 52 | if ((ctrl & TYPE2_EXEC) && (bp->pc == pc)) { |
45 | vfmv_f_s 001100 1 ..... 00000 001 ..... 1010111 @r2rd | 53 | /* check U/S/M bit against current privilege level */ |
46 | vfmv_s_f 001101 1 00000 ..... 101 ..... 1010111 @r2 | 54 | if ((ctrl >> 3) & BIT(env->priv)) { |
47 | +vslideup_vx 001110 . ..... ..... 100 ..... 1010111 @r_vm | 55 | + env->badaddr = pc; |
48 | +vslideup_vi 001110 . ..... ..... 011 ..... 1010111 @r_vm | 56 | return true; |
49 | +vslide1up_vx 001110 . ..... ..... 110 ..... 1010111 @r_vm | 57 | } |
50 | +vslidedown_vx 001111 . ..... ..... 100 ..... 1010111 @r_vm | 58 | } |
51 | +vslidedown_vi 001111 . ..... ..... 011 ..... 1010111 @r_vm | 59 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs) |
52 | +vslide1down_vx 001111 . ..... ..... 110 ..... 1010111 @r_vm | 60 | if (env->virt_enabled) { |
53 | 61 | /* check VU/VS bit against current privilege level */ | |
54 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 62 | if ((ctrl >> 23) & BIT(env->priv)) { |
55 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 63 | + env->badaddr = pc; |
56 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 64 | return true; |
57 | index XXXXXXX..XXXXXXX 100644 | 65 | } |
58 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 66 | } else { |
59 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 67 | /* check U/S/M bit against current privilege level */ |
60 | @@ -XXX,XX +XXX,XX @@ static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a) | 68 | if ((ctrl >> 3) & BIT(env->priv)) { |
61 | } | 69 | + env->badaddr = pc; |
62 | return false; | 70 | return true; |
63 | } | 71 | } |
64 | + | 72 | } |
65 | +/* Vector Slide Instructions */ | ||
66 | +static bool slideup_check(DisasContext *s, arg_rmrr *a) | ||
67 | +{ | ||
68 | + return (vext_check_isa_ill(s) && | ||
69 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
70 | + vext_check_reg(s, a->rd, false) && | ||
71 | + vext_check_reg(s, a->rs2, false) && | ||
72 | + (a->rd != a->rs2)); | ||
73 | +} | ||
74 | + | ||
75 | +GEN_OPIVX_TRANS(vslideup_vx, slideup_check) | ||
76 | +GEN_OPIVX_TRANS(vslide1up_vx, slideup_check) | ||
77 | +GEN_OPIVI_TRANS(vslideup_vi, 1, vslideup_vx, slideup_check) | ||
78 | + | ||
79 | +GEN_OPIVX_TRANS(vslidedown_vx, opivx_check) | ||
80 | +GEN_OPIVX_TRANS(vslide1down_vx, opivx_check) | ||
81 | +GEN_OPIVI_TRANS(vslidedown_vi, 1, vslidedown_vx, opivx_check) | ||
82 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/target/riscv/vector_helper.c | ||
85 | +++ b/target/riscv/vector_helper.c | ||
86 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VID_V(vid_v_b, uint8_t, H1, clearb) | ||
87 | GEN_VEXT_VID_V(vid_v_h, uint16_t, H2, clearh) | ||
88 | GEN_VEXT_VID_V(vid_v_w, uint32_t, H4, clearl) | ||
89 | GEN_VEXT_VID_V(vid_v_d, uint64_t, H8, clearq) | ||
90 | + | ||
91 | +/* | ||
92 | + *** Vector Permutation Instructions | ||
93 | + */ | ||
94 | + | ||
95 | +/* Vector Slide Instructions */ | ||
96 | +#define GEN_VEXT_VSLIDEUP_VX(NAME, ETYPE, H, CLEAR_FN) \ | ||
97 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
98 | + CPURISCVState *env, uint32_t desc) \ | ||
99 | +{ \ | ||
100 | + uint32_t mlen = vext_mlen(desc); \ | ||
101 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
102 | + uint32_t vm = vext_vm(desc); \ | ||
103 | + uint32_t vl = env->vl; \ | ||
104 | + target_ulong offset = s1, i; \ | ||
105 | + \ | ||
106 | + for (i = offset; i < vl; i++) { \ | ||
107 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
108 | + continue; \ | ||
109 | + } \ | ||
110 | + *((ETYPE *)vd + H(i)) = *((ETYPE *)vs2 + H(i - offset)); \ | ||
111 | + } \ | ||
112 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
113 | +} | ||
114 | + | ||
115 | +/* vslideup.vx vd, vs2, rs1, vm # vd[i+rs1] = vs2[i] */ | ||
116 | +GEN_VEXT_VSLIDEUP_VX(vslideup_vx_b, uint8_t, H1, clearb) | ||
117 | +GEN_VEXT_VSLIDEUP_VX(vslideup_vx_h, uint16_t, H2, clearh) | ||
118 | +GEN_VEXT_VSLIDEUP_VX(vslideup_vx_w, uint32_t, H4, clearl) | ||
119 | +GEN_VEXT_VSLIDEUP_VX(vslideup_vx_d, uint64_t, H8, clearq) | ||
120 | + | ||
121 | +#define GEN_VEXT_VSLIDEDOWN_VX(NAME, ETYPE, H, CLEAR_FN) \ | ||
122 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
123 | + CPURISCVState *env, uint32_t desc) \ | ||
124 | +{ \ | ||
125 | + uint32_t mlen = vext_mlen(desc); \ | ||
126 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
127 | + uint32_t vm = vext_vm(desc); \ | ||
128 | + uint32_t vl = env->vl; \ | ||
129 | + target_ulong offset = s1, i; \ | ||
130 | + \ | ||
131 | + for (i = 0; i < vl; ++i) { \ | ||
132 | + target_ulong j = i + offset; \ | ||
133 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
134 | + continue; \ | ||
135 | + } \ | ||
136 | + *((ETYPE *)vd + H(i)) = j >= vlmax ? 0 : *((ETYPE *)vs2 + H(j)); \ | ||
137 | + } \ | ||
138 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
139 | +} | ||
140 | + | ||
141 | +/* vslidedown.vx vd, vs2, rs1, vm # vd[i] = vs2[i+rs1] */ | ||
142 | +GEN_VEXT_VSLIDEDOWN_VX(vslidedown_vx_b, uint8_t, H1, clearb) | ||
143 | +GEN_VEXT_VSLIDEDOWN_VX(vslidedown_vx_h, uint16_t, H2, clearh) | ||
144 | +GEN_VEXT_VSLIDEDOWN_VX(vslidedown_vx_w, uint32_t, H4, clearl) | ||
145 | +GEN_VEXT_VSLIDEDOWN_VX(vslidedown_vx_d, uint64_t, H8, clearq) | ||
146 | + | ||
147 | +#define GEN_VEXT_VSLIDE1UP_VX(NAME, ETYPE, H, CLEAR_FN) \ | ||
148 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
149 | + CPURISCVState *env, uint32_t desc) \ | ||
150 | +{ \ | ||
151 | + uint32_t mlen = vext_mlen(desc); \ | ||
152 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
153 | + uint32_t vm = vext_vm(desc); \ | ||
154 | + uint32_t vl = env->vl; \ | ||
155 | + uint32_t i; \ | ||
156 | + \ | ||
157 | + for (i = 0; i < vl; i++) { \ | ||
158 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
159 | + continue; \ | ||
160 | + } \ | ||
161 | + if (i == 0) { \ | ||
162 | + *((ETYPE *)vd + H(i)) = s1; \ | ||
163 | + } else { \ | ||
164 | + *((ETYPE *)vd + H(i)) = *((ETYPE *)vs2 + H(i - 1)); \ | ||
165 | + } \ | ||
166 | + } \ | ||
167 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
168 | +} | ||
169 | + | ||
170 | +/* vslide1up.vx vd, vs2, rs1, vm # vd[0]=x[rs1], vd[i+1] = vs2[i] */ | ||
171 | +GEN_VEXT_VSLIDE1UP_VX(vslide1up_vx_b, uint8_t, H1, clearb) | ||
172 | +GEN_VEXT_VSLIDE1UP_VX(vslide1up_vx_h, uint16_t, H2, clearh) | ||
173 | +GEN_VEXT_VSLIDE1UP_VX(vslide1up_vx_w, uint32_t, H4, clearl) | ||
174 | +GEN_VEXT_VSLIDE1UP_VX(vslide1up_vx_d, uint64_t, H8, clearq) | ||
175 | + | ||
176 | +#define GEN_VEXT_VSLIDE1DOWN_VX(NAME, ETYPE, H, CLEAR_FN) \ | ||
177 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
178 | + CPURISCVState *env, uint32_t desc) \ | ||
179 | +{ \ | ||
180 | + uint32_t mlen = vext_mlen(desc); \ | ||
181 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
182 | + uint32_t vm = vext_vm(desc); \ | ||
183 | + uint32_t vl = env->vl; \ | ||
184 | + uint32_t i; \ | ||
185 | + \ | ||
186 | + for (i = 0; i < vl; i++) { \ | ||
187 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
188 | + continue; \ | ||
189 | + } \ | ||
190 | + if (i == vl - 1) { \ | ||
191 | + *((ETYPE *)vd + H(i)) = s1; \ | ||
192 | + } else { \ | ||
193 | + *((ETYPE *)vd + H(i)) = *((ETYPE *)vs2 + H(i + 1)); \ | ||
194 | + } \ | ||
195 | + } \ | ||
196 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
197 | +} | ||
198 | + | ||
199 | +/* vslide1down.vx vd, vs2, rs1, vm # vd[i] = vs2[i+1], vd[vl-1]=x[rs1] */ | ||
200 | +GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_b, uint8_t, H1, clearb) | ||
201 | +GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_h, uint16_t, H2, clearh) | ||
202 | +GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_w, uint32_t, H4, clearl) | ||
203 | +GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_d, uint64_t, H8, clearq) | ||
204 | -- | 73 | -- |
205 | 2.27.0 | 74 | 2.45.1 |
206 | |||
207 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Privileged spec section 4.1.9 mentions: |
4 | |||
5 | "When a trap is taken into S-mode, stval is written with | ||
6 | exception-specific information to assist software in handling the trap. | ||
7 | (...) | ||
8 | |||
9 | If stval is written with a nonzero value when a breakpoint, | ||
10 | address-misaligned, access-fault, or page-fault exception occurs on an | ||
11 | instruction fetch, load, or store, then stval will contain the faulting | ||
12 | virtual address." | ||
13 | |||
14 | A similar text is found for mtval in section 3.1.16. | ||
15 | |||
16 | Setting mtval/stval in this scenario is optional, but some softwares read | ||
17 | these regs when handling ebreaks. | ||
18 | |||
19 | Write 'badaddr' in all ebreak breakpoints to write the appropriate | ||
20 | 'tval' during riscv_do_cpu_interrrupt(). | ||
21 | |||
22 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
23 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
24 | Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20200623215920.2594-61-zhiwei_liu@c-sky.com | 26 | Message-ID: <20240416230437.1869024-3-dbarboza@ventanamicro.com> |
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 27 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 28 | --- |
8 | target/riscv/helper.h | 5 ++++ | 29 | target/riscv/insn_trans/trans_privileged.c.inc | 2 ++ |
9 | target/riscv/insn32.decode | 1 + | 30 | 1 file changed, 2 insertions(+) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 26 ++++++++++++++++++++ | ||
12 | 4 files changed, 64 insertions(+) | ||
13 | 31 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 32 | diff --git a/target/riscv/insn_trans/trans_privileged.c.inc b/target/riscv/insn_trans/trans_privileged.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 34 | --- a/target/riscv/insn_trans/trans_privileged.c.inc |
17 | +++ b/target/riscv/helper.h | 35 | +++ b/target/riscv/insn_trans/trans_privileged.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vrgather_vx_b, void, ptr, ptr, tl, ptr, env, i32) | 36 | @@ -XXX,XX +XXX,XX @@ static bool trans_ebreak(DisasContext *ctx, arg_ebreak *a) |
19 | DEF_HELPER_6(vrgather_vx_h, void, ptr, ptr, tl, ptr, env, i32) | 37 | if (pre == 0x01f01013 && ebreak == 0x00100073 && post == 0x40705013) { |
20 | DEF_HELPER_6(vrgather_vx_w, void, ptr, ptr, tl, ptr, env, i32) | 38 | generate_exception(ctx, RISCV_EXCP_SEMIHOST); |
21 | DEF_HELPER_6(vrgather_vx_d, void, ptr, ptr, tl, ptr, env, i32) | 39 | } else { |
22 | + | 40 | + tcg_gen_st_tl(tcg_constant_tl(ebreak_addr), tcg_env, |
23 | +DEF_HELPER_6(vcompress_vm_b, void, ptr, ptr, ptr, ptr, env, i32) | 41 | + offsetof(CPURISCVState, badaddr)); |
24 | +DEF_HELPER_6(vcompress_vm_h, void, ptr, ptr, ptr, ptr, env, i32) | 42 | generate_exception(ctx, RISCV_EXCP_BREAKPOINT); |
25 | +DEF_HELPER_6(vcompress_vm_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vcompress_vm_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/riscv/insn32.decode | ||
30 | +++ b/target/riscv/insn32.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ vslide1down_vx 001111 . ..... ..... 110 ..... 1010111 @r_vm | ||
32 | vrgather_vv 001100 . ..... ..... 000 ..... 1010111 @r_vm | ||
33 | vrgather_vx 001100 . ..... ..... 100 ..... 1010111 @r_vm | ||
34 | vrgather_vi 001100 . ..... ..... 011 ..... 1010111 @r_vm | ||
35 | +vcompress_vm 010111 - ..... ..... 010 ..... 1010111 @r | ||
36 | |||
37 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
38 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
39 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
42 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a) | ||
44 | } | 43 | } |
45 | return true; | 44 | return true; |
46 | } | ||
47 | + | ||
48 | +/* Vector Compress Instruction */ | ||
49 | +static bool vcompress_vm_check(DisasContext *s, arg_r *a) | ||
50 | +{ | ||
51 | + return (vext_check_isa_ill(s) && | ||
52 | + vext_check_reg(s, a->rd, false) && | ||
53 | + vext_check_reg(s, a->rs2, false) && | ||
54 | + vext_check_overlap_group(a->rd, 1 << s->lmul, a->rs1, 1) && | ||
55 | + (a->rd != a->rs2)); | ||
56 | +} | ||
57 | + | ||
58 | +static bool trans_vcompress_vm(DisasContext *s, arg_r *a) | ||
59 | +{ | ||
60 | + if (vcompress_vm_check(s, a)) { | ||
61 | + uint32_t data = 0; | ||
62 | + static gen_helper_gvec_4_ptr * const fns[4] = { | ||
63 | + gen_helper_vcompress_vm_b, gen_helper_vcompress_vm_h, | ||
64 | + gen_helper_vcompress_vm_w, gen_helper_vcompress_vm_d, | ||
65 | + }; | ||
66 | + TCGLabel *over = gen_new_label(); | ||
67 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
68 | + | ||
69 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
70 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
71 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), | ||
72 | + vreg_ofs(s, a->rs1), vreg_ofs(s, a->rs2), | ||
73 | + cpu_env, 0, s->vlen / 8, data, fns[s->sew]); | ||
74 | + gen_set_label(over); | ||
75 | + return true; | ||
76 | + } | ||
77 | + return false; | ||
78 | +} | ||
79 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/riscv/vector_helper.c | ||
82 | +++ b/target/riscv/vector_helper.c | ||
83 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VRGATHER_VX(vrgather_vx_b, uint8_t, H1, clearb) | ||
84 | GEN_VEXT_VRGATHER_VX(vrgather_vx_h, uint16_t, H2, clearh) | ||
85 | GEN_VEXT_VRGATHER_VX(vrgather_vx_w, uint32_t, H4, clearl) | ||
86 | GEN_VEXT_VRGATHER_VX(vrgather_vx_d, uint64_t, H8, clearq) | ||
87 | + | ||
88 | +/* Vector Compress Instruction */ | ||
89 | +#define GEN_VEXT_VCOMPRESS_VM(NAME, ETYPE, H, CLEAR_FN) \ | ||
90 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
91 | + CPURISCVState *env, uint32_t desc) \ | ||
92 | +{ \ | ||
93 | + uint32_t mlen = vext_mlen(desc); \ | ||
94 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
95 | + uint32_t vl = env->vl; \ | ||
96 | + uint32_t num = 0, i; \ | ||
97 | + \ | ||
98 | + for (i = 0; i < vl; i++) { \ | ||
99 | + if (!vext_elem_mask(vs1, mlen, i)) { \ | ||
100 | + continue; \ | ||
101 | + } \ | ||
102 | + *((ETYPE *)vd + H(num)) = *((ETYPE *)vs2 + H(i)); \ | ||
103 | + num++; \ | ||
104 | + } \ | ||
105 | + CLEAR_FN(vd, num, num * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
106 | +} | ||
107 | + | ||
108 | +/* Compress into vd elements of vs2 where vs1 is enabled */ | ||
109 | +GEN_VEXT_VCOMPRESS_VM(vcompress_vm_b, uint8_t, H1, clearb) | ||
110 | +GEN_VEXT_VCOMPRESS_VM(vcompress_vm_h, uint16_t, H2, clearh) | ||
111 | +GEN_VEXT_VCOMPRESS_VM(vcompress_vm_w, uint32_t, H4, clearl) | ||
112 | +GEN_VEXT_VCOMPRESS_VM(vcompress_vm_d, uint64_t, H8, clearq) | ||
113 | -- | 45 | -- |
114 | 2.27.0 | 46 | 2.45.1 |
115 | |||
116 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Jason Chien <jason.chien@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Add support for Zve32x extension and replace some checks for Zve32f with |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Zve32x, since Zve32f depends on Zve32x. |
5 | Message-id: 20200623215920.2594-58-zhiwei_liu@c-sky.com | 5 | |
6 | Signed-off-by: Jason Chien <jason.chien@sifive.com> | ||
7 | Reviewed-by: Frank Chang <frank.chang@sifive.com> | ||
8 | Reviewed-by: Max Chou <max.chou@sifive.com> | ||
9 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
10 | Message-ID: <20240328022343.6871-2-jason.chien@sifive.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 12 | --- |
8 | target/riscv/insn32.decode | 3 ++ | 13 | target/riscv/cpu_cfg.h | 1 + |
9 | target/riscv/insn_trans/trans_rvv.inc.c | 49 +++++++++++++++++++++++++ | 14 | target/riscv/cpu.c | 2 ++ |
10 | 2 files changed, 52 insertions(+) | 15 | target/riscv/cpu_helper.c | 2 +- |
16 | target/riscv/csr.c | 2 +- | ||
17 | target/riscv/tcg/tcg-cpu.c | 16 ++++++++-------- | ||
18 | target/riscv/insn_trans/trans_rvv.c.inc | 4 ++-- | ||
19 | 6 files changed, 15 insertions(+), 12 deletions(-) | ||
11 | 20 | ||
12 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 21 | diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h |
13 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/riscv/insn32.decode | 23 | --- a/target/riscv/cpu_cfg.h |
15 | +++ b/target/riscv/insn32.decode | 24 | +++ b/target/riscv/cpu_cfg.h |
16 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig { |
17 | @r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd | 26 | bool ext_zhinx; |
18 | @r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd | 27 | bool ext_zhinxmin; |
19 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | 28 | bool ext_zve32f; |
20 | +@r2rd ....... ..... ..... ... ..... ....... %rs2 %rd | 29 | + bool ext_zve32x; |
21 | @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | 30 | bool ext_zve64f; |
22 | @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd | 31 | bool ext_zve64d; |
23 | @r_vm_0 ...... . ..... ..... ... ..... ....... &rmrr vm=0 %rs2 %rs1 %rd | 32 | bool ext_zvbb; |
24 | @@ -XXX,XX +XXX,XX @@ viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | 33 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
25 | vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm | ||
26 | vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r | ||
27 | vmv_s_x 001101 1 00000 ..... 110 ..... 1010111 @r2 | ||
28 | +vfmv_f_s 001100 1 ..... 00000 001 ..... 1010111 @r2rd | ||
29 | +vfmv_s_f 001101 1 00000 ..... 101 ..... 1010111 @r2 | ||
30 | |||
31 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
32 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
33 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 35 | --- a/target/riscv/cpu.c |
36 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 36 | +++ b/target/riscv/cpu.c |
37 | @@ -XXX,XX +XXX,XX @@ static bool trans_vmv_s_x(DisasContext *s, arg_vmv_s_x *a) | 37 | @@ -XXX,XX +XXX,XX @@ const RISCVIsaExtData isa_edata_arr[] = { |
38 | ISA_EXT_DATA_ENTRY(zvbb, PRIV_VERSION_1_12_0, ext_zvbb), | ||
39 | ISA_EXT_DATA_ENTRY(zvbc, PRIV_VERSION_1_12_0, ext_zvbc), | ||
40 | ISA_EXT_DATA_ENTRY(zve32f, PRIV_VERSION_1_10_0, ext_zve32f), | ||
41 | + ISA_EXT_DATA_ENTRY(zve32x, PRIV_VERSION_1_10_0, ext_zve32x), | ||
42 | ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f), | ||
43 | ISA_EXT_DATA_ENTRY(zve64d, PRIV_VERSION_1_10_0, ext_zve64d), | ||
44 | ISA_EXT_DATA_ENTRY(zvfbfmin, PRIV_VERSION_1_12_0, ext_zvfbfmin), | ||
45 | @@ -XXX,XX +XXX,XX @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { | ||
46 | MULTI_EXT_CFG_BOOL("zfh", ext_zfh, false), | ||
47 | MULTI_EXT_CFG_BOOL("zfhmin", ext_zfhmin, false), | ||
48 | MULTI_EXT_CFG_BOOL("zve32f", ext_zve32f, false), | ||
49 | + MULTI_EXT_CFG_BOOL("zve32x", ext_zve32x, false), | ||
50 | MULTI_EXT_CFG_BOOL("zve64f", ext_zve64f, false), | ||
51 | MULTI_EXT_CFG_BOOL("zve64d", ext_zve64d, false), | ||
52 | MULTI_EXT_CFG_BOOL("zvfbfmin", ext_zvfbfmin, false), | ||
53 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/riscv/cpu_helper.c | ||
56 | +++ b/target/riscv/cpu_helper.c | ||
57 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, | ||
58 | *pc = env->xl == MXL_RV32 ? env->pc & UINT32_MAX : env->pc; | ||
59 | *cs_base = 0; | ||
60 | |||
61 | - if (cpu->cfg.ext_zve32f) { | ||
62 | + if (cpu->cfg.ext_zve32x) { | ||
63 | /* | ||
64 | * If env->vl equals to VLMAX, we can use generic vector operation | ||
65 | * expanders (GVEC) to accerlate the vector operations. | ||
66 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/riscv/csr.c | ||
69 | +++ b/target/riscv/csr.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static RISCVException fs(CPURISCVState *env, int csrno) | ||
71 | |||
72 | static RISCVException vs(CPURISCVState *env, int csrno) | ||
73 | { | ||
74 | - if (riscv_cpu_cfg(env)->ext_zve32f) { | ||
75 | + if (riscv_cpu_cfg(env)->ext_zve32x) { | ||
76 | #if !defined(CONFIG_USER_ONLY) | ||
77 | if (!env->debugger && !riscv_cpu_vector_enabled(env)) { | ||
78 | return RISCV_EXCP_ILLEGAL_INST; | ||
79 | diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/riscv/tcg/tcg-cpu.c | ||
82 | +++ b/target/riscv/tcg/tcg-cpu.c | ||
83 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) | ||
84 | return; | ||
38 | } | 85 | } |
39 | return false; | 86 | |
40 | } | 87 | - if (cpu->cfg.ext_zve32f && !riscv_has_ext(env, RVF)) { |
41 | + | 88 | - error_setg(errp, "Zve32f/Zve64f extensions require F extension"); |
42 | +/* Floating-Point Scalar Move Instructions */ | 89 | - return; |
43 | +static bool trans_vfmv_f_s(DisasContext *s, arg_vfmv_f_s *a) | 90 | + /* The Zve32f extension depends on the Zve32x extension */ |
44 | +{ | 91 | + if (cpu->cfg.ext_zve32f) { |
45 | + if (!s->vill && has_ext(s, RVF) && | 92 | + if (!riscv_has_ext(env, RVF)) { |
46 | + (s->mstatus_fs != 0) && (s->sew != 0)) { | 93 | + error_setg(errp, "Zve32f/Zve64f extensions require F extension"); |
47 | + unsigned int len = 8 << s->sew; | 94 | + return; |
48 | + | ||
49 | + vec_element_loadi(s, cpu_fpr[a->rd], a->rs2, 0); | ||
50 | + if (len < 64) { | ||
51 | + tcg_gen_ori_i64(cpu_fpr[a->rd], cpu_fpr[a->rd], | ||
52 | + MAKE_64BIT_MASK(len, 64 - len)); | ||
53 | + } | 95 | + } |
54 | + | 96 | + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32x), true); |
55 | + mark_fs_dirty(s); | 97 | } |
56 | + return true; | 98 | |
57 | + } | 99 | if (cpu->cfg.ext_zvfh) { |
58 | + return false; | 100 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) |
59 | +} | 101 | cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); |
60 | + | 102 | } |
61 | +/* vfmv.s.f vd, rs1 # vd[0] = rs1 (vs2=0) */ | 103 | |
62 | +static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a) | 104 | - /* |
63 | +{ | 105 | - * In principle Zve*x would also suffice here, were they supported |
64 | + if (!s->vill && has_ext(s, RVF) && (s->sew != 0)) { | 106 | - * in qemu |
65 | + TCGv_i64 t1; | 107 | - */ |
66 | + /* The instructions ignore LMUL and vector register group. */ | 108 | if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkb || cpu->cfg.ext_zvkg || |
67 | + uint32_t vlmax = s->vlen >> 3; | 109 | cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksed || |
68 | + | 110 | - cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { |
69 | + /* if vl == 0, skip vector register write back */ | 111 | + cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32x) { |
70 | + TCGLabel *over = gen_new_label(); | 112 | error_setg(errp, |
71 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | 113 | "Vector crypto extensions require V or Zve* extensions"); |
72 | + | 114 | return; |
73 | + /* zeroed all elements */ | 115 | diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc |
74 | + tcg_gen_gvec_dup_imm(SEW64, vreg_ofs(s, a->rd), vlmax, vlmax, 0); | 116 | index XXXXXXX..XXXXXXX 100644 |
75 | + | 117 | --- a/target/riscv/insn_trans/trans_rvv.c.inc |
76 | + /* NaN-box f[rs1] as necessary for SEW */ | 118 | +++ b/target/riscv/insn_trans/trans_rvv.c.inc |
77 | + t1 = tcg_temp_new_i64(); | 119 | @@ -XXX,XX +XXX,XX @@ static bool do_vsetvl(DisasContext *s, int rd, int rs1, TCGv s2) |
78 | + if (s->sew == MO_64 && !has_ext(s, RVD)) { | 120 | { |
79 | + tcg_gen_ori_i64(t1, cpu_fpr[a->rs1], MAKE_64BIT_MASK(32, 32)); | 121 | TCGv s1, dst; |
80 | + } else { | 122 | |
81 | + tcg_gen_mov_i64(t1, cpu_fpr[a->rs1]); | 123 | - if (!require_rvv(s) || !s->cfg_ptr->ext_zve32f) { |
82 | + } | 124 | + if (!require_rvv(s) || !s->cfg_ptr->ext_zve32x) { |
83 | + vec_element_storei(s, a->rd, 0, t1); | 125 | return false; |
84 | + tcg_temp_free_i64(t1); | 126 | } |
85 | + gen_set_label(over); | 127 | |
86 | + return true; | 128 | @@ -XXX,XX +XXX,XX @@ static bool do_vsetivli(DisasContext *s, int rd, TCGv s1, TCGv s2) |
87 | + } | 129 | { |
88 | + return false; | 130 | TCGv dst; |
89 | +} | 131 | |
132 | - if (!require_rvv(s) || !s->cfg_ptr->ext_zve32f) { | ||
133 | + if (!require_rvv(s) || !s->cfg_ptr->ext_zve32x) { | ||
134 | return false; | ||
135 | } | ||
136 | |||
90 | -- | 137 | -- |
91 | 2.27.0 | 138 | 2.45.1 |
92 | |||
93 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Jason Chien <jason.chien@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | vlen is the vector register length in bits. | 3 | Add support for Zve64x extension. Enabling Zve64f enables Zve64x and |
4 | elen is the max element size in bits. | 4 | enabling Zve64x enables Zve32x according to their dependency. |
5 | vext_spec is the vector specification version, default value is v0.7.1. | ||
6 | 5 | ||
7 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 6 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2107 |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Signed-off-by: Jason Chien <jason.chien@sifive.com> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Frank Chang <frank.chang@sifive.com> |
10 | Message-id: 20200623215920.2594-3-zhiwei_liu@c-sky.com | 9 | Reviewed-by: Max Chou <max.chou@sifive.com> |
10 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
11 | Message-ID: <20240328022343.6871-3-jason.chien@sifive.com> | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
12 | --- | 13 | --- |
13 | target/riscv/cpu.h | 5 +++++ | 14 | target/riscv/cpu_cfg.h | 1 + |
14 | target/riscv/cpu.c | 7 +++++++ | 15 | target/riscv/cpu.c | 2 ++ |
15 | 2 files changed, 12 insertions(+) | 16 | target/riscv/tcg/tcg-cpu.c | 17 +++++++++++------ |
17 | 3 files changed, 14 insertions(+), 6 deletions(-) | ||
16 | 18 | ||
17 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | 19 | diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h |
18 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/riscv/cpu.h | 21 | --- a/target/riscv/cpu_cfg.h |
20 | +++ b/target/riscv/cpu.h | 22 | +++ b/target/riscv/cpu_cfg.h |
21 | @@ -XXX,XX +XXX,XX @@ enum { | 23 | @@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig { |
22 | #define PRIV_VERSION_1_10_0 0x00011000 | 24 | bool ext_zve32x; |
23 | #define PRIV_VERSION_1_11_0 0x00011100 | 25 | bool ext_zve64f; |
24 | 26 | bool ext_zve64d; | |
25 | +#define VEXT_VERSION_0_07_1 0x00000701 | 27 | + bool ext_zve64x; |
26 | + | 28 | bool ext_zvbb; |
27 | #define TRANSLATE_PMP_FAIL 2 | 29 | bool ext_zvbc; |
28 | #define TRANSLATE_FAIL 1 | 30 | bool ext_zvkb; |
29 | #define TRANSLATE_SUCCESS 0 | ||
30 | @@ -XXX,XX +XXX,XX @@ struct CPURISCVState { | ||
31 | target_ulong guest_phys_fault_addr; | ||
32 | |||
33 | target_ulong priv_ver; | ||
34 | + target_ulong vext_ver; | ||
35 | target_ulong misa; | ||
36 | target_ulong misa_mask; | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ typedef struct RISCVCPU { | ||
39 | |||
40 | char *priv_spec; | ||
41 | char *user_spec; | ||
42 | + uint16_t vlen; | ||
43 | + uint16_t elen; | ||
44 | bool mmu; | ||
45 | bool pmp; | ||
46 | } cfg; | ||
47 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | 31 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
48 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/target/riscv/cpu.c | 33 | --- a/target/riscv/cpu.c |
50 | +++ b/target/riscv/cpu.c | 34 | +++ b/target/riscv/cpu.c |
51 | @@ -XXX,XX +XXX,XX @@ static void set_priv_version(CPURISCVState *env, int priv_ver) | 35 | @@ -XXX,XX +XXX,XX @@ const RISCVIsaExtData isa_edata_arr[] = { |
52 | env->priv_ver = priv_ver; | 36 | ISA_EXT_DATA_ENTRY(zve32x, PRIV_VERSION_1_10_0, ext_zve32x), |
53 | } | 37 | ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f), |
54 | 38 | ISA_EXT_DATA_ENTRY(zve64d, PRIV_VERSION_1_10_0, ext_zve64d), | |
55 | +static void set_vext_version(CPURISCVState *env, int vext_ver) | 39 | + ISA_EXT_DATA_ENTRY(zve64x, PRIV_VERSION_1_10_0, ext_zve64x), |
56 | +{ | 40 | ISA_EXT_DATA_ENTRY(zvfbfmin, PRIV_VERSION_1_12_0, ext_zvfbfmin), |
57 | + env->vext_ver = vext_ver; | 41 | ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma), |
58 | +} | 42 | ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh), |
59 | + | 43 | @@ -XXX,XX +XXX,XX @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { |
60 | static void set_feature(CPURISCVState *env, int feature) | 44 | MULTI_EXT_CFG_BOOL("zve32x", ext_zve32x, false), |
61 | { | 45 | MULTI_EXT_CFG_BOOL("zve64f", ext_zve64f, false), |
62 | env->features |= (1ULL << feature); | 46 | MULTI_EXT_CFG_BOOL("zve64d", ext_zve64d, false), |
63 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) | 47 | + MULTI_EXT_CFG_BOOL("zve64x", ext_zve64x, false), |
64 | CPURISCVState *env = &cpu->env; | 48 | MULTI_EXT_CFG_BOOL("zvfbfmin", ext_zvfbfmin, false), |
65 | RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev); | 49 | MULTI_EXT_CFG_BOOL("zvfbfwma", ext_zvfbfwma, false), |
66 | int priv_version = PRIV_VERSION_1_11_0; | 50 | MULTI_EXT_CFG_BOOL("zvfh", ext_zvfh, false), |
67 | + int vext_version = VEXT_VERSION_0_07_1; | 51 | diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c |
68 | target_ulong target_misa = 0; | 52 | index XXXXXXX..XXXXXXX 100644 |
69 | Error *local_err = NULL; | 53 | --- a/target/riscv/tcg/tcg-cpu.c |
70 | 54 | +++ b/target/riscv/tcg/tcg-cpu.c | |
71 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) | 55 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) |
56 | |||
57 | /* The Zve64d extension depends on the Zve64f extension */ | ||
58 | if (cpu->cfg.ext_zve64d) { | ||
59 | + if (!riscv_has_ext(env, RVD)) { | ||
60 | + error_setg(errp, "Zve64d/V extensions require D extension"); | ||
61 | + return; | ||
62 | + } | ||
63 | cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64f), true); | ||
72 | } | 64 | } |
73 | 65 | ||
74 | set_priv_version(env, priv_version); | 66 | - /* The Zve64f extension depends on the Zve32f extension */ |
75 | + set_vext_version(env, vext_version); | 67 | + /* The Zve64f extension depends on the Zve64x and Zve32f extensions */ |
76 | 68 | if (cpu->cfg.ext_zve64f) { | |
77 | if (cpu->cfg.mmu) { | 69 | + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64x), true); |
78 | set_feature(env, RISCV_FEATURE_MMU); | 70 | cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32f), true); |
71 | } | ||
72 | |||
73 | - if (cpu->cfg.ext_zve64d && !riscv_has_ext(env, RVD)) { | ||
74 | - error_setg(errp, "Zve64d/V extensions require D extension"); | ||
75 | - return; | ||
76 | + /* The Zve64x extension depends on the Zve32x extension */ | ||
77 | + if (cpu->cfg.ext_zve64x) { | ||
78 | + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32x), true); | ||
79 | } | ||
80 | |||
81 | /* The Zve32f extension depends on the Zve32x extension */ | ||
82 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | - if ((cpu->cfg.ext_zvbc || cpu->cfg.ext_zvknhb) && !cpu->cfg.ext_zve64f) { | ||
87 | + if ((cpu->cfg.ext_zvbc || cpu->cfg.ext_zvknhb) && !cpu->cfg.ext_zve64x) { | ||
88 | error_setg( | ||
89 | errp, | ||
90 | - "Zvbc and Zvknhb extensions require V or Zve64{f,d} extensions"); | ||
91 | + "Zvbc and Zvknhb extensions require V or Zve64x extensions"); | ||
92 | return; | ||
93 | } | ||
94 | |||
79 | -- | 95 | -- |
80 | 2.27.0 | 96 | 2.45.1 |
81 | |||
82 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Jason Chien <jason.chien@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | In current implementation, the gdbstub allows reading vector registers |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | only if V extension is supported. However, all vector extensions and |
5 | Message-id: 20200623215920.2594-57-zhiwei_liu@c-sky.com | 5 | vector crypto extensions have the vector registers and they all depend |
6 | on Zve32x. The gdbstub should check for Zve32x instead. | ||
7 | |||
8 | Signed-off-by: Jason Chien <jason.chien@sifive.com> | ||
9 | Reviewed-by: Frank Chang <frank.chang@sifive.com> | ||
10 | Reviewed-by: Max Chou <max.chou@sifive.com> | ||
11 | Message-ID: <20240328022343.6871-4-jason.chien@sifive.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 13 | --- |
8 | target/riscv/internals.h | 6 +++ | 14 | target/riscv/gdbstub.c | 2 +- |
9 | target/riscv/insn32.decode | 1 + | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 60 +++++++++++++++++++++++++ | ||
11 | 3 files changed, 67 insertions(+) | ||
12 | 16 | ||
13 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | 17 | diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/riscv/internals.h | 19 | --- a/target/riscv/gdbstub.c |
16 | +++ b/target/riscv/internals.h | 20 | +++ b/target/riscv/gdbstub.c |
17 | @@ -XXX,XX +XXX,XX @@ FIELD(VDATA, WD, 11, 1) | 21 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) |
18 | target_ulong fclass_h(uint64_t frs1); | 22 | gdb_find_static_feature("riscv-32bit-fpu.xml"), |
19 | target_ulong fclass_s(uint64_t frs1); | 23 | 0); |
20 | target_ulong fclass_d(uint64_t frs1); | 24 | } |
21 | + | 25 | - if (env->misa_ext & RVV) { |
22 | +#define SEW8 0 | 26 | + if (cpu->cfg.ext_zve32x) { |
23 | +#define SEW16 1 | 27 | gdb_register_coprocessor(cs, riscv_gdb_get_vector, |
24 | +#define SEW32 2 | 28 | riscv_gdb_set_vector, |
25 | +#define SEW64 3 | 29 | ricsv_gen_dynamic_vector_feature(cs, cs->gdb_num_regs), |
26 | + | ||
27 | #endif | ||
28 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/riscv/insn32.decode | ||
31 | +++ b/target/riscv/insn32.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | ||
33 | viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | ||
34 | vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm | ||
35 | vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r | ||
36 | +vmv_s_x 001101 1 00000 ..... 110 ..... 1010111 @r2 | ||
37 | |||
38 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
39 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
40 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
43 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool trans_vext_x_v(DisasContext *s, arg_r *a) | ||
45 | tcg_temp_free_i64(tmp); | ||
46 | return true; | ||
47 | } | ||
48 | + | ||
49 | +/* Integer Scalar Move Instruction */ | ||
50 | + | ||
51 | +static void store_element(TCGv_i64 val, TCGv_ptr base, | ||
52 | + int ofs, int sew) | ||
53 | +{ | ||
54 | + switch (sew) { | ||
55 | + case MO_8: | ||
56 | + tcg_gen_st8_i64(val, base, ofs); | ||
57 | + break; | ||
58 | + case MO_16: | ||
59 | + tcg_gen_st16_i64(val, base, ofs); | ||
60 | + break; | ||
61 | + case MO_32: | ||
62 | + tcg_gen_st32_i64(val, base, ofs); | ||
63 | + break; | ||
64 | + case MO_64: | ||
65 | + tcg_gen_st_i64(val, base, ofs); | ||
66 | + break; | ||
67 | + default: | ||
68 | + g_assert_not_reached(); | ||
69 | + break; | ||
70 | + } | ||
71 | +} | ||
72 | + | ||
73 | +/* | ||
74 | + * Store vreg[idx] = val. | ||
75 | + * The index must be in range of VLMAX. | ||
76 | + */ | ||
77 | +static void vec_element_storei(DisasContext *s, int vreg, | ||
78 | + int idx, TCGv_i64 val) | ||
79 | +{ | ||
80 | + store_element(val, cpu_env, endian_ofs(s, vreg, idx), s->sew); | ||
81 | +} | ||
82 | + | ||
83 | +/* vmv.s.x vd, rs1 # vd[0] = rs1 */ | ||
84 | +static bool trans_vmv_s_x(DisasContext *s, arg_vmv_s_x *a) | ||
85 | +{ | ||
86 | + if (vext_check_isa_ill(s)) { | ||
87 | + /* This instruction ignores LMUL and vector register groups */ | ||
88 | + int maxsz = s->vlen >> 3; | ||
89 | + TCGv_i64 t1; | ||
90 | + TCGLabel *over = gen_new_label(); | ||
91 | + | ||
92 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
93 | + tcg_gen_gvec_dup_imm(SEW64, vreg_ofs(s, a->rd), maxsz, maxsz, 0); | ||
94 | + if (a->rs1 == 0) { | ||
95 | + goto done; | ||
96 | + } | ||
97 | + | ||
98 | + t1 = tcg_temp_new_i64(); | ||
99 | + tcg_gen_extu_tl_i64(t1, cpu_gpr[a->rs1]); | ||
100 | + vec_element_storei(s, a->rd, 0, t1); | ||
101 | + tcg_temp_free_i64(t1); | ||
102 | + done: | ||
103 | + gen_set_label(over); | ||
104 | + return true; | ||
105 | + } | ||
106 | + return false; | ||
107 | +} | ||
108 | -- | 30 | -- |
109 | 2.27.0 | 31 | 2.45.1 |
110 | |||
111 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Huang Tao <eric.huang@linux.alibaba.com> |
---|---|---|---|
2 | 2 | ||
3 | Vector AMOs operate as if aq and rl bits were zero on each element | 3 | In RVV and vcrypto instructions, the masked and tail elements are set to 1s |
4 | with regard to ordering relative to other instructions in the same hart. | 4 | using vext_set_elems_1s function if the vma/vta bit is set. It is the element |
5 | Vector AMOs provide no ordering guarantee between element operations | 5 | agnostic policy. |
6 | in the same vector AMO instruction | ||
7 | 6 | ||
8 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 7 | However, this function can't deal the big endian situation. This patch fixes |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | the problem by adding handling of such case. |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | |
11 | Message-id: 20200623215920.2594-10-zhiwei_liu@c-sky.com | 10 | Signed-off-by: Huang Tao <eric.huang@linux.alibaba.com> |
11 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> | ||
13 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
14 | Message-ID: <20240325021654.6594-1-eric.huang@linux.alibaba.com> | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
13 | --- | 16 | --- |
14 | target/riscv/helper.h | 29 +++++ | 17 | target/riscv/vector_internals.c | 22 ++++++++++++++++++++++ |
15 | target/riscv/internals.h | 1 + | 18 | 1 file changed, 22 insertions(+) |
16 | target/riscv/insn32-64.decode | 11 ++ | ||
17 | target/riscv/insn32.decode | 13 +++ | ||
18 | target/riscv/insn_trans/trans_rvv.inc.c | 138 ++++++++++++++++++++++ | ||
19 | target/riscv/vector_helper.c | 147 ++++++++++++++++++++++++ | ||
20 | 6 files changed, 339 insertions(+) | ||
21 | 19 | ||
22 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 20 | diff --git a/target/riscv/vector_internals.c b/target/riscv/vector_internals.c |
23 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/riscv/helper.h | 22 | --- a/target/riscv/vector_internals.c |
25 | +++ b/target/riscv/helper.h | 23 | +++ b/target/riscv/vector_internals.c |
26 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vlhuff_v_w, void, ptr, ptr, tl, env, i32) | 24 | @@ -XXX,XX +XXX,XX @@ void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt, |
27 | DEF_HELPER_5(vlhuff_v_d, void, ptr, ptr, tl, env, i32) | 25 | if (tot - cnt == 0) { |
28 | DEF_HELPER_5(vlwuff_v_w, void, ptr, ptr, tl, env, i32) | 26 | return ; |
29 | DEF_HELPER_5(vlwuff_v_d, void, ptr, ptr, tl, env, i32) | 27 | } |
30 | +#ifdef TARGET_RISCV64 | ||
31 | +DEF_HELPER_6(vamoswapw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vamoswapd_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vamoaddw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vamoaddd_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vamoxorw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vamoxord_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vamoandw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vamoandd_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vamoorw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vamoord_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vamominw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vamomind_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vamomaxw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vamomaxd_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vamominuw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vamominud_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vamomaxuw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vamomaxud_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +#endif | ||
50 | +DEF_HELPER_6(vamoswapw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vamoaddw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vamoxorw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vamoandw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vamoorw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vamominw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | +DEF_HELPER_6(vamomaxw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
57 | +DEF_HELPER_6(vamominuw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
58 | +DEF_HELPER_6(vamomaxuw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
59 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/riscv/internals.h | ||
62 | +++ b/target/riscv/internals.h | ||
63 | @@ -XXX,XX +XXX,XX @@ FIELD(VDATA, MLEN, 0, 8) | ||
64 | FIELD(VDATA, VM, 8, 1) | ||
65 | FIELD(VDATA, LMUL, 9, 2) | ||
66 | FIELD(VDATA, NF, 11, 4) | ||
67 | +FIELD(VDATA, WD, 11, 1) | ||
68 | #endif | ||
69 | diff --git a/target/riscv/insn32-64.decode b/target/riscv/insn32-64.decode | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/riscv/insn32-64.decode | ||
72 | +++ b/target/riscv/insn32-64.decode | ||
73 | @@ -XXX,XX +XXX,XX @@ amomax_d 10100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
74 | amominu_d 11000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
75 | amomaxu_d 11100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
76 | |||
77 | +#*** Vector AMO operations (in addition to Zvamo) *** | ||
78 | +vamoswapd_v 00001 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
79 | +vamoaddd_v 00000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
80 | +vamoxord_v 00100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
81 | +vamoandd_v 01100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
82 | +vamoord_v 01000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
83 | +vamomind_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
84 | +vamomaxd_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
85 | +vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
86 | +vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
87 | + | 28 | + |
88 | # *** RV64F Standard Extension (in addition to RV32F) *** | 29 | + if (HOST_BIG_ENDIAN) { |
89 | fcvt_l_s 1100000 00010 ..... ... ..... 1010011 @r2_rm | 30 | + /* |
90 | fcvt_lu_s 1100000 00011 ..... ... ..... 1010011 @r2_rm | 31 | + * Deal the situation when the elements are insdie |
91 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 32 | + * only one uint64 block including setting the |
92 | index XXXXXXX..XXXXXXX 100644 | 33 | + * masked-off element. |
93 | --- a/target/riscv/insn32.decode | 34 | + */ |
94 | +++ b/target/riscv/insn32.decode | 35 | + if (((tot - 1) ^ cnt) < 8) { |
95 | @@ -XXX,XX +XXX,XX @@ | 36 | + memset(base + H1(tot - 1), -1, tot - cnt); |
96 | &u imm rd | 37 | + return; |
97 | &shift shamt rs1 rd | ||
98 | &atomic aq rl rs2 rs1 rd | ||
99 | +&rwdvm vm wd rd rs1 rs2 | ||
100 | &r2nfvm vm rd rs1 nf | ||
101 | &rnfvm vm rd rs1 rs2 nf | ||
102 | |||
103 | @@ -XXX,XX +XXX,XX @@ | ||
104 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | ||
105 | @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | ||
106 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | ||
107 | +@r_wdvm ..... wd:1 vm:1 ..... ..... ... ..... ....... &rwdvm %rs2 %rs1 %rd | ||
108 | @r2_zimm . zimm:11 ..... ... ..... ....... %rs1 %rd | ||
109 | |||
110 | @hfence_gvma ....... ..... ..... ... ..... ....... %rs2 %rs1 | ||
111 | @@ -XXX,XX +XXX,XX @@ vsxh_v ... -11 . ..... ..... 101 ..... 0100111 @r_nfvm | ||
112 | vsxw_v ... -11 . ..... ..... 110 ..... 0100111 @r_nfvm | ||
113 | vsxe_v ... -11 . ..... ..... 111 ..... 0100111 @r_nfvm | ||
114 | |||
115 | +#*** Vector AMO operations are encoded under the standard AMO major opcode *** | ||
116 | +vamoswapw_v 00001 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
117 | +vamoaddw_v 00000 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
118 | +vamoxorw_v 00100 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
119 | +vamoandw_v 01100 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
120 | +vamoorw_v 01000 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
121 | +vamominw_v 10000 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
122 | +vamomaxw_v 10100 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
123 | +vamominuw_v 11000 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
124 | +vamomaxuw_v 11100 . . ..... ..... 110 ..... 0101111 @r_wdvm | ||
125 | + | ||
126 | # *** new major opcode OP-V *** | ||
127 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
128 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
129 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
132 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
133 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_TRANS(vleff_v, 3, r2nfvm, ldff_op, ld_us_check) | ||
134 | GEN_VEXT_TRANS(vlbuff_v, 4, r2nfvm, ldff_op, ld_us_check) | ||
135 | GEN_VEXT_TRANS(vlhuff_v, 5, r2nfvm, ldff_op, ld_us_check) | ||
136 | GEN_VEXT_TRANS(vlwuff_v, 6, r2nfvm, ldff_op, ld_us_check) | ||
137 | + | ||
138 | +/* | ||
139 | + *** vector atomic operation | ||
140 | + */ | ||
141 | +typedef void gen_helper_amo(TCGv_ptr, TCGv_ptr, TCGv, TCGv_ptr, | ||
142 | + TCGv_env, TCGv_i32); | ||
143 | + | ||
144 | +static bool amo_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, | ||
145 | + uint32_t data, gen_helper_amo *fn, DisasContext *s) | ||
146 | +{ | ||
147 | + TCGv_ptr dest, mask, index; | ||
148 | + TCGv base; | ||
149 | + TCGv_i32 desc; | ||
150 | + | ||
151 | + TCGLabel *over = gen_new_label(); | ||
152 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
153 | + | ||
154 | + dest = tcg_temp_new_ptr(); | ||
155 | + mask = tcg_temp_new_ptr(); | ||
156 | + index = tcg_temp_new_ptr(); | ||
157 | + base = tcg_temp_new(); | ||
158 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
159 | + | ||
160 | + gen_get_gpr(base, rs1); | ||
161 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
162 | + tcg_gen_addi_ptr(index, cpu_env, vreg_ofs(s, vs2)); | ||
163 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
164 | + | ||
165 | + fn(dest, mask, base, index, cpu_env, desc); | ||
166 | + | ||
167 | + tcg_temp_free_ptr(dest); | ||
168 | + tcg_temp_free_ptr(mask); | ||
169 | + tcg_temp_free_ptr(index); | ||
170 | + tcg_temp_free(base); | ||
171 | + tcg_temp_free_i32(desc); | ||
172 | + gen_set_label(over); | ||
173 | + return true; | ||
174 | +} | ||
175 | + | ||
176 | +static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) | ||
177 | +{ | ||
178 | + uint32_t data = 0; | ||
179 | + gen_helper_amo *fn; | ||
180 | + static gen_helper_amo *const fnsw[9] = { | ||
181 | + /* no atomic operation */ | ||
182 | + gen_helper_vamoswapw_v_w, | ||
183 | + gen_helper_vamoaddw_v_w, | ||
184 | + gen_helper_vamoxorw_v_w, | ||
185 | + gen_helper_vamoandw_v_w, | ||
186 | + gen_helper_vamoorw_v_w, | ||
187 | + gen_helper_vamominw_v_w, | ||
188 | + gen_helper_vamomaxw_v_w, | ||
189 | + gen_helper_vamominuw_v_w, | ||
190 | + gen_helper_vamomaxuw_v_w | ||
191 | + }; | ||
192 | +#ifdef TARGET_RISCV64 | ||
193 | + static gen_helper_amo *const fnsd[18] = { | ||
194 | + gen_helper_vamoswapw_v_d, | ||
195 | + gen_helper_vamoaddw_v_d, | ||
196 | + gen_helper_vamoxorw_v_d, | ||
197 | + gen_helper_vamoandw_v_d, | ||
198 | + gen_helper_vamoorw_v_d, | ||
199 | + gen_helper_vamominw_v_d, | ||
200 | + gen_helper_vamomaxw_v_d, | ||
201 | + gen_helper_vamominuw_v_d, | ||
202 | + gen_helper_vamomaxuw_v_d, | ||
203 | + gen_helper_vamoswapd_v_d, | ||
204 | + gen_helper_vamoaddd_v_d, | ||
205 | + gen_helper_vamoxord_v_d, | ||
206 | + gen_helper_vamoandd_v_d, | ||
207 | + gen_helper_vamoord_v_d, | ||
208 | + gen_helper_vamomind_v_d, | ||
209 | + gen_helper_vamomaxd_v_d, | ||
210 | + gen_helper_vamominud_v_d, | ||
211 | + gen_helper_vamomaxud_v_d | ||
212 | + }; | ||
213 | +#endif | ||
214 | + | ||
215 | + if (tb_cflags(s->base.tb) & CF_PARALLEL) { | ||
216 | + gen_helper_exit_atomic(cpu_env); | ||
217 | + s->base.is_jmp = DISAS_NORETURN; | ||
218 | + return true; | ||
219 | + } else { | ||
220 | + if (s->sew == 3) { | ||
221 | +#ifdef TARGET_RISCV64 | ||
222 | + fn = fnsd[seq]; | ||
223 | +#else | ||
224 | + /* Check done in amo_check(). */ | ||
225 | + g_assert_not_reached(); | ||
226 | +#endif | ||
227 | + } else { | ||
228 | + fn = fnsw[seq]; | ||
229 | + } | 38 | + } |
39 | + /* | ||
40 | + * Otherwise, at least cross two uint64_t blocks. | ||
41 | + * Set first unaligned block. | ||
42 | + */ | ||
43 | + if (cnt % 8 != 0) { | ||
44 | + uint32_t j = ROUND_UP(cnt, 8); | ||
45 | + memset(base + H1(j - 1), -1, j - cnt); | ||
46 | + cnt = j; | ||
47 | + } | ||
48 | + /* Set other 64bit aligend blocks */ | ||
230 | + } | 49 | + } |
231 | + | 50 | memset(base + cnt, -1, tot - cnt); |
232 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
233 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
234 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
235 | + data = FIELD_DP32(data, VDATA, WD, a->wd); | ||
236 | + return amo_trans(a->rd, a->rs1, a->rs2, data, fn, s); | ||
237 | +} | ||
238 | +/* | ||
239 | + * There are two rules check here. | ||
240 | + * | ||
241 | + * 1. SEW must be at least as wide as the AMO memory element size. | ||
242 | + * | ||
243 | + * 2. If SEW is greater than XLEN, an illegal instruction exception is raised. | ||
244 | + */ | ||
245 | +static bool amo_check(DisasContext *s, arg_rwdvm* a) | ||
246 | +{ | ||
247 | + return (!s->vill && has_ext(s, RVA) && | ||
248 | + (!a->wd || vext_check_overlap_mask(s, a->rd, a->vm, false)) && | ||
249 | + vext_check_reg(s, a->rd, false) && | ||
250 | + vext_check_reg(s, a->rs2, false) && | ||
251 | + ((1 << s->sew) <= sizeof(target_ulong)) && | ||
252 | + ((1 << s->sew) >= 4)); | ||
253 | +} | ||
254 | + | ||
255 | +GEN_VEXT_TRANS(vamoswapw_v, 0, rwdvm, amo_op, amo_check) | ||
256 | +GEN_VEXT_TRANS(vamoaddw_v, 1, rwdvm, amo_op, amo_check) | ||
257 | +GEN_VEXT_TRANS(vamoxorw_v, 2, rwdvm, amo_op, amo_check) | ||
258 | +GEN_VEXT_TRANS(vamoandw_v, 3, rwdvm, amo_op, amo_check) | ||
259 | +GEN_VEXT_TRANS(vamoorw_v, 4, rwdvm, amo_op, amo_check) | ||
260 | +GEN_VEXT_TRANS(vamominw_v, 5, rwdvm, amo_op, amo_check) | ||
261 | +GEN_VEXT_TRANS(vamomaxw_v, 6, rwdvm, amo_op, amo_check) | ||
262 | +GEN_VEXT_TRANS(vamominuw_v, 7, rwdvm, amo_op, amo_check) | ||
263 | +GEN_VEXT_TRANS(vamomaxuw_v, 8, rwdvm, amo_op, amo_check) | ||
264 | +#ifdef TARGET_RISCV64 | ||
265 | +GEN_VEXT_TRANS(vamoswapd_v, 9, rwdvm, amo_op, amo_check) | ||
266 | +GEN_VEXT_TRANS(vamoaddd_v, 10, rwdvm, amo_op, amo_check) | ||
267 | +GEN_VEXT_TRANS(vamoxord_v, 11, rwdvm, amo_op, amo_check) | ||
268 | +GEN_VEXT_TRANS(vamoandd_v, 12, rwdvm, amo_op, amo_check) | ||
269 | +GEN_VEXT_TRANS(vamoord_v, 13, rwdvm, amo_op, amo_check) | ||
270 | +GEN_VEXT_TRANS(vamomind_v, 14, rwdvm, amo_op, amo_check) | ||
271 | +GEN_VEXT_TRANS(vamomaxd_v, 15, rwdvm, amo_op, amo_check) | ||
272 | +GEN_VEXT_TRANS(vamominud_v, 16, rwdvm, amo_op, amo_check) | ||
273 | +GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) | ||
274 | +#endif | ||
275 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
276 | index XXXXXXX..XXXXXXX 100644 | ||
277 | --- a/target/riscv/vector_helper.c | ||
278 | +++ b/target/riscv/vector_helper.c | ||
279 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t vext_lmul(uint32_t desc) | ||
280 | return FIELD_EX32(simd_data(desc), VDATA, LMUL); | ||
281 | } | 51 | } |
282 | 52 | ||
283 | +static uint32_t vext_wd(uint32_t desc) | ||
284 | +{ | ||
285 | + return (simd_data(desc) >> 11) & 0x1; | ||
286 | +} | ||
287 | + | ||
288 | /* | ||
289 | * Get vector group length in bytes. Its range is [64, 2048]. | ||
290 | * | ||
291 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_LDFF(vlhuff_v_w, uint16_t, uint32_t, ldhu_w, clearl) | ||
292 | GEN_VEXT_LDFF(vlhuff_v_d, uint16_t, uint64_t, ldhu_d, clearq) | ||
293 | GEN_VEXT_LDFF(vlwuff_v_w, uint32_t, uint32_t, ldwu_w, clearl) | ||
294 | GEN_VEXT_LDFF(vlwuff_v_d, uint32_t, uint64_t, ldwu_d, clearq) | ||
295 | + | ||
296 | +/* | ||
297 | + *** Vector AMO Operations (Zvamo) | ||
298 | + */ | ||
299 | +typedef void vext_amo_noatomic_fn(void *vs3, target_ulong addr, | ||
300 | + uint32_t wd, uint32_t idx, CPURISCVState *env, | ||
301 | + uintptr_t retaddr); | ||
302 | + | ||
303 | +/* no atomic opreation for vector atomic insructions */ | ||
304 | +#define DO_SWAP(N, M) (M) | ||
305 | +#define DO_AND(N, M) (N & M) | ||
306 | +#define DO_XOR(N, M) (N ^ M) | ||
307 | +#define DO_OR(N, M) (N | M) | ||
308 | +#define DO_ADD(N, M) (N + M) | ||
309 | + | ||
310 | +#define GEN_VEXT_AMO_NOATOMIC_OP(NAME, ESZ, MSZ, H, DO_OP, SUF) \ | ||
311 | +static void \ | ||
312 | +vext_##NAME##_noatomic_op(void *vs3, target_ulong addr, \ | ||
313 | + uint32_t wd, uint32_t idx, \ | ||
314 | + CPURISCVState *env, uintptr_t retaddr)\ | ||
315 | +{ \ | ||
316 | + typedef int##ESZ##_t ETYPE; \ | ||
317 | + typedef int##MSZ##_t MTYPE; \ | ||
318 | + typedef uint##MSZ##_t UMTYPE __attribute__((unused)); \ | ||
319 | + ETYPE *pe3 = (ETYPE *)vs3 + H(idx); \ | ||
320 | + MTYPE a = cpu_ld##SUF##_data(env, addr), b = *pe3; \ | ||
321 | + \ | ||
322 | + cpu_st##SUF##_data(env, addr, DO_OP(a, b)); \ | ||
323 | + if (wd) { \ | ||
324 | + *pe3 = a; \ | ||
325 | + } \ | ||
326 | +} | ||
327 | + | ||
328 | +/* Signed min/max */ | ||
329 | +#define DO_MAX(N, M) ((N) >= (M) ? (N) : (M)) | ||
330 | +#define DO_MIN(N, M) ((N) >= (M) ? (M) : (N)) | ||
331 | + | ||
332 | +/* Unsigned min/max */ | ||
333 | +#define DO_MAXU(N, M) DO_MAX((UMTYPE)N, (UMTYPE)M) | ||
334 | +#define DO_MINU(N, M) DO_MIN((UMTYPE)N, (UMTYPE)M) | ||
335 | + | ||
336 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoswapw_v_w, 32, 32, H4, DO_SWAP, l) | ||
337 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoaddw_v_w, 32, 32, H4, DO_ADD, l) | ||
338 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoxorw_v_w, 32, 32, H4, DO_XOR, l) | ||
339 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoandw_v_w, 32, 32, H4, DO_AND, l) | ||
340 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoorw_v_w, 32, 32, H4, DO_OR, l) | ||
341 | +GEN_VEXT_AMO_NOATOMIC_OP(vamominw_v_w, 32, 32, H4, DO_MIN, l) | ||
342 | +GEN_VEXT_AMO_NOATOMIC_OP(vamomaxw_v_w, 32, 32, H4, DO_MAX, l) | ||
343 | +GEN_VEXT_AMO_NOATOMIC_OP(vamominuw_v_w, 32, 32, H4, DO_MINU, l) | ||
344 | +GEN_VEXT_AMO_NOATOMIC_OP(vamomaxuw_v_w, 32, 32, H4, DO_MAXU, l) | ||
345 | +#ifdef TARGET_RISCV64 | ||
346 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoswapw_v_d, 64, 32, H8, DO_SWAP, l) | ||
347 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoswapd_v_d, 64, 64, H8, DO_SWAP, q) | ||
348 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoaddw_v_d, 64, 32, H8, DO_ADD, l) | ||
349 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoaddd_v_d, 64, 64, H8, DO_ADD, q) | ||
350 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoxorw_v_d, 64, 32, H8, DO_XOR, l) | ||
351 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoxord_v_d, 64, 64, H8, DO_XOR, q) | ||
352 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoandw_v_d, 64, 32, H8, DO_AND, l) | ||
353 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoandd_v_d, 64, 64, H8, DO_AND, q) | ||
354 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoorw_v_d, 64, 32, H8, DO_OR, l) | ||
355 | +GEN_VEXT_AMO_NOATOMIC_OP(vamoord_v_d, 64, 64, H8, DO_OR, q) | ||
356 | +GEN_VEXT_AMO_NOATOMIC_OP(vamominw_v_d, 64, 32, H8, DO_MIN, l) | ||
357 | +GEN_VEXT_AMO_NOATOMIC_OP(vamomind_v_d, 64, 64, H8, DO_MIN, q) | ||
358 | +GEN_VEXT_AMO_NOATOMIC_OP(vamomaxw_v_d, 64, 32, H8, DO_MAX, l) | ||
359 | +GEN_VEXT_AMO_NOATOMIC_OP(vamomaxd_v_d, 64, 64, H8, DO_MAX, q) | ||
360 | +GEN_VEXT_AMO_NOATOMIC_OP(vamominuw_v_d, 64, 32, H8, DO_MINU, l) | ||
361 | +GEN_VEXT_AMO_NOATOMIC_OP(vamominud_v_d, 64, 64, H8, DO_MINU, q) | ||
362 | +GEN_VEXT_AMO_NOATOMIC_OP(vamomaxuw_v_d, 64, 32, H8, DO_MAXU, l) | ||
363 | +GEN_VEXT_AMO_NOATOMIC_OP(vamomaxud_v_d, 64, 64, H8, DO_MAXU, q) | ||
364 | +#endif | ||
365 | + | ||
366 | +static inline void | ||
367 | +vext_amo_noatomic(void *vs3, void *v0, target_ulong base, | ||
368 | + void *vs2, CPURISCVState *env, uint32_t desc, | ||
369 | + vext_get_index_addr get_index_addr, | ||
370 | + vext_amo_noatomic_fn *noatomic_op, | ||
371 | + clear_fn *clear_elem, | ||
372 | + uint32_t esz, uint32_t msz, uintptr_t ra) | ||
373 | +{ | ||
374 | + uint32_t i; | ||
375 | + target_long addr; | ||
376 | + uint32_t wd = vext_wd(desc); | ||
377 | + uint32_t vm = vext_vm(desc); | ||
378 | + uint32_t mlen = vext_mlen(desc); | ||
379 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
380 | + | ||
381 | + for (i = 0; i < env->vl; i++) { | ||
382 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
383 | + continue; | ||
384 | + } | ||
385 | + probe_pages(env, get_index_addr(base, i, vs2), msz, ra, MMU_DATA_LOAD); | ||
386 | + probe_pages(env, get_index_addr(base, i, vs2), msz, ra, MMU_DATA_STORE); | ||
387 | + } | ||
388 | + for (i = 0; i < env->vl; i++) { | ||
389 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
390 | + continue; | ||
391 | + } | ||
392 | + addr = get_index_addr(base, i, vs2); | ||
393 | + noatomic_op(vs3, addr, wd, i, env, ra); | ||
394 | + } | ||
395 | + clear_elem(vs3, env->vl, env->vl * esz, vlmax * esz); | ||
396 | +} | ||
397 | + | ||
398 | +#define GEN_VEXT_AMO(NAME, MTYPE, ETYPE, INDEX_FN, CLEAR_FN) \ | ||
399 | +void HELPER(NAME)(void *vs3, void *v0, target_ulong base, \ | ||
400 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
401 | +{ \ | ||
402 | + vext_amo_noatomic(vs3, v0, base, vs2, env, desc, \ | ||
403 | + INDEX_FN, vext_##NAME##_noatomic_op, \ | ||
404 | + CLEAR_FN, sizeof(ETYPE), sizeof(MTYPE), \ | ||
405 | + GETPC()); \ | ||
406 | +} | ||
407 | + | ||
408 | +#ifdef TARGET_RISCV64 | ||
409 | +GEN_VEXT_AMO(vamoswapw_v_d, int32_t, int64_t, idx_d, clearq) | ||
410 | +GEN_VEXT_AMO(vamoswapd_v_d, int64_t, int64_t, idx_d, clearq) | ||
411 | +GEN_VEXT_AMO(vamoaddw_v_d, int32_t, int64_t, idx_d, clearq) | ||
412 | +GEN_VEXT_AMO(vamoaddd_v_d, int64_t, int64_t, idx_d, clearq) | ||
413 | +GEN_VEXT_AMO(vamoxorw_v_d, int32_t, int64_t, idx_d, clearq) | ||
414 | +GEN_VEXT_AMO(vamoxord_v_d, int64_t, int64_t, idx_d, clearq) | ||
415 | +GEN_VEXT_AMO(vamoandw_v_d, int32_t, int64_t, idx_d, clearq) | ||
416 | +GEN_VEXT_AMO(vamoandd_v_d, int64_t, int64_t, idx_d, clearq) | ||
417 | +GEN_VEXT_AMO(vamoorw_v_d, int32_t, int64_t, idx_d, clearq) | ||
418 | +GEN_VEXT_AMO(vamoord_v_d, int64_t, int64_t, idx_d, clearq) | ||
419 | +GEN_VEXT_AMO(vamominw_v_d, int32_t, int64_t, idx_d, clearq) | ||
420 | +GEN_VEXT_AMO(vamomind_v_d, int64_t, int64_t, idx_d, clearq) | ||
421 | +GEN_VEXT_AMO(vamomaxw_v_d, int32_t, int64_t, idx_d, clearq) | ||
422 | +GEN_VEXT_AMO(vamomaxd_v_d, int64_t, int64_t, idx_d, clearq) | ||
423 | +GEN_VEXT_AMO(vamominuw_v_d, uint32_t, uint64_t, idx_d, clearq) | ||
424 | +GEN_VEXT_AMO(vamominud_v_d, uint64_t, uint64_t, idx_d, clearq) | ||
425 | +GEN_VEXT_AMO(vamomaxuw_v_d, uint32_t, uint64_t, idx_d, clearq) | ||
426 | +GEN_VEXT_AMO(vamomaxud_v_d, uint64_t, uint64_t, idx_d, clearq) | ||
427 | +#endif | ||
428 | +GEN_VEXT_AMO(vamoswapw_v_w, int32_t, int32_t, idx_w, clearl) | ||
429 | +GEN_VEXT_AMO(vamoaddw_v_w, int32_t, int32_t, idx_w, clearl) | ||
430 | +GEN_VEXT_AMO(vamoxorw_v_w, int32_t, int32_t, idx_w, clearl) | ||
431 | +GEN_VEXT_AMO(vamoandw_v_w, int32_t, int32_t, idx_w, clearl) | ||
432 | +GEN_VEXT_AMO(vamoorw_v_w, int32_t, int32_t, idx_w, clearl) | ||
433 | +GEN_VEXT_AMO(vamominw_v_w, int32_t, int32_t, idx_w, clearl) | ||
434 | +GEN_VEXT_AMO(vamomaxw_v_w, int32_t, int32_t, idx_w, clearl) | ||
435 | +GEN_VEXT_AMO(vamominuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
436 | +GEN_VEXT_AMO(vamomaxuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
437 | -- | 53 | -- |
438 | 2.27.0 | 54 | 2.45.1 |
439 | |||
440 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Yangyu Chen <cyy@cyyself.name> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | This code has a typo that writes zvkb to zvkg, causing users can't |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | enable zvkb through the config. This patch gets this fixed. |
5 | Message-id: 20200623215920.2594-56-zhiwei_liu@c-sky.com | 5 | |
6 | Signed-off-by: Yangyu Chen <cyy@cyyself.name> | ||
7 | Fixes: ea61ef7097d0 ("target/riscv: Move vector crypto extensions to riscv_cpu_extensions") | ||
8 | Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Reviewed-by: Max Chou <max.chou@sifive.com> | ||
11 | Reviewed-by: Weiwei Li <liwei1518@gmail.com> | ||
12 | Message-ID: <tencent_7E34EEF0F90B9A68BF38BEE09EC6D4877C0A@qq.com> | ||
13 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 14 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 15 | --- |
8 | target/riscv/insn32.decode | 1 + | 16 | target/riscv/cpu.c | 2 +- |
9 | target/riscv/insn_trans/trans_rvv.inc.c | 116 ++++++++++++++++++++++++ | 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 2 files changed, 117 insertions(+) | ||
11 | 18 | ||
12 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 19 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
13 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/riscv/insn32.decode | 21 | --- a/target/riscv/cpu.c |
15 | +++ b/target/riscv/insn32.decode | 22 | +++ b/target/riscv/cpu.c |
16 | @@ -XXX,XX +XXX,XX @@ vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm | 23 | @@ -XXX,XX +XXX,XX @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { |
17 | vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | 24 | /* Vector cryptography extensions */ |
18 | viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | 25 | MULTI_EXT_CFG_BOOL("zvbb", ext_zvbb, false), |
19 | vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm | 26 | MULTI_EXT_CFG_BOOL("zvbc", ext_zvbc, false), |
20 | +vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r | 27 | - MULTI_EXT_CFG_BOOL("zvkb", ext_zvkg, false), |
21 | 28 | + MULTI_EXT_CFG_BOOL("zvkb", ext_zvkb, false), | |
22 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 29 | MULTI_EXT_CFG_BOOL("zvkg", ext_zvkg, false), |
23 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 30 | MULTI_EXT_CFG_BOOL("zvkned", ext_zvkned, false), |
24 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 31 | MULTI_EXT_CFG_BOOL("zvknha", ext_zvknha, false), |
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
27 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a) | ||
29 | } | ||
30 | return false; | ||
31 | } | ||
32 | + | ||
33 | +/* | ||
34 | + *** Vector Permutation Instructions | ||
35 | + */ | ||
36 | + | ||
37 | +/* Integer Extract Instruction */ | ||
38 | + | ||
39 | +static void load_element(TCGv_i64 dest, TCGv_ptr base, | ||
40 | + int ofs, int sew) | ||
41 | +{ | ||
42 | + switch (sew) { | ||
43 | + case MO_8: | ||
44 | + tcg_gen_ld8u_i64(dest, base, ofs); | ||
45 | + break; | ||
46 | + case MO_16: | ||
47 | + tcg_gen_ld16u_i64(dest, base, ofs); | ||
48 | + break; | ||
49 | + case MO_32: | ||
50 | + tcg_gen_ld32u_i64(dest, base, ofs); | ||
51 | + break; | ||
52 | + case MO_64: | ||
53 | + tcg_gen_ld_i64(dest, base, ofs); | ||
54 | + break; | ||
55 | + default: | ||
56 | + g_assert_not_reached(); | ||
57 | + break; | ||
58 | + } | ||
59 | +} | ||
60 | + | ||
61 | +/* offset of the idx element with base regsiter r */ | ||
62 | +static uint32_t endian_ofs(DisasContext *s, int r, int idx) | ||
63 | +{ | ||
64 | +#ifdef HOST_WORDS_BIGENDIAN | ||
65 | + return vreg_ofs(s, r) + ((idx ^ (7 >> s->sew)) << s->sew); | ||
66 | +#else | ||
67 | + return vreg_ofs(s, r) + (idx << s->sew); | ||
68 | +#endif | ||
69 | +} | ||
70 | + | ||
71 | +/* adjust the index according to the endian */ | ||
72 | +static void endian_adjust(TCGv_i32 ofs, int sew) | ||
73 | +{ | ||
74 | +#ifdef HOST_WORDS_BIGENDIAN | ||
75 | + tcg_gen_xori_i32(ofs, ofs, 7 >> sew); | ||
76 | +#endif | ||
77 | +} | ||
78 | + | ||
79 | +/* Load idx >= VLMAX ? 0 : vreg[idx] */ | ||
80 | +static void vec_element_loadx(DisasContext *s, TCGv_i64 dest, | ||
81 | + int vreg, TCGv idx, int vlmax) | ||
82 | +{ | ||
83 | + TCGv_i32 ofs = tcg_temp_new_i32(); | ||
84 | + TCGv_ptr base = tcg_temp_new_ptr(); | ||
85 | + TCGv_i64 t_idx = tcg_temp_new_i64(); | ||
86 | + TCGv_i64 t_vlmax, t_zero; | ||
87 | + | ||
88 | + /* | ||
89 | + * Mask the index to the length so that we do | ||
90 | + * not produce an out-of-range load. | ||
91 | + */ | ||
92 | + tcg_gen_trunc_tl_i32(ofs, idx); | ||
93 | + tcg_gen_andi_i32(ofs, ofs, vlmax - 1); | ||
94 | + | ||
95 | + /* Convert the index to an offset. */ | ||
96 | + endian_adjust(ofs, s->sew); | ||
97 | + tcg_gen_shli_i32(ofs, ofs, s->sew); | ||
98 | + | ||
99 | + /* Convert the index to a pointer. */ | ||
100 | + tcg_gen_ext_i32_ptr(base, ofs); | ||
101 | + tcg_gen_add_ptr(base, base, cpu_env); | ||
102 | + | ||
103 | + /* Perform the load. */ | ||
104 | + load_element(dest, base, | ||
105 | + vreg_ofs(s, vreg), s->sew); | ||
106 | + tcg_temp_free_ptr(base); | ||
107 | + tcg_temp_free_i32(ofs); | ||
108 | + | ||
109 | + /* Flush out-of-range indexing to zero. */ | ||
110 | + t_vlmax = tcg_const_i64(vlmax); | ||
111 | + t_zero = tcg_const_i64(0); | ||
112 | + tcg_gen_extu_tl_i64(t_idx, idx); | ||
113 | + | ||
114 | + tcg_gen_movcond_i64(TCG_COND_LTU, dest, t_idx, | ||
115 | + t_vlmax, dest, t_zero); | ||
116 | + | ||
117 | + tcg_temp_free_i64(t_vlmax); | ||
118 | + tcg_temp_free_i64(t_zero); | ||
119 | + tcg_temp_free_i64(t_idx); | ||
120 | +} | ||
121 | + | ||
122 | +static void vec_element_loadi(DisasContext *s, TCGv_i64 dest, | ||
123 | + int vreg, int idx) | ||
124 | +{ | ||
125 | + load_element(dest, cpu_env, endian_ofs(s, vreg, idx), s->sew); | ||
126 | +} | ||
127 | + | ||
128 | +static bool trans_vext_x_v(DisasContext *s, arg_r *a) | ||
129 | +{ | ||
130 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
131 | + TCGv dest = tcg_temp_new(); | ||
132 | + | ||
133 | + if (a->rs1 == 0) { | ||
134 | + /* Special case vmv.x.s rd, vs2. */ | ||
135 | + vec_element_loadi(s, tmp, a->rs2, 0); | ||
136 | + } else { | ||
137 | + /* This instruction ignores LMUL and vector register groups */ | ||
138 | + int vlmax = s->vlen >> (3 + s->sew); | ||
139 | + vec_element_loadx(s, tmp, a->rs2, cpu_gpr[a->rs1], vlmax); | ||
140 | + } | ||
141 | + tcg_gen_trunc_i64_tl(dest, tmp); | ||
142 | + gen_set_gpr(a->rd, dest); | ||
143 | + | ||
144 | + tcg_temp_free(dest); | ||
145 | + tcg_temp_free_i64(tmp); | ||
146 | + return true; | ||
147 | +} | ||
148 | -- | 32 | -- |
149 | 2.27.0 | 33 | 2.45.1 |
150 | 34 | ||
151 | 35 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Huang Tao <eric.huang@linux.alibaba.com> |
---|---|---|---|
2 | 2 | ||
3 | Vector strided operations access the first memory element at the base address, | 3 | In this patch, we modify the decoder to be a freely composable data |
4 | and then access subsequent elements at address increments given by the byte | 4 | structure instead of a hardcoded one. It can be dynamically builded up |
5 | offset contained in the x register specified by rs2. | 5 | according to the extensions. |
6 | This approach has several benefits: | ||
7 | 1. Provides support for heterogeneous cpu architectures. As we add decoder in | ||
8 | RISCVCPU, each cpu can have their own decoder, and the decoders can be | ||
9 | different due to cpu's features. | ||
10 | 2. Improve the decoding efficiency. We run the guard_func to see if the decoder | ||
11 | can be added to the dynamic_decoder when building up the decoder. Therefore, | ||
12 | there is no need to run the guard_func when decoding each instruction. It can | ||
13 | improve the decoding efficiency | ||
14 | 3. For vendor or dynamic cpus, it allows them to customize their own decoder | ||
15 | functions to improve decoding efficiency, especially when vendor-defined | ||
16 | instruction sets increase. Because of dynamic building up, it can skip the other | ||
17 | decoder guard functions when decoding. | ||
18 | 4. Pre patch for allowing adding a vendor decoder before decode_insn32() with minimal | ||
19 | overhead for users that don't need this particular vendor decoder. | ||
6 | 20 | ||
7 | Vector unit-stride operations access elements stored contiguously in memory | 21 | Signed-off-by: Huang Tao <eric.huang@linux.alibaba.com> |
8 | starting from the base effective address. It can been seen as a special | 22 | Suggested-by: Christoph Muellner <christoph.muellner@vrull.eu> |
9 | case of strided operations. | 23 | Co-authored-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> |
10 | |||
11 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 25 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
14 | Message-id: 20200623215920.2594-7-zhiwei_liu@c-sky.com | 26 | Message-ID: <20240506023607.29544-1-eric.huang@linux.alibaba.com> |
15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 27 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
16 | --- | 28 | --- |
17 | target/riscv/helper.h | 105 ++++++ | 29 | target/riscv/cpu.h | 1 + |
18 | target/riscv/internals.h | 5 + | 30 | target/riscv/tcg/tcg-cpu.h | 15 +++++++++++++++ |
19 | target/riscv/insn32.decode | 32 ++ | 31 | target/riscv/cpu.c | 1 + |
20 | target/riscv/insn_trans/trans_rvv.inc.c | 355 ++++++++++++++++++++ | 32 | target/riscv/tcg/tcg-cpu.c | 15 +++++++++++++++ |
21 | target/riscv/translate.c | 7 + | 33 | target/riscv/translate.c | 31 +++++++++++++++---------------- |
22 | target/riscv/vector_helper.c | 410 ++++++++++++++++++++++++ | 34 | 5 files changed, 47 insertions(+), 16 deletions(-) |
23 | 6 files changed, 914 insertions(+) | ||
24 | 35 | ||
25 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 36 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h |
26 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/riscv/helper.h | 38 | --- a/target/riscv/cpu.h |
28 | +++ b/target/riscv/helper.h | 39 | +++ b/target/riscv/cpu.h |
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_1(hyp_tlb_flush, void, env) | 40 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
30 | 41 | uint32_t pmu_avail_ctrs; | |
31 | /* Vector functions */ | 42 | /* Mapping of events to counters */ |
32 | DEF_HELPER_3(vsetvl, tl, env, tl, tl) | 43 | GHashTable *pmu_event_ctr_map; |
33 | +DEF_HELPER_5(vlb_v_b, void, ptr, ptr, tl, env, i32) | 44 | + const GPtrArray *decoders; |
34 | +DEF_HELPER_5(vlb_v_b_mask, void, ptr, ptr, tl, env, i32) | 45 | }; |
35 | +DEF_HELPER_5(vlb_v_h, void, ptr, ptr, tl, env, i32) | 46 | |
36 | +DEF_HELPER_5(vlb_v_h_mask, void, ptr, ptr, tl, env, i32) | 47 | /** |
37 | +DEF_HELPER_5(vlb_v_w, void, ptr, ptr, tl, env, i32) | 48 | diff --git a/target/riscv/tcg/tcg-cpu.h b/target/riscv/tcg/tcg-cpu.h |
38 | +DEF_HELPER_5(vlb_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
39 | +DEF_HELPER_5(vlb_v_d, void, ptr, ptr, tl, env, i32) | ||
40 | +DEF_HELPER_5(vlb_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
41 | +DEF_HELPER_5(vlh_v_h, void, ptr, ptr, tl, env, i32) | ||
42 | +DEF_HELPER_5(vlh_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
43 | +DEF_HELPER_5(vlh_v_w, void, ptr, ptr, tl, env, i32) | ||
44 | +DEF_HELPER_5(vlh_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
45 | +DEF_HELPER_5(vlh_v_d, void, ptr, ptr, tl, env, i32) | ||
46 | +DEF_HELPER_5(vlh_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
47 | +DEF_HELPER_5(vlw_v_w, void, ptr, ptr, tl, env, i32) | ||
48 | +DEF_HELPER_5(vlw_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
49 | +DEF_HELPER_5(vlw_v_d, void, ptr, ptr, tl, env, i32) | ||
50 | +DEF_HELPER_5(vlw_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
51 | +DEF_HELPER_5(vle_v_b, void, ptr, ptr, tl, env, i32) | ||
52 | +DEF_HELPER_5(vle_v_b_mask, void, ptr, ptr, tl, env, i32) | ||
53 | +DEF_HELPER_5(vle_v_h, void, ptr, ptr, tl, env, i32) | ||
54 | +DEF_HELPER_5(vle_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
55 | +DEF_HELPER_5(vle_v_w, void, ptr, ptr, tl, env, i32) | ||
56 | +DEF_HELPER_5(vle_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
57 | +DEF_HELPER_5(vle_v_d, void, ptr, ptr, tl, env, i32) | ||
58 | +DEF_HELPER_5(vle_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
59 | +DEF_HELPER_5(vlbu_v_b, void, ptr, ptr, tl, env, i32) | ||
60 | +DEF_HELPER_5(vlbu_v_b_mask, void, ptr, ptr, tl, env, i32) | ||
61 | +DEF_HELPER_5(vlbu_v_h, void, ptr, ptr, tl, env, i32) | ||
62 | +DEF_HELPER_5(vlbu_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
63 | +DEF_HELPER_5(vlbu_v_w, void, ptr, ptr, tl, env, i32) | ||
64 | +DEF_HELPER_5(vlbu_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
65 | +DEF_HELPER_5(vlbu_v_d, void, ptr, ptr, tl, env, i32) | ||
66 | +DEF_HELPER_5(vlbu_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
67 | +DEF_HELPER_5(vlhu_v_h, void, ptr, ptr, tl, env, i32) | ||
68 | +DEF_HELPER_5(vlhu_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
69 | +DEF_HELPER_5(vlhu_v_w, void, ptr, ptr, tl, env, i32) | ||
70 | +DEF_HELPER_5(vlhu_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
71 | +DEF_HELPER_5(vlhu_v_d, void, ptr, ptr, tl, env, i32) | ||
72 | +DEF_HELPER_5(vlhu_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
73 | +DEF_HELPER_5(vlwu_v_w, void, ptr, ptr, tl, env, i32) | ||
74 | +DEF_HELPER_5(vlwu_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
75 | +DEF_HELPER_5(vlwu_v_d, void, ptr, ptr, tl, env, i32) | ||
76 | +DEF_HELPER_5(vlwu_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
77 | +DEF_HELPER_5(vsb_v_b, void, ptr, ptr, tl, env, i32) | ||
78 | +DEF_HELPER_5(vsb_v_b_mask, void, ptr, ptr, tl, env, i32) | ||
79 | +DEF_HELPER_5(vsb_v_h, void, ptr, ptr, tl, env, i32) | ||
80 | +DEF_HELPER_5(vsb_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
81 | +DEF_HELPER_5(vsb_v_w, void, ptr, ptr, tl, env, i32) | ||
82 | +DEF_HELPER_5(vsb_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
83 | +DEF_HELPER_5(vsb_v_d, void, ptr, ptr, tl, env, i32) | ||
84 | +DEF_HELPER_5(vsb_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
85 | +DEF_HELPER_5(vsh_v_h, void, ptr, ptr, tl, env, i32) | ||
86 | +DEF_HELPER_5(vsh_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
87 | +DEF_HELPER_5(vsh_v_w, void, ptr, ptr, tl, env, i32) | ||
88 | +DEF_HELPER_5(vsh_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
89 | +DEF_HELPER_5(vsh_v_d, void, ptr, ptr, tl, env, i32) | ||
90 | +DEF_HELPER_5(vsh_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
91 | +DEF_HELPER_5(vsw_v_w, void, ptr, ptr, tl, env, i32) | ||
92 | +DEF_HELPER_5(vsw_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
93 | +DEF_HELPER_5(vsw_v_d, void, ptr, ptr, tl, env, i32) | ||
94 | +DEF_HELPER_5(vsw_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
95 | +DEF_HELPER_5(vse_v_b, void, ptr, ptr, tl, env, i32) | ||
96 | +DEF_HELPER_5(vse_v_b_mask, void, ptr, ptr, tl, env, i32) | ||
97 | +DEF_HELPER_5(vse_v_h, void, ptr, ptr, tl, env, i32) | ||
98 | +DEF_HELPER_5(vse_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
99 | +DEF_HELPER_5(vse_v_w, void, ptr, ptr, tl, env, i32) | ||
100 | +DEF_HELPER_5(vse_v_w_mask, void, ptr, ptr, tl, env, i32) | ||
101 | +DEF_HELPER_5(vse_v_d, void, ptr, ptr, tl, env, i32) | ||
102 | +DEF_HELPER_5(vse_v_d_mask, void, ptr, ptr, tl, env, i32) | ||
103 | +DEF_HELPER_6(vlsb_v_b, void, ptr, ptr, tl, tl, env, i32) | ||
104 | +DEF_HELPER_6(vlsb_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
105 | +DEF_HELPER_6(vlsb_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
106 | +DEF_HELPER_6(vlsb_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
107 | +DEF_HELPER_6(vlsh_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
108 | +DEF_HELPER_6(vlsh_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
109 | +DEF_HELPER_6(vlsh_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
110 | +DEF_HELPER_6(vlsw_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
111 | +DEF_HELPER_6(vlsw_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
112 | +DEF_HELPER_6(vlse_v_b, void, ptr, ptr, tl, tl, env, i32) | ||
113 | +DEF_HELPER_6(vlse_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
114 | +DEF_HELPER_6(vlse_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
115 | +DEF_HELPER_6(vlse_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
116 | +DEF_HELPER_6(vlsbu_v_b, void, ptr, ptr, tl, tl, env, i32) | ||
117 | +DEF_HELPER_6(vlsbu_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
118 | +DEF_HELPER_6(vlsbu_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
119 | +DEF_HELPER_6(vlsbu_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
120 | +DEF_HELPER_6(vlshu_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
121 | +DEF_HELPER_6(vlshu_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
122 | +DEF_HELPER_6(vlshu_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
123 | +DEF_HELPER_6(vlswu_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
124 | +DEF_HELPER_6(vlswu_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
125 | +DEF_HELPER_6(vssb_v_b, void, ptr, ptr, tl, tl, env, i32) | ||
126 | +DEF_HELPER_6(vssb_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
127 | +DEF_HELPER_6(vssb_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
128 | +DEF_HELPER_6(vssb_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
129 | +DEF_HELPER_6(vssh_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
130 | +DEF_HELPER_6(vssh_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
131 | +DEF_HELPER_6(vssh_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
132 | +DEF_HELPER_6(vssw_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
133 | +DEF_HELPER_6(vssw_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
134 | +DEF_HELPER_6(vsse_v_b, void, ptr, ptr, tl, tl, env, i32) | ||
135 | +DEF_HELPER_6(vsse_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
136 | +DEF_HELPER_6(vsse_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
137 | +DEF_HELPER_6(vsse_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
138 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | ||
139 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
140 | --- a/target/riscv/internals.h | 50 | --- a/target/riscv/tcg/tcg-cpu.h |
141 | +++ b/target/riscv/internals.h | 51 | +++ b/target/riscv/tcg/tcg-cpu.h |
142 | @@ -XXX,XX +XXX,XX @@ | 52 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp); |
143 | 53 | void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp); | |
144 | #include "hw/registerfields.h" | 54 | bool riscv_cpu_tcg_compatible(RISCVCPU *cpu); |
145 | 55 | ||
146 | +/* share data between vector helpers and decode code */ | 56 | +struct DisasContext; |
147 | +FIELD(VDATA, MLEN, 0, 8) | 57 | +struct RISCVCPUConfig; |
148 | +FIELD(VDATA, VM, 8, 1) | 58 | +typedef struct RISCVDecoder { |
149 | +FIELD(VDATA, LMUL, 9, 2) | 59 | + bool (*guard_func)(const struct RISCVCPUConfig *); |
150 | +FIELD(VDATA, NF, 11, 4) | 60 | + bool (*riscv_cpu_decode_fn)(struct DisasContext *, uint32_t); |
61 | +} RISCVDecoder; | ||
62 | + | ||
63 | +typedef bool (*riscv_cpu_decode_fn)(struct DisasContext *, uint32_t); | ||
64 | + | ||
65 | +extern const size_t decoder_table_size; | ||
66 | + | ||
67 | +extern const RISCVDecoder decoder_table[]; | ||
68 | + | ||
69 | +void riscv_tcg_cpu_finalize_dynamic_decoder(RISCVCPU *cpu); | ||
70 | + | ||
151 | #endif | 71 | #endif |
152 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 72 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
153 | index XXXXXXX..XXXXXXX 100644 | 73 | index XXXXXXX..XXXXXXX 100644 |
154 | --- a/target/riscv/insn32.decode | 74 | --- a/target/riscv/cpu.c |
155 | +++ b/target/riscv/insn32.decode | 75 | +++ b/target/riscv/cpu.c |
156 | @@ -XXX,XX +XXX,XX @@ | 76 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_finalize_features(RISCVCPU *cpu, Error **errp) |
157 | %sh10 20:10 | 77 | error_propagate(errp, local_err); |
158 | %csr 20:12 | 78 | return; |
159 | %rm 12:3 | 79 | } |
160 | +%nf 29:3 !function=ex_plus_1 | 80 | + riscv_tcg_cpu_finalize_dynamic_decoder(cpu); |
161 | 81 | } else if (kvm_enabled()) { | |
162 | # immediates: | 82 | riscv_kvm_cpu_finalize_features(cpu, &local_err); |
163 | %imm_i 20:s12 | 83 | if (local_err != NULL) { |
164 | @@ -XXX,XX +XXX,XX @@ | 84 | diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c |
165 | &u imm rd | 85 | index XXXXXXX..XXXXXXX 100644 |
166 | &shift shamt rs1 rd | 86 | --- a/target/riscv/tcg/tcg-cpu.c |
167 | &atomic aq rl rs2 rs1 rd | 87 | +++ b/target/riscv/tcg/tcg-cpu.c |
168 | +&r2nfvm vm rd rs1 nf | 88 | @@ -XXX,XX +XXX,XX @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp) |
169 | +&rnfvm vm rd rs1 rs2 nf | 89 | } |
170 | 90 | } | |
171 | # Formats 32: | 91 | |
172 | @r ....... ..... ..... ... ..... ....... &r %rs2 %rs1 %rd | 92 | +void riscv_tcg_cpu_finalize_dynamic_decoder(RISCVCPU *cpu) |
173 | @@ -XXX,XX +XXX,XX @@ | 93 | +{ |
174 | @r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd | 94 | + GPtrArray *dynamic_decoders; |
175 | @r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd | 95 | + dynamic_decoders = g_ptr_array_sized_new(decoder_table_size); |
176 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | 96 | + for (size_t i = 0; i < decoder_table_size; ++i) { |
177 | +@r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | 97 | + if (decoder_table[i].guard_func && |
178 | +@r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | 98 | + decoder_table[i].guard_func(&cpu->cfg)) { |
179 | @r2_zimm . zimm:11 ..... ... ..... ....... %rs1 %rd | 99 | + g_ptr_array_add(dynamic_decoders, |
180 | 100 | + (gpointer)decoder_table[i].riscv_cpu_decode_fn); | |
181 | @hfence_gvma ....... ..... ..... ... ..... ....... %rs2 %rs1 | 101 | + } |
182 | @@ -XXX,XX +XXX,XX @@ hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma | 102 | + } |
183 | hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma | ||
184 | |||
185 | # *** RV32V Extension *** | ||
186 | + | 103 | + |
187 | +# *** Vector loads and stores are encoded within LOADFP/STORE-FP *** | 104 | + cpu->decoders = dynamic_decoders; |
188 | +vlb_v ... 100 . 00000 ..... 000 ..... 0000111 @r2_nfvm | ||
189 | +vlh_v ... 100 . 00000 ..... 101 ..... 0000111 @r2_nfvm | ||
190 | +vlw_v ... 100 . 00000 ..... 110 ..... 0000111 @r2_nfvm | ||
191 | +vle_v ... 000 . 00000 ..... 111 ..... 0000111 @r2_nfvm | ||
192 | +vlbu_v ... 000 . 00000 ..... 000 ..... 0000111 @r2_nfvm | ||
193 | +vlhu_v ... 000 . 00000 ..... 101 ..... 0000111 @r2_nfvm | ||
194 | +vlwu_v ... 000 . 00000 ..... 110 ..... 0000111 @r2_nfvm | ||
195 | +vsb_v ... 000 . 00000 ..... 000 ..... 0100111 @r2_nfvm | ||
196 | +vsh_v ... 000 . 00000 ..... 101 ..... 0100111 @r2_nfvm | ||
197 | +vsw_v ... 000 . 00000 ..... 110 ..... 0100111 @r2_nfvm | ||
198 | +vse_v ... 000 . 00000 ..... 111 ..... 0100111 @r2_nfvm | ||
199 | + | ||
200 | +vlsb_v ... 110 . ..... ..... 000 ..... 0000111 @r_nfvm | ||
201 | +vlsh_v ... 110 . ..... ..... 101 ..... 0000111 @r_nfvm | ||
202 | +vlsw_v ... 110 . ..... ..... 110 ..... 0000111 @r_nfvm | ||
203 | +vlse_v ... 010 . ..... ..... 111 ..... 0000111 @r_nfvm | ||
204 | +vlsbu_v ... 010 . ..... ..... 000 ..... 0000111 @r_nfvm | ||
205 | +vlshu_v ... 010 . ..... ..... 101 ..... 0000111 @r_nfvm | ||
206 | +vlswu_v ... 010 . ..... ..... 110 ..... 0000111 @r_nfvm | ||
207 | +vssb_v ... 010 . ..... ..... 000 ..... 0100111 @r_nfvm | ||
208 | +vssh_v ... 010 . ..... ..... 101 ..... 0100111 @r_nfvm | ||
209 | +vssw_v ... 010 . ..... ..... 110 ..... 0100111 @r_nfvm | ||
210 | +vsse_v ... 010 . ..... ..... 111 ..... 0100111 @r_nfvm | ||
211 | + | ||
212 | +# *** new major opcode OP-V *** | ||
213 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
214 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
215 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
216 | index XXXXXXX..XXXXXXX 100644 | ||
217 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
218 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
219 | @@ -XXX,XX +XXX,XX @@ | ||
220 | * You should have received a copy of the GNU General Public License along with | ||
221 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
222 | */ | ||
223 | +#include "tcg/tcg-op-gvec.h" | ||
224 | +#include "tcg/tcg-gvec-desc.h" | ||
225 | +#include "internals.h" | ||
226 | |||
227 | static bool trans_vsetvl(DisasContext *ctx, arg_vsetvl *a) | ||
228 | { | ||
229 | @@ -XXX,XX +XXX,XX @@ static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a) | ||
230 | tcg_temp_free(dst); | ||
231 | return true; | ||
232 | } | ||
233 | + | ||
234 | +/* vector register offset from env */ | ||
235 | +static uint32_t vreg_ofs(DisasContext *s, int reg) | ||
236 | +{ | ||
237 | + return offsetof(CPURISCVState, vreg) + reg * s->vlen / 8; | ||
238 | +} | 105 | +} |
239 | + | 106 | + |
240 | +/* check functions */ | 107 | bool riscv_cpu_tcg_compatible(RISCVCPU *cpu) |
241 | + | 108 | { |
242 | +/* | 109 | return object_dynamic_cast(OBJECT(cpu), TYPE_RISCV_CPU_HOST) == NULL; |
243 | + * In cpu_get_tb_cpu_state(), set VILL if RVV was not present. | ||
244 | + * So RVV is also be checked in this function. | ||
245 | + */ | ||
246 | +static bool vext_check_isa_ill(DisasContext *s) | ||
247 | +{ | ||
248 | + return !s->vill; | ||
249 | +} | ||
250 | + | ||
251 | +/* | ||
252 | + * There are two rules check here. | ||
253 | + * | ||
254 | + * 1. Vector register numbers are multiples of LMUL. (Section 3.2) | ||
255 | + * | ||
256 | + * 2. For all widening instructions, the destination LMUL value must also be | ||
257 | + * a supported LMUL value. (Section 11.2) | ||
258 | + */ | ||
259 | +static bool vext_check_reg(DisasContext *s, uint32_t reg, bool widen) | ||
260 | +{ | ||
261 | + /* | ||
262 | + * The destination vector register group results are arranged as if both | ||
263 | + * SEW and LMUL were at twice their current settings. (Section 11.2). | ||
264 | + */ | ||
265 | + int legal = widen ? 2 << s->lmul : 1 << s->lmul; | ||
266 | + | ||
267 | + return !((s->lmul == 0x3 && widen) || (reg % legal)); | ||
268 | +} | ||
269 | + | ||
270 | +/* | ||
271 | + * There are two rules check here. | ||
272 | + * | ||
273 | + * 1. The destination vector register group for a masked vector instruction can | ||
274 | + * only overlap the source mask register (v0) when LMUL=1. (Section 5.3) | ||
275 | + * | ||
276 | + * 2. In widen instructions and some other insturctions, like vslideup.vx, | ||
277 | + * there is no need to check whether LMUL=1. | ||
278 | + */ | ||
279 | +static bool vext_check_overlap_mask(DisasContext *s, uint32_t vd, bool vm, | ||
280 | + bool force) | ||
281 | +{ | ||
282 | + return (vm != 0 || vd != 0) || (!force && (s->lmul == 0)); | ||
283 | +} | ||
284 | + | ||
285 | +/* The LMUL setting must be such that LMUL * NFIELDS <= 8. (Section 7.8) */ | ||
286 | +static bool vext_check_nf(DisasContext *s, uint32_t nf) | ||
287 | +{ | ||
288 | + return (1 << s->lmul) * nf <= 8; | ||
289 | +} | ||
290 | + | ||
291 | +/* common translation macro */ | ||
292 | +#define GEN_VEXT_TRANS(NAME, SEQ, ARGTYPE, OP, CHECK) \ | ||
293 | +static bool trans_##NAME(DisasContext *s, arg_##ARGTYPE *a)\ | ||
294 | +{ \ | ||
295 | + if (CHECK(s, a)) { \ | ||
296 | + return OP(s, a, SEQ); \ | ||
297 | + } \ | ||
298 | + return false; \ | ||
299 | +} | ||
300 | + | ||
301 | +/* | ||
302 | + *** unit stride load and store | ||
303 | + */ | ||
304 | +typedef void gen_helper_ldst_us(TCGv_ptr, TCGv_ptr, TCGv, | ||
305 | + TCGv_env, TCGv_i32); | ||
306 | + | ||
307 | +static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data, | ||
308 | + gen_helper_ldst_us *fn, DisasContext *s) | ||
309 | +{ | ||
310 | + TCGv_ptr dest, mask; | ||
311 | + TCGv base; | ||
312 | + TCGv_i32 desc; | ||
313 | + | ||
314 | + TCGLabel *over = gen_new_label(); | ||
315 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
316 | + | ||
317 | + dest = tcg_temp_new_ptr(); | ||
318 | + mask = tcg_temp_new_ptr(); | ||
319 | + base = tcg_temp_new(); | ||
320 | + | ||
321 | + /* | ||
322 | + * As simd_desc supports at most 256 bytes, and in this implementation, | ||
323 | + * the max vector group length is 2048 bytes. So split it into two parts. | ||
324 | + * | ||
325 | + * The first part is vlen in bytes, encoded in maxsz of simd_desc. | ||
326 | + * The second part is lmul, encoded in data of simd_desc. | ||
327 | + */ | ||
328 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
329 | + | ||
330 | + gen_get_gpr(base, rs1); | ||
331 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
332 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
333 | + | ||
334 | + fn(dest, mask, base, cpu_env, desc); | ||
335 | + | ||
336 | + tcg_temp_free_ptr(dest); | ||
337 | + tcg_temp_free_ptr(mask); | ||
338 | + tcg_temp_free(base); | ||
339 | + tcg_temp_free_i32(desc); | ||
340 | + gen_set_label(over); | ||
341 | + return true; | ||
342 | +} | ||
343 | + | ||
344 | +static bool ld_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) | ||
345 | +{ | ||
346 | + uint32_t data = 0; | ||
347 | + gen_helper_ldst_us *fn; | ||
348 | + static gen_helper_ldst_us * const fns[2][7][4] = { | ||
349 | + /* masked unit stride load */ | ||
350 | + { { gen_helper_vlb_v_b_mask, gen_helper_vlb_v_h_mask, | ||
351 | + gen_helper_vlb_v_w_mask, gen_helper_vlb_v_d_mask }, | ||
352 | + { NULL, gen_helper_vlh_v_h_mask, | ||
353 | + gen_helper_vlh_v_w_mask, gen_helper_vlh_v_d_mask }, | ||
354 | + { NULL, NULL, | ||
355 | + gen_helper_vlw_v_w_mask, gen_helper_vlw_v_d_mask }, | ||
356 | + { gen_helper_vle_v_b_mask, gen_helper_vle_v_h_mask, | ||
357 | + gen_helper_vle_v_w_mask, gen_helper_vle_v_d_mask }, | ||
358 | + { gen_helper_vlbu_v_b_mask, gen_helper_vlbu_v_h_mask, | ||
359 | + gen_helper_vlbu_v_w_mask, gen_helper_vlbu_v_d_mask }, | ||
360 | + { NULL, gen_helper_vlhu_v_h_mask, | ||
361 | + gen_helper_vlhu_v_w_mask, gen_helper_vlhu_v_d_mask }, | ||
362 | + { NULL, NULL, | ||
363 | + gen_helper_vlwu_v_w_mask, gen_helper_vlwu_v_d_mask } }, | ||
364 | + /* unmasked unit stride load */ | ||
365 | + { { gen_helper_vlb_v_b, gen_helper_vlb_v_h, | ||
366 | + gen_helper_vlb_v_w, gen_helper_vlb_v_d }, | ||
367 | + { NULL, gen_helper_vlh_v_h, | ||
368 | + gen_helper_vlh_v_w, gen_helper_vlh_v_d }, | ||
369 | + { NULL, NULL, | ||
370 | + gen_helper_vlw_v_w, gen_helper_vlw_v_d }, | ||
371 | + { gen_helper_vle_v_b, gen_helper_vle_v_h, | ||
372 | + gen_helper_vle_v_w, gen_helper_vle_v_d }, | ||
373 | + { gen_helper_vlbu_v_b, gen_helper_vlbu_v_h, | ||
374 | + gen_helper_vlbu_v_w, gen_helper_vlbu_v_d }, | ||
375 | + { NULL, gen_helper_vlhu_v_h, | ||
376 | + gen_helper_vlhu_v_w, gen_helper_vlhu_v_d }, | ||
377 | + { NULL, NULL, | ||
378 | + gen_helper_vlwu_v_w, gen_helper_vlwu_v_d } } | ||
379 | + }; | ||
380 | + | ||
381 | + fn = fns[a->vm][seq][s->sew]; | ||
382 | + if (fn == NULL) { | ||
383 | + return false; | ||
384 | + } | ||
385 | + | ||
386 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
387 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
388 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
389 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | ||
390 | + return ldst_us_trans(a->rd, a->rs1, data, fn, s); | ||
391 | +} | ||
392 | + | ||
393 | +static bool ld_us_check(DisasContext *s, arg_r2nfvm* a) | ||
394 | +{ | ||
395 | + return (vext_check_isa_ill(s) && | ||
396 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
397 | + vext_check_reg(s, a->rd, false) && | ||
398 | + vext_check_nf(s, a->nf)); | ||
399 | +} | ||
400 | + | ||
401 | +GEN_VEXT_TRANS(vlb_v, 0, r2nfvm, ld_us_op, ld_us_check) | ||
402 | +GEN_VEXT_TRANS(vlh_v, 1, r2nfvm, ld_us_op, ld_us_check) | ||
403 | +GEN_VEXT_TRANS(vlw_v, 2, r2nfvm, ld_us_op, ld_us_check) | ||
404 | +GEN_VEXT_TRANS(vle_v, 3, r2nfvm, ld_us_op, ld_us_check) | ||
405 | +GEN_VEXT_TRANS(vlbu_v, 4, r2nfvm, ld_us_op, ld_us_check) | ||
406 | +GEN_VEXT_TRANS(vlhu_v, 5, r2nfvm, ld_us_op, ld_us_check) | ||
407 | +GEN_VEXT_TRANS(vlwu_v, 6, r2nfvm, ld_us_op, ld_us_check) | ||
408 | + | ||
409 | +static bool st_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) | ||
410 | +{ | ||
411 | + uint32_t data = 0; | ||
412 | + gen_helper_ldst_us *fn; | ||
413 | + static gen_helper_ldst_us * const fns[2][4][4] = { | ||
414 | + /* masked unit stride load and store */ | ||
415 | + { { gen_helper_vsb_v_b_mask, gen_helper_vsb_v_h_mask, | ||
416 | + gen_helper_vsb_v_w_mask, gen_helper_vsb_v_d_mask }, | ||
417 | + { NULL, gen_helper_vsh_v_h_mask, | ||
418 | + gen_helper_vsh_v_w_mask, gen_helper_vsh_v_d_mask }, | ||
419 | + { NULL, NULL, | ||
420 | + gen_helper_vsw_v_w_mask, gen_helper_vsw_v_d_mask }, | ||
421 | + { gen_helper_vse_v_b_mask, gen_helper_vse_v_h_mask, | ||
422 | + gen_helper_vse_v_w_mask, gen_helper_vse_v_d_mask } }, | ||
423 | + /* unmasked unit stride store */ | ||
424 | + { { gen_helper_vsb_v_b, gen_helper_vsb_v_h, | ||
425 | + gen_helper_vsb_v_w, gen_helper_vsb_v_d }, | ||
426 | + { NULL, gen_helper_vsh_v_h, | ||
427 | + gen_helper_vsh_v_w, gen_helper_vsh_v_d }, | ||
428 | + { NULL, NULL, | ||
429 | + gen_helper_vsw_v_w, gen_helper_vsw_v_d }, | ||
430 | + { gen_helper_vse_v_b, gen_helper_vse_v_h, | ||
431 | + gen_helper_vse_v_w, gen_helper_vse_v_d } } | ||
432 | + }; | ||
433 | + | ||
434 | + fn = fns[a->vm][seq][s->sew]; | ||
435 | + if (fn == NULL) { | ||
436 | + return false; | ||
437 | + } | ||
438 | + | ||
439 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
440 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
441 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
442 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | ||
443 | + return ldst_us_trans(a->rd, a->rs1, data, fn, s); | ||
444 | +} | ||
445 | + | ||
446 | +static bool st_us_check(DisasContext *s, arg_r2nfvm* a) | ||
447 | +{ | ||
448 | + return (vext_check_isa_ill(s) && | ||
449 | + vext_check_reg(s, a->rd, false) && | ||
450 | + vext_check_nf(s, a->nf)); | ||
451 | +} | ||
452 | + | ||
453 | +GEN_VEXT_TRANS(vsb_v, 0, r2nfvm, st_us_op, st_us_check) | ||
454 | +GEN_VEXT_TRANS(vsh_v, 1, r2nfvm, st_us_op, st_us_check) | ||
455 | +GEN_VEXT_TRANS(vsw_v, 2, r2nfvm, st_us_op, st_us_check) | ||
456 | +GEN_VEXT_TRANS(vse_v, 3, r2nfvm, st_us_op, st_us_check) | ||
457 | + | ||
458 | +/* | ||
459 | + *** stride load and store | ||
460 | + */ | ||
461 | +typedef void gen_helper_ldst_stride(TCGv_ptr, TCGv_ptr, TCGv, | ||
462 | + TCGv, TCGv_env, TCGv_i32); | ||
463 | + | ||
464 | +static bool ldst_stride_trans(uint32_t vd, uint32_t rs1, uint32_t rs2, | ||
465 | + uint32_t data, gen_helper_ldst_stride *fn, | ||
466 | + DisasContext *s) | ||
467 | +{ | ||
468 | + TCGv_ptr dest, mask; | ||
469 | + TCGv base, stride; | ||
470 | + TCGv_i32 desc; | ||
471 | + | ||
472 | + TCGLabel *over = gen_new_label(); | ||
473 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
474 | + | ||
475 | + dest = tcg_temp_new_ptr(); | ||
476 | + mask = tcg_temp_new_ptr(); | ||
477 | + base = tcg_temp_new(); | ||
478 | + stride = tcg_temp_new(); | ||
479 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
480 | + | ||
481 | + gen_get_gpr(base, rs1); | ||
482 | + gen_get_gpr(stride, rs2); | ||
483 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
484 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
485 | + | ||
486 | + fn(dest, mask, base, stride, cpu_env, desc); | ||
487 | + | ||
488 | + tcg_temp_free_ptr(dest); | ||
489 | + tcg_temp_free_ptr(mask); | ||
490 | + tcg_temp_free(base); | ||
491 | + tcg_temp_free(stride); | ||
492 | + tcg_temp_free_i32(desc); | ||
493 | + gen_set_label(over); | ||
494 | + return true; | ||
495 | +} | ||
496 | + | ||
497 | +static bool ld_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) | ||
498 | +{ | ||
499 | + uint32_t data = 0; | ||
500 | + gen_helper_ldst_stride *fn; | ||
501 | + static gen_helper_ldst_stride * const fns[7][4] = { | ||
502 | + { gen_helper_vlsb_v_b, gen_helper_vlsb_v_h, | ||
503 | + gen_helper_vlsb_v_w, gen_helper_vlsb_v_d }, | ||
504 | + { NULL, gen_helper_vlsh_v_h, | ||
505 | + gen_helper_vlsh_v_w, gen_helper_vlsh_v_d }, | ||
506 | + { NULL, NULL, | ||
507 | + gen_helper_vlsw_v_w, gen_helper_vlsw_v_d }, | ||
508 | + { gen_helper_vlse_v_b, gen_helper_vlse_v_h, | ||
509 | + gen_helper_vlse_v_w, gen_helper_vlse_v_d }, | ||
510 | + { gen_helper_vlsbu_v_b, gen_helper_vlsbu_v_h, | ||
511 | + gen_helper_vlsbu_v_w, gen_helper_vlsbu_v_d }, | ||
512 | + { NULL, gen_helper_vlshu_v_h, | ||
513 | + gen_helper_vlshu_v_w, gen_helper_vlshu_v_d }, | ||
514 | + { NULL, NULL, | ||
515 | + gen_helper_vlswu_v_w, gen_helper_vlswu_v_d }, | ||
516 | + }; | ||
517 | + | ||
518 | + fn = fns[seq][s->sew]; | ||
519 | + if (fn == NULL) { | ||
520 | + return false; | ||
521 | + } | ||
522 | + | ||
523 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
524 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
525 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
526 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | ||
527 | + return ldst_stride_trans(a->rd, a->rs1, a->rs2, data, fn, s); | ||
528 | +} | ||
529 | + | ||
530 | +static bool ld_stride_check(DisasContext *s, arg_rnfvm* a) | ||
531 | +{ | ||
532 | + return (vext_check_isa_ill(s) && | ||
533 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
534 | + vext_check_reg(s, a->rd, false) && | ||
535 | + vext_check_nf(s, a->nf)); | ||
536 | +} | ||
537 | + | ||
538 | +GEN_VEXT_TRANS(vlsb_v, 0, rnfvm, ld_stride_op, ld_stride_check) | ||
539 | +GEN_VEXT_TRANS(vlsh_v, 1, rnfvm, ld_stride_op, ld_stride_check) | ||
540 | +GEN_VEXT_TRANS(vlsw_v, 2, rnfvm, ld_stride_op, ld_stride_check) | ||
541 | +GEN_VEXT_TRANS(vlse_v, 3, rnfvm, ld_stride_op, ld_stride_check) | ||
542 | +GEN_VEXT_TRANS(vlsbu_v, 4, rnfvm, ld_stride_op, ld_stride_check) | ||
543 | +GEN_VEXT_TRANS(vlshu_v, 5, rnfvm, ld_stride_op, ld_stride_check) | ||
544 | +GEN_VEXT_TRANS(vlswu_v, 6, rnfvm, ld_stride_op, ld_stride_check) | ||
545 | + | ||
546 | +static bool st_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) | ||
547 | +{ | ||
548 | + uint32_t data = 0; | ||
549 | + gen_helper_ldst_stride *fn; | ||
550 | + static gen_helper_ldst_stride * const fns[4][4] = { | ||
551 | + /* masked stride store */ | ||
552 | + { gen_helper_vssb_v_b, gen_helper_vssb_v_h, | ||
553 | + gen_helper_vssb_v_w, gen_helper_vssb_v_d }, | ||
554 | + { NULL, gen_helper_vssh_v_h, | ||
555 | + gen_helper_vssh_v_w, gen_helper_vssh_v_d }, | ||
556 | + { NULL, NULL, | ||
557 | + gen_helper_vssw_v_w, gen_helper_vssw_v_d }, | ||
558 | + { gen_helper_vsse_v_b, gen_helper_vsse_v_h, | ||
559 | + gen_helper_vsse_v_w, gen_helper_vsse_v_d } | ||
560 | + }; | ||
561 | + | ||
562 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
563 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
564 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
565 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | ||
566 | + fn = fns[seq][s->sew]; | ||
567 | + if (fn == NULL) { | ||
568 | + return false; | ||
569 | + } | ||
570 | + | ||
571 | + return ldst_stride_trans(a->rd, a->rs1, a->rs2, data, fn, s); | ||
572 | +} | ||
573 | + | ||
574 | +static bool st_stride_check(DisasContext *s, arg_rnfvm* a) | ||
575 | +{ | ||
576 | + return (vext_check_isa_ill(s) && | ||
577 | + vext_check_reg(s, a->rd, false) && | ||
578 | + vext_check_nf(s, a->nf)); | ||
579 | +} | ||
580 | + | ||
581 | +GEN_VEXT_TRANS(vssb_v, 0, rnfvm, st_stride_op, st_stride_check) | ||
582 | +GEN_VEXT_TRANS(vssh_v, 1, rnfvm, st_stride_op, st_stride_check) | ||
583 | +GEN_VEXT_TRANS(vssw_v, 2, rnfvm, st_stride_op, st_stride_check) | ||
584 | +GEN_VEXT_TRANS(vsse_v, 3, rnfvm, st_stride_op, st_stride_check) | ||
585 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | 110 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c |
586 | index XXXXXXX..XXXXXXX 100644 | 111 | index XXXXXXX..XXXXXXX 100644 |
587 | --- a/target/riscv/translate.c | 112 | --- a/target/riscv/translate.c |
588 | +++ b/target/riscv/translate.c | 113 | +++ b/target/riscv/translate.c |
114 | @@ -XXX,XX +XXX,XX @@ | ||
115 | #include "exec/helper-info.c.inc" | ||
116 | #undef HELPER_H | ||
117 | |||
118 | +#include "tcg/tcg-cpu.h" | ||
119 | + | ||
120 | /* global register indices */ | ||
121 | static TCGv cpu_gpr[32], cpu_gprh[32], cpu_pc, cpu_vl, cpu_vstart; | ||
122 | static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */ | ||
589 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 123 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
590 | uint8_t lmul; | 124 | /* FRM is known to contain a valid value. */ |
591 | uint8_t sew; | 125 | bool frm_valid; |
592 | uint16_t vlen; | 126 | bool insn_start_updated; |
593 | + uint16_t mlen; | 127 | + const GPtrArray *decoders; |
594 | bool vl_eq_vlmax; | ||
595 | } DisasContext; | 128 | } DisasContext; |
596 | 129 | ||
597 | @@ -XXX,XX +XXX,XX @@ static void decode_RV32_64C(DisasContext *ctx, uint16_t opcode) | 130 | static inline bool has_ext(DisasContext *ctx, uint32_t ext) |
598 | } | 131 | @@ -XXX,XX +XXX,XX @@ static inline int insn_len(uint16_t first_word) |
132 | return (first_word & 3) == 3 ? 4 : 2; | ||
599 | } | 133 | } |
600 | 134 | ||
601 | +static int ex_plus_1(DisasContext *ctx, int nf) | 135 | +const RISCVDecoder decoder_table[] = { |
602 | +{ | 136 | + { always_true_p, decode_insn32 }, |
603 | + return nf + 1; | 137 | + { has_xthead_p, decode_xthead}, |
604 | +} | 138 | + { has_XVentanaCondOps_p, decode_XVentanaCodeOps}, |
139 | +}; | ||
605 | + | 140 | + |
606 | #define EX_SH(amount) \ | 141 | +const size_t decoder_table_size = ARRAY_SIZE(decoder_table); |
607 | static int ex_shift_##amount(DisasContext *ctx, int imm) \ | 142 | + |
608 | { \ | 143 | static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) |
144 | { | ||
145 | - /* | ||
146 | - * A table with predicate (i.e., guard) functions and decoder functions | ||
147 | - * that are tested in-order until a decoder matches onto the opcode. | ||
148 | - */ | ||
149 | - static const struct { | ||
150 | - bool (*guard_func)(const RISCVCPUConfig *); | ||
151 | - bool (*decode_func)(DisasContext *, uint32_t); | ||
152 | - } decoders[] = { | ||
153 | - { always_true_p, decode_insn32 }, | ||
154 | - { has_xthead_p, decode_xthead }, | ||
155 | - { has_XVentanaCondOps_p, decode_XVentanaCodeOps }, | ||
156 | - }; | ||
157 | - | ||
158 | ctx->virt_inst_excp = false; | ||
159 | ctx->cur_insn_len = insn_len(opcode); | ||
160 | /* Check for compressed insn */ | ||
161 | @@ -XXX,XX +XXX,XX @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) | ||
162 | ctx->base.pc_next + 2)); | ||
163 | ctx->opcode = opcode32; | ||
164 | |||
165 | - for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i) { | ||
166 | - if (decoders[i].guard_func(ctx->cfg_ptr) && | ||
167 | - decoders[i].decode_func(ctx, opcode32)) { | ||
168 | + for (guint i = 0; i < ctx->decoders->len; ++i) { | ||
169 | + riscv_cpu_decode_fn func = g_ptr_array_index(ctx->decoders, i); | ||
170 | + if (func(ctx, opcode32)) { | ||
171 | return; | ||
172 | } | ||
173 | } | ||
609 | @@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 174 | @@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) |
610 | ctx->vill = FIELD_EX32(tb_flags, TB_FLAGS, VILL); | 175 | ctx->itrigger = FIELD_EX32(tb_flags, TB_FLAGS, ITRIGGER); |
611 | ctx->sew = FIELD_EX32(tb_flags, TB_FLAGS, SEW); | 176 | ctx->zero = tcg_constant_tl(0); |
612 | ctx->lmul = FIELD_EX32(tb_flags, TB_FLAGS, LMUL); | 177 | ctx->virt_inst_excp = false; |
613 | + ctx->mlen = 1 << (ctx->sew + 3 - ctx->lmul); | 178 | + ctx->decoders = cpu->decoders; |
614 | ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); | ||
615 | } | 179 | } |
616 | 180 | ||
617 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | 181 | static void riscv_tr_tb_start(DisasContextBase *db, CPUState *cpu) |
618 | index XXXXXXX..XXXXXXX 100644 | ||
619 | --- a/target/riscv/vector_helper.c | ||
620 | +++ b/target/riscv/vector_helper.c | ||
621 | @@ -XXX,XX +XXX,XX @@ | ||
622 | |||
623 | #include "qemu/osdep.h" | ||
624 | #include "cpu.h" | ||
625 | +#include "exec/memop.h" | ||
626 | #include "exec/exec-all.h" | ||
627 | #include "exec/helper-proto.h" | ||
628 | +#include "tcg/tcg-gvec-desc.h" | ||
629 | +#include "internals.h" | ||
630 | #include <math.h> | ||
631 | |||
632 | target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, | ||
633 | @@ -XXX,XX +XXX,XX @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, | ||
634 | env->vstart = 0; | ||
635 | return vl; | ||
636 | } | ||
637 | + | ||
638 | +/* | ||
639 | + * Note that vector data is stored in host-endian 64-bit chunks, | ||
640 | + * so addressing units smaller than that needs a host-endian fixup. | ||
641 | + */ | ||
642 | +#ifdef HOST_WORDS_BIGENDIAN | ||
643 | +#define H1(x) ((x) ^ 7) | ||
644 | +#define H1_2(x) ((x) ^ 6) | ||
645 | +#define H1_4(x) ((x) ^ 4) | ||
646 | +#define H2(x) ((x) ^ 3) | ||
647 | +#define H4(x) ((x) ^ 1) | ||
648 | +#define H8(x) ((x)) | ||
649 | +#else | ||
650 | +#define H1(x) (x) | ||
651 | +#define H1_2(x) (x) | ||
652 | +#define H1_4(x) (x) | ||
653 | +#define H2(x) (x) | ||
654 | +#define H4(x) (x) | ||
655 | +#define H8(x) (x) | ||
656 | +#endif | ||
657 | + | ||
658 | +static inline uint32_t vext_nf(uint32_t desc) | ||
659 | +{ | ||
660 | + return FIELD_EX32(simd_data(desc), VDATA, NF); | ||
661 | +} | ||
662 | + | ||
663 | +static inline uint32_t vext_mlen(uint32_t desc) | ||
664 | +{ | ||
665 | + return FIELD_EX32(simd_data(desc), VDATA, MLEN); | ||
666 | +} | ||
667 | + | ||
668 | +static inline uint32_t vext_vm(uint32_t desc) | ||
669 | +{ | ||
670 | + return FIELD_EX32(simd_data(desc), VDATA, VM); | ||
671 | +} | ||
672 | + | ||
673 | +static inline uint32_t vext_lmul(uint32_t desc) | ||
674 | +{ | ||
675 | + return FIELD_EX32(simd_data(desc), VDATA, LMUL); | ||
676 | +} | ||
677 | + | ||
678 | +/* | ||
679 | + * Get vector group length in bytes. Its range is [64, 2048]. | ||
680 | + * | ||
681 | + * As simd_desc support at most 256, the max vlen is 512 bits. | ||
682 | + * So vlen in bytes is encoded as maxsz. | ||
683 | + */ | ||
684 | +static inline uint32_t vext_maxsz(uint32_t desc) | ||
685 | +{ | ||
686 | + return simd_maxsz(desc) << vext_lmul(desc); | ||
687 | +} | ||
688 | + | ||
689 | +/* | ||
690 | + * This function checks watchpoint before real load operation. | ||
691 | + * | ||
692 | + * In softmmu mode, the TLB API probe_access is enough for watchpoint check. | ||
693 | + * In user mode, there is no watchpoint support now. | ||
694 | + * | ||
695 | + * It will trigger an exception if there is no mapping in TLB | ||
696 | + * and page table walk can't fill the TLB entry. Then the guest | ||
697 | + * software can return here after process the exception or never return. | ||
698 | + */ | ||
699 | +static void probe_pages(CPURISCVState *env, target_ulong addr, | ||
700 | + target_ulong len, uintptr_t ra, | ||
701 | + MMUAccessType access_type) | ||
702 | +{ | ||
703 | + target_ulong pagelen = -(addr | TARGET_PAGE_MASK); | ||
704 | + target_ulong curlen = MIN(pagelen, len); | ||
705 | + | ||
706 | + probe_access(env, addr, curlen, access_type, | ||
707 | + cpu_mmu_index(env, false), ra); | ||
708 | + if (len > curlen) { | ||
709 | + addr += curlen; | ||
710 | + curlen = len - curlen; | ||
711 | + probe_access(env, addr, curlen, access_type, | ||
712 | + cpu_mmu_index(env, false), ra); | ||
713 | + } | ||
714 | +} | ||
715 | + | ||
716 | +#ifdef HOST_WORDS_BIGENDIAN | ||
717 | +static void vext_clear(void *tail, uint32_t cnt, uint32_t tot) | ||
718 | +{ | ||
719 | + /* | ||
720 | + * Split the remaining range to two parts. | ||
721 | + * The first part is in the last uint64_t unit. | ||
722 | + * The second part start from the next uint64_t unit. | ||
723 | + */ | ||
724 | + int part1 = 0, part2 = tot - cnt; | ||
725 | + if (cnt % 8) { | ||
726 | + part1 = 8 - (cnt % 8); | ||
727 | + part2 = tot - cnt - part1; | ||
728 | + memset(tail & ~(7ULL), 0, part1); | ||
729 | + memset((tail + 8) & ~(7ULL), 0, part2); | ||
730 | + } else { | ||
731 | + memset(tail, 0, part2); | ||
732 | + } | ||
733 | +} | ||
734 | +#else | ||
735 | +static void vext_clear(void *tail, uint32_t cnt, uint32_t tot) | ||
736 | +{ | ||
737 | + memset(tail, 0, tot - cnt); | ||
738 | +} | ||
739 | +#endif | ||
740 | + | ||
741 | +static void clearb(void *vd, uint32_t idx, uint32_t cnt, uint32_t tot) | ||
742 | +{ | ||
743 | + int8_t *cur = ((int8_t *)vd + H1(idx)); | ||
744 | + vext_clear(cur, cnt, tot); | ||
745 | +} | ||
746 | + | ||
747 | +static void clearh(void *vd, uint32_t idx, uint32_t cnt, uint32_t tot) | ||
748 | +{ | ||
749 | + int16_t *cur = ((int16_t *)vd + H2(idx)); | ||
750 | + vext_clear(cur, cnt, tot); | ||
751 | +} | ||
752 | + | ||
753 | +static void clearl(void *vd, uint32_t idx, uint32_t cnt, uint32_t tot) | ||
754 | +{ | ||
755 | + int32_t *cur = ((int32_t *)vd + H4(idx)); | ||
756 | + vext_clear(cur, cnt, tot); | ||
757 | +} | ||
758 | + | ||
759 | +static void clearq(void *vd, uint32_t idx, uint32_t cnt, uint32_t tot) | ||
760 | +{ | ||
761 | + int64_t *cur = (int64_t *)vd + idx; | ||
762 | + vext_clear(cur, cnt, tot); | ||
763 | +} | ||
764 | + | ||
765 | + | ||
766 | +static inline int vext_elem_mask(void *v0, int mlen, int index) | ||
767 | +{ | ||
768 | + int idx = (index * mlen) / 64; | ||
769 | + int pos = (index * mlen) % 64; | ||
770 | + return (((uint64_t *)v0)[idx] >> pos) & 1; | ||
771 | +} | ||
772 | + | ||
773 | +/* elements operations for load and store */ | ||
774 | +typedef void vext_ldst_elem_fn(CPURISCVState *env, target_ulong addr, | ||
775 | + uint32_t idx, void *vd, uintptr_t retaddr); | ||
776 | +typedef void clear_fn(void *vd, uint32_t idx, uint32_t cnt, uint32_t tot); | ||
777 | + | ||
778 | +#define GEN_VEXT_LD_ELEM(NAME, MTYPE, ETYPE, H, LDSUF) \ | ||
779 | +static void NAME(CPURISCVState *env, abi_ptr addr, \ | ||
780 | + uint32_t idx, void *vd, uintptr_t retaddr)\ | ||
781 | +{ \ | ||
782 | + MTYPE data; \ | ||
783 | + ETYPE *cur = ((ETYPE *)vd + H(idx)); \ | ||
784 | + data = cpu_##LDSUF##_data_ra(env, addr, retaddr); \ | ||
785 | + *cur = data; \ | ||
786 | +} \ | ||
787 | + | ||
788 | +GEN_VEXT_LD_ELEM(ldb_b, int8_t, int8_t, H1, ldsb) | ||
789 | +GEN_VEXT_LD_ELEM(ldb_h, int8_t, int16_t, H2, ldsb) | ||
790 | +GEN_VEXT_LD_ELEM(ldb_w, int8_t, int32_t, H4, ldsb) | ||
791 | +GEN_VEXT_LD_ELEM(ldb_d, int8_t, int64_t, H8, ldsb) | ||
792 | +GEN_VEXT_LD_ELEM(ldh_h, int16_t, int16_t, H2, ldsw) | ||
793 | +GEN_VEXT_LD_ELEM(ldh_w, int16_t, int32_t, H4, ldsw) | ||
794 | +GEN_VEXT_LD_ELEM(ldh_d, int16_t, int64_t, H8, ldsw) | ||
795 | +GEN_VEXT_LD_ELEM(ldw_w, int32_t, int32_t, H4, ldl) | ||
796 | +GEN_VEXT_LD_ELEM(ldw_d, int32_t, int64_t, H8, ldl) | ||
797 | +GEN_VEXT_LD_ELEM(lde_b, int8_t, int8_t, H1, ldsb) | ||
798 | +GEN_VEXT_LD_ELEM(lde_h, int16_t, int16_t, H2, ldsw) | ||
799 | +GEN_VEXT_LD_ELEM(lde_w, int32_t, int32_t, H4, ldl) | ||
800 | +GEN_VEXT_LD_ELEM(lde_d, int64_t, int64_t, H8, ldq) | ||
801 | +GEN_VEXT_LD_ELEM(ldbu_b, uint8_t, uint8_t, H1, ldub) | ||
802 | +GEN_VEXT_LD_ELEM(ldbu_h, uint8_t, uint16_t, H2, ldub) | ||
803 | +GEN_VEXT_LD_ELEM(ldbu_w, uint8_t, uint32_t, H4, ldub) | ||
804 | +GEN_VEXT_LD_ELEM(ldbu_d, uint8_t, uint64_t, H8, ldub) | ||
805 | +GEN_VEXT_LD_ELEM(ldhu_h, uint16_t, uint16_t, H2, lduw) | ||
806 | +GEN_VEXT_LD_ELEM(ldhu_w, uint16_t, uint32_t, H4, lduw) | ||
807 | +GEN_VEXT_LD_ELEM(ldhu_d, uint16_t, uint64_t, H8, lduw) | ||
808 | +GEN_VEXT_LD_ELEM(ldwu_w, uint32_t, uint32_t, H4, ldl) | ||
809 | +GEN_VEXT_LD_ELEM(ldwu_d, uint32_t, uint64_t, H8, ldl) | ||
810 | + | ||
811 | +#define GEN_VEXT_ST_ELEM(NAME, ETYPE, H, STSUF) \ | ||
812 | +static void NAME(CPURISCVState *env, abi_ptr addr, \ | ||
813 | + uint32_t idx, void *vd, uintptr_t retaddr)\ | ||
814 | +{ \ | ||
815 | + ETYPE data = *((ETYPE *)vd + H(idx)); \ | ||
816 | + cpu_##STSUF##_data_ra(env, addr, data, retaddr); \ | ||
817 | +} | ||
818 | + | ||
819 | +GEN_VEXT_ST_ELEM(stb_b, int8_t, H1, stb) | ||
820 | +GEN_VEXT_ST_ELEM(stb_h, int16_t, H2, stb) | ||
821 | +GEN_VEXT_ST_ELEM(stb_w, int32_t, H4, stb) | ||
822 | +GEN_VEXT_ST_ELEM(stb_d, int64_t, H8, stb) | ||
823 | +GEN_VEXT_ST_ELEM(sth_h, int16_t, H2, stw) | ||
824 | +GEN_VEXT_ST_ELEM(sth_w, int32_t, H4, stw) | ||
825 | +GEN_VEXT_ST_ELEM(sth_d, int64_t, H8, stw) | ||
826 | +GEN_VEXT_ST_ELEM(stw_w, int32_t, H4, stl) | ||
827 | +GEN_VEXT_ST_ELEM(stw_d, int64_t, H8, stl) | ||
828 | +GEN_VEXT_ST_ELEM(ste_b, int8_t, H1, stb) | ||
829 | +GEN_VEXT_ST_ELEM(ste_h, int16_t, H2, stw) | ||
830 | +GEN_VEXT_ST_ELEM(ste_w, int32_t, H4, stl) | ||
831 | +GEN_VEXT_ST_ELEM(ste_d, int64_t, H8, stq) | ||
832 | + | ||
833 | +/* | ||
834 | + *** stride: access vector element from strided memory | ||
835 | + */ | ||
836 | +static void | ||
837 | +vext_ldst_stride(void *vd, void *v0, target_ulong base, | ||
838 | + target_ulong stride, CPURISCVState *env, | ||
839 | + uint32_t desc, uint32_t vm, | ||
840 | + vext_ldst_elem_fn *ldst_elem, clear_fn *clear_elem, | ||
841 | + uint32_t esz, uint32_t msz, uintptr_t ra, | ||
842 | + MMUAccessType access_type) | ||
843 | +{ | ||
844 | + uint32_t i, k; | ||
845 | + uint32_t nf = vext_nf(desc); | ||
846 | + uint32_t mlen = vext_mlen(desc); | ||
847 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
848 | + | ||
849 | + /* probe every access*/ | ||
850 | + for (i = 0; i < env->vl; i++) { | ||
851 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
852 | + continue; | ||
853 | + } | ||
854 | + probe_pages(env, base + stride * i, nf * msz, ra, access_type); | ||
855 | + } | ||
856 | + /* do real access */ | ||
857 | + for (i = 0; i < env->vl; i++) { | ||
858 | + k = 0; | ||
859 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
860 | + continue; | ||
861 | + } | ||
862 | + while (k < nf) { | ||
863 | + target_ulong addr = base + stride * i + k * msz; | ||
864 | + ldst_elem(env, addr, i + k * vlmax, vd, ra); | ||
865 | + k++; | ||
866 | + } | ||
867 | + } | ||
868 | + /* clear tail elements */ | ||
869 | + if (clear_elem) { | ||
870 | + for (k = 0; k < nf; k++) { | ||
871 | + clear_elem(vd, env->vl + k * vlmax, env->vl * esz, vlmax * esz); | ||
872 | + } | ||
873 | + } | ||
874 | +} | ||
875 | + | ||
876 | +#define GEN_VEXT_LD_STRIDE(NAME, MTYPE, ETYPE, LOAD_FN, CLEAR_FN) \ | ||
877 | +void HELPER(NAME)(void *vd, void * v0, target_ulong base, \ | ||
878 | + target_ulong stride, CPURISCVState *env, \ | ||
879 | + uint32_t desc) \ | ||
880 | +{ \ | ||
881 | + uint32_t vm = vext_vm(desc); \ | ||
882 | + vext_ldst_stride(vd, v0, base, stride, env, desc, vm, LOAD_FN, \ | ||
883 | + CLEAR_FN, sizeof(ETYPE), sizeof(MTYPE), \ | ||
884 | + GETPC(), MMU_DATA_LOAD); \ | ||
885 | +} | ||
886 | + | ||
887 | +GEN_VEXT_LD_STRIDE(vlsb_v_b, int8_t, int8_t, ldb_b, clearb) | ||
888 | +GEN_VEXT_LD_STRIDE(vlsb_v_h, int8_t, int16_t, ldb_h, clearh) | ||
889 | +GEN_VEXT_LD_STRIDE(vlsb_v_w, int8_t, int32_t, ldb_w, clearl) | ||
890 | +GEN_VEXT_LD_STRIDE(vlsb_v_d, int8_t, int64_t, ldb_d, clearq) | ||
891 | +GEN_VEXT_LD_STRIDE(vlsh_v_h, int16_t, int16_t, ldh_h, clearh) | ||
892 | +GEN_VEXT_LD_STRIDE(vlsh_v_w, int16_t, int32_t, ldh_w, clearl) | ||
893 | +GEN_VEXT_LD_STRIDE(vlsh_v_d, int16_t, int64_t, ldh_d, clearq) | ||
894 | +GEN_VEXT_LD_STRIDE(vlsw_v_w, int32_t, int32_t, ldw_w, clearl) | ||
895 | +GEN_VEXT_LD_STRIDE(vlsw_v_d, int32_t, int64_t, ldw_d, clearq) | ||
896 | +GEN_VEXT_LD_STRIDE(vlse_v_b, int8_t, int8_t, lde_b, clearb) | ||
897 | +GEN_VEXT_LD_STRIDE(vlse_v_h, int16_t, int16_t, lde_h, clearh) | ||
898 | +GEN_VEXT_LD_STRIDE(vlse_v_w, int32_t, int32_t, lde_w, clearl) | ||
899 | +GEN_VEXT_LD_STRIDE(vlse_v_d, int64_t, int64_t, lde_d, clearq) | ||
900 | +GEN_VEXT_LD_STRIDE(vlsbu_v_b, uint8_t, uint8_t, ldbu_b, clearb) | ||
901 | +GEN_VEXT_LD_STRIDE(vlsbu_v_h, uint8_t, uint16_t, ldbu_h, clearh) | ||
902 | +GEN_VEXT_LD_STRIDE(vlsbu_v_w, uint8_t, uint32_t, ldbu_w, clearl) | ||
903 | +GEN_VEXT_LD_STRIDE(vlsbu_v_d, uint8_t, uint64_t, ldbu_d, clearq) | ||
904 | +GEN_VEXT_LD_STRIDE(vlshu_v_h, uint16_t, uint16_t, ldhu_h, clearh) | ||
905 | +GEN_VEXT_LD_STRIDE(vlshu_v_w, uint16_t, uint32_t, ldhu_w, clearl) | ||
906 | +GEN_VEXT_LD_STRIDE(vlshu_v_d, uint16_t, uint64_t, ldhu_d, clearq) | ||
907 | +GEN_VEXT_LD_STRIDE(vlswu_v_w, uint32_t, uint32_t, ldwu_w, clearl) | ||
908 | +GEN_VEXT_LD_STRIDE(vlswu_v_d, uint32_t, uint64_t, ldwu_d, clearq) | ||
909 | + | ||
910 | +#define GEN_VEXT_ST_STRIDE(NAME, MTYPE, ETYPE, STORE_FN) \ | ||
911 | +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ | ||
912 | + target_ulong stride, CPURISCVState *env, \ | ||
913 | + uint32_t desc) \ | ||
914 | +{ \ | ||
915 | + uint32_t vm = vext_vm(desc); \ | ||
916 | + vext_ldst_stride(vd, v0, base, stride, env, desc, vm, STORE_FN, \ | ||
917 | + NULL, sizeof(ETYPE), sizeof(MTYPE), \ | ||
918 | + GETPC(), MMU_DATA_STORE); \ | ||
919 | +} | ||
920 | + | ||
921 | +GEN_VEXT_ST_STRIDE(vssb_v_b, int8_t, int8_t, stb_b) | ||
922 | +GEN_VEXT_ST_STRIDE(vssb_v_h, int8_t, int16_t, stb_h) | ||
923 | +GEN_VEXT_ST_STRIDE(vssb_v_w, int8_t, int32_t, stb_w) | ||
924 | +GEN_VEXT_ST_STRIDE(vssb_v_d, int8_t, int64_t, stb_d) | ||
925 | +GEN_VEXT_ST_STRIDE(vssh_v_h, int16_t, int16_t, sth_h) | ||
926 | +GEN_VEXT_ST_STRIDE(vssh_v_w, int16_t, int32_t, sth_w) | ||
927 | +GEN_VEXT_ST_STRIDE(vssh_v_d, int16_t, int64_t, sth_d) | ||
928 | +GEN_VEXT_ST_STRIDE(vssw_v_w, int32_t, int32_t, stw_w) | ||
929 | +GEN_VEXT_ST_STRIDE(vssw_v_d, int32_t, int64_t, stw_d) | ||
930 | +GEN_VEXT_ST_STRIDE(vsse_v_b, int8_t, int8_t, ste_b) | ||
931 | +GEN_VEXT_ST_STRIDE(vsse_v_h, int16_t, int16_t, ste_h) | ||
932 | +GEN_VEXT_ST_STRIDE(vsse_v_w, int32_t, int32_t, ste_w) | ||
933 | +GEN_VEXT_ST_STRIDE(vsse_v_d, int64_t, int64_t, ste_d) | ||
934 | + | ||
935 | +/* | ||
936 | + *** unit-stride: access elements stored contiguously in memory | ||
937 | + */ | ||
938 | + | ||
939 | +/* unmasked unit-stride load and store operation*/ | ||
940 | +static void | ||
941 | +vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc, | ||
942 | + vext_ldst_elem_fn *ldst_elem, clear_fn *clear_elem, | ||
943 | + uint32_t esz, uint32_t msz, uintptr_t ra, | ||
944 | + MMUAccessType access_type) | ||
945 | +{ | ||
946 | + uint32_t i, k; | ||
947 | + uint32_t nf = vext_nf(desc); | ||
948 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
949 | + | ||
950 | + /* probe every access */ | ||
951 | + probe_pages(env, base, env->vl * nf * msz, ra, access_type); | ||
952 | + /* load bytes from guest memory */ | ||
953 | + for (i = 0; i < env->vl; i++) { | ||
954 | + k = 0; | ||
955 | + while (k < nf) { | ||
956 | + target_ulong addr = base + (i * nf + k) * msz; | ||
957 | + ldst_elem(env, addr, i + k * vlmax, vd, ra); | ||
958 | + k++; | ||
959 | + } | ||
960 | + } | ||
961 | + /* clear tail elements */ | ||
962 | + if (clear_elem) { | ||
963 | + for (k = 0; k < nf; k++) { | ||
964 | + clear_elem(vd, env->vl + k * vlmax, env->vl * esz, vlmax * esz); | ||
965 | + } | ||
966 | + } | ||
967 | +} | ||
968 | + | ||
969 | +/* | ||
970 | + * masked unit-stride load and store operation will be a special case of stride, | ||
971 | + * stride = NF * sizeof (MTYPE) | ||
972 | + */ | ||
973 | + | ||
974 | +#define GEN_VEXT_LD_US(NAME, MTYPE, ETYPE, LOAD_FN, CLEAR_FN) \ | ||
975 | +void HELPER(NAME##_mask)(void *vd, void *v0, target_ulong base, \ | ||
976 | + CPURISCVState *env, uint32_t desc) \ | ||
977 | +{ \ | ||
978 | + uint32_t stride = vext_nf(desc) * sizeof(MTYPE); \ | ||
979 | + vext_ldst_stride(vd, v0, base, stride, env, desc, false, LOAD_FN, \ | ||
980 | + CLEAR_FN, sizeof(ETYPE), sizeof(MTYPE), \ | ||
981 | + GETPC(), MMU_DATA_LOAD); \ | ||
982 | +} \ | ||
983 | + \ | ||
984 | +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ | ||
985 | + CPURISCVState *env, uint32_t desc) \ | ||
986 | +{ \ | ||
987 | + vext_ldst_us(vd, base, env, desc, LOAD_FN, CLEAR_FN, \ | ||
988 | + sizeof(ETYPE), sizeof(MTYPE), GETPC(), MMU_DATA_LOAD); \ | ||
989 | +} | ||
990 | + | ||
991 | +GEN_VEXT_LD_US(vlb_v_b, int8_t, int8_t, ldb_b, clearb) | ||
992 | +GEN_VEXT_LD_US(vlb_v_h, int8_t, int16_t, ldb_h, clearh) | ||
993 | +GEN_VEXT_LD_US(vlb_v_w, int8_t, int32_t, ldb_w, clearl) | ||
994 | +GEN_VEXT_LD_US(vlb_v_d, int8_t, int64_t, ldb_d, clearq) | ||
995 | +GEN_VEXT_LD_US(vlh_v_h, int16_t, int16_t, ldh_h, clearh) | ||
996 | +GEN_VEXT_LD_US(vlh_v_w, int16_t, int32_t, ldh_w, clearl) | ||
997 | +GEN_VEXT_LD_US(vlh_v_d, int16_t, int64_t, ldh_d, clearq) | ||
998 | +GEN_VEXT_LD_US(vlw_v_w, int32_t, int32_t, ldw_w, clearl) | ||
999 | +GEN_VEXT_LD_US(vlw_v_d, int32_t, int64_t, ldw_d, clearq) | ||
1000 | +GEN_VEXT_LD_US(vle_v_b, int8_t, int8_t, lde_b, clearb) | ||
1001 | +GEN_VEXT_LD_US(vle_v_h, int16_t, int16_t, lde_h, clearh) | ||
1002 | +GEN_VEXT_LD_US(vle_v_w, int32_t, int32_t, lde_w, clearl) | ||
1003 | +GEN_VEXT_LD_US(vle_v_d, int64_t, int64_t, lde_d, clearq) | ||
1004 | +GEN_VEXT_LD_US(vlbu_v_b, uint8_t, uint8_t, ldbu_b, clearb) | ||
1005 | +GEN_VEXT_LD_US(vlbu_v_h, uint8_t, uint16_t, ldbu_h, clearh) | ||
1006 | +GEN_VEXT_LD_US(vlbu_v_w, uint8_t, uint32_t, ldbu_w, clearl) | ||
1007 | +GEN_VEXT_LD_US(vlbu_v_d, uint8_t, uint64_t, ldbu_d, clearq) | ||
1008 | +GEN_VEXT_LD_US(vlhu_v_h, uint16_t, uint16_t, ldhu_h, clearh) | ||
1009 | +GEN_VEXT_LD_US(vlhu_v_w, uint16_t, uint32_t, ldhu_w, clearl) | ||
1010 | +GEN_VEXT_LD_US(vlhu_v_d, uint16_t, uint64_t, ldhu_d, clearq) | ||
1011 | +GEN_VEXT_LD_US(vlwu_v_w, uint32_t, uint32_t, ldwu_w, clearl) | ||
1012 | +GEN_VEXT_LD_US(vlwu_v_d, uint32_t, uint64_t, ldwu_d, clearq) | ||
1013 | + | ||
1014 | +#define GEN_VEXT_ST_US(NAME, MTYPE, ETYPE, STORE_FN) \ | ||
1015 | +void HELPER(NAME##_mask)(void *vd, void *v0, target_ulong base, \ | ||
1016 | + CPURISCVState *env, uint32_t desc) \ | ||
1017 | +{ \ | ||
1018 | + uint32_t stride = vext_nf(desc) * sizeof(MTYPE); \ | ||
1019 | + vext_ldst_stride(vd, v0, base, stride, env, desc, false, STORE_FN, \ | ||
1020 | + NULL, sizeof(ETYPE), sizeof(MTYPE), \ | ||
1021 | + GETPC(), MMU_DATA_STORE); \ | ||
1022 | +} \ | ||
1023 | + \ | ||
1024 | +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ | ||
1025 | + CPURISCVState *env, uint32_t desc) \ | ||
1026 | +{ \ | ||
1027 | + vext_ldst_us(vd, base, env, desc, STORE_FN, NULL, \ | ||
1028 | + sizeof(ETYPE), sizeof(MTYPE), GETPC(), MMU_DATA_STORE);\ | ||
1029 | +} | ||
1030 | + | ||
1031 | +GEN_VEXT_ST_US(vsb_v_b, int8_t, int8_t , stb_b) | ||
1032 | +GEN_VEXT_ST_US(vsb_v_h, int8_t, int16_t, stb_h) | ||
1033 | +GEN_VEXT_ST_US(vsb_v_w, int8_t, int32_t, stb_w) | ||
1034 | +GEN_VEXT_ST_US(vsb_v_d, int8_t, int64_t, stb_d) | ||
1035 | +GEN_VEXT_ST_US(vsh_v_h, int16_t, int16_t, sth_h) | ||
1036 | +GEN_VEXT_ST_US(vsh_v_w, int16_t, int32_t, sth_w) | ||
1037 | +GEN_VEXT_ST_US(vsh_v_d, int16_t, int64_t, sth_d) | ||
1038 | +GEN_VEXT_ST_US(vsw_v_w, int32_t, int32_t, stw_w) | ||
1039 | +GEN_VEXT_ST_US(vsw_v_d, int32_t, int64_t, stw_d) | ||
1040 | +GEN_VEXT_ST_US(vse_v_b, int8_t, int8_t , ste_b) | ||
1041 | +GEN_VEXT_ST_US(vse_v_h, int16_t, int16_t, ste_h) | ||
1042 | +GEN_VEXT_ST_US(vse_v_w, int32_t, int32_t, ste_w) | ||
1043 | +GEN_VEXT_ST_US(vse_v_d, int64_t, int64_t, ste_d) | ||
1044 | -- | 182 | -- |
1045 | 2.27.0 | 183 | 2.45.1 |
1046 | |||
1047 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Christoph Müllner <christoph.muellner@vrull.eu> |
---|---|---|---|
2 | 2 | ||
3 | vsetvl and vsetvli are two configure instructions for vl, vtype. TB flags | 3 | The th.sxstatus CSR can be used to identify available custom extension |
4 | should update after configure instructions. The (ill, lmul, sew ) of vtype | 4 | on T-Head CPUs. The CSR is documented here: |
5 | and the bit of (VSTART == 0 && VL == VLMAX) will be placed within tb_flags. | 5 | https://github.com/T-head-Semi/thead-extension-spec/blob/master/xtheadsxstatus.adoc |
6 | 6 | ||
7 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 7 | An important property of this patch is, that the th.sxstatus MAEE field |
8 | is not set (indicating that XTheadMae is not available). | ||
9 | XTheadMae is a memory attribute extension (similar to Svpbmt) which is | ||
10 | implemented in many T-Head CPUs (C906, C910, etc.) and utilizes bits | ||
11 | in PTEs that are marked as reserved. QEMU maintainers prefer to not | ||
12 | implement XTheadMae, so we need give kernels a mechanism to identify | ||
13 | if XTheadMae is available in a system or not. And this patch introduces | ||
14 | this mechanism in QEMU in a way that's compatible with real HW | ||
15 | (i.e., probing the th.sxstatus.MAEE bit). | ||
16 | |||
17 | Further context can be found on the list: | ||
18 | https://lists.gnu.org/archive/html/qemu-devel/2024-02/msg00775.html | ||
19 | |||
20 | Reviewed-by: LIU Zhiwei <zhiwe_liu@linux.alibaba.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 21 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> |
10 | Message-id: 20200623215920.2594-5-zhiwei_liu@c-sky.com | 23 | Message-ID: <20240429073656.2486732-1-christoph.muellner@vrull.eu> |
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 24 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
12 | --- | 25 | --- |
13 | target/riscv/cpu.h | 63 +++++++++++++++++--- | 26 | MAINTAINERS | 1 + |
14 | target/riscv/helper.h | 3 + | 27 | target/riscv/cpu.h | 3 ++ |
15 | target/riscv/insn32.decode | 5 ++ | 28 | target/riscv/cpu.c | 1 + |
16 | target/riscv/insn_trans/trans_rvv.inc.c | 79 +++++++++++++++++++++++++ | 29 | target/riscv/th_csr.c | 79 ++++++++++++++++++++++++++++++++++++++++ |
17 | target/riscv/translate.c | 17 +++++- | 30 | target/riscv/meson.build | 1 + |
18 | target/riscv/vector_helper.c | 53 +++++++++++++++++ | 31 | 5 files changed, 85 insertions(+) |
19 | target/riscv/Makefile.objs | 2 +- | 32 | create mode 100644 target/riscv/th_csr.c |
20 | 7 files changed, 210 insertions(+), 12 deletions(-) | ||
21 | create mode 100644 target/riscv/insn_trans/trans_rvv.inc.c | ||
22 | create mode 100644 target/riscv/vector_helper.c | ||
23 | 33 | ||
34 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/MAINTAINERS | ||
37 | +++ b/MAINTAINERS | ||
38 | @@ -XXX,XX +XXX,XX @@ L: qemu-riscv@nongnu.org | ||
39 | S: Supported | ||
40 | F: target/riscv/insn_trans/trans_xthead.c.inc | ||
41 | F: target/riscv/xthead*.decode | ||
42 | +F: target/riscv/th_* | ||
43 | F: disas/riscv-xthead* | ||
44 | |||
45 | RISC-V XVentanaCondOps extension | ||
24 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | 46 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h |
25 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/riscv/cpu.h | 48 | --- a/target/riscv/cpu.h |
27 | +++ b/target/riscv/cpu.h | 49 | +++ b/target/riscv/cpu.h |
28 | @@ -XXX,XX +XXX,XX @@ | 50 | @@ -XXX,XX +XXX,XX @@ target_ulong riscv_new_csr_seed(target_ulong new_value, |
29 | #define RISCV_CPU_H | 51 | uint8_t satp_mode_max_from_map(uint32_t map); |
30 | 52 | const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit); | |
31 | #include "hw/core/cpu.h" | 53 | |
32 | +#include "hw/registerfields.h" | 54 | +/* Implemented in th_csr.c */ |
33 | #include "exec/cpu-defs.h" | 55 | +void th_register_custom_csrs(RISCVCPU *cpu); |
34 | #include "fpu/softfloat-types.h" | ||
35 | |||
36 | @@ -XXX,XX +XXX,XX @@ typedef struct CPURISCVState CPURISCVState; | ||
37 | |||
38 | #define RV_VLEN_MAX 512 | ||
39 | |||
40 | +FIELD(VTYPE, VLMUL, 0, 2) | ||
41 | +FIELD(VTYPE, VSEW, 2, 3) | ||
42 | +FIELD(VTYPE, VEDIV, 5, 2) | ||
43 | +FIELD(VTYPE, RESERVED, 7, sizeof(target_ulong) * 8 - 9) | ||
44 | +FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 2, 1) | ||
45 | + | 56 | + |
46 | struct CPURISCVState { | 57 | #endif /* RISCV_CPU_H */ |
47 | target_ulong gpr[32]; | 58 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
48 | uint64_t fpr[32]; /* assume both F and D extensions */ | 59 | index XXXXXXX..XXXXXXX 100644 |
49 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong); | 60 | --- a/target/riscv/cpu.c |
50 | #define TB_FLAGS_MMU_MASK 3 | 61 | +++ b/target/riscv/cpu.c |
51 | #define TB_FLAGS_MSTATUS_FS MSTATUS_FS | 62 | @@ -XXX,XX +XXX,XX @@ static void rv64_thead_c906_cpu_init(Object *obj) |
52 | 63 | cpu->cfg.mvendorid = THEAD_VENDOR_ID; | |
53 | +typedef CPURISCVState CPUArchState; | 64 | #ifndef CONFIG_USER_ONLY |
54 | +typedef RISCVCPU ArchCPU; | 65 | set_satp_mode_max_supported(cpu, VM_1_10_SV39); |
55 | +#include "exec/cpu-all.h" | 66 | + th_register_custom_csrs(cpu); |
56 | + | ||
57 | +FIELD(TB_FLAGS, VL_EQ_VLMAX, 2, 1) | ||
58 | +FIELD(TB_FLAGS, LMUL, 3, 2) | ||
59 | +FIELD(TB_FLAGS, SEW, 5, 3) | ||
60 | +FIELD(TB_FLAGS, VILL, 8, 1) | ||
61 | + | ||
62 | +/* | ||
63 | + * A simplification for VLMAX | ||
64 | + * = (1 << LMUL) * VLEN / (8 * (1 << SEW)) | ||
65 | + * = (VLEN << LMUL) / (8 << SEW) | ||
66 | + * = (VLEN << LMUL) >> (SEW + 3) | ||
67 | + * = VLEN >> (SEW + 3 - LMUL) | ||
68 | + */ | ||
69 | +static inline uint32_t vext_get_vlmax(RISCVCPU *cpu, target_ulong vtype) | ||
70 | +{ | ||
71 | + uint8_t sew, lmul; | ||
72 | + | ||
73 | + sew = FIELD_EX64(vtype, VTYPE, VSEW); | ||
74 | + lmul = FIELD_EX64(vtype, VTYPE, VLMUL); | ||
75 | + return cpu->cfg.vlen >> (sew + 3 - lmul); | ||
76 | +} | ||
77 | + | ||
78 | static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, | ||
79 | - target_ulong *cs_base, uint32_t *flags) | ||
80 | + target_ulong *cs_base, uint32_t *pflags) | ||
81 | { | ||
82 | + uint32_t flags = 0; | ||
83 | + | ||
84 | *pc = env->pc; | ||
85 | *cs_base = 0; | ||
86 | + | ||
87 | + if (riscv_has_ext(env, RVV)) { | ||
88 | + uint32_t vlmax = vext_get_vlmax(env_archcpu(env), env->vtype); | ||
89 | + bool vl_eq_vlmax = (env->vstart == 0) && (vlmax == env->vl); | ||
90 | + flags = FIELD_DP32(flags, TB_FLAGS, VILL, | ||
91 | + FIELD_EX64(env->vtype, VTYPE, VILL)); | ||
92 | + flags = FIELD_DP32(flags, TB_FLAGS, SEW, | ||
93 | + FIELD_EX64(env->vtype, VTYPE, VSEW)); | ||
94 | + flags = FIELD_DP32(flags, TB_FLAGS, LMUL, | ||
95 | + FIELD_EX64(env->vtype, VTYPE, VLMUL)); | ||
96 | + flags = FIELD_DP32(flags, TB_FLAGS, VL_EQ_VLMAX, vl_eq_vlmax); | ||
97 | + } else { | ||
98 | + flags = FIELD_DP32(flags, TB_FLAGS, VILL, 1); | ||
99 | + } | ||
100 | + | ||
101 | #ifdef CONFIG_USER_ONLY | ||
102 | - *flags = TB_FLAGS_MSTATUS_FS; | ||
103 | + flags |= TB_FLAGS_MSTATUS_FS; | ||
104 | #else | ||
105 | - *flags = cpu_mmu_index(env, 0); | ||
106 | + flags |= cpu_mmu_index(env, 0); | ||
107 | if (riscv_cpu_fp_enabled(env)) { | ||
108 | - *flags |= env->mstatus & MSTATUS_FS; | ||
109 | + flags |= env->mstatus & MSTATUS_FS; | ||
110 | } | ||
111 | #endif | 67 | #endif |
112 | + *pflags = flags; | 68 | |
113 | } | 69 | /* inherited from parent obj via riscv_cpu_init() */ |
114 | 70 | diff --git a/target/riscv/th_csr.c b/target/riscv/th_csr.c | |
115 | int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
116 | @@ -XXX,XX +XXX,XX @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops); | ||
117 | |||
118 | void riscv_cpu_register_gdb_regs_for_features(CPUState *cs); | ||
119 | |||
120 | -typedef CPURISCVState CPUArchState; | ||
121 | -typedef RISCVCPU ArchCPU; | ||
122 | - | ||
123 | -#include "exec/cpu-all.h" | ||
124 | - | ||
125 | #endif /* RISCV_CPU_H */ | ||
126 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/target/riscv/helper.h | ||
129 | +++ b/target/riscv/helper.h | ||
130 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_1(tlb_flush, void, env) | ||
131 | #ifndef CONFIG_USER_ONLY | ||
132 | DEF_HELPER_1(hyp_tlb_flush, void, env) | ||
133 | #endif | ||
134 | + | ||
135 | +/* Vector functions */ | ||
136 | +DEF_HELPER_3(vsetvl, tl, env, tl, tl) | ||
137 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
138 | index XXXXXXX..XXXXXXX 100644 | ||
139 | --- a/target/riscv/insn32.decode | ||
140 | +++ b/target/riscv/insn32.decode | ||
141 | @@ -XXX,XX +XXX,XX @@ | ||
142 | @r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd | ||
143 | @r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd | ||
144 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | ||
145 | +@r2_zimm . zimm:11 ..... ... ..... ....... %rs1 %rd | ||
146 | |||
147 | @hfence_gvma ....... ..... ..... ... ..... ....... %rs2 %rs1 | ||
148 | @hfence_vvma ....... ..... ..... ... ..... ....... %rs2 %rs1 | ||
149 | @@ -XXX,XX +XXX,XX @@ fcvt_d_wu 1101001 00001 ..... ... ..... 1010011 @r2_rm | ||
150 | # *** RV32H Base Instruction Set *** | ||
151 | hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma | ||
152 | hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma | ||
153 | + | ||
154 | +# *** RV32V Extension *** | ||
155 | +vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
156 | +vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
157 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
158 | new file mode 100644 | 71 | new file mode 100644 |
159 | index XXXXXXX..XXXXXXX | 72 | index XXXXXXX..XXXXXXX |
160 | --- /dev/null | 73 | --- /dev/null |
161 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 74 | +++ b/target/riscv/th_csr.c |
162 | @@ -XXX,XX +XXX,XX @@ | 75 | @@ -XXX,XX +XXX,XX @@ |
163 | +/* | 76 | +/* |
164 | + * RISC-V translation routines for the RVV Standard Extension. | 77 | + * T-Head-specific CSRs. |
165 | + * | 78 | + * |
166 | + * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved. | 79 | + * Copyright (c) 2024 VRULL GmbH |
167 | + * | ||
168 | + * This program is free software; you can redistribute it and/or modify it | ||
169 | + * under the terms and conditions of the GNU General Public License, | ||
170 | + * version 2 or later, as published by the Free Software Foundation. | ||
171 | + * | ||
172 | + * This program is distributed in the hope it will be useful, but WITHOUT | ||
173 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
174 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
175 | + * more details. | ||
176 | + * | ||
177 | + * You should have received a copy of the GNU General Public License along with | ||
178 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
179 | + */ | ||
180 | + | ||
181 | +static bool trans_vsetvl(DisasContext *ctx, arg_vsetvl *a) | ||
182 | +{ | ||
183 | + TCGv s1, s2, dst; | ||
184 | + | ||
185 | + if (!has_ext(ctx, RVV)) { | ||
186 | + return false; | ||
187 | + } | ||
188 | + | ||
189 | + s2 = tcg_temp_new(); | ||
190 | + dst = tcg_temp_new(); | ||
191 | + | ||
192 | + /* Using x0 as the rs1 register specifier, encodes an infinite AVL */ | ||
193 | + if (a->rs1 == 0) { | ||
194 | + /* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */ | ||
195 | + s1 = tcg_const_tl(RV_VLEN_MAX); | ||
196 | + } else { | ||
197 | + s1 = tcg_temp_new(); | ||
198 | + gen_get_gpr(s1, a->rs1); | ||
199 | + } | ||
200 | + gen_get_gpr(s2, a->rs2); | ||
201 | + gen_helper_vsetvl(dst, cpu_env, s1, s2); | ||
202 | + gen_set_gpr(a->rd, dst); | ||
203 | + tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn); | ||
204 | + lookup_and_goto_ptr(ctx); | ||
205 | + ctx->base.is_jmp = DISAS_NORETURN; | ||
206 | + | ||
207 | + tcg_temp_free(s1); | ||
208 | + tcg_temp_free(s2); | ||
209 | + tcg_temp_free(dst); | ||
210 | + return true; | ||
211 | +} | ||
212 | + | ||
213 | +static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a) | ||
214 | +{ | ||
215 | + TCGv s1, s2, dst; | ||
216 | + | ||
217 | + if (!has_ext(ctx, RVV)) { | ||
218 | + return false; | ||
219 | + } | ||
220 | + | ||
221 | + s2 = tcg_const_tl(a->zimm); | ||
222 | + dst = tcg_temp_new(); | ||
223 | + | ||
224 | + /* Using x0 as the rs1 register specifier, encodes an infinite AVL */ | ||
225 | + if (a->rs1 == 0) { | ||
226 | + /* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */ | ||
227 | + s1 = tcg_const_tl(RV_VLEN_MAX); | ||
228 | + } else { | ||
229 | + s1 = tcg_temp_new(); | ||
230 | + gen_get_gpr(s1, a->rs1); | ||
231 | + } | ||
232 | + gen_helper_vsetvl(dst, cpu_env, s1, s2); | ||
233 | + gen_set_gpr(a->rd, dst); | ||
234 | + gen_goto_tb(ctx, 0, ctx->pc_succ_insn); | ||
235 | + ctx->base.is_jmp = DISAS_NORETURN; | ||
236 | + | ||
237 | + tcg_temp_free(s1); | ||
238 | + tcg_temp_free(s2); | ||
239 | + tcg_temp_free(dst); | ||
240 | + return true; | ||
241 | +} | ||
242 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
243 | index XXXXXXX..XXXXXXX 100644 | ||
244 | --- a/target/riscv/translate.c | ||
245 | +++ b/target/riscv/translate.c | ||
246 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
247 | to reset this known value. */ | ||
248 | int frm; | ||
249 | bool ext_ifencei; | ||
250 | + /* vector extension */ | ||
251 | + bool vill; | ||
252 | + uint8_t lmul; | ||
253 | + uint8_t sew; | ||
254 | + uint16_t vlen; | ||
255 | + bool vl_eq_vlmax; | ||
256 | } DisasContext; | ||
257 | |||
258 | #ifdef TARGET_RISCV64 | ||
259 | @@ -XXX,XX +XXX,XX @@ static bool gen_shift(DisasContext *ctx, arg_r *a, | ||
260 | #include "insn_trans/trans_rvf.inc.c" | ||
261 | #include "insn_trans/trans_rvd.inc.c" | ||
262 | #include "insn_trans/trans_rvh.inc.c" | ||
263 | +#include "insn_trans/trans_rvv.inc.c" | ||
264 | #include "insn_trans/trans_privileged.inc.c" | ||
265 | |||
266 | /* Include the auto-generated decoder for 16 bit insn */ | ||
267 | @@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
268 | DisasContext *ctx = container_of(dcbase, DisasContext, base); | ||
269 | CPURISCVState *env = cs->env_ptr; | ||
270 | RISCVCPU *cpu = RISCV_CPU(cs); | ||
271 | + uint32_t tb_flags = ctx->base.tb->flags; | ||
272 | |||
273 | ctx->pc_succ_insn = ctx->base.pc_first; | ||
274 | - ctx->mem_idx = ctx->base.tb->flags & TB_FLAGS_MMU_MASK; | ||
275 | - ctx->mstatus_fs = ctx->base.tb->flags & TB_FLAGS_MSTATUS_FS; | ||
276 | + ctx->mem_idx = tb_flags & TB_FLAGS_MMU_MASK; | ||
277 | + ctx->mstatus_fs = tb_flags & TB_FLAGS_MSTATUS_FS; | ||
278 | ctx->priv_ver = env->priv_ver; | ||
279 | #if !defined(CONFIG_USER_ONLY) | ||
280 | if (riscv_has_ext(env, RVH)) { | ||
281 | @@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
282 | ctx->misa = env->misa; | ||
283 | ctx->frm = -1; /* unknown rounding mode */ | ||
284 | ctx->ext_ifencei = cpu->cfg.ext_ifencei; | ||
285 | + ctx->vlen = cpu->cfg.vlen; | ||
286 | + ctx->vill = FIELD_EX32(tb_flags, TB_FLAGS, VILL); | ||
287 | + ctx->sew = FIELD_EX32(tb_flags, TB_FLAGS, SEW); | ||
288 | + ctx->lmul = FIELD_EX32(tb_flags, TB_FLAGS, LMUL); | ||
289 | + ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); | ||
290 | } | ||
291 | |||
292 | static void riscv_tr_tb_start(DisasContextBase *db, CPUState *cpu) | ||
293 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
294 | new file mode 100644 | ||
295 | index XXXXXXX..XXXXXXX | ||
296 | --- /dev/null | ||
297 | +++ b/target/riscv/vector_helper.c | ||
298 | @@ -XXX,XX +XXX,XX @@ | ||
299 | +/* | ||
300 | + * RISC-V Vector Extension Helpers for QEMU. | ||
301 | + * | ||
302 | + * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved. | ||
303 | + * | 80 | + * |
304 | + * This program is free software; you can redistribute it and/or modify it | 81 | + * This program is free software; you can redistribute it and/or modify it |
305 | + * under the terms and conditions of the GNU General Public License, | 82 | + * under the terms and conditions of the GNU General Public License, |
306 | + * version 2 or later, as published by the Free Software Foundation. | 83 | + * version 2 or later, as published by the Free Software Foundation. |
307 | + * | 84 | + * |
... | ... | ||
314 | + * this program. If not, see <http://www.gnu.org/licenses/>. | 91 | + * this program. If not, see <http://www.gnu.org/licenses/>. |
315 | + */ | 92 | + */ |
316 | + | 93 | + |
317 | +#include "qemu/osdep.h" | 94 | +#include "qemu/osdep.h" |
318 | +#include "cpu.h" | 95 | +#include "cpu.h" |
319 | +#include "exec/exec-all.h" | 96 | +#include "cpu_vendorid.h" |
320 | +#include "exec/helper-proto.h" | ||
321 | +#include <math.h> | ||
322 | + | 97 | + |
323 | +target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, | 98 | +#define CSR_TH_SXSTATUS 0x5c0 |
324 | + target_ulong s2) | 99 | + |
100 | +/* TH_SXSTATUS bits */ | ||
101 | +#define TH_SXSTATUS_UCME BIT(16) | ||
102 | +#define TH_SXSTATUS_MAEE BIT(21) | ||
103 | +#define TH_SXSTATUS_THEADISAEE BIT(22) | ||
104 | + | ||
105 | +typedef struct { | ||
106 | + int csrno; | ||
107 | + int (*insertion_test)(RISCVCPU *cpu); | ||
108 | + riscv_csr_operations csr_ops; | ||
109 | +} riscv_csr; | ||
110 | + | ||
111 | +static RISCVException smode(CPURISCVState *env, int csrno) | ||
325 | +{ | 112 | +{ |
326 | + int vlmax, vl; | 113 | + if (riscv_has_ext(env, RVS)) { |
327 | + RISCVCPU *cpu = env_archcpu(env); | 114 | + return RISCV_EXCP_NONE; |
328 | + uint16_t sew = 8 << FIELD_EX64(s2, VTYPE, VSEW); | ||
329 | + uint8_t ediv = FIELD_EX64(s2, VTYPE, VEDIV); | ||
330 | + bool vill = FIELD_EX64(s2, VTYPE, VILL); | ||
331 | + target_ulong reserved = FIELD_EX64(s2, VTYPE, RESERVED); | ||
332 | + | ||
333 | + if ((sew > cpu->cfg.elen) || vill || (ediv != 0) || (reserved != 0)) { | ||
334 | + /* only set vill bit. */ | ||
335 | + env->vtype = FIELD_DP64(0, VTYPE, VILL, 1); | ||
336 | + env->vl = 0; | ||
337 | + env->vstart = 0; | ||
338 | + return 0; | ||
339 | + } | 115 | + } |
340 | + | 116 | + |
341 | + vlmax = vext_get_vlmax(cpu, s2); | 117 | + return RISCV_EXCP_ILLEGAL_INST; |
342 | + if (s1 <= vlmax) { | 118 | +} |
343 | + vl = s1; | 119 | + |
344 | + } else { | 120 | +static int test_thead_mvendorid(RISCVCPU *cpu) |
345 | + vl = vlmax; | 121 | +{ |
122 | + if (cpu->cfg.mvendorid != THEAD_VENDOR_ID) { | ||
123 | + return -1; | ||
346 | + } | 124 | + } |
347 | + env->vl = vl; | 125 | + |
348 | + env->vtype = s2; | 126 | + return 0; |
349 | + env->vstart = 0; | ||
350 | + return vl; | ||
351 | +} | 127 | +} |
352 | diff --git a/target/riscv/Makefile.objs b/target/riscv/Makefile.objs | 128 | + |
129 | +static RISCVException read_th_sxstatus(CPURISCVState *env, int csrno, | ||
130 | + target_ulong *val) | ||
131 | +{ | ||
132 | + /* We don't set MAEE here, because QEMU does not implement MAEE. */ | ||
133 | + *val = TH_SXSTATUS_UCME | TH_SXSTATUS_THEADISAEE; | ||
134 | + return RISCV_EXCP_NONE; | ||
135 | +} | ||
136 | + | ||
137 | +static riscv_csr th_csr_list[] = { | ||
138 | + { | ||
139 | + .csrno = CSR_TH_SXSTATUS, | ||
140 | + .insertion_test = test_thead_mvendorid, | ||
141 | + .csr_ops = { "th.sxstatus", smode, read_th_sxstatus } | ||
142 | + } | ||
143 | +}; | ||
144 | + | ||
145 | +void th_register_custom_csrs(RISCVCPU *cpu) | ||
146 | +{ | ||
147 | + for (size_t i = 0; i < ARRAY_SIZE(th_csr_list); i++) { | ||
148 | + int csrno = th_csr_list[i].csrno; | ||
149 | + riscv_csr_operations *csr_ops = &th_csr_list[i].csr_ops; | ||
150 | + if (!th_csr_list[i].insertion_test(cpu)) { | ||
151 | + riscv_set_csr_ops(csrno, csr_ops); | ||
152 | + } | ||
153 | + } | ||
154 | +} | ||
155 | diff --git a/target/riscv/meson.build b/target/riscv/meson.build | ||
353 | index XXXXXXX..XXXXXXX 100644 | 156 | index XXXXXXX..XXXXXXX 100644 |
354 | --- a/target/riscv/Makefile.objs | 157 | --- a/target/riscv/meson.build |
355 | +++ b/target/riscv/Makefile.objs | 158 | +++ b/target/riscv/meson.build |
356 | @@ -XXX,XX +XXX,XX @@ | 159 | @@ -XXX,XX +XXX,XX @@ riscv_system_ss.add(files( |
357 | -obj-y += translate.o op_helper.o cpu_helper.o cpu.o csr.o fpu_helper.o gdbstub.o | 160 | 'monitor.c', |
358 | +obj-y += translate.o op_helper.o cpu_helper.o cpu.o csr.o fpu_helper.o vector_helper.o gdbstub.o | 161 | 'machine.c', |
359 | obj-$(CONFIG_SOFTMMU) += pmp.o | 162 | 'pmu.c', |
360 | 163 | + 'th_csr.c', | |
361 | ifeq ($(CONFIG_SOFTMMU),y) | 164 | 'time_helper.c', |
165 | 'riscv-qmp-cmds.c', | ||
166 | )) | ||
362 | -- | 167 | -- |
363 | 2.27.0 | 168 | 2.45.1 |
364 | 169 | ||
365 | 170 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Max Chou <max.chou@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | The unit-stride fault-only-fault load instructions are used to | 3 | According v spec 18.4, only the vfwcvt.f.f.v and vfncvt.f.f.w |
4 | vectorize loops with data-dependent exit conditions(while loops). | 4 | instructions will be affected by Zvfhmin extension. |
5 | These instructions execute as a regular load except that they | 5 | And the vfwcvt.f.f.v and vfncvt.f.f.w instructions only support the |
6 | will only take a trap on element 0. | 6 | conversions of |
7 | 7 | ||
8 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 8 | * From 1*SEW(16/32) to 2*SEW(32/64) |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | * From 2*SEW(32/64) to 1*SEW(16/32) |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | |
11 | Message-id: 20200623215920.2594-9-zhiwei_liu@c-sky.com | 11 | Signed-off-by: Max Chou <max.chou@sifive.com> |
12 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
13 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
14 | Message-ID: <20240322092600.1198921-2-max.chou@sifive.com> | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
13 | --- | 16 | --- |
14 | target/riscv/helper.h | 22 +++++ | 17 | target/riscv/insn_trans/trans_rvv.c.inc | 20 ++++++++++++++++++-- |
15 | target/riscv/insn32.decode | 7 ++ | 18 | 1 file changed, 18 insertions(+), 2 deletions(-) |
16 | target/riscv/insn_trans/trans_rvv.inc.c | 73 ++++++++++++++++ | ||
17 | target/riscv/vector_helper.c | 110 ++++++++++++++++++++++++ | ||
18 | 4 files changed, 212 insertions(+) | ||
19 | 19 | ||
20 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 20 | diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/riscv/helper.h | 22 | --- a/target/riscv/insn_trans/trans_rvv.c.inc |
23 | +++ b/target/riscv/helper.h | 23 | +++ b/target/riscv/insn_trans/trans_rvv.c.inc |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vsxe_v_b, void, ptr, ptr, tl, ptr, env, i32) | 24 | @@ -XXX,XX +XXX,XX @@ static bool require_rvf(DisasContext *s) |
25 | DEF_HELPER_6(vsxe_v_h, void, ptr, ptr, tl, ptr, env, i32) | 25 | } |
26 | DEF_HELPER_6(vsxe_v_w, void, ptr, ptr, tl, ptr, env, i32) | 26 | } |
27 | DEF_HELPER_6(vsxe_v_d, void, ptr, ptr, tl, ptr, env, i32) | 27 | |
28 | +DEF_HELPER_5(vlbff_v_b, void, ptr, ptr, tl, env, i32) | 28 | +static bool require_rvfmin(DisasContext *s) |
29 | +DEF_HELPER_5(vlbff_v_h, void, ptr, ptr, tl, env, i32) | ||
30 | +DEF_HELPER_5(vlbff_v_w, void, ptr, ptr, tl, env, i32) | ||
31 | +DEF_HELPER_5(vlbff_v_d, void, ptr, ptr, tl, env, i32) | ||
32 | +DEF_HELPER_5(vlhff_v_h, void, ptr, ptr, tl, env, i32) | ||
33 | +DEF_HELPER_5(vlhff_v_w, void, ptr, ptr, tl, env, i32) | ||
34 | +DEF_HELPER_5(vlhff_v_d, void, ptr, ptr, tl, env, i32) | ||
35 | +DEF_HELPER_5(vlwff_v_w, void, ptr, ptr, tl, env, i32) | ||
36 | +DEF_HELPER_5(vlwff_v_d, void, ptr, ptr, tl, env, i32) | ||
37 | +DEF_HELPER_5(vleff_v_b, void, ptr, ptr, tl, env, i32) | ||
38 | +DEF_HELPER_5(vleff_v_h, void, ptr, ptr, tl, env, i32) | ||
39 | +DEF_HELPER_5(vleff_v_w, void, ptr, ptr, tl, env, i32) | ||
40 | +DEF_HELPER_5(vleff_v_d, void, ptr, ptr, tl, env, i32) | ||
41 | +DEF_HELPER_5(vlbuff_v_b, void, ptr, ptr, tl, env, i32) | ||
42 | +DEF_HELPER_5(vlbuff_v_h, void, ptr, ptr, tl, env, i32) | ||
43 | +DEF_HELPER_5(vlbuff_v_w, void, ptr, ptr, tl, env, i32) | ||
44 | +DEF_HELPER_5(vlbuff_v_d, void, ptr, ptr, tl, env, i32) | ||
45 | +DEF_HELPER_5(vlhuff_v_h, void, ptr, ptr, tl, env, i32) | ||
46 | +DEF_HELPER_5(vlhuff_v_w, void, ptr, ptr, tl, env, i32) | ||
47 | +DEF_HELPER_5(vlhuff_v_d, void, ptr, ptr, tl, env, i32) | ||
48 | +DEF_HELPER_5(vlwuff_v_w, void, ptr, ptr, tl, env, i32) | ||
49 | +DEF_HELPER_5(vlwuff_v_d, void, ptr, ptr, tl, env, i32) | ||
50 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/riscv/insn32.decode | ||
53 | +++ b/target/riscv/insn32.decode | ||
54 | @@ -XXX,XX +XXX,XX @@ vle_v ... 000 . 00000 ..... 111 ..... 0000111 @r2_nfvm | ||
55 | vlbu_v ... 000 . 00000 ..... 000 ..... 0000111 @r2_nfvm | ||
56 | vlhu_v ... 000 . 00000 ..... 101 ..... 0000111 @r2_nfvm | ||
57 | vlwu_v ... 000 . 00000 ..... 110 ..... 0000111 @r2_nfvm | ||
58 | +vlbff_v ... 100 . 10000 ..... 000 ..... 0000111 @r2_nfvm | ||
59 | +vlhff_v ... 100 . 10000 ..... 101 ..... 0000111 @r2_nfvm | ||
60 | +vlwff_v ... 100 . 10000 ..... 110 ..... 0000111 @r2_nfvm | ||
61 | +vleff_v ... 000 . 10000 ..... 111 ..... 0000111 @r2_nfvm | ||
62 | +vlbuff_v ... 000 . 10000 ..... 000 ..... 0000111 @r2_nfvm | ||
63 | +vlhuff_v ... 000 . 10000 ..... 101 ..... 0000111 @r2_nfvm | ||
64 | +vlwuff_v ... 000 . 10000 ..... 110 ..... 0000111 @r2_nfvm | ||
65 | vsb_v ... 000 . 00000 ..... 000 ..... 0100111 @r2_nfvm | ||
66 | vsh_v ... 000 . 00000 ..... 101 ..... 0100111 @r2_nfvm | ||
67 | vsw_v ... 000 . 00000 ..... 110 ..... 0100111 @r2_nfvm | ||
68 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
71 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_TRANS(vsxb_v, 0, rnfvm, st_index_op, st_index_check) | ||
73 | GEN_VEXT_TRANS(vsxh_v, 1, rnfvm, st_index_op, st_index_check) | ||
74 | GEN_VEXT_TRANS(vsxw_v, 2, rnfvm, st_index_op, st_index_check) | ||
75 | GEN_VEXT_TRANS(vsxe_v, 3, rnfvm, st_index_op, st_index_check) | ||
76 | + | ||
77 | +/* | ||
78 | + *** unit stride fault-only-first load | ||
79 | + */ | ||
80 | +static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data, | ||
81 | + gen_helper_ldst_us *fn, DisasContext *s) | ||
82 | +{ | 29 | +{ |
83 | + TCGv_ptr dest, mask; | 30 | + if (s->mstatus_fs == EXT_STATUS_DISABLED) { |
84 | + TCGv base; | ||
85 | + TCGv_i32 desc; | ||
86 | + | ||
87 | + TCGLabel *over = gen_new_label(); | ||
88 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
89 | + | ||
90 | + dest = tcg_temp_new_ptr(); | ||
91 | + mask = tcg_temp_new_ptr(); | ||
92 | + base = tcg_temp_new(); | ||
93 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
94 | + | ||
95 | + gen_get_gpr(base, rs1); | ||
96 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
97 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
98 | + | ||
99 | + fn(dest, mask, base, cpu_env, desc); | ||
100 | + | ||
101 | + tcg_temp_free_ptr(dest); | ||
102 | + tcg_temp_free_ptr(mask); | ||
103 | + tcg_temp_free(base); | ||
104 | + tcg_temp_free_i32(desc); | ||
105 | + gen_set_label(over); | ||
106 | + return true; | ||
107 | +} | ||
108 | + | ||
109 | +static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) | ||
110 | +{ | ||
111 | + uint32_t data = 0; | ||
112 | + gen_helper_ldst_us *fn; | ||
113 | + static gen_helper_ldst_us * const fns[7][4] = { | ||
114 | + { gen_helper_vlbff_v_b, gen_helper_vlbff_v_h, | ||
115 | + gen_helper_vlbff_v_w, gen_helper_vlbff_v_d }, | ||
116 | + { NULL, gen_helper_vlhff_v_h, | ||
117 | + gen_helper_vlhff_v_w, gen_helper_vlhff_v_d }, | ||
118 | + { NULL, NULL, | ||
119 | + gen_helper_vlwff_v_w, gen_helper_vlwff_v_d }, | ||
120 | + { gen_helper_vleff_v_b, gen_helper_vleff_v_h, | ||
121 | + gen_helper_vleff_v_w, gen_helper_vleff_v_d }, | ||
122 | + { gen_helper_vlbuff_v_b, gen_helper_vlbuff_v_h, | ||
123 | + gen_helper_vlbuff_v_w, gen_helper_vlbuff_v_d }, | ||
124 | + { NULL, gen_helper_vlhuff_v_h, | ||
125 | + gen_helper_vlhuff_v_w, gen_helper_vlhuff_v_d }, | ||
126 | + { NULL, NULL, | ||
127 | + gen_helper_vlwuff_v_w, gen_helper_vlwuff_v_d } | ||
128 | + }; | ||
129 | + | ||
130 | + fn = fns[seq][s->sew]; | ||
131 | + if (fn == NULL) { | ||
132 | + return false; | 31 | + return false; |
133 | + } | 32 | + } |
134 | + | 33 | + |
135 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | 34 | + switch (s->sew) { |
136 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | 35 | + case MO_16: |
137 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | 36 | + return s->cfg_ptr->ext_zvfhmin; |
138 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | 37 | + case MO_32: |
139 | + return ldff_trans(a->rd, a->rs1, data, fn, s); | 38 | + return s->cfg_ptr->ext_zve32f; |
140 | +} | 39 | + default: |
141 | + | 40 | + return false; |
142 | +GEN_VEXT_TRANS(vlbff_v, 0, r2nfvm, ldff_op, ld_us_check) | ||
143 | +GEN_VEXT_TRANS(vlhff_v, 1, r2nfvm, ldff_op, ld_us_check) | ||
144 | +GEN_VEXT_TRANS(vlwff_v, 2, r2nfvm, ldff_op, ld_us_check) | ||
145 | +GEN_VEXT_TRANS(vleff_v, 3, r2nfvm, ldff_op, ld_us_check) | ||
146 | +GEN_VEXT_TRANS(vlbuff_v, 4, r2nfvm, ldff_op, ld_us_check) | ||
147 | +GEN_VEXT_TRANS(vlhuff_v, 5, r2nfvm, ldff_op, ld_us_check) | ||
148 | +GEN_VEXT_TRANS(vlwuff_v, 6, r2nfvm, ldff_op, ld_us_check) | ||
149 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/target/riscv/vector_helper.c | ||
152 | +++ b/target/riscv/vector_helper.c | ||
153 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_ST_INDEX(vsxe_v_b, int8_t, int8_t, idx_b, ste_b) | ||
154 | GEN_VEXT_ST_INDEX(vsxe_v_h, int16_t, int16_t, idx_h, ste_h) | ||
155 | GEN_VEXT_ST_INDEX(vsxe_v_w, int32_t, int32_t, idx_w, ste_w) | ||
156 | GEN_VEXT_ST_INDEX(vsxe_v_d, int64_t, int64_t, idx_d, ste_d) | ||
157 | + | ||
158 | +/* | ||
159 | + *** unit-stride fault-only-fisrt load instructions | ||
160 | + */ | ||
161 | +static inline void | ||
162 | +vext_ldff(void *vd, void *v0, target_ulong base, | ||
163 | + CPURISCVState *env, uint32_t desc, | ||
164 | + vext_ldst_elem_fn *ldst_elem, | ||
165 | + clear_fn *clear_elem, | ||
166 | + uint32_t esz, uint32_t msz, uintptr_t ra) | ||
167 | +{ | ||
168 | + void *host; | ||
169 | + uint32_t i, k, vl = 0; | ||
170 | + uint32_t mlen = vext_mlen(desc); | ||
171 | + uint32_t nf = vext_nf(desc); | ||
172 | + uint32_t vm = vext_vm(desc); | ||
173 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
174 | + target_ulong addr, offset, remain; | ||
175 | + | ||
176 | + /* probe every access*/ | ||
177 | + for (i = 0; i < env->vl; i++) { | ||
178 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
179 | + continue; | ||
180 | + } | ||
181 | + addr = base + nf * i * msz; | ||
182 | + if (i == 0) { | ||
183 | + probe_pages(env, addr, nf * msz, ra, MMU_DATA_LOAD); | ||
184 | + } else { | ||
185 | + /* if it triggers an exception, no need to check watchpoint */ | ||
186 | + remain = nf * msz; | ||
187 | + while (remain > 0) { | ||
188 | + offset = -(addr | TARGET_PAGE_MASK); | ||
189 | + host = tlb_vaddr_to_host(env, addr, MMU_DATA_LOAD, | ||
190 | + cpu_mmu_index(env, false)); | ||
191 | + if (host) { | ||
192 | +#ifdef CONFIG_USER_ONLY | ||
193 | + if (page_check_range(addr, nf * msz, PAGE_READ) < 0) { | ||
194 | + vl = i; | ||
195 | + goto ProbeSuccess; | ||
196 | + } | ||
197 | +#else | ||
198 | + probe_pages(env, addr, nf * msz, ra, MMU_DATA_LOAD); | ||
199 | +#endif | ||
200 | + } else { | ||
201 | + vl = i; | ||
202 | + goto ProbeSuccess; | ||
203 | + } | ||
204 | + if (remain <= offset) { | ||
205 | + break; | ||
206 | + } | ||
207 | + remain -= offset; | ||
208 | + addr += offset; | ||
209 | + } | ||
210 | + } | ||
211 | + } | ||
212 | +ProbeSuccess: | ||
213 | + /* load bytes from guest memory */ | ||
214 | + if (vl != 0) { | ||
215 | + env->vl = vl; | ||
216 | + } | ||
217 | + for (i = 0; i < env->vl; i++) { | ||
218 | + k = 0; | ||
219 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
220 | + continue; | ||
221 | + } | ||
222 | + while (k < nf) { | ||
223 | + target_ulong addr = base + (i * nf + k) * msz; | ||
224 | + ldst_elem(env, addr, i + k * vlmax, vd, ra); | ||
225 | + k++; | ||
226 | + } | ||
227 | + } | ||
228 | + /* clear tail elements */ | ||
229 | + if (vl != 0) { | ||
230 | + return; | ||
231 | + } | ||
232 | + for (k = 0; k < nf; k++) { | ||
233 | + clear_elem(vd, env->vl + k * vlmax, env->vl * esz, vlmax * esz); | ||
234 | + } | 41 | + } |
235 | +} | 42 | +} |
236 | + | 43 | + |
237 | +#define GEN_VEXT_LDFF(NAME, MTYPE, ETYPE, LOAD_FN, CLEAR_FN) \ | 44 | static bool require_scale_rvf(DisasContext *s) |
238 | +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ | 45 | { |
239 | + CPURISCVState *env, uint32_t desc) \ | 46 | if (s->mstatus_fs == EXT_STATUS_DISABLED) { |
240 | +{ \ | 47 | @@ -XXX,XX +XXX,XX @@ static bool require_scale_rvfmin(DisasContext *s) |
241 | + vext_ldff(vd, v0, base, env, desc, LOAD_FN, CLEAR_FN, \ | 48 | } |
242 | + sizeof(ETYPE), sizeof(MTYPE), GETPC()); \ | 49 | |
243 | +} | 50 | switch (s->sew) { |
244 | + | 51 | - case MO_8: |
245 | +GEN_VEXT_LDFF(vlbff_v_b, int8_t, int8_t, ldb_b, clearb) | 52 | - return s->cfg_ptr->ext_zvfhmin; |
246 | +GEN_VEXT_LDFF(vlbff_v_h, int8_t, int16_t, ldb_h, clearh) | 53 | case MO_16: |
247 | +GEN_VEXT_LDFF(vlbff_v_w, int8_t, int32_t, ldb_w, clearl) | 54 | return s->cfg_ptr->ext_zve32f; |
248 | +GEN_VEXT_LDFF(vlbff_v_d, int8_t, int64_t, ldb_d, clearq) | 55 | case MO_32: |
249 | +GEN_VEXT_LDFF(vlhff_v_h, int16_t, int16_t, ldh_h, clearh) | 56 | @@ -XXX,XX +XXX,XX @@ static bool opxfv_widen_check(DisasContext *s, arg_rmr *a) |
250 | +GEN_VEXT_LDFF(vlhff_v_w, int16_t, int32_t, ldh_w, clearl) | 57 | static bool opffv_widen_check(DisasContext *s, arg_rmr *a) |
251 | +GEN_VEXT_LDFF(vlhff_v_d, int16_t, int64_t, ldh_d, clearq) | 58 | { |
252 | +GEN_VEXT_LDFF(vlwff_v_w, int32_t, int32_t, ldw_w, clearl) | 59 | return opfv_widen_check(s, a) && |
253 | +GEN_VEXT_LDFF(vlwff_v_d, int32_t, int64_t, ldw_d, clearq) | 60 | + require_rvfmin(s) && |
254 | +GEN_VEXT_LDFF(vleff_v_b, int8_t, int8_t, lde_b, clearb) | 61 | require_scale_rvfmin(s) && |
255 | +GEN_VEXT_LDFF(vleff_v_h, int16_t, int16_t, lde_h, clearh) | 62 | (s->sew != MO_8); |
256 | +GEN_VEXT_LDFF(vleff_v_w, int32_t, int32_t, lde_w, clearl) | 63 | } |
257 | +GEN_VEXT_LDFF(vleff_v_d, int64_t, int64_t, lde_d, clearq) | 64 | @@ -XXX,XX +XXX,XX @@ static bool opfxv_narrow_check(DisasContext *s, arg_rmr *a) |
258 | +GEN_VEXT_LDFF(vlbuff_v_b, uint8_t, uint8_t, ldbu_b, clearb) | 65 | static bool opffv_narrow_check(DisasContext *s, arg_rmr *a) |
259 | +GEN_VEXT_LDFF(vlbuff_v_h, uint8_t, uint16_t, ldbu_h, clearh) | 66 | { |
260 | +GEN_VEXT_LDFF(vlbuff_v_w, uint8_t, uint32_t, ldbu_w, clearl) | 67 | return opfv_narrow_check(s, a) && |
261 | +GEN_VEXT_LDFF(vlbuff_v_d, uint8_t, uint64_t, ldbu_d, clearq) | 68 | + require_rvfmin(s) && |
262 | +GEN_VEXT_LDFF(vlhuff_v_h, uint16_t, uint16_t, ldhu_h, clearh) | 69 | require_scale_rvfmin(s) && |
263 | +GEN_VEXT_LDFF(vlhuff_v_w, uint16_t, uint32_t, ldhu_w, clearl) | 70 | (s->sew != MO_8); |
264 | +GEN_VEXT_LDFF(vlhuff_v_d, uint16_t, uint64_t, ldhu_d, clearq) | 71 | } |
265 | +GEN_VEXT_LDFF(vlwuff_v_w, uint32_t, uint32_t, ldwu_w, clearl) | ||
266 | +GEN_VEXT_LDFF(vlwuff_v_d, uint32_t, uint64_t, ldwu_d, clearq) | ||
267 | -- | 72 | -- |
268 | 2.27.0 | 73 | 2.45.1 |
269 | |||
270 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Max Chou <max.chou@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | The require_scale_rvf function only checks the double width operator for |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | the vector floating point widen instructions, so most of the widen |
5 | Message-id: 20200623215920.2594-55-zhiwei_liu@c-sky.com | 5 | checking functions need to add require_rvf for single width operator. |
6 | |||
7 | The vfwcvt.f.x.v and vfwcvt.f.xu.v instructions convert single width | ||
8 | integer to double width float, so the opfxv_widen_check function doesn’t | ||
9 | need require_rvf for the single width operator(integer). | ||
10 | |||
11 | Signed-off-by: Max Chou <max.chou@sifive.com> | ||
12 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
13 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
14 | Message-ID: <20240322092600.1198921-3-max.chou@sifive.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 16 | --- |
8 | target/riscv/helper.h | 5 +++++ | 17 | target/riscv/insn_trans/trans_rvv.c.inc | 5 +++++ |
9 | target/riscv/insn32.decode | 2 ++ | 18 | 1 file changed, 5 insertions(+) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 25 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 24 ++++++++++++++++++++++++ | ||
12 | 4 files changed, 56 insertions(+) | ||
13 | 19 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 20 | diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 22 | --- a/target/riscv/insn_trans/trans_rvv.c.inc |
17 | +++ b/target/riscv/helper.h | 23 | +++ b/target/riscv/insn_trans/trans_rvv.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(viota_m_b, void, ptr, ptr, ptr, env, i32) | 24 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVF_TRANS(vfrsub_vf, opfvf_check) |
19 | DEF_HELPER_5(viota_m_h, void, ptr, ptr, ptr, env, i32) | 25 | static bool opfvv_widen_check(DisasContext *s, arg_rmrr *a) |
20 | DEF_HELPER_5(viota_m_w, void, ptr, ptr, ptr, env, i32) | 26 | { |
21 | DEF_HELPER_5(viota_m_d, void, ptr, ptr, ptr, env, i32) | 27 | return require_rvv(s) && |
22 | + | 28 | + require_rvf(s) && |
23 | +DEF_HELPER_4(vid_v_b, void, ptr, ptr, env, i32) | 29 | require_scale_rvf(s) && |
24 | +DEF_HELPER_4(vid_v_h, void, ptr, ptr, env, i32) | 30 | (s->sew != MO_8) && |
25 | +DEF_HELPER_4(vid_v_w, void, ptr, ptr, env, i32) | 31 | vext_check_isa_ill(s) && |
26 | +DEF_HELPER_4(vid_v_d, void, ptr, ptr, env, i32) | 32 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVV_WIDEN_TRANS(vfwsub_vv, opfvv_widen_check) |
27 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 33 | static bool opfvf_widen_check(DisasContext *s, arg_rmrr *a) |
28 | index XXXXXXX..XXXXXXX 100644 | 34 | { |
29 | --- a/target/riscv/insn32.decode | 35 | return require_rvv(s) && |
30 | +++ b/target/riscv/insn32.decode | 36 | + require_rvf(s) && |
31 | @@ -XXX,XX +XXX,XX @@ | 37 | require_scale_rvf(s) && |
32 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | 38 | (s->sew != MO_8) && |
33 | @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | 39 | vext_check_isa_ill(s) && |
34 | @r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd | 40 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVF_WIDEN_TRANS(vfwsub_vf) |
35 | +@r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd | 41 | static bool opfwv_widen_check(DisasContext *s, arg_rmrr *a) |
36 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | 42 | { |
37 | @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | 43 | return require_rvv(s) && |
38 | @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd | 44 | + require_rvf(s) && |
39 | @@ -XXX,XX +XXX,XX @@ vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm | 45 | require_scale_rvf(s) && |
40 | vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm | 46 | (s->sew != MO_8) && |
41 | vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | 47 | vext_check_isa_ill(s) && |
42 | viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | 48 | @@ -XXX,XX +XXX,XX @@ GEN_OPFWV_WIDEN_TRANS(vfwsub_wv) |
43 | +vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm | 49 | static bool opfwf_widen_check(DisasContext *s, arg_rmrr *a) |
44 | 50 | { | |
45 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 51 | return require_rvv(s) && |
46 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 52 | + require_rvf(s) && |
47 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 53 | require_scale_rvf(s) && |
48 | index XXXXXXX..XXXXXXX 100644 | 54 | (s->sew != MO_8) && |
49 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 55 | vext_check_isa_ill(s) && |
50 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 56 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVV_TRANS(vfredmin_vs, freduction_check) |
51 | @@ -XXX,XX +XXX,XX @@ static bool trans_viota_m(DisasContext *s, arg_viota_m *a) | 57 | static bool freduction_widen_check(DisasContext *s, arg_rmrr *a) |
52 | } | 58 | { |
53 | return false; | 59 | return reduction_widen_check(s, a) && |
60 | + require_rvf(s) && | ||
61 | require_scale_rvf(s) && | ||
62 | (s->sew != MO_8); | ||
54 | } | 63 | } |
55 | + | ||
56 | +/* Vector Element Index Instruction */ | ||
57 | +static bool trans_vid_v(DisasContext *s, arg_vid_v *a) | ||
58 | +{ | ||
59 | + if (vext_check_isa_ill(s) && | ||
60 | + vext_check_reg(s, a->rd, false) && | ||
61 | + vext_check_overlap_mask(s, a->rd, a->vm, false)) { | ||
62 | + uint32_t data = 0; | ||
63 | + TCGLabel *over = gen_new_label(); | ||
64 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
65 | + | ||
66 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
67 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
68 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
69 | + static gen_helper_gvec_2_ptr * const fns[4] = { | ||
70 | + gen_helper_vid_v_b, gen_helper_vid_v_h, | ||
71 | + gen_helper_vid_v_w, gen_helper_vid_v_d, | ||
72 | + }; | ||
73 | + tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), | ||
74 | + cpu_env, 0, s->vlen / 8, data, fns[s->sew]); | ||
75 | + gen_set_label(over); | ||
76 | + return true; | ||
77 | + } | ||
78 | + return false; | ||
79 | +} | ||
80 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/riscv/vector_helper.c | ||
83 | +++ b/target/riscv/vector_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VIOTA_M(viota_m_b, uint8_t, H1, clearb) | ||
85 | GEN_VEXT_VIOTA_M(viota_m_h, uint16_t, H2, clearh) | ||
86 | GEN_VEXT_VIOTA_M(viota_m_w, uint32_t, H4, clearl) | ||
87 | GEN_VEXT_VIOTA_M(viota_m_d, uint64_t, H8, clearq) | ||
88 | + | ||
89 | +/* Vector Element Index Instruction */ | ||
90 | +#define GEN_VEXT_VID_V(NAME, ETYPE, H, CLEAR_FN) \ | ||
91 | +void HELPER(NAME)(void *vd, void *v0, CPURISCVState *env, uint32_t desc) \ | ||
92 | +{ \ | ||
93 | + uint32_t mlen = vext_mlen(desc); \ | ||
94 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
95 | + uint32_t vm = vext_vm(desc); \ | ||
96 | + uint32_t vl = env->vl; \ | ||
97 | + int i; \ | ||
98 | + \ | ||
99 | + for (i = 0; i < vl; i++) { \ | ||
100 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
101 | + continue; \ | ||
102 | + } \ | ||
103 | + *((ETYPE *)vd + H(i)) = i; \ | ||
104 | + } \ | ||
105 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
106 | +} | ||
107 | + | ||
108 | +GEN_VEXT_VID_V(vid_v_b, uint8_t, H1, clearb) | ||
109 | +GEN_VEXT_VID_V(vid_v_h, uint16_t, H2, clearh) | ||
110 | +GEN_VEXT_VID_V(vid_v_w, uint32_t, H4, clearl) | ||
111 | +GEN_VEXT_VID_V(vid_v_d, uint64_t, H8, clearq) | ||
112 | -- | 64 | -- |
113 | 2.27.0 | 65 | 2.45.1 |
114 | 66 | ||
115 | 67 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Max Chou <max.chou@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | The opfv_narrow_check needs to check the single width float operator by |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | require_rvf. |
5 | Message-id: 20200623215920.2594-54-zhiwei_liu@c-sky.com | 5 | |
6 | Signed-off-by: Max Chou <max.chou@sifive.com> | ||
7 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
8 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
9 | Message-ID: <20240322092600.1198921-4-max.chou@sifive.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 11 | --- |
8 | target/riscv/helper.h | 5 +++++ | 12 | target/riscv/insn_trans/trans_rvv.c.inc | 1 + |
9 | target/riscv/insn32.decode | 1 + | 13 | 1 file changed, 1 insertion(+) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 27 +++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 29 +++++++++++++++++++++++++ | ||
12 | 4 files changed, 62 insertions(+) | ||
13 | 14 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 15 | diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 17 | --- a/target/riscv/insn_trans/trans_rvv.c.inc |
17 | +++ b/target/riscv/helper.h | 18 | +++ b/target/riscv/insn_trans/trans_rvv.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vmfirst_m, tl, ptr, ptr, env, i32) | 19 | @@ -XXX,XX +XXX,XX @@ static bool opffv_narrow_check(DisasContext *s, arg_rmr *a) |
19 | DEF_HELPER_5(vmsbf_m, void, ptr, ptr, ptr, env, i32) | 20 | static bool opffv_rod_narrow_check(DisasContext *s, arg_rmr *a) |
20 | DEF_HELPER_5(vmsif_m, void, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_5(vmsof_m, void, ptr, ptr, ptr, env, i32) | ||
22 | + | ||
23 | +DEF_HELPER_5(viota_m_b, void, ptr, ptr, ptr, env, i32) | ||
24 | +DEF_HELPER_5(viota_m_h, void, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_5(viota_m_w, void, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_5(viota_m_d, void, ptr, ptr, ptr, env, i32) | ||
27 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/riscv/insn32.decode | ||
30 | +++ b/target/riscv/insn32.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ vmfirst_m 010101 . ..... ----- 010 ..... 1010111 @r2_vm | ||
32 | vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm | ||
33 | vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm | ||
34 | vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | ||
35 | +viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | ||
36 | |||
37 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
38 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
39 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
42 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ | ||
44 | GEN_M_TRANS(vmsbf_m) | ||
45 | GEN_M_TRANS(vmsif_m) | ||
46 | GEN_M_TRANS(vmsof_m) | ||
47 | + | ||
48 | +/* Vector Iota Instruction */ | ||
49 | +static bool trans_viota_m(DisasContext *s, arg_viota_m *a) | ||
50 | +{ | ||
51 | + if (vext_check_isa_ill(s) && | ||
52 | + vext_check_reg(s, a->rd, false) && | ||
53 | + vext_check_overlap_group(a->rd, 1 << s->lmul, a->rs2, 1) && | ||
54 | + (a->vm != 0 || a->rd != 0)) { | ||
55 | + uint32_t data = 0; | ||
56 | + TCGLabel *over = gen_new_label(); | ||
57 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
58 | + | ||
59 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
60 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
61 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
62 | + static gen_helper_gvec_3_ptr * const fns[4] = { | ||
63 | + gen_helper_viota_m_b, gen_helper_viota_m_h, | ||
64 | + gen_helper_viota_m_w, gen_helper_viota_m_d, | ||
65 | + }; | ||
66 | + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), | ||
67 | + vreg_ofs(s, a->rs2), cpu_env, 0, | ||
68 | + s->vlen / 8, data, fns[s->sew]); | ||
69 | + gen_set_label(over); | ||
70 | + return true; | ||
71 | + } | ||
72 | + return false; | ||
73 | +} | ||
74 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/target/riscv/vector_helper.c | ||
77 | +++ b/target/riscv/vector_helper.c | ||
78 | @@ -XXX,XX +XXX,XX @@ void HELPER(vmsof_m)(void *vd, void *v0, void *vs2, CPURISCVState *env, | ||
79 | { | 21 | { |
80 | vmsetm(vd, v0, vs2, env, desc, ONLY_FIRST); | 22 | return opfv_narrow_check(s, a) && |
23 | + require_rvf(s) && | ||
24 | require_scale_rvf(s) && | ||
25 | (s->sew != MO_8); | ||
81 | } | 26 | } |
82 | + | ||
83 | +/* Vector Iota Instruction */ | ||
84 | +#define GEN_VEXT_VIOTA_M(NAME, ETYPE, H, CLEAR_FN) \ | ||
85 | +void HELPER(NAME)(void *vd, void *v0, void *vs2, CPURISCVState *env, \ | ||
86 | + uint32_t desc) \ | ||
87 | +{ \ | ||
88 | + uint32_t mlen = vext_mlen(desc); \ | ||
89 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
90 | + uint32_t vm = vext_vm(desc); \ | ||
91 | + uint32_t vl = env->vl; \ | ||
92 | + uint32_t sum = 0; \ | ||
93 | + int i; \ | ||
94 | + \ | ||
95 | + for (i = 0; i < vl; i++) { \ | ||
96 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
97 | + continue; \ | ||
98 | + } \ | ||
99 | + *((ETYPE *)vd + H(i)) = sum; \ | ||
100 | + if (vext_elem_mask(vs2, mlen, i)) { \ | ||
101 | + sum++; \ | ||
102 | + } \ | ||
103 | + } \ | ||
104 | + CLEAR_FN(vd, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ | ||
105 | +} | ||
106 | + | ||
107 | +GEN_VEXT_VIOTA_M(viota_m_b, uint8_t, H1, clearb) | ||
108 | +GEN_VEXT_VIOTA_M(viota_m_h, uint16_t, H2, clearh) | ||
109 | +GEN_VEXT_VIOTA_M(viota_m_w, uint32_t, H4, clearl) | ||
110 | +GEN_VEXT_VIOTA_M(viota_m_d, uint64_t, H8, clearq) | ||
111 | -- | 27 | -- |
112 | 2.27.0 | 28 | 2.45.1 |
113 | |||
114 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Max Chou <max.chou@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | If the checking functions check both the single and double width |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | operators at the same time, then the single width operator checking |
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 5 | functions (require_rvf[min]) will check whether the SEW is 8. |
6 | Message-id: 20200623215920.2594-41-zhiwei_liu@c-sky.com | 6 | |
7 | Signed-off-by: Max Chou <max.chou@sifive.com> | ||
8 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
9 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
10 | Message-ID: <20240322092600.1198921-5-max.chou@sifive.com> | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
8 | --- | 12 | --- |
9 | target/riscv/helper.h | 4 ++ | 13 | target/riscv/insn_trans/trans_rvv.c.inc | 16 ++++------------ |
10 | target/riscv/internals.h | 5 ++ | 14 | 1 file changed, 4 insertions(+), 12 deletions(-) |
11 | target/riscv/insn32.decode | 1 + | ||
12 | target/riscv/fpu_helper.c | 33 +-------- | ||
13 | target/riscv/insn_trans/trans_rvv.inc.c | 3 + | ||
14 | target/riscv/vector_helper.c | 91 +++++++++++++++++++++++++ | ||
15 | 6 files changed, 107 insertions(+), 30 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 16 | diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/riscv/helper.h | 18 | --- a/target/riscv/insn_trans/trans_rvv.c.inc |
20 | +++ b/target/riscv/helper.h | 19 | +++ b/target/riscv/insn_trans/trans_rvv.c.inc |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmford_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | 20 | @@ -XXX,XX +XXX,XX @@ static bool opfvv_widen_check(DisasContext *s, arg_rmrr *a) |
22 | DEF_HELPER_6(vmford_vf_h, void, ptr, ptr, i64, ptr, env, i32) | 21 | return require_rvv(s) && |
23 | DEF_HELPER_6(vmford_vf_w, void, ptr, ptr, i64, ptr, env, i32) | 22 | require_rvf(s) && |
24 | DEF_HELPER_6(vmford_vf_d, void, ptr, ptr, i64, ptr, env, i32) | 23 | require_scale_rvf(s) && |
25 | + | 24 | - (s->sew != MO_8) && |
26 | +DEF_HELPER_5(vfclass_v_h, void, ptr, ptr, ptr, env, i32) | 25 | vext_check_isa_ill(s) && |
27 | +DEF_HELPER_5(vfclass_v_w, void, ptr, ptr, ptr, env, i32) | 26 | vext_check_dss(s, a->rd, a->rs1, a->rs2, a->vm); |
28 | +DEF_HELPER_5(vfclass_v_d, void, ptr, ptr, ptr, env, i32) | 27 | } |
29 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | 28 | @@ -XXX,XX +XXX,XX @@ static bool opfvf_widen_check(DisasContext *s, arg_rmrr *a) |
30 | index XXXXXXX..XXXXXXX 100644 | 29 | return require_rvv(s) && |
31 | --- a/target/riscv/internals.h | 30 | require_rvf(s) && |
32 | +++ b/target/riscv/internals.h | 31 | require_scale_rvf(s) && |
33 | @@ -XXX,XX +XXX,XX @@ FIELD(VDATA, VM, 8, 1) | 32 | - (s->sew != MO_8) && |
34 | FIELD(VDATA, LMUL, 9, 2) | 33 | vext_check_isa_ill(s) && |
35 | FIELD(VDATA, NF, 11, 4) | 34 | vext_check_ds(s, a->rd, a->rs2, a->vm); |
36 | FIELD(VDATA, WD, 11, 1) | 35 | } |
37 | + | 36 | @@ -XXX,XX +XXX,XX @@ static bool opfwv_widen_check(DisasContext *s, arg_rmrr *a) |
38 | +/* float point classify helpers */ | 37 | return require_rvv(s) && |
39 | +target_ulong fclass_h(uint64_t frs1); | 38 | require_rvf(s) && |
40 | +target_ulong fclass_s(uint64_t frs1); | 39 | require_scale_rvf(s) && |
41 | +target_ulong fclass_d(uint64_t frs1); | 40 | - (s->sew != MO_8) && |
42 | #endif | 41 | vext_check_isa_ill(s) && |
43 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 42 | vext_check_dds(s, a->rd, a->rs1, a->rs2, a->vm); |
44 | index XXXXXXX..XXXXXXX 100644 | 43 | } |
45 | --- a/target/riscv/insn32.decode | 44 | @@ -XXX,XX +XXX,XX @@ static bool opfwf_widen_check(DisasContext *s, arg_rmrr *a) |
46 | +++ b/target/riscv/insn32.decode | 45 | return require_rvv(s) && |
47 | @@ -XXX,XX +XXX,XX @@ vmfgt_vf 011101 . ..... ..... 101 ..... 1010111 @r_vm | 46 | require_rvf(s) && |
48 | vmfge_vf 011111 . ..... ..... 101 ..... 1010111 @r_vm | 47 | require_scale_rvf(s) && |
49 | vmford_vv 011010 . ..... ..... 001 ..... 1010111 @r_vm | 48 | - (s->sew != MO_8) && |
50 | vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm | 49 | vext_check_isa_ill(s) && |
51 | +vfclass_v 100011 . ..... 10000 001 ..... 1010111 @r2_vm | 50 | vext_check_dd(s, a->rd, a->rs2, a->vm); |
52 | 51 | } | |
53 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 52 | @@ -XXX,XX +XXX,XX @@ static bool opffv_widen_check(DisasContext *s, arg_rmr *a) |
54 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
55 | diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/riscv/fpu_helper.c | ||
58 | +++ b/target/riscv/fpu_helper.c | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | #include "exec/exec-all.h" | ||
61 | #include "exec/helper-proto.h" | ||
62 | #include "fpu/softfloat.h" | ||
63 | +#include "internals.h" | ||
64 | |||
65 | target_ulong riscv_cpu_get_fflags(CPURISCVState *env) | ||
66 | { | 53 | { |
67 | @@ -XXX,XX +XXX,XX @@ uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t rs1) | 54 | return opfv_widen_check(s, a) && |
68 | 55 | require_rvfmin(s) && | |
69 | target_ulong helper_fclass_s(uint64_t frs1) | 56 | - require_scale_rvfmin(s) && |
57 | - (s->sew != MO_8); | ||
58 | + require_scale_rvfmin(s); | ||
59 | } | ||
60 | |||
61 | #define GEN_OPFV_WIDEN_TRANS(NAME, CHECK, HELPER, FRM) \ | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool opffv_narrow_check(DisasContext *s, arg_rmr *a) | ||
70 | { | 63 | { |
71 | - float32 f = frs1; | 64 | return opfv_narrow_check(s, a) && |
72 | - bool sign = float32_is_neg(f); | 65 | require_rvfmin(s) && |
73 | - | 66 | - require_scale_rvfmin(s) && |
74 | - if (float32_is_infinity(f)) { | 67 | - (s->sew != MO_8); |
75 | - return sign ? 1 << 0 : 1 << 7; | 68 | + require_scale_rvfmin(s); |
76 | - } else if (float32_is_zero(f)) { | ||
77 | - return sign ? 1 << 3 : 1 << 4; | ||
78 | - } else if (float32_is_zero_or_denormal(f)) { | ||
79 | - return sign ? 1 << 2 : 1 << 5; | ||
80 | - } else if (float32_is_any_nan(f)) { | ||
81 | - float_status s = { }; /* for snan_bit_is_one */ | ||
82 | - return float32_is_quiet_nan(f, &s) ? 1 << 9 : 1 << 8; | ||
83 | - } else { | ||
84 | - return sign ? 1 << 1 : 1 << 6; | ||
85 | - } | ||
86 | + return fclass_s(frs1); | ||
87 | } | 69 | } |
88 | 70 | ||
89 | uint64_t helper_fadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) | 71 | static bool opffv_rod_narrow_check(DisasContext *s, arg_rmr *a) |
90 | @@ -XXX,XX +XXX,XX @@ uint64_t helper_fcvt_d_lu(CPURISCVState *env, uint64_t rs1) | ||
91 | |||
92 | target_ulong helper_fclass_d(uint64_t frs1) | ||
93 | { | 72 | { |
94 | - float64 f = frs1; | 73 | return opfv_narrow_check(s, a) && |
95 | - bool sign = float64_is_neg(f); | 74 | require_rvf(s) && |
96 | - | 75 | - require_scale_rvf(s) && |
97 | - if (float64_is_infinity(f)) { | 76 | - (s->sew != MO_8); |
98 | - return sign ? 1 << 0 : 1 << 7; | 77 | + require_scale_rvf(s); |
99 | - } else if (float64_is_zero(f)) { | ||
100 | - return sign ? 1 << 3 : 1 << 4; | ||
101 | - } else if (float64_is_zero_or_denormal(f)) { | ||
102 | - return sign ? 1 << 2 : 1 << 5; | ||
103 | - } else if (float64_is_any_nan(f)) { | ||
104 | - float_status s = { }; /* for snan_bit_is_one */ | ||
105 | - return float64_is_quiet_nan(f, &s) ? 1 << 9 : 1 << 8; | ||
106 | - } else { | ||
107 | - return sign ? 1 << 1 : 1 << 6; | ||
108 | - } | ||
109 | + return fclass_d(frs1); | ||
110 | } | 78 | } |
111 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 79 | |
112 | index XXXXXXX..XXXXXXX 100644 | 80 | #define GEN_OPFV_NARROW_TRANS(NAME, CHECK, HELPER, FRM) \ |
113 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 81 | @@ -XXX,XX +XXX,XX @@ static bool freduction_widen_check(DisasContext *s, arg_rmrr *a) |
114 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 82 | { |
115 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVF_TRANS(vmfle_vf, opfvf_cmp_check) | 83 | return reduction_widen_check(s, a) && |
116 | GEN_OPFVF_TRANS(vmfgt_vf, opfvf_cmp_check) | 84 | require_rvf(s) && |
117 | GEN_OPFVF_TRANS(vmfge_vf, opfvf_cmp_check) | 85 | - require_scale_rvf(s) && |
118 | GEN_OPFVF_TRANS(vmford_vf, opfvf_cmp_check) | 86 | - (s->sew != MO_8); |
119 | + | 87 | + require_scale_rvf(s); |
120 | +/* Vector Floating-Point Classify Instruction */ | 88 | } |
121 | +GEN_OPFV_TRANS(vfclass_v, opfv_check) | 89 | |
122 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | 90 | GEN_OPFVV_WIDEN_TRANS(vfwredusum_vs, freduction_widen_check) |
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/target/riscv/vector_helper.c | ||
125 | +++ b/target/riscv/vector_helper.c | ||
126 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_CMP_VV_ENV(vmford_vv_d, uint64_t, H8, !float64_unordered_quiet) | ||
127 | GEN_VEXT_CMP_VF(vmford_vf_h, uint16_t, H2, !float16_unordered_quiet) | ||
128 | GEN_VEXT_CMP_VF(vmford_vf_w, uint32_t, H4, !float32_unordered_quiet) | ||
129 | GEN_VEXT_CMP_VF(vmford_vf_d, uint64_t, H8, !float64_unordered_quiet) | ||
130 | + | ||
131 | +/* Vector Floating-Point Classify Instruction */ | ||
132 | +#define OPIVV1(NAME, TD, T2, TX2, HD, HS2, OP) \ | ||
133 | +static void do_##NAME(void *vd, void *vs2, int i) \ | ||
134 | +{ \ | ||
135 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
136 | + *((TD *)vd + HD(i)) = OP(s2); \ | ||
137 | +} | ||
138 | + | ||
139 | +#define GEN_VEXT_V(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
140 | +void HELPER(NAME)(void *vd, void *v0, void *vs2, \ | ||
141 | + CPURISCVState *env, uint32_t desc) \ | ||
142 | +{ \ | ||
143 | + uint32_t vlmax = vext_maxsz(desc) / ESZ; \ | ||
144 | + uint32_t mlen = vext_mlen(desc); \ | ||
145 | + uint32_t vm = vext_vm(desc); \ | ||
146 | + uint32_t vl = env->vl; \ | ||
147 | + uint32_t i; \ | ||
148 | + \ | ||
149 | + for (i = 0; i < vl; i++) { \ | ||
150 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
151 | + continue; \ | ||
152 | + } \ | ||
153 | + do_##NAME(vd, vs2, i); \ | ||
154 | + } \ | ||
155 | + CLEAR_FN(vd, vl, vl * DSZ, vlmax * DSZ); \ | ||
156 | +} | ||
157 | + | ||
158 | +target_ulong fclass_h(uint64_t frs1) | ||
159 | +{ | ||
160 | + float16 f = frs1; | ||
161 | + bool sign = float16_is_neg(f); | ||
162 | + | ||
163 | + if (float16_is_infinity(f)) { | ||
164 | + return sign ? 1 << 0 : 1 << 7; | ||
165 | + } else if (float16_is_zero(f)) { | ||
166 | + return sign ? 1 << 3 : 1 << 4; | ||
167 | + } else if (float16_is_zero_or_denormal(f)) { | ||
168 | + return sign ? 1 << 2 : 1 << 5; | ||
169 | + } else if (float16_is_any_nan(f)) { | ||
170 | + float_status s = { }; /* for snan_bit_is_one */ | ||
171 | + return float16_is_quiet_nan(f, &s) ? 1 << 9 : 1 << 8; | ||
172 | + } else { | ||
173 | + return sign ? 1 << 1 : 1 << 6; | ||
174 | + } | ||
175 | +} | ||
176 | + | ||
177 | +target_ulong fclass_s(uint64_t frs1) | ||
178 | +{ | ||
179 | + float32 f = frs1; | ||
180 | + bool sign = float32_is_neg(f); | ||
181 | + | ||
182 | + if (float32_is_infinity(f)) { | ||
183 | + return sign ? 1 << 0 : 1 << 7; | ||
184 | + } else if (float32_is_zero(f)) { | ||
185 | + return sign ? 1 << 3 : 1 << 4; | ||
186 | + } else if (float32_is_zero_or_denormal(f)) { | ||
187 | + return sign ? 1 << 2 : 1 << 5; | ||
188 | + } else if (float32_is_any_nan(f)) { | ||
189 | + float_status s = { }; /* for snan_bit_is_one */ | ||
190 | + return float32_is_quiet_nan(f, &s) ? 1 << 9 : 1 << 8; | ||
191 | + } else { | ||
192 | + return sign ? 1 << 1 : 1 << 6; | ||
193 | + } | ||
194 | +} | ||
195 | + | ||
196 | +target_ulong fclass_d(uint64_t frs1) | ||
197 | +{ | ||
198 | + float64 f = frs1; | ||
199 | + bool sign = float64_is_neg(f); | ||
200 | + | ||
201 | + if (float64_is_infinity(f)) { | ||
202 | + return sign ? 1 << 0 : 1 << 7; | ||
203 | + } else if (float64_is_zero(f)) { | ||
204 | + return sign ? 1 << 3 : 1 << 4; | ||
205 | + } else if (float64_is_zero_or_denormal(f)) { | ||
206 | + return sign ? 1 << 2 : 1 << 5; | ||
207 | + } else if (float64_is_any_nan(f)) { | ||
208 | + float_status s = { }; /* for snan_bit_is_one */ | ||
209 | + return float64_is_quiet_nan(f, &s) ? 1 << 9 : 1 << 8; | ||
210 | + } else { | ||
211 | + return sign ? 1 << 1 : 1 << 6; | ||
212 | + } | ||
213 | +} | ||
214 | + | ||
215 | +RVVCALL(OPIVV1, vfclass_v_h, OP_UU_H, H2, H2, fclass_h) | ||
216 | +RVVCALL(OPIVV1, vfclass_v_w, OP_UU_W, H4, H4, fclass_s) | ||
217 | +RVVCALL(OPIVV1, vfclass_v_d, OP_UU_D, H8, H8, fclass_d) | ||
218 | +GEN_VEXT_V(vfclass_v_h, 2, 2, clearh) | ||
219 | +GEN_VEXT_V(vfclass_v_w, 4, 4, clearl) | ||
220 | +GEN_VEXT_V(vfclass_v_d, 8, 8, clearq) | ||
221 | -- | 91 | -- |
222 | 2.27.0 | 92 | 2.45.1 |
223 | |||
224 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | raise_mmu_exception(), as is today, is prioritizing guest page faults by |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | checking first if virt_enabled && !first_stage, and then considering the |
5 | Message-id: 20200623215920.2594-52-zhiwei_liu@c-sky.com | 5 | regular inst/load/store faults. |
6 | |||
7 | There's no mention in the spec about guest page fault being a higher | ||
8 | priority that PMP faults. In fact, privileged spec section 3.7.1 says: | ||
9 | |||
10 | "Attempting to fetch an instruction from a PMP region that does not have | ||
11 | execute permissions raises an instruction access-fault exception. | ||
12 | Attempting to execute a load or load-reserved instruction which accesses | ||
13 | a physical address within a PMP region without read permissions raises a | ||
14 | load access-fault exception. Attempting to execute a store, | ||
15 | store-conditional, or AMO instruction which accesses a physical address | ||
16 | within a PMP region without write permissions raises a store | ||
17 | access-fault exception." | ||
18 | |||
19 | So, in fact, we're doing it wrong - PMP faults should always be thrown, | ||
20 | regardless of also being a first or second stage fault. | ||
21 | |||
22 | The way riscv_cpu_tlb_fill() and get_physical_address() work is | ||
23 | adequate: a TRANSLATE_PMP_FAIL error is immediately reported and | ||
24 | reflected in the 'pmp_violation' flag. What we need is to change | ||
25 | raise_mmu_exception() to prioritize it. | ||
26 | |||
27 | Reported-by: Joseph Chan <jchan@ventanamicro.com> | ||
28 | Fixes: 82d53adfbb ("target/riscv/cpu_helper.c: Invalid exception on MMU translation stage") | ||
29 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
30 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
31 | Message-ID: <20240413105929.7030-1-alexei.filippov@syntacore.com> | ||
32 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 33 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 34 | --- |
8 | target/riscv/helper.h | 2 ++ | 35 | target/riscv/cpu_helper.c | 22 ++++++++++++---------- |
9 | target/riscv/insn32.decode | 1 + | 36 | 1 file changed, 12 insertions(+), 10 deletions(-) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 19 +++++++++++++++ | ||
12 | 4 files changed, 54 insertions(+) | ||
13 | 37 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 38 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 40 | --- a/target/riscv/cpu_helper.c |
17 | +++ b/target/riscv/helper.h | 41 | +++ b/target/riscv/cpu_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmornot_mm, void, ptr, ptr, ptr, ptr, env, i32) | 42 | @@ -XXX,XX +XXX,XX @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, |
19 | DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 43 | |
20 | 44 | switch (access_type) { | |
21 | DEF_HELPER_4(vmpopc_m, tl, ptr, ptr, env, i32) | 45 | case MMU_INST_FETCH: |
22 | + | 46 | - if (env->virt_enabled && !first_stage) { |
23 | +DEF_HELPER_4(vmfirst_m, tl, ptr, ptr, env, i32) | 47 | + if (pmp_violation) { |
24 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 48 | + cs->exception_index = RISCV_EXCP_INST_ACCESS_FAULT; |
25 | index XXXXXXX..XXXXXXX 100644 | 49 | + } else if (env->virt_enabled && !first_stage) { |
26 | --- a/target/riscv/insn32.decode | 50 | cs->exception_index = RISCV_EXCP_INST_GUEST_PAGE_FAULT; |
27 | +++ b/target/riscv/insn32.decode | 51 | } else { |
28 | @@ -XXX,XX +XXX,XX @@ vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r | 52 | - cs->exception_index = pmp_violation ? |
29 | vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | 53 | - RISCV_EXCP_INST_ACCESS_FAULT : RISCV_EXCP_INST_PAGE_FAULT; |
30 | vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | 54 | + cs->exception_index = RISCV_EXCP_INST_PAGE_FAULT; |
31 | vmpopc_m 010100 . ..... ----- 010 ..... 1010111 @r2_vm | 55 | } |
32 | +vmfirst_m 010101 . ..... ----- 010 ..... 1010111 @r2_vm | 56 | break; |
33 | 57 | case MMU_DATA_LOAD: | |
34 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 58 | - if (two_stage && !first_stage) { |
35 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 59 | + if (pmp_violation) { |
36 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 60 | + cs->exception_index = RISCV_EXCP_LOAD_ACCESS_FAULT; |
37 | index XXXXXXX..XXXXXXX 100644 | 61 | + } else if (two_stage && !first_stage) { |
38 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 62 | cs->exception_index = RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT; |
39 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 63 | } else { |
40 | @@ -XXX,XX +XXX,XX @@ static bool trans_vmpopc_m(DisasContext *s, arg_rmr *a) | 64 | - cs->exception_index = pmp_violation ? |
41 | } | 65 | - RISCV_EXCP_LOAD_ACCESS_FAULT : RISCV_EXCP_LOAD_PAGE_FAULT; |
42 | return false; | 66 | + cs->exception_index = RISCV_EXCP_LOAD_PAGE_FAULT; |
43 | } | 67 | } |
44 | + | 68 | break; |
45 | +/* vmfirst find-first-set mask bit */ | 69 | case MMU_DATA_STORE: |
46 | +static bool trans_vmfirst_m(DisasContext *s, arg_rmr *a) | 70 | - if (two_stage && !first_stage) { |
47 | +{ | 71 | + if (pmp_violation) { |
48 | + if (vext_check_isa_ill(s)) { | 72 | + cs->exception_index = RISCV_EXCP_STORE_AMO_ACCESS_FAULT; |
49 | + TCGv_ptr src2, mask; | 73 | + } else if (two_stage && !first_stage) { |
50 | + TCGv dst; | 74 | cs->exception_index = RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT; |
51 | + TCGv_i32 desc; | 75 | } else { |
52 | + uint32_t data = 0; | 76 | - cs->exception_index = pmp_violation ? |
53 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | 77 | - RISCV_EXCP_STORE_AMO_ACCESS_FAULT : |
54 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | 78 | - RISCV_EXCP_STORE_PAGE_FAULT; |
55 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | 79 | + cs->exception_index = RISCV_EXCP_STORE_PAGE_FAULT; |
56 | + | 80 | } |
57 | + mask = tcg_temp_new_ptr(); | 81 | break; |
58 | + src2 = tcg_temp_new_ptr(); | 82 | default: |
59 | + dst = tcg_temp_new(); | ||
60 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
61 | + | ||
62 | + tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, a->rs2)); | ||
63 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
64 | + | ||
65 | + gen_helper_vmfirst_m(dst, mask, src2, cpu_env, desc); | ||
66 | + gen_set_gpr(a->rd, dst); | ||
67 | + | ||
68 | + tcg_temp_free_ptr(mask); | ||
69 | + tcg_temp_free_ptr(src2); | ||
70 | + tcg_temp_free(dst); | ||
71 | + tcg_temp_free_i32(desc); | ||
72 | + return true; | ||
73 | + } | ||
74 | + return false; | ||
75 | +} | ||
76 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/riscv/vector_helper.c | ||
79 | +++ b/target/riscv/vector_helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ target_ulong HELPER(vmpopc_m)(void *v0, void *vs2, CPURISCVState *env, | ||
81 | } | ||
82 | return cnt; | ||
83 | } | ||
84 | + | ||
85 | +/* vmfirst find-first-set mask bit*/ | ||
86 | +target_ulong HELPER(vmfirst_m)(void *v0, void *vs2, CPURISCVState *env, | ||
87 | + uint32_t desc) | ||
88 | +{ | ||
89 | + uint32_t mlen = vext_mlen(desc); | ||
90 | + uint32_t vm = vext_vm(desc); | ||
91 | + uint32_t vl = env->vl; | ||
92 | + int i; | ||
93 | + | ||
94 | + for (i = 0; i < vl; i++) { | ||
95 | + if (vm || vext_elem_mask(v0, mlen, i)) { | ||
96 | + if (vext_elem_mask(vs2, mlen, i)) { | ||
97 | + return i; | ||
98 | + } | ||
99 | + } | ||
100 | + } | ||
101 | + return -1LL; | ||
102 | +} | ||
103 | -- | 83 | -- |
104 | 2.27.0 | 84 | 2.45.1 |
105 | |||
106 | diff view generated by jsdifflib |
1 | From: Jessica Clarke <jrtc27@jrtc27.com> | 1 | From: Alexei Filippov <alexei.filippov@syntacore.com> |
---|---|---|---|
2 | 2 | ||
3 | The source priorities can be used to order sources with respect to other | 3 | Previous patch fixed the PMP priority in raise_mmu_exception() but we're still |
4 | sources, not just as a way to enable/disable them based off a threshold. | 4 | setting mtval2 incorrectly. In riscv_cpu_tlb_fill(), after pmp check in 2 stage |
5 | We must therefore always claim the highest-priority source, rather than | 5 | translation part, mtval2 will be set in case of successes 2 stage translation but |
6 | the first source we find. | 6 | failed pmp check. |
7 | 7 | ||
8 | Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> | 8 | In this case we gonna set mtval2 via env->guest_phys_fault_addr in context of |
9 | riscv_cpu_tlb_fill(), as this was a guest-page-fault, but it didn't and mtval2 | ||
10 | should be zero, according to RISCV privileged spec sect. 9.4.4: When a guest | ||
11 | page-fault is taken into M-mode, mtval2 is written with either zero or guest | ||
12 | physical address that faulted, shifted by 2 bits. *For other traps, mtval2 | ||
13 | is set to zero...* | ||
14 | |||
15 | Signed-off-by: Alexei Filippov <alexei.filippov@syntacore.com> | ||
16 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 17 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
10 | Message-Id: <20200618202343.20455-1-jrtc27@jrtc27.com> | 18 | Message-ID: <20240503103052.6819-1-alexei.filippov@syntacore.com> |
19 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 20 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
12 | --- | 21 | --- |
13 | hw/riscv/sifive_plic.c | 17 ++++++++++++----- | 22 | target/riscv/cpu_helper.c | 12 ++++++------ |
14 | 1 file changed, 12 insertions(+), 5 deletions(-) | 23 | 1 file changed, 6 insertions(+), 6 deletions(-) |
15 | 24 | ||
16 | diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c | 25 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/riscv/sifive_plic.c | 27 | --- a/target/riscv/cpu_helper.c |
19 | +++ b/hw/riscv/sifive_plic.c | 28 | +++ b/target/riscv/cpu_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void sifive_plic_update(SiFivePLICState *plic) | 29 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
21 | static uint32_t sifive_plic_claim(SiFivePLICState *plic, uint32_t addrid) | 30 | __func__, pa, ret, prot_pmp, tlb_size); |
22 | { | 31 | |
23 | int i, j; | 32 | prot &= prot_pmp; |
24 | + uint32_t max_irq = 0; | 33 | - } |
25 | + uint32_t max_prio = plic->target_priority[addrid]; | 34 | - |
26 | + | 35 | - if (ret != TRANSLATE_SUCCESS) { |
27 | for (i = 0; i < plic->bitfield_words; i++) { | 36 | + } else { |
28 | uint32_t pending_enabled_not_claimed = | 37 | /* |
29 | (plic->pending[i] & ~plic->claimed[i]) & | 38 | * Guest physical address translation failed, this is a HS |
30 | @@ -XXX,XX +XXX,XX @@ static uint32_t sifive_plic_claim(SiFivePLICState *plic, uint32_t addrid) | 39 | * level exception |
31 | int irq = (i << 5) + j; | 40 | */ |
32 | uint32_t prio = plic->source_priority[irq]; | 41 | first_stage_error = false; |
33 | int enabled = pending_enabled_not_claimed & (1 << j); | 42 | - env->guest_phys_fault_addr = (im_address | |
34 | - if (enabled && prio > plic->target_priority[addrid]) { | 43 | - (address & |
35 | - sifive_plic_set_pending(plic, irq, false); | 44 | - (TARGET_PAGE_SIZE - 1))) >> 2; |
36 | - sifive_plic_set_claimed(plic, irq, true); | 45 | + if (ret != TRANSLATE_PMP_FAIL) { |
37 | - return irq; | 46 | + env->guest_phys_fault_addr = (im_address | |
38 | + if (enabled && prio > max_prio) { | 47 | + (address & |
39 | + max_irq = irq; | 48 | + (TARGET_PAGE_SIZE - 1))) >> 2; |
40 | + max_prio = prio; | 49 | + } |
41 | } | 50 | } |
42 | } | 51 | } |
43 | } | 52 | } else { |
44 | - return 0; | ||
45 | + | ||
46 | + if (max_irq) { | ||
47 | + sifive_plic_set_pending(plic, max_irq, false); | ||
48 | + sifive_plic_set_claimed(plic, max_irq, true); | ||
49 | + } | ||
50 | + return max_irq; | ||
51 | } | ||
52 | |||
53 | static uint64_t sifive_plic_read(void *opaque, hwaddr addr, unsigned size) | ||
54 | -- | 53 | -- |
55 | 2.27.0 | 54 | 2.45.1 |
56 | |||
57 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Rob Bradford <rbradford@rivosinc.com> |
---|---|---|---|
2 | 2 | ||
3 | Vector extension is default off. The only way to use vector extension is | 3 | This extension has now been ratified: |
4 | 1. use cpu rv32 or rv64 | 4 | https://jira.riscv.org/browse/RVS-2006 so the "x-" prefix can be |
5 | 2. turn on it by command line | 5 | removed. |
6 | "-cpu rv64,x-v=true,vlen=128,elen=64,vext_spec=v0.7.1". | ||
7 | 6 | ||
8 | vlen is the vector register length, default value is 128 bit. | 7 | Since this is now a ratified extension add it to the list of extensions |
9 | elen is the max operator size in bits, default value is 64 bit. | 8 | included in the "max" CPU variant. |
10 | vext_spec is the vector specification version, default value is v0.7.1. | ||
11 | These properties can be specified with other values. | ||
12 | 9 | ||
13 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 10 | Signed-off-by: Rob Bradford <rbradford@rivosinc.com> |
11 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
16 | Message-id: 20200623215920.2594-62-zhiwei_liu@c-sky.com | 14 | Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> |
15 | Message-ID: <20240514110217.22516-1-rbradford@rivosinc.com> | ||
17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 16 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
18 | --- | 17 | --- |
19 | target/riscv/cpu.h | 4 +++- | 18 | target/riscv/cpu.c | 2 +- |
20 | target/riscv/cpu.c | 43 +++++++++++++++++++++++++++++++++++++++++++ | 19 | target/riscv/tcg/tcg-cpu.c | 2 +- |
21 | 2 files changed, 46 insertions(+), 1 deletion(-) | 20 | 2 files changed, 2 insertions(+), 2 deletions(-) |
22 | 21 | ||
23 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/riscv/cpu.h | ||
26 | +++ b/target/riscv/cpu.h | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct CPURISCVState CPURISCVState; | ||
28 | |||
29 | #include "pmp.h" | ||
30 | |||
31 | -#define RV_VLEN_MAX 512 | ||
32 | +#define RV_VLEN_MAX 256 | ||
33 | |||
34 | FIELD(VTYPE, VLMUL, 0, 2) | ||
35 | FIELD(VTYPE, VSEW, 2, 3) | ||
36 | @@ -XXX,XX +XXX,XX @@ typedef struct RISCVCPU { | ||
37 | bool ext_s; | ||
38 | bool ext_u; | ||
39 | bool ext_h; | ||
40 | + bool ext_v; | ||
41 | bool ext_counters; | ||
42 | bool ext_ifencei; | ||
43 | bool ext_icsr; | ||
44 | |||
45 | char *priv_spec; | ||
46 | char *user_spec; | ||
47 | + char *vext_spec; | ||
48 | uint16_t vlen; | ||
49 | uint16_t elen; | ||
50 | bool mmu; | ||
51 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | 22 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
52 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/target/riscv/cpu.c | 24 | --- a/target/riscv/cpu.c |
54 | +++ b/target/riscv/cpu.c | 25 | +++ b/target/riscv/cpu.c |
55 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) | 26 | @@ -XXX,XX +XXX,XX @@ static const MISAExtInfo misa_ext_info_arr[] = { |
56 | if (cpu->cfg.ext_h) { | 27 | MISA_EXT_INFO(RVJ, "x-j", "Dynamic translated languages"), |
57 | target_misa |= RVH; | 28 | MISA_EXT_INFO(RVV, "v", "Vector operations"), |
58 | } | 29 | MISA_EXT_INFO(RVG, "g", "General purpose (IMAFD_Zicsr_Zifencei)"), |
59 | + if (cpu->cfg.ext_v) { | 30 | - MISA_EXT_INFO(RVB, "x-b", "Bit manipulation (Zba_Zbb_Zbs)") |
60 | + target_misa |= RVV; | 31 | + MISA_EXT_INFO(RVB, "b", "Bit manipulation (Zba_Zbb_Zbs)") |
61 | + if (!is_power_of_2(cpu->cfg.vlen)) { | 32 | }; |
62 | + error_setg(errp, | 33 | |
63 | + "Vector extension VLEN must be power of 2"); | 34 | static void riscv_cpu_validate_misa_mxl(RISCVCPUClass *mcc) |
64 | + return; | 35 | diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c |
65 | + } | 36 | index XXXXXXX..XXXXXXX 100644 |
66 | + if (cpu->cfg.vlen > RV_VLEN_MAX || cpu->cfg.vlen < 128) { | 37 | --- a/target/riscv/tcg/tcg-cpu.c |
67 | + error_setg(errp, | 38 | +++ b/target/riscv/tcg/tcg-cpu.c |
68 | + "Vector extension implementation only supports VLEN " | 39 | @@ -XXX,XX +XXX,XX @@ static void riscv_init_max_cpu_extensions(Object *obj) |
69 | + "in the range [128, %d]", RV_VLEN_MAX); | 40 | const RISCVCPUMultiExtConfig *prop; |
70 | + return; | 41 | |
71 | + } | 42 | /* Enable RVG, RVJ and RVV that are disabled by default */ |
72 | + if (!is_power_of_2(cpu->cfg.elen)) { | 43 | - riscv_cpu_set_misa_ext(env, env->misa_ext | RVG | RVJ | RVV); |
73 | + error_setg(errp, | 44 | + riscv_cpu_set_misa_ext(env, env->misa_ext | RVB | RVG | RVJ | RVV); |
74 | + "Vector extension ELEN must be power of 2"); | 45 | |
75 | + return; | 46 | for (prop = riscv_cpu_extensions; prop && prop->name; prop++) { |
76 | + } | 47 | isa_ext_update_enabled(cpu, prop->offset, true); |
77 | + if (cpu->cfg.elen > 64 || cpu->cfg.vlen < 8) { | ||
78 | + error_setg(errp, | ||
79 | + "Vector extension implementation only supports ELEN " | ||
80 | + "in the range [8, 64]"); | ||
81 | + return; | ||
82 | + } | ||
83 | + if (cpu->cfg.vext_spec) { | ||
84 | + if (!g_strcmp0(cpu->cfg.vext_spec, "v0.7.1")) { | ||
85 | + vext_version = VEXT_VERSION_0_07_1; | ||
86 | + } else { | ||
87 | + error_setg(errp, | ||
88 | + "Unsupported vector spec version '%s'", | ||
89 | + cpu->cfg.vext_spec); | ||
90 | + return; | ||
91 | + } | ||
92 | + } else { | ||
93 | + qemu_log("vector verison is not specified, " | ||
94 | + "use the default value v0.7.1\n"); | ||
95 | + } | ||
96 | + set_vext_version(env, vext_version); | ||
97 | + } | ||
98 | |||
99 | set_misa(env, RVXLEN | target_misa); | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = { | ||
102 | DEFINE_PROP_BOOL("u", RISCVCPU, cfg.ext_u, true), | ||
103 | /* This is experimental so mark with 'x-' */ | ||
104 | DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false), | ||
105 | + DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false), | ||
106 | DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true), | ||
107 | DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), | ||
108 | DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), | ||
109 | DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), | ||
110 | + DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), | ||
111 | + DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), | ||
112 | + DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), | ||
113 | DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), | ||
114 | DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), | ||
115 | DEFINE_PROP_END_OF_LIST(), | ||
116 | -- | 48 | -- |
117 | 2.27.0 | 49 | 2.45.1 |
118 | |||
119 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Alistair Francis <alistair23@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | When running the instruction |
4 | |||
5 | ``` | ||
6 | cbo.flush 0(x0) | ||
7 | ``` | ||
8 | |||
9 | QEMU would segfault. | ||
10 | |||
11 | The issue was in cpu_gpr[a->rs1] as QEMU does not have cpu_gpr[0] | ||
12 | allocated. | ||
13 | |||
14 | In order to fix this let's use the existing get_address() | ||
15 | helper. This also has the benefit of performing pointer mask | ||
16 | calculations on the address specified in rs1. | ||
17 | |||
18 | The pointer masking specificiation specifically states: | ||
19 | |||
20 | """ | ||
21 | Cache Management Operations: All instructions in Zicbom, Zicbop and Zicboz | ||
22 | """ | ||
23 | |||
24 | So this is the correct behaviour and we previously have been incorrectly | ||
25 | not masking the address. | ||
26 | |||
27 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
28 | Reported-by: Fabian Thomas <fabian.thomas@cispa.de> | ||
29 | Fixes: e05da09b7cfd ("target/riscv: implement Zicbom extension") | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 30 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 31 | Cc: qemu-stable <qemu-stable@nongnu.org> |
6 | Message-id: 20200623215920.2594-12-zhiwei_liu@c-sky.com | 32 | Message-ID: <20240514023910.301766-1-alistair.francis@wdc.com> |
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 33 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
8 | --- | 34 | --- |
9 | target/riscv/helper.h | 49 +++++++ | 35 | target/riscv/insn_trans/trans_rvzicbo.c.inc | 16 ++++++++++++---- |
10 | target/riscv/insn32.decode | 16 ++ | 36 | 1 file changed, 12 insertions(+), 4 deletions(-) |
11 | target/riscv/insn_trans/trans_rvv.inc.c | 186 ++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 111 ++++++++++++++ | ||
13 | 4 files changed, 362 insertions(+) | ||
14 | 37 | ||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 38 | diff --git a/target/riscv/insn_trans/trans_rvzicbo.c.inc b/target/riscv/insn_trans/trans_rvzicbo.c.inc |
16 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/riscv/helper.h | 40 | --- a/target/riscv/insn_trans/trans_rvzicbo.c.inc |
18 | +++ b/target/riscv/helper.h | 41 | +++ b/target/riscv/insn_trans/trans_rvzicbo.c.inc |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(vec_rsubs8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 42 | @@ -XXX,XX +XXX,XX @@ |
20 | DEF_HELPER_FLAGS_4(vec_rsubs16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 43 | static bool trans_cbo_clean(DisasContext *ctx, arg_cbo_clean *a) |
21 | DEF_HELPER_FLAGS_4(vec_rsubs32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 44 | { |
22 | DEF_HELPER_FLAGS_4(vec_rsubs64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 45 | REQUIRE_ZICBOM(ctx); |
46 | - gen_helper_cbo_clean_flush(tcg_env, cpu_gpr[a->rs1]); | ||
47 | + TCGv src = get_address(ctx, a->rs1, 0); | ||
23 | + | 48 | + |
24 | +DEF_HELPER_6(vwaddu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | 49 | + gen_helper_cbo_clean_flush(tcg_env, src); |
25 | +DEF_HELPER_6(vwaddu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | 50 | return true; |
26 | +DEF_HELPER_6(vwaddu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vwsubu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vwsubu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vwsubu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vwadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vwadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vwadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vwsub_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vwsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vwsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vwaddu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vwaddu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vwaddu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vwsubu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vwsubu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vwsubu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vwadd_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vwadd_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vwadd_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vwsub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vwsub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vwsub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vwaddu_wv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vwaddu_wv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vwaddu_wv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vwsubu_wv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vwsubu_wv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vwsubu_wv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vwadd_wv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vwadd_wv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
56 | +DEF_HELPER_6(vwadd_wv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
57 | +DEF_HELPER_6(vwsub_wv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
58 | +DEF_HELPER_6(vwsub_wv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
59 | +DEF_HELPER_6(vwsub_wv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
60 | +DEF_HELPER_6(vwaddu_wx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
61 | +DEF_HELPER_6(vwaddu_wx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
62 | +DEF_HELPER_6(vwaddu_wx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
63 | +DEF_HELPER_6(vwsubu_wx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
64 | +DEF_HELPER_6(vwsubu_wx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
65 | +DEF_HELPER_6(vwsubu_wx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
66 | +DEF_HELPER_6(vwadd_wx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
67 | +DEF_HELPER_6(vwadd_wx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
68 | +DEF_HELPER_6(vwadd_wx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
69 | +DEF_HELPER_6(vwsub_wx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
70 | +DEF_HELPER_6(vwsub_wx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
71 | +DEF_HELPER_6(vwsub_wx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
72 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/riscv/insn32.decode | ||
75 | +++ b/target/riscv/insn32.decode | ||
76 | @@ -XXX,XX +XXX,XX @@ vsub_vv 000010 . ..... ..... 000 ..... 1010111 @r_vm | ||
77 | vsub_vx 000010 . ..... ..... 100 ..... 1010111 @r_vm | ||
78 | vrsub_vx 000011 . ..... ..... 100 ..... 1010111 @r_vm | ||
79 | vrsub_vi 000011 . ..... ..... 011 ..... 1010111 @r_vm | ||
80 | +vwaddu_vv 110000 . ..... ..... 010 ..... 1010111 @r_vm | ||
81 | +vwaddu_vx 110000 . ..... ..... 110 ..... 1010111 @r_vm | ||
82 | +vwadd_vv 110001 . ..... ..... 010 ..... 1010111 @r_vm | ||
83 | +vwadd_vx 110001 . ..... ..... 110 ..... 1010111 @r_vm | ||
84 | +vwsubu_vv 110010 . ..... ..... 010 ..... 1010111 @r_vm | ||
85 | +vwsubu_vx 110010 . ..... ..... 110 ..... 1010111 @r_vm | ||
86 | +vwsub_vv 110011 . ..... ..... 010 ..... 1010111 @r_vm | ||
87 | +vwsub_vx 110011 . ..... ..... 110 ..... 1010111 @r_vm | ||
88 | +vwaddu_wv 110100 . ..... ..... 010 ..... 1010111 @r_vm | ||
89 | +vwaddu_wx 110100 . ..... ..... 110 ..... 1010111 @r_vm | ||
90 | +vwadd_wv 110101 . ..... ..... 010 ..... 1010111 @r_vm | ||
91 | +vwadd_wx 110101 . ..... ..... 110 ..... 1010111 @r_vm | ||
92 | +vwsubu_wv 110110 . ..... ..... 010 ..... 1010111 @r_vm | ||
93 | +vwsubu_wx 110110 . ..... ..... 110 ..... 1010111 @r_vm | ||
94 | +vwsub_wv 110111 . ..... ..... 010 ..... 1010111 @r_vm | ||
95 | +vwsub_wx 110111 . ..... ..... 110 ..... 1010111 @r_vm | ||
96 | |||
97 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
98 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
99 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
102 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
103 | @@ -XXX,XX +XXX,XX @@ static bool vext_check_nf(DisasContext *s, uint32_t nf) | ||
104 | return (1 << s->lmul) * nf <= 8; | ||
105 | } | 51 | } |
106 | 52 | ||
107 | +/* | 53 | static bool trans_cbo_flush(DisasContext *ctx, arg_cbo_flush *a) |
108 | + * The destination vector register group cannot overlap a source vector register | 54 | { |
109 | + * group of a different element width. (Section 11.2) | 55 | REQUIRE_ZICBOM(ctx); |
110 | + */ | 56 | - gen_helper_cbo_clean_flush(tcg_env, cpu_gpr[a->rs1]); |
111 | +static inline bool vext_check_overlap_group(int rd, int dlen, int rs, int slen) | 57 | + TCGv src = get_address(ctx, a->rs1, 0); |
112 | +{ | 58 | + |
113 | + return ((rd >= rs + slen) || (rs >= rd + dlen)); | 59 | + gen_helper_cbo_clean_flush(tcg_env, src); |
114 | +} | 60 | return true; |
115 | /* common translation macro */ | ||
116 | #define GEN_VEXT_TRANS(NAME, SEQ, ARGTYPE, OP, CHECK) \ | ||
117 | static bool trans_##NAME(DisasContext *s, arg_##ARGTYPE *a)\ | ||
118 | @@ -XXX,XX +XXX,XX @@ static void tcg_gen_gvec_rsubi(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
119 | } | 61 | } |
120 | 62 | ||
121 | GEN_OPIVI_GVEC_TRANS(vrsub_vi, 0, vrsub_vx, rsubi) | 63 | static bool trans_cbo_inval(DisasContext *ctx, arg_cbo_inval *a) |
64 | { | ||
65 | REQUIRE_ZICBOM(ctx); | ||
66 | - gen_helper_cbo_inval(tcg_env, cpu_gpr[a->rs1]); | ||
67 | + TCGv src = get_address(ctx, a->rs1, 0); | ||
122 | + | 68 | + |
123 | +/* Vector Widening Integer Add/Subtract */ | 69 | + gen_helper_cbo_inval(tcg_env, src); |
70 | return true; | ||
71 | } | ||
72 | |||
73 | static bool trans_cbo_zero(DisasContext *ctx, arg_cbo_zero *a) | ||
74 | { | ||
75 | REQUIRE_ZICBOZ(ctx); | ||
76 | - gen_helper_cbo_zero(tcg_env, cpu_gpr[a->rs1]); | ||
77 | + TCGv src = get_address(ctx, a->rs1, 0); | ||
124 | + | 78 | + |
125 | +/* OPIVV with WIDEN */ | 79 | + gen_helper_cbo_zero(tcg_env, src); |
126 | +static bool opivv_widen_check(DisasContext *s, arg_rmrr *a) | 80 | return true; |
127 | +{ | ||
128 | + return (vext_check_isa_ill(s) && | ||
129 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
130 | + vext_check_reg(s, a->rd, true) && | ||
131 | + vext_check_reg(s, a->rs2, false) && | ||
132 | + vext_check_reg(s, a->rs1, false) && | ||
133 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs2, | ||
134 | + 1 << s->lmul) && | ||
135 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs1, | ||
136 | + 1 << s->lmul) && | ||
137 | + (s->lmul < 0x3) && (s->sew < 0x3)); | ||
138 | +} | ||
139 | + | ||
140 | +static bool do_opivv_widen(DisasContext *s, arg_rmrr *a, | ||
141 | + gen_helper_gvec_4_ptr *fn, | ||
142 | + bool (*checkfn)(DisasContext *, arg_rmrr *)) | ||
143 | +{ | ||
144 | + if (checkfn(s, a)) { | ||
145 | + uint32_t data = 0; | ||
146 | + TCGLabel *over = gen_new_label(); | ||
147 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
148 | + | ||
149 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
150 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
151 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
152 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), | ||
153 | + vreg_ofs(s, a->rs1), | ||
154 | + vreg_ofs(s, a->rs2), | ||
155 | + cpu_env, 0, s->vlen / 8, | ||
156 | + data, fn); | ||
157 | + gen_set_label(over); | ||
158 | + return true; | ||
159 | + } | ||
160 | + return false; | ||
161 | +} | ||
162 | + | ||
163 | +#define GEN_OPIVV_WIDEN_TRANS(NAME, CHECK) \ | ||
164 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
165 | +{ \ | ||
166 | + static gen_helper_gvec_4_ptr * const fns[3] = { \ | ||
167 | + gen_helper_##NAME##_b, \ | ||
168 | + gen_helper_##NAME##_h, \ | ||
169 | + gen_helper_##NAME##_w \ | ||
170 | + }; \ | ||
171 | + return do_opivv_widen(s, a, fns[s->sew], CHECK); \ | ||
172 | +} | ||
173 | + | ||
174 | +GEN_OPIVV_WIDEN_TRANS(vwaddu_vv, opivv_widen_check) | ||
175 | +GEN_OPIVV_WIDEN_TRANS(vwadd_vv, opivv_widen_check) | ||
176 | +GEN_OPIVV_WIDEN_TRANS(vwsubu_vv, opivv_widen_check) | ||
177 | +GEN_OPIVV_WIDEN_TRANS(vwsub_vv, opivv_widen_check) | ||
178 | + | ||
179 | +/* OPIVX with WIDEN */ | ||
180 | +static bool opivx_widen_check(DisasContext *s, arg_rmrr *a) | ||
181 | +{ | ||
182 | + return (vext_check_isa_ill(s) && | ||
183 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
184 | + vext_check_reg(s, a->rd, true) && | ||
185 | + vext_check_reg(s, a->rs2, false) && | ||
186 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs2, | ||
187 | + 1 << s->lmul) && | ||
188 | + (s->lmul < 0x3) && (s->sew < 0x3)); | ||
189 | +} | ||
190 | + | ||
191 | +static bool do_opivx_widen(DisasContext *s, arg_rmrr *a, | ||
192 | + gen_helper_opivx *fn) | ||
193 | +{ | ||
194 | + if (opivx_widen_check(s, a)) { | ||
195 | + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s); | ||
196 | + } | ||
197 | + return true; | ||
198 | +} | ||
199 | + | ||
200 | +#define GEN_OPIVX_WIDEN_TRANS(NAME) \ | ||
201 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
202 | +{ \ | ||
203 | + static gen_helper_opivx * const fns[3] = { \ | ||
204 | + gen_helper_##NAME##_b, \ | ||
205 | + gen_helper_##NAME##_h, \ | ||
206 | + gen_helper_##NAME##_w \ | ||
207 | + }; \ | ||
208 | + return do_opivx_widen(s, a, fns[s->sew]); \ | ||
209 | +} | ||
210 | + | ||
211 | +GEN_OPIVX_WIDEN_TRANS(vwaddu_vx) | ||
212 | +GEN_OPIVX_WIDEN_TRANS(vwadd_vx) | ||
213 | +GEN_OPIVX_WIDEN_TRANS(vwsubu_vx) | ||
214 | +GEN_OPIVX_WIDEN_TRANS(vwsub_vx) | ||
215 | + | ||
216 | +/* WIDEN OPIVV with WIDEN */ | ||
217 | +static bool opiwv_widen_check(DisasContext *s, arg_rmrr *a) | ||
218 | +{ | ||
219 | + return (vext_check_isa_ill(s) && | ||
220 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
221 | + vext_check_reg(s, a->rd, true) && | ||
222 | + vext_check_reg(s, a->rs2, true) && | ||
223 | + vext_check_reg(s, a->rs1, false) && | ||
224 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs1, | ||
225 | + 1 << s->lmul) && | ||
226 | + (s->lmul < 0x3) && (s->sew < 0x3)); | ||
227 | +} | ||
228 | + | ||
229 | +static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a, | ||
230 | + gen_helper_gvec_4_ptr *fn) | ||
231 | +{ | ||
232 | + if (opiwv_widen_check(s, a)) { | ||
233 | + uint32_t data = 0; | ||
234 | + TCGLabel *over = gen_new_label(); | ||
235 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
236 | + | ||
237 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
238 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
239 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
240 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), | ||
241 | + vreg_ofs(s, a->rs1), | ||
242 | + vreg_ofs(s, a->rs2), | ||
243 | + cpu_env, 0, s->vlen / 8, data, fn); | ||
244 | + gen_set_label(over); | ||
245 | + return true; | ||
246 | + } | ||
247 | + return false; | ||
248 | +} | ||
249 | + | ||
250 | +#define GEN_OPIWV_WIDEN_TRANS(NAME) \ | ||
251 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
252 | +{ \ | ||
253 | + static gen_helper_gvec_4_ptr * const fns[3] = { \ | ||
254 | + gen_helper_##NAME##_b, \ | ||
255 | + gen_helper_##NAME##_h, \ | ||
256 | + gen_helper_##NAME##_w \ | ||
257 | + }; \ | ||
258 | + return do_opiwv_widen(s, a, fns[s->sew]); \ | ||
259 | +} | ||
260 | + | ||
261 | +GEN_OPIWV_WIDEN_TRANS(vwaddu_wv) | ||
262 | +GEN_OPIWV_WIDEN_TRANS(vwadd_wv) | ||
263 | +GEN_OPIWV_WIDEN_TRANS(vwsubu_wv) | ||
264 | +GEN_OPIWV_WIDEN_TRANS(vwsub_wv) | ||
265 | + | ||
266 | +/* WIDEN OPIVX with WIDEN */ | ||
267 | +static bool opiwx_widen_check(DisasContext *s, arg_rmrr *a) | ||
268 | +{ | ||
269 | + return (vext_check_isa_ill(s) && | ||
270 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
271 | + vext_check_reg(s, a->rd, true) && | ||
272 | + vext_check_reg(s, a->rs2, true) && | ||
273 | + (s->lmul < 0x3) && (s->sew < 0x3)); | ||
274 | +} | ||
275 | + | ||
276 | +static bool do_opiwx_widen(DisasContext *s, arg_rmrr *a, | ||
277 | + gen_helper_opivx *fn) | ||
278 | +{ | ||
279 | + if (opiwx_widen_check(s, a)) { | ||
280 | + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s); | ||
281 | + } | ||
282 | + return false; | ||
283 | +} | ||
284 | + | ||
285 | +#define GEN_OPIWX_WIDEN_TRANS(NAME) \ | ||
286 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
287 | +{ \ | ||
288 | + static gen_helper_opivx * const fns[3] = { \ | ||
289 | + gen_helper_##NAME##_b, \ | ||
290 | + gen_helper_##NAME##_h, \ | ||
291 | + gen_helper_##NAME##_w \ | ||
292 | + }; \ | ||
293 | + return do_opiwx_widen(s, a, fns[s->sew]); \ | ||
294 | +} | ||
295 | + | ||
296 | +GEN_OPIWX_WIDEN_TRANS(vwaddu_wx) | ||
297 | +GEN_OPIWX_WIDEN_TRANS(vwadd_wx) | ||
298 | +GEN_OPIWX_WIDEN_TRANS(vwsubu_wx) | ||
299 | +GEN_OPIWX_WIDEN_TRANS(vwsub_wx) | ||
300 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
301 | index XXXXXXX..XXXXXXX 100644 | ||
302 | --- a/target/riscv/vector_helper.c | ||
303 | +++ b/target/riscv/vector_helper.c | ||
304 | @@ -XXX,XX +XXX,XX @@ void HELPER(vec_rsubs64)(void *d, void *a, uint64_t b, uint32_t desc) | ||
305 | *(uint64_t *)(d + i) = b - *(uint64_t *)(a + i); | ||
306 | } | ||
307 | } | 81 | } |
308 | + | ||
309 | +/* Vector Widening Integer Add/Subtract */ | ||
310 | +#define WOP_UUU_B uint16_t, uint8_t, uint8_t, uint16_t, uint16_t | ||
311 | +#define WOP_UUU_H uint32_t, uint16_t, uint16_t, uint32_t, uint32_t | ||
312 | +#define WOP_UUU_W uint64_t, uint32_t, uint32_t, uint64_t, uint64_t | ||
313 | +#define WOP_SSS_B int16_t, int8_t, int8_t, int16_t, int16_t | ||
314 | +#define WOP_SSS_H int32_t, int16_t, int16_t, int32_t, int32_t | ||
315 | +#define WOP_SSS_W int64_t, int32_t, int32_t, int64_t, int64_t | ||
316 | +#define WOP_WUUU_B uint16_t, uint8_t, uint16_t, uint16_t, uint16_t | ||
317 | +#define WOP_WUUU_H uint32_t, uint16_t, uint32_t, uint32_t, uint32_t | ||
318 | +#define WOP_WUUU_W uint64_t, uint32_t, uint64_t, uint64_t, uint64_t | ||
319 | +#define WOP_WSSS_B int16_t, int8_t, int16_t, int16_t, int16_t | ||
320 | +#define WOP_WSSS_H int32_t, int16_t, int32_t, int32_t, int32_t | ||
321 | +#define WOP_WSSS_W int64_t, int32_t, int64_t, int64_t, int64_t | ||
322 | +RVVCALL(OPIVV2, vwaddu_vv_b, WOP_UUU_B, H2, H1, H1, DO_ADD) | ||
323 | +RVVCALL(OPIVV2, vwaddu_vv_h, WOP_UUU_H, H4, H2, H2, DO_ADD) | ||
324 | +RVVCALL(OPIVV2, vwaddu_vv_w, WOP_UUU_W, H8, H4, H4, DO_ADD) | ||
325 | +RVVCALL(OPIVV2, vwsubu_vv_b, WOP_UUU_B, H2, H1, H1, DO_SUB) | ||
326 | +RVVCALL(OPIVV2, vwsubu_vv_h, WOP_UUU_H, H4, H2, H2, DO_SUB) | ||
327 | +RVVCALL(OPIVV2, vwsubu_vv_w, WOP_UUU_W, H8, H4, H4, DO_SUB) | ||
328 | +RVVCALL(OPIVV2, vwadd_vv_b, WOP_SSS_B, H2, H1, H1, DO_ADD) | ||
329 | +RVVCALL(OPIVV2, vwadd_vv_h, WOP_SSS_H, H4, H2, H2, DO_ADD) | ||
330 | +RVVCALL(OPIVV2, vwadd_vv_w, WOP_SSS_W, H8, H4, H4, DO_ADD) | ||
331 | +RVVCALL(OPIVV2, vwsub_vv_b, WOP_SSS_B, H2, H1, H1, DO_SUB) | ||
332 | +RVVCALL(OPIVV2, vwsub_vv_h, WOP_SSS_H, H4, H2, H2, DO_SUB) | ||
333 | +RVVCALL(OPIVV2, vwsub_vv_w, WOP_SSS_W, H8, H4, H4, DO_SUB) | ||
334 | +RVVCALL(OPIVV2, vwaddu_wv_b, WOP_WUUU_B, H2, H1, H1, DO_ADD) | ||
335 | +RVVCALL(OPIVV2, vwaddu_wv_h, WOP_WUUU_H, H4, H2, H2, DO_ADD) | ||
336 | +RVVCALL(OPIVV2, vwaddu_wv_w, WOP_WUUU_W, H8, H4, H4, DO_ADD) | ||
337 | +RVVCALL(OPIVV2, vwsubu_wv_b, WOP_WUUU_B, H2, H1, H1, DO_SUB) | ||
338 | +RVVCALL(OPIVV2, vwsubu_wv_h, WOP_WUUU_H, H4, H2, H2, DO_SUB) | ||
339 | +RVVCALL(OPIVV2, vwsubu_wv_w, WOP_WUUU_W, H8, H4, H4, DO_SUB) | ||
340 | +RVVCALL(OPIVV2, vwadd_wv_b, WOP_WSSS_B, H2, H1, H1, DO_ADD) | ||
341 | +RVVCALL(OPIVV2, vwadd_wv_h, WOP_WSSS_H, H4, H2, H2, DO_ADD) | ||
342 | +RVVCALL(OPIVV2, vwadd_wv_w, WOP_WSSS_W, H8, H4, H4, DO_ADD) | ||
343 | +RVVCALL(OPIVV2, vwsub_wv_b, WOP_WSSS_B, H2, H1, H1, DO_SUB) | ||
344 | +RVVCALL(OPIVV2, vwsub_wv_h, WOP_WSSS_H, H4, H2, H2, DO_SUB) | ||
345 | +RVVCALL(OPIVV2, vwsub_wv_w, WOP_WSSS_W, H8, H4, H4, DO_SUB) | ||
346 | +GEN_VEXT_VV(vwaddu_vv_b, 1, 2, clearh) | ||
347 | +GEN_VEXT_VV(vwaddu_vv_h, 2, 4, clearl) | ||
348 | +GEN_VEXT_VV(vwaddu_vv_w, 4, 8, clearq) | ||
349 | +GEN_VEXT_VV(vwsubu_vv_b, 1, 2, clearh) | ||
350 | +GEN_VEXT_VV(vwsubu_vv_h, 2, 4, clearl) | ||
351 | +GEN_VEXT_VV(vwsubu_vv_w, 4, 8, clearq) | ||
352 | +GEN_VEXT_VV(vwadd_vv_b, 1, 2, clearh) | ||
353 | +GEN_VEXT_VV(vwadd_vv_h, 2, 4, clearl) | ||
354 | +GEN_VEXT_VV(vwadd_vv_w, 4, 8, clearq) | ||
355 | +GEN_VEXT_VV(vwsub_vv_b, 1, 2, clearh) | ||
356 | +GEN_VEXT_VV(vwsub_vv_h, 2, 4, clearl) | ||
357 | +GEN_VEXT_VV(vwsub_vv_w, 4, 8, clearq) | ||
358 | +GEN_VEXT_VV(vwaddu_wv_b, 1, 2, clearh) | ||
359 | +GEN_VEXT_VV(vwaddu_wv_h, 2, 4, clearl) | ||
360 | +GEN_VEXT_VV(vwaddu_wv_w, 4, 8, clearq) | ||
361 | +GEN_VEXT_VV(vwsubu_wv_b, 1, 2, clearh) | ||
362 | +GEN_VEXT_VV(vwsubu_wv_h, 2, 4, clearl) | ||
363 | +GEN_VEXT_VV(vwsubu_wv_w, 4, 8, clearq) | ||
364 | +GEN_VEXT_VV(vwadd_wv_b, 1, 2, clearh) | ||
365 | +GEN_VEXT_VV(vwadd_wv_h, 2, 4, clearl) | ||
366 | +GEN_VEXT_VV(vwadd_wv_w, 4, 8, clearq) | ||
367 | +GEN_VEXT_VV(vwsub_wv_b, 1, 2, clearh) | ||
368 | +GEN_VEXT_VV(vwsub_wv_h, 2, 4, clearl) | ||
369 | +GEN_VEXT_VV(vwsub_wv_w, 4, 8, clearq) | ||
370 | + | ||
371 | +RVVCALL(OPIVX2, vwaddu_vx_b, WOP_UUU_B, H2, H1, DO_ADD) | ||
372 | +RVVCALL(OPIVX2, vwaddu_vx_h, WOP_UUU_H, H4, H2, DO_ADD) | ||
373 | +RVVCALL(OPIVX2, vwaddu_vx_w, WOP_UUU_W, H8, H4, DO_ADD) | ||
374 | +RVVCALL(OPIVX2, vwsubu_vx_b, WOP_UUU_B, H2, H1, DO_SUB) | ||
375 | +RVVCALL(OPIVX2, vwsubu_vx_h, WOP_UUU_H, H4, H2, DO_SUB) | ||
376 | +RVVCALL(OPIVX2, vwsubu_vx_w, WOP_UUU_W, H8, H4, DO_SUB) | ||
377 | +RVVCALL(OPIVX2, vwadd_vx_b, WOP_SSS_B, H2, H1, DO_ADD) | ||
378 | +RVVCALL(OPIVX2, vwadd_vx_h, WOP_SSS_H, H4, H2, DO_ADD) | ||
379 | +RVVCALL(OPIVX2, vwadd_vx_w, WOP_SSS_W, H8, H4, DO_ADD) | ||
380 | +RVVCALL(OPIVX2, vwsub_vx_b, WOP_SSS_B, H2, H1, DO_SUB) | ||
381 | +RVVCALL(OPIVX2, vwsub_vx_h, WOP_SSS_H, H4, H2, DO_SUB) | ||
382 | +RVVCALL(OPIVX2, vwsub_vx_w, WOP_SSS_W, H8, H4, DO_SUB) | ||
383 | +RVVCALL(OPIVX2, vwaddu_wx_b, WOP_WUUU_B, H2, H1, DO_ADD) | ||
384 | +RVVCALL(OPIVX2, vwaddu_wx_h, WOP_WUUU_H, H4, H2, DO_ADD) | ||
385 | +RVVCALL(OPIVX2, vwaddu_wx_w, WOP_WUUU_W, H8, H4, DO_ADD) | ||
386 | +RVVCALL(OPIVX2, vwsubu_wx_b, WOP_WUUU_B, H2, H1, DO_SUB) | ||
387 | +RVVCALL(OPIVX2, vwsubu_wx_h, WOP_WUUU_H, H4, H2, DO_SUB) | ||
388 | +RVVCALL(OPIVX2, vwsubu_wx_w, WOP_WUUU_W, H8, H4, DO_SUB) | ||
389 | +RVVCALL(OPIVX2, vwadd_wx_b, WOP_WSSS_B, H2, H1, DO_ADD) | ||
390 | +RVVCALL(OPIVX2, vwadd_wx_h, WOP_WSSS_H, H4, H2, DO_ADD) | ||
391 | +RVVCALL(OPIVX2, vwadd_wx_w, WOP_WSSS_W, H8, H4, DO_ADD) | ||
392 | +RVVCALL(OPIVX2, vwsub_wx_b, WOP_WSSS_B, H2, H1, DO_SUB) | ||
393 | +RVVCALL(OPIVX2, vwsub_wx_h, WOP_WSSS_H, H4, H2, DO_SUB) | ||
394 | +RVVCALL(OPIVX2, vwsub_wx_w, WOP_WSSS_W, H8, H4, DO_SUB) | ||
395 | +GEN_VEXT_VX(vwaddu_vx_b, 1, 2, clearh) | ||
396 | +GEN_VEXT_VX(vwaddu_vx_h, 2, 4, clearl) | ||
397 | +GEN_VEXT_VX(vwaddu_vx_w, 4, 8, clearq) | ||
398 | +GEN_VEXT_VX(vwsubu_vx_b, 1, 2, clearh) | ||
399 | +GEN_VEXT_VX(vwsubu_vx_h, 2, 4, clearl) | ||
400 | +GEN_VEXT_VX(vwsubu_vx_w, 4, 8, clearq) | ||
401 | +GEN_VEXT_VX(vwadd_vx_b, 1, 2, clearh) | ||
402 | +GEN_VEXT_VX(vwadd_vx_h, 2, 4, clearl) | ||
403 | +GEN_VEXT_VX(vwadd_vx_w, 4, 8, clearq) | ||
404 | +GEN_VEXT_VX(vwsub_vx_b, 1, 2, clearh) | ||
405 | +GEN_VEXT_VX(vwsub_vx_h, 2, 4, clearl) | ||
406 | +GEN_VEXT_VX(vwsub_vx_w, 4, 8, clearq) | ||
407 | +GEN_VEXT_VX(vwaddu_wx_b, 1, 2, clearh) | ||
408 | +GEN_VEXT_VX(vwaddu_wx_h, 2, 4, clearl) | ||
409 | +GEN_VEXT_VX(vwaddu_wx_w, 4, 8, clearq) | ||
410 | +GEN_VEXT_VX(vwsubu_wx_b, 1, 2, clearh) | ||
411 | +GEN_VEXT_VX(vwsubu_wx_h, 2, 4, clearl) | ||
412 | +GEN_VEXT_VX(vwsubu_wx_w, 4, 8, clearq) | ||
413 | +GEN_VEXT_VX(vwadd_wx_b, 1, 2, clearh) | ||
414 | +GEN_VEXT_VX(vwadd_wx_h, 2, 4, clearl) | ||
415 | +GEN_VEXT_VX(vwadd_wx_w, 4, 8, clearq) | ||
416 | +GEN_VEXT_VX(vwsub_wx_b, 1, 2, clearh) | ||
417 | +GEN_VEXT_VX(vwsub_wx_h, 2, 4, clearl) | ||
418 | +GEN_VEXT_VX(vwsub_wx_w, 4, 8, clearq) | ||
419 | -- | 82 | -- |
420 | 2.27.0 | 83 | 2.45.1 |
421 | |||
422 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Yong-Xuan Wang <yongxuan.wang@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Vector indexed operations add the contents of each element of the | 3 | In AIA spec, each hart (or each hart within a group) has a unique hart |
4 | vector offset operand specified by vs2 to the base effective address | 4 | number to locate the memory pages of interrupt files in the address |
5 | to give the effective address of each element. | 5 | space. The number of bits required to represent any hart number is equal |
6 | to ceil(log2(hmax + 1)), where hmax is the largest hart number among | ||
7 | groups. | ||
6 | 8 | ||
7 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 9 | However, if the largest hart number among groups is a power of 2, QEMU |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 10 | will pass an inaccurate hart-index-bit setting to Linux. For example, when |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | the guest OS has 4 harts, only ceil(log2(3 + 1)) = 2 bits are sufficient |
10 | Message-id: 20200623215920.2594-8-zhiwei_liu@c-sky.com | 12 | to represent 4 harts, but we passes 3 to Linux. The code needs to be |
13 | updated to ensure accurate hart-index-bit settings. | ||
14 | |||
15 | Additionally, a Linux patch[1] is necessary to correctly recover the hart | ||
16 | index when the guest OS has only 1 hart, where the hart-index-bit is 0. | ||
17 | |||
18 | [1] https://lore.kernel.org/lkml/20240415064905.25184-1-yongxuan.wang@sifive.com/t/ | ||
19 | |||
20 | Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> | ||
21 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
22 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
23 | Message-ID: <20240515091129.28116-1-yongxuan.wang@sifive.com> | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 24 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
12 | --- | 25 | --- |
13 | target/riscv/helper.h | 35 +++++++ | 26 | target/riscv/kvm/kvm-cpu.c | 9 ++++++++- |
14 | target/riscv/insn32.decode | 13 +++ | 27 | 1 file changed, 8 insertions(+), 1 deletion(-) |
15 | target/riscv/insn_trans/trans_rvv.inc.c | 129 ++++++++++++++++++++++++ | ||
16 | target/riscv/vector_helper.c | 116 +++++++++++++++++++++ | ||
17 | 4 files changed, 293 insertions(+) | ||
18 | 28 | ||
19 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 29 | diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c |
20 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/riscv/helper.h | 31 | --- a/target/riscv/kvm/kvm-cpu.c |
22 | +++ b/target/riscv/helper.h | 32 | +++ b/target/riscv/kvm/kvm-cpu.c |
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vsse_v_b, void, ptr, ptr, tl, tl, env, i32) | 33 | @@ -XXX,XX +XXX,XX @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift, |
24 | DEF_HELPER_6(vsse_v_h, void, ptr, ptr, tl, tl, env, i32) | 34 | } |
25 | DEF_HELPER_6(vsse_v_w, void, ptr, ptr, tl, tl, env, i32) | 35 | } |
26 | DEF_HELPER_6(vsse_v_d, void, ptr, ptr, tl, tl, env, i32) | 36 | |
27 | +DEF_HELPER_6(vlxb_v_b, void, ptr, ptr, tl, ptr, env, i32) | 37 | - hart_bits = find_last_bit(&max_hart_per_socket, BITS_PER_LONG) + 1; |
28 | +DEF_HELPER_6(vlxb_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vlxb_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vlxb_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vlxh_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vlxh_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vlxh_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vlxw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vlxw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vlxe_v_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vlxe_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vlxe_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vlxe_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vlxbu_v_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vlxbu_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vlxbu_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vlxbu_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vlxhu_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vlxhu_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vlxhu_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vlxwu_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vlxwu_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vsxb_v_b, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vsxb_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vsxb_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vsxb_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vsxh_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vsxh_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vsxh_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | +DEF_HELPER_6(vsxw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
57 | +DEF_HELPER_6(vsxw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
58 | +DEF_HELPER_6(vsxe_v_b, void, ptr, ptr, tl, ptr, env, i32) | ||
59 | +DEF_HELPER_6(vsxe_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
60 | +DEF_HELPER_6(vsxe_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
61 | +DEF_HELPER_6(vsxe_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
62 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/riscv/insn32.decode | ||
65 | +++ b/target/riscv/insn32.decode | ||
66 | @@ -XXX,XX +XXX,XX @@ vssh_v ... 010 . ..... ..... 101 ..... 0100111 @r_nfvm | ||
67 | vssw_v ... 010 . ..... ..... 110 ..... 0100111 @r_nfvm | ||
68 | vsse_v ... 010 . ..... ..... 111 ..... 0100111 @r_nfvm | ||
69 | |||
70 | +vlxb_v ... 111 . ..... ..... 000 ..... 0000111 @r_nfvm | ||
71 | +vlxh_v ... 111 . ..... ..... 101 ..... 0000111 @r_nfvm | ||
72 | +vlxw_v ... 111 . ..... ..... 110 ..... 0000111 @r_nfvm | ||
73 | +vlxe_v ... 011 . ..... ..... 111 ..... 0000111 @r_nfvm | ||
74 | +vlxbu_v ... 011 . ..... ..... 000 ..... 0000111 @r_nfvm | ||
75 | +vlxhu_v ... 011 . ..... ..... 101 ..... 0000111 @r_nfvm | ||
76 | +vlxwu_v ... 011 . ..... ..... 110 ..... 0000111 @r_nfvm | ||
77 | +# Vector ordered-indexed and unordered-indexed store insns. | ||
78 | +vsxb_v ... -11 . ..... ..... 000 ..... 0100111 @r_nfvm | ||
79 | +vsxh_v ... -11 . ..... ..... 101 ..... 0100111 @r_nfvm | ||
80 | +vsxw_v ... -11 . ..... ..... 110 ..... 0100111 @r_nfvm | ||
81 | +vsxe_v ... -11 . ..... ..... 111 ..... 0100111 @r_nfvm | ||
82 | + | 38 | + |
83 | # *** new major opcode OP-V *** | 39 | + if (max_hart_per_socket > 1) { |
84 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 40 | + max_hart_per_socket--; |
85 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 41 | + hart_bits = find_last_bit(&max_hart_per_socket, BITS_PER_LONG) + 1; |
86 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 42 | + } else { |
87 | index XXXXXXX..XXXXXXX 100644 | 43 | + hart_bits = 0; |
88 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
89 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
90 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_TRANS(vssb_v, 0, rnfvm, st_stride_op, st_stride_check) | ||
91 | GEN_VEXT_TRANS(vssh_v, 1, rnfvm, st_stride_op, st_stride_check) | ||
92 | GEN_VEXT_TRANS(vssw_v, 2, rnfvm, st_stride_op, st_stride_check) | ||
93 | GEN_VEXT_TRANS(vsse_v, 3, rnfvm, st_stride_op, st_stride_check) | ||
94 | + | ||
95 | +/* | ||
96 | + *** index load and store | ||
97 | + */ | ||
98 | +typedef void gen_helper_ldst_index(TCGv_ptr, TCGv_ptr, TCGv, | ||
99 | + TCGv_ptr, TCGv_env, TCGv_i32); | ||
100 | + | ||
101 | +static bool ldst_index_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, | ||
102 | + uint32_t data, gen_helper_ldst_index *fn, | ||
103 | + DisasContext *s) | ||
104 | +{ | ||
105 | + TCGv_ptr dest, mask, index; | ||
106 | + TCGv base; | ||
107 | + TCGv_i32 desc; | ||
108 | + | ||
109 | + TCGLabel *over = gen_new_label(); | ||
110 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
111 | + | ||
112 | + dest = tcg_temp_new_ptr(); | ||
113 | + mask = tcg_temp_new_ptr(); | ||
114 | + index = tcg_temp_new_ptr(); | ||
115 | + base = tcg_temp_new(); | ||
116 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
117 | + | ||
118 | + gen_get_gpr(base, rs1); | ||
119 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
120 | + tcg_gen_addi_ptr(index, cpu_env, vreg_ofs(s, vs2)); | ||
121 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
122 | + | ||
123 | + fn(dest, mask, base, index, cpu_env, desc); | ||
124 | + | ||
125 | + tcg_temp_free_ptr(dest); | ||
126 | + tcg_temp_free_ptr(mask); | ||
127 | + tcg_temp_free_ptr(index); | ||
128 | + tcg_temp_free(base); | ||
129 | + tcg_temp_free_i32(desc); | ||
130 | + gen_set_label(over); | ||
131 | + return true; | ||
132 | +} | ||
133 | + | ||
134 | +static bool ld_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) | ||
135 | +{ | ||
136 | + uint32_t data = 0; | ||
137 | + gen_helper_ldst_index *fn; | ||
138 | + static gen_helper_ldst_index * const fns[7][4] = { | ||
139 | + { gen_helper_vlxb_v_b, gen_helper_vlxb_v_h, | ||
140 | + gen_helper_vlxb_v_w, gen_helper_vlxb_v_d }, | ||
141 | + { NULL, gen_helper_vlxh_v_h, | ||
142 | + gen_helper_vlxh_v_w, gen_helper_vlxh_v_d }, | ||
143 | + { NULL, NULL, | ||
144 | + gen_helper_vlxw_v_w, gen_helper_vlxw_v_d }, | ||
145 | + { gen_helper_vlxe_v_b, gen_helper_vlxe_v_h, | ||
146 | + gen_helper_vlxe_v_w, gen_helper_vlxe_v_d }, | ||
147 | + { gen_helper_vlxbu_v_b, gen_helper_vlxbu_v_h, | ||
148 | + gen_helper_vlxbu_v_w, gen_helper_vlxbu_v_d }, | ||
149 | + { NULL, gen_helper_vlxhu_v_h, | ||
150 | + gen_helper_vlxhu_v_w, gen_helper_vlxhu_v_d }, | ||
151 | + { NULL, NULL, | ||
152 | + gen_helper_vlxwu_v_w, gen_helper_vlxwu_v_d }, | ||
153 | + }; | ||
154 | + | ||
155 | + fn = fns[seq][s->sew]; | ||
156 | + if (fn == NULL) { | ||
157 | + return false; | ||
158 | + } | 44 | + } |
159 | + | 45 | + |
160 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | 46 | ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, |
161 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | 47 | KVM_DEV_RISCV_AIA_CONFIG_HART_BITS, |
162 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | 48 | &hart_bits, true, NULL); |
163 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | ||
164 | + return ldst_index_trans(a->rd, a->rs1, a->rs2, data, fn, s); | ||
165 | +} | ||
166 | + | ||
167 | +static bool ld_index_check(DisasContext *s, arg_rnfvm* a) | ||
168 | +{ | ||
169 | + return (vext_check_isa_ill(s) && | ||
170 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
171 | + vext_check_reg(s, a->rd, false) && | ||
172 | + vext_check_reg(s, a->rs2, false) && | ||
173 | + vext_check_nf(s, a->nf)); | ||
174 | +} | ||
175 | + | ||
176 | +GEN_VEXT_TRANS(vlxb_v, 0, rnfvm, ld_index_op, ld_index_check) | ||
177 | +GEN_VEXT_TRANS(vlxh_v, 1, rnfvm, ld_index_op, ld_index_check) | ||
178 | +GEN_VEXT_TRANS(vlxw_v, 2, rnfvm, ld_index_op, ld_index_check) | ||
179 | +GEN_VEXT_TRANS(vlxe_v, 3, rnfvm, ld_index_op, ld_index_check) | ||
180 | +GEN_VEXT_TRANS(vlxbu_v, 4, rnfvm, ld_index_op, ld_index_check) | ||
181 | +GEN_VEXT_TRANS(vlxhu_v, 5, rnfvm, ld_index_op, ld_index_check) | ||
182 | +GEN_VEXT_TRANS(vlxwu_v, 6, rnfvm, ld_index_op, ld_index_check) | ||
183 | + | ||
184 | +static bool st_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) | ||
185 | +{ | ||
186 | + uint32_t data = 0; | ||
187 | + gen_helper_ldst_index *fn; | ||
188 | + static gen_helper_ldst_index * const fns[4][4] = { | ||
189 | + { gen_helper_vsxb_v_b, gen_helper_vsxb_v_h, | ||
190 | + gen_helper_vsxb_v_w, gen_helper_vsxb_v_d }, | ||
191 | + { NULL, gen_helper_vsxh_v_h, | ||
192 | + gen_helper_vsxh_v_w, gen_helper_vsxh_v_d }, | ||
193 | + { NULL, NULL, | ||
194 | + gen_helper_vsxw_v_w, gen_helper_vsxw_v_d }, | ||
195 | + { gen_helper_vsxe_v_b, gen_helper_vsxe_v_h, | ||
196 | + gen_helper_vsxe_v_w, gen_helper_vsxe_v_d } | ||
197 | + }; | ||
198 | + | ||
199 | + fn = fns[seq][s->sew]; | ||
200 | + if (fn == NULL) { | ||
201 | + return false; | ||
202 | + } | ||
203 | + | ||
204 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
205 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
206 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
207 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | ||
208 | + return ldst_index_trans(a->rd, a->rs1, a->rs2, data, fn, s); | ||
209 | +} | ||
210 | + | ||
211 | +static bool st_index_check(DisasContext *s, arg_rnfvm* a) | ||
212 | +{ | ||
213 | + return (vext_check_isa_ill(s) && | ||
214 | + vext_check_reg(s, a->rd, false) && | ||
215 | + vext_check_reg(s, a->rs2, false) && | ||
216 | + vext_check_nf(s, a->nf)); | ||
217 | +} | ||
218 | + | ||
219 | +GEN_VEXT_TRANS(vsxb_v, 0, rnfvm, st_index_op, st_index_check) | ||
220 | +GEN_VEXT_TRANS(vsxh_v, 1, rnfvm, st_index_op, st_index_check) | ||
221 | +GEN_VEXT_TRANS(vsxw_v, 2, rnfvm, st_index_op, st_index_check) | ||
222 | +GEN_VEXT_TRANS(vsxe_v, 3, rnfvm, st_index_op, st_index_check) | ||
223 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
224 | index XXXXXXX..XXXXXXX 100644 | ||
225 | --- a/target/riscv/vector_helper.c | ||
226 | +++ b/target/riscv/vector_helper.c | ||
227 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_ST_US(vse_v_b, int8_t, int8_t , ste_b) | ||
228 | GEN_VEXT_ST_US(vse_v_h, int16_t, int16_t, ste_h) | ||
229 | GEN_VEXT_ST_US(vse_v_w, int32_t, int32_t, ste_w) | ||
230 | GEN_VEXT_ST_US(vse_v_d, int64_t, int64_t, ste_d) | ||
231 | + | ||
232 | +/* | ||
233 | + *** index: access vector element from indexed memory | ||
234 | + */ | ||
235 | +typedef target_ulong vext_get_index_addr(target_ulong base, | ||
236 | + uint32_t idx, void *vs2); | ||
237 | + | ||
238 | +#define GEN_VEXT_GET_INDEX_ADDR(NAME, ETYPE, H) \ | ||
239 | +static target_ulong NAME(target_ulong base, \ | ||
240 | + uint32_t idx, void *vs2) \ | ||
241 | +{ \ | ||
242 | + return (base + *((ETYPE *)vs2 + H(idx))); \ | ||
243 | +} | ||
244 | + | ||
245 | +GEN_VEXT_GET_INDEX_ADDR(idx_b, int8_t, H1) | ||
246 | +GEN_VEXT_GET_INDEX_ADDR(idx_h, int16_t, H2) | ||
247 | +GEN_VEXT_GET_INDEX_ADDR(idx_w, int32_t, H4) | ||
248 | +GEN_VEXT_GET_INDEX_ADDR(idx_d, int64_t, H8) | ||
249 | + | ||
250 | +static inline void | ||
251 | +vext_ldst_index(void *vd, void *v0, target_ulong base, | ||
252 | + void *vs2, CPURISCVState *env, uint32_t desc, | ||
253 | + vext_get_index_addr get_index_addr, | ||
254 | + vext_ldst_elem_fn *ldst_elem, | ||
255 | + clear_fn *clear_elem, | ||
256 | + uint32_t esz, uint32_t msz, uintptr_t ra, | ||
257 | + MMUAccessType access_type) | ||
258 | +{ | ||
259 | + uint32_t i, k; | ||
260 | + uint32_t nf = vext_nf(desc); | ||
261 | + uint32_t vm = vext_vm(desc); | ||
262 | + uint32_t mlen = vext_mlen(desc); | ||
263 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
264 | + | ||
265 | + /* probe every access*/ | ||
266 | + for (i = 0; i < env->vl; i++) { | ||
267 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
268 | + continue; | ||
269 | + } | ||
270 | + probe_pages(env, get_index_addr(base, i, vs2), nf * msz, ra, | ||
271 | + access_type); | ||
272 | + } | ||
273 | + /* load bytes from guest memory */ | ||
274 | + for (i = 0; i < env->vl; i++) { | ||
275 | + k = 0; | ||
276 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
277 | + continue; | ||
278 | + } | ||
279 | + while (k < nf) { | ||
280 | + abi_ptr addr = get_index_addr(base, i, vs2) + k * msz; | ||
281 | + ldst_elem(env, addr, i + k * vlmax, vd, ra); | ||
282 | + k++; | ||
283 | + } | ||
284 | + } | ||
285 | + /* clear tail elements */ | ||
286 | + if (clear_elem) { | ||
287 | + for (k = 0; k < nf; k++) { | ||
288 | + clear_elem(vd, env->vl + k * vlmax, env->vl * esz, vlmax * esz); | ||
289 | + } | ||
290 | + } | ||
291 | +} | ||
292 | + | ||
293 | +#define GEN_VEXT_LD_INDEX(NAME, MTYPE, ETYPE, INDEX_FN, LOAD_FN, CLEAR_FN) \ | ||
294 | +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ | ||
295 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
296 | +{ \ | ||
297 | + vext_ldst_index(vd, v0, base, vs2, env, desc, INDEX_FN, \ | ||
298 | + LOAD_FN, CLEAR_FN, sizeof(ETYPE), sizeof(MTYPE), \ | ||
299 | + GETPC(), MMU_DATA_LOAD); \ | ||
300 | +} | ||
301 | + | ||
302 | +GEN_VEXT_LD_INDEX(vlxb_v_b, int8_t, int8_t, idx_b, ldb_b, clearb) | ||
303 | +GEN_VEXT_LD_INDEX(vlxb_v_h, int8_t, int16_t, idx_h, ldb_h, clearh) | ||
304 | +GEN_VEXT_LD_INDEX(vlxb_v_w, int8_t, int32_t, idx_w, ldb_w, clearl) | ||
305 | +GEN_VEXT_LD_INDEX(vlxb_v_d, int8_t, int64_t, idx_d, ldb_d, clearq) | ||
306 | +GEN_VEXT_LD_INDEX(vlxh_v_h, int16_t, int16_t, idx_h, ldh_h, clearh) | ||
307 | +GEN_VEXT_LD_INDEX(vlxh_v_w, int16_t, int32_t, idx_w, ldh_w, clearl) | ||
308 | +GEN_VEXT_LD_INDEX(vlxh_v_d, int16_t, int64_t, idx_d, ldh_d, clearq) | ||
309 | +GEN_VEXT_LD_INDEX(vlxw_v_w, int32_t, int32_t, idx_w, ldw_w, clearl) | ||
310 | +GEN_VEXT_LD_INDEX(vlxw_v_d, int32_t, int64_t, idx_d, ldw_d, clearq) | ||
311 | +GEN_VEXT_LD_INDEX(vlxe_v_b, int8_t, int8_t, idx_b, lde_b, clearb) | ||
312 | +GEN_VEXT_LD_INDEX(vlxe_v_h, int16_t, int16_t, idx_h, lde_h, clearh) | ||
313 | +GEN_VEXT_LD_INDEX(vlxe_v_w, int32_t, int32_t, idx_w, lde_w, clearl) | ||
314 | +GEN_VEXT_LD_INDEX(vlxe_v_d, int64_t, int64_t, idx_d, lde_d, clearq) | ||
315 | +GEN_VEXT_LD_INDEX(vlxbu_v_b, uint8_t, uint8_t, idx_b, ldbu_b, clearb) | ||
316 | +GEN_VEXT_LD_INDEX(vlxbu_v_h, uint8_t, uint16_t, idx_h, ldbu_h, clearh) | ||
317 | +GEN_VEXT_LD_INDEX(vlxbu_v_w, uint8_t, uint32_t, idx_w, ldbu_w, clearl) | ||
318 | +GEN_VEXT_LD_INDEX(vlxbu_v_d, uint8_t, uint64_t, idx_d, ldbu_d, clearq) | ||
319 | +GEN_VEXT_LD_INDEX(vlxhu_v_h, uint16_t, uint16_t, idx_h, ldhu_h, clearh) | ||
320 | +GEN_VEXT_LD_INDEX(vlxhu_v_w, uint16_t, uint32_t, idx_w, ldhu_w, clearl) | ||
321 | +GEN_VEXT_LD_INDEX(vlxhu_v_d, uint16_t, uint64_t, idx_d, ldhu_d, clearq) | ||
322 | +GEN_VEXT_LD_INDEX(vlxwu_v_w, uint32_t, uint32_t, idx_w, ldwu_w, clearl) | ||
323 | +GEN_VEXT_LD_INDEX(vlxwu_v_d, uint32_t, uint64_t, idx_d, ldwu_d, clearq) | ||
324 | + | ||
325 | +#define GEN_VEXT_ST_INDEX(NAME, MTYPE, ETYPE, INDEX_FN, STORE_FN)\ | ||
326 | +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ | ||
327 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
328 | +{ \ | ||
329 | + vext_ldst_index(vd, v0, base, vs2, env, desc, INDEX_FN, \ | ||
330 | + STORE_FN, NULL, sizeof(ETYPE), sizeof(MTYPE),\ | ||
331 | + GETPC(), MMU_DATA_STORE); \ | ||
332 | +} | ||
333 | + | ||
334 | +GEN_VEXT_ST_INDEX(vsxb_v_b, int8_t, int8_t, idx_b, stb_b) | ||
335 | +GEN_VEXT_ST_INDEX(vsxb_v_h, int8_t, int16_t, idx_h, stb_h) | ||
336 | +GEN_VEXT_ST_INDEX(vsxb_v_w, int8_t, int32_t, idx_w, stb_w) | ||
337 | +GEN_VEXT_ST_INDEX(vsxb_v_d, int8_t, int64_t, idx_d, stb_d) | ||
338 | +GEN_VEXT_ST_INDEX(vsxh_v_h, int16_t, int16_t, idx_h, sth_h) | ||
339 | +GEN_VEXT_ST_INDEX(vsxh_v_w, int16_t, int32_t, idx_w, sth_w) | ||
340 | +GEN_VEXT_ST_INDEX(vsxh_v_d, int16_t, int64_t, idx_d, sth_d) | ||
341 | +GEN_VEXT_ST_INDEX(vsxw_v_w, int32_t, int32_t, idx_w, stw_w) | ||
342 | +GEN_VEXT_ST_INDEX(vsxw_v_d, int32_t, int64_t, idx_d, stw_d) | ||
343 | +GEN_VEXT_ST_INDEX(vsxe_v_b, int8_t, int8_t, idx_b, ste_b) | ||
344 | +GEN_VEXT_ST_INDEX(vsxe_v_h, int16_t, int16_t, idx_h, ste_h) | ||
345 | +GEN_VEXT_ST_INDEX(vsxe_v_w, int32_t, int32_t, idx_w, ste_w) | ||
346 | +GEN_VEXT_ST_INDEX(vsxe_v_d, int64_t, int64_t, idx_d, ste_d) | ||
347 | -- | 49 | -- |
348 | 2.27.0 | 50 | 2.45.1 |
349 | |||
350 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Commit 33a24910ae changed 'reg_width' to use 'vlenb', i.e. vector length |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | in bytes, when in this context we want 'reg_width' as the length in |
5 | Message-id: 20200623215920.2594-51-zhiwei_liu@c-sky.com | 5 | bits. |
6 | |||
7 | Fix 'reg_width' back to the value in bits like 7cb59921c05a | ||
8 | ("target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen'") set | ||
9 | beforehand. | ||
10 | |||
11 | While we're at it, rename 'reg_width' to 'bitsize' to provide a bit more | ||
12 | clarity about what the variable represents. 'bitsize' is also used in | ||
13 | riscv_gen_dynamic_csr_feature() with the same purpose, i.e. as an input to | ||
14 | gdb_feature_builder_append_reg(). | ||
15 | |||
16 | Cc: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
17 | Cc: Alex Bennée <alex.bennee@linaro.org> | ||
18 | Reported-by: Robin Dapp <rdapp.gcc@gmail.com> | ||
19 | Fixes: 33a24910ae ("target/riscv: Use GDBFeature for dynamic XML") | ||
20 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
21 | Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> | ||
22 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | ||
23 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
24 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
25 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
26 | Message-ID: <20240517203054.880861-2-dbarboza@ventanamicro.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 27 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 28 | --- |
8 | target/riscv/helper.h | 2 ++ | 29 | target/riscv/gdbstub.c | 6 +++--- |
9 | target/riscv/insn32.decode | 1 + | 30 | 1 file changed, 3 insertions(+), 3 deletions(-) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 20 ++++++++++++++++ | ||
12 | 4 files changed, 55 insertions(+) | ||
13 | 31 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 32 | diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c |
15 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 34 | --- a/target/riscv/gdbstub.c |
17 | +++ b/target/riscv/helper.h | 35 | +++ b/target/riscv/gdbstub.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 36 | @@ -XXX,XX +XXX,XX @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) |
19 | DEF_HELPER_6(vmnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 37 | static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg) |
20 | DEF_HELPER_6(vmornot_mm, void, ptr, ptr, ptr, ptr, env, i32) | 38 | { |
21 | DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 39 | RISCVCPU *cpu = RISCV_CPU(cs); |
22 | + | 40 | - int reg_width = cpu->cfg.vlenb; |
23 | +DEF_HELPER_4(vmpopc_m, tl, ptr, ptr, env, i32) | 41 | + int bitsize = cpu->cfg.vlenb << 3; |
24 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 42 | GDBFeatureBuilder builder; |
25 | index XXXXXXX..XXXXXXX 100644 | 43 | int i; |
26 | --- a/target/riscv/insn32.decode | 44 | |
27 | +++ b/target/riscv/insn32.decode | 45 | @@ -XXX,XX +XXX,XX @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg) |
28 | @@ -XXX,XX +XXX,XX @@ vmor_mm 011010 - ..... ..... 010 ..... 1010111 @r | 46 | |
29 | vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r | 47 | /* First define types and totals in a whole VL */ |
30 | vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | 48 | for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { |
31 | vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | 49 | - int count = reg_width / vec_lanes[i].size; |
32 | +vmpopc_m 010100 . ..... ----- 010 ..... 1010111 @r2_vm | 50 | + int count = bitsize / vec_lanes[i].size; |
33 | 51 | gdb_feature_builder_append_tag( | |
34 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 52 | &builder, "<vector id=\"%s\" type=\"%s\" count=\"%d\"/>", |
35 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 53 | vec_lanes[i].id, vec_lanes[i].gdb_type, count); |
36 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 54 | @@ -XXX,XX +XXX,XX @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg) |
37 | index XXXXXXX..XXXXXXX 100644 | 55 | /* Define vector registers */ |
38 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 56 | for (i = 0; i < 32; i++) { |
39 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 57 | gdb_feature_builder_append_reg(&builder, g_strdup_printf("v%d", i), |
40 | @@ -XXX,XX +XXX,XX @@ GEN_MM_TRANS(vmor_mm) | 58 | - reg_width, i, "riscv_vector", "vector"); |
41 | GEN_MM_TRANS(vmnor_mm) | 59 | + bitsize, i, "riscv_vector", "vector"); |
42 | GEN_MM_TRANS(vmornot_mm) | 60 | } |
43 | GEN_MM_TRANS(vmxnor_mm) | 61 | |
44 | + | 62 | gdb_feature_builder_end(&builder); |
45 | +/* Vector mask population count vmpopc */ | ||
46 | +static bool trans_vmpopc_m(DisasContext *s, arg_rmr *a) | ||
47 | +{ | ||
48 | + if (vext_check_isa_ill(s)) { | ||
49 | + TCGv_ptr src2, mask; | ||
50 | + TCGv dst; | ||
51 | + TCGv_i32 desc; | ||
52 | + uint32_t data = 0; | ||
53 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
54 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
55 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
56 | + | ||
57 | + mask = tcg_temp_new_ptr(); | ||
58 | + src2 = tcg_temp_new_ptr(); | ||
59 | + dst = tcg_temp_new(); | ||
60 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
61 | + | ||
62 | + tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, a->rs2)); | ||
63 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
64 | + | ||
65 | + gen_helper_vmpopc_m(dst, mask, src2, cpu_env, desc); | ||
66 | + gen_set_gpr(a->rd, dst); | ||
67 | + | ||
68 | + tcg_temp_free_ptr(mask); | ||
69 | + tcg_temp_free_ptr(src2); | ||
70 | + tcg_temp_free(dst); | ||
71 | + tcg_temp_free_i32(desc); | ||
72 | + return true; | ||
73 | + } | ||
74 | + return false; | ||
75 | +} | ||
76 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/riscv/vector_helper.c | ||
79 | +++ b/target/riscv/vector_helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_MASK_VV(vmor_mm, DO_OR) | ||
81 | GEN_VEXT_MASK_VV(vmnor_mm, DO_NOR) | ||
82 | GEN_VEXT_MASK_VV(vmornot_mm, DO_ORNOT) | ||
83 | GEN_VEXT_MASK_VV(vmxnor_mm, DO_XNOR) | ||
84 | + | ||
85 | +/* Vector mask population count vmpopc */ | ||
86 | +target_ulong HELPER(vmpopc_m)(void *v0, void *vs2, CPURISCVState *env, | ||
87 | + uint32_t desc) | ||
88 | +{ | ||
89 | + target_ulong cnt = 0; | ||
90 | + uint32_t mlen = vext_mlen(desc); | ||
91 | + uint32_t vm = vext_vm(desc); | ||
92 | + uint32_t vl = env->vl; | ||
93 | + int i; | ||
94 | + | ||
95 | + for (i = 0; i < vl; i++) { | ||
96 | + if (vm || vext_elem_mask(v0, mlen, i)) { | ||
97 | + if (vext_elem_mask(vs2, mlen, i)) { | ||
98 | + cnt++; | ||
99 | + } | ||
100 | + } | ||
101 | + } | ||
102 | + return cnt; | ||
103 | +} | ||
104 | -- | 63 | -- |
105 | 2.27.0 | 64 | 2.45.1 |
106 | 65 | ||
107 | 66 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Alistair Francis <alistair23@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Previously we only listed a single pmpcfg CSR and the first 16 pmpaddr |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | CSRs. This patch fixes this to list all 16 pmpcfg and all 64 pmpaddr |
5 | Message-id: 20200623215920.2594-50-zhiwei_liu@c-sky.com | 5 | CSRs are part of the disassembly. |
6 | |||
7 | Reported-by: Eric DeVolder <eric_devolder@yahoo.com> | ||
8 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Fixes: ea10325917 ("RISC-V Disassembler") | ||
10 | Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
11 | Cc: qemu-stable <qemu-stable@nongnu.org> | ||
12 | Message-ID: <20240514051615.330979-1-alistair.francis@wdc.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 13 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 14 | --- |
8 | target/riscv/helper.h | 9 ++++++ | 15 | disas/riscv.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++- |
9 | target/riscv/insn32.decode | 8 +++++ | 16 | 1 file changed, 64 insertions(+), 1 deletion(-) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 35 ++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 40 +++++++++++++++++++++++++ | ||
12 | 4 files changed, 92 insertions(+) | ||
13 | 17 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 18 | diff --git a/disas/riscv.c b/disas/riscv.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 20 | --- a/disas/riscv.c |
17 | +++ b/target/riscv/helper.h | 21 | +++ b/disas/riscv.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfredmin_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | 22 | @@ -XXX,XX +XXX,XX @@ static const char *csr_name(int csrno) |
19 | 23 | case 0x0383: return "mibound"; | |
20 | DEF_HELPER_6(vfwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | 24 | case 0x0384: return "mdbase"; |
21 | DEF_HELPER_6(vfwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | 25 | case 0x0385: return "mdbound"; |
22 | + | 26 | - case 0x03a0: return "pmpcfg3"; |
23 | +DEF_HELPER_6(vmand_mm, void, ptr, ptr, ptr, ptr, env, i32) | 27 | + case 0x03a0: return "pmpcfg0"; |
24 | +DEF_HELPER_6(vmnand_mm, void, ptr, ptr, ptr, ptr, env, i32) | 28 | + case 0x03a1: return "pmpcfg1"; |
25 | +DEF_HELPER_6(vmandnot_mm, void, ptr, ptr, ptr, ptr, env, i32) | 29 | + case 0x03a2: return "pmpcfg2"; |
26 | +DEF_HELPER_6(vmxor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 30 | + case 0x03a3: return "pmpcfg3"; |
27 | +DEF_HELPER_6(vmor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 31 | + case 0x03a4: return "pmpcfg4"; |
28 | +DEF_HELPER_6(vmnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 32 | + case 0x03a5: return "pmpcfg5"; |
29 | +DEF_HELPER_6(vmornot_mm, void, ptr, ptr, ptr, ptr, env, i32) | 33 | + case 0x03a6: return "pmpcfg6"; |
30 | +DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | 34 | + case 0x03a7: return "pmpcfg7"; |
31 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 35 | + case 0x03a8: return "pmpcfg8"; |
32 | index XXXXXXX..XXXXXXX 100644 | 36 | + case 0x03a9: return "pmpcfg9"; |
33 | --- a/target/riscv/insn32.decode | 37 | + case 0x03aa: return "pmpcfg10"; |
34 | +++ b/target/riscv/insn32.decode | 38 | + case 0x03ab: return "pmpcfg11"; |
35 | @@ -XXX,XX +XXX,XX @@ vfredmin_vs 000101 . ..... ..... 001 ..... 1010111 @r_vm | 39 | + case 0x03ac: return "pmpcfg12"; |
36 | vfredmax_vs 000111 . ..... ..... 001 ..... 1010111 @r_vm | 40 | + case 0x03ad: return "pmpcfg13"; |
37 | # Vector widening ordered and unordered float reduction sum | 41 | + case 0x03ae: return "pmpcfg14"; |
38 | vfwredsum_vs 1100-1 . ..... ..... 001 ..... 1010111 @r_vm | 42 | + case 0x03af: return "pmpcfg15"; |
39 | +vmand_mm 011001 - ..... ..... 010 ..... 1010111 @r | 43 | case 0x03b0: return "pmpaddr0"; |
40 | +vmnand_mm 011101 - ..... ..... 010 ..... 1010111 @r | 44 | case 0x03b1: return "pmpaddr1"; |
41 | +vmandnot_mm 011000 - ..... ..... 010 ..... 1010111 @r | 45 | case 0x03b2: return "pmpaddr2"; |
42 | +vmxor_mm 011011 - ..... ..... 010 ..... 1010111 @r | 46 | @@ -XXX,XX +XXX,XX @@ static const char *csr_name(int csrno) |
43 | +vmor_mm 011010 - ..... ..... 010 ..... 1010111 @r | 47 | case 0x03bd: return "pmpaddr13"; |
44 | +vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r | 48 | case 0x03be: return "pmpaddr14"; |
45 | +vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | 49 | case 0x03bf: return "pmpaddr15"; |
46 | +vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | 50 | + case 0x03c0: return "pmpaddr16"; |
47 | 51 | + case 0x03c1: return "pmpaddr17"; | |
48 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 52 | + case 0x03c2: return "pmpaddr18"; |
49 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 53 | + case 0x03c3: return "pmpaddr19"; |
50 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 54 | + case 0x03c4: return "pmpaddr20"; |
51 | index XXXXXXX..XXXXXXX 100644 | 55 | + case 0x03c5: return "pmpaddr21"; |
52 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 56 | + case 0x03c6: return "pmpaddr22"; |
53 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 57 | + case 0x03c7: return "pmpaddr23"; |
54 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVV_TRANS(vfredmin_vs, reduction_check) | 58 | + case 0x03c8: return "pmpaddr24"; |
55 | 59 | + case 0x03c9: return "pmpaddr25"; | |
56 | /* Vector Widening Floating-Point Reduction Instructions */ | 60 | + case 0x03ca: return "pmpaddr26"; |
57 | GEN_OPFVV_WIDEN_TRANS(vfwredsum_vs, reduction_check) | 61 | + case 0x03cb: return "pmpaddr27"; |
58 | + | 62 | + case 0x03cc: return "pmpaddr28"; |
59 | +/* | 63 | + case 0x03cd: return "pmpaddr29"; |
60 | + *** Vector Mask Operations | 64 | + case 0x03ce: return "pmpaddr30"; |
61 | + */ | 65 | + case 0x03cf: return "pmpaddr31"; |
62 | + | 66 | + case 0x03d0: return "pmpaddr32"; |
63 | +/* Vector Mask-Register Logical Instructions */ | 67 | + case 0x03d1: return "pmpaddr33"; |
64 | +#define GEN_MM_TRANS(NAME) \ | 68 | + case 0x03d2: return "pmpaddr34"; |
65 | +static bool trans_##NAME(DisasContext *s, arg_r *a) \ | 69 | + case 0x03d3: return "pmpaddr35"; |
66 | +{ \ | 70 | + case 0x03d4: return "pmpaddr36"; |
67 | + if (vext_check_isa_ill(s)) { \ | 71 | + case 0x03d5: return "pmpaddr37"; |
68 | + uint32_t data = 0; \ | 72 | + case 0x03d6: return "pmpaddr38"; |
69 | + gen_helper_gvec_4_ptr *fn = gen_helper_##NAME; \ | 73 | + case 0x03d7: return "pmpaddr39"; |
70 | + TCGLabel *over = gen_new_label(); \ | 74 | + case 0x03d8: return "pmpaddr40"; |
71 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | 75 | + case 0x03d9: return "pmpaddr41"; |
72 | + \ | 76 | + case 0x03da: return "pmpaddr42"; |
73 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | 77 | + case 0x03db: return "pmpaddr43"; |
74 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | 78 | + case 0x03dc: return "pmpaddr44"; |
75 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | 79 | + case 0x03dd: return "pmpaddr45"; |
76 | + vreg_ofs(s, a->rs1), \ | 80 | + case 0x03de: return "pmpaddr46"; |
77 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | 81 | + case 0x03df: return "pmpaddr47"; |
78 | + s->vlen / 8, data, fn); \ | 82 | + case 0x03e0: return "pmpaddr48"; |
79 | + gen_set_label(over); \ | 83 | + case 0x03e1: return "pmpaddr49"; |
80 | + return true; \ | 84 | + case 0x03e2: return "pmpaddr50"; |
81 | + } \ | 85 | + case 0x03e3: return "pmpaddr51"; |
82 | + return false; \ | 86 | + case 0x03e4: return "pmpaddr52"; |
83 | +} | 87 | + case 0x03e5: return "pmpaddr53"; |
84 | + | 88 | + case 0x03e6: return "pmpaddr54"; |
85 | +GEN_MM_TRANS(vmand_mm) | 89 | + case 0x03e7: return "pmpaddr55"; |
86 | +GEN_MM_TRANS(vmnand_mm) | 90 | + case 0x03e8: return "pmpaddr56"; |
87 | +GEN_MM_TRANS(vmandnot_mm) | 91 | + case 0x03e9: return "pmpaddr57"; |
88 | +GEN_MM_TRANS(vmxor_mm) | 92 | + case 0x03ea: return "pmpaddr58"; |
89 | +GEN_MM_TRANS(vmor_mm) | 93 | + case 0x03eb: return "pmpaddr59"; |
90 | +GEN_MM_TRANS(vmnor_mm) | 94 | + case 0x03ec: return "pmpaddr60"; |
91 | +GEN_MM_TRANS(vmornot_mm) | 95 | + case 0x03ed: return "pmpaddr61"; |
92 | +GEN_MM_TRANS(vmxnor_mm) | 96 | + case 0x03ee: return "pmpaddr62"; |
93 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | 97 | + case 0x03ef: return "pmpaddr63"; |
94 | index XXXXXXX..XXXXXXX 100644 | 98 | case 0x0780: return "mtohost"; |
95 | --- a/target/riscv/vector_helper.c | 99 | case 0x0781: return "mfromhost"; |
96 | +++ b/target/riscv/vector_helper.c | 100 | case 0x0782: return "mreset"; |
97 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfwredsum_vs_w)(void *vd, void *v0, void *vs1, | ||
98 | *((uint64_t *)vd) = s1; | ||
99 | clearq(vd, 1, sizeof(uint64_t), tot); | ||
100 | } | ||
101 | + | ||
102 | +/* | ||
103 | + *** Vector Mask Operations | ||
104 | + */ | ||
105 | +/* Vector Mask-Register Logical Instructions */ | ||
106 | +#define GEN_VEXT_MASK_VV(NAME, OP) \ | ||
107 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, \ | ||
108 | + void *vs2, CPURISCVState *env, \ | ||
109 | + uint32_t desc) \ | ||
110 | +{ \ | ||
111 | + uint32_t mlen = vext_mlen(desc); \ | ||
112 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
113 | + uint32_t vl = env->vl; \ | ||
114 | + uint32_t i; \ | ||
115 | + int a, b; \ | ||
116 | + \ | ||
117 | + for (i = 0; i < vl; i++) { \ | ||
118 | + a = vext_elem_mask(vs1, mlen, i); \ | ||
119 | + b = vext_elem_mask(vs2, mlen, i); \ | ||
120 | + vext_set_elem_mask(vd, mlen, i, OP(b, a)); \ | ||
121 | + } \ | ||
122 | + for (; i < vlmax; i++) { \ | ||
123 | + vext_set_elem_mask(vd, mlen, i, 0); \ | ||
124 | + } \ | ||
125 | +} | ||
126 | + | ||
127 | +#define DO_NAND(N, M) (!(N & M)) | ||
128 | +#define DO_ANDNOT(N, M) (N & !M) | ||
129 | +#define DO_NOR(N, M) (!(N | M)) | ||
130 | +#define DO_ORNOT(N, M) (N | !M) | ||
131 | +#define DO_XNOR(N, M) (!(N ^ M)) | ||
132 | + | ||
133 | +GEN_VEXT_MASK_VV(vmand_mm, DO_AND) | ||
134 | +GEN_VEXT_MASK_VV(vmnand_mm, DO_NAND) | ||
135 | +GEN_VEXT_MASK_VV(vmandnot_mm, DO_ANDNOT) | ||
136 | +GEN_VEXT_MASK_VV(vmxor_mm, DO_XOR) | ||
137 | +GEN_VEXT_MASK_VV(vmor_mm, DO_OR) | ||
138 | +GEN_VEXT_MASK_VV(vmnor_mm, DO_NOR) | ||
139 | +GEN_VEXT_MASK_VV(vmornot_mm, DO_ORNOT) | ||
140 | +GEN_VEXT_MASK_VV(vmxnor_mm, DO_XNOR) | ||
141 | -- | 101 | -- |
142 | 2.27.0 | 102 | 2.45.1 |
143 | |||
144 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Yu-Ming Chang <yumin686@andestech.com> |
---|---|---|---|
2 | 2 | ||
3 | The 32 vector registers will be viewed as a continuous memory block. | 3 | Both CSRRS and CSRRC always read the addressed CSR and cause any read side |
4 | It avoids the convension between element index and (regno, offset). | 4 | effects regardless of rs1 and rd fields. Note that if rs1 specifies a register |
5 | Thus elements can be directly accessed by offset from the first vector | 5 | holding a zero value other than x0, the instruction will still attempt to write |
6 | base address. | 6 | the unmodified value back to the CSR and will cause any attendant side effects. |
7 | 7 | ||
8 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 8 | So if CSRRS or CSRRC tries to write a read-only CSR with rs1 which specifies |
9 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | 9 | a register holding a zero value, an illegal instruction exception should be |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | raised. |
11 | Message-id: 20200623215920.2594-2-zhiwei_liu@c-sky.com | 11 | |
12 | Signed-off-by: Yu-Ming Chang <yumin686@andestech.com> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Message-ID: <20240403070823.80897-1-yumin686@andestech.com> | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
13 | --- | 16 | --- |
14 | target/riscv/cpu.h | 12 ++++++++++++ | 17 | target/riscv/cpu.h | 4 ++++ |
15 | target/riscv/translate.c | 3 ++- | 18 | target/riscv/csr.c | 51 ++++++++++++++++++++++++++++++++++++---- |
16 | 2 files changed, 14 insertions(+), 1 deletion(-) | 19 | target/riscv/op_helper.c | 6 ++--- |
20 | 3 files changed, 53 insertions(+), 8 deletions(-) | ||
17 | 21 | ||
18 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | 22 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h |
19 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/riscv/cpu.h | 24 | --- a/target/riscv/cpu.h |
21 | +++ b/target/riscv/cpu.h | 25 | +++ b/target/riscv/cpu.h |
22 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, |
23 | #define RVA RV('A') | 27 | void riscv_cpu_update_mask(CPURISCVState *env); |
24 | #define RVF RV('F') | 28 | bool riscv_cpu_is_32bit(RISCVCPU *cpu); |
25 | #define RVD RV('D') | 29 | |
26 | +#define RVV RV('V') | 30 | +RISCVException riscv_csrr(CPURISCVState *env, int csrno, |
27 | #define RVC RV('C') | 31 | + target_ulong *ret_value); |
28 | #define RVS RV('S') | 32 | RISCVException riscv_csrrw(CPURISCVState *env, int csrno, |
29 | #define RVU RV('U') | 33 | target_ulong *ret_value, |
30 | @@ -XXX,XX +XXX,XX @@ typedef struct CPURISCVState CPURISCVState; | 34 | target_ulong new_value, target_ulong write_mask); |
31 | 35 | @@ -XXX,XX +XXX,XX @@ typedef RISCVException (*riscv_csr_op_fn)(CPURISCVState *env, int csrno, | |
32 | #include "pmp.h" | 36 | target_ulong new_value, |
33 | 37 | target_ulong write_mask); | |
34 | +#define RV_VLEN_MAX 512 | 38 | |
39 | +RISCVException riscv_csrr_i128(CPURISCVState *env, int csrno, | ||
40 | + Int128 *ret_value); | ||
41 | RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, | ||
42 | Int128 *ret_value, | ||
43 | Int128 new_value, Int128 write_mask); | ||
44 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/riscv/csr.c | ||
47 | +++ b/target/riscv/csr.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static RISCVException rmw_seed(CPURISCVState *env, int csrno, | ||
49 | |||
50 | static inline RISCVException riscv_csrrw_check(CPURISCVState *env, | ||
51 | int csrno, | ||
52 | - bool write_mask) | ||
53 | + bool write) | ||
54 | { | ||
55 | /* check privileges and return RISCV_EXCP_ILLEGAL_INST if check fails */ | ||
56 | bool read_only = get_field(csrno, 0xC00) == 3; | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline RISCVException riscv_csrrw_check(CPURISCVState *env, | ||
58 | } | ||
59 | |||
60 | /* read / write check */ | ||
61 | - if (write_mask && read_only) { | ||
62 | + if (write && read_only) { | ||
63 | return RISCV_EXCP_ILLEGAL_INST; | ||
64 | } | ||
65 | |||
66 | @@ -XXX,XX +XXX,XX @@ static RISCVException riscv_csrrw_do64(CPURISCVState *env, int csrno, | ||
67 | return RISCV_EXCP_NONE; | ||
68 | } | ||
69 | |||
70 | +RISCVException riscv_csrr(CPURISCVState *env, int csrno, | ||
71 | + target_ulong *ret_value) | ||
72 | +{ | ||
73 | + RISCVException ret = riscv_csrrw_check(env, csrno, false); | ||
74 | + if (ret != RISCV_EXCP_NONE) { | ||
75 | + return ret; | ||
76 | + } | ||
35 | + | 77 | + |
36 | struct CPURISCVState { | 78 | + return riscv_csrrw_do64(env, csrno, ret_value, 0, 0); |
37 | target_ulong gpr[32]; | 79 | +} |
38 | uint64_t fpr[32]; /* assume both F and D extensions */ | ||
39 | + | 80 | + |
40 | + /* vector coprocessor state. */ | 81 | RISCVException riscv_csrrw(CPURISCVState *env, int csrno, |
41 | + uint64_t vreg[32 * RV_VLEN_MAX / 64] QEMU_ALIGNED(16); | 82 | target_ulong *ret_value, |
42 | + target_ulong vxrm; | 83 | target_ulong new_value, target_ulong write_mask) |
43 | + target_ulong vxsat; | 84 | { |
44 | + target_ulong vl; | 85 | - RISCVException ret = riscv_csrrw_check(env, csrno, write_mask); |
45 | + target_ulong vstart; | 86 | + RISCVException ret = riscv_csrrw_check(env, csrno, true); |
46 | + target_ulong vtype; | 87 | if (ret != RISCV_EXCP_NONE) { |
88 | return ret; | ||
89 | } | ||
90 | @@ -XXX,XX +XXX,XX @@ static RISCVException riscv_csrrw_do128(CPURISCVState *env, int csrno, | ||
91 | return RISCV_EXCP_NONE; | ||
92 | } | ||
93 | |||
94 | +RISCVException riscv_csrr_i128(CPURISCVState *env, int csrno, | ||
95 | + Int128 *ret_value) | ||
96 | +{ | ||
97 | + RISCVException ret; | ||
47 | + | 98 | + |
48 | target_ulong pc; | 99 | + ret = riscv_csrrw_check(env, csrno, false); |
49 | target_ulong load_res; | 100 | + if (ret != RISCV_EXCP_NONE) { |
50 | target_ulong load_val; | 101 | + return ret; |
51 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | 102 | + } |
103 | + | ||
104 | + if (csr_ops[csrno].read128) { | ||
105 | + return riscv_csrrw_do128(env, csrno, ret_value, | ||
106 | + int128_zero(), int128_zero()); | ||
107 | + } | ||
108 | + | ||
109 | + /* | ||
110 | + * Fall back to 64-bit version for now, if the 128-bit alternative isn't | ||
111 | + * at all defined. | ||
112 | + * Note, some CSRs don't need to extend to MXLEN (64 upper bits non | ||
113 | + * significant), for those, this fallback is correctly handling the | ||
114 | + * accesses | ||
115 | + */ | ||
116 | + target_ulong old_value; | ||
117 | + ret = riscv_csrrw_do64(env, csrno, &old_value, | ||
118 | + (target_ulong)0, | ||
119 | + (target_ulong)0); | ||
120 | + if (ret == RISCV_EXCP_NONE && ret_value) { | ||
121 | + *ret_value = int128_make64(old_value); | ||
122 | + } | ||
123 | + return ret; | ||
124 | +} | ||
125 | + | ||
126 | RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, | ||
127 | Int128 *ret_value, | ||
128 | Int128 new_value, Int128 write_mask) | ||
129 | { | ||
130 | RISCVException ret; | ||
131 | |||
132 | - ret = riscv_csrrw_check(env, csrno, int128_nz(write_mask)); | ||
133 | + ret = riscv_csrrw_check(env, csrno, true); | ||
134 | if (ret != RISCV_EXCP_NONE) { | ||
135 | return ret; | ||
136 | } | ||
137 | diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | 138 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/target/riscv/translate.c | 139 | --- a/target/riscv/op_helper.c |
54 | +++ b/target/riscv/translate.c | 140 | +++ b/target/riscv/op_helper.c |
55 | @@ -XXX,XX +XXX,XX @@ | 141 | @@ -XXX,XX +XXX,XX @@ target_ulong helper_csrr(CPURISCVState *env, int csr) |
56 | #include "instmap.h" | ||
57 | |||
58 | /* global register indices */ | ||
59 | -static TCGv cpu_gpr[32], cpu_pc; | ||
60 | +static TCGv cpu_gpr[32], cpu_pc, cpu_vl; | ||
61 | static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */ | ||
62 | static TCGv load_res; | ||
63 | static TCGv load_val; | ||
64 | @@ -XXX,XX +XXX,XX @@ void riscv_translate_init(void) | ||
65 | } | 142 | } |
66 | 143 | ||
67 | cpu_pc = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, pc), "pc"); | 144 | target_ulong val = 0; |
68 | + cpu_vl = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, vl), "vl"); | 145 | - RISCVException ret = riscv_csrrw(env, csr, &val, 0, 0); |
69 | load_res = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_res), | 146 | + RISCVException ret = riscv_csrr(env, csr, &val); |
70 | "load_res"); | 147 | |
71 | load_val = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_val), | 148 | if (ret != RISCV_EXCP_NONE) { |
149 | riscv_raise_exception(env, ret, GETPC()); | ||
150 | @@ -XXX,XX +XXX,XX @@ target_ulong helper_csrrw(CPURISCVState *env, int csr, | ||
151 | target_ulong helper_csrr_i128(CPURISCVState *env, int csr) | ||
152 | { | ||
153 | Int128 rv = int128_zero(); | ||
154 | - RISCVException ret = riscv_csrrw_i128(env, csr, &rv, | ||
155 | - int128_zero(), | ||
156 | - int128_zero()); | ||
157 | + RISCVException ret = riscv_csrr_i128(env, csr, &rv); | ||
158 | |||
159 | if (ret != RISCV_EXCP_NONE) { | ||
160 | riscv_raise_exception(env, ret, GETPC()); | ||
72 | -- | 161 | -- |
73 | 2.27.0 | 162 | 2.45.1 |
74 | |||
75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | The internals.h keeps things that are not relevant to the actual architecture, | ||
4 | only to the implementation, separate. | ||
5 | |||
6 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200623215920.2594-6-zhiwei_liu@c-sky.com | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | --- | ||
12 | target/riscv/internals.h | 24 ++++++++++++++++++++++++ | ||
13 | 1 file changed, 24 insertions(+) | ||
14 | create mode 100644 target/riscv/internals.h | ||
15 | |||
16 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | ||
17 | new file mode 100644 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/target/riscv/internals.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +/* | ||
23 | + * QEMU RISC-V CPU -- internal functions and types | ||
24 | + * | ||
25 | + * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved. | ||
26 | + * | ||
27 | + * This program is free software; you can redistribute it and/or modify it | ||
28 | + * under the terms and conditions of the GNU General Public License, | ||
29 | + * version 2 or later, as published by the Free Software Foundation. | ||
30 | + * | ||
31 | + * This program is distributed in the hope it will be useful, but WITHOUT | ||
32 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
33 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
34 | + * more details. | ||
35 | + * | ||
36 | + * You should have received a copy of the GNU General Public License along with | ||
37 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
38 | + */ | ||
39 | + | ||
40 | +#ifndef RISCV_CPU_INTERNALS_H | ||
41 | +#define RISCV_CPU_INTERNALS_H | ||
42 | + | ||
43 | +#include "hw/registerfields.h" | ||
44 | + | ||
45 | +#endif | ||
46 | -- | ||
47 | 2.27.0 | ||
48 | |||
49 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200623215920.2594-13-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 33 ++++++ | ||
10 | target/riscv/insn32.decode | 11 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 113 +++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 137 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 294 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vwadd_wx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vwsub_wx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vwsub_wx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vwsub_wx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vadc_vvm_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vadc_vvm_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vadc_vvm_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vadc_vvm_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vsbc_vvm_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vsbc_vvm_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vsbc_vvm_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vsbc_vvm_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vmadc_vvm_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vmadc_vvm_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vmadc_vvm_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vmadc_vvm_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vmsbc_vvm_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vmsbc_vvm_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vmsbc_vvm_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vmsbc_vvm_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vadc_vxm_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vadc_vxm_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vadc_vxm_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vadc_vxm_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vsbc_vxm_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vsbc_vxm_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vsbc_vxm_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vsbc_vxm_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vmadc_vxm_b, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vmadc_vxm_h, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vmadc_vxm_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vmadc_vxm_d, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vmsbc_vxm_b, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vmsbc_vxm_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vmsbc_vxm_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vmsbc_vxm_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/riscv/insn32.decode | ||
59 | +++ b/target/riscv/insn32.decode | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | ||
62 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | ||
63 | @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | ||
64 | +@r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd | ||
65 | @r_wdvm ..... wd:1 vm:1 ..... ..... ... ..... ....... &rwdvm %rs2 %rs1 %rd | ||
66 | @r2_zimm . zimm:11 ..... ... ..... ....... %rs1 %rd | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ vwsubu_wv 110110 . ..... ..... 010 ..... 1010111 @r_vm | ||
69 | vwsubu_wx 110110 . ..... ..... 110 ..... 1010111 @r_vm | ||
70 | vwsub_wv 110111 . ..... ..... 010 ..... 1010111 @r_vm | ||
71 | vwsub_wx 110111 . ..... ..... 110 ..... 1010111 @r_vm | ||
72 | +vadc_vvm 010000 1 ..... ..... 000 ..... 1010111 @r_vm_1 | ||
73 | +vadc_vxm 010000 1 ..... ..... 100 ..... 1010111 @r_vm_1 | ||
74 | +vadc_vim 010000 1 ..... ..... 011 ..... 1010111 @r_vm_1 | ||
75 | +vmadc_vvm 010001 1 ..... ..... 000 ..... 1010111 @r_vm_1 | ||
76 | +vmadc_vxm 010001 1 ..... ..... 100 ..... 1010111 @r_vm_1 | ||
77 | +vmadc_vim 010001 1 ..... ..... 011 ..... 1010111 @r_vm_1 | ||
78 | +vsbc_vvm 010010 1 ..... ..... 000 ..... 1010111 @r_vm_1 | ||
79 | +vsbc_vxm 010010 1 ..... ..... 100 ..... 1010111 @r_vm_1 | ||
80 | +vmsbc_vvm 010011 1 ..... ..... 000 ..... 1010111 @r_vm_1 | ||
81 | +vmsbc_vxm 010011 1 ..... ..... 100 ..... 1010111 @r_vm_1 | ||
82 | |||
83 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
84 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
85 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
88 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
89 | @@ -XXX,XX +XXX,XX @@ GEN_OPIWX_WIDEN_TRANS(vwaddu_wx) | ||
90 | GEN_OPIWX_WIDEN_TRANS(vwadd_wx) | ||
91 | GEN_OPIWX_WIDEN_TRANS(vwsubu_wx) | ||
92 | GEN_OPIWX_WIDEN_TRANS(vwsub_wx) | ||
93 | + | ||
94 | +/* Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions */ | ||
95 | +/* OPIVV without GVEC IR */ | ||
96 | +#define GEN_OPIVV_TRANS(NAME, CHECK) \ | ||
97 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
98 | +{ \ | ||
99 | + if (CHECK(s, a)) { \ | ||
100 | + uint32_t data = 0; \ | ||
101 | + static gen_helper_gvec_4_ptr * const fns[4] = { \ | ||
102 | + gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ | ||
103 | + gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ | ||
104 | + }; \ | ||
105 | + TCGLabel *over = gen_new_label(); \ | ||
106 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
107 | + \ | ||
108 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
109 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
110 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
111 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
112 | + vreg_ofs(s, a->rs1), \ | ||
113 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
114 | + s->vlen / 8, data, fns[s->sew]); \ | ||
115 | + gen_set_label(over); \ | ||
116 | + return true; \ | ||
117 | + } \ | ||
118 | + return false; \ | ||
119 | +} | ||
120 | + | ||
121 | +/* | ||
122 | + * For vadc and vsbc, an illegal instruction exception is raised if the | ||
123 | + * destination vector register is v0 and LMUL > 1. (Section 12.3) | ||
124 | + */ | ||
125 | +static bool opivv_vadc_check(DisasContext *s, arg_rmrr *a) | ||
126 | +{ | ||
127 | + return (vext_check_isa_ill(s) && | ||
128 | + vext_check_reg(s, a->rd, false) && | ||
129 | + vext_check_reg(s, a->rs2, false) && | ||
130 | + vext_check_reg(s, a->rs1, false) && | ||
131 | + ((a->rd != 0) || (s->lmul == 0))); | ||
132 | +} | ||
133 | + | ||
134 | +GEN_OPIVV_TRANS(vadc_vvm, opivv_vadc_check) | ||
135 | +GEN_OPIVV_TRANS(vsbc_vvm, opivv_vadc_check) | ||
136 | + | ||
137 | +/* | ||
138 | + * For vmadc and vmsbc, an illegal instruction exception is raised if the | ||
139 | + * destination vector register overlaps a source vector register group. | ||
140 | + */ | ||
141 | +static bool opivv_vmadc_check(DisasContext *s, arg_rmrr *a) | ||
142 | +{ | ||
143 | + return (vext_check_isa_ill(s) && | ||
144 | + vext_check_reg(s, a->rs2, false) && | ||
145 | + vext_check_reg(s, a->rs1, false) && | ||
146 | + vext_check_overlap_group(a->rd, 1, a->rs1, 1 << s->lmul) && | ||
147 | + vext_check_overlap_group(a->rd, 1, a->rs2, 1 << s->lmul)); | ||
148 | +} | ||
149 | + | ||
150 | +GEN_OPIVV_TRANS(vmadc_vvm, opivv_vmadc_check) | ||
151 | +GEN_OPIVV_TRANS(vmsbc_vvm, opivv_vmadc_check) | ||
152 | + | ||
153 | +static bool opivx_vadc_check(DisasContext *s, arg_rmrr *a) | ||
154 | +{ | ||
155 | + return (vext_check_isa_ill(s) && | ||
156 | + vext_check_reg(s, a->rd, false) && | ||
157 | + vext_check_reg(s, a->rs2, false) && | ||
158 | + ((a->rd != 0) || (s->lmul == 0))); | ||
159 | +} | ||
160 | + | ||
161 | +/* OPIVX without GVEC IR */ | ||
162 | +#define GEN_OPIVX_TRANS(NAME, CHECK) \ | ||
163 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
164 | +{ \ | ||
165 | + if (CHECK(s, a)) { \ | ||
166 | + static gen_helper_opivx * const fns[4] = { \ | ||
167 | + gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ | ||
168 | + gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ | ||
169 | + }; \ | ||
170 | + \ | ||
171 | + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s);\ | ||
172 | + } \ | ||
173 | + return false; \ | ||
174 | +} | ||
175 | + | ||
176 | +GEN_OPIVX_TRANS(vadc_vxm, opivx_vadc_check) | ||
177 | +GEN_OPIVX_TRANS(vsbc_vxm, opivx_vadc_check) | ||
178 | + | ||
179 | +static bool opivx_vmadc_check(DisasContext *s, arg_rmrr *a) | ||
180 | +{ | ||
181 | + return (vext_check_isa_ill(s) && | ||
182 | + vext_check_reg(s, a->rs2, false) && | ||
183 | + vext_check_overlap_group(a->rd, 1, a->rs2, 1 << s->lmul)); | ||
184 | +} | ||
185 | + | ||
186 | +GEN_OPIVX_TRANS(vmadc_vxm, opivx_vmadc_check) | ||
187 | +GEN_OPIVX_TRANS(vmsbc_vxm, opivx_vmadc_check) | ||
188 | + | ||
189 | +/* OPIVI without GVEC IR */ | ||
190 | +#define GEN_OPIVI_TRANS(NAME, ZX, OPIVX, CHECK) \ | ||
191 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
192 | +{ \ | ||
193 | + if (CHECK(s, a)) { \ | ||
194 | + static gen_helper_opivx * const fns[4] = { \ | ||
195 | + gen_helper_##OPIVX##_b, gen_helper_##OPIVX##_h, \ | ||
196 | + gen_helper_##OPIVX##_w, gen_helper_##OPIVX##_d, \ | ||
197 | + }; \ | ||
198 | + return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, \ | ||
199 | + fns[s->sew], s, ZX); \ | ||
200 | + } \ | ||
201 | + return false; \ | ||
202 | +} | ||
203 | + | ||
204 | +GEN_OPIVI_TRANS(vadc_vim, 0, vadc_vxm, opivx_vadc_check) | ||
205 | +GEN_OPIVI_TRANS(vmadc_vim, 0, vmadc_vxm, opivx_vmadc_check) | ||
206 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/target/riscv/vector_helper.c | ||
209 | +++ b/target/riscv/vector_helper.c | ||
210 | @@ -XXX,XX +XXX,XX @@ static void clearq(void *vd, uint32_t idx, uint32_t cnt, uint32_t tot) | ||
211 | vext_clear(cur, cnt, tot); | ||
212 | } | ||
213 | |||
214 | +static inline void vext_set_elem_mask(void *v0, int mlen, int index, | ||
215 | + uint8_t value) | ||
216 | +{ | ||
217 | + int idx = (index * mlen) / 64; | ||
218 | + int pos = (index * mlen) % 64; | ||
219 | + uint64_t old = ((uint64_t *)v0)[idx]; | ||
220 | + ((uint64_t *)v0)[idx] = deposit64(old, pos, mlen, value); | ||
221 | +} | ||
222 | |||
223 | static inline int vext_elem_mask(void *v0, int mlen, int index) | ||
224 | { | ||
225 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vwadd_wx_w, 4, 8, clearq) | ||
226 | GEN_VEXT_VX(vwsub_wx_b, 1, 2, clearh) | ||
227 | GEN_VEXT_VX(vwsub_wx_h, 2, 4, clearl) | ||
228 | GEN_VEXT_VX(vwsub_wx_w, 4, 8, clearq) | ||
229 | + | ||
230 | +/* Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions */ | ||
231 | +#define DO_VADC(N, M, C) (N + M + C) | ||
232 | +#define DO_VSBC(N, M, C) (N - M - C) | ||
233 | + | ||
234 | +#define GEN_VEXT_VADC_VVM(NAME, ETYPE, H, DO_OP, CLEAR_FN) \ | ||
235 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
236 | + CPURISCVState *env, uint32_t desc) \ | ||
237 | +{ \ | ||
238 | + uint32_t mlen = vext_mlen(desc); \ | ||
239 | + uint32_t vl = env->vl; \ | ||
240 | + uint32_t esz = sizeof(ETYPE); \ | ||
241 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
242 | + uint32_t i; \ | ||
243 | + \ | ||
244 | + for (i = 0; i < vl; i++) { \ | ||
245 | + ETYPE s1 = *((ETYPE *)vs1 + H(i)); \ | ||
246 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
247 | + uint8_t carry = vext_elem_mask(v0, mlen, i); \ | ||
248 | + \ | ||
249 | + *((ETYPE *)vd + H(i)) = DO_OP(s2, s1, carry); \ | ||
250 | + } \ | ||
251 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
252 | +} | ||
253 | + | ||
254 | +GEN_VEXT_VADC_VVM(vadc_vvm_b, uint8_t, H1, DO_VADC, clearb) | ||
255 | +GEN_VEXT_VADC_VVM(vadc_vvm_h, uint16_t, H2, DO_VADC, clearh) | ||
256 | +GEN_VEXT_VADC_VVM(vadc_vvm_w, uint32_t, H4, DO_VADC, clearl) | ||
257 | +GEN_VEXT_VADC_VVM(vadc_vvm_d, uint64_t, H8, DO_VADC, clearq) | ||
258 | + | ||
259 | +GEN_VEXT_VADC_VVM(vsbc_vvm_b, uint8_t, H1, DO_VSBC, clearb) | ||
260 | +GEN_VEXT_VADC_VVM(vsbc_vvm_h, uint16_t, H2, DO_VSBC, clearh) | ||
261 | +GEN_VEXT_VADC_VVM(vsbc_vvm_w, uint32_t, H4, DO_VSBC, clearl) | ||
262 | +GEN_VEXT_VADC_VVM(vsbc_vvm_d, uint64_t, H8, DO_VSBC, clearq) | ||
263 | + | ||
264 | +#define GEN_VEXT_VADC_VXM(NAME, ETYPE, H, DO_OP, CLEAR_FN) \ | ||
265 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
266 | + CPURISCVState *env, uint32_t desc) \ | ||
267 | +{ \ | ||
268 | + uint32_t mlen = vext_mlen(desc); \ | ||
269 | + uint32_t vl = env->vl; \ | ||
270 | + uint32_t esz = sizeof(ETYPE); \ | ||
271 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
272 | + uint32_t i; \ | ||
273 | + \ | ||
274 | + for (i = 0; i < vl; i++) { \ | ||
275 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
276 | + uint8_t carry = vext_elem_mask(v0, mlen, i); \ | ||
277 | + \ | ||
278 | + *((ETYPE *)vd + H(i)) = DO_OP(s2, (ETYPE)(target_long)s1, carry);\ | ||
279 | + } \ | ||
280 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
281 | +} | ||
282 | + | ||
283 | +GEN_VEXT_VADC_VXM(vadc_vxm_b, uint8_t, H1, DO_VADC, clearb) | ||
284 | +GEN_VEXT_VADC_VXM(vadc_vxm_h, uint16_t, H2, DO_VADC, clearh) | ||
285 | +GEN_VEXT_VADC_VXM(vadc_vxm_w, uint32_t, H4, DO_VADC, clearl) | ||
286 | +GEN_VEXT_VADC_VXM(vadc_vxm_d, uint64_t, H8, DO_VADC, clearq) | ||
287 | + | ||
288 | +GEN_VEXT_VADC_VXM(vsbc_vxm_b, uint8_t, H1, DO_VSBC, clearb) | ||
289 | +GEN_VEXT_VADC_VXM(vsbc_vxm_h, uint16_t, H2, DO_VSBC, clearh) | ||
290 | +GEN_VEXT_VADC_VXM(vsbc_vxm_w, uint32_t, H4, DO_VSBC, clearl) | ||
291 | +GEN_VEXT_VADC_VXM(vsbc_vxm_d, uint64_t, H8, DO_VSBC, clearq) | ||
292 | + | ||
293 | +#define DO_MADC(N, M, C) (C ? (__typeof(N))(N + M + 1) <= N : \ | ||
294 | + (__typeof(N))(N + M) < N) | ||
295 | +#define DO_MSBC(N, M, C) (C ? N <= M : N < M) | ||
296 | + | ||
297 | +#define GEN_VEXT_VMADC_VVM(NAME, ETYPE, H, DO_OP) \ | ||
298 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
299 | + CPURISCVState *env, uint32_t desc) \ | ||
300 | +{ \ | ||
301 | + uint32_t mlen = vext_mlen(desc); \ | ||
302 | + uint32_t vl = env->vl; \ | ||
303 | + uint32_t vlmax = vext_maxsz(desc) / sizeof(ETYPE); \ | ||
304 | + uint32_t i; \ | ||
305 | + \ | ||
306 | + for (i = 0; i < vl; i++) { \ | ||
307 | + ETYPE s1 = *((ETYPE *)vs1 + H(i)); \ | ||
308 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
309 | + uint8_t carry = vext_elem_mask(v0, mlen, i); \ | ||
310 | + \ | ||
311 | + vext_set_elem_mask(vd, mlen, i, DO_OP(s2, s1, carry));\ | ||
312 | + } \ | ||
313 | + for (; i < vlmax; i++) { \ | ||
314 | + vext_set_elem_mask(vd, mlen, i, 0); \ | ||
315 | + } \ | ||
316 | +} | ||
317 | + | ||
318 | +GEN_VEXT_VMADC_VVM(vmadc_vvm_b, uint8_t, H1, DO_MADC) | ||
319 | +GEN_VEXT_VMADC_VVM(vmadc_vvm_h, uint16_t, H2, DO_MADC) | ||
320 | +GEN_VEXT_VMADC_VVM(vmadc_vvm_w, uint32_t, H4, DO_MADC) | ||
321 | +GEN_VEXT_VMADC_VVM(vmadc_vvm_d, uint64_t, H8, DO_MADC) | ||
322 | + | ||
323 | +GEN_VEXT_VMADC_VVM(vmsbc_vvm_b, uint8_t, H1, DO_MSBC) | ||
324 | +GEN_VEXT_VMADC_VVM(vmsbc_vvm_h, uint16_t, H2, DO_MSBC) | ||
325 | +GEN_VEXT_VMADC_VVM(vmsbc_vvm_w, uint32_t, H4, DO_MSBC) | ||
326 | +GEN_VEXT_VMADC_VVM(vmsbc_vvm_d, uint64_t, H8, DO_MSBC) | ||
327 | + | ||
328 | +#define GEN_VEXT_VMADC_VXM(NAME, ETYPE, H, DO_OP) \ | ||
329 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ | ||
330 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
331 | +{ \ | ||
332 | + uint32_t mlen = vext_mlen(desc); \ | ||
333 | + uint32_t vl = env->vl; \ | ||
334 | + uint32_t vlmax = vext_maxsz(desc) / sizeof(ETYPE); \ | ||
335 | + uint32_t i; \ | ||
336 | + \ | ||
337 | + for (i = 0; i < vl; i++) { \ | ||
338 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
339 | + uint8_t carry = vext_elem_mask(v0, mlen, i); \ | ||
340 | + \ | ||
341 | + vext_set_elem_mask(vd, mlen, i, \ | ||
342 | + DO_OP(s2, (ETYPE)(target_long)s1, carry)); \ | ||
343 | + } \ | ||
344 | + for (; i < vlmax; i++) { \ | ||
345 | + vext_set_elem_mask(vd, mlen, i, 0); \ | ||
346 | + } \ | ||
347 | +} | ||
348 | + | ||
349 | +GEN_VEXT_VMADC_VXM(vmadc_vxm_b, uint8_t, H1, DO_MADC) | ||
350 | +GEN_VEXT_VMADC_VXM(vmadc_vxm_h, uint16_t, H2, DO_MADC) | ||
351 | +GEN_VEXT_VMADC_VXM(vmadc_vxm_w, uint32_t, H4, DO_MADC) | ||
352 | +GEN_VEXT_VMADC_VXM(vmadc_vxm_d, uint64_t, H8, DO_MADC) | ||
353 | + | ||
354 | +GEN_VEXT_VMADC_VXM(vmsbc_vxm_b, uint8_t, H1, DO_MSBC) | ||
355 | +GEN_VEXT_VMADC_VXM(vmsbc_vxm_h, uint16_t, H2, DO_MSBC) | ||
356 | +GEN_VEXT_VMADC_VXM(vmsbc_vxm_w, uint32_t, H4, DO_MSBC) | ||
357 | +GEN_VEXT_VMADC_VXM(vmsbc_vxm_d, uint64_t, H8, DO_MSBC) | ||
358 | -- | ||
359 | 2.27.0 | ||
360 | |||
361 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-14-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 25 ++++++++++++ | ||
10 | target/riscv/insn32.decode | 9 +++++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 11 ++++++ | ||
12 | target/riscv/vector_helper.c | 51 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 96 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmsbc_vxm_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vmsbc_vxm_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vmsbc_vxm_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vmsbc_vxm_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vand_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vand_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vand_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vand_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vor_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vor_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vor_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vor_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vxor_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vxor_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vxor_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vxor_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vand_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vand_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vand_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vand_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vor_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vor_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vor_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vor_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vxor_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vxor_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vxor_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vxor_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/riscv/insn32.decode | ||
51 | +++ b/target/riscv/insn32.decode | ||
52 | @@ -XXX,XX +XXX,XX @@ vsbc_vvm 010010 1 ..... ..... 000 ..... 1010111 @r_vm_1 | ||
53 | vsbc_vxm 010010 1 ..... ..... 100 ..... 1010111 @r_vm_1 | ||
54 | vmsbc_vvm 010011 1 ..... ..... 000 ..... 1010111 @r_vm_1 | ||
55 | vmsbc_vxm 010011 1 ..... ..... 100 ..... 1010111 @r_vm_1 | ||
56 | +vand_vv 001001 . ..... ..... 000 ..... 1010111 @r_vm | ||
57 | +vand_vx 001001 . ..... ..... 100 ..... 1010111 @r_vm | ||
58 | +vand_vi 001001 . ..... ..... 011 ..... 1010111 @r_vm | ||
59 | +vor_vv 001010 . ..... ..... 000 ..... 1010111 @r_vm | ||
60 | +vor_vx 001010 . ..... ..... 100 ..... 1010111 @r_vm | ||
61 | +vor_vi 001010 . ..... ..... 011 ..... 1010111 @r_vm | ||
62 | +vxor_vv 001011 . ..... ..... 000 ..... 1010111 @r_vm | ||
63 | +vxor_vx 001011 . ..... ..... 100 ..... 1010111 @r_vm | ||
64 | +vxor_vi 001011 . ..... ..... 011 ..... 1010111 @r_vm | ||
65 | |||
66 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
67 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
68 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
71 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
73 | |||
74 | GEN_OPIVI_TRANS(vadc_vim, 0, vadc_vxm, opivx_vadc_check) | ||
75 | GEN_OPIVI_TRANS(vmadc_vim, 0, vmadc_vxm, opivx_vmadc_check) | ||
76 | + | ||
77 | +/* Vector Bitwise Logical Instructions */ | ||
78 | +GEN_OPIVV_GVEC_TRANS(vand_vv, and) | ||
79 | +GEN_OPIVV_GVEC_TRANS(vor_vv, or) | ||
80 | +GEN_OPIVV_GVEC_TRANS(vxor_vv, xor) | ||
81 | +GEN_OPIVX_GVEC_TRANS(vand_vx, ands) | ||
82 | +GEN_OPIVX_GVEC_TRANS(vor_vx, ors) | ||
83 | +GEN_OPIVX_GVEC_TRANS(vxor_vx, xors) | ||
84 | +GEN_OPIVI_GVEC_TRANS(vand_vi, 0, vand_vx, andi) | ||
85 | +GEN_OPIVI_GVEC_TRANS(vor_vi, 0, vor_vx, ori) | ||
86 | +GEN_OPIVI_GVEC_TRANS(vxor_vi, 0, vxor_vx, xori) | ||
87 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/riscv/vector_helper.c | ||
90 | +++ b/target/riscv/vector_helper.c | ||
91 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VMADC_VXM(vmsbc_vxm_b, uint8_t, H1, DO_MSBC) | ||
92 | GEN_VEXT_VMADC_VXM(vmsbc_vxm_h, uint16_t, H2, DO_MSBC) | ||
93 | GEN_VEXT_VMADC_VXM(vmsbc_vxm_w, uint32_t, H4, DO_MSBC) | ||
94 | GEN_VEXT_VMADC_VXM(vmsbc_vxm_d, uint64_t, H8, DO_MSBC) | ||
95 | + | ||
96 | +/* Vector Bitwise Logical Instructions */ | ||
97 | +RVVCALL(OPIVV2, vand_vv_b, OP_SSS_B, H1, H1, H1, DO_AND) | ||
98 | +RVVCALL(OPIVV2, vand_vv_h, OP_SSS_H, H2, H2, H2, DO_AND) | ||
99 | +RVVCALL(OPIVV2, vand_vv_w, OP_SSS_W, H4, H4, H4, DO_AND) | ||
100 | +RVVCALL(OPIVV2, vand_vv_d, OP_SSS_D, H8, H8, H8, DO_AND) | ||
101 | +RVVCALL(OPIVV2, vor_vv_b, OP_SSS_B, H1, H1, H1, DO_OR) | ||
102 | +RVVCALL(OPIVV2, vor_vv_h, OP_SSS_H, H2, H2, H2, DO_OR) | ||
103 | +RVVCALL(OPIVV2, vor_vv_w, OP_SSS_W, H4, H4, H4, DO_OR) | ||
104 | +RVVCALL(OPIVV2, vor_vv_d, OP_SSS_D, H8, H8, H8, DO_OR) | ||
105 | +RVVCALL(OPIVV2, vxor_vv_b, OP_SSS_B, H1, H1, H1, DO_XOR) | ||
106 | +RVVCALL(OPIVV2, vxor_vv_h, OP_SSS_H, H2, H2, H2, DO_XOR) | ||
107 | +RVVCALL(OPIVV2, vxor_vv_w, OP_SSS_W, H4, H4, H4, DO_XOR) | ||
108 | +RVVCALL(OPIVV2, vxor_vv_d, OP_SSS_D, H8, H8, H8, DO_XOR) | ||
109 | +GEN_VEXT_VV(vand_vv_b, 1, 1, clearb) | ||
110 | +GEN_VEXT_VV(vand_vv_h, 2, 2, clearh) | ||
111 | +GEN_VEXT_VV(vand_vv_w, 4, 4, clearl) | ||
112 | +GEN_VEXT_VV(vand_vv_d, 8, 8, clearq) | ||
113 | +GEN_VEXT_VV(vor_vv_b, 1, 1, clearb) | ||
114 | +GEN_VEXT_VV(vor_vv_h, 2, 2, clearh) | ||
115 | +GEN_VEXT_VV(vor_vv_w, 4, 4, clearl) | ||
116 | +GEN_VEXT_VV(vor_vv_d, 8, 8, clearq) | ||
117 | +GEN_VEXT_VV(vxor_vv_b, 1, 1, clearb) | ||
118 | +GEN_VEXT_VV(vxor_vv_h, 2, 2, clearh) | ||
119 | +GEN_VEXT_VV(vxor_vv_w, 4, 4, clearl) | ||
120 | +GEN_VEXT_VV(vxor_vv_d, 8, 8, clearq) | ||
121 | + | ||
122 | +RVVCALL(OPIVX2, vand_vx_b, OP_SSS_B, H1, H1, DO_AND) | ||
123 | +RVVCALL(OPIVX2, vand_vx_h, OP_SSS_H, H2, H2, DO_AND) | ||
124 | +RVVCALL(OPIVX2, vand_vx_w, OP_SSS_W, H4, H4, DO_AND) | ||
125 | +RVVCALL(OPIVX2, vand_vx_d, OP_SSS_D, H8, H8, DO_AND) | ||
126 | +RVVCALL(OPIVX2, vor_vx_b, OP_SSS_B, H1, H1, DO_OR) | ||
127 | +RVVCALL(OPIVX2, vor_vx_h, OP_SSS_H, H2, H2, DO_OR) | ||
128 | +RVVCALL(OPIVX2, vor_vx_w, OP_SSS_W, H4, H4, DO_OR) | ||
129 | +RVVCALL(OPIVX2, vor_vx_d, OP_SSS_D, H8, H8, DO_OR) | ||
130 | +RVVCALL(OPIVX2, vxor_vx_b, OP_SSS_B, H1, H1, DO_XOR) | ||
131 | +RVVCALL(OPIVX2, vxor_vx_h, OP_SSS_H, H2, H2, DO_XOR) | ||
132 | +RVVCALL(OPIVX2, vxor_vx_w, OP_SSS_W, H4, H4, DO_XOR) | ||
133 | +RVVCALL(OPIVX2, vxor_vx_d, OP_SSS_D, H8, H8, DO_XOR) | ||
134 | +GEN_VEXT_VX(vand_vx_b, 1, 1, clearb) | ||
135 | +GEN_VEXT_VX(vand_vx_h, 2, 2, clearh) | ||
136 | +GEN_VEXT_VX(vand_vx_w, 4, 4, clearl) | ||
137 | +GEN_VEXT_VX(vand_vx_d, 8, 8, clearq) | ||
138 | +GEN_VEXT_VX(vor_vx_b, 1, 1, clearb) | ||
139 | +GEN_VEXT_VX(vor_vx_h, 2, 2, clearh) | ||
140 | +GEN_VEXT_VX(vor_vx_w, 4, 4, clearl) | ||
141 | +GEN_VEXT_VX(vor_vx_d, 8, 8, clearq) | ||
142 | +GEN_VEXT_VX(vxor_vx_b, 1, 1, clearb) | ||
143 | +GEN_VEXT_VX(vxor_vx_h, 2, 2, clearh) | ||
144 | +GEN_VEXT_VX(vxor_vx_w, 4, 4, clearl) | ||
145 | +GEN_VEXT_VX(vxor_vx_d, 8, 8, clearq) | ||
146 | -- | ||
147 | 2.27.0 | ||
148 | |||
149 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-15-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 25 ++++++++ | ||
10 | target/riscv/insn32.decode | 9 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 52 ++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 79 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 165 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vxor_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vxor_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vxor_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vxor_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vsll_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vsll_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vsll_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vsll_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vsrl_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vsrl_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vsrl_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vsrl_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vsra_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vsra_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vsra_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vsra_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vsll_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vsll_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vsll_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vsll_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vsrl_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vsrl_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vsrl_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vsrl_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vsra_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vsra_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vsra_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vsra_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/riscv/insn32.decode | ||
51 | +++ b/target/riscv/insn32.decode | ||
52 | @@ -XXX,XX +XXX,XX @@ vor_vi 001010 . ..... ..... 011 ..... 1010111 @r_vm | ||
53 | vxor_vv 001011 . ..... ..... 000 ..... 1010111 @r_vm | ||
54 | vxor_vx 001011 . ..... ..... 100 ..... 1010111 @r_vm | ||
55 | vxor_vi 001011 . ..... ..... 011 ..... 1010111 @r_vm | ||
56 | +vsll_vv 100101 . ..... ..... 000 ..... 1010111 @r_vm | ||
57 | +vsll_vx 100101 . ..... ..... 100 ..... 1010111 @r_vm | ||
58 | +vsll_vi 100101 . ..... ..... 011 ..... 1010111 @r_vm | ||
59 | +vsrl_vv 101000 . ..... ..... 000 ..... 1010111 @r_vm | ||
60 | +vsrl_vx 101000 . ..... ..... 100 ..... 1010111 @r_vm | ||
61 | +vsrl_vi 101000 . ..... ..... 011 ..... 1010111 @r_vm | ||
62 | +vsra_vv 101001 . ..... ..... 000 ..... 1010111 @r_vm | ||
63 | +vsra_vx 101001 . ..... ..... 100 ..... 1010111 @r_vm | ||
64 | +vsra_vi 101001 . ..... ..... 011 ..... 1010111 @r_vm | ||
65 | |||
66 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
67 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
68 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
71 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_GVEC_TRANS(vxor_vx, xors) | ||
73 | GEN_OPIVI_GVEC_TRANS(vand_vi, 0, vand_vx, andi) | ||
74 | GEN_OPIVI_GVEC_TRANS(vor_vi, 0, vor_vx, ori) | ||
75 | GEN_OPIVI_GVEC_TRANS(vxor_vi, 0, vxor_vx, xori) | ||
76 | + | ||
77 | +/* Vector Single-Width Bit Shift Instructions */ | ||
78 | +GEN_OPIVV_GVEC_TRANS(vsll_vv, shlv) | ||
79 | +GEN_OPIVV_GVEC_TRANS(vsrl_vv, shrv) | ||
80 | +GEN_OPIVV_GVEC_TRANS(vsra_vv, sarv) | ||
81 | + | ||
82 | +typedef void GVecGen2sFn32(unsigned, uint32_t, uint32_t, TCGv_i32, | ||
83 | + uint32_t, uint32_t); | ||
84 | + | ||
85 | +static inline bool | ||
86 | +do_opivx_gvec_shift(DisasContext *s, arg_rmrr *a, GVecGen2sFn32 *gvec_fn, | ||
87 | + gen_helper_opivx *fn) | ||
88 | +{ | ||
89 | + if (!opivx_check(s, a)) { | ||
90 | + return false; | ||
91 | + } | ||
92 | + | ||
93 | + if (a->vm && s->vl_eq_vlmax) { | ||
94 | + TCGv_i32 src1 = tcg_temp_new_i32(); | ||
95 | + TCGv tmp = tcg_temp_new(); | ||
96 | + | ||
97 | + gen_get_gpr(tmp, a->rs1); | ||
98 | + tcg_gen_trunc_tl_i32(src1, tmp); | ||
99 | + tcg_gen_extract_i32(src1, src1, 0, s->sew + 3); | ||
100 | + gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), | ||
101 | + src1, MAXSZ(s), MAXSZ(s)); | ||
102 | + | ||
103 | + tcg_temp_free_i32(src1); | ||
104 | + tcg_temp_free(tmp); | ||
105 | + return true; | ||
106 | + } | ||
107 | + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s); | ||
108 | +} | ||
109 | + | ||
110 | +#define GEN_OPIVX_GVEC_SHIFT_TRANS(NAME, SUF) \ | ||
111 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
112 | +{ \ | ||
113 | + static gen_helper_opivx * const fns[4] = { \ | ||
114 | + gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ | ||
115 | + gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ | ||
116 | + }; \ | ||
117 | + \ | ||
118 | + return do_opivx_gvec_shift(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ | ||
119 | +} | ||
120 | + | ||
121 | +GEN_OPIVX_GVEC_SHIFT_TRANS(vsll_vx, shls) | ||
122 | +GEN_OPIVX_GVEC_SHIFT_TRANS(vsrl_vx, shrs) | ||
123 | +GEN_OPIVX_GVEC_SHIFT_TRANS(vsra_vx, sars) | ||
124 | + | ||
125 | +GEN_OPIVI_GVEC_TRANS(vsll_vi, 1, vsll_vx, shli) | ||
126 | +GEN_OPIVI_GVEC_TRANS(vsrl_vi, 1, vsrl_vx, shri) | ||
127 | +GEN_OPIVI_GVEC_TRANS(vsra_vi, 1, vsra_vx, sari) | ||
128 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/target/riscv/vector_helper.c | ||
131 | +++ b/target/riscv/vector_helper.c | ||
132 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vxor_vx_b, 1, 1, clearb) | ||
133 | GEN_VEXT_VX(vxor_vx_h, 2, 2, clearh) | ||
134 | GEN_VEXT_VX(vxor_vx_w, 4, 4, clearl) | ||
135 | GEN_VEXT_VX(vxor_vx_d, 8, 8, clearq) | ||
136 | + | ||
137 | +/* Vector Single-Width Bit Shift Instructions */ | ||
138 | +#define DO_SLL(N, M) (N << (M)) | ||
139 | +#define DO_SRL(N, M) (N >> (M)) | ||
140 | + | ||
141 | +/* generate the helpers for shift instructions with two vector operators */ | ||
142 | +#define GEN_VEXT_SHIFT_VV(NAME, TS1, TS2, HS1, HS2, OP, MASK, CLEAR_FN) \ | ||
143 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, \ | ||
144 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
145 | +{ \ | ||
146 | + uint32_t mlen = vext_mlen(desc); \ | ||
147 | + uint32_t vm = vext_vm(desc); \ | ||
148 | + uint32_t vl = env->vl; \ | ||
149 | + uint32_t esz = sizeof(TS1); \ | ||
150 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
151 | + uint32_t i; \ | ||
152 | + \ | ||
153 | + for (i = 0; i < vl; i++) { \ | ||
154 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
155 | + continue; \ | ||
156 | + } \ | ||
157 | + TS1 s1 = *((TS1 *)vs1 + HS1(i)); \ | ||
158 | + TS2 s2 = *((TS2 *)vs2 + HS2(i)); \ | ||
159 | + *((TS1 *)vd + HS1(i)) = OP(s2, s1 & MASK); \ | ||
160 | + } \ | ||
161 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
162 | +} | ||
163 | + | ||
164 | +GEN_VEXT_SHIFT_VV(vsll_vv_b, uint8_t, uint8_t, H1, H1, DO_SLL, 0x7, clearb) | ||
165 | +GEN_VEXT_SHIFT_VV(vsll_vv_h, uint16_t, uint16_t, H2, H2, DO_SLL, 0xf, clearh) | ||
166 | +GEN_VEXT_SHIFT_VV(vsll_vv_w, uint32_t, uint32_t, H4, H4, DO_SLL, 0x1f, clearl) | ||
167 | +GEN_VEXT_SHIFT_VV(vsll_vv_d, uint64_t, uint64_t, H8, H8, DO_SLL, 0x3f, clearq) | ||
168 | + | ||
169 | +GEN_VEXT_SHIFT_VV(vsrl_vv_b, uint8_t, uint8_t, H1, H1, DO_SRL, 0x7, clearb) | ||
170 | +GEN_VEXT_SHIFT_VV(vsrl_vv_h, uint16_t, uint16_t, H2, H2, DO_SRL, 0xf, clearh) | ||
171 | +GEN_VEXT_SHIFT_VV(vsrl_vv_w, uint32_t, uint32_t, H4, H4, DO_SRL, 0x1f, clearl) | ||
172 | +GEN_VEXT_SHIFT_VV(vsrl_vv_d, uint64_t, uint64_t, H8, H8, DO_SRL, 0x3f, clearq) | ||
173 | + | ||
174 | +GEN_VEXT_SHIFT_VV(vsra_vv_b, uint8_t, int8_t, H1, H1, DO_SRL, 0x7, clearb) | ||
175 | +GEN_VEXT_SHIFT_VV(vsra_vv_h, uint16_t, int16_t, H2, H2, DO_SRL, 0xf, clearh) | ||
176 | +GEN_VEXT_SHIFT_VV(vsra_vv_w, uint32_t, int32_t, H4, H4, DO_SRL, 0x1f, clearl) | ||
177 | +GEN_VEXT_SHIFT_VV(vsra_vv_d, uint64_t, int64_t, H8, H8, DO_SRL, 0x3f, clearq) | ||
178 | + | ||
179 | +/* generate the helpers for shift instructions with one vector and one scalar */ | ||
180 | +#define GEN_VEXT_SHIFT_VX(NAME, TD, TS2, HD, HS2, OP, MASK, CLEAR_FN) \ | ||
181 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ | ||
182 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
183 | +{ \ | ||
184 | + uint32_t mlen = vext_mlen(desc); \ | ||
185 | + uint32_t vm = vext_vm(desc); \ | ||
186 | + uint32_t vl = env->vl; \ | ||
187 | + uint32_t esz = sizeof(TD); \ | ||
188 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
189 | + uint32_t i; \ | ||
190 | + \ | ||
191 | + for (i = 0; i < vl; i++) { \ | ||
192 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
193 | + continue; \ | ||
194 | + } \ | ||
195 | + TS2 s2 = *((TS2 *)vs2 + HS2(i)); \ | ||
196 | + *((TD *)vd + HD(i)) = OP(s2, s1 & MASK); \ | ||
197 | + } \ | ||
198 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
199 | +} | ||
200 | + | ||
201 | +GEN_VEXT_SHIFT_VX(vsll_vx_b, uint8_t, int8_t, H1, H1, DO_SLL, 0x7, clearb) | ||
202 | +GEN_VEXT_SHIFT_VX(vsll_vx_h, uint16_t, int16_t, H2, H2, DO_SLL, 0xf, clearh) | ||
203 | +GEN_VEXT_SHIFT_VX(vsll_vx_w, uint32_t, int32_t, H4, H4, DO_SLL, 0x1f, clearl) | ||
204 | +GEN_VEXT_SHIFT_VX(vsll_vx_d, uint64_t, int64_t, H8, H8, DO_SLL, 0x3f, clearq) | ||
205 | + | ||
206 | +GEN_VEXT_SHIFT_VX(vsrl_vx_b, uint8_t, uint8_t, H1, H1, DO_SRL, 0x7, clearb) | ||
207 | +GEN_VEXT_SHIFT_VX(vsrl_vx_h, uint16_t, uint16_t, H2, H2, DO_SRL, 0xf, clearh) | ||
208 | +GEN_VEXT_SHIFT_VX(vsrl_vx_w, uint32_t, uint32_t, H4, H4, DO_SRL, 0x1f, clearl) | ||
209 | +GEN_VEXT_SHIFT_VX(vsrl_vx_d, uint64_t, uint64_t, H8, H8, DO_SRL, 0x3f, clearq) | ||
210 | + | ||
211 | +GEN_VEXT_SHIFT_VX(vsra_vx_b, int8_t, int8_t, H1, H1, DO_SRL, 0x7, clearb) | ||
212 | +GEN_VEXT_SHIFT_VX(vsra_vx_h, int16_t, int16_t, H2, H2, DO_SRL, 0xf, clearh) | ||
213 | +GEN_VEXT_SHIFT_VX(vsra_vx_w, int32_t, int32_t, H4, H4, DO_SRL, 0x1f, clearl) | ||
214 | +GEN_VEXT_SHIFT_VX(vsra_vx_d, int64_t, int64_t, H8, H8, DO_SRL, 0x3f, clearq) | ||
215 | -- | ||
216 | 2.27.0 | ||
217 | |||
218 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-16-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 13 ++++ | ||
10 | target/riscv/insn32.decode | 6 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 90 +++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 14 ++++ | ||
13 | 4 files changed, 123 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vsra_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vsra_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vsra_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vsra_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vnsrl_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vnsrl_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vnsrl_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vnsra_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vnsra_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vnsra_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vnsrl_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vnsrl_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vnsrl_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vnsra_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vnsra_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vnsra_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/riscv/insn32.decode | ||
39 | +++ b/target/riscv/insn32.decode | ||
40 | @@ -XXX,XX +XXX,XX @@ vsrl_vi 101000 . ..... ..... 011 ..... 1010111 @r_vm | ||
41 | vsra_vv 101001 . ..... ..... 000 ..... 1010111 @r_vm | ||
42 | vsra_vx 101001 . ..... ..... 100 ..... 1010111 @r_vm | ||
43 | vsra_vi 101001 . ..... ..... 011 ..... 1010111 @r_vm | ||
44 | +vnsrl_vv 101100 . ..... ..... 000 ..... 1010111 @r_vm | ||
45 | +vnsrl_vx 101100 . ..... ..... 100 ..... 1010111 @r_vm | ||
46 | +vnsrl_vi 101100 . ..... ..... 011 ..... 1010111 @r_vm | ||
47 | +vnsra_vv 101101 . ..... ..... 000 ..... 1010111 @r_vm | ||
48 | +vnsra_vx 101101 . ..... ..... 100 ..... 1010111 @r_vm | ||
49 | +vnsra_vi 101101 . ..... ..... 011 ..... 1010111 @r_vm | ||
50 | |||
51 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
52 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
53 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
56 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
57 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_GVEC_SHIFT_TRANS(vsra_vx, sars) | ||
58 | GEN_OPIVI_GVEC_TRANS(vsll_vi, 1, vsll_vx, shli) | ||
59 | GEN_OPIVI_GVEC_TRANS(vsrl_vi, 1, vsrl_vx, shri) | ||
60 | GEN_OPIVI_GVEC_TRANS(vsra_vi, 1, vsra_vx, sari) | ||
61 | + | ||
62 | +/* Vector Narrowing Integer Right Shift Instructions */ | ||
63 | +static bool opivv_narrow_check(DisasContext *s, arg_rmrr *a) | ||
64 | +{ | ||
65 | + return (vext_check_isa_ill(s) && | ||
66 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
67 | + vext_check_reg(s, a->rd, false) && | ||
68 | + vext_check_reg(s, a->rs2, true) && | ||
69 | + vext_check_reg(s, a->rs1, false) && | ||
70 | + vext_check_overlap_group(a->rd, 1 << s->lmul, a->rs2, | ||
71 | + 2 << s->lmul) && | ||
72 | + (s->lmul < 0x3) && (s->sew < 0x3)); | ||
73 | +} | ||
74 | + | ||
75 | +/* OPIVV with NARROW */ | ||
76 | +#define GEN_OPIVV_NARROW_TRANS(NAME) \ | ||
77 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
78 | +{ \ | ||
79 | + if (opivv_narrow_check(s, a)) { \ | ||
80 | + uint32_t data = 0; \ | ||
81 | + static gen_helper_gvec_4_ptr * const fns[3] = { \ | ||
82 | + gen_helper_##NAME##_b, \ | ||
83 | + gen_helper_##NAME##_h, \ | ||
84 | + gen_helper_##NAME##_w, \ | ||
85 | + }; \ | ||
86 | + TCGLabel *over = gen_new_label(); \ | ||
87 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
88 | + \ | ||
89 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
90 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
91 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
92 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
93 | + vreg_ofs(s, a->rs1), \ | ||
94 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
95 | + s->vlen / 8, data, fns[s->sew]); \ | ||
96 | + gen_set_label(over); \ | ||
97 | + return true; \ | ||
98 | + } \ | ||
99 | + return false; \ | ||
100 | +} | ||
101 | +GEN_OPIVV_NARROW_TRANS(vnsra_vv) | ||
102 | +GEN_OPIVV_NARROW_TRANS(vnsrl_vv) | ||
103 | + | ||
104 | +static bool opivx_narrow_check(DisasContext *s, arg_rmrr *a) | ||
105 | +{ | ||
106 | + return (vext_check_isa_ill(s) && | ||
107 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
108 | + vext_check_reg(s, a->rd, false) && | ||
109 | + vext_check_reg(s, a->rs2, true) && | ||
110 | + vext_check_overlap_group(a->rd, 1 << s->lmul, a->rs2, | ||
111 | + 2 << s->lmul) && | ||
112 | + (s->lmul < 0x3) && (s->sew < 0x3)); | ||
113 | +} | ||
114 | + | ||
115 | +/* OPIVX with NARROW */ | ||
116 | +#define GEN_OPIVX_NARROW_TRANS(NAME) \ | ||
117 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
118 | +{ \ | ||
119 | + if (opivx_narrow_check(s, a)) { \ | ||
120 | + static gen_helper_opivx * const fns[3] = { \ | ||
121 | + gen_helper_##NAME##_b, \ | ||
122 | + gen_helper_##NAME##_h, \ | ||
123 | + gen_helper_##NAME##_w, \ | ||
124 | + }; \ | ||
125 | + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s);\ | ||
126 | + } \ | ||
127 | + return false; \ | ||
128 | +} | ||
129 | + | ||
130 | +GEN_OPIVX_NARROW_TRANS(vnsra_vx) | ||
131 | +GEN_OPIVX_NARROW_TRANS(vnsrl_vx) | ||
132 | + | ||
133 | +/* OPIVI with NARROW */ | ||
134 | +#define GEN_OPIVI_NARROW_TRANS(NAME, ZX, OPIVX) \ | ||
135 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
136 | +{ \ | ||
137 | + if (opivx_narrow_check(s, a)) { \ | ||
138 | + static gen_helper_opivx * const fns[3] = { \ | ||
139 | + gen_helper_##OPIVX##_b, \ | ||
140 | + gen_helper_##OPIVX##_h, \ | ||
141 | + gen_helper_##OPIVX##_w, \ | ||
142 | + }; \ | ||
143 | + return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, \ | ||
144 | + fns[s->sew], s, ZX); \ | ||
145 | + } \ | ||
146 | + return false; \ | ||
147 | +} | ||
148 | + | ||
149 | +GEN_OPIVI_NARROW_TRANS(vnsra_vi, 1, vnsra_vx) | ||
150 | +GEN_OPIVI_NARROW_TRANS(vnsrl_vi, 1, vnsrl_vx) | ||
151 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/target/riscv/vector_helper.c | ||
154 | +++ b/target/riscv/vector_helper.c | ||
155 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_SHIFT_VX(vsra_vx_b, int8_t, int8_t, H1, H1, DO_SRL, 0x7, clearb) | ||
156 | GEN_VEXT_SHIFT_VX(vsra_vx_h, int16_t, int16_t, H2, H2, DO_SRL, 0xf, clearh) | ||
157 | GEN_VEXT_SHIFT_VX(vsra_vx_w, int32_t, int32_t, H4, H4, DO_SRL, 0x1f, clearl) | ||
158 | GEN_VEXT_SHIFT_VX(vsra_vx_d, int64_t, int64_t, H8, H8, DO_SRL, 0x3f, clearq) | ||
159 | + | ||
160 | +/* Vector Narrowing Integer Right Shift Instructions */ | ||
161 | +GEN_VEXT_SHIFT_VV(vnsrl_vv_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf, clearb) | ||
162 | +GEN_VEXT_SHIFT_VV(vnsrl_vv_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f, clearh) | ||
163 | +GEN_VEXT_SHIFT_VV(vnsrl_vv_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f, clearl) | ||
164 | +GEN_VEXT_SHIFT_VV(vnsra_vv_b, uint8_t, int16_t, H1, H2, DO_SRL, 0xf, clearb) | ||
165 | +GEN_VEXT_SHIFT_VV(vnsra_vv_h, uint16_t, int32_t, H2, H4, DO_SRL, 0x1f, clearh) | ||
166 | +GEN_VEXT_SHIFT_VV(vnsra_vv_w, uint32_t, int64_t, H4, H8, DO_SRL, 0x3f, clearl) | ||
167 | +GEN_VEXT_SHIFT_VX(vnsrl_vx_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf, clearb) | ||
168 | +GEN_VEXT_SHIFT_VX(vnsrl_vx_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f, clearh) | ||
169 | +GEN_VEXT_SHIFT_VX(vnsrl_vx_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f, clearl) | ||
170 | +GEN_VEXT_SHIFT_VX(vnsra_vx_b, int8_t, int16_t, H1, H2, DO_SRL, 0xf, clearb) | ||
171 | +GEN_VEXT_SHIFT_VX(vnsra_vx_h, int16_t, int32_t, H2, H4, DO_SRL, 0x1f, clearh) | ||
172 | +GEN_VEXT_SHIFT_VX(vnsra_vx_w, int32_t, int64_t, H4, H8, DO_SRL, 0x3f, clearl) | ||
173 | -- | ||
174 | 2.27.0 | ||
175 | |||
176 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-17-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 57 +++++++++++ | ||
10 | target/riscv/insn32.decode | 20 ++++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 46 +++++++++ | ||
12 | target/riscv/vector_helper.c | 123 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 246 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vnsrl_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vnsra_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vnsra_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vnsra_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vmseq_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vmseq_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vmseq_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vmseq_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vmsne_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vmsne_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vmsne_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vmsne_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vmsltu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vmsltu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vmsltu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vmsltu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vmslt_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vmslt_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vmslt_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vmslt_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vmsleu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vmsleu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vmsleu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vmsleu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vmsle_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vmsle_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vmsle_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vmsle_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vmseq_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vmseq_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vmseq_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vmseq_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vmsne_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vmsne_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vmsne_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vmsne_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | +DEF_HELPER_6(vmsltu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
57 | +DEF_HELPER_6(vmsltu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
58 | +DEF_HELPER_6(vmsltu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
59 | +DEF_HELPER_6(vmsltu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
60 | +DEF_HELPER_6(vmslt_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
61 | +DEF_HELPER_6(vmslt_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
62 | +DEF_HELPER_6(vmslt_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
63 | +DEF_HELPER_6(vmslt_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
64 | +DEF_HELPER_6(vmsleu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
65 | +DEF_HELPER_6(vmsleu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
66 | +DEF_HELPER_6(vmsleu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
67 | +DEF_HELPER_6(vmsleu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
68 | +DEF_HELPER_6(vmsle_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
69 | +DEF_HELPER_6(vmsle_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
70 | +DEF_HELPER_6(vmsle_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
71 | +DEF_HELPER_6(vmsle_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
72 | +DEF_HELPER_6(vmsgtu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
73 | +DEF_HELPER_6(vmsgtu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
74 | +DEF_HELPER_6(vmsgtu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
75 | +DEF_HELPER_6(vmsgtu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
76 | +DEF_HELPER_6(vmsgt_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
77 | +DEF_HELPER_6(vmsgt_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
78 | +DEF_HELPER_6(vmsgt_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
79 | +DEF_HELPER_6(vmsgt_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
80 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/riscv/insn32.decode | ||
83 | +++ b/target/riscv/insn32.decode | ||
84 | @@ -XXX,XX +XXX,XX @@ vnsrl_vi 101100 . ..... ..... 011 ..... 1010111 @r_vm | ||
85 | vnsra_vv 101101 . ..... ..... 000 ..... 1010111 @r_vm | ||
86 | vnsra_vx 101101 . ..... ..... 100 ..... 1010111 @r_vm | ||
87 | vnsra_vi 101101 . ..... ..... 011 ..... 1010111 @r_vm | ||
88 | +vmseq_vv 011000 . ..... ..... 000 ..... 1010111 @r_vm | ||
89 | +vmseq_vx 011000 . ..... ..... 100 ..... 1010111 @r_vm | ||
90 | +vmseq_vi 011000 . ..... ..... 011 ..... 1010111 @r_vm | ||
91 | +vmsne_vv 011001 . ..... ..... 000 ..... 1010111 @r_vm | ||
92 | +vmsne_vx 011001 . ..... ..... 100 ..... 1010111 @r_vm | ||
93 | +vmsne_vi 011001 . ..... ..... 011 ..... 1010111 @r_vm | ||
94 | +vmsltu_vv 011010 . ..... ..... 000 ..... 1010111 @r_vm | ||
95 | +vmsltu_vx 011010 . ..... ..... 100 ..... 1010111 @r_vm | ||
96 | +vmslt_vv 011011 . ..... ..... 000 ..... 1010111 @r_vm | ||
97 | +vmslt_vx 011011 . ..... ..... 100 ..... 1010111 @r_vm | ||
98 | +vmsleu_vv 011100 . ..... ..... 000 ..... 1010111 @r_vm | ||
99 | +vmsleu_vx 011100 . ..... ..... 100 ..... 1010111 @r_vm | ||
100 | +vmsleu_vi 011100 . ..... ..... 011 ..... 1010111 @r_vm | ||
101 | +vmsle_vv 011101 . ..... ..... 000 ..... 1010111 @r_vm | ||
102 | +vmsle_vx 011101 . ..... ..... 100 ..... 1010111 @r_vm | ||
103 | +vmsle_vi 011101 . ..... ..... 011 ..... 1010111 @r_vm | ||
104 | +vmsgtu_vx 011110 . ..... ..... 100 ..... 1010111 @r_vm | ||
105 | +vmsgtu_vi 011110 . ..... ..... 011 ..... 1010111 @r_vm | ||
106 | +vmsgt_vx 011111 . ..... ..... 100 ..... 1010111 @r_vm | ||
107 | +vmsgt_vi 011111 . ..... ..... 011 ..... 1010111 @r_vm | ||
108 | |||
109 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
110 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
111 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
114 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
116 | |||
117 | GEN_OPIVI_NARROW_TRANS(vnsra_vi, 1, vnsra_vx) | ||
118 | GEN_OPIVI_NARROW_TRANS(vnsrl_vi, 1, vnsrl_vx) | ||
119 | + | ||
120 | +/* Vector Integer Comparison Instructions */ | ||
121 | +/* | ||
122 | + * For all comparison instructions, an illegal instruction exception is raised | ||
123 | + * if the destination vector register overlaps a source vector register group | ||
124 | + * and LMUL > 1. | ||
125 | + */ | ||
126 | +static bool opivv_cmp_check(DisasContext *s, arg_rmrr *a) | ||
127 | +{ | ||
128 | + return (vext_check_isa_ill(s) && | ||
129 | + vext_check_reg(s, a->rs2, false) && | ||
130 | + vext_check_reg(s, a->rs1, false) && | ||
131 | + ((vext_check_overlap_group(a->rd, 1, a->rs1, 1 << s->lmul) && | ||
132 | + vext_check_overlap_group(a->rd, 1, a->rs2, 1 << s->lmul)) || | ||
133 | + (s->lmul == 0))); | ||
134 | +} | ||
135 | +GEN_OPIVV_TRANS(vmseq_vv, opivv_cmp_check) | ||
136 | +GEN_OPIVV_TRANS(vmsne_vv, opivv_cmp_check) | ||
137 | +GEN_OPIVV_TRANS(vmsltu_vv, opivv_cmp_check) | ||
138 | +GEN_OPIVV_TRANS(vmslt_vv, opivv_cmp_check) | ||
139 | +GEN_OPIVV_TRANS(vmsleu_vv, opivv_cmp_check) | ||
140 | +GEN_OPIVV_TRANS(vmsle_vv, opivv_cmp_check) | ||
141 | + | ||
142 | +static bool opivx_cmp_check(DisasContext *s, arg_rmrr *a) | ||
143 | +{ | ||
144 | + return (vext_check_isa_ill(s) && | ||
145 | + vext_check_reg(s, a->rs2, false) && | ||
146 | + (vext_check_overlap_group(a->rd, 1, a->rs2, 1 << s->lmul) || | ||
147 | + (s->lmul == 0))); | ||
148 | +} | ||
149 | + | ||
150 | +GEN_OPIVX_TRANS(vmseq_vx, opivx_cmp_check) | ||
151 | +GEN_OPIVX_TRANS(vmsne_vx, opivx_cmp_check) | ||
152 | +GEN_OPIVX_TRANS(vmsltu_vx, opivx_cmp_check) | ||
153 | +GEN_OPIVX_TRANS(vmslt_vx, opivx_cmp_check) | ||
154 | +GEN_OPIVX_TRANS(vmsleu_vx, opivx_cmp_check) | ||
155 | +GEN_OPIVX_TRANS(vmsle_vx, opivx_cmp_check) | ||
156 | +GEN_OPIVX_TRANS(vmsgtu_vx, opivx_cmp_check) | ||
157 | +GEN_OPIVX_TRANS(vmsgt_vx, opivx_cmp_check) | ||
158 | + | ||
159 | +GEN_OPIVI_TRANS(vmseq_vi, 0, vmseq_vx, opivx_cmp_check) | ||
160 | +GEN_OPIVI_TRANS(vmsne_vi, 0, vmsne_vx, opivx_cmp_check) | ||
161 | +GEN_OPIVI_TRANS(vmsleu_vi, 1, vmsleu_vx, opivx_cmp_check) | ||
162 | +GEN_OPIVI_TRANS(vmsle_vi, 0, vmsle_vx, opivx_cmp_check) | ||
163 | +GEN_OPIVI_TRANS(vmsgtu_vi, 1, vmsgtu_vx, opivx_cmp_check) | ||
164 | +GEN_OPIVI_TRANS(vmsgt_vi, 0, vmsgt_vx, opivx_cmp_check) | ||
165 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
166 | index XXXXXXX..XXXXXXX 100644 | ||
167 | --- a/target/riscv/vector_helper.c | ||
168 | +++ b/target/riscv/vector_helper.c | ||
169 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_SHIFT_VX(vnsrl_vx_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f, clearl) | ||
170 | GEN_VEXT_SHIFT_VX(vnsra_vx_b, int8_t, int16_t, H1, H2, DO_SRL, 0xf, clearb) | ||
171 | GEN_VEXT_SHIFT_VX(vnsra_vx_h, int16_t, int32_t, H2, H4, DO_SRL, 0x1f, clearh) | ||
172 | GEN_VEXT_SHIFT_VX(vnsra_vx_w, int32_t, int64_t, H4, H8, DO_SRL, 0x3f, clearl) | ||
173 | + | ||
174 | +/* Vector Integer Comparison Instructions */ | ||
175 | +#define DO_MSEQ(N, M) (N == M) | ||
176 | +#define DO_MSNE(N, M) (N != M) | ||
177 | +#define DO_MSLT(N, M) (N < M) | ||
178 | +#define DO_MSLE(N, M) (N <= M) | ||
179 | +#define DO_MSGT(N, M) (N > M) | ||
180 | + | ||
181 | +#define GEN_VEXT_CMP_VV(NAME, ETYPE, H, DO_OP) \ | ||
182 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
183 | + CPURISCVState *env, uint32_t desc) \ | ||
184 | +{ \ | ||
185 | + uint32_t mlen = vext_mlen(desc); \ | ||
186 | + uint32_t vm = vext_vm(desc); \ | ||
187 | + uint32_t vl = env->vl; \ | ||
188 | + uint32_t vlmax = vext_maxsz(desc) / sizeof(ETYPE); \ | ||
189 | + uint32_t i; \ | ||
190 | + \ | ||
191 | + for (i = 0; i < vl; i++) { \ | ||
192 | + ETYPE s1 = *((ETYPE *)vs1 + H(i)); \ | ||
193 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
194 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
195 | + continue; \ | ||
196 | + } \ | ||
197 | + vext_set_elem_mask(vd, mlen, i, DO_OP(s2, s1)); \ | ||
198 | + } \ | ||
199 | + for (; i < vlmax; i++) { \ | ||
200 | + vext_set_elem_mask(vd, mlen, i, 0); \ | ||
201 | + } \ | ||
202 | +} | ||
203 | + | ||
204 | +GEN_VEXT_CMP_VV(vmseq_vv_b, uint8_t, H1, DO_MSEQ) | ||
205 | +GEN_VEXT_CMP_VV(vmseq_vv_h, uint16_t, H2, DO_MSEQ) | ||
206 | +GEN_VEXT_CMP_VV(vmseq_vv_w, uint32_t, H4, DO_MSEQ) | ||
207 | +GEN_VEXT_CMP_VV(vmseq_vv_d, uint64_t, H8, DO_MSEQ) | ||
208 | + | ||
209 | +GEN_VEXT_CMP_VV(vmsne_vv_b, uint8_t, H1, DO_MSNE) | ||
210 | +GEN_VEXT_CMP_VV(vmsne_vv_h, uint16_t, H2, DO_MSNE) | ||
211 | +GEN_VEXT_CMP_VV(vmsne_vv_w, uint32_t, H4, DO_MSNE) | ||
212 | +GEN_VEXT_CMP_VV(vmsne_vv_d, uint64_t, H8, DO_MSNE) | ||
213 | + | ||
214 | +GEN_VEXT_CMP_VV(vmsltu_vv_b, uint8_t, H1, DO_MSLT) | ||
215 | +GEN_VEXT_CMP_VV(vmsltu_vv_h, uint16_t, H2, DO_MSLT) | ||
216 | +GEN_VEXT_CMP_VV(vmsltu_vv_w, uint32_t, H4, DO_MSLT) | ||
217 | +GEN_VEXT_CMP_VV(vmsltu_vv_d, uint64_t, H8, DO_MSLT) | ||
218 | + | ||
219 | +GEN_VEXT_CMP_VV(vmslt_vv_b, int8_t, H1, DO_MSLT) | ||
220 | +GEN_VEXT_CMP_VV(vmslt_vv_h, int16_t, H2, DO_MSLT) | ||
221 | +GEN_VEXT_CMP_VV(vmslt_vv_w, int32_t, H4, DO_MSLT) | ||
222 | +GEN_VEXT_CMP_VV(vmslt_vv_d, int64_t, H8, DO_MSLT) | ||
223 | + | ||
224 | +GEN_VEXT_CMP_VV(vmsleu_vv_b, uint8_t, H1, DO_MSLE) | ||
225 | +GEN_VEXT_CMP_VV(vmsleu_vv_h, uint16_t, H2, DO_MSLE) | ||
226 | +GEN_VEXT_CMP_VV(vmsleu_vv_w, uint32_t, H4, DO_MSLE) | ||
227 | +GEN_VEXT_CMP_VV(vmsleu_vv_d, uint64_t, H8, DO_MSLE) | ||
228 | + | ||
229 | +GEN_VEXT_CMP_VV(vmsle_vv_b, int8_t, H1, DO_MSLE) | ||
230 | +GEN_VEXT_CMP_VV(vmsle_vv_h, int16_t, H2, DO_MSLE) | ||
231 | +GEN_VEXT_CMP_VV(vmsle_vv_w, int32_t, H4, DO_MSLE) | ||
232 | +GEN_VEXT_CMP_VV(vmsle_vv_d, int64_t, H8, DO_MSLE) | ||
233 | + | ||
234 | +#define GEN_VEXT_CMP_VX(NAME, ETYPE, H, DO_OP) \ | ||
235 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
236 | + CPURISCVState *env, uint32_t desc) \ | ||
237 | +{ \ | ||
238 | + uint32_t mlen = vext_mlen(desc); \ | ||
239 | + uint32_t vm = vext_vm(desc); \ | ||
240 | + uint32_t vl = env->vl; \ | ||
241 | + uint32_t vlmax = vext_maxsz(desc) / sizeof(ETYPE); \ | ||
242 | + uint32_t i; \ | ||
243 | + \ | ||
244 | + for (i = 0; i < vl; i++) { \ | ||
245 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
246 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
247 | + continue; \ | ||
248 | + } \ | ||
249 | + vext_set_elem_mask(vd, mlen, i, \ | ||
250 | + DO_OP(s2, (ETYPE)(target_long)s1)); \ | ||
251 | + } \ | ||
252 | + for (; i < vlmax; i++) { \ | ||
253 | + vext_set_elem_mask(vd, mlen, i, 0); \ | ||
254 | + } \ | ||
255 | +} | ||
256 | + | ||
257 | +GEN_VEXT_CMP_VX(vmseq_vx_b, uint8_t, H1, DO_MSEQ) | ||
258 | +GEN_VEXT_CMP_VX(vmseq_vx_h, uint16_t, H2, DO_MSEQ) | ||
259 | +GEN_VEXT_CMP_VX(vmseq_vx_w, uint32_t, H4, DO_MSEQ) | ||
260 | +GEN_VEXT_CMP_VX(vmseq_vx_d, uint64_t, H8, DO_MSEQ) | ||
261 | + | ||
262 | +GEN_VEXT_CMP_VX(vmsne_vx_b, uint8_t, H1, DO_MSNE) | ||
263 | +GEN_VEXT_CMP_VX(vmsne_vx_h, uint16_t, H2, DO_MSNE) | ||
264 | +GEN_VEXT_CMP_VX(vmsne_vx_w, uint32_t, H4, DO_MSNE) | ||
265 | +GEN_VEXT_CMP_VX(vmsne_vx_d, uint64_t, H8, DO_MSNE) | ||
266 | + | ||
267 | +GEN_VEXT_CMP_VX(vmsltu_vx_b, uint8_t, H1, DO_MSLT) | ||
268 | +GEN_VEXT_CMP_VX(vmsltu_vx_h, uint16_t, H2, DO_MSLT) | ||
269 | +GEN_VEXT_CMP_VX(vmsltu_vx_w, uint32_t, H4, DO_MSLT) | ||
270 | +GEN_VEXT_CMP_VX(vmsltu_vx_d, uint64_t, H8, DO_MSLT) | ||
271 | + | ||
272 | +GEN_VEXT_CMP_VX(vmslt_vx_b, int8_t, H1, DO_MSLT) | ||
273 | +GEN_VEXT_CMP_VX(vmslt_vx_h, int16_t, H2, DO_MSLT) | ||
274 | +GEN_VEXT_CMP_VX(vmslt_vx_w, int32_t, H4, DO_MSLT) | ||
275 | +GEN_VEXT_CMP_VX(vmslt_vx_d, int64_t, H8, DO_MSLT) | ||
276 | + | ||
277 | +GEN_VEXT_CMP_VX(vmsleu_vx_b, uint8_t, H1, DO_MSLE) | ||
278 | +GEN_VEXT_CMP_VX(vmsleu_vx_h, uint16_t, H2, DO_MSLE) | ||
279 | +GEN_VEXT_CMP_VX(vmsleu_vx_w, uint32_t, H4, DO_MSLE) | ||
280 | +GEN_VEXT_CMP_VX(vmsleu_vx_d, uint64_t, H8, DO_MSLE) | ||
281 | + | ||
282 | +GEN_VEXT_CMP_VX(vmsle_vx_b, int8_t, H1, DO_MSLE) | ||
283 | +GEN_VEXT_CMP_VX(vmsle_vx_h, int16_t, H2, DO_MSLE) | ||
284 | +GEN_VEXT_CMP_VX(vmsle_vx_w, int32_t, H4, DO_MSLE) | ||
285 | +GEN_VEXT_CMP_VX(vmsle_vx_d, int64_t, H8, DO_MSLE) | ||
286 | + | ||
287 | +GEN_VEXT_CMP_VX(vmsgtu_vx_b, uint8_t, H1, DO_MSGT) | ||
288 | +GEN_VEXT_CMP_VX(vmsgtu_vx_h, uint16_t, H2, DO_MSGT) | ||
289 | +GEN_VEXT_CMP_VX(vmsgtu_vx_w, uint32_t, H4, DO_MSGT) | ||
290 | +GEN_VEXT_CMP_VX(vmsgtu_vx_d, uint64_t, H8, DO_MSGT) | ||
291 | + | ||
292 | +GEN_VEXT_CMP_VX(vmsgt_vx_b, int8_t, H1, DO_MSGT) | ||
293 | +GEN_VEXT_CMP_VX(vmsgt_vx_h, int16_t, H2, DO_MSGT) | ||
294 | +GEN_VEXT_CMP_VX(vmsgt_vx_w, int32_t, H4, DO_MSGT) | ||
295 | +GEN_VEXT_CMP_VX(vmsgt_vx_d, int64_t, H8, DO_MSGT) | ||
296 | -- | ||
297 | 2.27.0 | ||
298 | |||
299 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-18-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 33 ++++++++++++ | ||
10 | target/riscv/insn32.decode | 8 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 10 ++++ | ||
12 | target/riscv/vector_helper.c | 71 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 122 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmsgt_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vmsgt_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vmsgt_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vmsgt_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vminu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vminu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vminu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vminu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vmin_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vmin_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vmin_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vmin_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vmaxu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vmaxu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vmaxu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vmaxu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vmax_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vmax_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vmax_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vmax_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vminu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vminu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vminu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vminu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vmin_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vmin_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vmin_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vmin_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vmaxu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vmaxu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vmaxu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vmaxu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vmax_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vmax_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vmax_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vmax_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/riscv/insn32.decode | ||
59 | +++ b/target/riscv/insn32.decode | ||
60 | @@ -XXX,XX +XXX,XX @@ vmsgtu_vx 011110 . ..... ..... 100 ..... 1010111 @r_vm | ||
61 | vmsgtu_vi 011110 . ..... ..... 011 ..... 1010111 @r_vm | ||
62 | vmsgt_vx 011111 . ..... ..... 100 ..... 1010111 @r_vm | ||
63 | vmsgt_vi 011111 . ..... ..... 011 ..... 1010111 @r_vm | ||
64 | +vminu_vv 000100 . ..... ..... 000 ..... 1010111 @r_vm | ||
65 | +vminu_vx 000100 . ..... ..... 100 ..... 1010111 @r_vm | ||
66 | +vmin_vv 000101 . ..... ..... 000 ..... 1010111 @r_vm | ||
67 | +vmin_vx 000101 . ..... ..... 100 ..... 1010111 @r_vm | ||
68 | +vmaxu_vv 000110 . ..... ..... 000 ..... 1010111 @r_vm | ||
69 | +vmaxu_vx 000110 . ..... ..... 100 ..... 1010111 @r_vm | ||
70 | +vmax_vv 000111 . ..... ..... 000 ..... 1010111 @r_vm | ||
71 | +vmax_vx 000111 . ..... ..... 100 ..... 1010111 @r_vm | ||
72 | |||
73 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
74 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
75 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
78 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
79 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVI_TRANS(vmsleu_vi, 1, vmsleu_vx, opivx_cmp_check) | ||
80 | GEN_OPIVI_TRANS(vmsle_vi, 0, vmsle_vx, opivx_cmp_check) | ||
81 | GEN_OPIVI_TRANS(vmsgtu_vi, 1, vmsgtu_vx, opivx_cmp_check) | ||
82 | GEN_OPIVI_TRANS(vmsgt_vi, 0, vmsgt_vx, opivx_cmp_check) | ||
83 | + | ||
84 | +/* Vector Integer Min/Max Instructions */ | ||
85 | +GEN_OPIVV_GVEC_TRANS(vminu_vv, umin) | ||
86 | +GEN_OPIVV_GVEC_TRANS(vmin_vv, smin) | ||
87 | +GEN_OPIVV_GVEC_TRANS(vmaxu_vv, umax) | ||
88 | +GEN_OPIVV_GVEC_TRANS(vmax_vv, smax) | ||
89 | +GEN_OPIVX_TRANS(vminu_vx, opivx_check) | ||
90 | +GEN_OPIVX_TRANS(vmin_vx, opivx_check) | ||
91 | +GEN_OPIVX_TRANS(vmaxu_vx, opivx_check) | ||
92 | +GEN_OPIVX_TRANS(vmax_vx, opivx_check) | ||
93 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/riscv/vector_helper.c | ||
96 | +++ b/target/riscv/vector_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO(vamomaxuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
98 | #define OP_SSS_H int16_t, int16_t, int16_t, int16_t, int16_t | ||
99 | #define OP_SSS_W int32_t, int32_t, int32_t, int32_t, int32_t | ||
100 | #define OP_SSS_D int64_t, int64_t, int64_t, int64_t, int64_t | ||
101 | +#define OP_UUU_B uint8_t, uint8_t, uint8_t, uint8_t, uint8_t | ||
102 | +#define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t | ||
103 | +#define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t | ||
104 | +#define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t | ||
105 | |||
106 | /* operation of two vector elements */ | ||
107 | typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); | ||
108 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_CMP_VX(vmsgt_vx_b, int8_t, H1, DO_MSGT) | ||
109 | GEN_VEXT_CMP_VX(vmsgt_vx_h, int16_t, H2, DO_MSGT) | ||
110 | GEN_VEXT_CMP_VX(vmsgt_vx_w, int32_t, H4, DO_MSGT) | ||
111 | GEN_VEXT_CMP_VX(vmsgt_vx_d, int64_t, H8, DO_MSGT) | ||
112 | + | ||
113 | +/* Vector Integer Min/Max Instructions */ | ||
114 | +RVVCALL(OPIVV2, vminu_vv_b, OP_UUU_B, H1, H1, H1, DO_MIN) | ||
115 | +RVVCALL(OPIVV2, vminu_vv_h, OP_UUU_H, H2, H2, H2, DO_MIN) | ||
116 | +RVVCALL(OPIVV2, vminu_vv_w, OP_UUU_W, H4, H4, H4, DO_MIN) | ||
117 | +RVVCALL(OPIVV2, vminu_vv_d, OP_UUU_D, H8, H8, H8, DO_MIN) | ||
118 | +RVVCALL(OPIVV2, vmin_vv_b, OP_SSS_B, H1, H1, H1, DO_MIN) | ||
119 | +RVVCALL(OPIVV2, vmin_vv_h, OP_SSS_H, H2, H2, H2, DO_MIN) | ||
120 | +RVVCALL(OPIVV2, vmin_vv_w, OP_SSS_W, H4, H4, H4, DO_MIN) | ||
121 | +RVVCALL(OPIVV2, vmin_vv_d, OP_SSS_D, H8, H8, H8, DO_MIN) | ||
122 | +RVVCALL(OPIVV2, vmaxu_vv_b, OP_UUU_B, H1, H1, H1, DO_MAX) | ||
123 | +RVVCALL(OPIVV2, vmaxu_vv_h, OP_UUU_H, H2, H2, H2, DO_MAX) | ||
124 | +RVVCALL(OPIVV2, vmaxu_vv_w, OP_UUU_W, H4, H4, H4, DO_MAX) | ||
125 | +RVVCALL(OPIVV2, vmaxu_vv_d, OP_UUU_D, H8, H8, H8, DO_MAX) | ||
126 | +RVVCALL(OPIVV2, vmax_vv_b, OP_SSS_B, H1, H1, H1, DO_MAX) | ||
127 | +RVVCALL(OPIVV2, vmax_vv_h, OP_SSS_H, H2, H2, H2, DO_MAX) | ||
128 | +RVVCALL(OPIVV2, vmax_vv_w, OP_SSS_W, H4, H4, H4, DO_MAX) | ||
129 | +RVVCALL(OPIVV2, vmax_vv_d, OP_SSS_D, H8, H8, H8, DO_MAX) | ||
130 | +GEN_VEXT_VV(vminu_vv_b, 1, 1, clearb) | ||
131 | +GEN_VEXT_VV(vminu_vv_h, 2, 2, clearh) | ||
132 | +GEN_VEXT_VV(vminu_vv_w, 4, 4, clearl) | ||
133 | +GEN_VEXT_VV(vminu_vv_d, 8, 8, clearq) | ||
134 | +GEN_VEXT_VV(vmin_vv_b, 1, 1, clearb) | ||
135 | +GEN_VEXT_VV(vmin_vv_h, 2, 2, clearh) | ||
136 | +GEN_VEXT_VV(vmin_vv_w, 4, 4, clearl) | ||
137 | +GEN_VEXT_VV(vmin_vv_d, 8, 8, clearq) | ||
138 | +GEN_VEXT_VV(vmaxu_vv_b, 1, 1, clearb) | ||
139 | +GEN_VEXT_VV(vmaxu_vv_h, 2, 2, clearh) | ||
140 | +GEN_VEXT_VV(vmaxu_vv_w, 4, 4, clearl) | ||
141 | +GEN_VEXT_VV(vmaxu_vv_d, 8, 8, clearq) | ||
142 | +GEN_VEXT_VV(vmax_vv_b, 1, 1, clearb) | ||
143 | +GEN_VEXT_VV(vmax_vv_h, 2, 2, clearh) | ||
144 | +GEN_VEXT_VV(vmax_vv_w, 4, 4, clearl) | ||
145 | +GEN_VEXT_VV(vmax_vv_d, 8, 8, clearq) | ||
146 | + | ||
147 | +RVVCALL(OPIVX2, vminu_vx_b, OP_UUU_B, H1, H1, DO_MIN) | ||
148 | +RVVCALL(OPIVX2, vminu_vx_h, OP_UUU_H, H2, H2, DO_MIN) | ||
149 | +RVVCALL(OPIVX2, vminu_vx_w, OP_UUU_W, H4, H4, DO_MIN) | ||
150 | +RVVCALL(OPIVX2, vminu_vx_d, OP_UUU_D, H8, H8, DO_MIN) | ||
151 | +RVVCALL(OPIVX2, vmin_vx_b, OP_SSS_B, H1, H1, DO_MIN) | ||
152 | +RVVCALL(OPIVX2, vmin_vx_h, OP_SSS_H, H2, H2, DO_MIN) | ||
153 | +RVVCALL(OPIVX2, vmin_vx_w, OP_SSS_W, H4, H4, DO_MIN) | ||
154 | +RVVCALL(OPIVX2, vmin_vx_d, OP_SSS_D, H8, H8, DO_MIN) | ||
155 | +RVVCALL(OPIVX2, vmaxu_vx_b, OP_UUU_B, H1, H1, DO_MAX) | ||
156 | +RVVCALL(OPIVX2, vmaxu_vx_h, OP_UUU_H, H2, H2, DO_MAX) | ||
157 | +RVVCALL(OPIVX2, vmaxu_vx_w, OP_UUU_W, H4, H4, DO_MAX) | ||
158 | +RVVCALL(OPIVX2, vmaxu_vx_d, OP_UUU_D, H8, H8, DO_MAX) | ||
159 | +RVVCALL(OPIVX2, vmax_vx_b, OP_SSS_B, H1, H1, DO_MAX) | ||
160 | +RVVCALL(OPIVX2, vmax_vx_h, OP_SSS_H, H2, H2, DO_MAX) | ||
161 | +RVVCALL(OPIVX2, vmax_vx_w, OP_SSS_W, H4, H4, DO_MAX) | ||
162 | +RVVCALL(OPIVX2, vmax_vx_d, OP_SSS_D, H8, H8, DO_MAX) | ||
163 | +GEN_VEXT_VX(vminu_vx_b, 1, 1, clearb) | ||
164 | +GEN_VEXT_VX(vminu_vx_h, 2, 2, clearh) | ||
165 | +GEN_VEXT_VX(vminu_vx_w, 4, 4, clearl) | ||
166 | +GEN_VEXT_VX(vminu_vx_d, 8, 8, clearq) | ||
167 | +GEN_VEXT_VX(vmin_vx_b, 1, 1, clearb) | ||
168 | +GEN_VEXT_VX(vmin_vx_h, 2, 2, clearh) | ||
169 | +GEN_VEXT_VX(vmin_vx_w, 4, 4, clearl) | ||
170 | +GEN_VEXT_VX(vmin_vx_d, 8, 8, clearq) | ||
171 | +GEN_VEXT_VX(vmaxu_vx_b, 1, 1, clearb) | ||
172 | +GEN_VEXT_VX(vmaxu_vx_h, 2, 2, clearh) | ||
173 | +GEN_VEXT_VX(vmaxu_vx_w, 4, 4, clearl) | ||
174 | +GEN_VEXT_VX(vmaxu_vx_d, 8, 8, clearq) | ||
175 | +GEN_VEXT_VX(vmax_vx_b, 1, 1, clearb) | ||
176 | +GEN_VEXT_VX(vmax_vx_h, 2, 2, clearh) | ||
177 | +GEN_VEXT_VX(vmax_vx_w, 4, 4, clearl) | ||
178 | +GEN_VEXT_VX(vmax_vx_d, 8, 8, clearq) | ||
179 | -- | ||
180 | 2.27.0 | ||
181 | |||
182 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200623215920.2594-19-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 33 +++++ | ||
10 | target/riscv/insn32.decode | 8 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 10 ++ | ||
12 | target/riscv/vector_helper.c | 163 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 214 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmax_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vmax_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vmax_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vmax_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vmul_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vmul_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vmulh_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vmulh_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vmulh_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vmulh_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vmulhu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vmulhu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vmulhu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vmulhu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vmulhsu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vmulhsu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vmulhsu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vmulhsu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vmul_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vmul_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vmul_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vmul_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vmulh_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vmulh_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vmulh_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vmulh_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vmulhu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vmulhu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vmulhu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vmulhu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vmulhsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vmulhsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vmulhsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vmulhsu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/riscv/insn32.decode | ||
59 | +++ b/target/riscv/insn32.decode | ||
60 | @@ -XXX,XX +XXX,XX @@ vmaxu_vv 000110 . ..... ..... 000 ..... 1010111 @r_vm | ||
61 | vmaxu_vx 000110 . ..... ..... 100 ..... 1010111 @r_vm | ||
62 | vmax_vv 000111 . ..... ..... 000 ..... 1010111 @r_vm | ||
63 | vmax_vx 000111 . ..... ..... 100 ..... 1010111 @r_vm | ||
64 | +vmul_vv 100101 . ..... ..... 010 ..... 1010111 @r_vm | ||
65 | +vmul_vx 100101 . ..... ..... 110 ..... 1010111 @r_vm | ||
66 | +vmulh_vv 100111 . ..... ..... 010 ..... 1010111 @r_vm | ||
67 | +vmulh_vx 100111 . ..... ..... 110 ..... 1010111 @r_vm | ||
68 | +vmulhu_vv 100100 . ..... ..... 010 ..... 1010111 @r_vm | ||
69 | +vmulhu_vx 100100 . ..... ..... 110 ..... 1010111 @r_vm | ||
70 | +vmulhsu_vv 100110 . ..... ..... 010 ..... 1010111 @r_vm | ||
71 | +vmulhsu_vx 100110 . ..... ..... 110 ..... 1010111 @r_vm | ||
72 | |||
73 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
74 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
75 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
78 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
79 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_TRANS(vminu_vx, opivx_check) | ||
80 | GEN_OPIVX_TRANS(vmin_vx, opivx_check) | ||
81 | GEN_OPIVX_TRANS(vmaxu_vx, opivx_check) | ||
82 | GEN_OPIVX_TRANS(vmax_vx, opivx_check) | ||
83 | + | ||
84 | +/* Vector Single-Width Integer Multiply Instructions */ | ||
85 | +GEN_OPIVV_GVEC_TRANS(vmul_vv, mul) | ||
86 | +GEN_OPIVV_TRANS(vmulh_vv, opivv_check) | ||
87 | +GEN_OPIVV_TRANS(vmulhu_vv, opivv_check) | ||
88 | +GEN_OPIVV_TRANS(vmulhsu_vv, opivv_check) | ||
89 | +GEN_OPIVX_GVEC_TRANS(vmul_vx, muls) | ||
90 | +GEN_OPIVX_TRANS(vmulh_vx, opivx_check) | ||
91 | +GEN_OPIVX_TRANS(vmulhu_vx, opivx_check) | ||
92 | +GEN_OPIVX_TRANS(vmulhsu_vx, opivx_check) | ||
93 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/riscv/vector_helper.c | ||
96 | +++ b/target/riscv/vector_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO(vamomaxuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
98 | #define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t | ||
99 | #define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t | ||
100 | #define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t | ||
101 | +#define OP_SUS_B int8_t, uint8_t, int8_t, uint8_t, int8_t | ||
102 | +#define OP_SUS_H int16_t, uint16_t, int16_t, uint16_t, int16_t | ||
103 | +#define OP_SUS_W int32_t, uint32_t, int32_t, uint32_t, int32_t | ||
104 | +#define OP_SUS_D int64_t, uint64_t, int64_t, uint64_t, int64_t | ||
105 | |||
106 | /* operation of two vector elements */ | ||
107 | typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); | ||
108 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vmax_vx_b, 1, 1, clearb) | ||
109 | GEN_VEXT_VX(vmax_vx_h, 2, 2, clearh) | ||
110 | GEN_VEXT_VX(vmax_vx_w, 4, 4, clearl) | ||
111 | GEN_VEXT_VX(vmax_vx_d, 8, 8, clearq) | ||
112 | + | ||
113 | +/* Vector Single-Width Integer Multiply Instructions */ | ||
114 | +#define DO_MUL(N, M) (N * M) | ||
115 | +RVVCALL(OPIVV2, vmul_vv_b, OP_SSS_B, H1, H1, H1, DO_MUL) | ||
116 | +RVVCALL(OPIVV2, vmul_vv_h, OP_SSS_H, H2, H2, H2, DO_MUL) | ||
117 | +RVVCALL(OPIVV2, vmul_vv_w, OP_SSS_W, H4, H4, H4, DO_MUL) | ||
118 | +RVVCALL(OPIVV2, vmul_vv_d, OP_SSS_D, H8, H8, H8, DO_MUL) | ||
119 | +GEN_VEXT_VV(vmul_vv_b, 1, 1, clearb) | ||
120 | +GEN_VEXT_VV(vmul_vv_h, 2, 2, clearh) | ||
121 | +GEN_VEXT_VV(vmul_vv_w, 4, 4, clearl) | ||
122 | +GEN_VEXT_VV(vmul_vv_d, 8, 8, clearq) | ||
123 | + | ||
124 | +static int8_t do_mulh_b(int8_t s2, int8_t s1) | ||
125 | +{ | ||
126 | + return (int16_t)s2 * (int16_t)s1 >> 8; | ||
127 | +} | ||
128 | + | ||
129 | +static int16_t do_mulh_h(int16_t s2, int16_t s1) | ||
130 | +{ | ||
131 | + return (int32_t)s2 * (int32_t)s1 >> 16; | ||
132 | +} | ||
133 | + | ||
134 | +static int32_t do_mulh_w(int32_t s2, int32_t s1) | ||
135 | +{ | ||
136 | + return (int64_t)s2 * (int64_t)s1 >> 32; | ||
137 | +} | ||
138 | + | ||
139 | +static int64_t do_mulh_d(int64_t s2, int64_t s1) | ||
140 | +{ | ||
141 | + uint64_t hi_64, lo_64; | ||
142 | + | ||
143 | + muls64(&lo_64, &hi_64, s1, s2); | ||
144 | + return hi_64; | ||
145 | +} | ||
146 | + | ||
147 | +static uint8_t do_mulhu_b(uint8_t s2, uint8_t s1) | ||
148 | +{ | ||
149 | + return (uint16_t)s2 * (uint16_t)s1 >> 8; | ||
150 | +} | ||
151 | + | ||
152 | +static uint16_t do_mulhu_h(uint16_t s2, uint16_t s1) | ||
153 | +{ | ||
154 | + return (uint32_t)s2 * (uint32_t)s1 >> 16; | ||
155 | +} | ||
156 | + | ||
157 | +static uint32_t do_mulhu_w(uint32_t s2, uint32_t s1) | ||
158 | +{ | ||
159 | + return (uint64_t)s2 * (uint64_t)s1 >> 32; | ||
160 | +} | ||
161 | + | ||
162 | +static uint64_t do_mulhu_d(uint64_t s2, uint64_t s1) | ||
163 | +{ | ||
164 | + uint64_t hi_64, lo_64; | ||
165 | + | ||
166 | + mulu64(&lo_64, &hi_64, s2, s1); | ||
167 | + return hi_64; | ||
168 | +} | ||
169 | + | ||
170 | +static int8_t do_mulhsu_b(int8_t s2, uint8_t s1) | ||
171 | +{ | ||
172 | + return (int16_t)s2 * (uint16_t)s1 >> 8; | ||
173 | +} | ||
174 | + | ||
175 | +static int16_t do_mulhsu_h(int16_t s2, uint16_t s1) | ||
176 | +{ | ||
177 | + return (int32_t)s2 * (uint32_t)s1 >> 16; | ||
178 | +} | ||
179 | + | ||
180 | +static int32_t do_mulhsu_w(int32_t s2, uint32_t s1) | ||
181 | +{ | ||
182 | + return (int64_t)s2 * (uint64_t)s1 >> 32; | ||
183 | +} | ||
184 | + | ||
185 | +/* | ||
186 | + * Let A = signed operand, | ||
187 | + * B = unsigned operand | ||
188 | + * P = mulu64(A, B), unsigned product | ||
189 | + * | ||
190 | + * LET X = 2 ** 64 - A, 2's complement of A | ||
191 | + * SP = signed product | ||
192 | + * THEN | ||
193 | + * IF A < 0 | ||
194 | + * SP = -X * B | ||
195 | + * = -(2 ** 64 - A) * B | ||
196 | + * = A * B - 2 ** 64 * B | ||
197 | + * = P - 2 ** 64 * B | ||
198 | + * ELSE | ||
199 | + * SP = P | ||
200 | + * THEN | ||
201 | + * HI_P -= (A < 0 ? B : 0) | ||
202 | + */ | ||
203 | + | ||
204 | +static int64_t do_mulhsu_d(int64_t s2, uint64_t s1) | ||
205 | +{ | ||
206 | + uint64_t hi_64, lo_64; | ||
207 | + | ||
208 | + mulu64(&lo_64, &hi_64, s2, s1); | ||
209 | + | ||
210 | + hi_64 -= s2 < 0 ? s1 : 0; | ||
211 | + return hi_64; | ||
212 | +} | ||
213 | + | ||
214 | +RVVCALL(OPIVV2, vmulh_vv_b, OP_SSS_B, H1, H1, H1, do_mulh_b) | ||
215 | +RVVCALL(OPIVV2, vmulh_vv_h, OP_SSS_H, H2, H2, H2, do_mulh_h) | ||
216 | +RVVCALL(OPIVV2, vmulh_vv_w, OP_SSS_W, H4, H4, H4, do_mulh_w) | ||
217 | +RVVCALL(OPIVV2, vmulh_vv_d, OP_SSS_D, H8, H8, H8, do_mulh_d) | ||
218 | +RVVCALL(OPIVV2, vmulhu_vv_b, OP_UUU_B, H1, H1, H1, do_mulhu_b) | ||
219 | +RVVCALL(OPIVV2, vmulhu_vv_h, OP_UUU_H, H2, H2, H2, do_mulhu_h) | ||
220 | +RVVCALL(OPIVV2, vmulhu_vv_w, OP_UUU_W, H4, H4, H4, do_mulhu_w) | ||
221 | +RVVCALL(OPIVV2, vmulhu_vv_d, OP_UUU_D, H8, H8, H8, do_mulhu_d) | ||
222 | +RVVCALL(OPIVV2, vmulhsu_vv_b, OP_SUS_B, H1, H1, H1, do_mulhsu_b) | ||
223 | +RVVCALL(OPIVV2, vmulhsu_vv_h, OP_SUS_H, H2, H2, H2, do_mulhsu_h) | ||
224 | +RVVCALL(OPIVV2, vmulhsu_vv_w, OP_SUS_W, H4, H4, H4, do_mulhsu_w) | ||
225 | +RVVCALL(OPIVV2, vmulhsu_vv_d, OP_SUS_D, H8, H8, H8, do_mulhsu_d) | ||
226 | +GEN_VEXT_VV(vmulh_vv_b, 1, 1, clearb) | ||
227 | +GEN_VEXT_VV(vmulh_vv_h, 2, 2, clearh) | ||
228 | +GEN_VEXT_VV(vmulh_vv_w, 4, 4, clearl) | ||
229 | +GEN_VEXT_VV(vmulh_vv_d, 8, 8, clearq) | ||
230 | +GEN_VEXT_VV(vmulhu_vv_b, 1, 1, clearb) | ||
231 | +GEN_VEXT_VV(vmulhu_vv_h, 2, 2, clearh) | ||
232 | +GEN_VEXT_VV(vmulhu_vv_w, 4, 4, clearl) | ||
233 | +GEN_VEXT_VV(vmulhu_vv_d, 8, 8, clearq) | ||
234 | +GEN_VEXT_VV(vmulhsu_vv_b, 1, 1, clearb) | ||
235 | +GEN_VEXT_VV(vmulhsu_vv_h, 2, 2, clearh) | ||
236 | +GEN_VEXT_VV(vmulhsu_vv_w, 4, 4, clearl) | ||
237 | +GEN_VEXT_VV(vmulhsu_vv_d, 8, 8, clearq) | ||
238 | + | ||
239 | +RVVCALL(OPIVX2, vmul_vx_b, OP_SSS_B, H1, H1, DO_MUL) | ||
240 | +RVVCALL(OPIVX2, vmul_vx_h, OP_SSS_H, H2, H2, DO_MUL) | ||
241 | +RVVCALL(OPIVX2, vmul_vx_w, OP_SSS_W, H4, H4, DO_MUL) | ||
242 | +RVVCALL(OPIVX2, vmul_vx_d, OP_SSS_D, H8, H8, DO_MUL) | ||
243 | +RVVCALL(OPIVX2, vmulh_vx_b, OP_SSS_B, H1, H1, do_mulh_b) | ||
244 | +RVVCALL(OPIVX2, vmulh_vx_h, OP_SSS_H, H2, H2, do_mulh_h) | ||
245 | +RVVCALL(OPIVX2, vmulh_vx_w, OP_SSS_W, H4, H4, do_mulh_w) | ||
246 | +RVVCALL(OPIVX2, vmulh_vx_d, OP_SSS_D, H8, H8, do_mulh_d) | ||
247 | +RVVCALL(OPIVX2, vmulhu_vx_b, OP_UUU_B, H1, H1, do_mulhu_b) | ||
248 | +RVVCALL(OPIVX2, vmulhu_vx_h, OP_UUU_H, H2, H2, do_mulhu_h) | ||
249 | +RVVCALL(OPIVX2, vmulhu_vx_w, OP_UUU_W, H4, H4, do_mulhu_w) | ||
250 | +RVVCALL(OPIVX2, vmulhu_vx_d, OP_UUU_D, H8, H8, do_mulhu_d) | ||
251 | +RVVCALL(OPIVX2, vmulhsu_vx_b, OP_SUS_B, H1, H1, do_mulhsu_b) | ||
252 | +RVVCALL(OPIVX2, vmulhsu_vx_h, OP_SUS_H, H2, H2, do_mulhsu_h) | ||
253 | +RVVCALL(OPIVX2, vmulhsu_vx_w, OP_SUS_W, H4, H4, do_mulhsu_w) | ||
254 | +RVVCALL(OPIVX2, vmulhsu_vx_d, OP_SUS_D, H8, H8, do_mulhsu_d) | ||
255 | +GEN_VEXT_VX(vmul_vx_b, 1, 1, clearb) | ||
256 | +GEN_VEXT_VX(vmul_vx_h, 2, 2, clearh) | ||
257 | +GEN_VEXT_VX(vmul_vx_w, 4, 4, clearl) | ||
258 | +GEN_VEXT_VX(vmul_vx_d, 8, 8, clearq) | ||
259 | +GEN_VEXT_VX(vmulh_vx_b, 1, 1, clearb) | ||
260 | +GEN_VEXT_VX(vmulh_vx_h, 2, 2, clearh) | ||
261 | +GEN_VEXT_VX(vmulh_vx_w, 4, 4, clearl) | ||
262 | +GEN_VEXT_VX(vmulh_vx_d, 8, 8, clearq) | ||
263 | +GEN_VEXT_VX(vmulhu_vx_b, 1, 1, clearb) | ||
264 | +GEN_VEXT_VX(vmulhu_vx_h, 2, 2, clearh) | ||
265 | +GEN_VEXT_VX(vmulhu_vx_w, 4, 4, clearl) | ||
266 | +GEN_VEXT_VX(vmulhu_vx_d, 8, 8, clearq) | ||
267 | +GEN_VEXT_VX(vmulhsu_vx_b, 1, 1, clearb) | ||
268 | +GEN_VEXT_VX(vmulhsu_vx_h, 2, 2, clearh) | ||
269 | +GEN_VEXT_VX(vmulhsu_vx_w, 4, 4, clearl) | ||
270 | +GEN_VEXT_VX(vmulhsu_vx_d, 8, 8, clearq) | ||
271 | -- | ||
272 | 2.27.0 | ||
273 | |||
274 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-20-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 33 +++++++++++ | ||
10 | target/riscv/insn32.decode | 8 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 10 ++++ | ||
12 | target/riscv/vector_helper.c | 74 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 125 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmulhsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vmulhsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vmulhsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vmulhsu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vdivu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vdivu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vdivu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vdivu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vdiv_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vdiv_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vdiv_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vdiv_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vremu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vremu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vremu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vremu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vrem_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vrem_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vrem_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vrem_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vdivu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vdivu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vdivu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vdivu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vdiv_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vdiv_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vdiv_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vdiv_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vremu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vremu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vremu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vremu_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vrem_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vrem_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vrem_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vrem_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/riscv/insn32.decode | ||
59 | +++ b/target/riscv/insn32.decode | ||
60 | @@ -XXX,XX +XXX,XX @@ vmulhu_vv 100100 . ..... ..... 010 ..... 1010111 @r_vm | ||
61 | vmulhu_vx 100100 . ..... ..... 110 ..... 1010111 @r_vm | ||
62 | vmulhsu_vv 100110 . ..... ..... 010 ..... 1010111 @r_vm | ||
63 | vmulhsu_vx 100110 . ..... ..... 110 ..... 1010111 @r_vm | ||
64 | +vdivu_vv 100000 . ..... ..... 010 ..... 1010111 @r_vm | ||
65 | +vdivu_vx 100000 . ..... ..... 110 ..... 1010111 @r_vm | ||
66 | +vdiv_vv 100001 . ..... ..... 010 ..... 1010111 @r_vm | ||
67 | +vdiv_vx 100001 . ..... ..... 110 ..... 1010111 @r_vm | ||
68 | +vremu_vv 100010 . ..... ..... 010 ..... 1010111 @r_vm | ||
69 | +vremu_vx 100010 . ..... ..... 110 ..... 1010111 @r_vm | ||
70 | +vrem_vv 100011 . ..... ..... 010 ..... 1010111 @r_vm | ||
71 | +vrem_vx 100011 . ..... ..... 110 ..... 1010111 @r_vm | ||
72 | |||
73 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
74 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
75 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
78 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
79 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_GVEC_TRANS(vmul_vx, muls) | ||
80 | GEN_OPIVX_TRANS(vmulh_vx, opivx_check) | ||
81 | GEN_OPIVX_TRANS(vmulhu_vx, opivx_check) | ||
82 | GEN_OPIVX_TRANS(vmulhsu_vx, opivx_check) | ||
83 | + | ||
84 | +/* Vector Integer Divide Instructions */ | ||
85 | +GEN_OPIVV_TRANS(vdivu_vv, opivv_check) | ||
86 | +GEN_OPIVV_TRANS(vdiv_vv, opivv_check) | ||
87 | +GEN_OPIVV_TRANS(vremu_vv, opivv_check) | ||
88 | +GEN_OPIVV_TRANS(vrem_vv, opivv_check) | ||
89 | +GEN_OPIVX_TRANS(vdivu_vx, opivx_check) | ||
90 | +GEN_OPIVX_TRANS(vdiv_vx, opivx_check) | ||
91 | +GEN_OPIVX_TRANS(vremu_vx, opivx_check) | ||
92 | +GEN_OPIVX_TRANS(vrem_vx, opivx_check) | ||
93 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/riscv/vector_helper.c | ||
96 | +++ b/target/riscv/vector_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vmulhsu_vx_b, 1, 1, clearb) | ||
98 | GEN_VEXT_VX(vmulhsu_vx_h, 2, 2, clearh) | ||
99 | GEN_VEXT_VX(vmulhsu_vx_w, 4, 4, clearl) | ||
100 | GEN_VEXT_VX(vmulhsu_vx_d, 8, 8, clearq) | ||
101 | + | ||
102 | +/* Vector Integer Divide Instructions */ | ||
103 | +#define DO_DIVU(N, M) (unlikely(M == 0) ? (__typeof(N))(-1) : N / M) | ||
104 | +#define DO_REMU(N, M) (unlikely(M == 0) ? N : N % M) | ||
105 | +#define DO_DIV(N, M) (unlikely(M == 0) ? (__typeof(N))(-1) :\ | ||
106 | + unlikely((N == -N) && (M == (__typeof(N))(-1))) ? N : N / M) | ||
107 | +#define DO_REM(N, M) (unlikely(M == 0) ? N :\ | ||
108 | + unlikely((N == -N) && (M == (__typeof(N))(-1))) ? 0 : N % M) | ||
109 | + | ||
110 | +RVVCALL(OPIVV2, vdivu_vv_b, OP_UUU_B, H1, H1, H1, DO_DIVU) | ||
111 | +RVVCALL(OPIVV2, vdivu_vv_h, OP_UUU_H, H2, H2, H2, DO_DIVU) | ||
112 | +RVVCALL(OPIVV2, vdivu_vv_w, OP_UUU_W, H4, H4, H4, DO_DIVU) | ||
113 | +RVVCALL(OPIVV2, vdivu_vv_d, OP_UUU_D, H8, H8, H8, DO_DIVU) | ||
114 | +RVVCALL(OPIVV2, vdiv_vv_b, OP_SSS_B, H1, H1, H1, DO_DIV) | ||
115 | +RVVCALL(OPIVV2, vdiv_vv_h, OP_SSS_H, H2, H2, H2, DO_DIV) | ||
116 | +RVVCALL(OPIVV2, vdiv_vv_w, OP_SSS_W, H4, H4, H4, DO_DIV) | ||
117 | +RVVCALL(OPIVV2, vdiv_vv_d, OP_SSS_D, H8, H8, H8, DO_DIV) | ||
118 | +RVVCALL(OPIVV2, vremu_vv_b, OP_UUU_B, H1, H1, H1, DO_REMU) | ||
119 | +RVVCALL(OPIVV2, vremu_vv_h, OP_UUU_H, H2, H2, H2, DO_REMU) | ||
120 | +RVVCALL(OPIVV2, vremu_vv_w, OP_UUU_W, H4, H4, H4, DO_REMU) | ||
121 | +RVVCALL(OPIVV2, vremu_vv_d, OP_UUU_D, H8, H8, H8, DO_REMU) | ||
122 | +RVVCALL(OPIVV2, vrem_vv_b, OP_SSS_B, H1, H1, H1, DO_REM) | ||
123 | +RVVCALL(OPIVV2, vrem_vv_h, OP_SSS_H, H2, H2, H2, DO_REM) | ||
124 | +RVVCALL(OPIVV2, vrem_vv_w, OP_SSS_W, H4, H4, H4, DO_REM) | ||
125 | +RVVCALL(OPIVV2, vrem_vv_d, OP_SSS_D, H8, H8, H8, DO_REM) | ||
126 | +GEN_VEXT_VV(vdivu_vv_b, 1, 1, clearb) | ||
127 | +GEN_VEXT_VV(vdivu_vv_h, 2, 2, clearh) | ||
128 | +GEN_VEXT_VV(vdivu_vv_w, 4, 4, clearl) | ||
129 | +GEN_VEXT_VV(vdivu_vv_d, 8, 8, clearq) | ||
130 | +GEN_VEXT_VV(vdiv_vv_b, 1, 1, clearb) | ||
131 | +GEN_VEXT_VV(vdiv_vv_h, 2, 2, clearh) | ||
132 | +GEN_VEXT_VV(vdiv_vv_w, 4, 4, clearl) | ||
133 | +GEN_VEXT_VV(vdiv_vv_d, 8, 8, clearq) | ||
134 | +GEN_VEXT_VV(vremu_vv_b, 1, 1, clearb) | ||
135 | +GEN_VEXT_VV(vremu_vv_h, 2, 2, clearh) | ||
136 | +GEN_VEXT_VV(vremu_vv_w, 4, 4, clearl) | ||
137 | +GEN_VEXT_VV(vremu_vv_d, 8, 8, clearq) | ||
138 | +GEN_VEXT_VV(vrem_vv_b, 1, 1, clearb) | ||
139 | +GEN_VEXT_VV(vrem_vv_h, 2, 2, clearh) | ||
140 | +GEN_VEXT_VV(vrem_vv_w, 4, 4, clearl) | ||
141 | +GEN_VEXT_VV(vrem_vv_d, 8, 8, clearq) | ||
142 | + | ||
143 | +RVVCALL(OPIVX2, vdivu_vx_b, OP_UUU_B, H1, H1, DO_DIVU) | ||
144 | +RVVCALL(OPIVX2, vdivu_vx_h, OP_UUU_H, H2, H2, DO_DIVU) | ||
145 | +RVVCALL(OPIVX2, vdivu_vx_w, OP_UUU_W, H4, H4, DO_DIVU) | ||
146 | +RVVCALL(OPIVX2, vdivu_vx_d, OP_UUU_D, H8, H8, DO_DIVU) | ||
147 | +RVVCALL(OPIVX2, vdiv_vx_b, OP_SSS_B, H1, H1, DO_DIV) | ||
148 | +RVVCALL(OPIVX2, vdiv_vx_h, OP_SSS_H, H2, H2, DO_DIV) | ||
149 | +RVVCALL(OPIVX2, vdiv_vx_w, OP_SSS_W, H4, H4, DO_DIV) | ||
150 | +RVVCALL(OPIVX2, vdiv_vx_d, OP_SSS_D, H8, H8, DO_DIV) | ||
151 | +RVVCALL(OPIVX2, vremu_vx_b, OP_UUU_B, H1, H1, DO_REMU) | ||
152 | +RVVCALL(OPIVX2, vremu_vx_h, OP_UUU_H, H2, H2, DO_REMU) | ||
153 | +RVVCALL(OPIVX2, vremu_vx_w, OP_UUU_W, H4, H4, DO_REMU) | ||
154 | +RVVCALL(OPIVX2, vremu_vx_d, OP_UUU_D, H8, H8, DO_REMU) | ||
155 | +RVVCALL(OPIVX2, vrem_vx_b, OP_SSS_B, H1, H1, DO_REM) | ||
156 | +RVVCALL(OPIVX2, vrem_vx_h, OP_SSS_H, H2, H2, DO_REM) | ||
157 | +RVVCALL(OPIVX2, vrem_vx_w, OP_SSS_W, H4, H4, DO_REM) | ||
158 | +RVVCALL(OPIVX2, vrem_vx_d, OP_SSS_D, H8, H8, DO_REM) | ||
159 | +GEN_VEXT_VX(vdivu_vx_b, 1, 1, clearb) | ||
160 | +GEN_VEXT_VX(vdivu_vx_h, 2, 2, clearh) | ||
161 | +GEN_VEXT_VX(vdivu_vx_w, 4, 4, clearl) | ||
162 | +GEN_VEXT_VX(vdivu_vx_d, 8, 8, clearq) | ||
163 | +GEN_VEXT_VX(vdiv_vx_b, 1, 1, clearb) | ||
164 | +GEN_VEXT_VX(vdiv_vx_h, 2, 2, clearh) | ||
165 | +GEN_VEXT_VX(vdiv_vx_w, 4, 4, clearl) | ||
166 | +GEN_VEXT_VX(vdiv_vx_d, 8, 8, clearq) | ||
167 | +GEN_VEXT_VX(vremu_vx_b, 1, 1, clearb) | ||
168 | +GEN_VEXT_VX(vremu_vx_h, 2, 2, clearh) | ||
169 | +GEN_VEXT_VX(vremu_vx_w, 4, 4, clearl) | ||
170 | +GEN_VEXT_VX(vremu_vx_d, 8, 8, clearq) | ||
171 | +GEN_VEXT_VX(vrem_vx_b, 1, 1, clearb) | ||
172 | +GEN_VEXT_VX(vrem_vx_h, 2, 2, clearh) | ||
173 | +GEN_VEXT_VX(vrem_vx_w, 4, 4, clearl) | ||
174 | +GEN_VEXT_VX(vrem_vx_d, 8, 8, clearq) | ||
175 | -- | ||
176 | 2.27.0 | ||
177 | |||
178 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-21-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 19 +++++++++ | ||
10 | target/riscv/insn32.decode | 6 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 8 ++++ | ||
12 | target/riscv/vector_helper.c | 51 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 84 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vrem_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vrem_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vrem_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vrem_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vwmul_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vwmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vwmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vwmulu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vwmulu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vwmulu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vwmulsu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vwmulsu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vwmulsu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vwmul_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vwmul_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vwmul_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vwmulu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vwmulu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vwmulu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vwmulsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vwmulsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vwmulsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/riscv/insn32.decode | ||
45 | +++ b/target/riscv/insn32.decode | ||
46 | @@ -XXX,XX +XXX,XX @@ vremu_vv 100010 . ..... ..... 010 ..... 1010111 @r_vm | ||
47 | vremu_vx 100010 . ..... ..... 110 ..... 1010111 @r_vm | ||
48 | vrem_vv 100011 . ..... ..... 010 ..... 1010111 @r_vm | ||
49 | vrem_vx 100011 . ..... ..... 110 ..... 1010111 @r_vm | ||
50 | +vwmulu_vv 111000 . ..... ..... 010 ..... 1010111 @r_vm | ||
51 | +vwmulu_vx 111000 . ..... ..... 110 ..... 1010111 @r_vm | ||
52 | +vwmulsu_vv 111010 . ..... ..... 010 ..... 1010111 @r_vm | ||
53 | +vwmulsu_vx 111010 . ..... ..... 110 ..... 1010111 @r_vm | ||
54 | +vwmul_vv 111011 . ..... ..... 010 ..... 1010111 @r_vm | ||
55 | +vwmul_vx 111011 . ..... ..... 110 ..... 1010111 @r_vm | ||
56 | |||
57 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
58 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
59 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
62 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
63 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_TRANS(vdivu_vx, opivx_check) | ||
64 | GEN_OPIVX_TRANS(vdiv_vx, opivx_check) | ||
65 | GEN_OPIVX_TRANS(vremu_vx, opivx_check) | ||
66 | GEN_OPIVX_TRANS(vrem_vx, opivx_check) | ||
67 | + | ||
68 | +/* Vector Widening Integer Multiply Instructions */ | ||
69 | +GEN_OPIVV_WIDEN_TRANS(vwmul_vv, opivv_widen_check) | ||
70 | +GEN_OPIVV_WIDEN_TRANS(vwmulu_vv, opivv_widen_check) | ||
71 | +GEN_OPIVV_WIDEN_TRANS(vwmulsu_vv, opivv_widen_check) | ||
72 | +GEN_OPIVX_WIDEN_TRANS(vwmul_vx) | ||
73 | +GEN_OPIVX_WIDEN_TRANS(vwmulu_vx) | ||
74 | +GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx) | ||
75 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/riscv/vector_helper.c | ||
78 | +++ b/target/riscv/vector_helper.c | ||
79 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO(vamomaxuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
80 | #define OP_SUS_H int16_t, uint16_t, int16_t, uint16_t, int16_t | ||
81 | #define OP_SUS_W int32_t, uint32_t, int32_t, uint32_t, int32_t | ||
82 | #define OP_SUS_D int64_t, uint64_t, int64_t, uint64_t, int64_t | ||
83 | +#define WOP_UUU_B uint16_t, uint8_t, uint8_t, uint16_t, uint16_t | ||
84 | +#define WOP_UUU_H uint32_t, uint16_t, uint16_t, uint32_t, uint32_t | ||
85 | +#define WOP_UUU_W uint64_t, uint32_t, uint32_t, uint64_t, uint64_t | ||
86 | +#define WOP_SSS_B int16_t, int8_t, int8_t, int16_t, int16_t | ||
87 | +#define WOP_SSS_H int32_t, int16_t, int16_t, int32_t, int32_t | ||
88 | +#define WOP_SSS_W int64_t, int32_t, int32_t, int64_t, int64_t | ||
89 | +#define WOP_SUS_B int16_t, uint8_t, int8_t, uint16_t, int16_t | ||
90 | +#define WOP_SUS_H int32_t, uint16_t, int16_t, uint32_t, int32_t | ||
91 | +#define WOP_SUS_W int64_t, uint32_t, int32_t, uint64_t, int64_t | ||
92 | +#define WOP_SSU_B int16_t, int8_t, uint8_t, int16_t, uint16_t | ||
93 | +#define WOP_SSU_H int32_t, int16_t, uint16_t, int32_t, uint32_t | ||
94 | +#define WOP_SSU_W int64_t, int32_t, uint32_t, int64_t, uint64_t | ||
95 | |||
96 | /* operation of two vector elements */ | ||
97 | typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); | ||
98 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vrem_vx_b, 1, 1, clearb) | ||
99 | GEN_VEXT_VX(vrem_vx_h, 2, 2, clearh) | ||
100 | GEN_VEXT_VX(vrem_vx_w, 4, 4, clearl) | ||
101 | GEN_VEXT_VX(vrem_vx_d, 8, 8, clearq) | ||
102 | + | ||
103 | +/* Vector Widening Integer Multiply Instructions */ | ||
104 | +RVVCALL(OPIVV2, vwmul_vv_b, WOP_SSS_B, H2, H1, H1, DO_MUL) | ||
105 | +RVVCALL(OPIVV2, vwmul_vv_h, WOP_SSS_H, H4, H2, H2, DO_MUL) | ||
106 | +RVVCALL(OPIVV2, vwmul_vv_w, WOP_SSS_W, H8, H4, H4, DO_MUL) | ||
107 | +RVVCALL(OPIVV2, vwmulu_vv_b, WOP_UUU_B, H2, H1, H1, DO_MUL) | ||
108 | +RVVCALL(OPIVV2, vwmulu_vv_h, WOP_UUU_H, H4, H2, H2, DO_MUL) | ||
109 | +RVVCALL(OPIVV2, vwmulu_vv_w, WOP_UUU_W, H8, H4, H4, DO_MUL) | ||
110 | +RVVCALL(OPIVV2, vwmulsu_vv_b, WOP_SUS_B, H2, H1, H1, DO_MUL) | ||
111 | +RVVCALL(OPIVV2, vwmulsu_vv_h, WOP_SUS_H, H4, H2, H2, DO_MUL) | ||
112 | +RVVCALL(OPIVV2, vwmulsu_vv_w, WOP_SUS_W, H8, H4, H4, DO_MUL) | ||
113 | +GEN_VEXT_VV(vwmul_vv_b, 1, 2, clearh) | ||
114 | +GEN_VEXT_VV(vwmul_vv_h, 2, 4, clearl) | ||
115 | +GEN_VEXT_VV(vwmul_vv_w, 4, 8, clearq) | ||
116 | +GEN_VEXT_VV(vwmulu_vv_b, 1, 2, clearh) | ||
117 | +GEN_VEXT_VV(vwmulu_vv_h, 2, 4, clearl) | ||
118 | +GEN_VEXT_VV(vwmulu_vv_w, 4, 8, clearq) | ||
119 | +GEN_VEXT_VV(vwmulsu_vv_b, 1, 2, clearh) | ||
120 | +GEN_VEXT_VV(vwmulsu_vv_h, 2, 4, clearl) | ||
121 | +GEN_VEXT_VV(vwmulsu_vv_w, 4, 8, clearq) | ||
122 | + | ||
123 | +RVVCALL(OPIVX2, vwmul_vx_b, WOP_SSS_B, H2, H1, DO_MUL) | ||
124 | +RVVCALL(OPIVX2, vwmul_vx_h, WOP_SSS_H, H4, H2, DO_MUL) | ||
125 | +RVVCALL(OPIVX2, vwmul_vx_w, WOP_SSS_W, H8, H4, DO_MUL) | ||
126 | +RVVCALL(OPIVX2, vwmulu_vx_b, WOP_UUU_B, H2, H1, DO_MUL) | ||
127 | +RVVCALL(OPIVX2, vwmulu_vx_h, WOP_UUU_H, H4, H2, DO_MUL) | ||
128 | +RVVCALL(OPIVX2, vwmulu_vx_w, WOP_UUU_W, H8, H4, DO_MUL) | ||
129 | +RVVCALL(OPIVX2, vwmulsu_vx_b, WOP_SUS_B, H2, H1, DO_MUL) | ||
130 | +RVVCALL(OPIVX2, vwmulsu_vx_h, WOP_SUS_H, H4, H2, DO_MUL) | ||
131 | +RVVCALL(OPIVX2, vwmulsu_vx_w, WOP_SUS_W, H8, H4, DO_MUL) | ||
132 | +GEN_VEXT_VX(vwmul_vx_b, 1, 2, clearh) | ||
133 | +GEN_VEXT_VX(vwmul_vx_h, 2, 4, clearl) | ||
134 | +GEN_VEXT_VX(vwmul_vx_w, 4, 8, clearq) | ||
135 | +GEN_VEXT_VX(vwmulu_vx_b, 1, 2, clearh) | ||
136 | +GEN_VEXT_VX(vwmulu_vx_h, 2, 4, clearl) | ||
137 | +GEN_VEXT_VX(vwmulu_vx_w, 4, 8, clearq) | ||
138 | +GEN_VEXT_VX(vwmulsu_vx_b, 1, 2, clearh) | ||
139 | +GEN_VEXT_VX(vwmulsu_vx_h, 2, 4, clearl) | ||
140 | +GEN_VEXT_VX(vwmulsu_vx_w, 4, 8, clearq) | ||
141 | -- | ||
142 | 2.27.0 | ||
143 | |||
144 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-22-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 33 ++++++++++ | ||
10 | target/riscv/insn32.decode | 8 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 10 +++ | ||
12 | target/riscv/vector_helper.c | 88 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 139 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vwmulu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vwmulsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vwmulsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vwmulsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vmacc_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vmacc_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vnmsac_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vnmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vnmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vnmsac_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vmadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vmadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vmadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vmadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vnmsub_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vnmsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vnmsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vnmsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vmacc_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vmacc_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vmacc_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vmacc_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vnmsac_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vnmsac_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vnmsac_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vnmsac_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vmadd_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vmadd_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vmadd_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vmadd_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vnmsub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vnmsub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vnmsub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vnmsub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
56 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/riscv/insn32.decode | ||
59 | +++ b/target/riscv/insn32.decode | ||
60 | @@ -XXX,XX +XXX,XX @@ vwmulsu_vv 111010 . ..... ..... 010 ..... 1010111 @r_vm | ||
61 | vwmulsu_vx 111010 . ..... ..... 110 ..... 1010111 @r_vm | ||
62 | vwmul_vv 111011 . ..... ..... 010 ..... 1010111 @r_vm | ||
63 | vwmul_vx 111011 . ..... ..... 110 ..... 1010111 @r_vm | ||
64 | +vmacc_vv 101101 . ..... ..... 010 ..... 1010111 @r_vm | ||
65 | +vmacc_vx 101101 . ..... ..... 110 ..... 1010111 @r_vm | ||
66 | +vnmsac_vv 101111 . ..... ..... 010 ..... 1010111 @r_vm | ||
67 | +vnmsac_vx 101111 . ..... ..... 110 ..... 1010111 @r_vm | ||
68 | +vmadd_vv 101001 . ..... ..... 010 ..... 1010111 @r_vm | ||
69 | +vmadd_vx 101001 . ..... ..... 110 ..... 1010111 @r_vm | ||
70 | +vnmsub_vv 101011 . ..... ..... 010 ..... 1010111 @r_vm | ||
71 | +vnmsub_vx 101011 . ..... ..... 110 ..... 1010111 @r_vm | ||
72 | |||
73 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
74 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
75 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
78 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
79 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVV_WIDEN_TRANS(vwmulsu_vv, opivv_widen_check) | ||
80 | GEN_OPIVX_WIDEN_TRANS(vwmul_vx) | ||
81 | GEN_OPIVX_WIDEN_TRANS(vwmulu_vx) | ||
82 | GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx) | ||
83 | + | ||
84 | +/* Vector Single-Width Integer Multiply-Add Instructions */ | ||
85 | +GEN_OPIVV_TRANS(vmacc_vv, opivv_check) | ||
86 | +GEN_OPIVV_TRANS(vnmsac_vv, opivv_check) | ||
87 | +GEN_OPIVV_TRANS(vmadd_vv, opivv_check) | ||
88 | +GEN_OPIVV_TRANS(vnmsub_vv, opivv_check) | ||
89 | +GEN_OPIVX_TRANS(vmacc_vx, opivx_check) | ||
90 | +GEN_OPIVX_TRANS(vnmsac_vx, opivx_check) | ||
91 | +GEN_OPIVX_TRANS(vmadd_vx, opivx_check) | ||
92 | +GEN_OPIVX_TRANS(vnmsub_vx, opivx_check) | ||
93 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/riscv/vector_helper.c | ||
96 | +++ b/target/riscv/vector_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vwmulu_vx_w, 4, 8, clearq) | ||
98 | GEN_VEXT_VX(vwmulsu_vx_b, 1, 2, clearh) | ||
99 | GEN_VEXT_VX(vwmulsu_vx_h, 2, 4, clearl) | ||
100 | GEN_VEXT_VX(vwmulsu_vx_w, 4, 8, clearq) | ||
101 | + | ||
102 | +/* Vector Single-Width Integer Multiply-Add Instructions */ | ||
103 | +#define OPIVV3(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ | ||
104 | +static void do_##NAME(void *vd, void *vs1, void *vs2, int i) \ | ||
105 | +{ \ | ||
106 | + TX1 s1 = *((T1 *)vs1 + HS1(i)); \ | ||
107 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
108 | + TD d = *((TD *)vd + HD(i)); \ | ||
109 | + *((TD *)vd + HD(i)) = OP(s2, s1, d); \ | ||
110 | +} | ||
111 | + | ||
112 | +#define DO_MACC(N, M, D) (M * N + D) | ||
113 | +#define DO_NMSAC(N, M, D) (-(M * N) + D) | ||
114 | +#define DO_MADD(N, M, D) (M * D + N) | ||
115 | +#define DO_NMSUB(N, M, D) (-(M * D) + N) | ||
116 | +RVVCALL(OPIVV3, vmacc_vv_b, OP_SSS_B, H1, H1, H1, DO_MACC) | ||
117 | +RVVCALL(OPIVV3, vmacc_vv_h, OP_SSS_H, H2, H2, H2, DO_MACC) | ||
118 | +RVVCALL(OPIVV3, vmacc_vv_w, OP_SSS_W, H4, H4, H4, DO_MACC) | ||
119 | +RVVCALL(OPIVV3, vmacc_vv_d, OP_SSS_D, H8, H8, H8, DO_MACC) | ||
120 | +RVVCALL(OPIVV3, vnmsac_vv_b, OP_SSS_B, H1, H1, H1, DO_NMSAC) | ||
121 | +RVVCALL(OPIVV3, vnmsac_vv_h, OP_SSS_H, H2, H2, H2, DO_NMSAC) | ||
122 | +RVVCALL(OPIVV3, vnmsac_vv_w, OP_SSS_W, H4, H4, H4, DO_NMSAC) | ||
123 | +RVVCALL(OPIVV3, vnmsac_vv_d, OP_SSS_D, H8, H8, H8, DO_NMSAC) | ||
124 | +RVVCALL(OPIVV3, vmadd_vv_b, OP_SSS_B, H1, H1, H1, DO_MADD) | ||
125 | +RVVCALL(OPIVV3, vmadd_vv_h, OP_SSS_H, H2, H2, H2, DO_MADD) | ||
126 | +RVVCALL(OPIVV3, vmadd_vv_w, OP_SSS_W, H4, H4, H4, DO_MADD) | ||
127 | +RVVCALL(OPIVV3, vmadd_vv_d, OP_SSS_D, H8, H8, H8, DO_MADD) | ||
128 | +RVVCALL(OPIVV3, vnmsub_vv_b, OP_SSS_B, H1, H1, H1, DO_NMSUB) | ||
129 | +RVVCALL(OPIVV3, vnmsub_vv_h, OP_SSS_H, H2, H2, H2, DO_NMSUB) | ||
130 | +RVVCALL(OPIVV3, vnmsub_vv_w, OP_SSS_W, H4, H4, H4, DO_NMSUB) | ||
131 | +RVVCALL(OPIVV3, vnmsub_vv_d, OP_SSS_D, H8, H8, H8, DO_NMSUB) | ||
132 | +GEN_VEXT_VV(vmacc_vv_b, 1, 1, clearb) | ||
133 | +GEN_VEXT_VV(vmacc_vv_h, 2, 2, clearh) | ||
134 | +GEN_VEXT_VV(vmacc_vv_w, 4, 4, clearl) | ||
135 | +GEN_VEXT_VV(vmacc_vv_d, 8, 8, clearq) | ||
136 | +GEN_VEXT_VV(vnmsac_vv_b, 1, 1, clearb) | ||
137 | +GEN_VEXT_VV(vnmsac_vv_h, 2, 2, clearh) | ||
138 | +GEN_VEXT_VV(vnmsac_vv_w, 4, 4, clearl) | ||
139 | +GEN_VEXT_VV(vnmsac_vv_d, 8, 8, clearq) | ||
140 | +GEN_VEXT_VV(vmadd_vv_b, 1, 1, clearb) | ||
141 | +GEN_VEXT_VV(vmadd_vv_h, 2, 2, clearh) | ||
142 | +GEN_VEXT_VV(vmadd_vv_w, 4, 4, clearl) | ||
143 | +GEN_VEXT_VV(vmadd_vv_d, 8, 8, clearq) | ||
144 | +GEN_VEXT_VV(vnmsub_vv_b, 1, 1, clearb) | ||
145 | +GEN_VEXT_VV(vnmsub_vv_h, 2, 2, clearh) | ||
146 | +GEN_VEXT_VV(vnmsub_vv_w, 4, 4, clearl) | ||
147 | +GEN_VEXT_VV(vnmsub_vv_d, 8, 8, clearq) | ||
148 | + | ||
149 | +#define OPIVX3(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ | ||
150 | +static void do_##NAME(void *vd, target_long s1, void *vs2, int i) \ | ||
151 | +{ \ | ||
152 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
153 | + TD d = *((TD *)vd + HD(i)); \ | ||
154 | + *((TD *)vd + HD(i)) = OP(s2, (TX1)(T1)s1, d); \ | ||
155 | +} | ||
156 | + | ||
157 | +RVVCALL(OPIVX3, vmacc_vx_b, OP_SSS_B, H1, H1, DO_MACC) | ||
158 | +RVVCALL(OPIVX3, vmacc_vx_h, OP_SSS_H, H2, H2, DO_MACC) | ||
159 | +RVVCALL(OPIVX3, vmacc_vx_w, OP_SSS_W, H4, H4, DO_MACC) | ||
160 | +RVVCALL(OPIVX3, vmacc_vx_d, OP_SSS_D, H8, H8, DO_MACC) | ||
161 | +RVVCALL(OPIVX3, vnmsac_vx_b, OP_SSS_B, H1, H1, DO_NMSAC) | ||
162 | +RVVCALL(OPIVX3, vnmsac_vx_h, OP_SSS_H, H2, H2, DO_NMSAC) | ||
163 | +RVVCALL(OPIVX3, vnmsac_vx_w, OP_SSS_W, H4, H4, DO_NMSAC) | ||
164 | +RVVCALL(OPIVX3, vnmsac_vx_d, OP_SSS_D, H8, H8, DO_NMSAC) | ||
165 | +RVVCALL(OPIVX3, vmadd_vx_b, OP_SSS_B, H1, H1, DO_MADD) | ||
166 | +RVVCALL(OPIVX3, vmadd_vx_h, OP_SSS_H, H2, H2, DO_MADD) | ||
167 | +RVVCALL(OPIVX3, vmadd_vx_w, OP_SSS_W, H4, H4, DO_MADD) | ||
168 | +RVVCALL(OPIVX3, vmadd_vx_d, OP_SSS_D, H8, H8, DO_MADD) | ||
169 | +RVVCALL(OPIVX3, vnmsub_vx_b, OP_SSS_B, H1, H1, DO_NMSUB) | ||
170 | +RVVCALL(OPIVX3, vnmsub_vx_h, OP_SSS_H, H2, H2, DO_NMSUB) | ||
171 | +RVVCALL(OPIVX3, vnmsub_vx_w, OP_SSS_W, H4, H4, DO_NMSUB) | ||
172 | +RVVCALL(OPIVX3, vnmsub_vx_d, OP_SSS_D, H8, H8, DO_NMSUB) | ||
173 | +GEN_VEXT_VX(vmacc_vx_b, 1, 1, clearb) | ||
174 | +GEN_VEXT_VX(vmacc_vx_h, 2, 2, clearh) | ||
175 | +GEN_VEXT_VX(vmacc_vx_w, 4, 4, clearl) | ||
176 | +GEN_VEXT_VX(vmacc_vx_d, 8, 8, clearq) | ||
177 | +GEN_VEXT_VX(vnmsac_vx_b, 1, 1, clearb) | ||
178 | +GEN_VEXT_VX(vnmsac_vx_h, 2, 2, clearh) | ||
179 | +GEN_VEXT_VX(vnmsac_vx_w, 4, 4, clearl) | ||
180 | +GEN_VEXT_VX(vnmsac_vx_d, 8, 8, clearq) | ||
181 | +GEN_VEXT_VX(vmadd_vx_b, 1, 1, clearb) | ||
182 | +GEN_VEXT_VX(vmadd_vx_h, 2, 2, clearh) | ||
183 | +GEN_VEXT_VX(vmadd_vx_w, 4, 4, clearl) | ||
184 | +GEN_VEXT_VX(vmadd_vx_d, 8, 8, clearq) | ||
185 | +GEN_VEXT_VX(vnmsub_vx_b, 1, 1, clearb) | ||
186 | +GEN_VEXT_VX(vnmsub_vx_h, 2, 2, clearh) | ||
187 | +GEN_VEXT_VX(vnmsub_vx_w, 4, 4, clearl) | ||
188 | +GEN_VEXT_VX(vnmsub_vx_d, 8, 8, clearq) | ||
189 | -- | ||
190 | 2.27.0 | ||
191 | |||
192 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-23-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 22 ++++++++++++ | ||
10 | target/riscv/insn32.decode | 7 ++++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 9 +++++ | ||
12 | target/riscv/vector_helper.c | 45 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 83 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vnmsub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vnmsub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vnmsub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vnmsub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vwmaccu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vwmaccu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vwmaccu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vwmacc_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vwmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vwmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vwmaccsu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vwmaccsu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vwmaccsu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vwmaccu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vwmaccu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vwmaccu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vwmacc_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vwmacc_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vwmacc_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vwmaccsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vwmaccsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vwmaccsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vwmaccus_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vwmaccus_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vwmaccus_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/riscv/insn32.decode | ||
48 | +++ b/target/riscv/insn32.decode | ||
49 | @@ -XXX,XX +XXX,XX @@ vmadd_vv 101001 . ..... ..... 010 ..... 1010111 @r_vm | ||
50 | vmadd_vx 101001 . ..... ..... 110 ..... 1010111 @r_vm | ||
51 | vnmsub_vv 101011 . ..... ..... 010 ..... 1010111 @r_vm | ||
52 | vnmsub_vx 101011 . ..... ..... 110 ..... 1010111 @r_vm | ||
53 | +vwmaccu_vv 111100 . ..... ..... 010 ..... 1010111 @r_vm | ||
54 | +vwmaccu_vx 111100 . ..... ..... 110 ..... 1010111 @r_vm | ||
55 | +vwmacc_vv 111101 . ..... ..... 010 ..... 1010111 @r_vm | ||
56 | +vwmacc_vx 111101 . ..... ..... 110 ..... 1010111 @r_vm | ||
57 | +vwmaccsu_vv 111110 . ..... ..... 010 ..... 1010111 @r_vm | ||
58 | +vwmaccsu_vx 111110 . ..... ..... 110 ..... 1010111 @r_vm | ||
59 | +vwmaccus_vx 111111 . ..... ..... 110 ..... 1010111 @r_vm | ||
60 | |||
61 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
62 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
63 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
66 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
67 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_TRANS(vmacc_vx, opivx_check) | ||
68 | GEN_OPIVX_TRANS(vnmsac_vx, opivx_check) | ||
69 | GEN_OPIVX_TRANS(vmadd_vx, opivx_check) | ||
70 | GEN_OPIVX_TRANS(vnmsub_vx, opivx_check) | ||
71 | + | ||
72 | +/* Vector Widening Integer Multiply-Add Instructions */ | ||
73 | +GEN_OPIVV_WIDEN_TRANS(vwmaccu_vv, opivv_widen_check) | ||
74 | +GEN_OPIVV_WIDEN_TRANS(vwmacc_vv, opivv_widen_check) | ||
75 | +GEN_OPIVV_WIDEN_TRANS(vwmaccsu_vv, opivv_widen_check) | ||
76 | +GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx) | ||
77 | +GEN_OPIVX_WIDEN_TRANS(vwmacc_vx) | ||
78 | +GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx) | ||
79 | +GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx) | ||
80 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/riscv/vector_helper.c | ||
83 | +++ b/target/riscv/vector_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vnmsub_vx_b, 1, 1, clearb) | ||
85 | GEN_VEXT_VX(vnmsub_vx_h, 2, 2, clearh) | ||
86 | GEN_VEXT_VX(vnmsub_vx_w, 4, 4, clearl) | ||
87 | GEN_VEXT_VX(vnmsub_vx_d, 8, 8, clearq) | ||
88 | + | ||
89 | +/* Vector Widening Integer Multiply-Add Instructions */ | ||
90 | +RVVCALL(OPIVV3, vwmaccu_vv_b, WOP_UUU_B, H2, H1, H1, DO_MACC) | ||
91 | +RVVCALL(OPIVV3, vwmaccu_vv_h, WOP_UUU_H, H4, H2, H2, DO_MACC) | ||
92 | +RVVCALL(OPIVV3, vwmaccu_vv_w, WOP_UUU_W, H8, H4, H4, DO_MACC) | ||
93 | +RVVCALL(OPIVV3, vwmacc_vv_b, WOP_SSS_B, H2, H1, H1, DO_MACC) | ||
94 | +RVVCALL(OPIVV3, vwmacc_vv_h, WOP_SSS_H, H4, H2, H2, DO_MACC) | ||
95 | +RVVCALL(OPIVV3, vwmacc_vv_w, WOP_SSS_W, H8, H4, H4, DO_MACC) | ||
96 | +RVVCALL(OPIVV3, vwmaccsu_vv_b, WOP_SSU_B, H2, H1, H1, DO_MACC) | ||
97 | +RVVCALL(OPIVV3, vwmaccsu_vv_h, WOP_SSU_H, H4, H2, H2, DO_MACC) | ||
98 | +RVVCALL(OPIVV3, vwmaccsu_vv_w, WOP_SSU_W, H8, H4, H4, DO_MACC) | ||
99 | +GEN_VEXT_VV(vwmaccu_vv_b, 1, 2, clearh) | ||
100 | +GEN_VEXT_VV(vwmaccu_vv_h, 2, 4, clearl) | ||
101 | +GEN_VEXT_VV(vwmaccu_vv_w, 4, 8, clearq) | ||
102 | +GEN_VEXT_VV(vwmacc_vv_b, 1, 2, clearh) | ||
103 | +GEN_VEXT_VV(vwmacc_vv_h, 2, 4, clearl) | ||
104 | +GEN_VEXT_VV(vwmacc_vv_w, 4, 8, clearq) | ||
105 | +GEN_VEXT_VV(vwmaccsu_vv_b, 1, 2, clearh) | ||
106 | +GEN_VEXT_VV(vwmaccsu_vv_h, 2, 4, clearl) | ||
107 | +GEN_VEXT_VV(vwmaccsu_vv_w, 4, 8, clearq) | ||
108 | + | ||
109 | +RVVCALL(OPIVX3, vwmaccu_vx_b, WOP_UUU_B, H2, H1, DO_MACC) | ||
110 | +RVVCALL(OPIVX3, vwmaccu_vx_h, WOP_UUU_H, H4, H2, DO_MACC) | ||
111 | +RVVCALL(OPIVX3, vwmaccu_vx_w, WOP_UUU_W, H8, H4, DO_MACC) | ||
112 | +RVVCALL(OPIVX3, vwmacc_vx_b, WOP_SSS_B, H2, H1, DO_MACC) | ||
113 | +RVVCALL(OPIVX3, vwmacc_vx_h, WOP_SSS_H, H4, H2, DO_MACC) | ||
114 | +RVVCALL(OPIVX3, vwmacc_vx_w, WOP_SSS_W, H8, H4, DO_MACC) | ||
115 | +RVVCALL(OPIVX3, vwmaccsu_vx_b, WOP_SSU_B, H2, H1, DO_MACC) | ||
116 | +RVVCALL(OPIVX3, vwmaccsu_vx_h, WOP_SSU_H, H4, H2, DO_MACC) | ||
117 | +RVVCALL(OPIVX3, vwmaccsu_vx_w, WOP_SSU_W, H8, H4, DO_MACC) | ||
118 | +RVVCALL(OPIVX3, vwmaccus_vx_b, WOP_SUS_B, H2, H1, DO_MACC) | ||
119 | +RVVCALL(OPIVX3, vwmaccus_vx_h, WOP_SUS_H, H4, H2, DO_MACC) | ||
120 | +RVVCALL(OPIVX3, vwmaccus_vx_w, WOP_SUS_W, H8, H4, DO_MACC) | ||
121 | +GEN_VEXT_VX(vwmaccu_vx_b, 1, 2, clearh) | ||
122 | +GEN_VEXT_VX(vwmaccu_vx_h, 2, 4, clearl) | ||
123 | +GEN_VEXT_VX(vwmaccu_vx_w, 4, 8, clearq) | ||
124 | +GEN_VEXT_VX(vwmacc_vx_b, 1, 2, clearh) | ||
125 | +GEN_VEXT_VX(vwmacc_vx_h, 2, 4, clearl) | ||
126 | +GEN_VEXT_VX(vwmacc_vx_w, 4, 8, clearq) | ||
127 | +GEN_VEXT_VX(vwmaccsu_vx_b, 1, 2, clearh) | ||
128 | +GEN_VEXT_VX(vwmaccsu_vx_h, 2, 4, clearl) | ||
129 | +GEN_VEXT_VX(vwmaccsu_vx_w, 4, 8, clearq) | ||
130 | +GEN_VEXT_VX(vwmaccus_vx_b, 1, 2, clearh) | ||
131 | +GEN_VEXT_VX(vwmaccus_vx_h, 2, 4, clearl) | ||
132 | +GEN_VEXT_VX(vwmaccus_vx_w, 4, 8, clearq) | ||
133 | -- | ||
134 | 2.27.0 | ||
135 | |||
136 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200623215920.2594-24-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 17 ++++ | ||
10 | target/riscv/insn32.decode | 7 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 113 ++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 88 ++++++++++++++++++ | ||
13 | 4 files changed, 225 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vwmaccsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vwmaccus_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vwmaccus_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vwmaccus_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vmerge_vvm_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vmerge_vvm_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vmerge_vvm_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vmerge_vvm_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vmerge_vxm_b, void, ptr, ptr, tl, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vmerge_vxm_h, void, ptr, ptr, tl, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vmerge_vxm_w, void, ptr, ptr, tl, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vmerge_vxm_d, void, ptr, ptr, tl, ptr, env, i32) | ||
32 | +DEF_HELPER_4(vmv_v_v_b, void, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_4(vmv_v_v_h, void, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_4(vmv_v_v_w, void, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_4(vmv_v_v_d, void, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_4(vmv_v_x_b, void, ptr, i64, env, i32) | ||
37 | +DEF_HELPER_4(vmv_v_x_h, void, ptr, i64, env, i32) | ||
38 | +DEF_HELPER_4(vmv_v_x_w, void, ptr, i64, env, i32) | ||
39 | +DEF_HELPER_4(vmv_v_x_d, void, ptr, i64, env, i32) | ||
40 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn32.decode | ||
43 | +++ b/target/riscv/insn32.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | ||
46 | @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | ||
47 | @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd | ||
48 | +@r_vm_0 ...... . ..... ..... ... ..... ....... &rmrr vm=0 %rs2 %rs1 %rd | ||
49 | @r_wdvm ..... wd:1 vm:1 ..... ..... ... ..... ....... &rwdvm %rs2 %rs1 %rd | ||
50 | @r2_zimm . zimm:11 ..... ... ..... ....... %rs1 %rd | ||
51 | |||
52 | @@ -XXX,XX +XXX,XX @@ vwmacc_vx 111101 . ..... ..... 110 ..... 1010111 @r_vm | ||
53 | vwmaccsu_vv 111110 . ..... ..... 010 ..... 1010111 @r_vm | ||
54 | vwmaccsu_vx 111110 . ..... ..... 110 ..... 1010111 @r_vm | ||
55 | vwmaccus_vx 111111 . ..... ..... 110 ..... 1010111 @r_vm | ||
56 | +vmv_v_v 010111 1 00000 ..... 000 ..... 1010111 @r2 | ||
57 | +vmv_v_x 010111 1 00000 ..... 100 ..... 1010111 @r2 | ||
58 | +vmv_v_i 010111 1 00000 ..... 011 ..... 1010111 @r2 | ||
59 | +vmerge_vvm 010111 0 ..... ..... 000 ..... 1010111 @r_vm_0 | ||
60 | +vmerge_vxm 010111 0 ..... ..... 100 ..... 1010111 @r_vm_0 | ||
61 | +vmerge_vim 010111 0 ..... ..... 011 ..... 1010111 @r_vm_0 | ||
62 | |||
63 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
64 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
65 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
68 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
69 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx) | ||
70 | GEN_OPIVX_WIDEN_TRANS(vwmacc_vx) | ||
71 | GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx) | ||
72 | GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx) | ||
73 | + | ||
74 | +/* Vector Integer Merge and Move Instructions */ | ||
75 | +static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a) | ||
76 | +{ | ||
77 | + if (vext_check_isa_ill(s) && | ||
78 | + vext_check_reg(s, a->rd, false) && | ||
79 | + vext_check_reg(s, a->rs1, false)) { | ||
80 | + | ||
81 | + if (s->vl_eq_vlmax) { | ||
82 | + tcg_gen_gvec_mov(s->sew, vreg_ofs(s, a->rd), | ||
83 | + vreg_ofs(s, a->rs1), | ||
84 | + MAXSZ(s), MAXSZ(s)); | ||
85 | + } else { | ||
86 | + uint32_t data = FIELD_DP32(0, VDATA, LMUL, s->lmul); | ||
87 | + static gen_helper_gvec_2_ptr * const fns[4] = { | ||
88 | + gen_helper_vmv_v_v_b, gen_helper_vmv_v_v_h, | ||
89 | + gen_helper_vmv_v_v_w, gen_helper_vmv_v_v_d, | ||
90 | + }; | ||
91 | + TCGLabel *over = gen_new_label(); | ||
92 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
93 | + | ||
94 | + tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1), | ||
95 | + cpu_env, 0, s->vlen / 8, data, fns[s->sew]); | ||
96 | + gen_set_label(over); | ||
97 | + } | ||
98 | + return true; | ||
99 | + } | ||
100 | + return false; | ||
101 | +} | ||
102 | + | ||
103 | +typedef void gen_helper_vmv_vx(TCGv_ptr, TCGv_i64, TCGv_env, TCGv_i32); | ||
104 | +static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a) | ||
105 | +{ | ||
106 | + if (vext_check_isa_ill(s) && | ||
107 | + vext_check_reg(s, a->rd, false)) { | ||
108 | + | ||
109 | + TCGv s1; | ||
110 | + TCGLabel *over = gen_new_label(); | ||
111 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
112 | + | ||
113 | + s1 = tcg_temp_new(); | ||
114 | + gen_get_gpr(s1, a->rs1); | ||
115 | + | ||
116 | + if (s->vl_eq_vlmax) { | ||
117 | + tcg_gen_gvec_dup_tl(s->sew, vreg_ofs(s, a->rd), | ||
118 | + MAXSZ(s), MAXSZ(s), s1); | ||
119 | + } else { | ||
120 | + TCGv_i32 desc ; | ||
121 | + TCGv_i64 s1_i64 = tcg_temp_new_i64(); | ||
122 | + TCGv_ptr dest = tcg_temp_new_ptr(); | ||
123 | + uint32_t data = FIELD_DP32(0, VDATA, LMUL, s->lmul); | ||
124 | + static gen_helper_vmv_vx * const fns[4] = { | ||
125 | + gen_helper_vmv_v_x_b, gen_helper_vmv_v_x_h, | ||
126 | + gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, | ||
127 | + }; | ||
128 | + | ||
129 | + tcg_gen_ext_tl_i64(s1_i64, s1); | ||
130 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
131 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, a->rd)); | ||
132 | + fns[s->sew](dest, s1_i64, cpu_env, desc); | ||
133 | + | ||
134 | + tcg_temp_free_ptr(dest); | ||
135 | + tcg_temp_free_i32(desc); | ||
136 | + tcg_temp_free_i64(s1_i64); | ||
137 | + } | ||
138 | + | ||
139 | + tcg_temp_free(s1); | ||
140 | + gen_set_label(over); | ||
141 | + return true; | ||
142 | + } | ||
143 | + return false; | ||
144 | +} | ||
145 | + | ||
146 | +static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a) | ||
147 | +{ | ||
148 | + if (vext_check_isa_ill(s) && | ||
149 | + vext_check_reg(s, a->rd, false)) { | ||
150 | + | ||
151 | + int64_t simm = sextract64(a->rs1, 0, 5); | ||
152 | + if (s->vl_eq_vlmax) { | ||
153 | + tcg_gen_gvec_dup_imm(s->sew, vreg_ofs(s, a->rd), | ||
154 | + MAXSZ(s), MAXSZ(s), simm); | ||
155 | + } else { | ||
156 | + TCGv_i32 desc; | ||
157 | + TCGv_i64 s1; | ||
158 | + TCGv_ptr dest; | ||
159 | + uint32_t data = FIELD_DP32(0, VDATA, LMUL, s->lmul); | ||
160 | + static gen_helper_vmv_vx * const fns[4] = { | ||
161 | + gen_helper_vmv_v_x_b, gen_helper_vmv_v_x_h, | ||
162 | + gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, | ||
163 | + }; | ||
164 | + TCGLabel *over = gen_new_label(); | ||
165 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
166 | + | ||
167 | + s1 = tcg_const_i64(simm); | ||
168 | + dest = tcg_temp_new_ptr(); | ||
169 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
170 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, a->rd)); | ||
171 | + fns[s->sew](dest, s1, cpu_env, desc); | ||
172 | + | ||
173 | + tcg_temp_free_ptr(dest); | ||
174 | + tcg_temp_free_i32(desc); | ||
175 | + tcg_temp_free_i64(s1); | ||
176 | + gen_set_label(over); | ||
177 | + } | ||
178 | + return true; | ||
179 | + } | ||
180 | + return false; | ||
181 | +} | ||
182 | + | ||
183 | +GEN_OPIVV_TRANS(vmerge_vvm, opivv_vadc_check) | ||
184 | +GEN_OPIVX_TRANS(vmerge_vxm, opivx_vadc_check) | ||
185 | +GEN_OPIVI_TRANS(vmerge_vim, 0, vmerge_vxm, opivx_vadc_check) | ||
186 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
187 | index XXXXXXX..XXXXXXX 100644 | ||
188 | --- a/target/riscv/vector_helper.c | ||
189 | +++ b/target/riscv/vector_helper.c | ||
190 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX(vwmaccsu_vx_w, 4, 8, clearq) | ||
191 | GEN_VEXT_VX(vwmaccus_vx_b, 1, 2, clearh) | ||
192 | GEN_VEXT_VX(vwmaccus_vx_h, 2, 4, clearl) | ||
193 | GEN_VEXT_VX(vwmaccus_vx_w, 4, 8, clearq) | ||
194 | + | ||
195 | +/* Vector Integer Merge and Move Instructions */ | ||
196 | +#define GEN_VEXT_VMV_VV(NAME, ETYPE, H, CLEAR_FN) \ | ||
197 | +void HELPER(NAME)(void *vd, void *vs1, CPURISCVState *env, \ | ||
198 | + uint32_t desc) \ | ||
199 | +{ \ | ||
200 | + uint32_t vl = env->vl; \ | ||
201 | + uint32_t esz = sizeof(ETYPE); \ | ||
202 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
203 | + uint32_t i; \ | ||
204 | + \ | ||
205 | + for (i = 0; i < vl; i++) { \ | ||
206 | + ETYPE s1 = *((ETYPE *)vs1 + H(i)); \ | ||
207 | + *((ETYPE *)vd + H(i)) = s1; \ | ||
208 | + } \ | ||
209 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
210 | +} | ||
211 | + | ||
212 | +GEN_VEXT_VMV_VV(vmv_v_v_b, int8_t, H1, clearb) | ||
213 | +GEN_VEXT_VMV_VV(vmv_v_v_h, int16_t, H2, clearh) | ||
214 | +GEN_VEXT_VMV_VV(vmv_v_v_w, int32_t, H4, clearl) | ||
215 | +GEN_VEXT_VMV_VV(vmv_v_v_d, int64_t, H8, clearq) | ||
216 | + | ||
217 | +#define GEN_VEXT_VMV_VX(NAME, ETYPE, H, CLEAR_FN) \ | ||
218 | +void HELPER(NAME)(void *vd, uint64_t s1, CPURISCVState *env, \ | ||
219 | + uint32_t desc) \ | ||
220 | +{ \ | ||
221 | + uint32_t vl = env->vl; \ | ||
222 | + uint32_t esz = sizeof(ETYPE); \ | ||
223 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
224 | + uint32_t i; \ | ||
225 | + \ | ||
226 | + for (i = 0; i < vl; i++) { \ | ||
227 | + *((ETYPE *)vd + H(i)) = (ETYPE)s1; \ | ||
228 | + } \ | ||
229 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
230 | +} | ||
231 | + | ||
232 | +GEN_VEXT_VMV_VX(vmv_v_x_b, int8_t, H1, clearb) | ||
233 | +GEN_VEXT_VMV_VX(vmv_v_x_h, int16_t, H2, clearh) | ||
234 | +GEN_VEXT_VMV_VX(vmv_v_x_w, int32_t, H4, clearl) | ||
235 | +GEN_VEXT_VMV_VX(vmv_v_x_d, int64_t, H8, clearq) | ||
236 | + | ||
237 | +#define GEN_VEXT_VMERGE_VV(NAME, ETYPE, H, CLEAR_FN) \ | ||
238 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
239 | + CPURISCVState *env, uint32_t desc) \ | ||
240 | +{ \ | ||
241 | + uint32_t mlen = vext_mlen(desc); \ | ||
242 | + uint32_t vl = env->vl; \ | ||
243 | + uint32_t esz = sizeof(ETYPE); \ | ||
244 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
245 | + uint32_t i; \ | ||
246 | + \ | ||
247 | + for (i = 0; i < vl; i++) { \ | ||
248 | + ETYPE *vt = (!vext_elem_mask(v0, mlen, i) ? vs2 : vs1); \ | ||
249 | + *((ETYPE *)vd + H(i)) = *(vt + H(i)); \ | ||
250 | + } \ | ||
251 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
252 | +} | ||
253 | + | ||
254 | +GEN_VEXT_VMERGE_VV(vmerge_vvm_b, int8_t, H1, clearb) | ||
255 | +GEN_VEXT_VMERGE_VV(vmerge_vvm_h, int16_t, H2, clearh) | ||
256 | +GEN_VEXT_VMERGE_VV(vmerge_vvm_w, int32_t, H4, clearl) | ||
257 | +GEN_VEXT_VMERGE_VV(vmerge_vvm_d, int64_t, H8, clearq) | ||
258 | + | ||
259 | +#define GEN_VEXT_VMERGE_VX(NAME, ETYPE, H, CLEAR_FN) \ | ||
260 | +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ | ||
261 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
262 | +{ \ | ||
263 | + uint32_t mlen = vext_mlen(desc); \ | ||
264 | + uint32_t vl = env->vl; \ | ||
265 | + uint32_t esz = sizeof(ETYPE); \ | ||
266 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
267 | + uint32_t i; \ | ||
268 | + \ | ||
269 | + for (i = 0; i < vl; i++) { \ | ||
270 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
271 | + ETYPE d = (!vext_elem_mask(v0, mlen, i) ? s2 : \ | ||
272 | + (ETYPE)(target_long)s1); \ | ||
273 | + *((ETYPE *)vd + H(i)) = d; \ | ||
274 | + } \ | ||
275 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
276 | +} | ||
277 | + | ||
278 | +GEN_VEXT_VMERGE_VX(vmerge_vxm_b, int8_t, H1, clearb) | ||
279 | +GEN_VEXT_VMERGE_VX(vmerge_vxm_h, int16_t, H2, clearh) | ||
280 | +GEN_VEXT_VMERGE_VX(vmerge_vxm_w, int32_t, H4, clearl) | ||
281 | +GEN_VEXT_VMERGE_VX(vmerge_vxm_d, int64_t, H8, clearq) | ||
282 | -- | ||
283 | 2.27.0 | ||
284 | |||
285 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200623215920.2594-26-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 17 ++++ | ||
10 | target/riscv/insn32.decode | 5 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 7 ++ | ||
12 | target/riscv/vector_helper.c | 100 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 129 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vssub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vssub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vssub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vssub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vaadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vaadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vaadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vaadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vasub_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vasub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vasub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vasub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vaadd_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vaadd_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vaadd_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vaadd_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vasub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vasub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vasub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vasub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn32.decode | ||
43 | +++ b/target/riscv/insn32.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ vssubu_vv 100010 . ..... ..... 000 ..... 1010111 @r_vm | ||
45 | vssubu_vx 100010 . ..... ..... 100 ..... 1010111 @r_vm | ||
46 | vssub_vv 100011 . ..... ..... 000 ..... 1010111 @r_vm | ||
47 | vssub_vx 100011 . ..... ..... 100 ..... 1010111 @r_vm | ||
48 | +vaadd_vv 100100 . ..... ..... 000 ..... 1010111 @r_vm | ||
49 | +vaadd_vx 100100 . ..... ..... 100 ..... 1010111 @r_vm | ||
50 | +vaadd_vi 100100 . ..... ..... 011 ..... 1010111 @r_vm | ||
51 | +vasub_vv 100110 . ..... ..... 000 ..... 1010111 @r_vm | ||
52 | +vasub_vx 100110 . ..... ..... 100 ..... 1010111 @r_vm | ||
53 | |||
54 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
55 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
56 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
59 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
60 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_TRANS(vssubu_vx, opivx_check) | ||
61 | GEN_OPIVX_TRANS(vssub_vx, opivx_check) | ||
62 | GEN_OPIVI_TRANS(vsaddu_vi, 1, vsaddu_vx, opivx_check) | ||
63 | GEN_OPIVI_TRANS(vsadd_vi, 0, vsadd_vx, opivx_check) | ||
64 | + | ||
65 | +/* Vector Single-Width Averaging Add and Subtract */ | ||
66 | +GEN_OPIVV_TRANS(vaadd_vv, opivv_check) | ||
67 | +GEN_OPIVV_TRANS(vasub_vv, opivv_check) | ||
68 | +GEN_OPIVX_TRANS(vaadd_vx, opivx_check) | ||
69 | +GEN_OPIVX_TRANS(vasub_vx, opivx_check) | ||
70 | +GEN_OPIVI_TRANS(vaadd_vi, 0, vaadd_vx, opivx_check) | ||
71 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/riscv/vector_helper.c | ||
74 | +++ b/target/riscv/vector_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX_RM(vssub_vx_b, 1, 1, clearb) | ||
76 | GEN_VEXT_VX_RM(vssub_vx_h, 2, 2, clearh) | ||
77 | GEN_VEXT_VX_RM(vssub_vx_w, 4, 4, clearl) | ||
78 | GEN_VEXT_VX_RM(vssub_vx_d, 8, 8, clearq) | ||
79 | + | ||
80 | +/* Vector Single-Width Averaging Add and Subtract */ | ||
81 | +static inline uint8_t get_round(int vxrm, uint64_t v, uint8_t shift) | ||
82 | +{ | ||
83 | + uint8_t d = extract64(v, shift, 1); | ||
84 | + uint8_t d1; | ||
85 | + uint64_t D1, D2; | ||
86 | + | ||
87 | + if (shift == 0 || shift > 64) { | ||
88 | + return 0; | ||
89 | + } | ||
90 | + | ||
91 | + d1 = extract64(v, shift - 1, 1); | ||
92 | + D1 = extract64(v, 0, shift); | ||
93 | + if (vxrm == 0) { /* round-to-nearest-up (add +0.5 LSB) */ | ||
94 | + return d1; | ||
95 | + } else if (vxrm == 1) { /* round-to-nearest-even */ | ||
96 | + if (shift > 1) { | ||
97 | + D2 = extract64(v, 0, shift - 1); | ||
98 | + return d1 & ((D2 != 0) | d); | ||
99 | + } else { | ||
100 | + return d1 & d; | ||
101 | + } | ||
102 | + } else if (vxrm == 3) { /* round-to-odd (OR bits into LSB, aka "jam") */ | ||
103 | + return !d & (D1 != 0); | ||
104 | + } | ||
105 | + return 0; /* round-down (truncate) */ | ||
106 | +} | ||
107 | + | ||
108 | +static inline int32_t aadd32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) | ||
109 | +{ | ||
110 | + int64_t res = (int64_t)a + b; | ||
111 | + uint8_t round = get_round(vxrm, res, 1); | ||
112 | + | ||
113 | + return (res >> 1) + round; | ||
114 | +} | ||
115 | + | ||
116 | +static inline int64_t aadd64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
117 | +{ | ||
118 | + int64_t res = a + b; | ||
119 | + uint8_t round = get_round(vxrm, res, 1); | ||
120 | + int64_t over = (res ^ a) & (res ^ b) & INT64_MIN; | ||
121 | + | ||
122 | + /* With signed overflow, bit 64 is inverse of bit 63. */ | ||
123 | + return ((res >> 1) ^ over) + round; | ||
124 | +} | ||
125 | + | ||
126 | +RVVCALL(OPIVV2_RM, vaadd_vv_b, OP_SSS_B, H1, H1, H1, aadd32) | ||
127 | +RVVCALL(OPIVV2_RM, vaadd_vv_h, OP_SSS_H, H2, H2, H2, aadd32) | ||
128 | +RVVCALL(OPIVV2_RM, vaadd_vv_w, OP_SSS_W, H4, H4, H4, aadd32) | ||
129 | +RVVCALL(OPIVV2_RM, vaadd_vv_d, OP_SSS_D, H8, H8, H8, aadd64) | ||
130 | +GEN_VEXT_VV_RM(vaadd_vv_b, 1, 1, clearb) | ||
131 | +GEN_VEXT_VV_RM(vaadd_vv_h, 2, 2, clearh) | ||
132 | +GEN_VEXT_VV_RM(vaadd_vv_w, 4, 4, clearl) | ||
133 | +GEN_VEXT_VV_RM(vaadd_vv_d, 8, 8, clearq) | ||
134 | + | ||
135 | +RVVCALL(OPIVX2_RM, vaadd_vx_b, OP_SSS_B, H1, H1, aadd32) | ||
136 | +RVVCALL(OPIVX2_RM, vaadd_vx_h, OP_SSS_H, H2, H2, aadd32) | ||
137 | +RVVCALL(OPIVX2_RM, vaadd_vx_w, OP_SSS_W, H4, H4, aadd32) | ||
138 | +RVVCALL(OPIVX2_RM, vaadd_vx_d, OP_SSS_D, H8, H8, aadd64) | ||
139 | +GEN_VEXT_VX_RM(vaadd_vx_b, 1, 1, clearb) | ||
140 | +GEN_VEXT_VX_RM(vaadd_vx_h, 2, 2, clearh) | ||
141 | +GEN_VEXT_VX_RM(vaadd_vx_w, 4, 4, clearl) | ||
142 | +GEN_VEXT_VX_RM(vaadd_vx_d, 8, 8, clearq) | ||
143 | + | ||
144 | +static inline int32_t asub32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) | ||
145 | +{ | ||
146 | + int64_t res = (int64_t)a - b; | ||
147 | + uint8_t round = get_round(vxrm, res, 1); | ||
148 | + | ||
149 | + return (res >> 1) + round; | ||
150 | +} | ||
151 | + | ||
152 | +static inline int64_t asub64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
153 | +{ | ||
154 | + int64_t res = (int64_t)a - b; | ||
155 | + uint8_t round = get_round(vxrm, res, 1); | ||
156 | + int64_t over = (res ^ a) & (a ^ b) & INT64_MIN; | ||
157 | + | ||
158 | + /* With signed overflow, bit 64 is inverse of bit 63. */ | ||
159 | + return ((res >> 1) ^ over) + round; | ||
160 | +} | ||
161 | + | ||
162 | +RVVCALL(OPIVV2_RM, vasub_vv_b, OP_SSS_B, H1, H1, H1, asub32) | ||
163 | +RVVCALL(OPIVV2_RM, vasub_vv_h, OP_SSS_H, H2, H2, H2, asub32) | ||
164 | +RVVCALL(OPIVV2_RM, vasub_vv_w, OP_SSS_W, H4, H4, H4, asub32) | ||
165 | +RVVCALL(OPIVV2_RM, vasub_vv_d, OP_SSS_D, H8, H8, H8, asub64) | ||
166 | +GEN_VEXT_VV_RM(vasub_vv_b, 1, 1, clearb) | ||
167 | +GEN_VEXT_VV_RM(vasub_vv_h, 2, 2, clearh) | ||
168 | +GEN_VEXT_VV_RM(vasub_vv_w, 4, 4, clearl) | ||
169 | +GEN_VEXT_VV_RM(vasub_vv_d, 8, 8, clearq) | ||
170 | + | ||
171 | +RVVCALL(OPIVX2_RM, vasub_vx_b, OP_SSS_B, H1, H1, asub32) | ||
172 | +RVVCALL(OPIVX2_RM, vasub_vx_h, OP_SSS_H, H2, H2, asub32) | ||
173 | +RVVCALL(OPIVX2_RM, vasub_vx_w, OP_SSS_W, H4, H4, asub32) | ||
174 | +RVVCALL(OPIVX2_RM, vasub_vx_d, OP_SSS_D, H8, H8, asub64) | ||
175 | +GEN_VEXT_VX_RM(vasub_vx_b, 1, 1, clearb) | ||
176 | +GEN_VEXT_VX_RM(vasub_vx_h, 2, 2, clearh) | ||
177 | +GEN_VEXT_VX_RM(vasub_vx_w, 4, 4, clearl) | ||
178 | +GEN_VEXT_VX_RM(vasub_vx_d, 8, 8, clearq) | ||
179 | -- | ||
180 | 2.27.0 | ||
181 | |||
182 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200623215920.2594-27-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 9 ++ | ||
10 | target/riscv/insn32.decode | 2 + | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 4 + | ||
12 | target/riscv/vector_helper.c | 107 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 122 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vasub_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vasub_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vasub_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vasub_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vsmul_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vsmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vsmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vsmul_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vsmul_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vsmul_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vsmul_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vsmul_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
32 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/riscv/insn32.decode | ||
35 | +++ b/target/riscv/insn32.decode | ||
36 | @@ -XXX,XX +XXX,XX @@ vaadd_vx 100100 . ..... ..... 100 ..... 1010111 @r_vm | ||
37 | vaadd_vi 100100 . ..... ..... 011 ..... 1010111 @r_vm | ||
38 | vasub_vv 100110 . ..... ..... 000 ..... 1010111 @r_vm | ||
39 | vasub_vx 100110 . ..... ..... 100 ..... 1010111 @r_vm | ||
40 | +vsmul_vv 100111 . ..... ..... 000 ..... 1010111 @r_vm | ||
41 | +vsmul_vx 100111 . ..... ..... 100 ..... 1010111 @r_vm | ||
42 | |||
43 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
44 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
45 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
48 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
49 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVV_TRANS(vasub_vv, opivv_check) | ||
50 | GEN_OPIVX_TRANS(vaadd_vx, opivx_check) | ||
51 | GEN_OPIVX_TRANS(vasub_vx, opivx_check) | ||
52 | GEN_OPIVI_TRANS(vaadd_vi, 0, vaadd_vx, opivx_check) | ||
53 | + | ||
54 | +/* Vector Single-Width Fractional Multiply with Rounding and Saturation */ | ||
55 | +GEN_OPIVV_TRANS(vsmul_vv, opivv_check) | ||
56 | +GEN_OPIVX_TRANS(vsmul_vx, opivx_check) | ||
57 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/riscv/vector_helper.c | ||
60 | +++ b/target/riscv/vector_helper.c | ||
61 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX_RM(vasub_vx_b, 1, 1, clearb) | ||
62 | GEN_VEXT_VX_RM(vasub_vx_h, 2, 2, clearh) | ||
63 | GEN_VEXT_VX_RM(vasub_vx_w, 4, 4, clearl) | ||
64 | GEN_VEXT_VX_RM(vasub_vx_d, 8, 8, clearq) | ||
65 | + | ||
66 | +/* Vector Single-Width Fractional Multiply with Rounding and Saturation */ | ||
67 | +static inline int8_t vsmul8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) | ||
68 | +{ | ||
69 | + uint8_t round; | ||
70 | + int16_t res; | ||
71 | + | ||
72 | + res = (int16_t)a * (int16_t)b; | ||
73 | + round = get_round(vxrm, res, 7); | ||
74 | + res = (res >> 7) + round; | ||
75 | + | ||
76 | + if (res > INT8_MAX) { | ||
77 | + env->vxsat = 0x1; | ||
78 | + return INT8_MAX; | ||
79 | + } else if (res < INT8_MIN) { | ||
80 | + env->vxsat = 0x1; | ||
81 | + return INT8_MIN; | ||
82 | + } else { | ||
83 | + return res; | ||
84 | + } | ||
85 | +} | ||
86 | + | ||
87 | +static int16_t vsmul16(CPURISCVState *env, int vxrm, int16_t a, int16_t b) | ||
88 | +{ | ||
89 | + uint8_t round; | ||
90 | + int32_t res; | ||
91 | + | ||
92 | + res = (int32_t)a * (int32_t)b; | ||
93 | + round = get_round(vxrm, res, 15); | ||
94 | + res = (res >> 15) + round; | ||
95 | + | ||
96 | + if (res > INT16_MAX) { | ||
97 | + env->vxsat = 0x1; | ||
98 | + return INT16_MAX; | ||
99 | + } else if (res < INT16_MIN) { | ||
100 | + env->vxsat = 0x1; | ||
101 | + return INT16_MIN; | ||
102 | + } else { | ||
103 | + return res; | ||
104 | + } | ||
105 | +} | ||
106 | + | ||
107 | +static int32_t vsmul32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) | ||
108 | +{ | ||
109 | + uint8_t round; | ||
110 | + int64_t res; | ||
111 | + | ||
112 | + res = (int64_t)a * (int64_t)b; | ||
113 | + round = get_round(vxrm, res, 31); | ||
114 | + res = (res >> 31) + round; | ||
115 | + | ||
116 | + if (res > INT32_MAX) { | ||
117 | + env->vxsat = 0x1; | ||
118 | + return INT32_MAX; | ||
119 | + } else if (res < INT32_MIN) { | ||
120 | + env->vxsat = 0x1; | ||
121 | + return INT32_MIN; | ||
122 | + } else { | ||
123 | + return res; | ||
124 | + } | ||
125 | +} | ||
126 | + | ||
127 | +static int64_t vsmul64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
128 | +{ | ||
129 | + uint8_t round; | ||
130 | + uint64_t hi_64, lo_64; | ||
131 | + int64_t res; | ||
132 | + | ||
133 | + if (a == INT64_MIN && b == INT64_MIN) { | ||
134 | + env->vxsat = 1; | ||
135 | + return INT64_MAX; | ||
136 | + } | ||
137 | + | ||
138 | + muls64(&lo_64, &hi_64, a, b); | ||
139 | + round = get_round(vxrm, lo_64, 63); | ||
140 | + /* | ||
141 | + * Cannot overflow, as there are always | ||
142 | + * 2 sign bits after multiply. | ||
143 | + */ | ||
144 | + res = (hi_64 << 1) | (lo_64 >> 63); | ||
145 | + if (round) { | ||
146 | + if (res == INT64_MAX) { | ||
147 | + env->vxsat = 1; | ||
148 | + } else { | ||
149 | + res += 1; | ||
150 | + } | ||
151 | + } | ||
152 | + return res; | ||
153 | +} | ||
154 | + | ||
155 | +RVVCALL(OPIVV2_RM, vsmul_vv_b, OP_SSS_B, H1, H1, H1, vsmul8) | ||
156 | +RVVCALL(OPIVV2_RM, vsmul_vv_h, OP_SSS_H, H2, H2, H2, vsmul16) | ||
157 | +RVVCALL(OPIVV2_RM, vsmul_vv_w, OP_SSS_W, H4, H4, H4, vsmul32) | ||
158 | +RVVCALL(OPIVV2_RM, vsmul_vv_d, OP_SSS_D, H8, H8, H8, vsmul64) | ||
159 | +GEN_VEXT_VV_RM(vsmul_vv_b, 1, 1, clearb) | ||
160 | +GEN_VEXT_VV_RM(vsmul_vv_h, 2, 2, clearh) | ||
161 | +GEN_VEXT_VV_RM(vsmul_vv_w, 4, 4, clearl) | ||
162 | +GEN_VEXT_VV_RM(vsmul_vv_d, 8, 8, clearq) | ||
163 | + | ||
164 | +RVVCALL(OPIVX2_RM, vsmul_vx_b, OP_SSS_B, H1, H1, vsmul8) | ||
165 | +RVVCALL(OPIVX2_RM, vsmul_vx_h, OP_SSS_H, H2, H2, vsmul16) | ||
166 | +RVVCALL(OPIVX2_RM, vsmul_vx_w, OP_SSS_W, H4, H4, vsmul32) | ||
167 | +RVVCALL(OPIVX2_RM, vsmul_vx_d, OP_SSS_D, H8, H8, vsmul64) | ||
168 | +GEN_VEXT_VX_RM(vsmul_vx_b, 1, 1, clearb) | ||
169 | +GEN_VEXT_VX_RM(vsmul_vx_h, 2, 2, clearh) | ||
170 | +GEN_VEXT_VX_RM(vsmul_vx_w, 4, 4, clearl) | ||
171 | +GEN_VEXT_VX_RM(vsmul_vx_d, 8, 8, clearq) | ||
172 | -- | ||
173 | 2.27.0 | ||
174 | |||
175 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-28-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 22 +++ | ||
10 | target/riscv/insn32.decode | 7 + | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 9 ++ | ||
12 | target/riscv/vector_helper.c | 205 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 243 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vsmul_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vsmul_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vsmul_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vsmul_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vwsmaccu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vwsmaccu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vwsmaccu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vwsmacc_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vwsmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vwsmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vwsmaccsu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vwsmaccsu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vwsmaccsu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vwsmaccu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vwsmaccu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vwsmaccu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vwsmacc_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vwsmacc_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vwsmacc_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vwsmaccsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vwsmaccsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vwsmaccsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vwsmaccus_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vwsmaccus_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vwsmaccus_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
45 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/riscv/insn32.decode | ||
48 | +++ b/target/riscv/insn32.decode | ||
49 | @@ -XXX,XX +XXX,XX @@ vasub_vv 100110 . ..... ..... 000 ..... 1010111 @r_vm | ||
50 | vasub_vx 100110 . ..... ..... 100 ..... 1010111 @r_vm | ||
51 | vsmul_vv 100111 . ..... ..... 000 ..... 1010111 @r_vm | ||
52 | vsmul_vx 100111 . ..... ..... 100 ..... 1010111 @r_vm | ||
53 | +vwsmaccu_vv 111100 . ..... ..... 000 ..... 1010111 @r_vm | ||
54 | +vwsmaccu_vx 111100 . ..... ..... 100 ..... 1010111 @r_vm | ||
55 | +vwsmacc_vv 111101 . ..... ..... 000 ..... 1010111 @r_vm | ||
56 | +vwsmacc_vx 111101 . ..... ..... 100 ..... 1010111 @r_vm | ||
57 | +vwsmaccsu_vv 111110 . ..... ..... 000 ..... 1010111 @r_vm | ||
58 | +vwsmaccsu_vx 111110 . ..... ..... 100 ..... 1010111 @r_vm | ||
59 | +vwsmaccus_vx 111111 . ..... ..... 100 ..... 1010111 @r_vm | ||
60 | |||
61 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
62 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
63 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
66 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
67 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVI_TRANS(vaadd_vi, 0, vaadd_vx, opivx_check) | ||
68 | /* Vector Single-Width Fractional Multiply with Rounding and Saturation */ | ||
69 | GEN_OPIVV_TRANS(vsmul_vv, opivv_check) | ||
70 | GEN_OPIVX_TRANS(vsmul_vx, opivx_check) | ||
71 | + | ||
72 | +/* Vector Widening Saturating Scaled Multiply-Add */ | ||
73 | +GEN_OPIVV_WIDEN_TRANS(vwsmaccu_vv, opivv_widen_check) | ||
74 | +GEN_OPIVV_WIDEN_TRANS(vwsmacc_vv, opivv_widen_check) | ||
75 | +GEN_OPIVV_WIDEN_TRANS(vwsmaccsu_vv, opivv_widen_check) | ||
76 | +GEN_OPIVX_WIDEN_TRANS(vwsmaccu_vx) | ||
77 | +GEN_OPIVX_WIDEN_TRANS(vwsmacc_vx) | ||
78 | +GEN_OPIVX_WIDEN_TRANS(vwsmaccsu_vx) | ||
79 | +GEN_OPIVX_WIDEN_TRANS(vwsmaccus_vx) | ||
80 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/riscv/vector_helper.c | ||
83 | +++ b/target/riscv/vector_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX_RM(vsmul_vx_b, 1, 1, clearb) | ||
85 | GEN_VEXT_VX_RM(vsmul_vx_h, 2, 2, clearh) | ||
86 | GEN_VEXT_VX_RM(vsmul_vx_w, 4, 4, clearl) | ||
87 | GEN_VEXT_VX_RM(vsmul_vx_d, 8, 8, clearq) | ||
88 | + | ||
89 | +/* Vector Widening Saturating Scaled Multiply-Add */ | ||
90 | +static inline uint16_t | ||
91 | +vwsmaccu8(CPURISCVState *env, int vxrm, uint8_t a, uint8_t b, | ||
92 | + uint16_t c) | ||
93 | +{ | ||
94 | + uint8_t round; | ||
95 | + uint16_t res = (uint16_t)a * b; | ||
96 | + | ||
97 | + round = get_round(vxrm, res, 4); | ||
98 | + res = (res >> 4) + round; | ||
99 | + return saddu16(env, vxrm, c, res); | ||
100 | +} | ||
101 | + | ||
102 | +static inline uint32_t | ||
103 | +vwsmaccu16(CPURISCVState *env, int vxrm, uint16_t a, uint16_t b, | ||
104 | + uint32_t c) | ||
105 | +{ | ||
106 | + uint8_t round; | ||
107 | + uint32_t res = (uint32_t)a * b; | ||
108 | + | ||
109 | + round = get_round(vxrm, res, 8); | ||
110 | + res = (res >> 8) + round; | ||
111 | + return saddu32(env, vxrm, c, res); | ||
112 | +} | ||
113 | + | ||
114 | +static inline uint64_t | ||
115 | +vwsmaccu32(CPURISCVState *env, int vxrm, uint32_t a, uint32_t b, | ||
116 | + uint64_t c) | ||
117 | +{ | ||
118 | + uint8_t round; | ||
119 | + uint64_t res = (uint64_t)a * b; | ||
120 | + | ||
121 | + round = get_round(vxrm, res, 16); | ||
122 | + res = (res >> 16) + round; | ||
123 | + return saddu64(env, vxrm, c, res); | ||
124 | +} | ||
125 | + | ||
126 | +#define OPIVV3_RM(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ | ||
127 | +static inline void \ | ||
128 | +do_##NAME(void *vd, void *vs1, void *vs2, int i, \ | ||
129 | + CPURISCVState *env, int vxrm) \ | ||
130 | +{ \ | ||
131 | + TX1 s1 = *((T1 *)vs1 + HS1(i)); \ | ||
132 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
133 | + TD d = *((TD *)vd + HD(i)); \ | ||
134 | + *((TD *)vd + HD(i)) = OP(env, vxrm, s2, s1, d); \ | ||
135 | +} | ||
136 | + | ||
137 | +RVVCALL(OPIVV3_RM, vwsmaccu_vv_b, WOP_UUU_B, H2, H1, H1, vwsmaccu8) | ||
138 | +RVVCALL(OPIVV3_RM, vwsmaccu_vv_h, WOP_UUU_H, H4, H2, H2, vwsmaccu16) | ||
139 | +RVVCALL(OPIVV3_RM, vwsmaccu_vv_w, WOP_UUU_W, H8, H4, H4, vwsmaccu32) | ||
140 | +GEN_VEXT_VV_RM(vwsmaccu_vv_b, 1, 2, clearh) | ||
141 | +GEN_VEXT_VV_RM(vwsmaccu_vv_h, 2, 4, clearl) | ||
142 | +GEN_VEXT_VV_RM(vwsmaccu_vv_w, 4, 8, clearq) | ||
143 | + | ||
144 | +#define OPIVX3_RM(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ | ||
145 | +static inline void \ | ||
146 | +do_##NAME(void *vd, target_long s1, void *vs2, int i, \ | ||
147 | + CPURISCVState *env, int vxrm) \ | ||
148 | +{ \ | ||
149 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
150 | + TD d = *((TD *)vd + HD(i)); \ | ||
151 | + *((TD *)vd + HD(i)) = OP(env, vxrm, s2, (TX1)(T1)s1, d); \ | ||
152 | +} | ||
153 | + | ||
154 | +RVVCALL(OPIVX3_RM, vwsmaccu_vx_b, WOP_UUU_B, H2, H1, vwsmaccu8) | ||
155 | +RVVCALL(OPIVX3_RM, vwsmaccu_vx_h, WOP_UUU_H, H4, H2, vwsmaccu16) | ||
156 | +RVVCALL(OPIVX3_RM, vwsmaccu_vx_w, WOP_UUU_W, H8, H4, vwsmaccu32) | ||
157 | +GEN_VEXT_VX_RM(vwsmaccu_vx_b, 1, 2, clearh) | ||
158 | +GEN_VEXT_VX_RM(vwsmaccu_vx_h, 2, 4, clearl) | ||
159 | +GEN_VEXT_VX_RM(vwsmaccu_vx_w, 4, 8, clearq) | ||
160 | + | ||
161 | +static inline int16_t | ||
162 | +vwsmacc8(CPURISCVState *env, int vxrm, int8_t a, int8_t b, int16_t c) | ||
163 | +{ | ||
164 | + uint8_t round; | ||
165 | + int16_t res = (int16_t)a * b; | ||
166 | + | ||
167 | + round = get_round(vxrm, res, 4); | ||
168 | + res = (res >> 4) + round; | ||
169 | + return sadd16(env, vxrm, c, res); | ||
170 | +} | ||
171 | + | ||
172 | +static inline int32_t | ||
173 | +vwsmacc16(CPURISCVState *env, int vxrm, int16_t a, int16_t b, int32_t c) | ||
174 | +{ | ||
175 | + uint8_t round; | ||
176 | + int32_t res = (int32_t)a * b; | ||
177 | + | ||
178 | + round = get_round(vxrm, res, 8); | ||
179 | + res = (res >> 8) + round; | ||
180 | + return sadd32(env, vxrm, c, res); | ||
181 | + | ||
182 | +} | ||
183 | + | ||
184 | +static inline int64_t | ||
185 | +vwsmacc32(CPURISCVState *env, int vxrm, int32_t a, int32_t b, int64_t c) | ||
186 | +{ | ||
187 | + uint8_t round; | ||
188 | + int64_t res = (int64_t)a * b; | ||
189 | + | ||
190 | + round = get_round(vxrm, res, 16); | ||
191 | + res = (res >> 16) + round; | ||
192 | + return sadd64(env, vxrm, c, res); | ||
193 | +} | ||
194 | + | ||
195 | +RVVCALL(OPIVV3_RM, vwsmacc_vv_b, WOP_SSS_B, H2, H1, H1, vwsmacc8) | ||
196 | +RVVCALL(OPIVV3_RM, vwsmacc_vv_h, WOP_SSS_H, H4, H2, H2, vwsmacc16) | ||
197 | +RVVCALL(OPIVV3_RM, vwsmacc_vv_w, WOP_SSS_W, H8, H4, H4, vwsmacc32) | ||
198 | +GEN_VEXT_VV_RM(vwsmacc_vv_b, 1, 2, clearh) | ||
199 | +GEN_VEXT_VV_RM(vwsmacc_vv_h, 2, 4, clearl) | ||
200 | +GEN_VEXT_VV_RM(vwsmacc_vv_w, 4, 8, clearq) | ||
201 | +RVVCALL(OPIVX3_RM, vwsmacc_vx_b, WOP_SSS_B, H2, H1, vwsmacc8) | ||
202 | +RVVCALL(OPIVX3_RM, vwsmacc_vx_h, WOP_SSS_H, H4, H2, vwsmacc16) | ||
203 | +RVVCALL(OPIVX3_RM, vwsmacc_vx_w, WOP_SSS_W, H8, H4, vwsmacc32) | ||
204 | +GEN_VEXT_VX_RM(vwsmacc_vx_b, 1, 2, clearh) | ||
205 | +GEN_VEXT_VX_RM(vwsmacc_vx_h, 2, 4, clearl) | ||
206 | +GEN_VEXT_VX_RM(vwsmacc_vx_w, 4, 8, clearq) | ||
207 | + | ||
208 | +static inline int16_t | ||
209 | +vwsmaccsu8(CPURISCVState *env, int vxrm, uint8_t a, int8_t b, int16_t c) | ||
210 | +{ | ||
211 | + uint8_t round; | ||
212 | + int16_t res = a * (int16_t)b; | ||
213 | + | ||
214 | + round = get_round(vxrm, res, 4); | ||
215 | + res = (res >> 4) + round; | ||
216 | + return ssub16(env, vxrm, c, res); | ||
217 | +} | ||
218 | + | ||
219 | +static inline int32_t | ||
220 | +vwsmaccsu16(CPURISCVState *env, int vxrm, uint16_t a, int16_t b, uint32_t c) | ||
221 | +{ | ||
222 | + uint8_t round; | ||
223 | + int32_t res = a * (int32_t)b; | ||
224 | + | ||
225 | + round = get_round(vxrm, res, 8); | ||
226 | + res = (res >> 8) + round; | ||
227 | + return ssub32(env, vxrm, c, res); | ||
228 | +} | ||
229 | + | ||
230 | +static inline int64_t | ||
231 | +vwsmaccsu32(CPURISCVState *env, int vxrm, uint32_t a, int32_t b, int64_t c) | ||
232 | +{ | ||
233 | + uint8_t round; | ||
234 | + int64_t res = a * (int64_t)b; | ||
235 | + | ||
236 | + round = get_round(vxrm, res, 16); | ||
237 | + res = (res >> 16) + round; | ||
238 | + return ssub64(env, vxrm, c, res); | ||
239 | +} | ||
240 | + | ||
241 | +RVVCALL(OPIVV3_RM, vwsmaccsu_vv_b, WOP_SSU_B, H2, H1, H1, vwsmaccsu8) | ||
242 | +RVVCALL(OPIVV3_RM, vwsmaccsu_vv_h, WOP_SSU_H, H4, H2, H2, vwsmaccsu16) | ||
243 | +RVVCALL(OPIVV3_RM, vwsmaccsu_vv_w, WOP_SSU_W, H8, H4, H4, vwsmaccsu32) | ||
244 | +GEN_VEXT_VV_RM(vwsmaccsu_vv_b, 1, 2, clearh) | ||
245 | +GEN_VEXT_VV_RM(vwsmaccsu_vv_h, 2, 4, clearl) | ||
246 | +GEN_VEXT_VV_RM(vwsmaccsu_vv_w, 4, 8, clearq) | ||
247 | +RVVCALL(OPIVX3_RM, vwsmaccsu_vx_b, WOP_SSU_B, H2, H1, vwsmaccsu8) | ||
248 | +RVVCALL(OPIVX3_RM, vwsmaccsu_vx_h, WOP_SSU_H, H4, H2, vwsmaccsu16) | ||
249 | +RVVCALL(OPIVX3_RM, vwsmaccsu_vx_w, WOP_SSU_W, H8, H4, vwsmaccsu32) | ||
250 | +GEN_VEXT_VX_RM(vwsmaccsu_vx_b, 1, 2, clearh) | ||
251 | +GEN_VEXT_VX_RM(vwsmaccsu_vx_h, 2, 4, clearl) | ||
252 | +GEN_VEXT_VX_RM(vwsmaccsu_vx_w, 4, 8, clearq) | ||
253 | + | ||
254 | +static inline int16_t | ||
255 | +vwsmaccus8(CPURISCVState *env, int vxrm, int8_t a, uint8_t b, int16_t c) | ||
256 | +{ | ||
257 | + uint8_t round; | ||
258 | + int16_t res = (int16_t)a * b; | ||
259 | + | ||
260 | + round = get_round(vxrm, res, 4); | ||
261 | + res = (res >> 4) + round; | ||
262 | + return ssub16(env, vxrm, c, res); | ||
263 | +} | ||
264 | + | ||
265 | +static inline int32_t | ||
266 | +vwsmaccus16(CPURISCVState *env, int vxrm, int16_t a, uint16_t b, int32_t c) | ||
267 | +{ | ||
268 | + uint8_t round; | ||
269 | + int32_t res = (int32_t)a * b; | ||
270 | + | ||
271 | + round = get_round(vxrm, res, 8); | ||
272 | + res = (res >> 8) + round; | ||
273 | + return ssub32(env, vxrm, c, res); | ||
274 | +} | ||
275 | + | ||
276 | +static inline int64_t | ||
277 | +vwsmaccus32(CPURISCVState *env, int vxrm, int32_t a, uint32_t b, int64_t c) | ||
278 | +{ | ||
279 | + uint8_t round; | ||
280 | + int64_t res = (int64_t)a * b; | ||
281 | + | ||
282 | + round = get_round(vxrm, res, 16); | ||
283 | + res = (res >> 16) + round; | ||
284 | + return ssub64(env, vxrm, c, res); | ||
285 | +} | ||
286 | + | ||
287 | +RVVCALL(OPIVX3_RM, vwsmaccus_vx_b, WOP_SUS_B, H2, H1, vwsmaccus8) | ||
288 | +RVVCALL(OPIVX3_RM, vwsmaccus_vx_h, WOP_SUS_H, H4, H2, vwsmaccus16) | ||
289 | +RVVCALL(OPIVX3_RM, vwsmaccus_vx_w, WOP_SUS_W, H8, H4, vwsmaccus32) | ||
290 | +GEN_VEXT_VX_RM(vwsmaccus_vx_b, 1, 2, clearh) | ||
291 | +GEN_VEXT_VX_RM(vwsmaccus_vx_h, 2, 4, clearl) | ||
292 | +GEN_VEXT_VX_RM(vwsmaccus_vx_w, 4, 8, clearq) | ||
293 | -- | ||
294 | 2.27.0 | ||
295 | |||
296 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-29-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 17 ++++ | ||
10 | target/riscv/insn32.decode | 6 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 8 ++ | ||
12 | target/riscv/vector_helper.c | 117 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 148 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vwsmaccsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vwsmaccus_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vwsmaccus_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vwsmaccus_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vssrl_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vssrl_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vssrl_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vssrl_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vssra_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vssra_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vssra_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vssra_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vssrl_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vssrl_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vssrl_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vssrl_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vssra_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vssra_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vssra_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vssra_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
40 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn32.decode | ||
43 | +++ b/target/riscv/insn32.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ vwsmacc_vx 111101 . ..... ..... 100 ..... 1010111 @r_vm | ||
45 | vwsmaccsu_vv 111110 . ..... ..... 000 ..... 1010111 @r_vm | ||
46 | vwsmaccsu_vx 111110 . ..... ..... 100 ..... 1010111 @r_vm | ||
47 | vwsmaccus_vx 111111 . ..... ..... 100 ..... 1010111 @r_vm | ||
48 | +vssrl_vv 101010 . ..... ..... 000 ..... 1010111 @r_vm | ||
49 | +vssrl_vx 101010 . ..... ..... 100 ..... 1010111 @r_vm | ||
50 | +vssrl_vi 101010 . ..... ..... 011 ..... 1010111 @r_vm | ||
51 | +vssra_vv 101011 . ..... ..... 000 ..... 1010111 @r_vm | ||
52 | +vssra_vx 101011 . ..... ..... 100 ..... 1010111 @r_vm | ||
53 | +vssra_vi 101011 . ..... ..... 011 ..... 1010111 @r_vm | ||
54 | |||
55 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
56 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
57 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
60 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
61 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_WIDEN_TRANS(vwsmaccu_vx) | ||
62 | GEN_OPIVX_WIDEN_TRANS(vwsmacc_vx) | ||
63 | GEN_OPIVX_WIDEN_TRANS(vwsmaccsu_vx) | ||
64 | GEN_OPIVX_WIDEN_TRANS(vwsmaccus_vx) | ||
65 | + | ||
66 | +/* Vector Single-Width Scaling Shift Instructions */ | ||
67 | +GEN_OPIVV_TRANS(vssrl_vv, opivv_check) | ||
68 | +GEN_OPIVV_TRANS(vssra_vv, opivv_check) | ||
69 | +GEN_OPIVX_TRANS(vssrl_vx, opivx_check) | ||
70 | +GEN_OPIVX_TRANS(vssra_vx, opivx_check) | ||
71 | +GEN_OPIVI_TRANS(vssrl_vi, 1, vssrl_vx, opivx_check) | ||
72 | +GEN_OPIVI_TRANS(vssra_vi, 0, vssra_vx, opivx_check) | ||
73 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/riscv/vector_helper.c | ||
76 | +++ b/target/riscv/vector_helper.c | ||
77 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPIVX3_RM, vwsmaccus_vx_w, WOP_SUS_W, H8, H4, vwsmaccus32) | ||
78 | GEN_VEXT_VX_RM(vwsmaccus_vx_b, 1, 2, clearh) | ||
79 | GEN_VEXT_VX_RM(vwsmaccus_vx_h, 2, 4, clearl) | ||
80 | GEN_VEXT_VX_RM(vwsmaccus_vx_w, 4, 8, clearq) | ||
81 | + | ||
82 | +/* Vector Single-Width Scaling Shift Instructions */ | ||
83 | +static inline uint8_t | ||
84 | +vssrl8(CPURISCVState *env, int vxrm, uint8_t a, uint8_t b) | ||
85 | +{ | ||
86 | + uint8_t round, shift = b & 0x7; | ||
87 | + uint8_t res; | ||
88 | + | ||
89 | + round = get_round(vxrm, a, shift); | ||
90 | + res = (a >> shift) + round; | ||
91 | + return res; | ||
92 | +} | ||
93 | +static inline uint16_t | ||
94 | +vssrl16(CPURISCVState *env, int vxrm, uint16_t a, uint16_t b) | ||
95 | +{ | ||
96 | + uint8_t round, shift = b & 0xf; | ||
97 | + uint16_t res; | ||
98 | + | ||
99 | + round = get_round(vxrm, a, shift); | ||
100 | + res = (a >> shift) + round; | ||
101 | + return res; | ||
102 | +} | ||
103 | +static inline uint32_t | ||
104 | +vssrl32(CPURISCVState *env, int vxrm, uint32_t a, uint32_t b) | ||
105 | +{ | ||
106 | + uint8_t round, shift = b & 0x1f; | ||
107 | + uint32_t res; | ||
108 | + | ||
109 | + round = get_round(vxrm, a, shift); | ||
110 | + res = (a >> shift) + round; | ||
111 | + return res; | ||
112 | +} | ||
113 | +static inline uint64_t | ||
114 | +vssrl64(CPURISCVState *env, int vxrm, uint64_t a, uint64_t b) | ||
115 | +{ | ||
116 | + uint8_t round, shift = b & 0x3f; | ||
117 | + uint64_t res; | ||
118 | + | ||
119 | + round = get_round(vxrm, a, shift); | ||
120 | + res = (a >> shift) + round; | ||
121 | + return res; | ||
122 | +} | ||
123 | +RVVCALL(OPIVV2_RM, vssrl_vv_b, OP_UUU_B, H1, H1, H1, vssrl8) | ||
124 | +RVVCALL(OPIVV2_RM, vssrl_vv_h, OP_UUU_H, H2, H2, H2, vssrl16) | ||
125 | +RVVCALL(OPIVV2_RM, vssrl_vv_w, OP_UUU_W, H4, H4, H4, vssrl32) | ||
126 | +RVVCALL(OPIVV2_RM, vssrl_vv_d, OP_UUU_D, H8, H8, H8, vssrl64) | ||
127 | +GEN_VEXT_VV_RM(vssrl_vv_b, 1, 1, clearb) | ||
128 | +GEN_VEXT_VV_RM(vssrl_vv_h, 2, 2, clearh) | ||
129 | +GEN_VEXT_VV_RM(vssrl_vv_w, 4, 4, clearl) | ||
130 | +GEN_VEXT_VV_RM(vssrl_vv_d, 8, 8, clearq) | ||
131 | + | ||
132 | +RVVCALL(OPIVX2_RM, vssrl_vx_b, OP_UUU_B, H1, H1, vssrl8) | ||
133 | +RVVCALL(OPIVX2_RM, vssrl_vx_h, OP_UUU_H, H2, H2, vssrl16) | ||
134 | +RVVCALL(OPIVX2_RM, vssrl_vx_w, OP_UUU_W, H4, H4, vssrl32) | ||
135 | +RVVCALL(OPIVX2_RM, vssrl_vx_d, OP_UUU_D, H8, H8, vssrl64) | ||
136 | +GEN_VEXT_VX_RM(vssrl_vx_b, 1, 1, clearb) | ||
137 | +GEN_VEXT_VX_RM(vssrl_vx_h, 2, 2, clearh) | ||
138 | +GEN_VEXT_VX_RM(vssrl_vx_w, 4, 4, clearl) | ||
139 | +GEN_VEXT_VX_RM(vssrl_vx_d, 8, 8, clearq) | ||
140 | + | ||
141 | +static inline int8_t | ||
142 | +vssra8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) | ||
143 | +{ | ||
144 | + uint8_t round, shift = b & 0x7; | ||
145 | + int8_t res; | ||
146 | + | ||
147 | + round = get_round(vxrm, a, shift); | ||
148 | + res = (a >> shift) + round; | ||
149 | + return res; | ||
150 | +} | ||
151 | +static inline int16_t | ||
152 | +vssra16(CPURISCVState *env, int vxrm, int16_t a, int16_t b) | ||
153 | +{ | ||
154 | + uint8_t round, shift = b & 0xf; | ||
155 | + int16_t res; | ||
156 | + | ||
157 | + round = get_round(vxrm, a, shift); | ||
158 | + res = (a >> shift) + round; | ||
159 | + return res; | ||
160 | +} | ||
161 | +static inline int32_t | ||
162 | +vssra32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) | ||
163 | +{ | ||
164 | + uint8_t round, shift = b & 0x1f; | ||
165 | + int32_t res; | ||
166 | + | ||
167 | + round = get_round(vxrm, a, shift); | ||
168 | + res = (a >> shift) + round; | ||
169 | + return res; | ||
170 | +} | ||
171 | +static inline int64_t | ||
172 | +vssra64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
173 | +{ | ||
174 | + uint8_t round, shift = b & 0x3f; | ||
175 | + int64_t res; | ||
176 | + | ||
177 | + round = get_round(vxrm, a, shift); | ||
178 | + res = (a >> shift) + round; | ||
179 | + return res; | ||
180 | +} | ||
181 | +RVVCALL(OPIVV2_RM, vssra_vv_b, OP_SSS_B, H1, H1, H1, vssra8) | ||
182 | +RVVCALL(OPIVV2_RM, vssra_vv_h, OP_SSS_H, H2, H2, H2, vssra16) | ||
183 | +RVVCALL(OPIVV2_RM, vssra_vv_w, OP_SSS_W, H4, H4, H4, vssra32) | ||
184 | +RVVCALL(OPIVV2_RM, vssra_vv_d, OP_SSS_D, H8, H8, H8, vssra64) | ||
185 | +GEN_VEXT_VV_RM(vssra_vv_b, 1, 1, clearb) | ||
186 | +GEN_VEXT_VV_RM(vssra_vv_h, 2, 2, clearh) | ||
187 | +GEN_VEXT_VV_RM(vssra_vv_w, 4, 4, clearl) | ||
188 | +GEN_VEXT_VV_RM(vssra_vv_d, 8, 8, clearq) | ||
189 | + | ||
190 | +RVVCALL(OPIVX2_RM, vssra_vx_b, OP_SSS_B, H1, H1, vssra8) | ||
191 | +RVVCALL(OPIVX2_RM, vssra_vx_h, OP_SSS_H, H2, H2, vssra16) | ||
192 | +RVVCALL(OPIVX2_RM, vssra_vx_w, OP_SSS_W, H4, H4, vssra32) | ||
193 | +RVVCALL(OPIVX2_RM, vssra_vx_d, OP_SSS_D, H8, H8, vssra64) | ||
194 | +GEN_VEXT_VX_RM(vssra_vx_b, 1, 1, clearb) | ||
195 | +GEN_VEXT_VX_RM(vssra_vx_h, 2, 2, clearh) | ||
196 | +GEN_VEXT_VX_RM(vssra_vx_w, 4, 4, clearl) | ||
197 | +GEN_VEXT_VX_RM(vssra_vx_d, 8, 8, clearq) | ||
198 | -- | ||
199 | 2.27.0 | ||
200 | |||
201 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-30-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 13 +++ | ||
10 | target/riscv/insn32.decode | 6 + | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 8 ++ | ||
12 | target/riscv/vector_helper.c | 141 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 168 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vssra_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vssra_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vssra_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vssra_vx_d, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vnclip_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vnclip_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vnclip_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vnclipu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vnclipu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vnclipu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vnclipu_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vnclipu_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vnclipu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vnclip_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vnclip_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vnclip_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
36 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/riscv/insn32.decode | ||
39 | +++ b/target/riscv/insn32.decode | ||
40 | @@ -XXX,XX +XXX,XX @@ vssrl_vi 101010 . ..... ..... 011 ..... 1010111 @r_vm | ||
41 | vssra_vv 101011 . ..... ..... 000 ..... 1010111 @r_vm | ||
42 | vssra_vx 101011 . ..... ..... 100 ..... 1010111 @r_vm | ||
43 | vssra_vi 101011 . ..... ..... 011 ..... 1010111 @r_vm | ||
44 | +vnclipu_vv 101110 . ..... ..... 000 ..... 1010111 @r_vm | ||
45 | +vnclipu_vx 101110 . ..... ..... 100 ..... 1010111 @r_vm | ||
46 | +vnclipu_vi 101110 . ..... ..... 011 ..... 1010111 @r_vm | ||
47 | +vnclip_vv 101111 . ..... ..... 000 ..... 1010111 @r_vm | ||
48 | +vnclip_vx 101111 . ..... ..... 100 ..... 1010111 @r_vm | ||
49 | +vnclip_vi 101111 . ..... ..... 011 ..... 1010111 @r_vm | ||
50 | |||
51 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
52 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
53 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
56 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
57 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_TRANS(vssrl_vx, opivx_check) | ||
58 | GEN_OPIVX_TRANS(vssra_vx, opivx_check) | ||
59 | GEN_OPIVI_TRANS(vssrl_vi, 1, vssrl_vx, opivx_check) | ||
60 | GEN_OPIVI_TRANS(vssra_vi, 0, vssra_vx, opivx_check) | ||
61 | + | ||
62 | +/* Vector Narrowing Fixed-Point Clip Instructions */ | ||
63 | +GEN_OPIVV_NARROW_TRANS(vnclipu_vv) | ||
64 | +GEN_OPIVV_NARROW_TRANS(vnclip_vv) | ||
65 | +GEN_OPIVX_NARROW_TRANS(vnclipu_vx) | ||
66 | +GEN_OPIVX_NARROW_TRANS(vnclip_vx) | ||
67 | +GEN_OPIVI_NARROW_TRANS(vnclipu_vi, 1, vnclipu_vx) | ||
68 | +GEN_OPIVI_NARROW_TRANS(vnclip_vi, 1, vnclip_vx) | ||
69 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/riscv/vector_helper.c | ||
72 | +++ b/target/riscv/vector_helper.c | ||
73 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO(vamomaxuw_v_w, uint32_t, uint32_t, idx_w, clearl) | ||
74 | #define WOP_SSU_B int16_t, int8_t, uint8_t, int16_t, uint16_t | ||
75 | #define WOP_SSU_H int32_t, int16_t, uint16_t, int32_t, uint32_t | ||
76 | #define WOP_SSU_W int64_t, int32_t, uint32_t, int64_t, uint64_t | ||
77 | +#define NOP_SSS_B int8_t, int8_t, int16_t, int8_t, int16_t | ||
78 | +#define NOP_SSS_H int16_t, int16_t, int32_t, int16_t, int32_t | ||
79 | +#define NOP_SSS_W int32_t, int32_t, int64_t, int32_t, int64_t | ||
80 | +#define NOP_UUU_B uint8_t, uint8_t, uint16_t, uint8_t, uint16_t | ||
81 | +#define NOP_UUU_H uint16_t, uint16_t, uint32_t, uint16_t, uint32_t | ||
82 | +#define NOP_UUU_W uint32_t, uint32_t, uint64_t, uint32_t, uint64_t | ||
83 | |||
84 | /* operation of two vector elements */ | ||
85 | typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); | ||
86 | @@ -XXX,XX +XXX,XX @@ vssra64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
87 | res = (a >> shift) + round; | ||
88 | return res; | ||
89 | } | ||
90 | + | ||
91 | RVVCALL(OPIVV2_RM, vssra_vv_b, OP_SSS_B, H1, H1, H1, vssra8) | ||
92 | RVVCALL(OPIVV2_RM, vssra_vv_h, OP_SSS_H, H2, H2, H2, vssra16) | ||
93 | RVVCALL(OPIVV2_RM, vssra_vv_w, OP_SSS_W, H4, H4, H4, vssra32) | ||
94 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VX_RM(vssra_vx_b, 1, 1, clearb) | ||
95 | GEN_VEXT_VX_RM(vssra_vx_h, 2, 2, clearh) | ||
96 | GEN_VEXT_VX_RM(vssra_vx_w, 4, 4, clearl) | ||
97 | GEN_VEXT_VX_RM(vssra_vx_d, 8, 8, clearq) | ||
98 | + | ||
99 | +/* Vector Narrowing Fixed-Point Clip Instructions */ | ||
100 | +static inline int8_t | ||
101 | +vnclip8(CPURISCVState *env, int vxrm, int16_t a, int8_t b) | ||
102 | +{ | ||
103 | + uint8_t round, shift = b & 0xf; | ||
104 | + int16_t res; | ||
105 | + | ||
106 | + round = get_round(vxrm, a, shift); | ||
107 | + res = (a >> shift) + round; | ||
108 | + if (res > INT8_MAX) { | ||
109 | + env->vxsat = 0x1; | ||
110 | + return INT8_MAX; | ||
111 | + } else if (res < INT8_MIN) { | ||
112 | + env->vxsat = 0x1; | ||
113 | + return INT8_MIN; | ||
114 | + } else { | ||
115 | + return res; | ||
116 | + } | ||
117 | +} | ||
118 | + | ||
119 | +static inline int16_t | ||
120 | +vnclip16(CPURISCVState *env, int vxrm, int32_t a, int16_t b) | ||
121 | +{ | ||
122 | + uint8_t round, shift = b & 0x1f; | ||
123 | + int32_t res; | ||
124 | + | ||
125 | + round = get_round(vxrm, a, shift); | ||
126 | + res = (a >> shift) + round; | ||
127 | + if (res > INT16_MAX) { | ||
128 | + env->vxsat = 0x1; | ||
129 | + return INT16_MAX; | ||
130 | + } else if (res < INT16_MIN) { | ||
131 | + env->vxsat = 0x1; | ||
132 | + return INT16_MIN; | ||
133 | + } else { | ||
134 | + return res; | ||
135 | + } | ||
136 | +} | ||
137 | + | ||
138 | +static inline int32_t | ||
139 | +vnclip32(CPURISCVState *env, int vxrm, int64_t a, int32_t b) | ||
140 | +{ | ||
141 | + uint8_t round, shift = b & 0x3f; | ||
142 | + int64_t res; | ||
143 | + | ||
144 | + round = get_round(vxrm, a, shift); | ||
145 | + res = (a >> shift) + round; | ||
146 | + if (res > INT32_MAX) { | ||
147 | + env->vxsat = 0x1; | ||
148 | + return INT32_MAX; | ||
149 | + } else if (res < INT32_MIN) { | ||
150 | + env->vxsat = 0x1; | ||
151 | + return INT32_MIN; | ||
152 | + } else { | ||
153 | + return res; | ||
154 | + } | ||
155 | +} | ||
156 | + | ||
157 | +RVVCALL(OPIVV2_RM, vnclip_vv_b, NOP_SSS_B, H1, H2, H1, vnclip8) | ||
158 | +RVVCALL(OPIVV2_RM, vnclip_vv_h, NOP_SSS_H, H2, H4, H2, vnclip16) | ||
159 | +RVVCALL(OPIVV2_RM, vnclip_vv_w, NOP_SSS_W, H4, H8, H4, vnclip32) | ||
160 | +GEN_VEXT_VV_RM(vnclip_vv_b, 1, 1, clearb) | ||
161 | +GEN_VEXT_VV_RM(vnclip_vv_h, 2, 2, clearh) | ||
162 | +GEN_VEXT_VV_RM(vnclip_vv_w, 4, 4, clearl) | ||
163 | + | ||
164 | +RVVCALL(OPIVX2_RM, vnclip_vx_b, NOP_SSS_B, H1, H2, vnclip8) | ||
165 | +RVVCALL(OPIVX2_RM, vnclip_vx_h, NOP_SSS_H, H2, H4, vnclip16) | ||
166 | +RVVCALL(OPIVX2_RM, vnclip_vx_w, NOP_SSS_W, H4, H8, vnclip32) | ||
167 | +GEN_VEXT_VX_RM(vnclip_vx_b, 1, 1, clearb) | ||
168 | +GEN_VEXT_VX_RM(vnclip_vx_h, 2, 2, clearh) | ||
169 | +GEN_VEXT_VX_RM(vnclip_vx_w, 4, 4, clearl) | ||
170 | + | ||
171 | +static inline uint8_t | ||
172 | +vnclipu8(CPURISCVState *env, int vxrm, uint16_t a, uint8_t b) | ||
173 | +{ | ||
174 | + uint8_t round, shift = b & 0xf; | ||
175 | + uint16_t res; | ||
176 | + | ||
177 | + round = get_round(vxrm, a, shift); | ||
178 | + res = (a >> shift) + round; | ||
179 | + if (res > UINT8_MAX) { | ||
180 | + env->vxsat = 0x1; | ||
181 | + return UINT8_MAX; | ||
182 | + } else { | ||
183 | + return res; | ||
184 | + } | ||
185 | +} | ||
186 | + | ||
187 | +static inline uint16_t | ||
188 | +vnclipu16(CPURISCVState *env, int vxrm, uint32_t a, uint16_t b) | ||
189 | +{ | ||
190 | + uint8_t round, shift = b & 0x1f; | ||
191 | + uint32_t res; | ||
192 | + | ||
193 | + round = get_round(vxrm, a, shift); | ||
194 | + res = (a >> shift) + round; | ||
195 | + if (res > UINT16_MAX) { | ||
196 | + env->vxsat = 0x1; | ||
197 | + return UINT16_MAX; | ||
198 | + } else { | ||
199 | + return res; | ||
200 | + } | ||
201 | +} | ||
202 | + | ||
203 | +static inline uint32_t | ||
204 | +vnclipu32(CPURISCVState *env, int vxrm, uint64_t a, uint32_t b) | ||
205 | +{ | ||
206 | + uint8_t round, shift = b & 0x3f; | ||
207 | + int64_t res; | ||
208 | + | ||
209 | + round = get_round(vxrm, a, shift); | ||
210 | + res = (a >> shift) + round; | ||
211 | + if (res > UINT32_MAX) { | ||
212 | + env->vxsat = 0x1; | ||
213 | + return UINT32_MAX; | ||
214 | + } else { | ||
215 | + return res; | ||
216 | + } | ||
217 | +} | ||
218 | + | ||
219 | +RVVCALL(OPIVV2_RM, vnclipu_vv_b, NOP_UUU_B, H1, H2, H1, vnclipu8) | ||
220 | +RVVCALL(OPIVV2_RM, vnclipu_vv_h, NOP_UUU_H, H2, H4, H2, vnclipu16) | ||
221 | +RVVCALL(OPIVV2_RM, vnclipu_vv_w, NOP_UUU_W, H4, H8, H4, vnclipu32) | ||
222 | +GEN_VEXT_VV_RM(vnclipu_vv_b, 1, 1, clearb) | ||
223 | +GEN_VEXT_VV_RM(vnclipu_vv_h, 2, 2, clearh) | ||
224 | +GEN_VEXT_VV_RM(vnclipu_vv_w, 4, 4, clearl) | ||
225 | + | ||
226 | +RVVCALL(OPIVX2_RM, vnclipu_vx_b, NOP_UUU_B, H1, H2, vnclipu8) | ||
227 | +RVVCALL(OPIVX2_RM, vnclipu_vx_h, NOP_UUU_H, H2, H4, vnclipu16) | ||
228 | +RVVCALL(OPIVX2_RM, vnclipu_vx_w, NOP_UUU_W, H4, H8, vnclipu32) | ||
229 | +GEN_VEXT_VX_RM(vnclipu_vx_b, 1, 1, clearb) | ||
230 | +GEN_VEXT_VX_RM(vnclipu_vx_h, 2, 2, clearh) | ||
231 | +GEN_VEXT_VX_RM(vnclipu_vx_w, 4, 4, clearl) | ||
232 | -- | ||
233 | 2.27.0 | ||
234 | |||
235 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-31-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 16 ++++ | ||
10 | target/riscv/insn32.decode | 5 + | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 118 ++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 111 ++++++++++++++++++++++ | ||
13 | 4 files changed, 250 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vnclipu_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vnclip_vx_b, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vnclip_vx_h, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vnclip_vx_w, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vfsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfadd_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vfsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vfsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vfsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vfrsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vfrsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vfrsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
39 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/riscv/insn32.decode | ||
42 | +++ b/target/riscv/insn32.decode | ||
43 | @@ -XXX,XX +XXX,XX @@ vnclipu_vi 101110 . ..... ..... 011 ..... 1010111 @r_vm | ||
44 | vnclip_vv 101111 . ..... ..... 000 ..... 1010111 @r_vm | ||
45 | vnclip_vx 101111 . ..... ..... 100 ..... 1010111 @r_vm | ||
46 | vnclip_vi 101111 . ..... ..... 011 ..... 1010111 @r_vm | ||
47 | +vfadd_vv 000000 . ..... ..... 001 ..... 1010111 @r_vm | ||
48 | +vfadd_vf 000000 . ..... ..... 101 ..... 1010111 @r_vm | ||
49 | +vfsub_vv 000010 . ..... ..... 001 ..... 1010111 @r_vm | ||
50 | +vfsub_vf 000010 . ..... ..... 101 ..... 1010111 @r_vm | ||
51 | +vfrsub_vf 100111 . ..... ..... 101 ..... 1010111 @r_vm | ||
52 | |||
53 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
54 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
55 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
58 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
59 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVX_NARROW_TRANS(vnclipu_vx) | ||
60 | GEN_OPIVX_NARROW_TRANS(vnclip_vx) | ||
61 | GEN_OPIVI_NARROW_TRANS(vnclipu_vi, 1, vnclipu_vx) | ||
62 | GEN_OPIVI_NARROW_TRANS(vnclip_vi, 1, vnclip_vx) | ||
63 | + | ||
64 | +/* | ||
65 | + *** Vector Float Point Arithmetic Instructions | ||
66 | + */ | ||
67 | +/* Vector Single-Width Floating-Point Add/Subtract Instructions */ | ||
68 | + | ||
69 | +/* | ||
70 | + * If the current SEW does not correspond to a supported IEEE floating-point | ||
71 | + * type, an illegal instruction exception is raised. | ||
72 | + */ | ||
73 | +static bool opfvv_check(DisasContext *s, arg_rmrr *a) | ||
74 | +{ | ||
75 | + return (vext_check_isa_ill(s) && | ||
76 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
77 | + vext_check_reg(s, a->rd, false) && | ||
78 | + vext_check_reg(s, a->rs2, false) && | ||
79 | + vext_check_reg(s, a->rs1, false) && | ||
80 | + (s->sew != 0)); | ||
81 | +} | ||
82 | + | ||
83 | +/* OPFVV without GVEC IR */ | ||
84 | +#define GEN_OPFVV_TRANS(NAME, CHECK) \ | ||
85 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
86 | +{ \ | ||
87 | + if (CHECK(s, a)) { \ | ||
88 | + uint32_t data = 0; \ | ||
89 | + static gen_helper_gvec_4_ptr * const fns[3] = { \ | ||
90 | + gen_helper_##NAME##_h, \ | ||
91 | + gen_helper_##NAME##_w, \ | ||
92 | + gen_helper_##NAME##_d, \ | ||
93 | + }; \ | ||
94 | + TCGLabel *over = gen_new_label(); \ | ||
95 | + gen_set_rm(s, 7); \ | ||
96 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
97 | + \ | ||
98 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
99 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
100 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
101 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
102 | + vreg_ofs(s, a->rs1), \ | ||
103 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
104 | + s->vlen / 8, data, fns[s->sew - 1]); \ | ||
105 | + gen_set_label(over); \ | ||
106 | + return true; \ | ||
107 | + } \ | ||
108 | + return false; \ | ||
109 | +} | ||
110 | +GEN_OPFVV_TRANS(vfadd_vv, opfvv_check) | ||
111 | +GEN_OPFVV_TRANS(vfsub_vv, opfvv_check) | ||
112 | + | ||
113 | +typedef void gen_helper_opfvf(TCGv_ptr, TCGv_ptr, TCGv_i64, TCGv_ptr, | ||
114 | + TCGv_env, TCGv_i32); | ||
115 | + | ||
116 | +static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, | ||
117 | + uint32_t data, gen_helper_opfvf *fn, DisasContext *s) | ||
118 | +{ | ||
119 | + TCGv_ptr dest, src2, mask; | ||
120 | + TCGv_i32 desc; | ||
121 | + | ||
122 | + TCGLabel *over = gen_new_label(); | ||
123 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
124 | + | ||
125 | + dest = tcg_temp_new_ptr(); | ||
126 | + mask = tcg_temp_new_ptr(); | ||
127 | + src2 = tcg_temp_new_ptr(); | ||
128 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
129 | + | ||
130 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd)); | ||
131 | + tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, vs2)); | ||
132 | + tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0)); | ||
133 | + | ||
134 | + fn(dest, mask, cpu_fpr[rs1], src2, cpu_env, desc); | ||
135 | + | ||
136 | + tcg_temp_free_ptr(dest); | ||
137 | + tcg_temp_free_ptr(mask); | ||
138 | + tcg_temp_free_ptr(src2); | ||
139 | + tcg_temp_free_i32(desc); | ||
140 | + gen_set_label(over); | ||
141 | + return true; | ||
142 | +} | ||
143 | + | ||
144 | +static bool opfvf_check(DisasContext *s, arg_rmrr *a) | ||
145 | +{ | ||
146 | +/* | ||
147 | + * If the current SEW does not correspond to a supported IEEE floating-point | ||
148 | + * type, an illegal instruction exception is raised | ||
149 | + */ | ||
150 | + return (vext_check_isa_ill(s) && | ||
151 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
152 | + vext_check_reg(s, a->rd, false) && | ||
153 | + vext_check_reg(s, a->rs2, false) && | ||
154 | + (s->sew != 0)); | ||
155 | +} | ||
156 | + | ||
157 | +/* OPFVF without GVEC IR */ | ||
158 | +#define GEN_OPFVF_TRANS(NAME, CHECK) \ | ||
159 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
160 | +{ \ | ||
161 | + if (CHECK(s, a)) { \ | ||
162 | + uint32_t data = 0; \ | ||
163 | + static gen_helper_opfvf *const fns[3] = { \ | ||
164 | + gen_helper_##NAME##_h, \ | ||
165 | + gen_helper_##NAME##_w, \ | ||
166 | + gen_helper_##NAME##_d, \ | ||
167 | + }; \ | ||
168 | + gen_set_rm(s, 7); \ | ||
169 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
170 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
171 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
172 | + return opfvf_trans(a->rd, a->rs1, a->rs2, data, \ | ||
173 | + fns[s->sew - 1], s); \ | ||
174 | + } \ | ||
175 | + return false; \ | ||
176 | +} | ||
177 | + | ||
178 | +GEN_OPFVF_TRANS(vfadd_vf, opfvf_check) | ||
179 | +GEN_OPFVF_TRANS(vfsub_vf, opfvf_check) | ||
180 | +GEN_OPFVF_TRANS(vfrsub_vf, opfvf_check) | ||
181 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
182 | index XXXXXXX..XXXXXXX 100644 | ||
183 | --- a/target/riscv/vector_helper.c | ||
184 | +++ b/target/riscv/vector_helper.c | ||
185 | @@ -XXX,XX +XXX,XX @@ | ||
186 | #include "exec/memop.h" | ||
187 | #include "exec/exec-all.h" | ||
188 | #include "exec/helper-proto.h" | ||
189 | +#include "fpu/softfloat.h" | ||
190 | #include "tcg/tcg-gvec-desc.h" | ||
191 | #include "internals.h" | ||
192 | #include <math.h> | ||
193 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPIVX2_RM, vnclipu_vx_w, NOP_UUU_W, H4, H8, vnclipu32) | ||
194 | GEN_VEXT_VX_RM(vnclipu_vx_b, 1, 1, clearb) | ||
195 | GEN_VEXT_VX_RM(vnclipu_vx_h, 2, 2, clearh) | ||
196 | GEN_VEXT_VX_RM(vnclipu_vx_w, 4, 4, clearl) | ||
197 | + | ||
198 | +/* | ||
199 | + *** Vector Float Point Arithmetic Instructions | ||
200 | + */ | ||
201 | +/* Vector Single-Width Floating-Point Add/Subtract Instructions */ | ||
202 | +#define OPFVV2(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ | ||
203 | +static void do_##NAME(void *vd, void *vs1, void *vs2, int i, \ | ||
204 | + CPURISCVState *env) \ | ||
205 | +{ \ | ||
206 | + TX1 s1 = *((T1 *)vs1 + HS1(i)); \ | ||
207 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
208 | + *((TD *)vd + HD(i)) = OP(s2, s1, &env->fp_status); \ | ||
209 | +} | ||
210 | + | ||
211 | +#define GEN_VEXT_VV_ENV(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
212 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, \ | ||
213 | + void *vs2, CPURISCVState *env, \ | ||
214 | + uint32_t desc) \ | ||
215 | +{ \ | ||
216 | + uint32_t vlmax = vext_maxsz(desc) / ESZ; \ | ||
217 | + uint32_t mlen = vext_mlen(desc); \ | ||
218 | + uint32_t vm = vext_vm(desc); \ | ||
219 | + uint32_t vl = env->vl; \ | ||
220 | + uint32_t i; \ | ||
221 | + \ | ||
222 | + for (i = 0; i < vl; i++) { \ | ||
223 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
224 | + continue; \ | ||
225 | + } \ | ||
226 | + do_##NAME(vd, vs1, vs2, i, env); \ | ||
227 | + } \ | ||
228 | + CLEAR_FN(vd, vl, vl * DSZ, vlmax * DSZ); \ | ||
229 | +} | ||
230 | + | ||
231 | +RVVCALL(OPFVV2, vfadd_vv_h, OP_UUU_H, H2, H2, H2, float16_add) | ||
232 | +RVVCALL(OPFVV2, vfadd_vv_w, OP_UUU_W, H4, H4, H4, float32_add) | ||
233 | +RVVCALL(OPFVV2, vfadd_vv_d, OP_UUU_D, H8, H8, H8, float64_add) | ||
234 | +GEN_VEXT_VV_ENV(vfadd_vv_h, 2, 2, clearh) | ||
235 | +GEN_VEXT_VV_ENV(vfadd_vv_w, 4, 4, clearl) | ||
236 | +GEN_VEXT_VV_ENV(vfadd_vv_d, 8, 8, clearq) | ||
237 | + | ||
238 | +#define OPFVF2(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ | ||
239 | +static void do_##NAME(void *vd, uint64_t s1, void *vs2, int i, \ | ||
240 | + CPURISCVState *env) \ | ||
241 | +{ \ | ||
242 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
243 | + *((TD *)vd + HD(i)) = OP(s2, (TX1)(T1)s1, &env->fp_status);\ | ||
244 | +} | ||
245 | + | ||
246 | +#define GEN_VEXT_VF(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
247 | +void HELPER(NAME)(void *vd, void *v0, uint64_t s1, \ | ||
248 | + void *vs2, CPURISCVState *env, \ | ||
249 | + uint32_t desc) \ | ||
250 | +{ \ | ||
251 | + uint32_t vlmax = vext_maxsz(desc) / ESZ; \ | ||
252 | + uint32_t mlen = vext_mlen(desc); \ | ||
253 | + uint32_t vm = vext_vm(desc); \ | ||
254 | + uint32_t vl = env->vl; \ | ||
255 | + uint32_t i; \ | ||
256 | + \ | ||
257 | + for (i = 0; i < vl; i++) { \ | ||
258 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
259 | + continue; \ | ||
260 | + } \ | ||
261 | + do_##NAME(vd, s1, vs2, i, env); \ | ||
262 | + } \ | ||
263 | + CLEAR_FN(vd, vl, vl * DSZ, vlmax * DSZ); \ | ||
264 | +} | ||
265 | + | ||
266 | +RVVCALL(OPFVF2, vfadd_vf_h, OP_UUU_H, H2, H2, float16_add) | ||
267 | +RVVCALL(OPFVF2, vfadd_vf_w, OP_UUU_W, H4, H4, float32_add) | ||
268 | +RVVCALL(OPFVF2, vfadd_vf_d, OP_UUU_D, H8, H8, float64_add) | ||
269 | +GEN_VEXT_VF(vfadd_vf_h, 2, 2, clearh) | ||
270 | +GEN_VEXT_VF(vfadd_vf_w, 4, 4, clearl) | ||
271 | +GEN_VEXT_VF(vfadd_vf_d, 8, 8, clearq) | ||
272 | + | ||
273 | +RVVCALL(OPFVV2, vfsub_vv_h, OP_UUU_H, H2, H2, H2, float16_sub) | ||
274 | +RVVCALL(OPFVV2, vfsub_vv_w, OP_UUU_W, H4, H4, H4, float32_sub) | ||
275 | +RVVCALL(OPFVV2, vfsub_vv_d, OP_UUU_D, H8, H8, H8, float64_sub) | ||
276 | +GEN_VEXT_VV_ENV(vfsub_vv_h, 2, 2, clearh) | ||
277 | +GEN_VEXT_VV_ENV(vfsub_vv_w, 4, 4, clearl) | ||
278 | +GEN_VEXT_VV_ENV(vfsub_vv_d, 8, 8, clearq) | ||
279 | +RVVCALL(OPFVF2, vfsub_vf_h, OP_UUU_H, H2, H2, float16_sub) | ||
280 | +RVVCALL(OPFVF2, vfsub_vf_w, OP_UUU_W, H4, H4, float32_sub) | ||
281 | +RVVCALL(OPFVF2, vfsub_vf_d, OP_UUU_D, H8, H8, float64_sub) | ||
282 | +GEN_VEXT_VF(vfsub_vf_h, 2, 2, clearh) | ||
283 | +GEN_VEXT_VF(vfsub_vf_w, 4, 4, clearl) | ||
284 | +GEN_VEXT_VF(vfsub_vf_d, 8, 8, clearq) | ||
285 | + | ||
286 | +static uint16_t float16_rsub(uint16_t a, uint16_t b, float_status *s) | ||
287 | +{ | ||
288 | + return float16_sub(b, a, s); | ||
289 | +} | ||
290 | + | ||
291 | +static uint32_t float32_rsub(uint32_t a, uint32_t b, float_status *s) | ||
292 | +{ | ||
293 | + return float32_sub(b, a, s); | ||
294 | +} | ||
295 | + | ||
296 | +static uint64_t float64_rsub(uint64_t a, uint64_t b, float_status *s) | ||
297 | +{ | ||
298 | + return float64_sub(b, a, s); | ||
299 | +} | ||
300 | + | ||
301 | +RVVCALL(OPFVF2, vfrsub_vf_h, OP_UUU_H, H2, H2, float16_rsub) | ||
302 | +RVVCALL(OPFVF2, vfrsub_vf_w, OP_UUU_W, H4, H4, float32_rsub) | ||
303 | +RVVCALL(OPFVF2, vfrsub_vf_d, OP_UUU_D, H8, H8, float64_rsub) | ||
304 | +GEN_VEXT_VF(vfrsub_vf_h, 2, 2, clearh) | ||
305 | +GEN_VEXT_VF(vfrsub_vf_w, 4, 4, clearl) | ||
306 | +GEN_VEXT_VF(vfrsub_vf_d, 8, 8, clearq) | ||
307 | -- | ||
308 | 2.27.0 | ||
309 | |||
310 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-32-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 17 +++ | ||
10 | target/riscv/insn32.decode | 8 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 149 ++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 83 +++++++++++++ | ||
13 | 4 files changed, 257 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfrsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfrsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfrsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfwadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfwadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfwsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfwsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vfwadd_wv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfwadd_wv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfwsub_wv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfwsub_wv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfwadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vfwadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vfwsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vfwsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vfwadd_wf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vfwadd_wf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vfwsub_wf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vfwsub_wf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
40 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn32.decode | ||
43 | +++ b/target/riscv/insn32.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ vfadd_vf 000000 . ..... ..... 101 ..... 1010111 @r_vm | ||
45 | vfsub_vv 000010 . ..... ..... 001 ..... 1010111 @r_vm | ||
46 | vfsub_vf 000010 . ..... ..... 101 ..... 1010111 @r_vm | ||
47 | vfrsub_vf 100111 . ..... ..... 101 ..... 1010111 @r_vm | ||
48 | +vfwadd_vv 110000 . ..... ..... 001 ..... 1010111 @r_vm | ||
49 | +vfwadd_vf 110000 . ..... ..... 101 ..... 1010111 @r_vm | ||
50 | +vfwadd_wv 110100 . ..... ..... 001 ..... 1010111 @r_vm | ||
51 | +vfwadd_wf 110100 . ..... ..... 101 ..... 1010111 @r_vm | ||
52 | +vfwsub_vv 110010 . ..... ..... 001 ..... 1010111 @r_vm | ||
53 | +vfwsub_vf 110010 . ..... ..... 101 ..... 1010111 @r_vm | ||
54 | +vfwsub_wv 110110 . ..... ..... 001 ..... 1010111 @r_vm | ||
55 | +vfwsub_wf 110110 . ..... ..... 101 ..... 1010111 @r_vm | ||
56 | |||
57 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
58 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
59 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
62 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
64 | GEN_OPFVF_TRANS(vfadd_vf, opfvf_check) | ||
65 | GEN_OPFVF_TRANS(vfsub_vf, opfvf_check) | ||
66 | GEN_OPFVF_TRANS(vfrsub_vf, opfvf_check) | ||
67 | + | ||
68 | +/* Vector Widening Floating-Point Add/Subtract Instructions */ | ||
69 | +static bool opfvv_widen_check(DisasContext *s, arg_rmrr *a) | ||
70 | +{ | ||
71 | + return (vext_check_isa_ill(s) && | ||
72 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
73 | + vext_check_reg(s, a->rd, true) && | ||
74 | + vext_check_reg(s, a->rs2, false) && | ||
75 | + vext_check_reg(s, a->rs1, false) && | ||
76 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs2, | ||
77 | + 1 << s->lmul) && | ||
78 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs1, | ||
79 | + 1 << s->lmul) && | ||
80 | + (s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0)); | ||
81 | +} | ||
82 | + | ||
83 | +/* OPFVV with WIDEN */ | ||
84 | +#define GEN_OPFVV_WIDEN_TRANS(NAME, CHECK) \ | ||
85 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
86 | +{ \ | ||
87 | + if (CHECK(s, a)) { \ | ||
88 | + uint32_t data = 0; \ | ||
89 | + static gen_helper_gvec_4_ptr * const fns[2] = { \ | ||
90 | + gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ | ||
91 | + }; \ | ||
92 | + TCGLabel *over = gen_new_label(); \ | ||
93 | + gen_set_rm(s, 7); \ | ||
94 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
95 | + \ | ||
96 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
97 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
98 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
99 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
100 | + vreg_ofs(s, a->rs1), \ | ||
101 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
102 | + s->vlen / 8, data, fns[s->sew - 1]); \ | ||
103 | + gen_set_label(over); \ | ||
104 | + return true; \ | ||
105 | + } \ | ||
106 | + return false; \ | ||
107 | +} | ||
108 | + | ||
109 | +GEN_OPFVV_WIDEN_TRANS(vfwadd_vv, opfvv_widen_check) | ||
110 | +GEN_OPFVV_WIDEN_TRANS(vfwsub_vv, opfvv_widen_check) | ||
111 | + | ||
112 | +static bool opfvf_widen_check(DisasContext *s, arg_rmrr *a) | ||
113 | +{ | ||
114 | + return (vext_check_isa_ill(s) && | ||
115 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
116 | + vext_check_reg(s, a->rd, true) && | ||
117 | + vext_check_reg(s, a->rs2, false) && | ||
118 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs2, | ||
119 | + 1 << s->lmul) && | ||
120 | + (s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0)); | ||
121 | +} | ||
122 | + | ||
123 | +/* OPFVF with WIDEN */ | ||
124 | +#define GEN_OPFVF_WIDEN_TRANS(NAME) \ | ||
125 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
126 | +{ \ | ||
127 | + if (opfvf_widen_check(s, a)) { \ | ||
128 | + uint32_t data = 0; \ | ||
129 | + static gen_helper_opfvf *const fns[2] = { \ | ||
130 | + gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ | ||
131 | + }; \ | ||
132 | + gen_set_rm(s, 7); \ | ||
133 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
134 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
135 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
136 | + return opfvf_trans(a->rd, a->rs1, a->rs2, data, \ | ||
137 | + fns[s->sew - 1], s); \ | ||
138 | + } \ | ||
139 | + return false; \ | ||
140 | +} | ||
141 | + | ||
142 | +GEN_OPFVF_WIDEN_TRANS(vfwadd_vf) | ||
143 | +GEN_OPFVF_WIDEN_TRANS(vfwsub_vf) | ||
144 | + | ||
145 | +static bool opfwv_widen_check(DisasContext *s, arg_rmrr *a) | ||
146 | +{ | ||
147 | + return (vext_check_isa_ill(s) && | ||
148 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
149 | + vext_check_reg(s, a->rd, true) && | ||
150 | + vext_check_reg(s, a->rs2, true) && | ||
151 | + vext_check_reg(s, a->rs1, false) && | ||
152 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs1, | ||
153 | + 1 << s->lmul) && | ||
154 | + (s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0)); | ||
155 | +} | ||
156 | + | ||
157 | +/* WIDEN OPFVV with WIDEN */ | ||
158 | +#define GEN_OPFWV_WIDEN_TRANS(NAME) \ | ||
159 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
160 | +{ \ | ||
161 | + if (opfwv_widen_check(s, a)) { \ | ||
162 | + uint32_t data = 0; \ | ||
163 | + static gen_helper_gvec_4_ptr * const fns[2] = { \ | ||
164 | + gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ | ||
165 | + }; \ | ||
166 | + TCGLabel *over = gen_new_label(); \ | ||
167 | + gen_set_rm(s, 7); \ | ||
168 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
169 | + \ | ||
170 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
171 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
172 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
173 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
174 | + vreg_ofs(s, a->rs1), \ | ||
175 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
176 | + s->vlen / 8, data, fns[s->sew - 1]); \ | ||
177 | + gen_set_label(over); \ | ||
178 | + return true; \ | ||
179 | + } \ | ||
180 | + return false; \ | ||
181 | +} | ||
182 | + | ||
183 | +GEN_OPFWV_WIDEN_TRANS(vfwadd_wv) | ||
184 | +GEN_OPFWV_WIDEN_TRANS(vfwsub_wv) | ||
185 | + | ||
186 | +static bool opfwf_widen_check(DisasContext *s, arg_rmrr *a) | ||
187 | +{ | ||
188 | + return (vext_check_isa_ill(s) && | ||
189 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
190 | + vext_check_reg(s, a->rd, true) && | ||
191 | + vext_check_reg(s, a->rs2, true) && | ||
192 | + (s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0)); | ||
193 | +} | ||
194 | + | ||
195 | +/* WIDEN OPFVF with WIDEN */ | ||
196 | +#define GEN_OPFWF_WIDEN_TRANS(NAME) \ | ||
197 | +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
198 | +{ \ | ||
199 | + if (opfwf_widen_check(s, a)) { \ | ||
200 | + uint32_t data = 0; \ | ||
201 | + static gen_helper_opfvf *const fns[2] = { \ | ||
202 | + gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ | ||
203 | + }; \ | ||
204 | + gen_set_rm(s, 7); \ | ||
205 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
206 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
207 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
208 | + return opfvf_trans(a->rd, a->rs1, a->rs2, data, \ | ||
209 | + fns[s->sew - 1], s); \ | ||
210 | + } \ | ||
211 | + return false; \ | ||
212 | +} | ||
213 | + | ||
214 | +GEN_OPFWF_WIDEN_TRANS(vfwadd_wf) | ||
215 | +GEN_OPFWF_WIDEN_TRANS(vfwsub_wf) | ||
216 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
217 | index XXXXXXX..XXXXXXX 100644 | ||
218 | --- a/target/riscv/vector_helper.c | ||
219 | +++ b/target/riscv/vector_helper.c | ||
220 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF2, vfrsub_vf_d, OP_UUU_D, H8, H8, float64_rsub) | ||
221 | GEN_VEXT_VF(vfrsub_vf_h, 2, 2, clearh) | ||
222 | GEN_VEXT_VF(vfrsub_vf_w, 4, 4, clearl) | ||
223 | GEN_VEXT_VF(vfrsub_vf_d, 8, 8, clearq) | ||
224 | + | ||
225 | +/* Vector Widening Floating-Point Add/Subtract Instructions */ | ||
226 | +static uint32_t vfwadd16(uint16_t a, uint16_t b, float_status *s) | ||
227 | +{ | ||
228 | + return float32_add(float16_to_float32(a, true, s), | ||
229 | + float16_to_float32(b, true, s), s); | ||
230 | +} | ||
231 | + | ||
232 | +static uint64_t vfwadd32(uint32_t a, uint32_t b, float_status *s) | ||
233 | +{ | ||
234 | + return float64_add(float32_to_float64(a, s), | ||
235 | + float32_to_float64(b, s), s); | ||
236 | + | ||
237 | +} | ||
238 | + | ||
239 | +RVVCALL(OPFVV2, vfwadd_vv_h, WOP_UUU_H, H4, H2, H2, vfwadd16) | ||
240 | +RVVCALL(OPFVV2, vfwadd_vv_w, WOP_UUU_W, H8, H4, H4, vfwadd32) | ||
241 | +GEN_VEXT_VV_ENV(vfwadd_vv_h, 2, 4, clearl) | ||
242 | +GEN_VEXT_VV_ENV(vfwadd_vv_w, 4, 8, clearq) | ||
243 | +RVVCALL(OPFVF2, vfwadd_vf_h, WOP_UUU_H, H4, H2, vfwadd16) | ||
244 | +RVVCALL(OPFVF2, vfwadd_vf_w, WOP_UUU_W, H8, H4, vfwadd32) | ||
245 | +GEN_VEXT_VF(vfwadd_vf_h, 2, 4, clearl) | ||
246 | +GEN_VEXT_VF(vfwadd_vf_w, 4, 8, clearq) | ||
247 | + | ||
248 | +static uint32_t vfwsub16(uint16_t a, uint16_t b, float_status *s) | ||
249 | +{ | ||
250 | + return float32_sub(float16_to_float32(a, true, s), | ||
251 | + float16_to_float32(b, true, s), s); | ||
252 | +} | ||
253 | + | ||
254 | +static uint64_t vfwsub32(uint32_t a, uint32_t b, float_status *s) | ||
255 | +{ | ||
256 | + return float64_sub(float32_to_float64(a, s), | ||
257 | + float32_to_float64(b, s), s); | ||
258 | + | ||
259 | +} | ||
260 | + | ||
261 | +RVVCALL(OPFVV2, vfwsub_vv_h, WOP_UUU_H, H4, H2, H2, vfwsub16) | ||
262 | +RVVCALL(OPFVV2, vfwsub_vv_w, WOP_UUU_W, H8, H4, H4, vfwsub32) | ||
263 | +GEN_VEXT_VV_ENV(vfwsub_vv_h, 2, 4, clearl) | ||
264 | +GEN_VEXT_VV_ENV(vfwsub_vv_w, 4, 8, clearq) | ||
265 | +RVVCALL(OPFVF2, vfwsub_vf_h, WOP_UUU_H, H4, H2, vfwsub16) | ||
266 | +RVVCALL(OPFVF2, vfwsub_vf_w, WOP_UUU_W, H8, H4, vfwsub32) | ||
267 | +GEN_VEXT_VF(vfwsub_vf_h, 2, 4, clearl) | ||
268 | +GEN_VEXT_VF(vfwsub_vf_w, 4, 8, clearq) | ||
269 | + | ||
270 | +static uint32_t vfwaddw16(uint32_t a, uint16_t b, float_status *s) | ||
271 | +{ | ||
272 | + return float32_add(a, float16_to_float32(b, true, s), s); | ||
273 | +} | ||
274 | + | ||
275 | +static uint64_t vfwaddw32(uint64_t a, uint32_t b, float_status *s) | ||
276 | +{ | ||
277 | + return float64_add(a, float32_to_float64(b, s), s); | ||
278 | +} | ||
279 | + | ||
280 | +RVVCALL(OPFVV2, vfwadd_wv_h, WOP_WUUU_H, H4, H2, H2, vfwaddw16) | ||
281 | +RVVCALL(OPFVV2, vfwadd_wv_w, WOP_WUUU_W, H8, H4, H4, vfwaddw32) | ||
282 | +GEN_VEXT_VV_ENV(vfwadd_wv_h, 2, 4, clearl) | ||
283 | +GEN_VEXT_VV_ENV(vfwadd_wv_w, 4, 8, clearq) | ||
284 | +RVVCALL(OPFVF2, vfwadd_wf_h, WOP_WUUU_H, H4, H2, vfwaddw16) | ||
285 | +RVVCALL(OPFVF2, vfwadd_wf_w, WOP_WUUU_W, H8, H4, vfwaddw32) | ||
286 | +GEN_VEXT_VF(vfwadd_wf_h, 2, 4, clearl) | ||
287 | +GEN_VEXT_VF(vfwadd_wf_w, 4, 8, clearq) | ||
288 | + | ||
289 | +static uint32_t vfwsubw16(uint32_t a, uint16_t b, float_status *s) | ||
290 | +{ | ||
291 | + return float32_sub(a, float16_to_float32(b, true, s), s); | ||
292 | +} | ||
293 | + | ||
294 | +static uint64_t vfwsubw32(uint64_t a, uint32_t b, float_status *s) | ||
295 | +{ | ||
296 | + return float64_sub(a, float32_to_float64(b, s), s); | ||
297 | +} | ||
298 | + | ||
299 | +RVVCALL(OPFVV2, vfwsub_wv_h, WOP_WUUU_H, H4, H2, H2, vfwsubw16) | ||
300 | +RVVCALL(OPFVV2, vfwsub_wv_w, WOP_WUUU_W, H8, H4, H4, vfwsubw32) | ||
301 | +GEN_VEXT_VV_ENV(vfwsub_wv_h, 2, 4, clearl) | ||
302 | +GEN_VEXT_VV_ENV(vfwsub_wv_w, 4, 8, clearq) | ||
303 | +RVVCALL(OPFVF2, vfwsub_wf_h, WOP_WUUU_H, H4, H2, vfwsubw16) | ||
304 | +RVVCALL(OPFVF2, vfwsub_wf_w, WOP_WUUU_W, H8, H4, vfwsubw32) | ||
305 | +GEN_VEXT_VF(vfwsub_wf_h, 2, 4, clearl) | ||
306 | +GEN_VEXT_VF(vfwsub_wf_w, 4, 8, clearq) | ||
307 | -- | ||
308 | 2.27.0 | ||
309 | |||
310 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-33-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 16 ++++++++ | ||
10 | target/riscv/insn32.decode | 5 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 7 ++++ | ||
12 | target/riscv/vector_helper.c | 49 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 77 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfwadd_wf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfwadd_wf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfwsub_wf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfwsub_wf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfmul_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfdiv_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vfdiv_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfdiv_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfmul_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfmul_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfmul_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vfdiv_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vfdiv_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vfdiv_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vfrdiv_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vfrdiv_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vfrdiv_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
39 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/riscv/insn32.decode | ||
42 | +++ b/target/riscv/insn32.decode | ||
43 | @@ -XXX,XX +XXX,XX @@ vfwsub_vv 110010 . ..... ..... 001 ..... 1010111 @r_vm | ||
44 | vfwsub_vf 110010 . ..... ..... 101 ..... 1010111 @r_vm | ||
45 | vfwsub_wv 110110 . ..... ..... 001 ..... 1010111 @r_vm | ||
46 | vfwsub_wf 110110 . ..... ..... 101 ..... 1010111 @r_vm | ||
47 | +vfmul_vv 100100 . ..... ..... 001 ..... 1010111 @r_vm | ||
48 | +vfmul_vf 100100 . ..... ..... 101 ..... 1010111 @r_vm | ||
49 | +vfdiv_vv 100000 . ..... ..... 001 ..... 1010111 @r_vm | ||
50 | +vfdiv_vf 100000 . ..... ..... 101 ..... 1010111 @r_vm | ||
51 | +vfrdiv_vf 100001 . ..... ..... 101 ..... 1010111 @r_vm | ||
52 | |||
53 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
54 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
55 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
58 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ | ||
60 | |||
61 | GEN_OPFWF_WIDEN_TRANS(vfwadd_wf) | ||
62 | GEN_OPFWF_WIDEN_TRANS(vfwsub_wf) | ||
63 | + | ||
64 | +/* Vector Single-Width Floating-Point Multiply/Divide Instructions */ | ||
65 | +GEN_OPFVV_TRANS(vfmul_vv, opfvv_check) | ||
66 | +GEN_OPFVV_TRANS(vfdiv_vv, opfvv_check) | ||
67 | +GEN_OPFVF_TRANS(vfmul_vf, opfvf_check) | ||
68 | +GEN_OPFVF_TRANS(vfdiv_vf, opfvf_check) | ||
69 | +GEN_OPFVF_TRANS(vfrdiv_vf, opfvf_check) | ||
70 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/target/riscv/vector_helper.c | ||
73 | +++ b/target/riscv/vector_helper.c | ||
74 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF2, vfwsub_wf_h, WOP_WUUU_H, H4, H2, vfwsubw16) | ||
75 | RVVCALL(OPFVF2, vfwsub_wf_w, WOP_WUUU_W, H8, H4, vfwsubw32) | ||
76 | GEN_VEXT_VF(vfwsub_wf_h, 2, 4, clearl) | ||
77 | GEN_VEXT_VF(vfwsub_wf_w, 4, 8, clearq) | ||
78 | + | ||
79 | +/* Vector Single-Width Floating-Point Multiply/Divide Instructions */ | ||
80 | +RVVCALL(OPFVV2, vfmul_vv_h, OP_UUU_H, H2, H2, H2, float16_mul) | ||
81 | +RVVCALL(OPFVV2, vfmul_vv_w, OP_UUU_W, H4, H4, H4, float32_mul) | ||
82 | +RVVCALL(OPFVV2, vfmul_vv_d, OP_UUU_D, H8, H8, H8, float64_mul) | ||
83 | +GEN_VEXT_VV_ENV(vfmul_vv_h, 2, 2, clearh) | ||
84 | +GEN_VEXT_VV_ENV(vfmul_vv_w, 4, 4, clearl) | ||
85 | +GEN_VEXT_VV_ENV(vfmul_vv_d, 8, 8, clearq) | ||
86 | +RVVCALL(OPFVF2, vfmul_vf_h, OP_UUU_H, H2, H2, float16_mul) | ||
87 | +RVVCALL(OPFVF2, vfmul_vf_w, OP_UUU_W, H4, H4, float32_mul) | ||
88 | +RVVCALL(OPFVF2, vfmul_vf_d, OP_UUU_D, H8, H8, float64_mul) | ||
89 | +GEN_VEXT_VF(vfmul_vf_h, 2, 2, clearh) | ||
90 | +GEN_VEXT_VF(vfmul_vf_w, 4, 4, clearl) | ||
91 | +GEN_VEXT_VF(vfmul_vf_d, 8, 8, clearq) | ||
92 | + | ||
93 | +RVVCALL(OPFVV2, vfdiv_vv_h, OP_UUU_H, H2, H2, H2, float16_div) | ||
94 | +RVVCALL(OPFVV2, vfdiv_vv_w, OP_UUU_W, H4, H4, H4, float32_div) | ||
95 | +RVVCALL(OPFVV2, vfdiv_vv_d, OP_UUU_D, H8, H8, H8, float64_div) | ||
96 | +GEN_VEXT_VV_ENV(vfdiv_vv_h, 2, 2, clearh) | ||
97 | +GEN_VEXT_VV_ENV(vfdiv_vv_w, 4, 4, clearl) | ||
98 | +GEN_VEXT_VV_ENV(vfdiv_vv_d, 8, 8, clearq) | ||
99 | +RVVCALL(OPFVF2, vfdiv_vf_h, OP_UUU_H, H2, H2, float16_div) | ||
100 | +RVVCALL(OPFVF2, vfdiv_vf_w, OP_UUU_W, H4, H4, float32_div) | ||
101 | +RVVCALL(OPFVF2, vfdiv_vf_d, OP_UUU_D, H8, H8, float64_div) | ||
102 | +GEN_VEXT_VF(vfdiv_vf_h, 2, 2, clearh) | ||
103 | +GEN_VEXT_VF(vfdiv_vf_w, 4, 4, clearl) | ||
104 | +GEN_VEXT_VF(vfdiv_vf_d, 8, 8, clearq) | ||
105 | + | ||
106 | +static uint16_t float16_rdiv(uint16_t a, uint16_t b, float_status *s) | ||
107 | +{ | ||
108 | + return float16_div(b, a, s); | ||
109 | +} | ||
110 | + | ||
111 | +static uint32_t float32_rdiv(uint32_t a, uint32_t b, float_status *s) | ||
112 | +{ | ||
113 | + return float32_div(b, a, s); | ||
114 | +} | ||
115 | + | ||
116 | +static uint64_t float64_rdiv(uint64_t a, uint64_t b, float_status *s) | ||
117 | +{ | ||
118 | + return float64_div(b, a, s); | ||
119 | +} | ||
120 | + | ||
121 | +RVVCALL(OPFVF2, vfrdiv_vf_h, OP_UUU_H, H2, H2, float16_rdiv) | ||
122 | +RVVCALL(OPFVF2, vfrdiv_vf_w, OP_UUU_W, H4, H4, float32_rdiv) | ||
123 | +RVVCALL(OPFVF2, vfrdiv_vf_d, OP_UUU_D, H8, H8, float64_rdiv) | ||
124 | +GEN_VEXT_VF(vfrdiv_vf_h, 2, 2, clearh) | ||
125 | +GEN_VEXT_VF(vfrdiv_vf_w, 4, 4, clearl) | ||
126 | +GEN_VEXT_VF(vfrdiv_vf_d, 8, 8, clearq) | ||
127 | -- | ||
128 | 2.27.0 | ||
129 | |||
130 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-34-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 5 +++++ | ||
10 | target/riscv/insn32.decode | 2 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 4 ++++ | ||
12 | target/riscv/vector_helper.c | 22 ++++++++++++++++++++++ | ||
13 | 4 files changed, 33 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfdiv_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfrdiv_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfrdiv_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfrdiv_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfwmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfwmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfwmul_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfwmul_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
28 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/riscv/insn32.decode | ||
31 | +++ b/target/riscv/insn32.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ vfmul_vf 100100 . ..... ..... 101 ..... 1010111 @r_vm | ||
33 | vfdiv_vv 100000 . ..... ..... 001 ..... 1010111 @r_vm | ||
34 | vfdiv_vf 100000 . ..... ..... 101 ..... 1010111 @r_vm | ||
35 | vfrdiv_vf 100001 . ..... ..... 101 ..... 1010111 @r_vm | ||
36 | +vfwmul_vv 111000 . ..... ..... 001 ..... 1010111 @r_vm | ||
37 | +vfwmul_vf 111000 . ..... ..... 101 ..... 1010111 @r_vm | ||
38 | |||
39 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
40 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
41 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
44 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
45 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVV_TRANS(vfdiv_vv, opfvv_check) | ||
46 | GEN_OPFVF_TRANS(vfmul_vf, opfvf_check) | ||
47 | GEN_OPFVF_TRANS(vfdiv_vf, opfvf_check) | ||
48 | GEN_OPFVF_TRANS(vfrdiv_vf, opfvf_check) | ||
49 | + | ||
50 | +/* Vector Widening Floating-Point Multiply */ | ||
51 | +GEN_OPFVV_WIDEN_TRANS(vfwmul_vv, opfvv_widen_check) | ||
52 | +GEN_OPFVF_WIDEN_TRANS(vfwmul_vf) | ||
53 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/riscv/vector_helper.c | ||
56 | +++ b/target/riscv/vector_helper.c | ||
57 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF2, vfrdiv_vf_d, OP_UUU_D, H8, H8, float64_rdiv) | ||
58 | GEN_VEXT_VF(vfrdiv_vf_h, 2, 2, clearh) | ||
59 | GEN_VEXT_VF(vfrdiv_vf_w, 4, 4, clearl) | ||
60 | GEN_VEXT_VF(vfrdiv_vf_d, 8, 8, clearq) | ||
61 | + | ||
62 | +/* Vector Widening Floating-Point Multiply */ | ||
63 | +static uint32_t vfwmul16(uint16_t a, uint16_t b, float_status *s) | ||
64 | +{ | ||
65 | + return float32_mul(float16_to_float32(a, true, s), | ||
66 | + float16_to_float32(b, true, s), s); | ||
67 | +} | ||
68 | + | ||
69 | +static uint64_t vfwmul32(uint32_t a, uint32_t b, float_status *s) | ||
70 | +{ | ||
71 | + return float64_mul(float32_to_float64(a, s), | ||
72 | + float32_to_float64(b, s), s); | ||
73 | + | ||
74 | +} | ||
75 | +RVVCALL(OPFVV2, vfwmul_vv_h, WOP_UUU_H, H4, H2, H2, vfwmul16) | ||
76 | +RVVCALL(OPFVV2, vfwmul_vv_w, WOP_UUU_W, H8, H4, H4, vfwmul32) | ||
77 | +GEN_VEXT_VV_ENV(vfwmul_vv_h, 2, 4, clearl) | ||
78 | +GEN_VEXT_VV_ENV(vfwmul_vv_w, 4, 8, clearq) | ||
79 | +RVVCALL(OPFVF2, vfwmul_vf_h, WOP_UUU_H, H4, H2, vfwmul16) | ||
80 | +RVVCALL(OPFVF2, vfwmul_vf_w, WOP_UUU_W, H8, H4, vfwmul32) | ||
81 | +GEN_VEXT_VF(vfwmul_vf_h, 2, 4, clearl) | ||
82 | +GEN_VEXT_VF(vfwmul_vf_w, 4, 8, clearq) | ||
83 | -- | ||
84 | 2.27.0 | ||
85 | |||
86 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-35-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 49 +++++ | ||
10 | target/riscv/insn32.decode | 16 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 18 ++ | ||
12 | target/riscv/vector_helper.c | 251 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 334 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfwmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfwmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfwmul_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfwmul_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfmacc_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfnmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vfnmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfnmacc_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfmsac_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vfnmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vfnmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vfnmsac_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vfmadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vfmadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vfmadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vfnmadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vfnmadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vfnmadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vfmsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vfmsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vfmsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vfnmsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vfnmsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vfnmsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vfmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vfmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vfmacc_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vfnmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vfnmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vfnmacc_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vfmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vfmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
56 | +DEF_HELPER_6(vfmsac_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
57 | +DEF_HELPER_6(vfnmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
58 | +DEF_HELPER_6(vfnmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
59 | +DEF_HELPER_6(vfnmsac_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
60 | +DEF_HELPER_6(vfmadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
61 | +DEF_HELPER_6(vfmadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
62 | +DEF_HELPER_6(vfmadd_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
63 | +DEF_HELPER_6(vfnmadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
64 | +DEF_HELPER_6(vfnmadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
65 | +DEF_HELPER_6(vfnmadd_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
66 | +DEF_HELPER_6(vfmsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
67 | +DEF_HELPER_6(vfmsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
68 | +DEF_HELPER_6(vfmsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
69 | +DEF_HELPER_6(vfnmsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
70 | +DEF_HELPER_6(vfnmsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
71 | +DEF_HELPER_6(vfnmsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
72 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/riscv/insn32.decode | ||
75 | +++ b/target/riscv/insn32.decode | ||
76 | @@ -XXX,XX +XXX,XX @@ vfdiv_vf 100000 . ..... ..... 101 ..... 1010111 @r_vm | ||
77 | vfrdiv_vf 100001 . ..... ..... 101 ..... 1010111 @r_vm | ||
78 | vfwmul_vv 111000 . ..... ..... 001 ..... 1010111 @r_vm | ||
79 | vfwmul_vf 111000 . ..... ..... 101 ..... 1010111 @r_vm | ||
80 | +vfmacc_vv 101100 . ..... ..... 001 ..... 1010111 @r_vm | ||
81 | +vfnmacc_vv 101101 . ..... ..... 001 ..... 1010111 @r_vm | ||
82 | +vfnmacc_vf 101101 . ..... ..... 101 ..... 1010111 @r_vm | ||
83 | +vfmacc_vf 101100 . ..... ..... 101 ..... 1010111 @r_vm | ||
84 | +vfmsac_vv 101110 . ..... ..... 001 ..... 1010111 @r_vm | ||
85 | +vfmsac_vf 101110 . ..... ..... 101 ..... 1010111 @r_vm | ||
86 | +vfnmsac_vv 101111 . ..... ..... 001 ..... 1010111 @r_vm | ||
87 | +vfnmsac_vf 101111 . ..... ..... 101 ..... 1010111 @r_vm | ||
88 | +vfmadd_vv 101000 . ..... ..... 001 ..... 1010111 @r_vm | ||
89 | +vfmadd_vf 101000 . ..... ..... 101 ..... 1010111 @r_vm | ||
90 | +vfnmadd_vv 101001 . ..... ..... 001 ..... 1010111 @r_vm | ||
91 | +vfnmadd_vf 101001 . ..... ..... 101 ..... 1010111 @r_vm | ||
92 | +vfmsub_vv 101010 . ..... ..... 001 ..... 1010111 @r_vm | ||
93 | +vfmsub_vf 101010 . ..... ..... 101 ..... 1010111 @r_vm | ||
94 | +vfnmsub_vv 101011 . ..... ..... 001 ..... 1010111 @r_vm | ||
95 | +vfnmsub_vf 101011 . ..... ..... 101 ..... 1010111 @r_vm | ||
96 | |||
97 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
98 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
99 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
102 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
103 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVF_TRANS(vfrdiv_vf, opfvf_check) | ||
104 | /* Vector Widening Floating-Point Multiply */ | ||
105 | GEN_OPFVV_WIDEN_TRANS(vfwmul_vv, opfvv_widen_check) | ||
106 | GEN_OPFVF_WIDEN_TRANS(vfwmul_vf) | ||
107 | + | ||
108 | +/* Vector Single-Width Floating-Point Fused Multiply-Add Instructions */ | ||
109 | +GEN_OPFVV_TRANS(vfmacc_vv, opfvv_check) | ||
110 | +GEN_OPFVV_TRANS(vfnmacc_vv, opfvv_check) | ||
111 | +GEN_OPFVV_TRANS(vfmsac_vv, opfvv_check) | ||
112 | +GEN_OPFVV_TRANS(vfnmsac_vv, opfvv_check) | ||
113 | +GEN_OPFVV_TRANS(vfmadd_vv, opfvv_check) | ||
114 | +GEN_OPFVV_TRANS(vfnmadd_vv, opfvv_check) | ||
115 | +GEN_OPFVV_TRANS(vfmsub_vv, opfvv_check) | ||
116 | +GEN_OPFVV_TRANS(vfnmsub_vv, opfvv_check) | ||
117 | +GEN_OPFVF_TRANS(vfmacc_vf, opfvf_check) | ||
118 | +GEN_OPFVF_TRANS(vfnmacc_vf, opfvf_check) | ||
119 | +GEN_OPFVF_TRANS(vfmsac_vf, opfvf_check) | ||
120 | +GEN_OPFVF_TRANS(vfnmsac_vf, opfvf_check) | ||
121 | +GEN_OPFVF_TRANS(vfmadd_vf, opfvf_check) | ||
122 | +GEN_OPFVF_TRANS(vfnmadd_vf, opfvf_check) | ||
123 | +GEN_OPFVF_TRANS(vfmsub_vf, opfvf_check) | ||
124 | +GEN_OPFVF_TRANS(vfnmsub_vf, opfvf_check) | ||
125 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/target/riscv/vector_helper.c | ||
128 | +++ b/target/riscv/vector_helper.c | ||
129 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF2, vfwmul_vf_h, WOP_UUU_H, H4, H2, vfwmul16) | ||
130 | RVVCALL(OPFVF2, vfwmul_vf_w, WOP_UUU_W, H8, H4, vfwmul32) | ||
131 | GEN_VEXT_VF(vfwmul_vf_h, 2, 4, clearl) | ||
132 | GEN_VEXT_VF(vfwmul_vf_w, 4, 8, clearq) | ||
133 | + | ||
134 | +/* Vector Single-Width Floating-Point Fused Multiply-Add Instructions */ | ||
135 | +#define OPFVV3(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ | ||
136 | +static void do_##NAME(void *vd, void *vs1, void *vs2, int i, \ | ||
137 | + CPURISCVState *env) \ | ||
138 | +{ \ | ||
139 | + TX1 s1 = *((T1 *)vs1 + HS1(i)); \ | ||
140 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
141 | + TD d = *((TD *)vd + HD(i)); \ | ||
142 | + *((TD *)vd + HD(i)) = OP(s2, s1, d, &env->fp_status); \ | ||
143 | +} | ||
144 | + | ||
145 | +static uint16_t fmacc16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
146 | +{ | ||
147 | + return float16_muladd(a, b, d, 0, s); | ||
148 | +} | ||
149 | + | ||
150 | +static uint32_t fmacc32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
151 | +{ | ||
152 | + return float32_muladd(a, b, d, 0, s); | ||
153 | +} | ||
154 | + | ||
155 | +static uint64_t fmacc64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
156 | +{ | ||
157 | + return float64_muladd(a, b, d, 0, s); | ||
158 | +} | ||
159 | + | ||
160 | +RVVCALL(OPFVV3, vfmacc_vv_h, OP_UUU_H, H2, H2, H2, fmacc16) | ||
161 | +RVVCALL(OPFVV3, vfmacc_vv_w, OP_UUU_W, H4, H4, H4, fmacc32) | ||
162 | +RVVCALL(OPFVV3, vfmacc_vv_d, OP_UUU_D, H8, H8, H8, fmacc64) | ||
163 | +GEN_VEXT_VV_ENV(vfmacc_vv_h, 2, 2, clearh) | ||
164 | +GEN_VEXT_VV_ENV(vfmacc_vv_w, 4, 4, clearl) | ||
165 | +GEN_VEXT_VV_ENV(vfmacc_vv_d, 8, 8, clearq) | ||
166 | + | ||
167 | +#define OPFVF3(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ | ||
168 | +static void do_##NAME(void *vd, uint64_t s1, void *vs2, int i, \ | ||
169 | + CPURISCVState *env) \ | ||
170 | +{ \ | ||
171 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
172 | + TD d = *((TD *)vd + HD(i)); \ | ||
173 | + *((TD *)vd + HD(i)) = OP(s2, (TX1)(T1)s1, d, &env->fp_status);\ | ||
174 | +} | ||
175 | + | ||
176 | +RVVCALL(OPFVF3, vfmacc_vf_h, OP_UUU_H, H2, H2, fmacc16) | ||
177 | +RVVCALL(OPFVF3, vfmacc_vf_w, OP_UUU_W, H4, H4, fmacc32) | ||
178 | +RVVCALL(OPFVF3, vfmacc_vf_d, OP_UUU_D, H8, H8, fmacc64) | ||
179 | +GEN_VEXT_VF(vfmacc_vf_h, 2, 2, clearh) | ||
180 | +GEN_VEXT_VF(vfmacc_vf_w, 4, 4, clearl) | ||
181 | +GEN_VEXT_VF(vfmacc_vf_d, 8, 8, clearq) | ||
182 | + | ||
183 | +static uint16_t fnmacc16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
184 | +{ | ||
185 | + return float16_muladd(a, b, d, | ||
186 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
187 | +} | ||
188 | + | ||
189 | +static uint32_t fnmacc32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
190 | +{ | ||
191 | + return float32_muladd(a, b, d, | ||
192 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
193 | +} | ||
194 | + | ||
195 | +static uint64_t fnmacc64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
196 | +{ | ||
197 | + return float64_muladd(a, b, d, | ||
198 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
199 | +} | ||
200 | + | ||
201 | +RVVCALL(OPFVV3, vfnmacc_vv_h, OP_UUU_H, H2, H2, H2, fnmacc16) | ||
202 | +RVVCALL(OPFVV3, vfnmacc_vv_w, OP_UUU_W, H4, H4, H4, fnmacc32) | ||
203 | +RVVCALL(OPFVV3, vfnmacc_vv_d, OP_UUU_D, H8, H8, H8, fnmacc64) | ||
204 | +GEN_VEXT_VV_ENV(vfnmacc_vv_h, 2, 2, clearh) | ||
205 | +GEN_VEXT_VV_ENV(vfnmacc_vv_w, 4, 4, clearl) | ||
206 | +GEN_VEXT_VV_ENV(vfnmacc_vv_d, 8, 8, clearq) | ||
207 | +RVVCALL(OPFVF3, vfnmacc_vf_h, OP_UUU_H, H2, H2, fnmacc16) | ||
208 | +RVVCALL(OPFVF3, vfnmacc_vf_w, OP_UUU_W, H4, H4, fnmacc32) | ||
209 | +RVVCALL(OPFVF3, vfnmacc_vf_d, OP_UUU_D, H8, H8, fnmacc64) | ||
210 | +GEN_VEXT_VF(vfnmacc_vf_h, 2, 2, clearh) | ||
211 | +GEN_VEXT_VF(vfnmacc_vf_w, 4, 4, clearl) | ||
212 | +GEN_VEXT_VF(vfnmacc_vf_d, 8, 8, clearq) | ||
213 | + | ||
214 | +static uint16_t fmsac16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
215 | +{ | ||
216 | + return float16_muladd(a, b, d, float_muladd_negate_c, s); | ||
217 | +} | ||
218 | + | ||
219 | +static uint32_t fmsac32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
220 | +{ | ||
221 | + return float32_muladd(a, b, d, float_muladd_negate_c, s); | ||
222 | +} | ||
223 | + | ||
224 | +static uint64_t fmsac64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
225 | +{ | ||
226 | + return float64_muladd(a, b, d, float_muladd_negate_c, s); | ||
227 | +} | ||
228 | + | ||
229 | +RVVCALL(OPFVV3, vfmsac_vv_h, OP_UUU_H, H2, H2, H2, fmsac16) | ||
230 | +RVVCALL(OPFVV3, vfmsac_vv_w, OP_UUU_W, H4, H4, H4, fmsac32) | ||
231 | +RVVCALL(OPFVV3, vfmsac_vv_d, OP_UUU_D, H8, H8, H8, fmsac64) | ||
232 | +GEN_VEXT_VV_ENV(vfmsac_vv_h, 2, 2, clearh) | ||
233 | +GEN_VEXT_VV_ENV(vfmsac_vv_w, 4, 4, clearl) | ||
234 | +GEN_VEXT_VV_ENV(vfmsac_vv_d, 8, 8, clearq) | ||
235 | +RVVCALL(OPFVF3, vfmsac_vf_h, OP_UUU_H, H2, H2, fmsac16) | ||
236 | +RVVCALL(OPFVF3, vfmsac_vf_w, OP_UUU_W, H4, H4, fmsac32) | ||
237 | +RVVCALL(OPFVF3, vfmsac_vf_d, OP_UUU_D, H8, H8, fmsac64) | ||
238 | +GEN_VEXT_VF(vfmsac_vf_h, 2, 2, clearh) | ||
239 | +GEN_VEXT_VF(vfmsac_vf_w, 4, 4, clearl) | ||
240 | +GEN_VEXT_VF(vfmsac_vf_d, 8, 8, clearq) | ||
241 | + | ||
242 | +static uint16_t fnmsac16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
243 | +{ | ||
244 | + return float16_muladd(a, b, d, float_muladd_negate_product, s); | ||
245 | +} | ||
246 | + | ||
247 | +static uint32_t fnmsac32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
248 | +{ | ||
249 | + return float32_muladd(a, b, d, float_muladd_negate_product, s); | ||
250 | +} | ||
251 | + | ||
252 | +static uint64_t fnmsac64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
253 | +{ | ||
254 | + return float64_muladd(a, b, d, float_muladd_negate_product, s); | ||
255 | +} | ||
256 | + | ||
257 | +RVVCALL(OPFVV3, vfnmsac_vv_h, OP_UUU_H, H2, H2, H2, fnmsac16) | ||
258 | +RVVCALL(OPFVV3, vfnmsac_vv_w, OP_UUU_W, H4, H4, H4, fnmsac32) | ||
259 | +RVVCALL(OPFVV3, vfnmsac_vv_d, OP_UUU_D, H8, H8, H8, fnmsac64) | ||
260 | +GEN_VEXT_VV_ENV(vfnmsac_vv_h, 2, 2, clearh) | ||
261 | +GEN_VEXT_VV_ENV(vfnmsac_vv_w, 4, 4, clearl) | ||
262 | +GEN_VEXT_VV_ENV(vfnmsac_vv_d, 8, 8, clearq) | ||
263 | +RVVCALL(OPFVF3, vfnmsac_vf_h, OP_UUU_H, H2, H2, fnmsac16) | ||
264 | +RVVCALL(OPFVF3, vfnmsac_vf_w, OP_UUU_W, H4, H4, fnmsac32) | ||
265 | +RVVCALL(OPFVF3, vfnmsac_vf_d, OP_UUU_D, H8, H8, fnmsac64) | ||
266 | +GEN_VEXT_VF(vfnmsac_vf_h, 2, 2, clearh) | ||
267 | +GEN_VEXT_VF(vfnmsac_vf_w, 4, 4, clearl) | ||
268 | +GEN_VEXT_VF(vfnmsac_vf_d, 8, 8, clearq) | ||
269 | + | ||
270 | +static uint16_t fmadd16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
271 | +{ | ||
272 | + return float16_muladd(d, b, a, 0, s); | ||
273 | +} | ||
274 | + | ||
275 | +static uint32_t fmadd32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
276 | +{ | ||
277 | + return float32_muladd(d, b, a, 0, s); | ||
278 | +} | ||
279 | + | ||
280 | +static uint64_t fmadd64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
281 | +{ | ||
282 | + return float64_muladd(d, b, a, 0, s); | ||
283 | +} | ||
284 | + | ||
285 | +RVVCALL(OPFVV3, vfmadd_vv_h, OP_UUU_H, H2, H2, H2, fmadd16) | ||
286 | +RVVCALL(OPFVV3, vfmadd_vv_w, OP_UUU_W, H4, H4, H4, fmadd32) | ||
287 | +RVVCALL(OPFVV3, vfmadd_vv_d, OP_UUU_D, H8, H8, H8, fmadd64) | ||
288 | +GEN_VEXT_VV_ENV(vfmadd_vv_h, 2, 2, clearh) | ||
289 | +GEN_VEXT_VV_ENV(vfmadd_vv_w, 4, 4, clearl) | ||
290 | +GEN_VEXT_VV_ENV(vfmadd_vv_d, 8, 8, clearq) | ||
291 | +RVVCALL(OPFVF3, vfmadd_vf_h, OP_UUU_H, H2, H2, fmadd16) | ||
292 | +RVVCALL(OPFVF3, vfmadd_vf_w, OP_UUU_W, H4, H4, fmadd32) | ||
293 | +RVVCALL(OPFVF3, vfmadd_vf_d, OP_UUU_D, H8, H8, fmadd64) | ||
294 | +GEN_VEXT_VF(vfmadd_vf_h, 2, 2, clearh) | ||
295 | +GEN_VEXT_VF(vfmadd_vf_w, 4, 4, clearl) | ||
296 | +GEN_VEXT_VF(vfmadd_vf_d, 8, 8, clearq) | ||
297 | + | ||
298 | +static uint16_t fnmadd16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
299 | +{ | ||
300 | + return float16_muladd(d, b, a, | ||
301 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
302 | +} | ||
303 | + | ||
304 | +static uint32_t fnmadd32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
305 | +{ | ||
306 | + return float32_muladd(d, b, a, | ||
307 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
308 | +} | ||
309 | + | ||
310 | +static uint64_t fnmadd64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
311 | +{ | ||
312 | + return float64_muladd(d, b, a, | ||
313 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
314 | +} | ||
315 | + | ||
316 | +RVVCALL(OPFVV3, vfnmadd_vv_h, OP_UUU_H, H2, H2, H2, fnmadd16) | ||
317 | +RVVCALL(OPFVV3, vfnmadd_vv_w, OP_UUU_W, H4, H4, H4, fnmadd32) | ||
318 | +RVVCALL(OPFVV3, vfnmadd_vv_d, OP_UUU_D, H8, H8, H8, fnmadd64) | ||
319 | +GEN_VEXT_VV_ENV(vfnmadd_vv_h, 2, 2, clearh) | ||
320 | +GEN_VEXT_VV_ENV(vfnmadd_vv_w, 4, 4, clearl) | ||
321 | +GEN_VEXT_VV_ENV(vfnmadd_vv_d, 8, 8, clearq) | ||
322 | +RVVCALL(OPFVF3, vfnmadd_vf_h, OP_UUU_H, H2, H2, fnmadd16) | ||
323 | +RVVCALL(OPFVF3, vfnmadd_vf_w, OP_UUU_W, H4, H4, fnmadd32) | ||
324 | +RVVCALL(OPFVF3, vfnmadd_vf_d, OP_UUU_D, H8, H8, fnmadd64) | ||
325 | +GEN_VEXT_VF(vfnmadd_vf_h, 2, 2, clearh) | ||
326 | +GEN_VEXT_VF(vfnmadd_vf_w, 4, 4, clearl) | ||
327 | +GEN_VEXT_VF(vfnmadd_vf_d, 8, 8, clearq) | ||
328 | + | ||
329 | +static uint16_t fmsub16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
330 | +{ | ||
331 | + return float16_muladd(d, b, a, float_muladd_negate_c, s); | ||
332 | +} | ||
333 | + | ||
334 | +static uint32_t fmsub32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
335 | +{ | ||
336 | + return float32_muladd(d, b, a, float_muladd_negate_c, s); | ||
337 | +} | ||
338 | + | ||
339 | +static uint64_t fmsub64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
340 | +{ | ||
341 | + return float64_muladd(d, b, a, float_muladd_negate_c, s); | ||
342 | +} | ||
343 | + | ||
344 | +RVVCALL(OPFVV3, vfmsub_vv_h, OP_UUU_H, H2, H2, H2, fmsub16) | ||
345 | +RVVCALL(OPFVV3, vfmsub_vv_w, OP_UUU_W, H4, H4, H4, fmsub32) | ||
346 | +RVVCALL(OPFVV3, vfmsub_vv_d, OP_UUU_D, H8, H8, H8, fmsub64) | ||
347 | +GEN_VEXT_VV_ENV(vfmsub_vv_h, 2, 2, clearh) | ||
348 | +GEN_VEXT_VV_ENV(vfmsub_vv_w, 4, 4, clearl) | ||
349 | +GEN_VEXT_VV_ENV(vfmsub_vv_d, 8, 8, clearq) | ||
350 | +RVVCALL(OPFVF3, vfmsub_vf_h, OP_UUU_H, H2, H2, fmsub16) | ||
351 | +RVVCALL(OPFVF3, vfmsub_vf_w, OP_UUU_W, H4, H4, fmsub32) | ||
352 | +RVVCALL(OPFVF3, vfmsub_vf_d, OP_UUU_D, H8, H8, fmsub64) | ||
353 | +GEN_VEXT_VF(vfmsub_vf_h, 2, 2, clearh) | ||
354 | +GEN_VEXT_VF(vfmsub_vf_w, 4, 4, clearl) | ||
355 | +GEN_VEXT_VF(vfmsub_vf_d, 8, 8, clearq) | ||
356 | + | ||
357 | +static uint16_t fnmsub16(uint16_t a, uint16_t b, uint16_t d, float_status *s) | ||
358 | +{ | ||
359 | + return float16_muladd(d, b, a, float_muladd_negate_product, s); | ||
360 | +} | ||
361 | + | ||
362 | +static uint32_t fnmsub32(uint32_t a, uint32_t b, uint32_t d, float_status *s) | ||
363 | +{ | ||
364 | + return float32_muladd(d, b, a, float_muladd_negate_product, s); | ||
365 | +} | ||
366 | + | ||
367 | +static uint64_t fnmsub64(uint64_t a, uint64_t b, uint64_t d, float_status *s) | ||
368 | +{ | ||
369 | + return float64_muladd(d, b, a, float_muladd_negate_product, s); | ||
370 | +} | ||
371 | + | ||
372 | +RVVCALL(OPFVV3, vfnmsub_vv_h, OP_UUU_H, H2, H2, H2, fnmsub16) | ||
373 | +RVVCALL(OPFVV3, vfnmsub_vv_w, OP_UUU_W, H4, H4, H4, fnmsub32) | ||
374 | +RVVCALL(OPFVV3, vfnmsub_vv_d, OP_UUU_D, H8, H8, H8, fnmsub64) | ||
375 | +GEN_VEXT_VV_ENV(vfnmsub_vv_h, 2, 2, clearh) | ||
376 | +GEN_VEXT_VV_ENV(vfnmsub_vv_w, 4, 4, clearl) | ||
377 | +GEN_VEXT_VV_ENV(vfnmsub_vv_d, 8, 8, clearq) | ||
378 | +RVVCALL(OPFVF3, vfnmsub_vf_h, OP_UUU_H, H2, H2, fnmsub16) | ||
379 | +RVVCALL(OPFVF3, vfnmsub_vf_w, OP_UUU_W, H4, H4, fnmsub32) | ||
380 | +RVVCALL(OPFVF3, vfnmsub_vf_d, OP_UUU_D, H8, H8, fnmsub64) | ||
381 | +GEN_VEXT_VF(vfnmsub_vf_h, 2, 2, clearh) | ||
382 | +GEN_VEXT_VF(vfnmsub_vf_w, 4, 4, clearl) | ||
383 | +GEN_VEXT_VF(vfnmsub_vf_d, 8, 8, clearq) | ||
384 | -- | ||
385 | 2.27.0 | ||
386 | |||
387 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-36-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 17 +++++ | ||
10 | target/riscv/insn32.decode | 8 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 10 +++ | ||
12 | target/riscv/vector_helper.c | 91 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 126 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfmsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfnmsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfnmsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfnmsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfwmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfwmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfwnmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfwnmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vfwmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfwmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfwnmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfwnmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfwmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vfwmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vfwnmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vfwnmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vfwmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vfwmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vfwnmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vfwnmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
40 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn32.decode | ||
43 | +++ b/target/riscv/insn32.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ vfmsub_vv 101010 . ..... ..... 001 ..... 1010111 @r_vm | ||
45 | vfmsub_vf 101010 . ..... ..... 101 ..... 1010111 @r_vm | ||
46 | vfnmsub_vv 101011 . ..... ..... 001 ..... 1010111 @r_vm | ||
47 | vfnmsub_vf 101011 . ..... ..... 101 ..... 1010111 @r_vm | ||
48 | +vfwmacc_vv 111100 . ..... ..... 001 ..... 1010111 @r_vm | ||
49 | +vfwmacc_vf 111100 . ..... ..... 101 ..... 1010111 @r_vm | ||
50 | +vfwnmacc_vv 111101 . ..... ..... 001 ..... 1010111 @r_vm | ||
51 | +vfwnmacc_vf 111101 . ..... ..... 101 ..... 1010111 @r_vm | ||
52 | +vfwmsac_vv 111110 . ..... ..... 001 ..... 1010111 @r_vm | ||
53 | +vfwmsac_vf 111110 . ..... ..... 101 ..... 1010111 @r_vm | ||
54 | +vfwnmsac_vv 111111 . ..... ..... 001 ..... 1010111 @r_vm | ||
55 | +vfwnmsac_vf 111111 . ..... ..... 101 ..... 1010111 @r_vm | ||
56 | |||
57 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
58 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
59 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
62 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
63 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVF_TRANS(vfmadd_vf, opfvf_check) | ||
64 | GEN_OPFVF_TRANS(vfnmadd_vf, opfvf_check) | ||
65 | GEN_OPFVF_TRANS(vfmsub_vf, opfvf_check) | ||
66 | GEN_OPFVF_TRANS(vfnmsub_vf, opfvf_check) | ||
67 | + | ||
68 | +/* Vector Widening Floating-Point Fused Multiply-Add Instructions */ | ||
69 | +GEN_OPFVV_WIDEN_TRANS(vfwmacc_vv, opfvv_widen_check) | ||
70 | +GEN_OPFVV_WIDEN_TRANS(vfwnmacc_vv, opfvv_widen_check) | ||
71 | +GEN_OPFVV_WIDEN_TRANS(vfwmsac_vv, opfvv_widen_check) | ||
72 | +GEN_OPFVV_WIDEN_TRANS(vfwnmsac_vv, opfvv_widen_check) | ||
73 | +GEN_OPFVF_WIDEN_TRANS(vfwmacc_vf) | ||
74 | +GEN_OPFVF_WIDEN_TRANS(vfwnmacc_vf) | ||
75 | +GEN_OPFVF_WIDEN_TRANS(vfwmsac_vf) | ||
76 | +GEN_OPFVF_WIDEN_TRANS(vfwnmsac_vf) | ||
77 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/riscv/vector_helper.c | ||
80 | +++ b/target/riscv/vector_helper.c | ||
81 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF3, vfnmsub_vf_d, OP_UUU_D, H8, H8, fnmsub64) | ||
82 | GEN_VEXT_VF(vfnmsub_vf_h, 2, 2, clearh) | ||
83 | GEN_VEXT_VF(vfnmsub_vf_w, 4, 4, clearl) | ||
84 | GEN_VEXT_VF(vfnmsub_vf_d, 8, 8, clearq) | ||
85 | + | ||
86 | +/* Vector Widening Floating-Point Fused Multiply-Add Instructions */ | ||
87 | +static uint32_t fwmacc16(uint16_t a, uint16_t b, uint32_t d, float_status *s) | ||
88 | +{ | ||
89 | + return float32_muladd(float16_to_float32(a, true, s), | ||
90 | + float16_to_float32(b, true, s), d, 0, s); | ||
91 | +} | ||
92 | + | ||
93 | +static uint64_t fwmacc32(uint32_t a, uint32_t b, uint64_t d, float_status *s) | ||
94 | +{ | ||
95 | + return float64_muladd(float32_to_float64(a, s), | ||
96 | + float32_to_float64(b, s), d, 0, s); | ||
97 | +} | ||
98 | + | ||
99 | +RVVCALL(OPFVV3, vfwmacc_vv_h, WOP_UUU_H, H4, H2, H2, fwmacc16) | ||
100 | +RVVCALL(OPFVV3, vfwmacc_vv_w, WOP_UUU_W, H8, H4, H4, fwmacc32) | ||
101 | +GEN_VEXT_VV_ENV(vfwmacc_vv_h, 2, 4, clearl) | ||
102 | +GEN_VEXT_VV_ENV(vfwmacc_vv_w, 4, 8, clearq) | ||
103 | +RVVCALL(OPFVF3, vfwmacc_vf_h, WOP_UUU_H, H4, H2, fwmacc16) | ||
104 | +RVVCALL(OPFVF3, vfwmacc_vf_w, WOP_UUU_W, H8, H4, fwmacc32) | ||
105 | +GEN_VEXT_VF(vfwmacc_vf_h, 2, 4, clearl) | ||
106 | +GEN_VEXT_VF(vfwmacc_vf_w, 4, 8, clearq) | ||
107 | + | ||
108 | +static uint32_t fwnmacc16(uint16_t a, uint16_t b, uint32_t d, float_status *s) | ||
109 | +{ | ||
110 | + return float32_muladd(float16_to_float32(a, true, s), | ||
111 | + float16_to_float32(b, true, s), d, | ||
112 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
113 | +} | ||
114 | + | ||
115 | +static uint64_t fwnmacc32(uint32_t a, uint32_t b, uint64_t d, float_status *s) | ||
116 | +{ | ||
117 | + return float64_muladd(float32_to_float64(a, s), | ||
118 | + float32_to_float64(b, s), d, | ||
119 | + float_muladd_negate_c | float_muladd_negate_product, s); | ||
120 | +} | ||
121 | + | ||
122 | +RVVCALL(OPFVV3, vfwnmacc_vv_h, WOP_UUU_H, H4, H2, H2, fwnmacc16) | ||
123 | +RVVCALL(OPFVV3, vfwnmacc_vv_w, WOP_UUU_W, H8, H4, H4, fwnmacc32) | ||
124 | +GEN_VEXT_VV_ENV(vfwnmacc_vv_h, 2, 4, clearl) | ||
125 | +GEN_VEXT_VV_ENV(vfwnmacc_vv_w, 4, 8, clearq) | ||
126 | +RVVCALL(OPFVF3, vfwnmacc_vf_h, WOP_UUU_H, H4, H2, fwnmacc16) | ||
127 | +RVVCALL(OPFVF3, vfwnmacc_vf_w, WOP_UUU_W, H8, H4, fwnmacc32) | ||
128 | +GEN_VEXT_VF(vfwnmacc_vf_h, 2, 4, clearl) | ||
129 | +GEN_VEXT_VF(vfwnmacc_vf_w, 4, 8, clearq) | ||
130 | + | ||
131 | +static uint32_t fwmsac16(uint16_t a, uint16_t b, uint32_t d, float_status *s) | ||
132 | +{ | ||
133 | + return float32_muladd(float16_to_float32(a, true, s), | ||
134 | + float16_to_float32(b, true, s), d, | ||
135 | + float_muladd_negate_c, s); | ||
136 | +} | ||
137 | + | ||
138 | +static uint64_t fwmsac32(uint32_t a, uint32_t b, uint64_t d, float_status *s) | ||
139 | +{ | ||
140 | + return float64_muladd(float32_to_float64(a, s), | ||
141 | + float32_to_float64(b, s), d, | ||
142 | + float_muladd_negate_c, s); | ||
143 | +} | ||
144 | + | ||
145 | +RVVCALL(OPFVV3, vfwmsac_vv_h, WOP_UUU_H, H4, H2, H2, fwmsac16) | ||
146 | +RVVCALL(OPFVV3, vfwmsac_vv_w, WOP_UUU_W, H8, H4, H4, fwmsac32) | ||
147 | +GEN_VEXT_VV_ENV(vfwmsac_vv_h, 2, 4, clearl) | ||
148 | +GEN_VEXT_VV_ENV(vfwmsac_vv_w, 4, 8, clearq) | ||
149 | +RVVCALL(OPFVF3, vfwmsac_vf_h, WOP_UUU_H, H4, H2, fwmsac16) | ||
150 | +RVVCALL(OPFVF3, vfwmsac_vf_w, WOP_UUU_W, H8, H4, fwmsac32) | ||
151 | +GEN_VEXT_VF(vfwmsac_vf_h, 2, 4, clearl) | ||
152 | +GEN_VEXT_VF(vfwmsac_vf_w, 4, 8, clearq) | ||
153 | + | ||
154 | +static uint32_t fwnmsac16(uint16_t a, uint16_t b, uint32_t d, float_status *s) | ||
155 | +{ | ||
156 | + return float32_muladd(float16_to_float32(a, true, s), | ||
157 | + float16_to_float32(b, true, s), d, | ||
158 | + float_muladd_negate_product, s); | ||
159 | +} | ||
160 | + | ||
161 | +static uint64_t fwnmsac32(uint32_t a, uint32_t b, uint64_t d, float_status *s) | ||
162 | +{ | ||
163 | + return float64_muladd(float32_to_float64(a, s), | ||
164 | + float32_to_float64(b, s), d, | ||
165 | + float_muladd_negate_product, s); | ||
166 | +} | ||
167 | + | ||
168 | +RVVCALL(OPFVV3, vfwnmsac_vv_h, WOP_UUU_H, H4, H2, H2, fwnmsac16) | ||
169 | +RVVCALL(OPFVV3, vfwnmsac_vv_w, WOP_UUU_W, H8, H4, H4, fwnmsac32) | ||
170 | +GEN_VEXT_VV_ENV(vfwnmsac_vv_h, 2, 4, clearl) | ||
171 | +GEN_VEXT_VV_ENV(vfwnmsac_vv_w, 4, 8, clearq) | ||
172 | +RVVCALL(OPFVF3, vfwnmsac_vf_h, WOP_UUU_H, H4, H2, fwnmsac16) | ||
173 | +RVVCALL(OPFVF3, vfwnmsac_vf_w, WOP_UUU_W, H8, H4, fwnmsac32) | ||
174 | +GEN_VEXT_VF(vfwnmsac_vf_h, 2, 4, clearl) | ||
175 | +GEN_VEXT_VF(vfwnmsac_vf_w, 4, 8, clearq) | ||
176 | -- | ||
177 | 2.27.0 | ||
178 | |||
179 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-37-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 4 +++ | ||
10 | target/riscv/insn32.decode | 3 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 43 +++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 43 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 93 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfwmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfwmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfwnmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfwnmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_5(vfsqrt_v_h, void, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_5(vfsqrt_v_w, void, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_5(vfsqrt_v_d, void, ptr, ptr, ptr, env, i32) | ||
27 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/riscv/insn32.decode | ||
30 | +++ b/target/riscv/insn32.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | &shift shamt rs1 rd | ||
33 | &atomic aq rl rs2 rs1 rd | ||
34 | &rmrr vm rd rs1 rs2 | ||
35 | +&rmr vm rd rs2 | ||
36 | &rwdvm vm wd rd rs1 rs2 | ||
37 | &r2nfvm vm rd rs1 nf | ||
38 | &rnfvm vm rd rs1 rs2 nf | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | @r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd | ||
41 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | ||
42 | @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | ||
43 | +@r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd | ||
44 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | ||
45 | @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | ||
46 | @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd | ||
47 | @@ -XXX,XX +XXX,XX @@ vfwmsac_vv 111110 . ..... ..... 001 ..... 1010111 @r_vm | ||
48 | vfwmsac_vf 111110 . ..... ..... 101 ..... 1010111 @r_vm | ||
49 | vfwnmsac_vv 111111 . ..... ..... 001 ..... 1010111 @r_vm | ||
50 | vfwnmsac_vf 111111 . ..... ..... 101 ..... 1010111 @r_vm | ||
51 | +vfsqrt_v 100011 . ..... 00000 001 ..... 1010111 @r2_vm | ||
52 | |||
53 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
54 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
55 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
58 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
59 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVF_WIDEN_TRANS(vfwmacc_vf) | ||
60 | GEN_OPFVF_WIDEN_TRANS(vfwnmacc_vf) | ||
61 | GEN_OPFVF_WIDEN_TRANS(vfwmsac_vf) | ||
62 | GEN_OPFVF_WIDEN_TRANS(vfwnmsac_vf) | ||
63 | + | ||
64 | +/* Vector Floating-Point Square-Root Instruction */ | ||
65 | + | ||
66 | +/* | ||
67 | + * If the current SEW does not correspond to a supported IEEE floating-point | ||
68 | + * type, an illegal instruction exception is raised | ||
69 | + */ | ||
70 | +static bool opfv_check(DisasContext *s, arg_rmr *a) | ||
71 | +{ | ||
72 | + return (vext_check_isa_ill(s) && | ||
73 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
74 | + vext_check_reg(s, a->rd, false) && | ||
75 | + vext_check_reg(s, a->rs2, false) && | ||
76 | + (s->sew != 0)); | ||
77 | +} | ||
78 | + | ||
79 | +#define GEN_OPFV_TRANS(NAME, CHECK) \ | ||
80 | +static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ | ||
81 | +{ \ | ||
82 | + if (CHECK(s, a)) { \ | ||
83 | + uint32_t data = 0; \ | ||
84 | + static gen_helper_gvec_3_ptr * const fns[3] = { \ | ||
85 | + gen_helper_##NAME##_h, \ | ||
86 | + gen_helper_##NAME##_w, \ | ||
87 | + gen_helper_##NAME##_d, \ | ||
88 | + }; \ | ||
89 | + TCGLabel *over = gen_new_label(); \ | ||
90 | + gen_set_rm(s, 7); \ | ||
91 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
92 | + \ | ||
93 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
94 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
95 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
96 | + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
97 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
98 | + s->vlen / 8, data, fns[s->sew - 1]); \ | ||
99 | + gen_set_label(over); \ | ||
100 | + return true; \ | ||
101 | + } \ | ||
102 | + return false; \ | ||
103 | +} | ||
104 | + | ||
105 | +GEN_OPFV_TRANS(vfsqrt_v, opfv_check) | ||
106 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/riscv/vector_helper.c | ||
109 | +++ b/target/riscv/vector_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF3, vfwnmsac_vf_h, WOP_UUU_H, H4, H2, fwnmsac16) | ||
111 | RVVCALL(OPFVF3, vfwnmsac_vf_w, WOP_UUU_W, H8, H4, fwnmsac32) | ||
112 | GEN_VEXT_VF(vfwnmsac_vf_h, 2, 4, clearl) | ||
113 | GEN_VEXT_VF(vfwnmsac_vf_w, 4, 8, clearq) | ||
114 | + | ||
115 | +/* Vector Floating-Point Square-Root Instruction */ | ||
116 | +/* (TD, T2, TX2) */ | ||
117 | +#define OP_UU_H uint16_t, uint16_t, uint16_t | ||
118 | +#define OP_UU_W uint32_t, uint32_t, uint32_t | ||
119 | +#define OP_UU_D uint64_t, uint64_t, uint64_t | ||
120 | + | ||
121 | +#define OPFVV1(NAME, TD, T2, TX2, HD, HS2, OP) \ | ||
122 | +static void do_##NAME(void *vd, void *vs2, int i, \ | ||
123 | + CPURISCVState *env) \ | ||
124 | +{ \ | ||
125 | + TX2 s2 = *((T2 *)vs2 + HS2(i)); \ | ||
126 | + *((TD *)vd + HD(i)) = OP(s2, &env->fp_status); \ | ||
127 | +} | ||
128 | + | ||
129 | +#define GEN_VEXT_V_ENV(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
130 | +void HELPER(NAME)(void *vd, void *v0, void *vs2, \ | ||
131 | + CPURISCVState *env, uint32_t desc) \ | ||
132 | +{ \ | ||
133 | + uint32_t vlmax = vext_maxsz(desc) / ESZ; \ | ||
134 | + uint32_t mlen = vext_mlen(desc); \ | ||
135 | + uint32_t vm = vext_vm(desc); \ | ||
136 | + uint32_t vl = env->vl; \ | ||
137 | + uint32_t i; \ | ||
138 | + \ | ||
139 | + if (vl == 0) { \ | ||
140 | + return; \ | ||
141 | + } \ | ||
142 | + for (i = 0; i < vl; i++) { \ | ||
143 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
144 | + continue; \ | ||
145 | + } \ | ||
146 | + do_##NAME(vd, vs2, i, env); \ | ||
147 | + } \ | ||
148 | + CLEAR_FN(vd, vl, vl * DSZ, vlmax * DSZ); \ | ||
149 | +} | ||
150 | + | ||
151 | +RVVCALL(OPFVV1, vfsqrt_v_h, OP_UU_H, H2, H2, float16_sqrt) | ||
152 | +RVVCALL(OPFVV1, vfsqrt_v_w, OP_UU_W, H4, H4, float32_sqrt) | ||
153 | +RVVCALL(OPFVV1, vfsqrt_v_d, OP_UU_D, H8, H8, float64_sqrt) | ||
154 | +GEN_VEXT_V_ENV(vfsqrt_v_h, 2, 2, clearh) | ||
155 | +GEN_VEXT_V_ENV(vfsqrt_v_w, 4, 4, clearl) | ||
156 | +GEN_VEXT_V_ENV(vfsqrt_v_d, 8, 8, clearq) | ||
157 | -- | ||
158 | 2.27.0 | ||
159 | |||
160 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-39-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 19 ++++++ | ||
10 | target/riscv/insn32.decode | 6 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 8 +++ | ||
12 | target/riscv/vector_helper.c | 85 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 118 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfmin_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfmax_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfmax_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfmax_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfsgnj_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfsgnj_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfsgnj_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfsgnjn_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vfsgnjn_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfsgnjn_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfsgnjx_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfsgnjx_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfsgnjx_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vfsgnj_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vfsgnj_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vfsgnj_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vfsgnjn_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vfsgnjn_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vfsgnjn_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vfsgnjx_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vfsgnjx_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vfsgnjx_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
42 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/riscv/insn32.decode | ||
45 | +++ b/target/riscv/insn32.decode | ||
46 | @@ -XXX,XX +XXX,XX @@ vfmin_vv 000100 . ..... ..... 001 ..... 1010111 @r_vm | ||
47 | vfmin_vf 000100 . ..... ..... 101 ..... 1010111 @r_vm | ||
48 | vfmax_vv 000110 . ..... ..... 001 ..... 1010111 @r_vm | ||
49 | vfmax_vf 000110 . ..... ..... 101 ..... 1010111 @r_vm | ||
50 | +vfsgnj_vv 001000 . ..... ..... 001 ..... 1010111 @r_vm | ||
51 | +vfsgnj_vf 001000 . ..... ..... 101 ..... 1010111 @r_vm | ||
52 | +vfsgnjn_vv 001001 . ..... ..... 001 ..... 1010111 @r_vm | ||
53 | +vfsgnjn_vf 001001 . ..... ..... 101 ..... 1010111 @r_vm | ||
54 | +vfsgnjx_vv 001010 . ..... ..... 001 ..... 1010111 @r_vm | ||
55 | +vfsgnjx_vf 001010 . ..... ..... 101 ..... 1010111 @r_vm | ||
56 | |||
57 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
58 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
59 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
62 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
63 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVV_TRANS(vfmin_vv, opfvv_check) | ||
64 | GEN_OPFVV_TRANS(vfmax_vv, opfvv_check) | ||
65 | GEN_OPFVF_TRANS(vfmin_vf, opfvf_check) | ||
66 | GEN_OPFVF_TRANS(vfmax_vf, opfvf_check) | ||
67 | + | ||
68 | +/* Vector Floating-Point Sign-Injection Instructions */ | ||
69 | +GEN_OPFVV_TRANS(vfsgnj_vv, opfvv_check) | ||
70 | +GEN_OPFVV_TRANS(vfsgnjn_vv, opfvv_check) | ||
71 | +GEN_OPFVV_TRANS(vfsgnjx_vv, opfvv_check) | ||
72 | +GEN_OPFVF_TRANS(vfsgnj_vf, opfvf_check) | ||
73 | +GEN_OPFVF_TRANS(vfsgnjn_vf, opfvf_check) | ||
74 | +GEN_OPFVF_TRANS(vfsgnjx_vf, opfvf_check) | ||
75 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/riscv/vector_helper.c | ||
78 | +++ b/target/riscv/vector_helper.c | ||
79 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF2, vfmax_vf_d, OP_UUU_D, H8, H8, float64_maxnum) | ||
80 | GEN_VEXT_VF(vfmax_vf_h, 2, 2, clearh) | ||
81 | GEN_VEXT_VF(vfmax_vf_w, 4, 4, clearl) | ||
82 | GEN_VEXT_VF(vfmax_vf_d, 8, 8, clearq) | ||
83 | + | ||
84 | +/* Vector Floating-Point Sign-Injection Instructions */ | ||
85 | +static uint16_t fsgnj16(uint16_t a, uint16_t b, float_status *s) | ||
86 | +{ | ||
87 | + return deposit64(b, 0, 15, a); | ||
88 | +} | ||
89 | + | ||
90 | +static uint32_t fsgnj32(uint32_t a, uint32_t b, float_status *s) | ||
91 | +{ | ||
92 | + return deposit64(b, 0, 31, a); | ||
93 | +} | ||
94 | + | ||
95 | +static uint64_t fsgnj64(uint64_t a, uint64_t b, float_status *s) | ||
96 | +{ | ||
97 | + return deposit64(b, 0, 63, a); | ||
98 | +} | ||
99 | + | ||
100 | +RVVCALL(OPFVV2, vfsgnj_vv_h, OP_UUU_H, H2, H2, H2, fsgnj16) | ||
101 | +RVVCALL(OPFVV2, vfsgnj_vv_w, OP_UUU_W, H4, H4, H4, fsgnj32) | ||
102 | +RVVCALL(OPFVV2, vfsgnj_vv_d, OP_UUU_D, H8, H8, H8, fsgnj64) | ||
103 | +GEN_VEXT_VV_ENV(vfsgnj_vv_h, 2, 2, clearh) | ||
104 | +GEN_VEXT_VV_ENV(vfsgnj_vv_w, 4, 4, clearl) | ||
105 | +GEN_VEXT_VV_ENV(vfsgnj_vv_d, 8, 8, clearq) | ||
106 | +RVVCALL(OPFVF2, vfsgnj_vf_h, OP_UUU_H, H2, H2, fsgnj16) | ||
107 | +RVVCALL(OPFVF2, vfsgnj_vf_w, OP_UUU_W, H4, H4, fsgnj32) | ||
108 | +RVVCALL(OPFVF2, vfsgnj_vf_d, OP_UUU_D, H8, H8, fsgnj64) | ||
109 | +GEN_VEXT_VF(vfsgnj_vf_h, 2, 2, clearh) | ||
110 | +GEN_VEXT_VF(vfsgnj_vf_w, 4, 4, clearl) | ||
111 | +GEN_VEXT_VF(vfsgnj_vf_d, 8, 8, clearq) | ||
112 | + | ||
113 | +static uint16_t fsgnjn16(uint16_t a, uint16_t b, float_status *s) | ||
114 | +{ | ||
115 | + return deposit64(~b, 0, 15, a); | ||
116 | +} | ||
117 | + | ||
118 | +static uint32_t fsgnjn32(uint32_t a, uint32_t b, float_status *s) | ||
119 | +{ | ||
120 | + return deposit64(~b, 0, 31, a); | ||
121 | +} | ||
122 | + | ||
123 | +static uint64_t fsgnjn64(uint64_t a, uint64_t b, float_status *s) | ||
124 | +{ | ||
125 | + return deposit64(~b, 0, 63, a); | ||
126 | +} | ||
127 | + | ||
128 | +RVVCALL(OPFVV2, vfsgnjn_vv_h, OP_UUU_H, H2, H2, H2, fsgnjn16) | ||
129 | +RVVCALL(OPFVV2, vfsgnjn_vv_w, OP_UUU_W, H4, H4, H4, fsgnjn32) | ||
130 | +RVVCALL(OPFVV2, vfsgnjn_vv_d, OP_UUU_D, H8, H8, H8, fsgnjn64) | ||
131 | +GEN_VEXT_VV_ENV(vfsgnjn_vv_h, 2, 2, clearh) | ||
132 | +GEN_VEXT_VV_ENV(vfsgnjn_vv_w, 4, 4, clearl) | ||
133 | +GEN_VEXT_VV_ENV(vfsgnjn_vv_d, 8, 8, clearq) | ||
134 | +RVVCALL(OPFVF2, vfsgnjn_vf_h, OP_UUU_H, H2, H2, fsgnjn16) | ||
135 | +RVVCALL(OPFVF2, vfsgnjn_vf_w, OP_UUU_W, H4, H4, fsgnjn32) | ||
136 | +RVVCALL(OPFVF2, vfsgnjn_vf_d, OP_UUU_D, H8, H8, fsgnjn64) | ||
137 | +GEN_VEXT_VF(vfsgnjn_vf_h, 2, 2, clearh) | ||
138 | +GEN_VEXT_VF(vfsgnjn_vf_w, 4, 4, clearl) | ||
139 | +GEN_VEXT_VF(vfsgnjn_vf_d, 8, 8, clearq) | ||
140 | + | ||
141 | +static uint16_t fsgnjx16(uint16_t a, uint16_t b, float_status *s) | ||
142 | +{ | ||
143 | + return deposit64(b ^ a, 0, 15, a); | ||
144 | +} | ||
145 | + | ||
146 | +static uint32_t fsgnjx32(uint32_t a, uint32_t b, float_status *s) | ||
147 | +{ | ||
148 | + return deposit64(b ^ a, 0, 31, a); | ||
149 | +} | ||
150 | + | ||
151 | +static uint64_t fsgnjx64(uint64_t a, uint64_t b, float_status *s) | ||
152 | +{ | ||
153 | + return deposit64(b ^ a, 0, 63, a); | ||
154 | +} | ||
155 | + | ||
156 | +RVVCALL(OPFVV2, vfsgnjx_vv_h, OP_UUU_H, H2, H2, H2, fsgnjx16) | ||
157 | +RVVCALL(OPFVV2, vfsgnjx_vv_w, OP_UUU_W, H4, H4, H4, fsgnjx32) | ||
158 | +RVVCALL(OPFVV2, vfsgnjx_vv_d, OP_UUU_D, H8, H8, H8, fsgnjx64) | ||
159 | +GEN_VEXT_VV_ENV(vfsgnjx_vv_h, 2, 2, clearh) | ||
160 | +GEN_VEXT_VV_ENV(vfsgnjx_vv_w, 4, 4, clearl) | ||
161 | +GEN_VEXT_VV_ENV(vfsgnjx_vv_d, 8, 8, clearq) | ||
162 | +RVVCALL(OPFVF2, vfsgnjx_vf_h, OP_UUU_H, H2, H2, fsgnjx16) | ||
163 | +RVVCALL(OPFVF2, vfsgnjx_vf_w, OP_UUU_W, H4, H4, fsgnjx32) | ||
164 | +RVVCALL(OPFVF2, vfsgnjx_vf_d, OP_UUU_D, H8, H8, fsgnjx64) | ||
165 | +GEN_VEXT_VF(vfsgnjx_vf_h, 2, 2, clearh) | ||
166 | +GEN_VEXT_VF(vfsgnjx_vf_w, 4, 4, clearl) | ||
167 | +GEN_VEXT_VF(vfsgnjx_vf_d, 8, 8, clearq) | ||
168 | -- | ||
169 | 2.27.0 | ||
170 | |||
171 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200623215920.2594-40-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 37 +++++ | ||
10 | target/riscv/insn32.decode | 12 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 35 +++++ | ||
12 | target/riscv/vector_helper.c | 174 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 258 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfsgnjn_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfsgnjx_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfsgnjx_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfsgnjx_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vmfeq_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vmfeq_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vmfeq_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vmfne_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vmfne_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vmfne_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vmflt_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vmflt_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vmflt_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vmfle_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vmfle_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vmfle_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vmfeq_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vmfeq_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vmfeq_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vmfne_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vmfne_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vmfne_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vmflt_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vmflt_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vmflt_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vmfle_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vmfle_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vmfle_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vmfgt_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vmfgt_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vmfgt_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vmfge_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vmfge_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vmfge_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vmford_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vmford_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
56 | +DEF_HELPER_6(vmford_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
57 | +DEF_HELPER_6(vmford_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
58 | +DEF_HELPER_6(vmford_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
59 | +DEF_HELPER_6(vmford_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
60 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/riscv/insn32.decode | ||
63 | +++ b/target/riscv/insn32.decode | ||
64 | @@ -XXX,XX +XXX,XX @@ vfsgnjn_vv 001001 . ..... ..... 001 ..... 1010111 @r_vm | ||
65 | vfsgnjn_vf 001001 . ..... ..... 101 ..... 1010111 @r_vm | ||
66 | vfsgnjx_vv 001010 . ..... ..... 001 ..... 1010111 @r_vm | ||
67 | vfsgnjx_vf 001010 . ..... ..... 101 ..... 1010111 @r_vm | ||
68 | +vmfeq_vv 011000 . ..... ..... 001 ..... 1010111 @r_vm | ||
69 | +vmfeq_vf 011000 . ..... ..... 101 ..... 1010111 @r_vm | ||
70 | +vmfne_vv 011100 . ..... ..... 001 ..... 1010111 @r_vm | ||
71 | +vmfne_vf 011100 . ..... ..... 101 ..... 1010111 @r_vm | ||
72 | +vmflt_vv 011011 . ..... ..... 001 ..... 1010111 @r_vm | ||
73 | +vmflt_vf 011011 . ..... ..... 101 ..... 1010111 @r_vm | ||
74 | +vmfle_vv 011001 . ..... ..... 001 ..... 1010111 @r_vm | ||
75 | +vmfle_vf 011001 . ..... ..... 101 ..... 1010111 @r_vm | ||
76 | +vmfgt_vf 011101 . ..... ..... 101 ..... 1010111 @r_vm | ||
77 | +vmfge_vf 011111 . ..... ..... 101 ..... 1010111 @r_vm | ||
78 | +vmford_vv 011010 . ..... ..... 001 ..... 1010111 @r_vm | ||
79 | +vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm | ||
80 | |||
81 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
82 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
83 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
86 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
87 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVV_TRANS(vfsgnjx_vv, opfvv_check) | ||
88 | GEN_OPFVF_TRANS(vfsgnj_vf, opfvf_check) | ||
89 | GEN_OPFVF_TRANS(vfsgnjn_vf, opfvf_check) | ||
90 | GEN_OPFVF_TRANS(vfsgnjx_vf, opfvf_check) | ||
91 | + | ||
92 | +/* Vector Floating-Point Compare Instructions */ | ||
93 | +static bool opfvv_cmp_check(DisasContext *s, arg_rmrr *a) | ||
94 | +{ | ||
95 | + return (vext_check_isa_ill(s) && | ||
96 | + vext_check_reg(s, a->rs2, false) && | ||
97 | + vext_check_reg(s, a->rs1, false) && | ||
98 | + (s->sew != 0) && | ||
99 | + ((vext_check_overlap_group(a->rd, 1, a->rs1, 1 << s->lmul) && | ||
100 | + vext_check_overlap_group(a->rd, 1, a->rs2, 1 << s->lmul)) || | ||
101 | + (s->lmul == 0))); | ||
102 | +} | ||
103 | + | ||
104 | +GEN_OPFVV_TRANS(vmfeq_vv, opfvv_cmp_check) | ||
105 | +GEN_OPFVV_TRANS(vmfne_vv, opfvv_cmp_check) | ||
106 | +GEN_OPFVV_TRANS(vmflt_vv, opfvv_cmp_check) | ||
107 | +GEN_OPFVV_TRANS(vmfle_vv, opfvv_cmp_check) | ||
108 | +GEN_OPFVV_TRANS(vmford_vv, opfvv_cmp_check) | ||
109 | + | ||
110 | +static bool opfvf_cmp_check(DisasContext *s, arg_rmrr *a) | ||
111 | +{ | ||
112 | + return (vext_check_isa_ill(s) && | ||
113 | + vext_check_reg(s, a->rs2, false) && | ||
114 | + (s->sew != 0) && | ||
115 | + (vext_check_overlap_group(a->rd, 1, a->rs2, 1 << s->lmul) || | ||
116 | + (s->lmul == 0))); | ||
117 | +} | ||
118 | + | ||
119 | +GEN_OPFVF_TRANS(vmfeq_vf, opfvf_cmp_check) | ||
120 | +GEN_OPFVF_TRANS(vmfne_vf, opfvf_cmp_check) | ||
121 | +GEN_OPFVF_TRANS(vmflt_vf, opfvf_cmp_check) | ||
122 | +GEN_OPFVF_TRANS(vmfle_vf, opfvf_cmp_check) | ||
123 | +GEN_OPFVF_TRANS(vmfgt_vf, opfvf_cmp_check) | ||
124 | +GEN_OPFVF_TRANS(vmfge_vf, opfvf_cmp_check) | ||
125 | +GEN_OPFVF_TRANS(vmford_vf, opfvf_cmp_check) | ||
126 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/target/riscv/vector_helper.c | ||
129 | +++ b/target/riscv/vector_helper.c | ||
130 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVF2, vfsgnjx_vf_d, OP_UUU_D, H8, H8, fsgnjx64) | ||
131 | GEN_VEXT_VF(vfsgnjx_vf_h, 2, 2, clearh) | ||
132 | GEN_VEXT_VF(vfsgnjx_vf_w, 4, 4, clearl) | ||
133 | GEN_VEXT_VF(vfsgnjx_vf_d, 8, 8, clearq) | ||
134 | + | ||
135 | +/* Vector Floating-Point Compare Instructions */ | ||
136 | +#define GEN_VEXT_CMP_VV_ENV(NAME, ETYPE, H, DO_OP) \ | ||
137 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
138 | + CPURISCVState *env, uint32_t desc) \ | ||
139 | +{ \ | ||
140 | + uint32_t mlen = vext_mlen(desc); \ | ||
141 | + uint32_t vm = vext_vm(desc); \ | ||
142 | + uint32_t vl = env->vl; \ | ||
143 | + uint32_t vlmax = vext_maxsz(desc) / sizeof(ETYPE); \ | ||
144 | + uint32_t i; \ | ||
145 | + \ | ||
146 | + for (i = 0; i < vl; i++) { \ | ||
147 | + ETYPE s1 = *((ETYPE *)vs1 + H(i)); \ | ||
148 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
149 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
150 | + continue; \ | ||
151 | + } \ | ||
152 | + vext_set_elem_mask(vd, mlen, i, \ | ||
153 | + DO_OP(s2, s1, &env->fp_status)); \ | ||
154 | + } \ | ||
155 | + for (; i < vlmax; i++) { \ | ||
156 | + vext_set_elem_mask(vd, mlen, i, 0); \ | ||
157 | + } \ | ||
158 | +} | ||
159 | + | ||
160 | +static bool float16_eq_quiet(uint16_t a, uint16_t b, float_status *s) | ||
161 | +{ | ||
162 | + FloatRelation compare = float16_compare_quiet(a, b, s); | ||
163 | + return compare == float_relation_equal; | ||
164 | +} | ||
165 | + | ||
166 | +GEN_VEXT_CMP_VV_ENV(vmfeq_vv_h, uint16_t, H2, float16_eq_quiet) | ||
167 | +GEN_VEXT_CMP_VV_ENV(vmfeq_vv_w, uint32_t, H4, float32_eq_quiet) | ||
168 | +GEN_VEXT_CMP_VV_ENV(vmfeq_vv_d, uint64_t, H8, float64_eq_quiet) | ||
169 | + | ||
170 | +#define GEN_VEXT_CMP_VF(NAME, ETYPE, H, DO_OP) \ | ||
171 | +void HELPER(NAME)(void *vd, void *v0, uint64_t s1, void *vs2, \ | ||
172 | + CPURISCVState *env, uint32_t desc) \ | ||
173 | +{ \ | ||
174 | + uint32_t mlen = vext_mlen(desc); \ | ||
175 | + uint32_t vm = vext_vm(desc); \ | ||
176 | + uint32_t vl = env->vl; \ | ||
177 | + uint32_t vlmax = vext_maxsz(desc) / sizeof(ETYPE); \ | ||
178 | + uint32_t i; \ | ||
179 | + \ | ||
180 | + for (i = 0; i < vl; i++) { \ | ||
181 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
182 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
183 | + continue; \ | ||
184 | + } \ | ||
185 | + vext_set_elem_mask(vd, mlen, i, \ | ||
186 | + DO_OP(s2, (ETYPE)s1, &env->fp_status)); \ | ||
187 | + } \ | ||
188 | + for (; i < vlmax; i++) { \ | ||
189 | + vext_set_elem_mask(vd, mlen, i, 0); \ | ||
190 | + } \ | ||
191 | +} | ||
192 | + | ||
193 | +GEN_VEXT_CMP_VF(vmfeq_vf_h, uint16_t, H2, float16_eq_quiet) | ||
194 | +GEN_VEXT_CMP_VF(vmfeq_vf_w, uint32_t, H4, float32_eq_quiet) | ||
195 | +GEN_VEXT_CMP_VF(vmfeq_vf_d, uint64_t, H8, float64_eq_quiet) | ||
196 | + | ||
197 | +static bool vmfne16(uint16_t a, uint16_t b, float_status *s) | ||
198 | +{ | ||
199 | + FloatRelation compare = float16_compare_quiet(a, b, s); | ||
200 | + return compare != float_relation_equal; | ||
201 | +} | ||
202 | + | ||
203 | +static bool vmfne32(uint32_t a, uint32_t b, float_status *s) | ||
204 | +{ | ||
205 | + FloatRelation compare = float32_compare_quiet(a, b, s); | ||
206 | + return compare != float_relation_equal; | ||
207 | +} | ||
208 | + | ||
209 | +static bool vmfne64(uint64_t a, uint64_t b, float_status *s) | ||
210 | +{ | ||
211 | + FloatRelation compare = float64_compare_quiet(a, b, s); | ||
212 | + return compare != float_relation_equal; | ||
213 | +} | ||
214 | + | ||
215 | +GEN_VEXT_CMP_VV_ENV(vmfne_vv_h, uint16_t, H2, vmfne16) | ||
216 | +GEN_VEXT_CMP_VV_ENV(vmfne_vv_w, uint32_t, H4, vmfne32) | ||
217 | +GEN_VEXT_CMP_VV_ENV(vmfne_vv_d, uint64_t, H8, vmfne64) | ||
218 | +GEN_VEXT_CMP_VF(vmfne_vf_h, uint16_t, H2, vmfne16) | ||
219 | +GEN_VEXT_CMP_VF(vmfne_vf_w, uint32_t, H4, vmfne32) | ||
220 | +GEN_VEXT_CMP_VF(vmfne_vf_d, uint64_t, H8, vmfne64) | ||
221 | + | ||
222 | +static bool float16_lt(uint16_t a, uint16_t b, float_status *s) | ||
223 | +{ | ||
224 | + FloatRelation compare = float16_compare(a, b, s); | ||
225 | + return compare == float_relation_less; | ||
226 | +} | ||
227 | + | ||
228 | +GEN_VEXT_CMP_VV_ENV(vmflt_vv_h, uint16_t, H2, float16_lt) | ||
229 | +GEN_VEXT_CMP_VV_ENV(vmflt_vv_w, uint32_t, H4, float32_lt) | ||
230 | +GEN_VEXT_CMP_VV_ENV(vmflt_vv_d, uint64_t, H8, float64_lt) | ||
231 | +GEN_VEXT_CMP_VF(vmflt_vf_h, uint16_t, H2, float16_lt) | ||
232 | +GEN_VEXT_CMP_VF(vmflt_vf_w, uint32_t, H4, float32_lt) | ||
233 | +GEN_VEXT_CMP_VF(vmflt_vf_d, uint64_t, H8, float64_lt) | ||
234 | + | ||
235 | +static bool float16_le(uint16_t a, uint16_t b, float_status *s) | ||
236 | +{ | ||
237 | + FloatRelation compare = float16_compare(a, b, s); | ||
238 | + return compare == float_relation_less || | ||
239 | + compare == float_relation_equal; | ||
240 | +} | ||
241 | + | ||
242 | +GEN_VEXT_CMP_VV_ENV(vmfle_vv_h, uint16_t, H2, float16_le) | ||
243 | +GEN_VEXT_CMP_VV_ENV(vmfle_vv_w, uint32_t, H4, float32_le) | ||
244 | +GEN_VEXT_CMP_VV_ENV(vmfle_vv_d, uint64_t, H8, float64_le) | ||
245 | +GEN_VEXT_CMP_VF(vmfle_vf_h, uint16_t, H2, float16_le) | ||
246 | +GEN_VEXT_CMP_VF(vmfle_vf_w, uint32_t, H4, float32_le) | ||
247 | +GEN_VEXT_CMP_VF(vmfle_vf_d, uint64_t, H8, float64_le) | ||
248 | + | ||
249 | +static bool vmfgt16(uint16_t a, uint16_t b, float_status *s) | ||
250 | +{ | ||
251 | + FloatRelation compare = float16_compare(a, b, s); | ||
252 | + return compare == float_relation_greater; | ||
253 | +} | ||
254 | + | ||
255 | +static bool vmfgt32(uint32_t a, uint32_t b, float_status *s) | ||
256 | +{ | ||
257 | + FloatRelation compare = float32_compare(a, b, s); | ||
258 | + return compare == float_relation_greater; | ||
259 | +} | ||
260 | + | ||
261 | +static bool vmfgt64(uint64_t a, uint64_t b, float_status *s) | ||
262 | +{ | ||
263 | + FloatRelation compare = float64_compare(a, b, s); | ||
264 | + return compare == float_relation_greater; | ||
265 | +} | ||
266 | + | ||
267 | +GEN_VEXT_CMP_VF(vmfgt_vf_h, uint16_t, H2, vmfgt16) | ||
268 | +GEN_VEXT_CMP_VF(vmfgt_vf_w, uint32_t, H4, vmfgt32) | ||
269 | +GEN_VEXT_CMP_VF(vmfgt_vf_d, uint64_t, H8, vmfgt64) | ||
270 | + | ||
271 | +static bool vmfge16(uint16_t a, uint16_t b, float_status *s) | ||
272 | +{ | ||
273 | + FloatRelation compare = float16_compare(a, b, s); | ||
274 | + return compare == float_relation_greater || | ||
275 | + compare == float_relation_equal; | ||
276 | +} | ||
277 | + | ||
278 | +static bool vmfge32(uint32_t a, uint32_t b, float_status *s) | ||
279 | +{ | ||
280 | + FloatRelation compare = float32_compare(a, b, s); | ||
281 | + return compare == float_relation_greater || | ||
282 | + compare == float_relation_equal; | ||
283 | +} | ||
284 | + | ||
285 | +static bool vmfge64(uint64_t a, uint64_t b, float_status *s) | ||
286 | +{ | ||
287 | + FloatRelation compare = float64_compare(a, b, s); | ||
288 | + return compare == float_relation_greater || | ||
289 | + compare == float_relation_equal; | ||
290 | +} | ||
291 | + | ||
292 | +GEN_VEXT_CMP_VF(vmfge_vf_h, uint16_t, H2, vmfge16) | ||
293 | +GEN_VEXT_CMP_VF(vmfge_vf_w, uint32_t, H4, vmfge32) | ||
294 | +GEN_VEXT_CMP_VF(vmfge_vf_d, uint64_t, H8, vmfge64) | ||
295 | + | ||
296 | +static bool float16_unordered_quiet(uint16_t a, uint16_t b, float_status *s) | ||
297 | +{ | ||
298 | + FloatRelation compare = float16_compare_quiet(a, b, s); | ||
299 | + return compare == float_relation_unordered; | ||
300 | +} | ||
301 | + | ||
302 | +GEN_VEXT_CMP_VV_ENV(vmford_vv_h, uint16_t, H2, !float16_unordered_quiet) | ||
303 | +GEN_VEXT_CMP_VV_ENV(vmford_vv_w, uint32_t, H4, !float32_unordered_quiet) | ||
304 | +GEN_VEXT_CMP_VV_ENV(vmford_vv_d, uint64_t, H8, !float64_unordered_quiet) | ||
305 | +GEN_VEXT_CMP_VF(vmford_vf_h, uint16_t, H2, !float16_unordered_quiet) | ||
306 | +GEN_VEXT_CMP_VF(vmford_vf_w, uint32_t, H4, !float32_unordered_quiet) | ||
307 | +GEN_VEXT_CMP_VF(vmford_vf_d, uint64_t, H8, !float64_unordered_quiet) | ||
308 | -- | ||
309 | 2.27.0 | ||
310 | |||
311 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200623215920.2594-42-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 4 +++ | ||
10 | target/riscv/insn32.decode | 2 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 38 +++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 24 ++++++++++++++++ | ||
13 | 4 files changed, 68 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmford_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_5(vfclass_v_h, void, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_5(vfclass_v_w, void, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_5(vfclass_v_d, void, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfmerge_vfm_h, void, ptr, ptr, i64, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfmerge_vfm_w, void, ptr, ptr, i64, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfmerge_vfm_d, void, ptr, ptr, i64, ptr, env, i32) | ||
27 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/riscv/insn32.decode | ||
30 | +++ b/target/riscv/insn32.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ vmfge_vf 011111 . ..... ..... 101 ..... 1010111 @r_vm | ||
32 | vmford_vv 011010 . ..... ..... 001 ..... 1010111 @r_vm | ||
33 | vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm | ||
34 | vfclass_v 100011 . ..... 10000 001 ..... 1010111 @r2_vm | ||
35 | +vfmerge_vfm 010111 0 ..... ..... 101 ..... 1010111 @r_vm_0 | ||
36 | +vfmv_v_f 010111 1 00000 ..... 101 ..... 1010111 @r2 | ||
37 | |||
38 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
39 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
40 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
43 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
44 | @@ -XXX,XX +XXX,XX @@ GEN_OPFVF_TRANS(vmford_vf, opfvf_cmp_check) | ||
45 | |||
46 | /* Vector Floating-Point Classify Instruction */ | ||
47 | GEN_OPFV_TRANS(vfclass_v, opfv_check) | ||
48 | + | ||
49 | +/* Vector Floating-Point Merge Instruction */ | ||
50 | +GEN_OPFVF_TRANS(vfmerge_vfm, opfvf_check) | ||
51 | + | ||
52 | +static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a) | ||
53 | +{ | ||
54 | + if (vext_check_isa_ill(s) && | ||
55 | + vext_check_reg(s, a->rd, false) && | ||
56 | + (s->sew != 0)) { | ||
57 | + | ||
58 | + if (s->vl_eq_vlmax) { | ||
59 | + tcg_gen_gvec_dup_i64(s->sew, vreg_ofs(s, a->rd), | ||
60 | + MAXSZ(s), MAXSZ(s), cpu_fpr[a->rs1]); | ||
61 | + } else { | ||
62 | + TCGv_ptr dest; | ||
63 | + TCGv_i32 desc; | ||
64 | + uint32_t data = FIELD_DP32(0, VDATA, LMUL, s->lmul); | ||
65 | + static gen_helper_vmv_vx * const fns[3] = { | ||
66 | + gen_helper_vmv_v_x_h, | ||
67 | + gen_helper_vmv_v_x_w, | ||
68 | + gen_helper_vmv_v_x_d, | ||
69 | + }; | ||
70 | + TCGLabel *over = gen_new_label(); | ||
71 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
72 | + | ||
73 | + dest = tcg_temp_new_ptr(); | ||
74 | + desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data)); | ||
75 | + tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, a->rd)); | ||
76 | + fns[s->sew - 1](dest, cpu_fpr[a->rs1], cpu_env, desc); | ||
77 | + | ||
78 | + tcg_temp_free_ptr(dest); | ||
79 | + tcg_temp_free_i32(desc); | ||
80 | + gen_set_label(over); | ||
81 | + } | ||
82 | + return true; | ||
83 | + } | ||
84 | + return false; | ||
85 | +} | ||
86 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/riscv/vector_helper.c | ||
89 | +++ b/target/riscv/vector_helper.c | ||
90 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPIVV1, vfclass_v_d, OP_UU_D, H8, H8, fclass_d) | ||
91 | GEN_VEXT_V(vfclass_v_h, 2, 2, clearh) | ||
92 | GEN_VEXT_V(vfclass_v_w, 4, 4, clearl) | ||
93 | GEN_VEXT_V(vfclass_v_d, 8, 8, clearq) | ||
94 | + | ||
95 | +/* Vector Floating-Point Merge Instruction */ | ||
96 | +#define GEN_VFMERGE_VF(NAME, ETYPE, H, CLEAR_FN) \ | ||
97 | +void HELPER(NAME)(void *vd, void *v0, uint64_t s1, void *vs2, \ | ||
98 | + CPURISCVState *env, uint32_t desc) \ | ||
99 | +{ \ | ||
100 | + uint32_t mlen = vext_mlen(desc); \ | ||
101 | + uint32_t vm = vext_vm(desc); \ | ||
102 | + uint32_t vl = env->vl; \ | ||
103 | + uint32_t esz = sizeof(ETYPE); \ | ||
104 | + uint32_t vlmax = vext_maxsz(desc) / esz; \ | ||
105 | + uint32_t i; \ | ||
106 | + \ | ||
107 | + for (i = 0; i < vl; i++) { \ | ||
108 | + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ | ||
109 | + *((ETYPE *)vd + H(i)) \ | ||
110 | + = (!vm && !vext_elem_mask(v0, mlen, i) ? s2 : s1); \ | ||
111 | + } \ | ||
112 | + CLEAR_FN(vd, vl, vl * esz, vlmax * esz); \ | ||
113 | +} | ||
114 | + | ||
115 | +GEN_VFMERGE_VF(vfmerge_vfm_h, int16_t, H2, clearh) | ||
116 | +GEN_VFMERGE_VF(vfmerge_vfm_w, int32_t, H4, clearl) | ||
117 | +GEN_VFMERGE_VF(vfmerge_vfm_d, int64_t, H8, clearq) | ||
118 | -- | ||
119 | 2.27.0 | ||
120 | |||
121 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-43-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 13 ++++++++++ | ||
10 | target/riscv/insn32.decode | 4 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 6 +++++ | ||
12 | target/riscv/vector_helper.c | 33 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 56 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vfclass_v_d, void, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfmerge_vfm_h, void, ptr, ptr, i64, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfmerge_vfm_w, void, ptr, ptr, i64, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfmerge_vfm_d, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_5(vfcvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_5(vfcvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_5(vfcvt_xu_f_v_d, void, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_5(vfcvt_x_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_5(vfcvt_x_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_5(vfcvt_x_f_v_d, void, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_5(vfcvt_f_xu_v_h, void, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_5(vfcvt_f_xu_v_w, void, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_5(vfcvt_f_xu_v_d, void, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_5(vfcvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_5(vfcvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_5(vfcvt_f_x_v_d, void, ptr, ptr, ptr, env, i32) | ||
36 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/riscv/insn32.decode | ||
39 | +++ b/target/riscv/insn32.decode | ||
40 | @@ -XXX,XX +XXX,XX @@ vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm | ||
41 | vfclass_v 100011 . ..... 10000 001 ..... 1010111 @r2_vm | ||
42 | vfmerge_vfm 010111 0 ..... ..... 101 ..... 1010111 @r_vm_0 | ||
43 | vfmv_v_f 010111 1 00000 ..... 101 ..... 1010111 @r2 | ||
44 | +vfcvt_xu_f_v 100010 . ..... 00000 001 ..... 1010111 @r2_vm | ||
45 | +vfcvt_x_f_v 100010 . ..... 00001 001 ..... 1010111 @r2_vm | ||
46 | +vfcvt_f_xu_v 100010 . ..... 00010 001 ..... 1010111 @r2_vm | ||
47 | +vfcvt_f_x_v 100010 . ..... 00011 001 ..... 1010111 @r2_vm | ||
48 | |||
49 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
50 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
51 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
54 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a) | ||
56 | } | ||
57 | return false; | ||
58 | } | ||
59 | + | ||
60 | +/* Single-Width Floating-Point/Integer Type-Convert Instructions */ | ||
61 | +GEN_OPFV_TRANS(vfcvt_xu_f_v, opfv_check) | ||
62 | +GEN_OPFV_TRANS(vfcvt_x_f_v, opfv_check) | ||
63 | +GEN_OPFV_TRANS(vfcvt_f_xu_v, opfv_check) | ||
64 | +GEN_OPFV_TRANS(vfcvt_f_x_v, opfv_check) | ||
65 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/riscv/vector_helper.c | ||
68 | +++ b/target/riscv/vector_helper.c | ||
69 | @@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *v0, uint64_t s1, void *vs2, \ | ||
70 | GEN_VFMERGE_VF(vfmerge_vfm_h, int16_t, H2, clearh) | ||
71 | GEN_VFMERGE_VF(vfmerge_vfm_w, int32_t, H4, clearl) | ||
72 | GEN_VFMERGE_VF(vfmerge_vfm_d, int64_t, H8, clearq) | ||
73 | + | ||
74 | +/* Single-Width Floating-Point/Integer Type-Convert Instructions */ | ||
75 | +/* vfcvt.xu.f.v vd, vs2, vm # Convert float to unsigned integer. */ | ||
76 | +RVVCALL(OPFVV1, vfcvt_xu_f_v_h, OP_UU_H, H2, H2, float16_to_uint16) | ||
77 | +RVVCALL(OPFVV1, vfcvt_xu_f_v_w, OP_UU_W, H4, H4, float32_to_uint32) | ||
78 | +RVVCALL(OPFVV1, vfcvt_xu_f_v_d, OP_UU_D, H8, H8, float64_to_uint64) | ||
79 | +GEN_VEXT_V_ENV(vfcvt_xu_f_v_h, 2, 2, clearh) | ||
80 | +GEN_VEXT_V_ENV(vfcvt_xu_f_v_w, 4, 4, clearl) | ||
81 | +GEN_VEXT_V_ENV(vfcvt_xu_f_v_d, 8, 8, clearq) | ||
82 | + | ||
83 | +/* vfcvt.x.f.v vd, vs2, vm # Convert float to signed integer. */ | ||
84 | +RVVCALL(OPFVV1, vfcvt_x_f_v_h, OP_UU_H, H2, H2, float16_to_int16) | ||
85 | +RVVCALL(OPFVV1, vfcvt_x_f_v_w, OP_UU_W, H4, H4, float32_to_int32) | ||
86 | +RVVCALL(OPFVV1, vfcvt_x_f_v_d, OP_UU_D, H8, H8, float64_to_int64) | ||
87 | +GEN_VEXT_V_ENV(vfcvt_x_f_v_h, 2, 2, clearh) | ||
88 | +GEN_VEXT_V_ENV(vfcvt_x_f_v_w, 4, 4, clearl) | ||
89 | +GEN_VEXT_V_ENV(vfcvt_x_f_v_d, 8, 8, clearq) | ||
90 | + | ||
91 | +/* vfcvt.f.xu.v vd, vs2, vm # Convert unsigned integer to float. */ | ||
92 | +RVVCALL(OPFVV1, vfcvt_f_xu_v_h, OP_UU_H, H2, H2, uint16_to_float16) | ||
93 | +RVVCALL(OPFVV1, vfcvt_f_xu_v_w, OP_UU_W, H4, H4, uint32_to_float32) | ||
94 | +RVVCALL(OPFVV1, vfcvt_f_xu_v_d, OP_UU_D, H8, H8, uint64_to_float64) | ||
95 | +GEN_VEXT_V_ENV(vfcvt_f_xu_v_h, 2, 2, clearh) | ||
96 | +GEN_VEXT_V_ENV(vfcvt_f_xu_v_w, 4, 4, clearl) | ||
97 | +GEN_VEXT_V_ENV(vfcvt_f_xu_v_d, 8, 8, clearq) | ||
98 | + | ||
99 | +/* vfcvt.f.x.v vd, vs2, vm # Convert integer to float. */ | ||
100 | +RVVCALL(OPFVV1, vfcvt_f_x_v_h, OP_UU_H, H2, H2, int16_to_float16) | ||
101 | +RVVCALL(OPFVV1, vfcvt_f_x_v_w, OP_UU_W, H4, H4, int32_to_float32) | ||
102 | +RVVCALL(OPFVV1, vfcvt_f_x_v_d, OP_UU_D, H8, H8, int64_to_float64) | ||
103 | +GEN_VEXT_V_ENV(vfcvt_f_x_v_h, 2, 2, clearh) | ||
104 | +GEN_VEXT_V_ENV(vfcvt_f_x_v_w, 4, 4, clearl) | ||
105 | +GEN_VEXT_V_ENV(vfcvt_f_x_v_d, 8, 8, clearq) | ||
106 | -- | ||
107 | 2.27.0 | ||
108 | |||
109 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-44-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 11 ++++++ | ||
10 | target/riscv/insn32.decode | 5 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 48 +++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 42 ++++++++++++++++++++++ | ||
13 | 4 files changed, 106 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vfcvt_f_xu_v_d, void, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_5(vfcvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_5(vfcvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_5(vfcvt_f_x_v_d, void, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_5(vfwcvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_5(vfwcvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_5(vfwcvt_x_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_5(vfwcvt_x_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_5(vfwcvt_f_xu_v_h, void, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_5(vfwcvt_f_xu_v_w, void, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_5(vfwcvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_5(vfwcvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_5(vfwcvt_f_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_5(vfwcvt_f_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
34 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/riscv/insn32.decode | ||
37 | +++ b/target/riscv/insn32.decode | ||
38 | @@ -XXX,XX +XXX,XX @@ vfcvt_xu_f_v 100010 . ..... 00000 001 ..... 1010111 @r2_vm | ||
39 | vfcvt_x_f_v 100010 . ..... 00001 001 ..... 1010111 @r2_vm | ||
40 | vfcvt_f_xu_v 100010 . ..... 00010 001 ..... 1010111 @r2_vm | ||
41 | vfcvt_f_x_v 100010 . ..... 00011 001 ..... 1010111 @r2_vm | ||
42 | +vfwcvt_xu_f_v 100010 . ..... 01000 001 ..... 1010111 @r2_vm | ||
43 | +vfwcvt_x_f_v 100010 . ..... 01001 001 ..... 1010111 @r2_vm | ||
44 | +vfwcvt_f_xu_v 100010 . ..... 01010 001 ..... 1010111 @r2_vm | ||
45 | +vfwcvt_f_x_v 100010 . ..... 01011 001 ..... 1010111 @r2_vm | ||
46 | +vfwcvt_f_f_v 100010 . ..... 01100 001 ..... 1010111 @r2_vm | ||
47 | |||
48 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
49 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
50 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
53 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
54 | @@ -XXX,XX +XXX,XX @@ GEN_OPFV_TRANS(vfcvt_xu_f_v, opfv_check) | ||
55 | GEN_OPFV_TRANS(vfcvt_x_f_v, opfv_check) | ||
56 | GEN_OPFV_TRANS(vfcvt_f_xu_v, opfv_check) | ||
57 | GEN_OPFV_TRANS(vfcvt_f_x_v, opfv_check) | ||
58 | + | ||
59 | +/* Widening Floating-Point/Integer Type-Convert Instructions */ | ||
60 | + | ||
61 | +/* | ||
62 | + * If the current SEW does not correspond to a supported IEEE floating-point | ||
63 | + * type, an illegal instruction exception is raised | ||
64 | + */ | ||
65 | +static bool opfv_widen_check(DisasContext *s, arg_rmr *a) | ||
66 | +{ | ||
67 | + return (vext_check_isa_ill(s) && | ||
68 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | ||
69 | + vext_check_reg(s, a->rd, true) && | ||
70 | + vext_check_reg(s, a->rs2, false) && | ||
71 | + vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs2, | ||
72 | + 1 << s->lmul) && | ||
73 | + (s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0)); | ||
74 | +} | ||
75 | + | ||
76 | +#define GEN_OPFV_WIDEN_TRANS(NAME) \ | ||
77 | +static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ | ||
78 | +{ \ | ||
79 | + if (opfv_widen_check(s, a)) { \ | ||
80 | + uint32_t data = 0; \ | ||
81 | + static gen_helper_gvec_3_ptr * const fns[2] = { \ | ||
82 | + gen_helper_##NAME##_h, \ | ||
83 | + gen_helper_##NAME##_w, \ | ||
84 | + }; \ | ||
85 | + TCGLabel *over = gen_new_label(); \ | ||
86 | + gen_set_rm(s, 7); \ | ||
87 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
88 | + \ | ||
89 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
90 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
91 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
92 | + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
93 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
94 | + s->vlen / 8, data, fns[s->sew - 1]); \ | ||
95 | + gen_set_label(over); \ | ||
96 | + return true; \ | ||
97 | + } \ | ||
98 | + return false; \ | ||
99 | +} | ||
100 | + | ||
101 | +GEN_OPFV_WIDEN_TRANS(vfwcvt_xu_f_v) | ||
102 | +GEN_OPFV_WIDEN_TRANS(vfwcvt_x_f_v) | ||
103 | +GEN_OPFV_WIDEN_TRANS(vfwcvt_f_xu_v) | ||
104 | +GEN_OPFV_WIDEN_TRANS(vfwcvt_f_x_v) | ||
105 | +GEN_OPFV_WIDEN_TRANS(vfwcvt_f_f_v) | ||
106 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/riscv/vector_helper.c | ||
109 | +++ b/target/riscv/vector_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVV1, vfcvt_f_x_v_d, OP_UU_D, H8, H8, int64_to_float64) | ||
111 | GEN_VEXT_V_ENV(vfcvt_f_x_v_h, 2, 2, clearh) | ||
112 | GEN_VEXT_V_ENV(vfcvt_f_x_v_w, 4, 4, clearl) | ||
113 | GEN_VEXT_V_ENV(vfcvt_f_x_v_d, 8, 8, clearq) | ||
114 | + | ||
115 | +/* Widening Floating-Point/Integer Type-Convert Instructions */ | ||
116 | +/* (TD, T2, TX2) */ | ||
117 | +#define WOP_UU_H uint32_t, uint16_t, uint16_t | ||
118 | +#define WOP_UU_W uint64_t, uint32_t, uint32_t | ||
119 | +/* vfwcvt.xu.f.v vd, vs2, vm # Convert float to double-width unsigned integer.*/ | ||
120 | +RVVCALL(OPFVV1, vfwcvt_xu_f_v_h, WOP_UU_H, H4, H2, float16_to_uint32) | ||
121 | +RVVCALL(OPFVV1, vfwcvt_xu_f_v_w, WOP_UU_W, H8, H4, float32_to_uint64) | ||
122 | +GEN_VEXT_V_ENV(vfwcvt_xu_f_v_h, 2, 4, clearl) | ||
123 | +GEN_VEXT_V_ENV(vfwcvt_xu_f_v_w, 4, 8, clearq) | ||
124 | + | ||
125 | +/* vfwcvt.x.f.v vd, vs2, vm # Convert float to double-width signed integer. */ | ||
126 | +RVVCALL(OPFVV1, vfwcvt_x_f_v_h, WOP_UU_H, H4, H2, float16_to_int32) | ||
127 | +RVVCALL(OPFVV1, vfwcvt_x_f_v_w, WOP_UU_W, H8, H4, float32_to_int64) | ||
128 | +GEN_VEXT_V_ENV(vfwcvt_x_f_v_h, 2, 4, clearl) | ||
129 | +GEN_VEXT_V_ENV(vfwcvt_x_f_v_w, 4, 8, clearq) | ||
130 | + | ||
131 | +/* vfwcvt.f.xu.v vd, vs2, vm # Convert unsigned integer to double-width float */ | ||
132 | +RVVCALL(OPFVV1, vfwcvt_f_xu_v_h, WOP_UU_H, H4, H2, uint16_to_float32) | ||
133 | +RVVCALL(OPFVV1, vfwcvt_f_xu_v_w, WOP_UU_W, H8, H4, uint32_to_float64) | ||
134 | +GEN_VEXT_V_ENV(vfwcvt_f_xu_v_h, 2, 4, clearl) | ||
135 | +GEN_VEXT_V_ENV(vfwcvt_f_xu_v_w, 4, 8, clearq) | ||
136 | + | ||
137 | +/* vfwcvt.f.x.v vd, vs2, vm # Convert integer to double-width float. */ | ||
138 | +RVVCALL(OPFVV1, vfwcvt_f_x_v_h, WOP_UU_H, H4, H2, int16_to_float32) | ||
139 | +RVVCALL(OPFVV1, vfwcvt_f_x_v_w, WOP_UU_W, H8, H4, int32_to_float64) | ||
140 | +GEN_VEXT_V_ENV(vfwcvt_f_x_v_h, 2, 4, clearl) | ||
141 | +GEN_VEXT_V_ENV(vfwcvt_f_x_v_w, 4, 8, clearq) | ||
142 | + | ||
143 | +/* | ||
144 | + * vfwcvt.f.f.v vd, vs2, vm # | ||
145 | + * Convert single-width float to double-width float. | ||
146 | + */ | ||
147 | +static uint32_t vfwcvtffv16(uint16_t a, float_status *s) | ||
148 | +{ | ||
149 | + return float16_to_float32(a, true, s); | ||
150 | +} | ||
151 | + | ||
152 | +RVVCALL(OPFVV1, vfwcvt_f_f_v_h, WOP_UU_H, H4, H2, vfwcvtffv16) | ||
153 | +RVVCALL(OPFVV1, vfwcvt_f_f_v_w, WOP_UU_W, H8, H4, float32_to_float64) | ||
154 | +GEN_VEXT_V_ENV(vfwcvt_f_f_v_h, 2, 4, clearl) | ||
155 | +GEN_VEXT_V_ENV(vfwcvt_f_f_v_w, 4, 8, clearq) | ||
156 | -- | ||
157 | 2.27.0 | ||
158 | |||
159 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-45-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 11 ++++++ | ||
10 | target/riscv/insn32.decode | 5 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 48 +++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 39 ++++++++++++++++++++ | ||
13 | 4 files changed, 103 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vfwcvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_5(vfwcvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_5(vfwcvt_f_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_5(vfwcvt_f_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_5(vfncvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_5(vfncvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_5(vfncvt_x_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_5(vfncvt_x_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_5(vfncvt_f_xu_v_h, void, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_5(vfncvt_f_xu_v_w, void, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_5(vfncvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_5(vfncvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_5(vfncvt_f_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_5(vfncvt_f_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
34 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/riscv/insn32.decode | ||
37 | +++ b/target/riscv/insn32.decode | ||
38 | @@ -XXX,XX +XXX,XX @@ vfwcvt_x_f_v 100010 . ..... 01001 001 ..... 1010111 @r2_vm | ||
39 | vfwcvt_f_xu_v 100010 . ..... 01010 001 ..... 1010111 @r2_vm | ||
40 | vfwcvt_f_x_v 100010 . ..... 01011 001 ..... 1010111 @r2_vm | ||
41 | vfwcvt_f_f_v 100010 . ..... 01100 001 ..... 1010111 @r2_vm | ||
42 | +vfncvt_xu_f_v 100010 . ..... 10000 001 ..... 1010111 @r2_vm | ||
43 | +vfncvt_x_f_v 100010 . ..... 10001 001 ..... 1010111 @r2_vm | ||
44 | +vfncvt_f_xu_v 100010 . ..... 10010 001 ..... 1010111 @r2_vm | ||
45 | +vfncvt_f_x_v 100010 . ..... 10011 001 ..... 1010111 @r2_vm | ||
46 | +vfncvt_f_f_v 100010 . ..... 10100 001 ..... 1010111 @r2_vm | ||
47 | |||
48 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
49 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
50 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
53 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
54 | @@ -XXX,XX +XXX,XX @@ GEN_OPFV_WIDEN_TRANS(vfwcvt_x_f_v) | ||
55 | GEN_OPFV_WIDEN_TRANS(vfwcvt_f_xu_v) | ||
56 | GEN_OPFV_WIDEN_TRANS(vfwcvt_f_x_v) | ||
57 | GEN_OPFV_WIDEN_TRANS(vfwcvt_f_f_v) | ||
58 | + | ||
59 | +/* Narrowing Floating-Point/Integer Type-Convert Instructions */ | ||
60 | + | ||
61 | +/* | ||
62 | + * If the current SEW does not correspond to a supported IEEE floating-point | ||
63 | + * type, an illegal instruction exception is raised | ||
64 | + */ | ||
65 | +static bool opfv_narrow_check(DisasContext *s, arg_rmr *a) | ||
66 | +{ | ||
67 | + return (vext_check_isa_ill(s) && | ||
68 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
69 | + vext_check_reg(s, a->rd, false) && | ||
70 | + vext_check_reg(s, a->rs2, true) && | ||
71 | + vext_check_overlap_group(a->rd, 1 << s->lmul, a->rs2, | ||
72 | + 2 << s->lmul) && | ||
73 | + (s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0)); | ||
74 | +} | ||
75 | + | ||
76 | +#define GEN_OPFV_NARROW_TRANS(NAME) \ | ||
77 | +static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ | ||
78 | +{ \ | ||
79 | + if (opfv_narrow_check(s, a)) { \ | ||
80 | + uint32_t data = 0; \ | ||
81 | + static gen_helper_gvec_3_ptr * const fns[2] = { \ | ||
82 | + gen_helper_##NAME##_h, \ | ||
83 | + gen_helper_##NAME##_w, \ | ||
84 | + }; \ | ||
85 | + TCGLabel *over = gen_new_label(); \ | ||
86 | + gen_set_rm(s, 7); \ | ||
87 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
88 | + \ | ||
89 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
90 | + data = FIELD_DP32(data, VDATA, VM, a->vm); \ | ||
91 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
92 | + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
93 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
94 | + s->vlen / 8, data, fns[s->sew - 1]); \ | ||
95 | + gen_set_label(over); \ | ||
96 | + return true; \ | ||
97 | + } \ | ||
98 | + return false; \ | ||
99 | +} | ||
100 | + | ||
101 | +GEN_OPFV_NARROW_TRANS(vfncvt_xu_f_v) | ||
102 | +GEN_OPFV_NARROW_TRANS(vfncvt_x_f_v) | ||
103 | +GEN_OPFV_NARROW_TRANS(vfncvt_f_xu_v) | ||
104 | +GEN_OPFV_NARROW_TRANS(vfncvt_f_x_v) | ||
105 | +GEN_OPFV_NARROW_TRANS(vfncvt_f_f_v) | ||
106 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/riscv/vector_helper.c | ||
109 | +++ b/target/riscv/vector_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVV1, vfwcvt_f_f_v_h, WOP_UU_H, H4, H2, vfwcvtffv16) | ||
111 | RVVCALL(OPFVV1, vfwcvt_f_f_v_w, WOP_UU_W, H8, H4, float32_to_float64) | ||
112 | GEN_VEXT_V_ENV(vfwcvt_f_f_v_h, 2, 4, clearl) | ||
113 | GEN_VEXT_V_ENV(vfwcvt_f_f_v_w, 4, 8, clearq) | ||
114 | + | ||
115 | +/* Narrowing Floating-Point/Integer Type-Convert Instructions */ | ||
116 | +/* (TD, T2, TX2) */ | ||
117 | +#define NOP_UU_H uint16_t, uint32_t, uint32_t | ||
118 | +#define NOP_UU_W uint32_t, uint64_t, uint64_t | ||
119 | +/* vfncvt.xu.f.v vd, vs2, vm # Convert float to unsigned integer. */ | ||
120 | +RVVCALL(OPFVV1, vfncvt_xu_f_v_h, NOP_UU_H, H2, H4, float32_to_uint16) | ||
121 | +RVVCALL(OPFVV1, vfncvt_xu_f_v_w, NOP_UU_W, H4, H8, float64_to_uint32) | ||
122 | +GEN_VEXT_V_ENV(vfncvt_xu_f_v_h, 2, 2, clearh) | ||
123 | +GEN_VEXT_V_ENV(vfncvt_xu_f_v_w, 4, 4, clearl) | ||
124 | + | ||
125 | +/* vfncvt.x.f.v vd, vs2, vm # Convert double-width float to signed integer. */ | ||
126 | +RVVCALL(OPFVV1, vfncvt_x_f_v_h, NOP_UU_H, H2, H4, float32_to_int16) | ||
127 | +RVVCALL(OPFVV1, vfncvt_x_f_v_w, NOP_UU_W, H4, H8, float64_to_int32) | ||
128 | +GEN_VEXT_V_ENV(vfncvt_x_f_v_h, 2, 2, clearh) | ||
129 | +GEN_VEXT_V_ENV(vfncvt_x_f_v_w, 4, 4, clearl) | ||
130 | + | ||
131 | +/* vfncvt.f.xu.v vd, vs2, vm # Convert double-width unsigned integer to float */ | ||
132 | +RVVCALL(OPFVV1, vfncvt_f_xu_v_h, NOP_UU_H, H2, H4, uint32_to_float16) | ||
133 | +RVVCALL(OPFVV1, vfncvt_f_xu_v_w, NOP_UU_W, H4, H8, uint64_to_float32) | ||
134 | +GEN_VEXT_V_ENV(vfncvt_f_xu_v_h, 2, 2, clearh) | ||
135 | +GEN_VEXT_V_ENV(vfncvt_f_xu_v_w, 4, 4, clearl) | ||
136 | + | ||
137 | +/* vfncvt.f.x.v vd, vs2, vm # Convert double-width integer to float. */ | ||
138 | +RVVCALL(OPFVV1, vfncvt_f_x_v_h, NOP_UU_H, H2, H4, int32_to_float16) | ||
139 | +RVVCALL(OPFVV1, vfncvt_f_x_v_w, NOP_UU_W, H4, H8, int64_to_float32) | ||
140 | +GEN_VEXT_V_ENV(vfncvt_f_x_v_h, 2, 2, clearh) | ||
141 | +GEN_VEXT_V_ENV(vfncvt_f_x_v_w, 4, 4, clearl) | ||
142 | + | ||
143 | +/* vfncvt.f.f.v vd, vs2, vm # Convert double float to single-width float. */ | ||
144 | +static uint16_t vfncvtffv16(uint32_t a, float_status *s) | ||
145 | +{ | ||
146 | + return float32_to_float16(a, true, s); | ||
147 | +} | ||
148 | + | ||
149 | +RVVCALL(OPFVV1, vfncvt_f_f_v_h, NOP_UU_H, H2, H4, vfncvtffv16) | ||
150 | +RVVCALL(OPFVV1, vfncvt_f_f_v_w, NOP_UU_W, H4, H8, float64_to_float32) | ||
151 | +GEN_VEXT_V_ENV(vfncvt_f_f_v_h, 2, 2, clearh) | ||
152 | +GEN_VEXT_V_ENV(vfncvt_f_f_v_w, 4, 4, clearl) | ||
153 | -- | ||
154 | 2.27.0 | ||
155 | |||
156 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-46-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 33 +++++++++++ | ||
10 | target/riscv/insn32.decode | 8 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 18 ++++++ | ||
12 | target/riscv/vector_helper.c | 74 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 133 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vfncvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_5(vfncvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_5(vfncvt_f_f_v_h, void, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_5(vfncvt_f_f_v_w, void, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vredsum_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vredsum_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vredmaxu_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vredmaxu_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vredmaxu_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vredmaxu_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vredmax_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | +DEF_HELPER_6(vredmax_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
34 | +DEF_HELPER_6(vredmax_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
35 | +DEF_HELPER_6(vredmax_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
36 | +DEF_HELPER_6(vredminu_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
37 | +DEF_HELPER_6(vredminu_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
38 | +DEF_HELPER_6(vredminu_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
39 | +DEF_HELPER_6(vredminu_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
40 | +DEF_HELPER_6(vredmin_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
41 | +DEF_HELPER_6(vredmin_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
42 | +DEF_HELPER_6(vredmin_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
43 | +DEF_HELPER_6(vredmin_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
44 | +DEF_HELPER_6(vredand_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
45 | +DEF_HELPER_6(vredand_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
46 | +DEF_HELPER_6(vredand_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
47 | +DEF_HELPER_6(vredand_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
48 | +DEF_HELPER_6(vredor_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
49 | +DEF_HELPER_6(vredor_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
50 | +DEF_HELPER_6(vredor_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
51 | +DEF_HELPER_6(vredor_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
52 | +DEF_HELPER_6(vredxor_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
53 | +DEF_HELPER_6(vredxor_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
54 | +DEF_HELPER_6(vredxor_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
55 | +DEF_HELPER_6(vredxor_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
56 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/riscv/insn32.decode | ||
59 | +++ b/target/riscv/insn32.decode | ||
60 | @@ -XXX,XX +XXX,XX @@ vfncvt_x_f_v 100010 . ..... 10001 001 ..... 1010111 @r2_vm | ||
61 | vfncvt_f_xu_v 100010 . ..... 10010 001 ..... 1010111 @r2_vm | ||
62 | vfncvt_f_x_v 100010 . ..... 10011 001 ..... 1010111 @r2_vm | ||
63 | vfncvt_f_f_v 100010 . ..... 10100 001 ..... 1010111 @r2_vm | ||
64 | +vredsum_vs 000000 . ..... ..... 010 ..... 1010111 @r_vm | ||
65 | +vredand_vs 000001 . ..... ..... 010 ..... 1010111 @r_vm | ||
66 | +vredor_vs 000010 . ..... ..... 010 ..... 1010111 @r_vm | ||
67 | +vredxor_vs 000011 . ..... ..... 010 ..... 1010111 @r_vm | ||
68 | +vredminu_vs 000100 . ..... ..... 010 ..... 1010111 @r_vm | ||
69 | +vredmin_vs 000101 . ..... ..... 010 ..... 1010111 @r_vm | ||
70 | +vredmaxu_vs 000110 . ..... ..... 010 ..... 1010111 @r_vm | ||
71 | +vredmax_vs 000111 . ..... ..... 010 ..... 1010111 @r_vm | ||
72 | |||
73 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
74 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
75 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
78 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
79 | @@ -XXX,XX +XXX,XX @@ GEN_OPFV_NARROW_TRANS(vfncvt_x_f_v) | ||
80 | GEN_OPFV_NARROW_TRANS(vfncvt_f_xu_v) | ||
81 | GEN_OPFV_NARROW_TRANS(vfncvt_f_x_v) | ||
82 | GEN_OPFV_NARROW_TRANS(vfncvt_f_f_v) | ||
83 | + | ||
84 | +/* | ||
85 | + *** Vector Reduction Operations | ||
86 | + */ | ||
87 | +/* Vector Single-Width Integer Reduction Instructions */ | ||
88 | +static bool reduction_check(DisasContext *s, arg_rmrr *a) | ||
89 | +{ | ||
90 | + return vext_check_isa_ill(s) && vext_check_reg(s, a->rs2, false); | ||
91 | +} | ||
92 | + | ||
93 | +GEN_OPIVV_TRANS(vredsum_vs, reduction_check) | ||
94 | +GEN_OPIVV_TRANS(vredmaxu_vs, reduction_check) | ||
95 | +GEN_OPIVV_TRANS(vredmax_vs, reduction_check) | ||
96 | +GEN_OPIVV_TRANS(vredminu_vs, reduction_check) | ||
97 | +GEN_OPIVV_TRANS(vredmin_vs, reduction_check) | ||
98 | +GEN_OPIVV_TRANS(vredand_vs, reduction_check) | ||
99 | +GEN_OPIVV_TRANS(vredor_vs, reduction_check) | ||
100 | +GEN_OPIVV_TRANS(vredxor_vs, reduction_check) | ||
101 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/riscv/vector_helper.c | ||
104 | +++ b/target/riscv/vector_helper.c | ||
105 | @@ -XXX,XX +XXX,XX @@ RVVCALL(OPFVV1, vfncvt_f_f_v_h, NOP_UU_H, H2, H4, vfncvtffv16) | ||
106 | RVVCALL(OPFVV1, vfncvt_f_f_v_w, NOP_UU_W, H4, H8, float64_to_float32) | ||
107 | GEN_VEXT_V_ENV(vfncvt_f_f_v_h, 2, 2, clearh) | ||
108 | GEN_VEXT_V_ENV(vfncvt_f_f_v_w, 4, 4, clearl) | ||
109 | + | ||
110 | +/* | ||
111 | + *** Vector Reduction Operations | ||
112 | + */ | ||
113 | +/* Vector Single-Width Integer Reduction Instructions */ | ||
114 | +#define GEN_VEXT_RED(NAME, TD, TS2, HD, HS2, OP, CLEAR_FN)\ | ||
115 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, \ | ||
116 | + void *vs2, CPURISCVState *env, uint32_t desc) \ | ||
117 | +{ \ | ||
118 | + uint32_t mlen = vext_mlen(desc); \ | ||
119 | + uint32_t vm = vext_vm(desc); \ | ||
120 | + uint32_t vl = env->vl; \ | ||
121 | + uint32_t i; \ | ||
122 | + uint32_t tot = env_archcpu(env)->cfg.vlen / 8; \ | ||
123 | + TD s1 = *((TD *)vs1 + HD(0)); \ | ||
124 | + \ | ||
125 | + for (i = 0; i < vl; i++) { \ | ||
126 | + TS2 s2 = *((TS2 *)vs2 + HS2(i)); \ | ||
127 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
128 | + continue; \ | ||
129 | + } \ | ||
130 | + s1 = OP(s1, (TD)s2); \ | ||
131 | + } \ | ||
132 | + *((TD *)vd + HD(0)) = s1; \ | ||
133 | + CLEAR_FN(vd, 1, sizeof(TD), tot); \ | ||
134 | +} | ||
135 | + | ||
136 | +/* vd[0] = sum(vs1[0], vs2[*]) */ | ||
137 | +GEN_VEXT_RED(vredsum_vs_b, int8_t, int8_t, H1, H1, DO_ADD, clearb) | ||
138 | +GEN_VEXT_RED(vredsum_vs_h, int16_t, int16_t, H2, H2, DO_ADD, clearh) | ||
139 | +GEN_VEXT_RED(vredsum_vs_w, int32_t, int32_t, H4, H4, DO_ADD, clearl) | ||
140 | +GEN_VEXT_RED(vredsum_vs_d, int64_t, int64_t, H8, H8, DO_ADD, clearq) | ||
141 | + | ||
142 | +/* vd[0] = maxu(vs1[0], vs2[*]) */ | ||
143 | +GEN_VEXT_RED(vredmaxu_vs_b, uint8_t, uint8_t, H1, H1, DO_MAX, clearb) | ||
144 | +GEN_VEXT_RED(vredmaxu_vs_h, uint16_t, uint16_t, H2, H2, DO_MAX, clearh) | ||
145 | +GEN_VEXT_RED(vredmaxu_vs_w, uint32_t, uint32_t, H4, H4, DO_MAX, clearl) | ||
146 | +GEN_VEXT_RED(vredmaxu_vs_d, uint64_t, uint64_t, H8, H8, DO_MAX, clearq) | ||
147 | + | ||
148 | +/* vd[0] = max(vs1[0], vs2[*]) */ | ||
149 | +GEN_VEXT_RED(vredmax_vs_b, int8_t, int8_t, H1, H1, DO_MAX, clearb) | ||
150 | +GEN_VEXT_RED(vredmax_vs_h, int16_t, int16_t, H2, H2, DO_MAX, clearh) | ||
151 | +GEN_VEXT_RED(vredmax_vs_w, int32_t, int32_t, H4, H4, DO_MAX, clearl) | ||
152 | +GEN_VEXT_RED(vredmax_vs_d, int64_t, int64_t, H8, H8, DO_MAX, clearq) | ||
153 | + | ||
154 | +/* vd[0] = minu(vs1[0], vs2[*]) */ | ||
155 | +GEN_VEXT_RED(vredminu_vs_b, uint8_t, uint8_t, H1, H1, DO_MIN, clearb) | ||
156 | +GEN_VEXT_RED(vredminu_vs_h, uint16_t, uint16_t, H2, H2, DO_MIN, clearh) | ||
157 | +GEN_VEXT_RED(vredminu_vs_w, uint32_t, uint32_t, H4, H4, DO_MIN, clearl) | ||
158 | +GEN_VEXT_RED(vredminu_vs_d, uint64_t, uint64_t, H8, H8, DO_MIN, clearq) | ||
159 | + | ||
160 | +/* vd[0] = min(vs1[0], vs2[*]) */ | ||
161 | +GEN_VEXT_RED(vredmin_vs_b, int8_t, int8_t, H1, H1, DO_MIN, clearb) | ||
162 | +GEN_VEXT_RED(vredmin_vs_h, int16_t, int16_t, H2, H2, DO_MIN, clearh) | ||
163 | +GEN_VEXT_RED(vredmin_vs_w, int32_t, int32_t, H4, H4, DO_MIN, clearl) | ||
164 | +GEN_VEXT_RED(vredmin_vs_d, int64_t, int64_t, H8, H8, DO_MIN, clearq) | ||
165 | + | ||
166 | +/* vd[0] = and(vs1[0], vs2[*]) */ | ||
167 | +GEN_VEXT_RED(vredand_vs_b, int8_t, int8_t, H1, H1, DO_AND, clearb) | ||
168 | +GEN_VEXT_RED(vredand_vs_h, int16_t, int16_t, H2, H2, DO_AND, clearh) | ||
169 | +GEN_VEXT_RED(vredand_vs_w, int32_t, int32_t, H4, H4, DO_AND, clearl) | ||
170 | +GEN_VEXT_RED(vredand_vs_d, int64_t, int64_t, H8, H8, DO_AND, clearq) | ||
171 | + | ||
172 | +/* vd[0] = or(vs1[0], vs2[*]) */ | ||
173 | +GEN_VEXT_RED(vredor_vs_b, int8_t, int8_t, H1, H1, DO_OR, clearb) | ||
174 | +GEN_VEXT_RED(vredor_vs_h, int16_t, int16_t, H2, H2, DO_OR, clearh) | ||
175 | +GEN_VEXT_RED(vredor_vs_w, int32_t, int32_t, H4, H4, DO_OR, clearl) | ||
176 | +GEN_VEXT_RED(vredor_vs_d, int64_t, int64_t, H8, H8, DO_OR, clearq) | ||
177 | + | ||
178 | +/* vd[0] = xor(vs1[0], vs2[*]) */ | ||
179 | +GEN_VEXT_RED(vredxor_vs_b, int8_t, int8_t, H1, H1, DO_XOR, clearb) | ||
180 | +GEN_VEXT_RED(vredxor_vs_h, int16_t, int16_t, H2, H2, DO_XOR, clearh) | ||
181 | +GEN_VEXT_RED(vredxor_vs_w, int32_t, int32_t, H4, H4, DO_XOR, clearl) | ||
182 | +GEN_VEXT_RED(vredxor_vs_d, int64_t, int64_t, H8, H8, DO_XOR, clearq) | ||
183 | -- | ||
184 | 2.27.0 | ||
185 | |||
186 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-47-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 7 +++++++ | ||
10 | target/riscv/insn32.decode | 2 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 4 ++++ | ||
12 | target/riscv/vector_helper.c | 11 +++++++++++ | ||
13 | 4 files changed, 24 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vredxor_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_6(vredxor_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_6(vredxor_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_6(vredxor_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vwredsumu_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vwredsumu_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vwredsumu_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vwredsum_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/riscv/insn32.decode | ||
33 | +++ b/target/riscv/insn32.decode | ||
34 | @@ -XXX,XX +XXX,XX @@ vredminu_vs 000100 . ..... ..... 010 ..... 1010111 @r_vm | ||
35 | vredmin_vs 000101 . ..... ..... 010 ..... 1010111 @r_vm | ||
36 | vredmaxu_vs 000110 . ..... ..... 010 ..... 1010111 @r_vm | ||
37 | vredmax_vs 000111 . ..... ..... 010 ..... 1010111 @r_vm | ||
38 | +vwredsumu_vs 110000 . ..... ..... 000 ..... 1010111 @r_vm | ||
39 | +vwredsum_vs 110001 . ..... ..... 000 ..... 1010111 @r_vm | ||
40 | |||
41 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
42 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
43 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
46 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
47 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVV_TRANS(vredmin_vs, reduction_check) | ||
48 | GEN_OPIVV_TRANS(vredand_vs, reduction_check) | ||
49 | GEN_OPIVV_TRANS(vredor_vs, reduction_check) | ||
50 | GEN_OPIVV_TRANS(vredxor_vs, reduction_check) | ||
51 | + | ||
52 | +/* Vector Widening Integer Reduction Instructions */ | ||
53 | +GEN_OPIVV_WIDEN_TRANS(vwredsum_vs, reduction_check) | ||
54 | +GEN_OPIVV_WIDEN_TRANS(vwredsumu_vs, reduction_check) | ||
55 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/riscv/vector_helper.c | ||
58 | +++ b/target/riscv/vector_helper.c | ||
59 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_RED(vredxor_vs_b, int8_t, int8_t, H1, H1, DO_XOR, clearb) | ||
60 | GEN_VEXT_RED(vredxor_vs_h, int16_t, int16_t, H2, H2, DO_XOR, clearh) | ||
61 | GEN_VEXT_RED(vredxor_vs_w, int32_t, int32_t, H4, H4, DO_XOR, clearl) | ||
62 | GEN_VEXT_RED(vredxor_vs_d, int64_t, int64_t, H8, H8, DO_XOR, clearq) | ||
63 | + | ||
64 | +/* Vector Widening Integer Reduction Instructions */ | ||
65 | +/* signed sum reduction into double-width accumulator */ | ||
66 | +GEN_VEXT_RED(vwredsum_vs_b, int16_t, int8_t, H2, H1, DO_ADD, clearh) | ||
67 | +GEN_VEXT_RED(vwredsum_vs_h, int32_t, int16_t, H4, H2, DO_ADD, clearl) | ||
68 | +GEN_VEXT_RED(vwredsum_vs_w, int64_t, int32_t, H8, H4, DO_ADD, clearq) | ||
69 | + | ||
70 | +/* Unsigned sum reduction into double-width accumulator */ | ||
71 | +GEN_VEXT_RED(vwredsumu_vs_b, uint16_t, uint8_t, H2, H1, DO_ADD, clearh) | ||
72 | +GEN_VEXT_RED(vwredsumu_vs_h, uint32_t, uint16_t, H4, H2, DO_ADD, clearl) | ||
73 | +GEN_VEXT_RED(vwredsumu_vs_w, uint64_t, uint32_t, H8, H4, DO_ADD, clearq) | ||
74 | -- | ||
75 | 2.27.0 | ||
76 | |||
77 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-48-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 10 +++++++ | ||
10 | target/riscv/insn32.decode | 4 +++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 5 ++++ | ||
12 | target/riscv/vector_helper.c | 39 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 58 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vwredsumu_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_6(vwredsum_vs_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_6(vwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_6(vwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfredsum_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfredmax_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vfredmax_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vfredmax_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vfredmin_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
31 | +DEF_HELPER_6(vfredmin_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
32 | +DEF_HELPER_6(vfredmin_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
33 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/riscv/insn32.decode | ||
36 | +++ b/target/riscv/insn32.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ vredmaxu_vs 000110 . ..... ..... 010 ..... 1010111 @r_vm | ||
38 | vredmax_vs 000111 . ..... ..... 010 ..... 1010111 @r_vm | ||
39 | vwredsumu_vs 110000 . ..... ..... 000 ..... 1010111 @r_vm | ||
40 | vwredsum_vs 110001 . ..... ..... 000 ..... 1010111 @r_vm | ||
41 | +# Vector ordered and unordered reduction sum | ||
42 | +vfredsum_vs 0000-1 . ..... ..... 001 ..... 1010111 @r_vm | ||
43 | +vfredmin_vs 000101 . ..... ..... 001 ..... 1010111 @r_vm | ||
44 | +vfredmax_vs 000111 . ..... ..... 001 ..... 1010111 @r_vm | ||
45 | |||
46 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
47 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
48 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
51 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
52 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVV_TRANS(vredxor_vs, reduction_check) | ||
53 | /* Vector Widening Integer Reduction Instructions */ | ||
54 | GEN_OPIVV_WIDEN_TRANS(vwredsum_vs, reduction_check) | ||
55 | GEN_OPIVV_WIDEN_TRANS(vwredsumu_vs, reduction_check) | ||
56 | + | ||
57 | +/* Vector Single-Width Floating-Point Reduction Instructions */ | ||
58 | +GEN_OPFVV_TRANS(vfredsum_vs, reduction_check) | ||
59 | +GEN_OPFVV_TRANS(vfredmax_vs, reduction_check) | ||
60 | +GEN_OPFVV_TRANS(vfredmin_vs, reduction_check) | ||
61 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/riscv/vector_helper.c | ||
64 | +++ b/target/riscv/vector_helper.c | ||
65 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_RED(vwredsum_vs_w, int64_t, int32_t, H8, H4, DO_ADD, clearq) | ||
66 | GEN_VEXT_RED(vwredsumu_vs_b, uint16_t, uint8_t, H2, H1, DO_ADD, clearh) | ||
67 | GEN_VEXT_RED(vwredsumu_vs_h, uint32_t, uint16_t, H4, H2, DO_ADD, clearl) | ||
68 | GEN_VEXT_RED(vwredsumu_vs_w, uint64_t, uint32_t, H8, H4, DO_ADD, clearq) | ||
69 | + | ||
70 | +/* Vector Single-Width Floating-Point Reduction Instructions */ | ||
71 | +#define GEN_VEXT_FRED(NAME, TD, TS2, HD, HS2, OP, CLEAR_FN)\ | ||
72 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, \ | ||
73 | + void *vs2, CPURISCVState *env, \ | ||
74 | + uint32_t desc) \ | ||
75 | +{ \ | ||
76 | + uint32_t mlen = vext_mlen(desc); \ | ||
77 | + uint32_t vm = vext_vm(desc); \ | ||
78 | + uint32_t vl = env->vl; \ | ||
79 | + uint32_t i; \ | ||
80 | + uint32_t tot = env_archcpu(env)->cfg.vlen / 8; \ | ||
81 | + TD s1 = *((TD *)vs1 + HD(0)); \ | ||
82 | + \ | ||
83 | + for (i = 0; i < vl; i++) { \ | ||
84 | + TS2 s2 = *((TS2 *)vs2 + HS2(i)); \ | ||
85 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
86 | + continue; \ | ||
87 | + } \ | ||
88 | + s1 = OP(s1, (TD)s2, &env->fp_status); \ | ||
89 | + } \ | ||
90 | + *((TD *)vd + HD(0)) = s1; \ | ||
91 | + CLEAR_FN(vd, 1, sizeof(TD), tot); \ | ||
92 | +} | ||
93 | + | ||
94 | +/* Unordered sum */ | ||
95 | +GEN_VEXT_FRED(vfredsum_vs_h, uint16_t, uint16_t, H2, H2, float16_add, clearh) | ||
96 | +GEN_VEXT_FRED(vfredsum_vs_w, uint32_t, uint32_t, H4, H4, float32_add, clearl) | ||
97 | +GEN_VEXT_FRED(vfredsum_vs_d, uint64_t, uint64_t, H8, H8, float64_add, clearq) | ||
98 | + | ||
99 | +/* Maximum value */ | ||
100 | +GEN_VEXT_FRED(vfredmax_vs_h, uint16_t, uint16_t, H2, H2, float16_maxnum, clearh) | ||
101 | +GEN_VEXT_FRED(vfredmax_vs_w, uint32_t, uint32_t, H4, H4, float32_maxnum, clearl) | ||
102 | +GEN_VEXT_FRED(vfredmax_vs_d, uint64_t, uint64_t, H8, H8, float64_maxnum, clearq) | ||
103 | + | ||
104 | +/* Minimum value */ | ||
105 | +GEN_VEXT_FRED(vfredmin_vs_h, uint16_t, uint16_t, H2, H2, float16_minnum, clearh) | ||
106 | +GEN_VEXT_FRED(vfredmin_vs_w, uint32_t, uint32_t, H4, H4, float32_minnum, clearl) | ||
107 | +GEN_VEXT_FRED(vfredmin_vs_d, uint64_t, uint64_t, H8, H8, float64_minnum, clearq) | ||
108 | -- | ||
109 | 2.27.0 | ||
110 | |||
111 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-49-zhiwei_liu@c-sky.com | ||
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | --- | ||
9 | target/riscv/helper.h | 3 ++ | ||
10 | target/riscv/insn32.decode | 2 ++ | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 3 ++ | ||
12 | target/riscv/vector_helper.c | 46 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 54 insertions(+) | ||
14 | |||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/helper.h | ||
18 | +++ b/target/riscv/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfredmax_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_6(vfredmin_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfredmin_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_6(vfredmin_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/riscv/insn32.decode | ||
29 | +++ b/target/riscv/insn32.decode | ||
30 | @@ -XXX,XX +XXX,XX @@ vwredsum_vs 110001 . ..... ..... 000 ..... 1010111 @r_vm | ||
31 | vfredsum_vs 0000-1 . ..... ..... 001 ..... 1010111 @r_vm | ||
32 | vfredmin_vs 000101 . ..... ..... 001 ..... 1010111 @r_vm | ||
33 | vfredmax_vs 000111 . ..... ..... 001 ..... 1010111 @r_vm | ||
34 | +# Vector widening ordered and unordered float reduction sum | ||
35 | +vfwredsum_vs 1100-1 . ..... ..... 001 ..... 1010111 @r_vm | ||
36 | |||
37 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
38 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
39 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
42 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
43 | @@ -XXX,XX +XXX,XX @@ GEN_OPIVV_WIDEN_TRANS(vwredsumu_vs, reduction_check) | ||
44 | GEN_OPFVV_TRANS(vfredsum_vs, reduction_check) | ||
45 | GEN_OPFVV_TRANS(vfredmax_vs, reduction_check) | ||
46 | GEN_OPFVV_TRANS(vfredmin_vs, reduction_check) | ||
47 | + | ||
48 | +/* Vector Widening Floating-Point Reduction Instructions */ | ||
49 | +GEN_OPFVV_WIDEN_TRANS(vfwredsum_vs, reduction_check) | ||
50 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/riscv/vector_helper.c | ||
53 | +++ b/target/riscv/vector_helper.c | ||
54 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_FRED(vfredmax_vs_d, uint64_t, uint64_t, H8, H8, float64_maxnum, clearq) | ||
55 | GEN_VEXT_FRED(vfredmin_vs_h, uint16_t, uint16_t, H2, H2, float16_minnum, clearh) | ||
56 | GEN_VEXT_FRED(vfredmin_vs_w, uint32_t, uint32_t, H4, H4, float32_minnum, clearl) | ||
57 | GEN_VEXT_FRED(vfredmin_vs_d, uint64_t, uint64_t, H8, H8, float64_minnum, clearq) | ||
58 | + | ||
59 | +/* Vector Widening Floating-Point Reduction Instructions */ | ||
60 | +/* Unordered reduce 2*SEW = 2*SEW + sum(promote(SEW)) */ | ||
61 | +void HELPER(vfwredsum_vs_h)(void *vd, void *v0, void *vs1, | ||
62 | + void *vs2, CPURISCVState *env, uint32_t desc) | ||
63 | +{ | ||
64 | + uint32_t mlen = vext_mlen(desc); | ||
65 | + uint32_t vm = vext_vm(desc); | ||
66 | + uint32_t vl = env->vl; | ||
67 | + uint32_t i; | ||
68 | + uint32_t tot = env_archcpu(env)->cfg.vlen / 8; | ||
69 | + uint32_t s1 = *((uint32_t *)vs1 + H4(0)); | ||
70 | + | ||
71 | + for (i = 0; i < vl; i++) { | ||
72 | + uint16_t s2 = *((uint16_t *)vs2 + H2(i)); | ||
73 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
74 | + continue; | ||
75 | + } | ||
76 | + s1 = float32_add(s1, float16_to_float32(s2, true, &env->fp_status), | ||
77 | + &env->fp_status); | ||
78 | + } | ||
79 | + *((uint32_t *)vd + H4(0)) = s1; | ||
80 | + clearl(vd, 1, sizeof(uint32_t), tot); | ||
81 | +} | ||
82 | + | ||
83 | +void HELPER(vfwredsum_vs_w)(void *vd, void *v0, void *vs1, | ||
84 | + void *vs2, CPURISCVState *env, uint32_t desc) | ||
85 | +{ | ||
86 | + uint32_t mlen = vext_mlen(desc); | ||
87 | + uint32_t vm = vext_vm(desc); | ||
88 | + uint32_t vl = env->vl; | ||
89 | + uint32_t i; | ||
90 | + uint32_t tot = env_archcpu(env)->cfg.vlen / 8; | ||
91 | + uint64_t s1 = *((uint64_t *)vs1); | ||
92 | + | ||
93 | + for (i = 0; i < vl; i++) { | ||
94 | + uint32_t s2 = *((uint32_t *)vs2 + H4(i)); | ||
95 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
96 | + continue; | ||
97 | + } | ||
98 | + s1 = float64_add(s1, float32_to_float64(s2, &env->fp_status), | ||
99 | + &env->fp_status); | ||
100 | + } | ||
101 | + *((uint64_t *)vd) = s1; | ||
102 | + clearq(vd, 1, sizeof(uint64_t), tot); | ||
103 | +} | ||
104 | -- | ||
105 | 2.27.0 | ||
106 | |||
107 | diff view generated by jsdifflib |