1 | The following changes since commit 553cf5d7c47bee05a3dec9461c1f8430316d516b: | 1 | The following changes since commit c95bd5ff1660883d15ad6e0005e4c8571604f51a: |
---|---|---|---|
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 remote-tracking branch 'remotes/philmd/tags/mips-fixes-20210322' into staging (2021-03-22 14:26:13 +0000) |
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 | git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20210322-2 |
8 | 8 | ||
9 | for you to fetch changes up to b39d59434ea10649fdb9e0a339c30c76e38c5e17: | 9 | for you to fetch changes up to 9a27f69bd668d9d71674407badc412ce1231c7d5: |
10 | 10 | ||
11 | target/riscv: configure and turn on vector extension from command line (2020-06-26 14:22:15 -0700) | 11 | target/riscv: Prevent lost illegal instruction exceptions (2021-03-22 21:54:40 -0400) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | This PR contains two patches to improve PLIC support in QEMU. | 14 | RISC-V PR for 6.0 |
15 | 15 | ||
16 | The rest of the PR is adding support for the v0.7.1 RISC-V vector | 16 | This PR includes: |
17 | extensions. This is experimental support as the vector extensions are | 17 | - Fix for vector CSR access |
18 | still in a draft state. | 18 | - Improvements to the Ibex UART device |
19 | - PMP improvements and bug fixes | ||
20 | - Hypervisor extension bug fixes | ||
21 | - ramfb support for the virt machine | ||
22 | - Fast read support for SST flash | ||
23 | - Improvements to the microchip_pfsoc machine | ||
19 | 24 | ||
20 | ---------------------------------------------------------------- | 25 | ---------------------------------------------------------------- |
21 | Jessica Clarke (2): | 26 | Alexander Wagner (1): |
22 | riscv: plic: Honour source priorities | 27 | hw/char: disable ibex uart receive if the buffer is full |
23 | riscv: plic: Add a couple of mising sifive_plic_update calls | ||
24 | 28 | ||
25 | LIU Zhiwei (61): | 29 | Asherah Connor (2): |
26 | target/riscv: add vector extension field in CPURISCVState | 30 | hw/riscv: Add fw_cfg support to virt |
27 | target/riscv: implementation-defined constant parameters | 31 | hw/riscv: allow ramfb on virt |
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 | 32 | ||
88 | target/riscv/cpu.h | 82 +- | 33 | Bin Meng (3): |
89 | target/riscv/cpu_bits.h | 15 + | 34 | hw/block: m25p80: Support fast read for SST flashes |
90 | target/riscv/helper.h | 1069 +++++++ | 35 | hw/riscv: microchip_pfsoc: Map EMMC/SD mux register |
91 | target/riscv/internals.h | 41 + | 36 | docs/system: riscv: Add documentation for 'microchip-icicle-kit' machine |
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 | 37 | ||
38 | Frank Chang (1): | ||
39 | target/riscv: fix vs() to return proper error code | ||
40 | |||
41 | Georg Kotheimer (6): | ||
42 | target/riscv: Adjust privilege level for HLV(X)/HSV instructions | ||
43 | target/riscv: Make VSTIP and VSEIP read-only in hip | ||
44 | target/riscv: Use background registers also for MSTATUS_MPV | ||
45 | target/riscv: Fix read and write accesses to vsip and vsie | ||
46 | target/riscv: Add proper two-stage lookup exception detection | ||
47 | target/riscv: Prevent lost illegal instruction exceptions | ||
48 | |||
49 | Jim Shu (3): | ||
50 | target/riscv: propagate PMP permission to TLB page | ||
51 | target/riscv: add log of PMP permission checking | ||
52 | target/riscv: flush TLB pages if PMP permission has been changed | ||
53 | |||
54 | docs/system/riscv/microchip-icicle-kit.rst | 89 ++++++++++++++ | ||
55 | docs/system/target-riscv.rst | 1 + | ||
56 | include/hw/char/ibex_uart.h | 4 + | ||
57 | include/hw/riscv/microchip_pfsoc.h | 1 + | ||
58 | include/hw/riscv/virt.h | 2 + | ||
59 | target/riscv/cpu.h | 4 + | ||
60 | target/riscv/pmp.h | 4 +- | ||
61 | hw/block/m25p80.c | 3 + | ||
62 | hw/char/ibex_uart.c | 23 +++- | ||
63 | hw/riscv/microchip_pfsoc.c | 6 + | ||
64 | hw/riscv/virt.c | 33 ++++++ | ||
65 | target/riscv/cpu.c | 1 + | ||
66 | target/riscv/cpu_helper.c | 144 +++++++++++++++-------- | ||
67 | target/riscv/csr.c | 77 +++++++------ | ||
68 | target/riscv/pmp.c | 84 ++++++++++---- | ||
69 | target/riscv/translate.c | 179 +---------------------------- | ||
70 | hw/riscv/Kconfig | 1 + | ||
71 | 17 files changed, 367 insertions(+), 289 deletions(-) | ||
72 | create mode 100644 docs/system/riscv/microchip-icicle-kit.rst | ||
73 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Frank Chang <frank.chang@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | vs() should return -RISCV_EXCP_ILLEGAL_INST instead of -1 if rvv feature |
4 | is not enabled. | ||
5 | |||
6 | If -1 is returned, exception will be raised and cs->exception_index will | ||
7 | be set to the negative return value. The exception will then be treated | ||
8 | as an instruction access fault instead of illegal instruction fault. | ||
9 | |||
10 | Signed-off-by: Frank Chang <frank.chang@sifive.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
6 | Message-id: 20200623215920.2594-12-zhiwei_liu@c-sky.com | 13 | Message-id: 20210223065935.20208-1-frank.chang@sifive.com |
7 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 14 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
8 | --- | 15 | --- |
9 | target/riscv/helper.h | 49 +++++++ | 16 | target/riscv/csr.c | 2 +- |
10 | target/riscv/insn32.decode | 16 ++ | 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | target/riscv/insn_trans/trans_rvv.inc.c | 186 ++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 111 ++++++++++++++ | ||
13 | 4 files changed, 362 insertions(+) | ||
14 | 18 | ||
15 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 19 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/riscv/helper.h | 21 | --- a/target/riscv/csr.c |
18 | +++ b/target/riscv/helper.h | 22 | +++ b/target/riscv/csr.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(vec_rsubs8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 23 | @@ -XXX,XX +XXX,XX @@ static int vs(CPURISCVState *env, int csrno) |
20 | DEF_HELPER_FLAGS_4(vec_rsubs16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 24 | if (env->misa & RVV) { |
21 | DEF_HELPER_FLAGS_4(vec_rsubs32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 25 | return 0; |
22 | DEF_HELPER_FLAGS_4(vec_rsubs64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) | 26 | } |
23 | + | 27 | - return -1; |
24 | +DEF_HELPER_6(vwaddu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | 28 | + return -RISCV_EXCP_ILLEGAL_INST; |
25 | +DEF_HELPER_6(vwaddu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
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 | } | 29 | } |
106 | 30 | ||
107 | +/* | 31 | static int ctr(CPURISCVState *env, int csrno) |
108 | + * The destination vector register group cannot overlap a source vector register | ||
109 | + * group of a different element width. (Section 11.2) | ||
110 | + */ | ||
111 | +static inline bool vext_check_overlap_group(int rd, int dlen, int rs, int slen) | ||
112 | +{ | ||
113 | + return ((rd >= rs + slen) || (rs >= rd + dlen)); | ||
114 | +} | ||
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 | } | ||
120 | |||
121 | GEN_OPIVI_GVEC_TRANS(vrsub_vi, 0, vrsub_vx, rsubi) | ||
122 | + | ||
123 | +/* Vector Widening Integer Add/Subtract */ | ||
124 | + | ||
125 | +/* OPIVV with WIDEN */ | ||
126 | +static bool opivv_widen_check(DisasContext *s, arg_rmrr *a) | ||
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 | } | ||
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 | -- | 32 | -- |
420 | 2.27.0 | 33 | 2.30.1 |
421 | 34 | ||
422 | 35 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Alexander Wagner <alexander.wagner@ulal.de> |
---|---|---|---|
2 | 2 | ||
3 | Vector extension is default off. The only way to use vector extension is | 3 | Not disabling the UART leads to QEMU overwriting the UART receive buffer with |
4 | 1. use cpu rv32 or rv64 | 4 | the newest received byte. The rx_level variable is added to allow the use of |
5 | 2. turn on it by command line | 5 | the existing OpenTitan driver libraries. |
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 | Signed-off-by: Alexander Wagner <alexander.wagner@ulal.de> |
9 | elen is the max operator size in bits, default value is 64 bit. | ||
10 | vext_spec is the vector specification version, default value is v0.7.1. | ||
11 | These properties can be specified with other values. | ||
12 | |||
13 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20210309152130.13038-1-alexander.wagner@ulal.de |
16 | Message-id: 20200623215920.2594-62-zhiwei_liu@c-sky.com | ||
17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
18 | --- | 11 | --- |
19 | target/riscv/cpu.h | 4 +++- | 12 | include/hw/char/ibex_uart.h | 4 ++++ |
20 | target/riscv/cpu.c | 43 +++++++++++++++++++++++++++++++++++++++++++ | 13 | hw/char/ibex_uart.c | 23 ++++++++++++++++++----- |
21 | 2 files changed, 46 insertions(+), 1 deletion(-) | 14 | 2 files changed, 22 insertions(+), 5 deletions(-) |
22 | 15 | ||
23 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | 16 | diff --git a/include/hw/char/ibex_uart.h b/include/hw/char/ibex_uart.h |
24 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/riscv/cpu.h | 18 | --- a/include/hw/char/ibex_uart.h |
26 | +++ b/target/riscv/cpu.h | 19 | +++ b/include/hw/char/ibex_uart.h |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct CPURISCVState CPURISCVState; | 20 | @@ -XXX,XX +XXX,XX @@ REG32(FIFO_CTRL, 0x1c) |
28 | 21 | FIELD(FIFO_CTRL, RXILVL, 2, 3) | |
29 | #include "pmp.h" | 22 | FIELD(FIFO_CTRL, TXILVL, 5, 2) |
30 | 23 | REG32(FIFO_STATUS, 0x20) | |
31 | -#define RV_VLEN_MAX 512 | 24 | + FIELD(FIFO_STATUS, TXLVL, 0, 5) |
32 | +#define RV_VLEN_MAX 256 | 25 | + FIELD(FIFO_STATUS, RXLVL, 16, 5) |
33 | 26 | REG32(OVRD, 0x24) | |
34 | FIELD(VTYPE, VLMUL, 0, 2) | 27 | REG32(VAL, 0x28) |
35 | FIELD(VTYPE, VSEW, 2, 3) | 28 | REG32(TIMEOUT_CTRL, 0x2c) |
36 | @@ -XXX,XX +XXX,XX @@ typedef struct RISCVCPU { | 29 | @@ -XXX,XX +XXX,XX @@ struct IbexUartState { |
37 | bool ext_s; | 30 | uint8_t tx_fifo[IBEX_UART_TX_FIFO_SIZE]; |
38 | bool ext_u; | 31 | uint32_t tx_level; |
39 | bool ext_h; | 32 | |
40 | + bool ext_v; | 33 | + uint32_t rx_level; |
41 | bool ext_counters; | 34 | + |
42 | bool ext_ifencei; | 35 | QEMUTimer *fifo_trigger_handle; |
43 | bool ext_icsr; | 36 | uint64_t char_tx_time; |
44 | 37 | ||
45 | char *priv_spec; | 38 | diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c |
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 | ||
52 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/target/riscv/cpu.c | 40 | --- a/hw/char/ibex_uart.c |
54 | +++ b/target/riscv/cpu.c | 41 | +++ b/hw/char/ibex_uart.c |
55 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) | 42 | @@ -XXX,XX +XXX,XX @@ static int ibex_uart_can_receive(void *opaque) |
56 | if (cpu->cfg.ext_h) { | 43 | { |
57 | target_misa |= RVH; | 44 | IbexUartState *s = opaque; |
45 | |||
46 | - if (s->uart_ctrl & R_CTRL_RX_ENABLE_MASK) { | ||
47 | + if ((s->uart_ctrl & R_CTRL_RX_ENABLE_MASK) | ||
48 | + && !(s->uart_status & R_STATUS_RXFULL_MASK)) { | ||
49 | return 1; | ||
50 | } | ||
51 | |||
52 | @@ -XXX,XX +XXX,XX @@ static void ibex_uart_receive(void *opaque, const uint8_t *buf, int size) | ||
53 | |||
54 | s->uart_status &= ~R_STATUS_RXIDLE_MASK; | ||
55 | s->uart_status &= ~R_STATUS_RXEMPTY_MASK; | ||
56 | + /* The RXFULL is set after receiving a single byte | ||
57 | + * as the FIFO buffers are not yet implemented. | ||
58 | + */ | ||
59 | + s->uart_status |= R_STATUS_RXFULL_MASK; | ||
60 | + s->rx_level += 1; | ||
61 | |||
62 | if (size > rx_fifo_level) { | ||
63 | s->uart_intr_state |= R_INTR_STATE_RX_WATERMARK_MASK; | ||
64 | @@ -XXX,XX +XXX,XX @@ static void ibex_uart_reset(DeviceState *dev) | ||
65 | s->uart_timeout_ctrl = 0x00000000; | ||
66 | |||
67 | s->tx_level = 0; | ||
68 | + s->rx_level = 0; | ||
69 | |||
70 | s->char_tx_time = (NANOSECONDS_PER_SECOND / 230400) * 10; | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static uint64_t ibex_uart_read(void *opaque, hwaddr addr, | ||
73 | |||
74 | case R_RDATA: | ||
75 | retvalue = s->uart_rdata; | ||
76 | - if (s->uart_ctrl & R_CTRL_RX_ENABLE_MASK) { | ||
77 | + if ((s->uart_ctrl & R_CTRL_RX_ENABLE_MASK) && (s->rx_level > 0)) { | ||
78 | qemu_chr_fe_accept_input(&s->chr); | ||
79 | |||
80 | - s->uart_status |= R_STATUS_RXIDLE_MASK; | ||
81 | - s->uart_status |= R_STATUS_RXEMPTY_MASK; | ||
82 | + s->rx_level -= 1; | ||
83 | + s->uart_status &= ~R_STATUS_RXFULL_MASK; | ||
84 | + if (s->rx_level == 0) { | ||
85 | + s->uart_status |= R_STATUS_RXIDLE_MASK; | ||
86 | + s->uart_status |= R_STATUS_RXEMPTY_MASK; | ||
87 | + } | ||
58 | } | 88 | } |
59 | + if (cpu->cfg.ext_v) { | 89 | break; |
60 | + target_misa |= RVV; | 90 | case R_WDATA: |
61 | + if (!is_power_of_2(cpu->cfg.vlen)) { | 91 | @@ -XXX,XX +XXX,XX @@ static uint64_t ibex_uart_read(void *opaque, hwaddr addr, |
62 | + error_setg(errp, | 92 | case R_FIFO_STATUS: |
63 | + "Vector extension VLEN must be power of 2"); | 93 | retvalue = s->uart_fifo_status; |
64 | + return; | 94 | |
65 | + } | 95 | - retvalue |= s->tx_level & 0x1F; |
66 | + if (cpu->cfg.vlen > RV_VLEN_MAX || cpu->cfg.vlen < 128) { | 96 | + retvalue |= (s->rx_level & 0x1F) << R_FIFO_STATUS_RXLVL_SHIFT; |
67 | + error_setg(errp, | 97 | + retvalue |= (s->tx_level & 0x1F) << R_FIFO_STATUS_TXLVL_SHIFT; |
68 | + "Vector extension implementation only supports VLEN " | 98 | |
69 | + "in the range [128, %d]", RV_VLEN_MAX); | 99 | qemu_log_mask(LOG_UNIMP, |
70 | + return; | 100 | "%s: RX fifos are not supported\n", __func__); |
71 | + } | 101 | @@ -XXX,XX +XXX,XX @@ static void ibex_uart_write(void *opaque, hwaddr addr, |
72 | + if (!is_power_of_2(cpu->cfg.elen)) { | 102 | s->uart_fifo_ctrl = value; |
73 | + error_setg(errp, | 103 | |
74 | + "Vector extension ELEN must be power of 2"); | 104 | if (value & R_FIFO_CTRL_RXRST_MASK) { |
75 | + return; | 105 | + s->rx_level = 0; |
76 | + } | 106 | qemu_log_mask(LOG_UNIMP, |
77 | + if (cpu->cfg.elen > 64 || cpu->cfg.vlen < 8) { | 107 | "%s: RX fifos are not supported\n", __func__); |
78 | + error_setg(errp, | 108 | } |
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 | -- | 109 | -- |
117 | 2.27.0 | 110 | 2.30.1 |
118 | 111 | ||
119 | 112 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Jim Shu <cwshu@andestech.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Currently, PMP permission checking of TLB page is bypassed if TLB hits |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Fix it by propagating PMP permission to TLB page permission. |
5 | Message-id: 20200623215920.2594-56-zhiwei_liu@c-sky.com | 5 | |
6 | PMP permission checking also use MMU-style API to change TLB permission | ||
7 | and size. | ||
8 | |||
9 | Signed-off-by: Jim Shu <cwshu@andestech.com> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Message-id: 1613916082-19528-2-git-send-email-cwshu@andestech.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/insn32.decode | 1 + | 14 | target/riscv/pmp.h | 4 +- |
9 | target/riscv/insn_trans/trans_rvv.inc.c | 116 ++++++++++++++++++++++++ | 15 | target/riscv/cpu_helper.c | 84 +++++++++++++++++++++++++++++---------- |
10 | 2 files changed, 117 insertions(+) | 16 | target/riscv/pmp.c | 80 +++++++++++++++++++++++++++---------- |
11 | 17 | 3 files changed, 125 insertions(+), 43 deletions(-) | |
12 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 18 | |
19 | diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/riscv/insn32.decode | 21 | --- a/target/riscv/pmp.h |
15 | +++ b/target/riscv/insn32.decode | 22 | +++ b/target/riscv/pmp.h |
16 | @@ -XXX,XX +XXX,XX @@ vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm | 23 | @@ -XXX,XX +XXX,XX @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index, |
17 | vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | 24 | target_ulong val); |
18 | viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | 25 | target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index); |
19 | vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm | 26 | bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, |
20 | +vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r | 27 | - target_ulong size, pmp_priv_t priv, target_ulong mode); |
21 | 28 | + target_ulong size, pmp_priv_t privs, pmp_priv_t *allowed_privs, | |
22 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 29 | + target_ulong mode); |
23 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 30 | bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa, |
24 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | 31 | target_ulong *tlb_size); |
32 | void pmp_update_rule_addr(CPURISCVState *env, uint32_t pmp_index); | ||
33 | void pmp_update_rule_nums(CPURISCVState *env); | ||
34 | uint32_t pmp_get_num_rules(CPURISCVState *env); | ||
35 | +int pmp_priv_to_page_prot(pmp_priv_t pmp_priv); | ||
36 | |||
37 | #endif | ||
38 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 40 | --- a/target/riscv/cpu_helper.c |
27 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 41 | +++ b/target/riscv/cpu_helper.c |
28 | @@ -XXX,XX +XXX,XX @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a) | 42 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv) |
29 | } | 43 | env->load_res = -1; |
44 | } | ||
45 | |||
46 | +/* | ||
47 | + * get_physical_address_pmp - check PMP permission for this physical address | ||
48 | + * | ||
49 | + * Match the PMP region and check permission for this physical address and it's | ||
50 | + * TLB page. Returns 0 if the permission checking was successful | ||
51 | + * | ||
52 | + * @env: CPURISCVState | ||
53 | + * @prot: The returned protection attributes | ||
54 | + * @tlb_size: TLB page size containing addr. It could be modified after PMP | ||
55 | + * permission checking. NULL if not set TLB page for addr. | ||
56 | + * @addr: The physical address to be checked permission | ||
57 | + * @access_type: The type of MMU access | ||
58 | + * @mode: Indicates current privilege level. | ||
59 | + */ | ||
60 | +static int get_physical_address_pmp(CPURISCVState *env, int *prot, | ||
61 | + target_ulong *tlb_size, hwaddr addr, | ||
62 | + int size, MMUAccessType access_type, | ||
63 | + int mode) | ||
64 | +{ | ||
65 | + pmp_priv_t pmp_priv; | ||
66 | + target_ulong tlb_size_pmp = 0; | ||
67 | + | ||
68 | + if (!riscv_feature(env, RISCV_FEATURE_PMP)) { | ||
69 | + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
70 | + return TRANSLATE_SUCCESS; | ||
71 | + } | ||
72 | + | ||
73 | + if (!pmp_hart_has_privs(env, addr, size, 1 << access_type, &pmp_priv, | ||
74 | + mode)) { | ||
75 | + *prot = 0; | ||
76 | + return TRANSLATE_PMP_FAIL; | ||
77 | + } | ||
78 | + | ||
79 | + *prot = pmp_priv_to_page_prot(pmp_priv); | ||
80 | + if (tlb_size != NULL) { | ||
81 | + if (pmp_is_range_in_tlb(env, addr & ~(*tlb_size - 1), &tlb_size_pmp)) { | ||
82 | + *tlb_size = tlb_size_pmp; | ||
83 | + } | ||
84 | + } | ||
85 | + | ||
86 | + return TRANSLATE_SUCCESS; | ||
87 | +} | ||
88 | + | ||
89 | /* get_physical_address - get the physical address for this virtual address | ||
90 | * | ||
91 | * Do a page table walk to obtain the physical address corresponding to a | ||
92 | @@ -XXX,XX +XXX,XX @@ restart: | ||
93 | pte_addr = base + idx * ptesize; | ||
94 | } | ||
95 | |||
96 | - if (riscv_feature(env, RISCV_FEATURE_PMP) && | ||
97 | - !pmp_hart_has_privs(env, pte_addr, sizeof(target_ulong), | ||
98 | - 1 << MMU_DATA_LOAD, PRV_S)) { | ||
99 | + int pmp_prot; | ||
100 | + int pmp_ret = get_physical_address_pmp(env, &pmp_prot, NULL, pte_addr, | ||
101 | + sizeof(target_ulong), | ||
102 | + MMU_DATA_LOAD, PRV_S); | ||
103 | + if (pmp_ret != TRANSLATE_SUCCESS) { | ||
104 | return TRANSLATE_PMP_FAIL; | ||
105 | } | ||
106 | |||
107 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
108 | #ifndef CONFIG_USER_ONLY | ||
109 | vaddr im_address; | ||
110 | hwaddr pa = 0; | ||
111 | - int prot, prot2; | ||
112 | + int prot, prot2, prot_pmp; | ||
113 | bool pmp_violation = false; | ||
114 | bool first_stage_error = true; | ||
115 | bool two_stage_lookup = false; | ||
116 | int ret = TRANSLATE_FAIL; | ||
117 | int mode = mmu_idx; | ||
118 | - target_ulong tlb_size = 0; | ||
119 | + /* default TLB page size */ | ||
120 | + target_ulong tlb_size = TARGET_PAGE_SIZE; | ||
121 | |||
122 | env->guest_phys_fault_addr = 0; | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
125 | |||
126 | prot &= prot2; | ||
127 | |||
128 | - if (riscv_feature(env, RISCV_FEATURE_PMP) && | ||
129 | - (ret == TRANSLATE_SUCCESS) && | ||
130 | - !pmp_hart_has_privs(env, pa, size, 1 << access_type, mode)) { | ||
131 | - ret = TRANSLATE_PMP_FAIL; | ||
132 | + if (ret == TRANSLATE_SUCCESS) { | ||
133 | + ret = get_physical_address_pmp(env, &prot_pmp, &tlb_size, pa, | ||
134 | + size, access_type, mode); | ||
135 | + prot &= prot_pmp; | ||
136 | } | ||
137 | |||
138 | if (ret != TRANSLATE_SUCCESS) { | ||
139 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
140 | "%s address=%" VADDR_PRIx " ret %d physical " | ||
141 | TARGET_FMT_plx " prot %d\n", | ||
142 | __func__, address, ret, pa, prot); | ||
143 | - } | ||
144 | |||
145 | - if (riscv_feature(env, RISCV_FEATURE_PMP) && | ||
146 | - (ret == TRANSLATE_SUCCESS) && | ||
147 | - !pmp_hart_has_privs(env, pa, size, 1 << access_type, mode)) { | ||
148 | - ret = TRANSLATE_PMP_FAIL; | ||
149 | + if (ret == TRANSLATE_SUCCESS) { | ||
150 | + ret = get_physical_address_pmp(env, &prot_pmp, &tlb_size, pa, | ||
151 | + size, access_type, mode); | ||
152 | + prot &= prot_pmp; | ||
153 | + } | ||
154 | } | ||
155 | + | ||
156 | if (ret == TRANSLATE_PMP_FAIL) { | ||
157 | pmp_violation = true; | ||
158 | } | ||
159 | |||
160 | if (ret == TRANSLATE_SUCCESS) { | ||
161 | - if (pmp_is_range_in_tlb(env, pa & TARGET_PAGE_MASK, &tlb_size)) { | ||
162 | - tlb_set_page(cs, address & ~(tlb_size - 1), pa & ~(tlb_size - 1), | ||
163 | - prot, mmu_idx, tlb_size); | ||
164 | - } else { | ||
165 | - tlb_set_page(cs, address & TARGET_PAGE_MASK, pa & TARGET_PAGE_MASK, | ||
166 | - prot, mmu_idx, TARGET_PAGE_SIZE); | ||
167 | - } | ||
168 | + tlb_set_page(cs, address & ~(tlb_size - 1), pa & ~(tlb_size - 1), | ||
169 | + prot, mmu_idx, tlb_size); | ||
170 | return true; | ||
171 | } else if (probe) { | ||
172 | return false; | ||
173 | diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/riscv/pmp.c | ||
176 | +++ b/target/riscv/pmp.c | ||
177 | @@ -XXX,XX +XXX,XX @@ static int pmp_is_in_range(CPURISCVState *env, int pmp_index, target_ulong addr) | ||
178 | return result; | ||
179 | } | ||
180 | |||
181 | +/* | ||
182 | + * Check if the address has required RWX privs when no PMP entry is matched. | ||
183 | + */ | ||
184 | +static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, | ||
185 | + target_ulong size, pmp_priv_t privs, pmp_priv_t *allowed_privs, | ||
186 | + target_ulong mode) | ||
187 | +{ | ||
188 | + bool ret; | ||
189 | + | ||
190 | + if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode == PRV_M)) { | ||
191 | + /* | ||
192 | + * Privileged spec v1.10 states if HW doesn't implement any PMP entry | ||
193 | + * or no PMP entry matches an M-Mode access, the access succeeds. | ||
194 | + */ | ||
195 | + ret = true; | ||
196 | + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; | ||
197 | + } else { | ||
198 | + /* | ||
199 | + * Other modes are not allowed to succeed if they don't * match a rule, | ||
200 | + * but there are rules. We've checked for no rule earlier in this | ||
201 | + * function. | ||
202 | + */ | ||
203 | + ret = false; | ||
204 | + *allowed_privs = 0; | ||
205 | + } | ||
206 | + | ||
207 | + return ret; | ||
208 | +} | ||
209 | + | ||
210 | |||
211 | /* | ||
212 | * Public Interface | ||
213 | @@ -XXX,XX +XXX,XX @@ static int pmp_is_in_range(CPURISCVState *env, int pmp_index, target_ulong addr) | ||
214 | * Check if the address has required RWX privs to complete desired operation | ||
215 | */ | ||
216 | bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, | ||
217 | - target_ulong size, pmp_priv_t privs, target_ulong mode) | ||
218 | + target_ulong size, pmp_priv_t privs, pmp_priv_t *allowed_privs, | ||
219 | + target_ulong mode) | ||
220 | { | ||
221 | int i = 0; | ||
222 | int ret = -1; | ||
223 | int pmp_size = 0; | ||
224 | target_ulong s = 0; | ||
225 | target_ulong e = 0; | ||
226 | - pmp_priv_t allowed_privs = 0; | ||
227 | |||
228 | /* Short cut if no rules */ | ||
229 | if (0 == pmp_get_num_rules(env)) { | ||
230 | - return (env->priv == PRV_M) ? true : false; | ||
231 | + return pmp_hart_has_privs_default(env, addr, size, privs, | ||
232 | + allowed_privs, mode); | ||
233 | } | ||
234 | |||
235 | if (size == 0) { | ||
236 | @@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, | ||
237 | * check | ||
238 | */ | ||
239 | if (((s + e) == 2) && (PMP_AMATCH_OFF != a_field)) { | ||
240 | - allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; | ||
241 | + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; | ||
242 | if ((mode != PRV_M) || pmp_is_locked(env, i)) { | ||
243 | - allowed_privs &= env->pmp_state.pmp[i].cfg_reg; | ||
244 | + *allowed_privs &= env->pmp_state.pmp[i].cfg_reg; | ||
245 | } | ||
246 | |||
247 | - if ((privs & allowed_privs) == privs) { | ||
248 | - ret = 1; | ||
249 | - break; | ||
250 | - } else { | ||
251 | - ret = 0; | ||
252 | - break; | ||
253 | - } | ||
254 | + ret = ((privs & *allowed_privs) == privs); | ||
255 | + break; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | /* No rule matched */ | ||
260 | if (ret == -1) { | ||
261 | - if (mode == PRV_M) { | ||
262 | - ret = 1; /* Privileged spec v1.10 states if no PMP entry matches an | ||
263 | - * M-Mode access, the access succeeds */ | ||
264 | - } else { | ||
265 | - ret = 0; /* Other modes are not allowed to succeed if they don't | ||
266 | - * match a rule, but there are rules. We've checked for | ||
267 | - * no rule earlier in this function. */ | ||
268 | - } | ||
269 | + return pmp_hart_has_privs_default(env, addr, size, privs, | ||
270 | + allowed_privs, mode); | ||
271 | } | ||
272 | |||
273 | return ret == 1 ? true : false; | ||
274 | } | ||
275 | |||
276 | - | ||
277 | /* | ||
278 | * Handle a write to a pmpcfg CSP | ||
279 | */ | ||
280 | @@ -XXX,XX +XXX,XX @@ bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa, | ||
281 | |||
30 | return false; | 282 | return false; |
31 | } | 283 | } |
32 | + | 284 | + |
33 | +/* | 285 | +/* |
34 | + *** Vector Permutation Instructions | 286 | + * Convert PMP privilege to TLB page privilege. |
35 | + */ | 287 | + */ |
36 | + | 288 | +int pmp_priv_to_page_prot(pmp_priv_t pmp_priv) |
37 | +/* Integer Extract Instruction */ | ||
38 | + | ||
39 | +static void load_element(TCGv_i64 dest, TCGv_ptr base, | ||
40 | + int ofs, int sew) | ||
41 | +{ | 289 | +{ |
42 | + switch (sew) { | 290 | + int prot = 0; |
43 | + case MO_8: | 291 | + |
44 | + tcg_gen_ld8u_i64(dest, base, ofs); | 292 | + if (pmp_priv & PMP_READ) { |
45 | + break; | 293 | + prot |= PAGE_READ; |
46 | + case MO_16: | 294 | + } |
47 | + tcg_gen_ld16u_i64(dest, base, ofs); | 295 | + if (pmp_priv & PMP_WRITE) { |
48 | + break; | 296 | + prot |= PAGE_WRITE; |
49 | + case MO_32: | 297 | + } |
50 | + tcg_gen_ld32u_i64(dest, base, ofs); | 298 | + if (pmp_priv & PMP_EXEC) { |
51 | + break; | 299 | + prot |= PAGE_EXEC; |
52 | + case MO_64: | 300 | + } |
53 | + tcg_gen_ld_i64(dest, base, ofs); | 301 | + |
54 | + break; | 302 | + return prot; |
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 | +} | 303 | +} |
148 | -- | 304 | -- |
149 | 2.27.0 | 305 | 2.30.1 |
150 | 306 | ||
151 | 307 | diff view generated by jsdifflib |
1 | From: Jessica Clarke <jrtc27@jrtc27.com> | 1 | From: Jim Shu <cwshu@andestech.com> |
---|---|---|---|
2 | 2 | ||
3 | Claiming an interrupt and changing the source priority both potentially | 3 | Like MMU translation, add qemu log of PMP permission checking for |
4 | affect whether an interrupt is pending, thus we must re-compute xEIP. | 4 | debugging. |
5 | Note that we don't put the sifive_plic_update inside sifive_plic_claim | ||
6 | so that the logging of a claim (and the resulting IRQ) happens before | ||
7 | the state update, making the causal effect clear, and that we drop the | ||
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 | 5 | ||
11 | This can result in both spurious interrupt storms if you fail to | 6 | Signed-off-by: Jim Shu <cwshu@andestech.com> |
12 | complete an IRQ before enabling interrupts (and no other actions occur | ||
13 | that result in a call to sifive_plic_update), but also more importantly | ||
14 | lost interrupts if a disabled interrupt is pending and then becomes | ||
15 | enabled. | ||
16 | |||
17 | Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> | ||
18 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
19 | Message-id: 20200618210649.22451-1-jrtc27@jrtc27.com | 8 | Message-id: 1613916082-19528-3-git-send-email-cwshu@andestech.com |
20 | Message-Id: <20200618210649.22451-1-jrtc27@jrtc27.com> | ||
21 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
22 | --- | 10 | --- |
23 | hw/riscv/sifive_plic.c | 3 ++- | 11 | target/riscv/cpu_helper.c | 12 ++++++++++++ |
24 | 1 file changed, 2 insertions(+), 1 deletion(-) | 12 | 1 file changed, 12 insertions(+) |
25 | 13 | ||
26 | diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c | 14 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c |
27 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/riscv/sifive_plic.c | 16 | --- a/target/riscv/cpu_helper.c |
29 | +++ b/hw/riscv/sifive_plic.c | 17 | +++ b/target/riscv/cpu_helper.c |
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t sifive_plic_read(void *opaque, hwaddr addr, unsigned size) | 18 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
31 | plic->addr_config[addrid].hartid, | 19 | if (ret == TRANSLATE_SUCCESS) { |
32 | mode_to_char(plic->addr_config[addrid].mode), | 20 | ret = get_physical_address_pmp(env, &prot_pmp, &tlb_size, pa, |
33 | value); | 21 | size, access_type, mode); |
34 | - sifive_plic_print_state(plic); | 22 | + |
23 | + qemu_log_mask(CPU_LOG_MMU, | ||
24 | + "%s PMP address=" TARGET_FMT_plx " ret %d prot" | ||
25 | + " %d tlb_size " TARGET_FMT_lu "\n", | ||
26 | + __func__, pa, ret, prot_pmp, tlb_size); | ||
27 | + | ||
28 | prot &= prot_pmp; | ||
35 | } | 29 | } |
36 | + sifive_plic_update(plic); | 30 | |
37 | return value; | 31 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
32 | if (ret == TRANSLATE_SUCCESS) { | ||
33 | ret = get_physical_address_pmp(env, &prot_pmp, &tlb_size, pa, | ||
34 | size, access_type, mode); | ||
35 | + | ||
36 | + qemu_log_mask(CPU_LOG_MMU, | ||
37 | + "%s PMP address=" TARGET_FMT_plx " ret %d prot" | ||
38 | + " %d tlb_size " TARGET_FMT_lu "\n", | ||
39 | + __func__, pa, ret, prot_pmp, tlb_size); | ||
40 | + | ||
41 | prot &= prot_pmp; | ||
38 | } | 42 | } |
39 | } | 43 | } |
40 | @@ -XXX,XX +XXX,XX @@ static void sifive_plic_write(void *opaque, hwaddr addr, uint64_t value, | ||
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 | -- | 44 | -- |
49 | 2.27.0 | 45 | 2.30.1 |
50 | 46 | ||
51 | 47 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Jim Shu <cwshu@andestech.com> |
---|---|---|---|
2 | 2 | ||
3 | Vector AMOs operate as if aq and rl bits were zero on each element | 3 | If PMP permission of any address has been changed by updating PMP entry, |
4 | with regard to ordering relative to other instructions in the same hart. | 4 | flush all TLB pages to prevent from getting old permission. |
5 | Vector AMOs provide no ordering guarantee between element operations | ||
6 | in the same vector AMO instruction | ||
7 | 5 | ||
8 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 6 | Signed-off-by: Jim Shu <cwshu@andestech.com> |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 1613916082-19528-4-git-send-email-cwshu@andestech.com |
11 | Message-id: 20200623215920.2594-10-zhiwei_liu@c-sky.com | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
13 | --- | 10 | --- |
14 | target/riscv/helper.h | 29 +++++ | 11 | target/riscv/pmp.c | 4 ++++ |
15 | target/riscv/internals.h | 1 + | 12 | 1 file changed, 4 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 | 13 | ||
22 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 14 | diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c |
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/riscv/helper.h | 16 | --- a/target/riscv/pmp.c |
25 | +++ b/target/riscv/helper.h | 17 | +++ b/target/riscv/pmp.c |
26 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vlhuff_v_w, void, ptr, ptr, tl, env, i32) | 18 | @@ -XXX,XX +XXX,XX @@ |
27 | DEF_HELPER_5(vlhuff_v_d, void, ptr, ptr, tl, env, i32) | 19 | #include "qapi/error.h" |
28 | DEF_HELPER_5(vlwuff_v_w, void, ptr, ptr, tl, env, i32) | 20 | #include "cpu.h" |
29 | DEF_HELPER_5(vlwuff_v_d, void, ptr, ptr, tl, env, i32) | 21 | #include "trace.h" |
30 | +#ifdef TARGET_RISCV64 | 22 | +#include "exec/exec-all.h" |
31 | +DEF_HELPER_6(vamoswapw_v_d, void, ptr, ptr, tl, ptr, env, i32) | 23 | |
32 | +DEF_HELPER_6(vamoswapd_v_d, void, ptr, ptr, tl, ptr, env, i32) | 24 | static void pmp_write_cfg(CPURISCVState *env, uint32_t addr_index, |
33 | +DEF_HELPER_6(vamoaddw_v_d, void, ptr, ptr, tl, ptr, env, i32) | 25 | uint8_t val); |
34 | +DEF_HELPER_6(vamoaddd_v_d, void, ptr, ptr, tl, ptr, env, i32) | 26 | @@ -XXX,XX +XXX,XX @@ void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index, |
35 | +DEF_HELPER_6(vamoxorw_v_d, void, ptr, ptr, tl, ptr, env, i32) | 27 | cfg_val = (val >> 8 * i) & 0xff; |
36 | +DEF_HELPER_6(vamoxord_v_d, void, ptr, ptr, tl, ptr, env, i32) | 28 | pmp_write_cfg(env, (reg_index * 4) + i, cfg_val); |
37 | +DEF_HELPER_6(vamoandw_v_d, void, ptr, ptr, tl, ptr, env, i32) | 29 | } |
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 | + | 30 | + |
88 | # *** RV64F Standard Extension (in addition to RV32F) *** | 31 | + /* If PMP permission of any addr has been changed, flush TLB pages. */ |
89 | fcvt_l_s 1100000 00010 ..... ... ..... 1010011 @r2_rm | 32 | + tlb_flush(env_cpu(env)); |
90 | fcvt_lu_s 1100000 00011 ..... ... ..... 1010011 @r2_rm | ||
91 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/target/riscv/insn32.decode | ||
94 | +++ b/target/riscv/insn32.decode | ||
95 | @@ -XXX,XX +XXX,XX @@ | ||
96 | &u imm rd | ||
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 | + } | ||
230 | + } | ||
231 | + | ||
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 | } | 33 | } |
282 | 34 | ||
283 | +static uint32_t vext_wd(uint32_t desc) | 35 | |
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 | -- | 36 | -- |
438 | 2.27.0 | 37 | 2.30.1 |
439 | 38 | ||
440 | 39 | diff view generated by jsdifflib |
1 | From: Jessica Clarke <jrtc27@jrtc27.com> | 1 | From: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
---|---|---|---|
2 | 2 | ||
3 | The source priorities can be used to order sources with respect to other | 3 | According to the specification the "field SPVP of hstatus controls the |
4 | sources, not just as a way to enable/disable them based off a threshold. | 4 | privilege level of the access" for the hypervisor virtual-machine load |
5 | We must therefore always claim the highest-priority source, rather than | 5 | and store instructions HLV, HLVX and HSV. |
6 | the first source we find. | ||
7 | 6 | ||
8 | Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> | 7 | Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
10 | Message-Id: <20200618202343.20455-1-jrtc27@jrtc27.com> | 9 | Message-id: 20210311103005.1400718-1-georg.kotheimer@kernkonzept.com |
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
12 | --- | 11 | --- |
13 | hw/riscv/sifive_plic.c | 17 ++++++++++++----- | 12 | target/riscv/cpu_helper.c | 25 ++++++++++++++----------- |
14 | 1 file changed, 12 insertions(+), 5 deletions(-) | 13 | 1 file changed, 14 insertions(+), 11 deletions(-) |
15 | 14 | ||
16 | diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c | 15 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/riscv/sifive_plic.c | 17 | --- a/target/riscv/cpu_helper.c |
19 | +++ b/hw/riscv/sifive_plic.c | 18 | +++ b/target/riscv/cpu_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void sifive_plic_update(SiFivePLICState *plic) | 19 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, |
21 | static uint32_t sifive_plic_claim(SiFivePLICState *plic, uint32_t addrid) | 20 | use_background = true; |
22 | { | 21 | } |
23 | int i, j; | 22 | |
24 | + uint32_t max_irq = 0; | 23 | - if (mode == PRV_M && access_type != MMU_INST_FETCH) { |
25 | + uint32_t max_prio = plic->target_priority[addrid]; | 24 | + /* MPRV does not affect the virtual-machine load/store |
26 | + | 25 | + instructions, HLV, HLVX, and HSV. */ |
27 | for (i = 0; i < plic->bitfield_words; i++) { | 26 | + if (riscv_cpu_two_stage_lookup(mmu_idx)) { |
28 | uint32_t pending_enabled_not_claimed = | 27 | + mode = get_field(env->hstatus, HSTATUS_SPVP); |
29 | (plic->pending[i] & ~plic->claimed[i]) & | 28 | + } else if (mode == PRV_M && access_type != MMU_INST_FETCH) { |
30 | @@ -XXX,XX +XXX,XX @@ static uint32_t sifive_plic_claim(SiFivePLICState *plic, uint32_t addrid) | 29 | if (get_field(env->mstatus, MSTATUS_MPRV)) { |
31 | int irq = (i << 5) + j; | 30 | mode = get_field(env->mstatus, MSTATUS_MPP); |
32 | uint32_t prio = plic->source_priority[irq]; | 31 | } |
33 | int enabled = pending_enabled_not_claimed & (1 << j); | 32 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
34 | - if (enabled && prio > plic->target_priority[addrid]) { | 33 | qemu_log_mask(CPU_LOG_MMU, "%s ad %" VADDR_PRIx " rw %d mmu_idx %d\n", |
35 | - sifive_plic_set_pending(plic, irq, false); | 34 | __func__, address, access_type, mmu_idx); |
36 | - sifive_plic_set_claimed(plic, irq, true); | 35 | |
37 | - return irq; | 36 | - if (mode == PRV_M && access_type != MMU_INST_FETCH) { |
38 | + if (enabled && prio > max_prio) { | 37 | - if (get_field(env->mstatus, MSTATUS_MPRV)) { |
39 | + max_irq = irq; | 38 | - mode = get_field(env->mstatus, MSTATUS_MPP); |
40 | + max_prio = prio; | 39 | + /* MPRV does not affect the virtual-machine load/store |
41 | } | 40 | + instructions, HLV, HLVX, and HSV. */ |
41 | + if (riscv_cpu_two_stage_lookup(mmu_idx)) { | ||
42 | + mode = get_field(env->hstatus, HSTATUS_SPVP); | ||
43 | + } else if (mode == PRV_M && access_type != MMU_INST_FETCH && | ||
44 | + get_field(env->mstatus, MSTATUS_MPRV)) { | ||
45 | + mode = get_field(env->mstatus, MSTATUS_MPP); | ||
46 | + if (riscv_has_ext(env, RVH) && get_field(env->mstatus, MSTATUS_MPV)) { | ||
47 | + two_stage_lookup = true; | ||
42 | } | 48 | } |
43 | } | 49 | } |
44 | - return 0; | 50 | |
45 | + | 51 | - if (riscv_has_ext(env, RVH) && env->priv == PRV_M && |
46 | + if (max_irq) { | 52 | - access_type != MMU_INST_FETCH && |
47 | + sifive_plic_set_pending(plic, max_irq, false); | 53 | - get_field(env->mstatus, MSTATUS_MPRV) && |
48 | + sifive_plic_set_claimed(plic, max_irq, true); | 54 | - get_field(env->mstatus, MSTATUS_MPV)) { |
49 | + } | 55 | - two_stage_lookup = true; |
50 | + return max_irq; | 56 | - } |
51 | } | 57 | - |
52 | 58 | if (riscv_cpu_virt_enabled(env) || | |
53 | static uint64_t sifive_plic_read(void *opaque, hwaddr addr, unsigned size) | 59 | ((riscv_cpu_two_stage_lookup(mmu_idx) || two_stage_lookup) && |
60 | access_type != MMU_INST_FETCH)) { | ||
54 | -- | 61 | -- |
55 | 2.27.0 | 62 | 2.30.1 |
56 | 63 | ||
57 | 64 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
5 | Message-id: 20200623215920.2594-61-zhiwei_liu@c-sky.com | 5 | Message-id: 20210311094902.1377593-1-georg.kotheimer@kernkonzept.com |
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 7 | --- |
8 | target/riscv/helper.h | 5 ++++ | 8 | target/riscv/csr.c | 7 ++++--- |
9 | target/riscv/insn32.decode | 1 + | 9 | 1 file changed, 4 insertions(+), 3 deletions(-) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 26 ++++++++++++++++++++ | ||
12 | 4 files changed, 64 insertions(+) | ||
13 | 10 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 11 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c |
15 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 13 | --- a/target/riscv/csr.c |
17 | +++ b/target/riscv/helper.h | 14 | +++ b/target/riscv/csr.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vrgather_vx_b, void, ptr, ptr, tl, ptr, env, i32) | 15 | @@ -XXX,XX +XXX,XX @@ static const target_ulong sstatus_v1_10_mask = SSTATUS_SIE | SSTATUS_SPIE | |
19 | DEF_HELPER_6(vrgather_vx_h, void, ptr, ptr, tl, ptr, env, i32) | 16 | SSTATUS_UIE | SSTATUS_UPIE | SSTATUS_SPP | SSTATUS_FS | SSTATUS_XS | |
20 | DEF_HELPER_6(vrgather_vx_w, void, ptr, ptr, tl, ptr, env, i32) | 17 | SSTATUS_SUM | SSTATUS_MXR | SSTATUS_SD; |
21 | DEF_HELPER_6(vrgather_vx_d, void, ptr, ptr, tl, ptr, env, i32) | 18 | static const target_ulong sip_writable_mask = SIP_SSIP | MIP_USIP | MIP_UEIP; |
22 | + | 19 | -static const target_ulong hip_writable_mask = MIP_VSSIP | MIP_VSTIP | MIP_VSEIP; |
23 | +DEF_HELPER_6(vcompress_vm_b, void, ptr, ptr, ptr, ptr, env, i32) | 20 | +static const target_ulong hip_writable_mask = MIP_VSSIP; |
24 | +DEF_HELPER_6(vcompress_vm_h, void, ptr, ptr, ptr, ptr, env, i32) | 21 | +static const target_ulong hvip_writable_mask = MIP_VSSIP | MIP_VSTIP | MIP_VSEIP; |
25 | +DEF_HELPER_6(vcompress_vm_w, void, ptr, ptr, ptr, ptr, env, i32) | 22 | static const target_ulong vsip_writable_mask = MIP_VSSIP; |
26 | +DEF_HELPER_6(vcompress_vm_d, void, ptr, ptr, ptr, ptr, env, i32) | 23 | |
27 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 24 | static const char valid_vm_1_10_32[16] = { |
28 | index XXXXXXX..XXXXXXX 100644 | 25 | @@ -XXX,XX +XXX,XX @@ static int rmw_hvip(CPURISCVState *env, int csrno, target_ulong *ret_value, |
29 | --- a/target/riscv/insn32.decode | 26 | target_ulong new_value, target_ulong write_mask) |
30 | +++ b/target/riscv/insn32.decode | 27 | { |
31 | @@ -XXX,XX +XXX,XX @@ vslide1down_vx 001111 . ..... ..... 110 ..... 1010111 @r_vm | 28 | int ret = rmw_mip(env, 0, ret_value, new_value, |
32 | vrgather_vv 001100 . ..... ..... 000 ..... 1010111 @r_vm | 29 | - write_mask & hip_writable_mask); |
33 | vrgather_vx 001100 . ..... ..... 100 ..... 1010111 @r_vm | 30 | + write_mask & hvip_writable_mask); |
34 | vrgather_vi 001100 . ..... ..... 011 ..... 1010111 @r_vm | 31 | |
35 | +vcompress_vm 010111 - ..... ..... 010 ..... 1010111 @r | 32 | - *ret_value &= hip_writable_mask; |
36 | 33 | + *ret_value &= hvip_writable_mask; | |
37 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | 34 | |
38 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | 35 | return ret; |
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 | } | ||
45 | return true; | ||
46 | } | 36 | } |
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 | -- | 37 | -- |
114 | 2.27.0 | 38 | 2.30.1 |
115 | 39 | ||
116 | 40 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
---|---|---|---|
2 | 2 | ||
3 | The 32 vector registers will be viewed as a continuous memory block. | 3 | The current condition for the use of background registers only |
4 | It avoids the convension between element index and (regno, offset). | 4 | considers the hypervisor load and store instructions, |
5 | Thus elements can be directly accessed by offset from the first vector | 5 | but not accesses from M mode via MSTATUS_MPRV+MPV. |
6 | base address. | ||
7 | 6 | ||
8 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 7 | Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
9 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20210311103036.1401073-1-georg.kotheimer@kernkonzept.com |
11 | Message-id: 20200623215920.2594-2-zhiwei_liu@c-sky.com | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
13 | --- | 11 | --- |
14 | target/riscv/cpu.h | 12 ++++++++++++ | 12 | target/riscv/cpu_helper.c | 2 +- |
15 | target/riscv/translate.c | 3 ++- | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
16 | 2 files changed, 14 insertions(+), 1 deletion(-) | ||
17 | 14 | ||
18 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | 15 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/riscv/cpu.h | 17 | --- a/target/riscv/cpu_helper.c |
21 | +++ b/target/riscv/cpu.h | 18 | +++ b/target/riscv/cpu_helper.c |
22 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, |
23 | #define RVA RV('A') | 20 | * was called. Background registers will be used if the guest has |
24 | #define RVF RV('F') | 21 | * forced a two stage translation to be on (in HS or M mode). |
25 | #define RVD RV('D') | 22 | */ |
26 | +#define RVV RV('V') | 23 | - if (!riscv_cpu_virt_enabled(env) && riscv_cpu_two_stage_lookup(mmu_idx)) { |
27 | #define RVC RV('C') | 24 | + if (!riscv_cpu_virt_enabled(env) && two_stage) { |
28 | #define RVS RV('S') | 25 | use_background = true; |
29 | #define RVU RV('U') | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct CPURISCVState CPURISCVState; | ||
31 | |||
32 | #include "pmp.h" | ||
33 | |||
34 | +#define RV_VLEN_MAX 512 | ||
35 | + | ||
36 | struct CPURISCVState { | ||
37 | target_ulong gpr[32]; | ||
38 | uint64_t fpr[32]; /* assume both F and D extensions */ | ||
39 | + | ||
40 | + /* vector coprocessor state. */ | ||
41 | + uint64_t vreg[32 * RV_VLEN_MAX / 64] QEMU_ALIGNED(16); | ||
42 | + target_ulong vxrm; | ||
43 | + target_ulong vxsat; | ||
44 | + target_ulong vl; | ||
45 | + target_ulong vstart; | ||
46 | + target_ulong vtype; | ||
47 | + | ||
48 | target_ulong pc; | ||
49 | target_ulong load_res; | ||
50 | target_ulong load_val; | ||
51 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/riscv/translate.c | ||
54 | +++ b/target/riscv/translate.c | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
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 | } | 26 | } |
66 | 27 | ||
67 | cpu_pc = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, pc), "pc"); | ||
68 | + cpu_vl = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, vl), "vl"); | ||
69 | load_res = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_res), | ||
70 | "load_res"); | ||
71 | load_val = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_val), | ||
72 | -- | 28 | -- |
73 | 2.27.0 | 29 | 2.30.1 |
74 | 30 | ||
75 | 31 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Asherah Connor <ashe@kivikakk.ee> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Provides fw_cfg for the virt machine on riscv. This enables |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | using e.g. ramfb later. |
5 | Message-id: 20200623215920.2594-60-zhiwei_liu@c-sky.com | 5 | |
6 | Signed-off-by: Asherah Connor <ashe@kivikakk.ee> | ||
7 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Message-id: 20210318235041.17175-2-ashe@kivikakk.ee | ||
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 | 9 +++ | 12 | include/hw/riscv/virt.h | 2 ++ |
9 | target/riscv/insn32.decode | 3 + | 13 | hw/riscv/virt.c | 30 ++++++++++++++++++++++++++++++ |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 78 +++++++++++++++++++++++++ | 14 | hw/riscv/Kconfig | 1 + |
11 | target/riscv/vector_helper.c | 60 +++++++++++++++++++ | 15 | 3 files changed, 33 insertions(+) |
12 | 4 files changed, 150 insertions(+) | ||
13 | 16 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 17 | diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 19 | --- a/include/hw/riscv/virt.h |
17 | +++ b/target/riscv/helper.h | 20 | +++ b/include/hw/riscv/virt.h |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vslide1down_vx_b, void, ptr, ptr, tl, ptr, env, i32) | 21 | @@ -XXX,XX +XXX,XX @@ struct RISCVVirtState { |
19 | DEF_HELPER_6(vslide1down_vx_h, void, ptr, ptr, tl, ptr, env, i32) | 22 | RISCVHartArrayState soc[VIRT_SOCKETS_MAX]; |
20 | DEF_HELPER_6(vslide1down_vx_w, void, ptr, ptr, tl, ptr, env, i32) | 23 | DeviceState *plic[VIRT_SOCKETS_MAX]; |
21 | DEF_HELPER_6(vslide1down_vx_d, void, ptr, ptr, tl, ptr, env, i32) | 24 | PFlashCFI01 *flash[2]; |
25 | + FWCfgState *fw_cfg; | ||
26 | |||
27 | int fdt_size; | ||
28 | }; | ||
29 | @@ -XXX,XX +XXX,XX @@ enum { | ||
30 | VIRT_PLIC, | ||
31 | VIRT_UART0, | ||
32 | VIRT_VIRTIO, | ||
33 | + VIRT_FW_CFG, | ||
34 | VIRT_FLASH, | ||
35 | VIRT_DRAM, | ||
36 | VIRT_PCIE_MMIO, | ||
37 | diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/riscv/virt.c | ||
40 | +++ b/hw/riscv/virt.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry virt_memmap[] = { | ||
42 | [VIRT_PLIC] = { 0xc000000, VIRT_PLIC_SIZE(VIRT_CPUS_MAX * 2) }, | ||
43 | [VIRT_UART0] = { 0x10000000, 0x100 }, | ||
44 | [VIRT_VIRTIO] = { 0x10001000, 0x1000 }, | ||
45 | + [VIRT_FW_CFG] = { 0x10100000, 0x18 }, | ||
46 | [VIRT_FLASH] = { 0x20000000, 0x4000000 }, | ||
47 | [VIRT_PCIE_ECAM] = { 0x30000000, 0x10000000 }, | ||
48 | [VIRT_PCIE_MMIO] = { 0x40000000, 0x40000000 }, | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem, | ||
50 | return dev; | ||
51 | } | ||
52 | |||
53 | +static FWCfgState *create_fw_cfg(const MachineState *mc) | ||
54 | +{ | ||
55 | + hwaddr base = virt_memmap[VIRT_FW_CFG].base; | ||
56 | + hwaddr size = virt_memmap[VIRT_FW_CFG].size; | ||
57 | + FWCfgState *fw_cfg; | ||
58 | + char *nodename; | ||
22 | + | 59 | + |
23 | +DEF_HELPER_6(vrgather_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | 60 | + fw_cfg = fw_cfg_init_mem_wide(base + 8, base, 8, base + 16, |
24 | +DEF_HELPER_6(vrgather_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | 61 | + &address_space_memory); |
25 | +DEF_HELPER_6(vrgather_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | 62 | + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)mc->smp.cpus); |
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 | + | 63 | + |
54 | +/* Vector Register Gather Instruction */ | 64 | + nodename = g_strdup_printf("/fw-cfg@%" PRIx64, base); |
55 | +static bool vrgather_vv_check(DisasContext *s, arg_rmrr *a) | 65 | + qemu_fdt_add_subnode(mc->fdt, nodename); |
56 | +{ | 66 | + qemu_fdt_setprop_string(mc->fdt, nodename, |
57 | + return (vext_check_isa_ill(s) && | 67 | + "compatible", "qemu,fw-cfg-mmio"); |
58 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | 68 | + qemu_fdt_setprop_sized_cells(mc->fdt, nodename, "reg", |
59 | + vext_check_reg(s, a->rd, false) && | 69 | + 2, base, 2, size); |
60 | + vext_check_reg(s, a->rs1, false) && | 70 | + qemu_fdt_setprop(mc->fdt, nodename, "dma-coherent", NULL, 0); |
61 | + vext_check_reg(s, a->rs2, false) && | 71 | + g_free(nodename); |
62 | + (a->rd != a->rs2) && (a->rd != a->rs1)); | 72 | + return fw_cfg; |
63 | +} | 73 | +} |
64 | + | 74 | + |
65 | +GEN_OPIVV_TRANS(vrgather_vv, vrgather_vv_check) | 75 | static void virt_machine_init(MachineState *machine) |
76 | { | ||
77 | const MemMapEntry *memmap = virt_memmap; | ||
78 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine) | ||
79 | start_addr = virt_memmap[VIRT_FLASH].base; | ||
80 | } | ||
81 | |||
82 | + /* | ||
83 | + * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the device | ||
84 | + * tree cannot be altered and we get FDT_ERR_NOSPACE. | ||
85 | + */ | ||
86 | + s->fw_cfg = create_fw_cfg(machine); | ||
87 | + rom_set_fw(s->fw_cfg); | ||
66 | + | 88 | + |
67 | +static bool vrgather_vx_check(DisasContext *s, arg_rmrr *a) | 89 | /* Compute the fdt load address in dram */ |
68 | +{ | 90 | fdt_load_addr = riscv_load_fdt(memmap[VIRT_DRAM].base, |
69 | + return (vext_check_isa_ill(s) && | 91 | machine->ram_size, machine->fdt); |
70 | + vext_check_overlap_mask(s, a->rd, a->vm, true) && | 92 | diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig |
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 | + } | ||
82 | + | ||
83 | + if (a->vm && s->vl_eq_vlmax) { | ||
84 | + int vlmax = s->vlen / s->mlen; | ||
85 | + TCGv_i64 dest = tcg_temp_new_i64(); | ||
86 | + | ||
87 | + if (a->rs1 == 0) { | ||
88 | + vec_element_loadi(s, dest, a->rs2, 0); | ||
89 | + } else { | ||
90 | + vec_element_loadx(s, dest, a->rs2, cpu_gpr[a->rs1], vlmax); | ||
91 | + } | ||
92 | + | ||
93 | + tcg_gen_gvec_dup_i64(s->sew, vreg_ofs(s, a->rd), | ||
94 | + MAXSZ(s), MAXSZ(s), dest); | ||
95 | + tcg_temp_free_i64(dest); | ||
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 | 93 | index XXXXXXX..XXXXXXX 100644 |
133 | --- a/target/riscv/vector_helper.c | 94 | --- a/hw/riscv/Kconfig |
134 | +++ b/target/riscv/vector_helper.c | 95 | +++ b/hw/riscv/Kconfig |
135 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_b, uint8_t, H1, clearb) | 96 | @@ -XXX,XX +XXX,XX @@ config RISCV_VIRT |
136 | GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_h, uint16_t, H2, clearh) | 97 | select SIFIVE_PLIC |
137 | GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_w, uint32_t, H4, clearl) | 98 | select SIFIVE_TEST |
138 | GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_d, uint64_t, H8, clearq) | 99 | select VIRTIO_MMIO |
139 | + | 100 | + select FW_CFG_DMA |
140 | +/* Vector Register Gather Instruction */ | 101 | |
141 | +#define GEN_VEXT_VRGATHER_VV(NAME, ETYPE, H, CLEAR_FN) \ | 102 | config SIFIVE_E |
142 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | 103 | bool |
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 | -- | 104 | -- |
200 | 2.27.0 | 105 | 2.30.1 |
201 | 106 | ||
202 | 107 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Asherah Connor <ashe@kivikakk.ee> |
---|---|---|---|
2 | 2 | ||
3 | vsetvl and vsetvli are two configure instructions for vl, vtype. TB flags | 3 | Allow ramfb on virt. This lets `-device ramfb' work. |
4 | should update after configure instructions. The (ill, lmul, sew ) of vtype | ||
5 | and the bit of (VSTART == 0 && VL == VLMAX) will be placed within tb_flags. | ||
6 | 4 | ||
7 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 5 | Signed-off-by: Asherah Connor <ashe@kivikakk.ee> |
6 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20210318235041.17175-3-ashe@kivikakk.ee |
10 | Message-id: 20200623215920.2594-5-zhiwei_liu@c-sky.com | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
12 | --- | 10 | --- |
13 | target/riscv/cpu.h | 63 +++++++++++++++++--- | 11 | hw/riscv/virt.c | 3 +++ |
14 | target/riscv/helper.h | 3 + | 12 | 1 file changed, 3 insertions(+) |
15 | target/riscv/insn32.decode | 5 ++ | ||
16 | target/riscv/insn_trans/trans_rvv.inc.c | 79 +++++++++++++++++++++++++ | ||
17 | target/riscv/translate.c | 17 +++++- | ||
18 | target/riscv/vector_helper.c | 53 +++++++++++++++++ | ||
19 | target/riscv/Makefile.objs | 2 +- | ||
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 | 13 | ||
24 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | 14 | diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c |
25 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/riscv/cpu.h | 16 | --- a/hw/riscv/virt.c |
27 | +++ b/target/riscv/cpu.h | 17 | +++ b/hw/riscv/virt.c |
28 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
29 | #define RISCV_CPU_H | 19 | #include "sysemu/sysemu.h" |
30 | 20 | #include "hw/pci/pci.h" | |
31 | #include "hw/core/cpu.h" | 21 | #include "hw/pci-host/gpex.h" |
32 | +#include "hw/registerfields.h" | 22 | +#include "hw/display/ramfb.h" |
33 | #include "exec/cpu-defs.h" | 23 | |
34 | #include "fpu/softfloat-types.h" | 24 | static const MemMapEntry virt_memmap[] = { |
35 | 25 | [VIRT_DEBUG] = { 0x0, 0x100 }, | |
36 | @@ -XXX,XX +XXX,XX @@ typedef struct CPURISCVState CPURISCVState; | 26 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) |
37 | 27 | mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; | |
38 | #define RV_VLEN_MAX 512 | 28 | mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id; |
39 | 29 | mc->numa_mem_supported = true; | |
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 | + | 30 | + |
46 | struct CPURISCVState { | 31 | + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE); |
47 | target_ulong gpr[32]; | ||
48 | uint64_t fpr[32]; /* assume both F and D extensions */ | ||
49 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong); | ||
50 | #define TB_FLAGS_MMU_MASK 3 | ||
51 | #define TB_FLAGS_MSTATUS_FS MSTATUS_FS | ||
52 | |||
53 | +typedef CPURISCVState CPUArchState; | ||
54 | +typedef RISCVCPU ArchCPU; | ||
55 | +#include "exec/cpu-all.h" | ||
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 | ||
112 | + *pflags = flags; | ||
113 | } | 32 | } |
114 | 33 | ||
115 | int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | 34 | static const TypeInfo virt_machine_typeinfo = { |
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 | ||
159 | index XXXXXXX..XXXXXXX | ||
160 | --- /dev/null | ||
161 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
162 | @@ -XXX,XX +XXX,XX @@ | ||
163 | +/* | ||
164 | + * RISC-V translation routines for the RVV Standard Extension. | ||
165 | + * | ||
166 | + * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved. | ||
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 | + * | ||
304 | + * 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, | ||
306 | + * version 2 or later, as published by the Free Software Foundation. | ||
307 | + * | ||
308 | + * This program is distributed in the hope it will be useful, but WITHOUT | ||
309 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
310 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
311 | + * more details. | ||
312 | + * | ||
313 | + * You should have received a copy of the GNU General Public License along with | ||
314 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
315 | + */ | ||
316 | + | ||
317 | +#include "qemu/osdep.h" | ||
318 | +#include "cpu.h" | ||
319 | +#include "exec/exec-all.h" | ||
320 | +#include "exec/helper-proto.h" | ||
321 | +#include <math.h> | ||
322 | + | ||
323 | +target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, | ||
324 | + target_ulong s2) | ||
325 | +{ | ||
326 | + int vlmax, vl; | ||
327 | + RISCVCPU *cpu = env_archcpu(env); | ||
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 | + } | ||
340 | + | ||
341 | + vlmax = vext_get_vlmax(cpu, s2); | ||
342 | + if (s1 <= vlmax) { | ||
343 | + vl = s1; | ||
344 | + } else { | ||
345 | + vl = vlmax; | ||
346 | + } | ||
347 | + env->vl = vl; | ||
348 | + env->vtype = s2; | ||
349 | + env->vstart = 0; | ||
350 | + return vl; | ||
351 | +} | ||
352 | diff --git a/target/riscv/Makefile.objs b/target/riscv/Makefile.objs | ||
353 | index XXXXXXX..XXXXXXX 100644 | ||
354 | --- a/target/riscv/Makefile.objs | ||
355 | +++ b/target/riscv/Makefile.objs | ||
356 | @@ -XXX,XX +XXX,XX @@ | ||
357 | -obj-y += translate.o op_helper.o cpu_helper.o cpu.o csr.o fpu_helper.o gdbstub.o | ||
358 | +obj-y += translate.o op_helper.o cpu_helper.o cpu.o csr.o fpu_helper.o vector_helper.o gdbstub.o | ||
359 | obj-$(CONFIG_SOFTMMU) += pmp.o | ||
360 | |||
361 | ifeq ($(CONFIG_SOFTMMU),y) | ||
362 | -- | 35 | -- |
363 | 2.27.0 | 36 | 2.30.1 |
364 | 37 | ||
365 | 38 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
---|---|---|---|
2 | 2 | ||
3 | The v0.7.1 specification does not define vector status within mstatus. | 3 | The previous implementation was broken in many ways: |
4 | A future revision will define the privileged portion of the vector status. | 4 | - Used mideleg instead of hideleg to mask accesses |
5 | - Used MIP_VSSIP instead of VS_MODE_INTERRUPTS to mask writes to vsie | ||
6 | - Did not shift between S bits and VS bits (VSEIP <-> SEIP, ...) | ||
5 | 7 | ||
6 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 8 | Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Message-id: 20210311094738.1376795-1-georg.kotheimer@kernkonzept.com |
9 | Message-id: 20200623215920.2594-4-zhiwei_liu@c-sky.com | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
11 | --- | 12 | --- |
12 | target/riscv/cpu_bits.h | 15 +++++++++ | 13 | target/riscv/csr.c | 68 +++++++++++++++++++++++----------------------- |
13 | target/riscv/csr.c | 75 ++++++++++++++++++++++++++++++++++++++++- | 14 | 1 file changed, 34 insertions(+), 34 deletions(-) |
14 | 2 files changed, 89 insertions(+), 1 deletion(-) | ||
15 | 15 | ||
16 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/riscv/cpu_bits.h | ||
19 | +++ b/target/riscv/cpu_bits.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #define FSR_NXA (FPEXC_NX << FSR_AEXC_SHIFT) | ||
22 | #define FSR_AEXC (FSR_NVA | FSR_OFA | FSR_UFA | FSR_DZA | FSR_NXA) | ||
23 | |||
24 | +/* Vector Fixed-Point round model */ | ||
25 | +#define FSR_VXRM_SHIFT 9 | ||
26 | +#define FSR_VXRM (0x3 << FSR_VXRM_SHIFT) | ||
27 | + | ||
28 | +/* Vector Fixed-Point saturation flag */ | ||
29 | +#define FSR_VXSAT_SHIFT 8 | ||
30 | +#define FSR_VXSAT (0x1 << FSR_VXSAT_SHIFT) | ||
31 | + | ||
32 | /* Control and Status Registers */ | ||
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 | 16 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c |
50 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/target/riscv/csr.c | 18 | --- a/target/riscv/csr.c |
52 | +++ b/target/riscv/csr.c | 19 | +++ b/target/riscv/csr.c |
53 | @@ -XXX,XX +XXX,XX @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops) | 20 | @@ -XXX,XX +XXX,XX @@ static int write_sstatus(CPURISCVState *env, int csrno, target_ulong val) |
54 | static int fs(CPURISCVState *env, int csrno) | 21 | return write_mstatus(env, CSR_MSTATUS, newval); |
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 | } | 22 | } |
67 | 23 | ||
68 | +static int vs(CPURISCVState *env, int csrno) | 24 | +static int read_vsie(CPURISCVState *env, int csrno, target_ulong *val) |
69 | +{ | 25 | +{ |
70 | + if (env->misa & RVV) { | 26 | + /* Shift the VS bits to their S bit location in vsie */ |
71 | + return 0; | 27 | + *val = (env->mie & env->hideleg & VS_MODE_INTERRUPTS) >> 1; |
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; | 28 | + return 0; |
106 | +} | 29 | +} |
107 | + | 30 | + |
108 | +static int read_vl(CPURISCVState *env, int csrno, target_ulong *val) | 31 | static int read_sie(CPURISCVState *env, int csrno, target_ulong *val) |
32 | { | ||
33 | if (riscv_cpu_virt_enabled(env)) { | ||
34 | - /* Tell the guest the VS bits, shifted to the S bit locations */ | ||
35 | - *val = (env->mie & env->mideleg & VS_MODE_INTERRUPTS) >> 1; | ||
36 | + read_vsie(env, CSR_VSIE, val); | ||
37 | } else { | ||
38 | *val = env->mie & env->mideleg; | ||
39 | } | ||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | -static int write_sie(CPURISCVState *env, int csrno, target_ulong val) | ||
44 | +static int write_vsie(CPURISCVState *env, int csrno, target_ulong val) | ||
45 | { | ||
46 | - target_ulong newval; | ||
47 | + /* Shift the S bits to their VS bit location in mie */ | ||
48 | + target_ulong newval = (env->mie & ~VS_MODE_INTERRUPTS) | | ||
49 | + ((val << 1) & env->hideleg & VS_MODE_INTERRUPTS); | ||
50 | + return write_mie(env, CSR_MIE, newval); | ||
51 | +} | ||
52 | |||
53 | +static int write_sie(CPURISCVState *env, int csrno, target_ulong val) | ||
109 | +{ | 54 | +{ |
110 | + *val = env->vl; | 55 | if (riscv_cpu_virt_enabled(env)) { |
56 | - /* Shift the guests S bits to VS */ | ||
57 | - newval = (env->mie & ~VS_MODE_INTERRUPTS) | | ||
58 | - ((val << 1) & VS_MODE_INTERRUPTS); | ||
59 | + write_vsie(env, CSR_VSIE, val); | ||
60 | } else { | ||
61 | - newval = (env->mie & ~S_MODE_INTERRUPTS) | (val & S_MODE_INTERRUPTS); | ||
62 | + target_ulong newval = (env->mie & ~S_MODE_INTERRUPTS) | | ||
63 | + (val & S_MODE_INTERRUPTS); | ||
64 | + write_mie(env, CSR_MIE, newval); | ||
65 | } | ||
66 | |||
67 | - return write_mie(env, CSR_MIE, newval); | ||
111 | + return 0; | 68 | + return 0; |
69 | } | ||
70 | |||
71 | static int read_stvec(CPURISCVState *env, int csrno, target_ulong *val) | ||
72 | @@ -XXX,XX +XXX,XX @@ static int write_sbadaddr(CPURISCVState *env, int csrno, target_ulong val) | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | +static int rmw_vsip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
77 | + target_ulong new_value, target_ulong write_mask) | ||
78 | +{ | ||
79 | + /* Shift the S bits to their VS bit location in mip */ | ||
80 | + int ret = rmw_mip(env, 0, ret_value, new_value << 1, | ||
81 | + (write_mask << 1) & vsip_writable_mask & env->hideleg); | ||
82 | + *ret_value &= VS_MODE_INTERRUPTS; | ||
83 | + /* Shift the VS bits to their S bit location in vsip */ | ||
84 | + *ret_value >>= 1; | ||
85 | + return ret; | ||
112 | +} | 86 | +} |
113 | + | 87 | + |
114 | +static int read_vxrm(CPURISCVState *env, int csrno, target_ulong *val) | 88 | static int rmw_sip(CPURISCVState *env, int csrno, target_ulong *ret_value, |
115 | +{ | 89 | target_ulong new_value, target_ulong write_mask) |
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 | { | 90 | { |
153 | @@ -XXX,XX +XXX,XX @@ static riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { | 91 | int ret; |
154 | [CSR_FFLAGS] = { fs, read_fflags, write_fflags }, | 92 | |
155 | [CSR_FRM] = { fs, read_frm, write_frm }, | 93 | if (riscv_cpu_virt_enabled(env)) { |
156 | [CSR_FCSR] = { fs, read_fcsr, write_fcsr }, | 94 | - /* Shift the new values to line up with the VS bits */ |
95 | - ret = rmw_mip(env, CSR_MSTATUS, ret_value, new_value << 1, | ||
96 | - (write_mask & sip_writable_mask) << 1 & env->mideleg); | ||
97 | - ret &= vsip_writable_mask; | ||
98 | - ret >>= 1; | ||
99 | + ret = rmw_vsip(env, CSR_VSIP, ret_value, new_value, write_mask); | ||
100 | } else { | ||
101 | ret = rmw_mip(env, CSR_MSTATUS, ret_value, new_value, | ||
102 | write_mask & env->mideleg & sip_writable_mask); | ||
103 | @@ -XXX,XX +XXX,XX @@ static int write_vsstatus(CPURISCVState *env, int csrno, target_ulong val) | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | -static int rmw_vsip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
108 | - target_ulong new_value, target_ulong write_mask) | ||
109 | -{ | ||
110 | - int ret = rmw_mip(env, 0, ret_value, new_value, | ||
111 | - write_mask & env->mideleg & vsip_writable_mask); | ||
112 | - return ret; | ||
113 | -} | ||
157 | - | 114 | - |
158 | + /* Vector CSRs */ | 115 | -static int read_vsie(CPURISCVState *env, int csrno, target_ulong *val) |
159 | + [CSR_VSTART] = { vs, read_vstart, write_vstart }, | 116 | -{ |
160 | + [CSR_VXSAT] = { vs, read_vxsat, write_vxsat }, | 117 | - *val = env->mie & env->mideleg & VS_MODE_INTERRUPTS; |
161 | + [CSR_VXRM] = { vs, read_vxrm, write_vxrm }, | 118 | - return 0; |
162 | + [CSR_VL] = { vs, read_vl }, | 119 | -} |
163 | + [CSR_VTYPE] = { vs, read_vtype }, | 120 | - |
164 | /* User Timers and Counters */ | 121 | -static int write_vsie(CPURISCVState *env, int csrno, target_ulong val) |
165 | [CSR_CYCLE] = { ctr, read_instret }, | 122 | -{ |
166 | [CSR_INSTRET] = { ctr, read_instret }, | 123 | - target_ulong newval = (env->mie & ~env->mideleg) | (val & env->mideleg & MIP_VSSIP); |
124 | - return write_mie(env, CSR_MIE, newval); | ||
125 | -} | ||
126 | - | ||
127 | static int read_vstvec(CPURISCVState *env, int csrno, target_ulong *val) | ||
128 | { | ||
129 | *val = env->vstvec; | ||
167 | -- | 130 | -- |
168 | 2.27.0 | 131 | 2.30.1 |
169 | 132 | ||
170 | 133 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
---|---|---|---|
2 | 2 | ||
3 | vlen is the vector register length in bits. | 3 | The current two-stage lookup detection in riscv_cpu_do_interrupt falls |
4 | elen is the max element size in bits. | 4 | short of its purpose, as all it checks is whether two-stage address |
5 | vext_spec is the vector specification version, default value is v0.7.1. | 5 | translation either via the hypervisor-load store instructions or the |
6 | MPRV feature would be allowed. | ||
6 | 7 | ||
7 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 8 | What we really need instead is whether two-stage address translation was |
9 | active when the exception was raised. However, in riscv_cpu_do_interrupt | ||
10 | we do not have the information to reliably detect this. Therefore, when | ||
11 | we raise a memory fault exception we have to record whether two-stage | ||
12 | address translation is active. | ||
13 | |||
14 | Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Message-id: 20210319141459.1196741-1-georg.kotheimer@kernkonzept.com |
10 | Message-id: 20200623215920.2594-3-zhiwei_liu@c-sky.com | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
12 | --- | 18 | --- |
13 | target/riscv/cpu.h | 5 +++++ | 19 | target/riscv/cpu.h | 4 ++++ |
14 | target/riscv/cpu.c | 7 +++++++ | 20 | target/riscv/cpu.c | 1 + |
15 | 2 files changed, 12 insertions(+) | 21 | target/riscv/cpu_helper.c | 21 ++++++++------------- |
22 | 3 files changed, 13 insertions(+), 13 deletions(-) | ||
16 | 23 | ||
17 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | 24 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/riscv/cpu.h | 26 | --- a/target/riscv/cpu.h |
20 | +++ b/target/riscv/cpu.h | 27 | +++ b/target/riscv/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ enum { | 28 | @@ -XXX,XX +XXX,XX @@ struct CPURISCVState { |
22 | #define PRIV_VERSION_1_10_0 0x00011000 | 29 | target_ulong satp_hs; |
23 | #define PRIV_VERSION_1_11_0 0x00011100 | 30 | uint64_t mstatus_hs; |
24 | 31 | ||
25 | +#define VEXT_VERSION_0_07_1 0x00000701 | 32 | + /* Signals whether the current exception occurred with two-stage address |
33 | + translation active. */ | ||
34 | + bool two_stage_lookup; | ||
26 | + | 35 | + |
27 | #define TRANSLATE_PMP_FAIL 2 | 36 | target_ulong scounteren; |
28 | #define TRANSLATE_FAIL 1 | 37 | target_ulong mcounteren; |
29 | #define TRANSLATE_SUCCESS 0 | 38 | |
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 | 39 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
48 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/target/riscv/cpu.c | 41 | --- a/target/riscv/cpu.c |
50 | +++ b/target/riscv/cpu.c | 42 | +++ b/target/riscv/cpu.c |
51 | @@ -XXX,XX +XXX,XX @@ static void set_priv_version(CPURISCVState *env, int priv_ver) | 43 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset(DeviceState *dev) |
52 | env->priv_ver = priv_ver; | 44 | env->mstatus &= ~(MSTATUS_MIE | MSTATUS_MPRV); |
45 | env->mcause = 0; | ||
46 | env->pc = env->resetvec; | ||
47 | + env->two_stage_lookup = false; | ||
48 | #endif | ||
49 | cs->exception_index = EXCP_NONE; | ||
50 | env->load_res = -1; | ||
51 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/riscv/cpu_helper.c | ||
54 | +++ b/target/riscv/cpu_helper.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, | ||
56 | g_assert_not_reached(); | ||
57 | } | ||
58 | env->badaddr = address; | ||
59 | + env->two_stage_lookup = two_stage; | ||
53 | } | 60 | } |
54 | 61 | ||
55 | +static void set_vext_version(CPURISCVState *env, int vext_ver) | 62 | hwaddr riscv_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) |
56 | +{ | 63 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, |
57 | + env->vext_ver = vext_ver; | ||
58 | +} | ||
59 | + | ||
60 | static void set_feature(CPURISCVState *env, int feature) | ||
61 | { | ||
62 | env->features |= (1ULL << feature); | ||
63 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) | ||
64 | CPURISCVState *env = &cpu->env; | ||
65 | RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev); | ||
66 | int priv_version = PRIV_VERSION_1_11_0; | ||
67 | + int vext_version = VEXT_VERSION_0_07_1; | ||
68 | target_ulong target_misa = 0; | ||
69 | Error *local_err = NULL; | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) | ||
72 | } | 64 | } |
73 | 65 | ||
74 | set_priv_version(env, priv_version); | 66 | env->badaddr = addr; |
75 | + set_vext_version(env, vext_version); | 67 | + env->two_stage_lookup = riscv_cpu_virt_enabled(env) || |
76 | 68 | + riscv_cpu_two_stage_lookup(mmu_idx); | |
77 | if (cpu->cfg.mmu) { | 69 | riscv_raise_exception(&cpu->env, cs->exception_index, retaddr); |
78 | set_feature(env, RISCV_FEATURE_MMU); | 70 | } |
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, | ||
73 | g_assert_not_reached(); | ||
74 | } | ||
75 | env->badaddr = addr; | ||
76 | + env->two_stage_lookup = riscv_cpu_virt_enabled(env) || | ||
77 | + riscv_cpu_two_stage_lookup(mmu_idx); | ||
78 | riscv_raise_exception(env, cs->exception_index, retaddr); | ||
79 | } | ||
80 | #endif /* !CONFIG_USER_ONLY */ | ||
81 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs) | ||
82 | /* handle the trap in S-mode */ | ||
83 | if (riscv_has_ext(env, RVH)) { | ||
84 | target_ulong hdeleg = async ? env->hideleg : env->hedeleg; | ||
85 | - bool two_stage_lookup = false; | ||
86 | |||
87 | - if (env->priv == PRV_M || | ||
88 | - (env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) || | ||
89 | - (env->priv == PRV_U && !riscv_cpu_virt_enabled(env) && | ||
90 | - get_field(env->hstatus, HSTATUS_HU))) { | ||
91 | - two_stage_lookup = true; | ||
92 | - } | ||
93 | - | ||
94 | - if ((riscv_cpu_virt_enabled(env) || two_stage_lookup) && write_tval) { | ||
95 | + if (env->two_stage_lookup && write_tval) { | ||
96 | /* | ||
97 | * If we are writing a guest virtual address to stval, set | ||
98 | * this to 1. If we are trapping to VS we will set this to 0 | ||
99 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs) | ||
100 | riscv_cpu_set_force_hs_excep(env, 0); | ||
101 | } else { | ||
102 | /* Trap into HS mode */ | ||
103 | - if (!two_stage_lookup) { | ||
104 | - env->hstatus = set_field(env->hstatus, HSTATUS_SPV, | ||
105 | - riscv_cpu_virt_enabled(env)); | ||
106 | - } | ||
107 | + env->hstatus = set_field(env->hstatus, HSTATUS_SPV, false); | ||
108 | htval = env->guest_phys_fault_addr; | ||
109 | } | ||
110 | } | ||
111 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs) | ||
112 | * RISC-V ISA Specification. | ||
113 | */ | ||
114 | |||
115 | + env->two_stage_lookup = false; | ||
116 | #endif | ||
117 | cs->exception_index = EXCP_NONE; /* mark handled to qemu */ | ||
118 | } | ||
79 | -- | 119 | -- |
80 | 2.27.0 | 120 | 2.30.1 |
81 | 121 | ||
82 | 122 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Per SST25VF016B datasheet [1], SST flash requires a dummy byte after |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | the address bytes. Note only SPI mode is supported by SST flashes. |
5 | Message-id: 20200623215920.2594-59-zhiwei_liu@c-sky.com | 5 | |
6 | [1] http://ww1.microchip.com/downloads/en/devicedoc/s71271_04.pdf | ||
7 | |||
8 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
9 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20210306060152.7250-1-bmeng.cn@gmail.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 | 17 ++++ | 13 | hw/block/m25p80.c | 3 +++ |
9 | target/riscv/insn32.decode | 6 ++ | 14 | 1 file changed, 3 insertions(+) |
10 | target/riscv/insn_trans/trans_rvv.inc.c | 18 ++++ | ||
11 | target/riscv/vector_helper.c | 114 ++++++++++++++++++++++++ | ||
12 | 4 files changed, 155 insertions(+) | ||
13 | 15 | ||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | 16 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/riscv/helper.h | 18 | --- a/hw/block/m25p80.c |
17 | +++ b/target/riscv/helper.h | 19 | +++ b/hw/block/m25p80.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vid_v_b, void, ptr, ptr, env, i32) | 20 | @@ -XXX,XX +XXX,XX @@ static void decode_fast_read_cmd(Flash *s) |
19 | DEF_HELPER_4(vid_v_h, void, ptr, ptr, env, i32) | 21 | s->needed_bytes = get_addr_length(s); |
20 | DEF_HELPER_4(vid_v_w, void, ptr, ptr, env, i32) | 22 | switch (get_man(s)) { |
21 | DEF_HELPER_4(vid_v_d, void, ptr, ptr, env, i32) | 23 | /* Dummy cycles - modeled with bytes writes instead of bits */ |
22 | + | 24 | + case MAN_SST: |
23 | +DEF_HELPER_6(vslideup_vx_b, void, ptr, ptr, tl, ptr, env, i32) | 25 | + s->needed_bytes += 1; |
24 | +DEF_HELPER_6(vslideup_vx_h, void, ptr, ptr, tl, ptr, env, i32) | 26 | + break; |
25 | +DEF_HELPER_6(vslideup_vx_w, void, ptr, ptr, tl, ptr, env, i32) | 27 | case MAN_WINBOND: |
26 | +DEF_HELPER_6(vslideup_vx_d, void, ptr, ptr, tl, ptr, env, i32) | 28 | s->needed_bytes += 8; |
27 | +DEF_HELPER_6(vslidedown_vx_b, void, ptr, ptr, tl, ptr, env, i32) | 29 | break; |
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 | ||
41 | --- a/target/riscv/insn32.decode | ||
42 | +++ b/target/riscv/insn32.decode | ||
43 | @@ -XXX,XX +XXX,XX @@ vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r | ||
44 | vmv_s_x 001101 1 00000 ..... 110 ..... 1010111 @r2 | ||
45 | vfmv_f_s 001100 1 ..... 00000 001 ..... 1010111 @r2rd | ||
46 | vfmv_s_f 001101 1 00000 ..... 101 ..... 1010111 @r2 | ||
47 | +vslideup_vx 001110 . ..... ..... 100 ..... 1010111 @r_vm | ||
48 | +vslideup_vi 001110 . ..... ..... 011 ..... 1010111 @r_vm | ||
49 | +vslide1up_vx 001110 . ..... ..... 110 ..... 1010111 @r_vm | ||
50 | +vslidedown_vx 001111 . ..... ..... 100 ..... 1010111 @r_vm | ||
51 | +vslidedown_vi 001111 . ..... ..... 011 ..... 1010111 @r_vm | ||
52 | +vslide1down_vx 001111 . ..... ..... 110 ..... 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 @@ static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a) | ||
61 | } | ||
62 | return false; | ||
63 | } | ||
64 | + | ||
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 | -- | 30 | -- |
205 | 2.27.0 | 31 | 2.30.1 |
206 | 32 | ||
207 | 33 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 3 | Since HSS commit c20a89f8dcac, the Icicle Kit reference design has |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | been updated to use a register mapped at 0x4f000000 instead of a |
5 | Message-id: 20200623215920.2594-58-zhiwei_liu@c-sky.com | 5 | GPIO to control whether eMMC or SD card is to be used. With this |
6 | support the same HSS image can be used for both eMMC and SD card | ||
7 | boot flow, while previously two different board configurations were | ||
8 | used. This is undocumented but one can take a look at the HSS code | ||
9 | HSS_MMCInit() in services/mmc/mmc_api.c. | ||
10 | |||
11 | With this commit, HSS image built from 2020.12 release boots again. | ||
12 | |||
13 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
15 | Message-id: 20210322075248.136255-1-bmeng.cn@gmail.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 16 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | --- | 17 | --- |
8 | target/riscv/insn32.decode | 3 ++ | 18 | include/hw/riscv/microchip_pfsoc.h | 1 + |
9 | target/riscv/insn_trans/trans_rvv.inc.c | 49 +++++++++++++++++++++++++ | 19 | hw/riscv/microchip_pfsoc.c | 6 ++++++ |
10 | 2 files changed, 52 insertions(+) | 20 | 2 files changed, 7 insertions(+) |
11 | 21 | ||
12 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | 22 | diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h |
13 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/riscv/insn32.decode | 24 | --- a/include/hw/riscv/microchip_pfsoc.h |
15 | +++ b/target/riscv/insn32.decode | 25 | +++ b/include/hw/riscv/microchip_pfsoc.h |
16 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ enum { |
17 | @r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd | 27 | MICROCHIP_PFSOC_ENVM_DATA, |
18 | @r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd | 28 | MICROCHIP_PFSOC_QSPI_XIP, |
19 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | 29 | MICROCHIP_PFSOC_IOSCB, |
20 | +@r2rd ....... ..... ..... ... ..... ....... %rs2 %rd | 30 | + MICROCHIP_PFSOC_EMMC_SD_MUX, |
21 | @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | 31 | MICROCHIP_PFSOC_DRAM_LO, |
22 | @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd | 32 | MICROCHIP_PFSOC_DRAM_LO_ALIAS, |
23 | @r_vm_0 ...... . ..... ..... ... ..... ....... &rmrr vm=0 %rs2 %rs1 %rd | 33 | MICROCHIP_PFSOC_DRAM_HI, |
24 | @@ -XXX,XX +XXX,XX @@ viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | 34 | diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.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 | 35 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | 36 | --- a/hw/riscv/microchip_pfsoc.c |
36 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | 37 | +++ b/hw/riscv/microchip_pfsoc.c |
37 | @@ -XXX,XX +XXX,XX @@ static bool trans_vmv_s_x(DisasContext *s, arg_vmv_s_x *a) | 38 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry microchip_pfsoc_memmap[] = { |
38 | } | 39 | [MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 }, |
39 | return false; | 40 | [MICROCHIP_PFSOC_QSPI_XIP] = { 0x21000000, 0x1000000 }, |
40 | } | 41 | [MICROCHIP_PFSOC_IOSCB] = { 0x30000000, 0x10000000 }, |
42 | + [MICROCHIP_PFSOC_EMMC_SD_MUX] = { 0x4f000000, 0x4 }, | ||
43 | [MICROCHIP_PFSOC_DRAM_LO] = { 0x80000000, 0x40000000 }, | ||
44 | [MICROCHIP_PFSOC_DRAM_LO_ALIAS] = { 0xc0000000, 0x40000000 }, | ||
45 | [MICROCHIP_PFSOC_DRAM_HI] = { 0x1000000000, 0x0 }, | ||
46 | @@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) | ||
47 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->ioscb), 0, | ||
48 | memmap[MICROCHIP_PFSOC_IOSCB].base); | ||
49 | |||
50 | + /* eMMC/SD mux */ | ||
51 | + create_unimplemented_device("microchip.pfsoc.emmc_sd_mux", | ||
52 | + memmap[MICROCHIP_PFSOC_EMMC_SD_MUX].base, | ||
53 | + memmap[MICROCHIP_PFSOC_EMMC_SD_MUX].size); | ||
41 | + | 54 | + |
42 | +/* Floating-Point Scalar Move Instructions */ | 55 | /* QSPI Flash */ |
43 | +static bool trans_vfmv_f_s(DisasContext *s, arg_vfmv_f_s *a) | 56 | memory_region_init_rom(qspi_xip_mem, OBJECT(dev), |
44 | +{ | 57 | "microchip.pfsoc.qspi_xip", |
45 | + if (!s->vill && has_ext(s, RVF) && | ||
46 | + (s->mstatus_fs != 0) && (s->sew != 0)) { | ||
47 | + unsigned int len = 8 << s->sew; | ||
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 | + } | ||
54 | + | ||
55 | + mark_fs_dirty(s); | ||
56 | + return true; | ||
57 | + } | ||
58 | + return false; | ||
59 | +} | ||
60 | + | ||
61 | +/* vfmv.s.f vd, rs1 # vd[0] = rs1 (vs2=0) */ | ||
62 | +static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a) | ||
63 | +{ | ||
64 | + if (!s->vill && has_ext(s, RVF) && (s->sew != 0)) { | ||
65 | + TCGv_i64 t1; | ||
66 | + /* The instructions ignore LMUL and vector register group. */ | ||
67 | + uint32_t vlmax = s->vlen >> 3; | ||
68 | + | ||
69 | + /* if vl == 0, skip vector register write back */ | ||
70 | + TCGLabel *over = gen_new_label(); | ||
71 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); | ||
72 | + | ||
73 | + /* zeroed all elements */ | ||
74 | + tcg_gen_gvec_dup_imm(SEW64, vreg_ofs(s, a->rd), vlmax, vlmax, 0); | ||
75 | + | ||
76 | + /* NaN-box f[rs1] as necessary for SEW */ | ||
77 | + t1 = tcg_temp_new_i64(); | ||
78 | + if (s->sew == MO_64 && !has_ext(s, RVD)) { | ||
79 | + tcg_gen_ori_i64(t1, cpu_fpr[a->rs1], MAKE_64BIT_MASK(32, 32)); | ||
80 | + } else { | ||
81 | + tcg_gen_mov_i64(t1, cpu_fpr[a->rs1]); | ||
82 | + } | ||
83 | + vec_element_storei(s, a->rd, 0, t1); | ||
84 | + tcg_temp_free_i64(t1); | ||
85 | + gen_set_label(over); | ||
86 | + return true; | ||
87 | + } | ||
88 | + return false; | ||
89 | +} | ||
90 | -- | 58 | -- |
91 | 2.27.0 | 59 | 2.30.1 |
92 | 60 | ||
93 | 61 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | The internals.h keeps things that are not relevant to the actual architecture, | 3 | This adds the documentation to describe what is supported for the |
4 | only to the implementation, separate. | 4 | 'microchip-icicle-kit' machine, and how to boot the machine in QEMU. |
5 | 5 | ||
6 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 6 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20210322075248.136255-2-bmeng.cn@gmail.com |
9 | Message-id: 20200623215920.2594-6-zhiwei_liu@c-sky.com | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
11 | --- | 10 | --- |
12 | target/riscv/internals.h | 24 ++++++++++++++++++++++++ | 11 | docs/system/riscv/microchip-icicle-kit.rst | 89 ++++++++++++++++++++++ |
13 | 1 file changed, 24 insertions(+) | 12 | docs/system/target-riscv.rst | 1 + |
14 | create mode 100644 target/riscv/internals.h | 13 | 2 files changed, 90 insertions(+) |
14 | create mode 100644 docs/system/riscv/microchip-icicle-kit.rst | ||
15 | 15 | ||
16 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | 16 | diff --git a/docs/system/riscv/microchip-icicle-kit.rst b/docs/system/riscv/microchip-icicle-kit.rst |
17 | new file mode 100644 | 17 | new file mode 100644 |
18 | index XXXXXXX..XXXXXXX | 18 | index XXXXXXX..XXXXXXX |
19 | --- /dev/null | 19 | --- /dev/null |
20 | +++ b/target/riscv/internals.h | 20 | +++ b/docs/system/riscv/microchip-icicle-kit.rst |
21 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
22 | +/* | 22 | +Microchip PolarFire SoC Icicle Kit (``microchip-icicle-kit``) |
23 | + * QEMU RISC-V CPU -- internal functions and types | 23 | +============================================================= |
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 | + | 24 | + |
40 | +#ifndef RISCV_CPU_INTERNALS_H | 25 | +Microchip PolarFire SoC Icicle Kit integrates a PolarFire SoC, with one |
41 | +#define RISCV_CPU_INTERNALS_H | 26 | +SiFive's E51 plus four U54 cores and many on-chip peripherals and an FPGA. |
42 | + | 27 | + |
43 | +#include "hw/registerfields.h" | 28 | +For more details about Microchip PolarFire SoC, please see: |
29 | +https://www.microsemi.com/product-directory/soc-fpgas/5498-polarfire-soc-fpga | ||
44 | + | 30 | + |
45 | +#endif | 31 | +The Icicle Kit board information can be found here: |
32 | +https://www.microsemi.com/existing-parts/parts/152514 | ||
33 | + | ||
34 | +Supported devices | ||
35 | +----------------- | ||
36 | + | ||
37 | +The ``microchip-icicle-kit`` machine supports the following devices: | ||
38 | + | ||
39 | + * 1 E51 core | ||
40 | + * 4 U54 cores | ||
41 | + * Core Level Interruptor (CLINT) | ||
42 | + * Platform-Level Interrupt Controller (PLIC) | ||
43 | + * L2 Loosely Integrated Memory (L2-LIM) | ||
44 | + * DDR memory controller | ||
45 | + * 5 MMUARTs | ||
46 | + * 1 DMA controller | ||
47 | + * 2 GEM Ethernet controllers | ||
48 | + * 1 SDHC storage controller | ||
49 | + | ||
50 | +Boot options | ||
51 | +------------ | ||
52 | + | ||
53 | +The ``microchip-icicle-kit`` machine can start using the standard -bios | ||
54 | +functionality for loading its BIOS image, aka Hart Software Services (HSS_). | ||
55 | +HSS loads the second stage bootloader U-Boot from an SD card. It does not | ||
56 | +support direct kernel loading via the -kernel option. One has to load kernel | ||
57 | +from U-Boot. | ||
58 | + | ||
59 | +The memory is set to 1537 MiB by default which is the minimum required high | ||
60 | +memory size by HSS. A sanity check on ram size is performed in the machine | ||
61 | +init routine to prompt user to increase the RAM size to > 1537 MiB when less | ||
62 | +than 1537 MiB ram is detected. | ||
63 | + | ||
64 | +Boot the machine | ||
65 | +---------------- | ||
66 | + | ||
67 | +HSS 2020.12 release is tested at the time of writing. To build an HSS image | ||
68 | +that can be booted by the ``microchip-icicle-kit`` machine, type the following | ||
69 | +in the HSS source tree: | ||
70 | + | ||
71 | +.. code-block:: bash | ||
72 | + | ||
73 | + $ export CROSS_COMPILE=riscv64-linux- | ||
74 | + $ cp boards/mpfs-icicle-kit-es/def_config .config | ||
75 | + $ make BOARD=mpfs-icicle-kit-es | ||
76 | + | ||
77 | +Download the official SD card image released by Microchip and prepare it for | ||
78 | +QEMU usage: | ||
79 | + | ||
80 | +.. code-block:: bash | ||
81 | + | ||
82 | + $ wget ftp://ftpsoc.microsemi.com/outgoing/core-image-minimal-dev-icicle-kit-es-sd-20201009141623.rootfs.wic.gz | ||
83 | + $ gunzip core-image-minimal-dev-icicle-kit-es-sd-20201009141623.rootfs.wic.gz | ||
84 | + $ qemu-img resize core-image-minimal-dev-icicle-kit-es-sd-20201009141623.rootfs.wic 4G | ||
85 | + | ||
86 | +Then we can boot the machine by: | ||
87 | + | ||
88 | +.. code-block:: bash | ||
89 | + | ||
90 | + $ qemu-system-riscv64 -M microchip-icicle-kit -smp 5 \ | ||
91 | + -bios path/to/hss.bin -sd path/to/sdcard.img \ | ||
92 | + -nic user,model=cadence_gem \ | ||
93 | + -nic tap,ifname=tap,model=cadence_gem,script=no \ | ||
94 | + -display none -serial stdio \ | ||
95 | + -chardev socket,id=serial1,path=serial1.sock,server=on,wait=on \ | ||
96 | + -serial chardev:serial1 | ||
97 | + | ||
98 | +With above command line, current terminal session will be used for the first | ||
99 | +serial port. Open another terminal window, and use `minicom` to connect the | ||
100 | +second serial port. | ||
101 | + | ||
102 | +.. code-block:: bash | ||
103 | + | ||
104 | + $ minicom -D unix\#serial1.sock | ||
105 | + | ||
106 | +HSS output is on the first serial port (stdio) and U-Boot outputs on the | ||
107 | +second serial port. U-Boot will automatically load the Linux kernel from | ||
108 | +the SD card image. | ||
109 | + | ||
110 | +.. _HSS: https://github.com/polarfire-soc/hart-software-services | ||
111 | diff --git a/docs/system/target-riscv.rst b/docs/system/target-riscv.rst | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/docs/system/target-riscv.rst | ||
114 | +++ b/docs/system/target-riscv.rst | ||
115 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | ||
116 | .. toctree:: | ||
117 | :maxdepth: 1 | ||
118 | |||
119 | + riscv/microchip-icicle-kit | ||
120 | riscv/sifive_u | ||
121 | |||
122 | RISC-V CPU features | ||
46 | -- | 123 | -- |
47 | 2.27.0 | 124 | 2.30.1 |
48 | 125 | ||
49 | 126 | diff view generated by jsdifflib |
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | 1 | From: Georg Kotheimer <georg.kotheimer@kernkonzept.com> |
---|---|---|---|
2 | 2 | ||
3 | Vector strided operations access the first memory element at the base address, | 3 | When decode_insn16() fails, we fall back to decode_RV32_64C() for |
4 | and then access subsequent elements at address increments given by the byte | 4 | further compressed instruction decoding. However, prior to this change, |
5 | offset contained in the x register specified by rs2. | 5 | we did not raise an illegal instruction exception, if decode_RV32_64C() |
6 | 6 | fails to decode the instruction. This means that we skipped illegal | |
7 | Vector unit-stride operations access elements stored contiguously in memory | 7 | compressed instructions instead of raising an illegal instruction |
8 | starting from the base effective address. It can been seen as a special | 8 | exception. |
9 | case of strided operations. | 9 | |
10 | 10 | Instead of patching decode_RV32_64C(), we can just remove it, | |
11 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | 11 | as it is dead code since f330433b363 anyway. |
12 | |||
13 | Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> | ||
14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 16 | Message-id: 20210322121609.3097928-1-georg.kotheimer@kernkonzept.com |
14 | Message-id: 20200623215920.2594-7-zhiwei_liu@c-sky.com | ||
15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
16 | --- | 18 | --- |
17 | target/riscv/helper.h | 105 ++++++ | 19 | target/riscv/translate.c | 179 +-------------------------------------- |
18 | target/riscv/internals.h | 5 + | 20 | 1 file changed, 1 insertion(+), 178 deletions(-) |
19 | target/riscv/insn32.decode | 32 ++ | 21 | |
20 | target/riscv/insn_trans/trans_rvv.inc.c | 355 ++++++++++++++++++++ | ||
21 | target/riscv/translate.c | 7 + | ||
22 | target/riscv/vector_helper.c | 410 ++++++++++++++++++++++++ | ||
23 | 6 files changed, 914 insertions(+) | ||
24 | |||
25 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/riscv/helper.h | ||
28 | +++ b/target/riscv/helper.h | ||
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_1(hyp_tlb_flush, void, env) | ||
30 | |||
31 | /* Vector functions */ | ||
32 | DEF_HELPER_3(vsetvl, tl, env, tl, tl) | ||
33 | +DEF_HELPER_5(vlb_v_b, void, ptr, ptr, tl, env, i32) | ||
34 | +DEF_HELPER_5(vlb_v_b_mask, void, ptr, ptr, tl, env, i32) | ||
35 | +DEF_HELPER_5(vlb_v_h, void, ptr, ptr, tl, env, i32) | ||
36 | +DEF_HELPER_5(vlb_v_h_mask, void, ptr, ptr, tl, env, i32) | ||
37 | +DEF_HELPER_5(vlb_v_w, void, ptr, ptr, tl, env, i32) | ||
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 | ||
140 | --- a/target/riscv/internals.h | ||
141 | +++ b/target/riscv/internals.h | ||
142 | @@ -XXX,XX +XXX,XX @@ | ||
143 | |||
144 | #include "hw/registerfields.h" | ||
145 | |||
146 | +/* share data between vector helpers and decode code */ | ||
147 | +FIELD(VDATA, MLEN, 0, 8) | ||
148 | +FIELD(VDATA, VM, 8, 1) | ||
149 | +FIELD(VDATA, LMUL, 9, 2) | ||
150 | +FIELD(VDATA, NF, 11, 4) | ||
151 | #endif | ||
152 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/riscv/insn32.decode | ||
155 | +++ b/target/riscv/insn32.decode | ||
156 | @@ -XXX,XX +XXX,XX @@ | ||
157 | %sh10 20:10 | ||
158 | %csr 20:12 | ||
159 | %rm 12:3 | ||
160 | +%nf 29:3 !function=ex_plus_1 | ||
161 | |||
162 | # immediates: | ||
163 | %imm_i 20:s12 | ||
164 | @@ -XXX,XX +XXX,XX @@ | ||
165 | &u imm rd | ||
166 | &shift shamt rs1 rd | ||
167 | &atomic aq rl rs2 rs1 rd | ||
168 | +&r2nfvm vm rd rs1 nf | ||
169 | +&rnfvm vm rd rs1 rs2 nf | ||
170 | |||
171 | # Formats 32: | ||
172 | @r ....... ..... ..... ... ..... ....... &r %rs2 %rs1 %rd | ||
173 | @@ -XXX,XX +XXX,XX @@ | ||
174 | @r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd | ||
175 | @r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd | ||
176 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | ||
177 | +@r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | ||
178 | +@r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | ||
179 | @r2_zimm . zimm:11 ..... ... ..... ....... %rs1 %rd | ||
180 | |||
181 | @hfence_gvma ....... ..... ..... ... ..... ....... %rs2 %rs1 | ||
182 | @@ -XXX,XX +XXX,XX @@ hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma | ||
183 | hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma | ||
184 | |||
185 | # *** RV32V Extension *** | ||
186 | + | ||
187 | +# *** Vector loads and stores are encoded within LOADFP/STORE-FP *** | ||
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 | +} | ||
239 | + | ||
240 | +/* check functions */ | ||
241 | + | ||
242 | +/* | ||
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 | 22 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c |
586 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
587 | --- a/target/riscv/translate.c | 24 | --- a/target/riscv/translate.c |
588 | +++ b/target/riscv/translate.c | 25 | +++ b/target/riscv/translate.c |
589 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 26 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
590 | uint8_t lmul; | 27 | CPUState *cs; |
591 | uint8_t sew; | ||
592 | uint16_t vlen; | ||
593 | + uint16_t mlen; | ||
594 | bool vl_eq_vlmax; | ||
595 | } DisasContext; | 28 | } DisasContext; |
596 | 29 | ||
597 | @@ -XXX,XX +XXX,XX @@ static void decode_RV32_64C(DisasContext *ctx, uint16_t opcode) | 30 | -#ifdef TARGET_RISCV64 |
598 | } | 31 | -/* convert riscv funct3 to qemu memop for load/store */ |
32 | -static const int tcg_memop_lookup[8] = { | ||
33 | - [0 ... 7] = -1, | ||
34 | - [0] = MO_SB, | ||
35 | - [1] = MO_TESW, | ||
36 | - [2] = MO_TESL, | ||
37 | - [3] = MO_TEQ, | ||
38 | - [4] = MO_UB, | ||
39 | - [5] = MO_TEUW, | ||
40 | - [6] = MO_TEUL, | ||
41 | -}; | ||
42 | -#endif | ||
43 | - | ||
44 | #ifdef TARGET_RISCV64 | ||
45 | #define CASE_OP_32_64(X) case X: case glue(X, W) | ||
46 | #else | ||
47 | @@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) | ||
48 | ctx->base.is_jmp = DISAS_NORETURN; | ||
599 | } | 49 | } |
600 | 50 | ||
601 | +static int ex_plus_1(DisasContext *ctx, int nf) | 51 | -#ifdef TARGET_RISCV64 |
602 | +{ | 52 | -static void gen_load_c(DisasContext *ctx, uint32_t opc, int rd, int rs1, |
603 | + return nf + 1; | 53 | - target_long imm) |
604 | +} | 54 | -{ |
605 | + | 55 | - TCGv t0 = tcg_temp_new(); |
606 | #define EX_SH(amount) \ | 56 | - TCGv t1 = tcg_temp_new(); |
607 | static int ex_shift_##amount(DisasContext *ctx, int imm) \ | 57 | - gen_get_gpr(t0, rs1); |
608 | { \ | 58 | - tcg_gen_addi_tl(t0, t0, imm); |
609 | @@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 59 | - int memop = tcg_memop_lookup[(opc >> 12) & 0x7]; |
610 | ctx->vill = FIELD_EX32(tb_flags, TB_FLAGS, VILL); | 60 | - |
611 | ctx->sew = FIELD_EX32(tb_flags, TB_FLAGS, SEW); | 61 | - if (memop < 0) { |
612 | ctx->lmul = FIELD_EX32(tb_flags, TB_FLAGS, LMUL); | 62 | - gen_exception_illegal(ctx); |
613 | + ctx->mlen = 1 << (ctx->sew + 3 - ctx->lmul); | 63 | - return; |
614 | ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); | 64 | - } |
65 | - | ||
66 | - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, memop); | ||
67 | - gen_set_gpr(rd, t1); | ||
68 | - tcg_temp_free(t0); | ||
69 | - tcg_temp_free(t1); | ||
70 | -} | ||
71 | - | ||
72 | -static void gen_store_c(DisasContext *ctx, uint32_t opc, int rs1, int rs2, | ||
73 | - target_long imm) | ||
74 | -{ | ||
75 | - TCGv t0 = tcg_temp_new(); | ||
76 | - TCGv dat = tcg_temp_new(); | ||
77 | - gen_get_gpr(t0, rs1); | ||
78 | - tcg_gen_addi_tl(t0, t0, imm); | ||
79 | - gen_get_gpr(dat, rs2); | ||
80 | - int memop = tcg_memop_lookup[(opc >> 12) & 0x7]; | ||
81 | - | ||
82 | - if (memop < 0) { | ||
83 | - gen_exception_illegal(ctx); | ||
84 | - return; | ||
85 | - } | ||
86 | - | ||
87 | - tcg_gen_qemu_st_tl(dat, t0, ctx->mem_idx, memop); | ||
88 | - tcg_temp_free(t0); | ||
89 | - tcg_temp_free(dat); | ||
90 | -} | ||
91 | -#endif | ||
92 | - | ||
93 | #ifndef CONFIG_USER_ONLY | ||
94 | /* The states of mstatus_fs are: | ||
95 | * 0 = disabled, 1 = initial, 2 = clean, 3 = dirty | ||
96 | @@ -XXX,XX +XXX,XX @@ static void mark_fs_dirty(DisasContext *ctx) | ||
97 | static inline void mark_fs_dirty(DisasContext *ctx) { } | ||
98 | #endif | ||
99 | |||
100 | -#if !defined(TARGET_RISCV64) | ||
101 | -static void gen_fp_load(DisasContext *ctx, uint32_t opc, int rd, | ||
102 | - int rs1, target_long imm) | ||
103 | -{ | ||
104 | - TCGv t0; | ||
105 | - | ||
106 | - if (ctx->mstatus_fs == 0) { | ||
107 | - gen_exception_illegal(ctx); | ||
108 | - return; | ||
109 | - } | ||
110 | - | ||
111 | - t0 = tcg_temp_new(); | ||
112 | - gen_get_gpr(t0, rs1); | ||
113 | - tcg_gen_addi_tl(t0, t0, imm); | ||
114 | - | ||
115 | - switch (opc) { | ||
116 | - case OPC_RISC_FLW: | ||
117 | - if (!has_ext(ctx, RVF)) { | ||
118 | - goto do_illegal; | ||
119 | - } | ||
120 | - tcg_gen_qemu_ld_i64(cpu_fpr[rd], t0, ctx->mem_idx, MO_TEUL); | ||
121 | - /* RISC-V requires NaN-boxing of narrower width floating point values */ | ||
122 | - tcg_gen_ori_i64(cpu_fpr[rd], cpu_fpr[rd], 0xffffffff00000000ULL); | ||
123 | - break; | ||
124 | - case OPC_RISC_FLD: | ||
125 | - if (!has_ext(ctx, RVD)) { | ||
126 | - goto do_illegal; | ||
127 | - } | ||
128 | - tcg_gen_qemu_ld_i64(cpu_fpr[rd], t0, ctx->mem_idx, MO_TEQ); | ||
129 | - break; | ||
130 | - do_illegal: | ||
131 | - default: | ||
132 | - gen_exception_illegal(ctx); | ||
133 | - break; | ||
134 | - } | ||
135 | - tcg_temp_free(t0); | ||
136 | - | ||
137 | - mark_fs_dirty(ctx); | ||
138 | -} | ||
139 | - | ||
140 | -static void gen_fp_store(DisasContext *ctx, uint32_t opc, int rs1, | ||
141 | - int rs2, target_long imm) | ||
142 | -{ | ||
143 | - TCGv t0; | ||
144 | - | ||
145 | - if (ctx->mstatus_fs == 0) { | ||
146 | - gen_exception_illegal(ctx); | ||
147 | - return; | ||
148 | - } | ||
149 | - | ||
150 | - t0 = tcg_temp_new(); | ||
151 | - gen_get_gpr(t0, rs1); | ||
152 | - tcg_gen_addi_tl(t0, t0, imm); | ||
153 | - | ||
154 | - switch (opc) { | ||
155 | - case OPC_RISC_FSW: | ||
156 | - if (!has_ext(ctx, RVF)) { | ||
157 | - goto do_illegal; | ||
158 | - } | ||
159 | - tcg_gen_qemu_st_i64(cpu_fpr[rs2], t0, ctx->mem_idx, MO_TEUL); | ||
160 | - break; | ||
161 | - case OPC_RISC_FSD: | ||
162 | - if (!has_ext(ctx, RVD)) { | ||
163 | - goto do_illegal; | ||
164 | - } | ||
165 | - tcg_gen_qemu_st_i64(cpu_fpr[rs2], t0, ctx->mem_idx, MO_TEQ); | ||
166 | - break; | ||
167 | - do_illegal: | ||
168 | - default: | ||
169 | - gen_exception_illegal(ctx); | ||
170 | - break; | ||
171 | - } | ||
172 | - | ||
173 | - tcg_temp_free(t0); | ||
174 | -} | ||
175 | -#endif | ||
176 | - | ||
177 | static void gen_set_rm(DisasContext *ctx, int rm) | ||
178 | { | ||
179 | TCGv_i32 t0; | ||
180 | @@ -XXX,XX +XXX,XX @@ static void gen_set_rm(DisasContext *ctx, int rm) | ||
181 | tcg_temp_free_i32(t0); | ||
615 | } | 182 | } |
616 | 183 | ||
617 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | 184 | -static void decode_RV32_64C0(DisasContext *ctx, uint16_t opcode) |
618 | index XXXXXXX..XXXXXXX 100644 | 185 | -{ |
619 | --- a/target/riscv/vector_helper.c | 186 | - uint8_t funct3 = extract16(opcode, 13, 3); |
620 | +++ b/target/riscv/vector_helper.c | 187 | - uint8_t rd_rs2 = GET_C_RS2S(opcode); |
621 | @@ -XXX,XX +XXX,XX @@ | 188 | - uint8_t rs1s = GET_C_RS1S(opcode); |
622 | 189 | - | |
623 | #include "qemu/osdep.h" | 190 | - switch (funct3) { |
624 | #include "cpu.h" | 191 | - case 3: |
625 | +#include "exec/memop.h" | 192 | -#if defined(TARGET_RISCV64) |
626 | #include "exec/exec-all.h" | 193 | - /* C.LD(RV64/128) -> ld rd', offset[7:3](rs1')*/ |
627 | #include "exec/helper-proto.h" | 194 | - gen_load_c(ctx, OPC_RISC_LD, rd_rs2, rs1s, |
628 | +#include "tcg/tcg-gvec-desc.h" | 195 | - GET_C_LD_IMM(opcode)); |
629 | +#include "internals.h" | 196 | -#else |
630 | #include <math.h> | 197 | - /* C.FLW (RV32) -> flw rd', offset[6:2](rs1')*/ |
631 | 198 | - gen_fp_load(ctx, OPC_RISC_FLW, rd_rs2, rs1s, | |
632 | target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, | 199 | - GET_C_LW_IMM(opcode)); |
633 | @@ -XXX,XX +XXX,XX @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, | 200 | -#endif |
634 | env->vstart = 0; | 201 | - break; |
635 | return vl; | 202 | - case 7: |
636 | } | 203 | -#if defined(TARGET_RISCV64) |
637 | + | 204 | - /* C.SD (RV64/128) -> sd rs2', offset[7:3](rs1')*/ |
638 | +/* | 205 | - gen_store_c(ctx, OPC_RISC_SD, rs1s, rd_rs2, |
639 | + * Note that vector data is stored in host-endian 64-bit chunks, | 206 | - GET_C_LD_IMM(opcode)); |
640 | + * so addressing units smaller than that needs a host-endian fixup. | 207 | -#else |
641 | + */ | 208 | - /* C.FSW (RV32) -> fsw rs2', offset[6:2](rs1')*/ |
642 | +#ifdef HOST_WORDS_BIGENDIAN | 209 | - gen_fp_store(ctx, OPC_RISC_FSW, rs1s, rd_rs2, |
643 | +#define H1(x) ((x) ^ 7) | 210 | - GET_C_LW_IMM(opcode)); |
644 | +#define H1_2(x) ((x) ^ 6) | 211 | -#endif |
645 | +#define H1_4(x) ((x) ^ 4) | 212 | - break; |
646 | +#define H2(x) ((x) ^ 3) | 213 | - } |
647 | +#define H4(x) ((x) ^ 1) | 214 | -} |
648 | +#define H8(x) ((x)) | 215 | - |
649 | +#else | 216 | -static void decode_RV32_64C(DisasContext *ctx, uint16_t opcode) |
650 | +#define H1(x) (x) | 217 | -{ |
651 | +#define H1_2(x) (x) | 218 | - uint8_t op = extract16(opcode, 0, 2); |
652 | +#define H1_4(x) (x) | 219 | - |
653 | +#define H2(x) (x) | 220 | - switch (op) { |
654 | +#define H4(x) (x) | 221 | - case 0: |
655 | +#define H8(x) (x) | 222 | - decode_RV32_64C0(ctx, opcode); |
656 | +#endif | 223 | - break; |
657 | + | 224 | - } |
658 | +static inline uint32_t vext_nf(uint32_t desc) | 225 | -} |
659 | +{ | 226 | - |
660 | + return FIELD_EX32(simd_data(desc), VDATA, NF); | 227 | static int ex_plus_1(DisasContext *ctx, int nf) |
661 | +} | 228 | { |
662 | + | 229 | return nf + 1; |
663 | +static inline uint32_t vext_mlen(uint32_t desc) | 230 | @@ -XXX,XX +XXX,XX @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) |
664 | +{ | 231 | } else { |
665 | + return FIELD_EX32(simd_data(desc), VDATA, MLEN); | 232 | ctx->pc_succ_insn = ctx->base.pc_next + 2; |
666 | +} | 233 | if (!decode_insn16(ctx, opcode)) { |
667 | + | 234 | - /* fall back to old decoder */ |
668 | +static inline uint32_t vext_vm(uint32_t desc) | 235 | - decode_RV32_64C(ctx, opcode); |
669 | +{ | 236 | + gen_exception_illegal(ctx); |
670 | + return FIELD_EX32(simd_data(desc), VDATA, VM); | 237 | } |
671 | +} | 238 | } |
672 | + | 239 | } else { |
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 | -- | 240 | -- |
1045 | 2.27.0 | 241 | 2.30.1 |
1046 | 242 | ||
1047 | 243 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | Vector indexed operations add the contents of each element of the | ||
4 | vector offset operand specified by vs2 to the base effective address | ||
5 | to give the effective address of each element. | ||
6 | |||
7 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20200623215920.2594-8-zhiwei_liu@c-sky.com | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | --- | ||
13 | target/riscv/helper.h | 35 +++++++ | ||
14 | target/riscv/insn32.decode | 13 +++ | ||
15 | target/riscv/insn_trans/trans_rvv.inc.c | 129 ++++++++++++++++++++++++ | ||
16 | target/riscv/vector_helper.c | 116 +++++++++++++++++++++ | ||
17 | 4 files changed, 293 insertions(+) | ||
18 | |||
19 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/riscv/helper.h | ||
22 | +++ b/target/riscv/helper.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vsse_v_b, void, ptr, ptr, tl, tl, env, i32) | ||
24 | DEF_HELPER_6(vsse_v_h, void, ptr, ptr, tl, tl, env, i32) | ||
25 | DEF_HELPER_6(vsse_v_w, void, ptr, ptr, tl, tl, env, i32) | ||
26 | DEF_HELPER_6(vsse_v_d, void, ptr, ptr, tl, tl, env, i32) | ||
27 | +DEF_HELPER_6(vlxb_v_b, void, ptr, ptr, tl, ptr, env, i32) | ||
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 | + | ||
83 | # *** new major opcode OP-V *** | ||
84 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
85 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
86 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
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 | + } | ||
159 | + | ||
160 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
161 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
162 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
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 | -- | ||
348 | 2.27.0 | ||
349 | |||
350 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
2 | 1 | ||
3 | The unit-stride fault-only-fault load instructions are used to | ||
4 | vectorize loops with data-dependent exit conditions(while loops). | ||
5 | These instructions execute as a regular load except that they | ||
6 | will only take a trap on element 0. | ||
7 | |||
8 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20200623215920.2594-9-zhiwei_liu@c-sky.com | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | --- | ||
14 | target/riscv/helper.h | 22 +++++ | ||
15 | target/riscv/insn32.decode | 7 ++ | ||
16 | target/riscv/insn_trans/trans_rvv.inc.c | 73 ++++++++++++++++ | ||
17 | target/riscv/vector_helper.c | 110 ++++++++++++++++++++++++ | ||
18 | 4 files changed, 212 insertions(+) | ||
19 | |||
20 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/riscv/helper.h | ||
23 | +++ b/target/riscv/helper.h | ||
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vsxe_v_b, void, ptr, ptr, tl, ptr, env, i32) | ||
25 | DEF_HELPER_6(vsxe_v_h, void, ptr, ptr, tl, ptr, env, i32) | ||
26 | DEF_HELPER_6(vsxe_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
27 | DEF_HELPER_6(vsxe_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
28 | +DEF_HELPER_5(vlbff_v_b, void, ptr, ptr, tl, env, i32) | ||
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 | +{ | ||
83 | + TCGv_ptr dest, mask; | ||
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; | ||
133 | + } | ||
134 | + | ||
135 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); | ||
136 | + data = FIELD_DP32(data, VDATA, VM, a->vm); | ||
137 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); | ||
138 | + data = FIELD_DP32(data, VDATA, NF, a->nf); | ||
139 | + return ldff_trans(a->rd, a->rs1, data, fn, s); | ||
140 | +} | ||
141 | + | ||
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 | + } | ||
235 | +} | ||
236 | + | ||
237 | +#define GEN_VEXT_LDFF(NAME, MTYPE, ETYPE, LOAD_FN, CLEAR_FN) \ | ||
238 | +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ | ||
239 | + CPURISCVState *env, uint32_t desc) \ | ||
240 | +{ \ | ||
241 | + vext_ldff(vd, v0, base, env, desc, LOAD_FN, CLEAR_FN, \ | ||
242 | + sizeof(ETYPE), sizeof(MTYPE), GETPC()); \ | ||
243 | +} | ||
244 | + | ||
245 | +GEN_VEXT_LDFF(vlbff_v_b, int8_t, int8_t, ldb_b, clearb) | ||
246 | +GEN_VEXT_LDFF(vlbff_v_h, int8_t, int16_t, ldb_h, clearh) | ||
247 | +GEN_VEXT_LDFF(vlbff_v_w, int8_t, int32_t, ldb_w, clearl) | ||
248 | +GEN_VEXT_LDFF(vlbff_v_d, int8_t, int64_t, ldb_d, clearq) | ||
249 | +GEN_VEXT_LDFF(vlhff_v_h, int16_t, int16_t, ldh_h, clearh) | ||
250 | +GEN_VEXT_LDFF(vlhff_v_w, int16_t, int32_t, ldh_w, clearl) | ||
251 | +GEN_VEXT_LDFF(vlhff_v_d, int16_t, int64_t, ldh_d, clearq) | ||
252 | +GEN_VEXT_LDFF(vlwff_v_w, int32_t, int32_t, ldw_w, clearl) | ||
253 | +GEN_VEXT_LDFF(vlwff_v_d, int32_t, int64_t, ldw_d, clearq) | ||
254 | +GEN_VEXT_LDFF(vleff_v_b, int8_t, int8_t, lde_b, clearb) | ||
255 | +GEN_VEXT_LDFF(vleff_v_h, int16_t, int16_t, lde_h, clearh) | ||
256 | +GEN_VEXT_LDFF(vleff_v_w, int32_t, int32_t, lde_w, clearl) | ||
257 | +GEN_VEXT_LDFF(vleff_v_d, int64_t, int64_t, lde_d, clearq) | ||
258 | +GEN_VEXT_LDFF(vlbuff_v_b, uint8_t, uint8_t, ldbu_b, clearb) | ||
259 | +GEN_VEXT_LDFF(vlbuff_v_h, uint8_t, uint16_t, ldbu_h, clearh) | ||
260 | +GEN_VEXT_LDFF(vlbuff_v_w, uint8_t, uint32_t, ldbu_w, clearl) | ||
261 | +GEN_VEXT_LDFF(vlbuff_v_d, uint8_t, uint64_t, ldbu_d, clearq) | ||
262 | +GEN_VEXT_LDFF(vlhuff_v_h, uint16_t, uint16_t, ldhu_h, clearh) | ||
263 | +GEN_VEXT_LDFF(vlhuff_v_w, uint16_t, uint32_t, ldhu_w, clearl) | ||
264 | +GEN_VEXT_LDFF(vlhuff_v_d, uint16_t, uint64_t, ldhu_d, clearq) | ||
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 | -- | ||
268 | 2.27.0 | ||
269 | |||
270 | 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-11-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 | 10 + | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 291 ++++++++++++++++++++++++ | ||
12 | target/riscv/vector_helper.c | 183 +++++++++++++++ | ||
13 | 4 files changed, 509 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(vamominw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
20 | DEF_HELPER_6(vamomaxw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
21 | DEF_HELPER_6(vamominuw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
22 | DEF_HELPER_6(vamomaxuw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
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 | ||
50 | --- a/target/riscv/insn32.decode | ||
51 | +++ b/target/riscv/insn32.decode | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | &u imm rd | ||
54 | &shift shamt rs1 rd | ||
55 | &atomic aq rl rs2 rs1 rd | ||
56 | +&rmrr vm rd rs1 rs2 | ||
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 | +{ | ||
98 | + return (vext_check_isa_ill(s) && | ||
99 | + vext_check_overlap_mask(s, a->rd, a->vm, false) && | ||
100 | + vext_check_reg(s, a->rd, false) && | ||
101 | + vext_check_reg(s, a->rs2, false) && | ||
102 | + vext_check_reg(s, a->rs1, false)); | ||
103 | +} | ||
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 | + } | ||
541 | +} | ||
542 | + | ||
543 | +void HELPER(vec_rsubs16)(void *d, void *a, uint64_t b, uint32_t desc) | ||
544 | +{ | ||
545 | + intptr_t oprsz = simd_oprsz(desc); | ||
546 | + intptr_t i; | ||
547 | + | ||
548 | + for (i = 0; i < oprsz; i += sizeof(uint16_t)) { | ||
549 | + *(uint16_t *)(d + i) = (uint16_t)b - *(uint16_t *)(a + i); | ||
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 | +} | ||
572 | -- | ||
573 | 2.27.0 | ||
574 | |||
575 | 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: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-25-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 | 10 + | ||
11 | target/riscv/insn_trans/trans_rvv.inc.c | 16 + | ||
12 | target/riscv/vector_helper.c | 385 ++++++++++++++++++++++++ | ||
13 | 4 files changed, 444 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_4(vmv_v_x_b, void, ptr, i64, env, i32) | ||
20 | DEF_HELPER_4(vmv_v_x_h, void, ptr, i64, env, i32) | ||
21 | DEF_HELPER_4(vmv_v_x_w, void, ptr, i64, env, i32) | ||
22 | DEF_HELPER_4(vmv_v_x_d, void, ptr, i64, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vsaddu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vsaddu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vsaddu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vsaddu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
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 | ||
58 | --- a/target/riscv/insn32.decode | ||
59 | +++ b/target/riscv/insn32.decode | ||
60 | @@ -XXX,XX +XXX,XX @@ vmv_v_i 010111 1 00000 ..... 011 ..... 1010111 @r2 | ||
61 | vmerge_vvm 010111 0 ..... ..... 000 ..... 1010111 @r_vm_0 | ||
62 | vmerge_vxm 010111 0 ..... ..... 100 ..... 1010111 @r_vm_0 | ||
63 | vmerge_vim 010111 0 ..... ..... 011 ..... 1010111 @r_vm_0 | ||
64 | +vsaddu_vv 100000 . ..... ..... 000 ..... 1010111 @r_vm | ||
65 | +vsaddu_vx 100000 . ..... ..... 100 ..... 1010111 @r_vm | ||
66 | +vsaddu_vi 100000 . ..... ..... 011 ..... 1010111 @r_vm | ||
67 | +vsadd_vv 100001 . ..... ..... 000 ..... 1010111 @r_vm | ||
68 | +vsadd_vx 100001 . ..... ..... 100 ..... 1010111 @r_vm | ||
69 | +vsadd_vi 100001 . ..... ..... 011 ..... 1010111 @r_vm | ||
70 | +vssubu_vv 100010 . ..... ..... 000 ..... 1010111 @r_vm | ||
71 | +vssubu_vx 100010 . ..... ..... 100 ..... 1010111 @r_vm | ||
72 | +vssub_vv 100011 . ..... ..... 000 ..... 1010111 @r_vm | ||
73 | +vssub_vx 100011 . ..... ..... 100 ..... 1010111 @r_vm | ||
74 | |||
75 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
76 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
77 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
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 | +} | ||
132 | + | ||
133 | +static inline void | ||
134 | +vext_vv_rm_1(void *vd, void *v0, void *vs1, void *vs2, | ||
135 | + CPURISCVState *env, | ||
136 | + uint32_t vl, uint32_t vm, uint32_t mlen, int vxrm, | ||
137 | + opivv2_rm_fn *fn) | ||
138 | +{ | ||
139 | + for (uint32_t i = 0; i < vl; i++) { | ||
140 | + if (!vm && !vext_elem_mask(v0, mlen, i)) { | ||
141 | + continue; | ||
142 | + } | ||
143 | + fn(vd, vs1, vs2, i, env, vxrm); | ||
144 | + } | ||
145 | +} | ||
146 | + | ||
147 | +static inline void | ||
148 | +vext_vv_rm_2(void *vd, void *v0, void *vs1, void *vs2, | ||
149 | + CPURISCVState *env, | ||
150 | + uint32_t desc, uint32_t esz, uint32_t dsz, | ||
151 | + opivv2_rm_fn *fn, clear_fn *clearfn) | ||
152 | +{ | ||
153 | + uint32_t vlmax = vext_maxsz(desc) / esz; | ||
154 | + uint32_t mlen = vext_mlen(desc); | ||
155 | + uint32_t vm = vext_vm(desc); | ||
156 | + uint32_t vl = env->vl; | ||
157 | + | ||
158 | + switch (env->vxrm) { | ||
159 | + case 0: /* rnu */ | ||
160 | + vext_vv_rm_1(vd, v0, vs1, vs2, | ||
161 | + env, vl, vm, mlen, 0, fn); | ||
162 | + break; | ||
163 | + case 1: /* rne */ | ||
164 | + vext_vv_rm_1(vd, v0, vs1, vs2, | ||
165 | + env, vl, vm, mlen, 1, fn); | ||
166 | + break; | ||
167 | + case 2: /* rdn */ | ||
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; | ||
175 | + } | ||
176 | + | ||
177 | + clearfn(vd, vl, vl * dsz, vlmax * dsz); | ||
178 | +} | ||
179 | + | ||
180 | +/* generate helpers for fixed point instructions with OPIVV format */ | ||
181 | +#define GEN_VEXT_VV_RM(NAME, ESZ, DSZ, CLEAR_FN) \ | ||
182 | +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
183 | + CPURISCVState *env, uint32_t desc) \ | ||
184 | +{ \ | ||
185 | + vext_vv_rm_2(vd, v0, vs1, vs2, env, desc, ESZ, DSZ, \ | ||
186 | + do_##NAME, CLEAR_FN); \ | ||
187 | +} | ||
188 | + | ||
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; | ||
283 | + case 1: /* rne */ | ||
284 | + vext_vx_rm_1(vd, v0, s1, vs2, | ||
285 | + env, vl, vm, mlen, 1, fn); | ||
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 | -- | ||
495 | 2.27.0 | ||
496 | |||
497 | 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-38-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 | 27 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 50 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(vfwnmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
20 | DEF_HELPER_5(vfsqrt_v_h, void, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_5(vfsqrt_v_w, void, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_5(vfsqrt_v_d, void, ptr, ptr, ptr, env, i32) | ||
23 | + | ||
24 | +DEF_HELPER_6(vfmin_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vfmin_vv_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vfmin_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vfmax_vv_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
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 | } | ||
57 | |||
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 | -- | ||
101 | 2.27.0 | ||
102 | |||
103 | 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: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-id: 20200623215920.2594-41-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/internals.h | 5 ++ | ||
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 | |||
17 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/riscv/helper.h | ||
20 | +++ b/target/riscv/helper.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmford_vv_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
22 | DEF_HELPER_6(vmford_vf_h, void, ptr, ptr, i64, ptr, env, i32) | ||
23 | DEF_HELPER_6(vmford_vf_w, void, ptr, ptr, i64, ptr, env, i32) | ||
24 | DEF_HELPER_6(vmford_vf_d, void, ptr, ptr, i64, ptr, env, i32) | ||
25 | + | ||
26 | +DEF_HELPER_5(vfclass_v_h, void, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_5(vfclass_v_w, void, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_5(vfclass_v_d, void, ptr, ptr, ptr, env, i32) | ||
29 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/riscv/internals.h | ||
32 | +++ b/target/riscv/internals.h | ||
33 | @@ -XXX,XX +XXX,XX @@ FIELD(VDATA, VM, 8, 1) | ||
34 | FIELD(VDATA, LMUL, 9, 2) | ||
35 | FIELD(VDATA, NF, 11, 4) | ||
36 | FIELD(VDATA, WD, 11, 1) | ||
37 | + | ||
38 | +/* float point classify helpers */ | ||
39 | +target_ulong fclass_h(uint64_t frs1); | ||
40 | +target_ulong fclass_s(uint64_t frs1); | ||
41 | +target_ulong fclass_d(uint64_t frs1); | ||
42 | #endif | ||
43 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/riscv/insn32.decode | ||
46 | +++ b/target/riscv/insn32.decode | ||
47 | @@ -XXX,XX +XXX,XX @@ vmfgt_vf 011101 . ..... ..... 101 ..... 1010111 @r_vm | ||
48 | vmfge_vf 011111 . ..... ..... 101 ..... 1010111 @r_vm | ||
49 | vmford_vv 011010 . ..... ..... 001 ..... 1010111 @r_vm | ||
50 | vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm | ||
51 | +vfclass_v 100011 . ..... 10000 001 ..... 1010111 @r2_vm | ||
52 | |||
53 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
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 | { | ||
67 | @@ -XXX,XX +XXX,XX @@ uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t rs1) | ||
68 | |||
69 | target_ulong helper_fclass_s(uint64_t frs1) | ||
70 | { | ||
71 | - float32 f = frs1; | ||
72 | - bool sign = float32_is_neg(f); | ||
73 | - | ||
74 | - if (float32_is_infinity(f)) { | ||
75 | - return sign ? 1 << 0 : 1 << 7; | ||
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 | } | ||
88 | |||
89 | uint64_t helper_fadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) | ||
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 | { | ||
94 | - float64 f = frs1; | ||
95 | - bool sign = float64_is_neg(f); | ||
96 | - | ||
97 | - if (float64_is_infinity(f)) { | ||
98 | - return sign ? 1 << 0 : 1 << 7; | ||
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 | } | ||
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 @@ GEN_OPFVF_TRANS(vmfle_vf, opfvf_cmp_check) | ||
116 | GEN_OPFVF_TRANS(vmfgt_vf, opfvf_cmp_check) | ||
117 | GEN_OPFVF_TRANS(vmfge_vf, opfvf_cmp_check) | ||
118 | GEN_OPFVF_TRANS(vmford_vf, opfvf_cmp_check) | ||
119 | + | ||
120 | +/* Vector Floating-Point Classify Instruction */ | ||
121 | +GEN_OPFV_TRANS(vfclass_v, opfv_check) | ||
122 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
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 | -- | ||
222 | 2.27.0 | ||
223 | |||
224 | 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 |
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 | Message-id: 20200623215920.2594-50-zhiwei_liu@c-sky.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | --- | ||
8 | target/riscv/helper.h | 9 ++++++ | ||
9 | target/riscv/insn32.decode | 8 +++++ | ||
10 | target/riscv/insn_trans/trans_rvv.inc.c | 35 ++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 40 +++++++++++++++++++++++++ | ||
12 | 4 files changed, 92 insertions(+) | ||
13 | |||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/riscv/helper.h | ||
17 | +++ b/target/riscv/helper.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfredmin_vs_d, void, ptr, ptr, ptr, ptr, env, i32) | ||
19 | |||
20 | DEF_HELPER_6(vfwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_6(vfwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) | ||
22 | + | ||
23 | +DEF_HELPER_6(vmand_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
24 | +DEF_HELPER_6(vmnand_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_6(vmandnot_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_6(vmxor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
27 | +DEF_HELPER_6(vmor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
28 | +DEF_HELPER_6(vmnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
29 | +DEF_HELPER_6(vmornot_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
30 | +DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, 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 @@ vfredmin_vs 000101 . ..... ..... 001 ..... 1010111 @r_vm | ||
36 | vfredmax_vs 000111 . ..... ..... 001 ..... 1010111 @r_vm | ||
37 | # Vector widening ordered and unordered float reduction sum | ||
38 | vfwredsum_vs 1100-1 . ..... ..... 001 ..... 1010111 @r_vm | ||
39 | +vmand_mm 011001 - ..... ..... 010 ..... 1010111 @r | ||
40 | +vmnand_mm 011101 - ..... ..... 010 ..... 1010111 @r | ||
41 | +vmandnot_mm 011000 - ..... ..... 010 ..... 1010111 @r | ||
42 | +vmxor_mm 011011 - ..... ..... 010 ..... 1010111 @r | ||
43 | +vmor_mm 011010 - ..... ..... 010 ..... 1010111 @r | ||
44 | +vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r | ||
45 | +vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | ||
46 | +vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | ||
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_OPFVV_TRANS(vfredmin_vs, reduction_check) | ||
55 | |||
56 | /* Vector Widening Floating-Point Reduction Instructions */ | ||
57 | GEN_OPFVV_WIDEN_TRANS(vfwredsum_vs, reduction_check) | ||
58 | + | ||
59 | +/* | ||
60 | + *** Vector Mask Operations | ||
61 | + */ | ||
62 | + | ||
63 | +/* Vector Mask-Register Logical Instructions */ | ||
64 | +#define GEN_MM_TRANS(NAME) \ | ||
65 | +static bool trans_##NAME(DisasContext *s, arg_r *a) \ | ||
66 | +{ \ | ||
67 | + if (vext_check_isa_ill(s)) { \ | ||
68 | + uint32_t data = 0; \ | ||
69 | + gen_helper_gvec_4_ptr *fn = gen_helper_##NAME; \ | ||
70 | + TCGLabel *over = gen_new_label(); \ | ||
71 | + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ | ||
72 | + \ | ||
73 | + data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \ | ||
74 | + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ | ||
75 | + tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ | ||
76 | + vreg_ofs(s, a->rs1), \ | ||
77 | + vreg_ofs(s, a->rs2), cpu_env, 0, \ | ||
78 | + s->vlen / 8, data, fn); \ | ||
79 | + gen_set_label(over); \ | ||
80 | + return true; \ | ||
81 | + } \ | ||
82 | + return false; \ | ||
83 | +} | ||
84 | + | ||
85 | +GEN_MM_TRANS(vmand_mm) | ||
86 | +GEN_MM_TRANS(vmnand_mm) | ||
87 | +GEN_MM_TRANS(vmandnot_mm) | ||
88 | +GEN_MM_TRANS(vmxor_mm) | ||
89 | +GEN_MM_TRANS(vmor_mm) | ||
90 | +GEN_MM_TRANS(vmnor_mm) | ||
91 | +GEN_MM_TRANS(vmornot_mm) | ||
92 | +GEN_MM_TRANS(vmxnor_mm) | ||
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 @@ 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 | -- | ||
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 | Message-id: 20200623215920.2594-51-zhiwei_liu@c-sky.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | --- | ||
8 | target/riscv/helper.h | 2 ++ | ||
9 | target/riscv/insn32.decode | 1 + | ||
10 | target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 20 ++++++++++++++++ | ||
12 | 4 files changed, 55 insertions(+) | ||
13 | |||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/riscv/helper.h | ||
17 | +++ b/target/riscv/helper.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
19 | DEF_HELPER_6(vmnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_6(vmornot_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
22 | + | ||
23 | +DEF_HELPER_4(vmpopc_m, tl, ptr, ptr, env, i32) | ||
24 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/riscv/insn32.decode | ||
27 | +++ b/target/riscv/insn32.decode | ||
28 | @@ -XXX,XX +XXX,XX @@ vmor_mm 011010 - ..... ..... 010 ..... 1010111 @r | ||
29 | vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r | ||
30 | vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | ||
31 | vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | ||
32 | +vmpopc_m 010100 . ..... ----- 010 ..... 1010111 @r2_vm | ||
33 | |||
34 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
35 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
36 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
39 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
40 | @@ -XXX,XX +XXX,XX @@ GEN_MM_TRANS(vmor_mm) | ||
41 | GEN_MM_TRANS(vmnor_mm) | ||
42 | GEN_MM_TRANS(vmornot_mm) | ||
43 | GEN_MM_TRANS(vmxnor_mm) | ||
44 | + | ||
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 | -- | ||
105 | 2.27.0 | ||
106 | |||
107 | 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 | Message-id: 20200623215920.2594-52-zhiwei_liu@c-sky.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | --- | ||
8 | target/riscv/helper.h | 2 ++ | ||
9 | target/riscv/insn32.decode | 1 + | ||
10 | target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 19 +++++++++++++++ | ||
12 | 4 files changed, 54 insertions(+) | ||
13 | |||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/riscv/helper.h | ||
17 | +++ b/target/riscv/helper.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmornot_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
19 | DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
20 | |||
21 | DEF_HELPER_4(vmpopc_m, tl, ptr, ptr, env, i32) | ||
22 | + | ||
23 | +DEF_HELPER_4(vmfirst_m, tl, ptr, ptr, env, i32) | ||
24 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/riscv/insn32.decode | ||
27 | +++ b/target/riscv/insn32.decode | ||
28 | @@ -XXX,XX +XXX,XX @@ vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r | ||
29 | vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | ||
30 | vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | ||
31 | vmpopc_m 010100 . ..... ----- 010 ..... 1010111 @r2_vm | ||
32 | +vmfirst_m 010101 . ..... ----- 010 ..... 1010111 @r2_vm | ||
33 | |||
34 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
35 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
36 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
39 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool trans_vmpopc_m(DisasContext *s, arg_rmr *a) | ||
41 | } | ||
42 | return false; | ||
43 | } | ||
44 | + | ||
45 | +/* vmfirst find-first-set mask bit */ | ||
46 | +static bool trans_vmfirst_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_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 | -- | ||
104 | 2.27.0 | ||
105 | |||
106 | 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 | Message-id: 20200623215920.2594-53-zhiwei_liu@c-sky.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | --- | ||
8 | target/riscv/helper.h | 4 ++ | ||
9 | target/riscv/insn32.decode | 3 ++ | ||
10 | target/riscv/insn_trans/trans_rvv.inc.c | 28 +++++++++++ | ||
11 | target/riscv/vector_helper.c | 63 +++++++++++++++++++++++++ | ||
12 | 4 files changed, 98 insertions(+) | ||
13 | |||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/riscv/helper.h | ||
17 | +++ b/target/riscv/helper.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) | ||
19 | DEF_HELPER_4(vmpopc_m, tl, ptr, ptr, env, i32) | ||
20 | |||
21 | DEF_HELPER_4(vmfirst_m, tl, ptr, ptr, env, i32) | ||
22 | + | ||
23 | +DEF_HELPER_5(vmsbf_m, void, ptr, ptr, ptr, env, i32) | ||
24 | +DEF_HELPER_5(vmsif_m, void, ptr, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_5(vmsof_m, void, 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 @@ vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r | ||
31 | vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r | ||
32 | vmpopc_m 010100 . ..... ----- 010 ..... 1010111 @r2_vm | ||
33 | vmfirst_m 010101 . ..... ----- 010 ..... 1010111 @r2_vm | ||
34 | +vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm | ||
35 | +vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm | ||
36 | +vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | ||
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_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 | +}; | ||
90 | + | ||
91 | +static void vmsetm(void *vd, void *v0, void *vs2, CPURISCVState *env, | ||
92 | + uint32_t desc, enum set_mask_type type) | ||
93 | +{ | ||
94 | + uint32_t mlen = vext_mlen(desc); | ||
95 | + uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; | ||
96 | + uint32_t vm = vext_vm(desc); | ||
97 | + uint32_t vl = env->vl; | ||
98 | + int i; | ||
99 | + bool first_mask_bit = false; | ||
100 | + | ||
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 | + } | ||
128 | +} | ||
129 | + | ||
130 | +void HELPER(vmsbf_m)(void *vd, void *v0, void *vs2, CPURISCVState *env, | ||
131 | + uint32_t desc) | ||
132 | +{ | ||
133 | + vmsetm(vd, v0, vs2, env, desc, BEFORE_FIRST); | ||
134 | +} | ||
135 | + | ||
136 | +void HELPER(vmsif_m)(void *vd, void *v0, void *vs2, CPURISCVState *env, | ||
137 | + uint32_t desc) | ||
138 | +{ | ||
139 | + vmsetm(vd, v0, vs2, env, desc, INCLUDE_FIRST); | ||
140 | +} | ||
141 | + | ||
142 | +void HELPER(vmsof_m)(void *vd, void *v0, void *vs2, CPURISCVState *env, | ||
143 | + uint32_t desc) | ||
144 | +{ | ||
145 | + vmsetm(vd, v0, vs2, env, desc, ONLY_FIRST); | ||
146 | +} | ||
147 | -- | ||
148 | 2.27.0 | ||
149 | |||
150 | 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 | Message-id: 20200623215920.2594-54-zhiwei_liu@c-sky.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | --- | ||
8 | target/riscv/helper.h | 5 +++++ | ||
9 | target/riscv/insn32.decode | 1 + | ||
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 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/riscv/helper.h | ||
17 | +++ b/target/riscv/helper.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vmfirst_m, tl, ptr, ptr, env, i32) | ||
19 | DEF_HELPER_5(vmsbf_m, void, ptr, ptr, ptr, env, i32) | ||
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 | { | ||
80 | vmsetm(vd, v0, vs2, env, desc, ONLY_FIRST); | ||
81 | } | ||
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 | -- | ||
112 | 2.27.0 | ||
113 | |||
114 | 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 | Message-id: 20200623215920.2594-55-zhiwei_liu@c-sky.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | --- | ||
8 | target/riscv/helper.h | 5 +++++ | ||
9 | target/riscv/insn32.decode | 2 ++ | ||
10 | target/riscv/insn_trans/trans_rvv.inc.c | 25 +++++++++++++++++++++++++ | ||
11 | target/riscv/vector_helper.c | 24 ++++++++++++++++++++++++ | ||
12 | 4 files changed, 56 insertions(+) | ||
13 | |||
14 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/riscv/helper.h | ||
17 | +++ b/target/riscv/helper.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(viota_m_b, void, ptr, ptr, ptr, env, i32) | ||
19 | DEF_HELPER_5(viota_m_h, void, ptr, ptr, ptr, env, i32) | ||
20 | DEF_HELPER_5(viota_m_w, void, ptr, ptr, ptr, env, i32) | ||
21 | DEF_HELPER_5(viota_m_d, void, ptr, ptr, ptr, env, i32) | ||
22 | + | ||
23 | +DEF_HELPER_4(vid_v_b, void, ptr, ptr, env, i32) | ||
24 | +DEF_HELPER_4(vid_v_h, void, ptr, ptr, env, i32) | ||
25 | +DEF_HELPER_4(vid_v_w, void, ptr, ptr, env, i32) | ||
26 | +DEF_HELPER_4(vid_v_d, void, 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 | @r2 ....... ..... ..... ... ..... ....... %rs1 %rd | ||
33 | @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd | ||
34 | @r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd | ||
35 | +@r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd | ||
36 | @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd | ||
37 | @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd | ||
38 | @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd | ||
39 | @@ -XXX,XX +XXX,XX @@ vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm | ||
40 | vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm | ||
41 | vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm | ||
42 | viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm | ||
43 | +vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm | ||
44 | |||
45 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
46 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
47 | diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/riscv/insn_trans/trans_rvv.inc.c | ||
50 | +++ b/target/riscv/insn_trans/trans_rvv.inc.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static bool trans_viota_m(DisasContext *s, arg_viota_m *a) | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
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 | -- | ||
113 | 2.27.0 | ||
114 | |||
115 | 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 | Message-id: 20200623215920.2594-57-zhiwei_liu@c-sky.com | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | --- | ||
8 | target/riscv/internals.h | 6 +++ | ||
9 | target/riscv/insn32.decode | 1 + | ||
10 | target/riscv/insn_trans/trans_rvv.inc.c | 60 +++++++++++++++++++++++++ | ||
11 | 3 files changed, 67 insertions(+) | ||
12 | |||
13 | diff --git a/target/riscv/internals.h b/target/riscv/internals.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/riscv/internals.h | ||
16 | +++ b/target/riscv/internals.h | ||
17 | @@ -XXX,XX +XXX,XX @@ FIELD(VDATA, WD, 11, 1) | ||
18 | target_ulong fclass_h(uint64_t frs1); | ||
19 | target_ulong fclass_s(uint64_t frs1); | ||
20 | target_ulong fclass_d(uint64_t frs1); | ||
21 | + | ||
22 | +#define SEW8 0 | ||
23 | +#define SEW16 1 | ||
24 | +#define SEW32 2 | ||
25 | +#define SEW64 3 | ||
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 | -- | ||
109 | 2.27.0 | ||
110 | |||
111 | diff view generated by jsdifflib |