Add RISC-V Zvqdotq extension support
v5 cover Add RISC-V Zvqdotq extension support
This patch series adds Zvqdotq support.
The isa spec of Zvqdotq extension is not ratified yet, so this patch series is based on the latest draft of the spec (v0.0.2) and make the Zvqdotq extension as an experimental extension.
The draft of the Zvqdotq isa spec:
https://github.com/riscv/riscv-dot-product
v5:
* Add disassembler support
* Rebase to riscv-to-apply.next branch
v4:
* Update the PRIV_VERSION (Thanks for Daniel Henrique Barboza's
* suggestion)
v3:
* Fix casting and simplify vs1/vs2 access (Thanks for Richard
* Henderson's
suggestion)
v2:
* Remove unnecessary variable and mask (Thanks for Richard Henderson's suggestion)
Max Chou (4):
target/riscv: Add Zvqdotq cfg property target/riscv: rvv: Add Zvqdotq support target/riscv: Expose Zvqdotq extension as a cpu property disas/riscv: Support the Zvqdotq extension
disas/riscv.c | 21 +++++++ target/riscv/cpu.c | 2 + target/riscv/cpu_cfg_fields.h.inc | 1 + target/riscv/helper.h | 10 +++ target/riscv/insn32.decode | 9 +++ target/riscv/insn_trans/trans_rvzvqdotq.c.inc | 61 +++++++++++++++++++ target/riscv/tcg/tcg-cpu.c | 5 ++ target/riscv/translate.c | 1 + target/riscv/vector_helper.c | 57 +++++++++++++++++ 9 files changed, 167 insertions(+) create mode 100644 target/riscv/insn_trans/trans_rvzvqdotq.c.inc
Signature · 1 line
2.43.7
PATCH v5 1/4 target/riscv: Add Zvqdotq cfg property
The Zvqdotq extension is the vector dot-product extension of RISC-V.
--- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg_fields.h.inc | 1 + target/riscv/tcg/tcg-cpu.c | 5 +++++ 3 files changed, 7 insertions(+)
target/riscv/cpu.c +1 -0
@@ -206,6 +206,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zvksg,PRIV_VERSION_1_12_0 , ext_zvksg),ISA_EXT_DATA_ENTRY (zvksh,PRIV_VERSION_1_12_0 , ext_zvksh),ISA_EXT_DATA_ENTRY (zvkt,PRIV_VERSION_1_12_0 , ext_zvkt), +ISA_EXT_DATA_ENTRY (zvqdotq,PRIV_VERSION_1_13_0 , ext_zvqdotq),ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin,PRIV_VERSION_1_12_0 , ext_zhinxmin), ISA_EXT_DATA_ENTRY(sdtrig, PRIV_VERSION_1_12_0, debug),
target/riscv/cpu_cfg_fields.h.inc +1 -0
@@ -103,6 +103,7 @@ BOOL_FIELD(ext_zvfbfmin) BOOL_FIELD(ext_zvfbfwma) BOOL_FIELD(ext_zvfh) BOOL_FIELD(ext_zvfhmin) +BOOL_FIELD(ext_zvqdotq) BOOL_FIELD(ext_smaia) BOOL_FIELD(ext_ssaia) BOOL_FIELD(ext_smctr)
target/riscv/tcg/tcg-cpu.c +5 -0
@@ -783,6 +783,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)return ; } +if (cpu->cfg.ext_zvqdotq && !cpu->cfg.ext_zve32x) { +error_setg (errp,"Zvqdotq extension requires V or Zve* extensions" ); +return ; + } +if ((cpu->cfg.ext_zvbc || cpu->cfg.ext_zvknhb) && !cpu->cfg.ext_zve64x) { error_setg( errp,
Signature · 1 line
2.43.7
PATCH v5 2/4 target/riscv: rvv: Add Zvqdotq support
In reply to Max ChouSupport instructions for vector dot-product extension (Zvqdotq)
- vqdot.[vv,vx]
- vqdotu.[vv,vx]
- vqdotsu.[vv,vx]
- vqdotus.vx
--- target/riscv/helper.h | 10 +++ target/riscv/insn32.decode | 9 +++ target/riscv/insn_trans/trans_rvzvqdotq.c.inc | 61 +++++++++++++++++++ target/riscv/translate.c | 1 + target/riscv/vector_helper.c | 57 +++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 target/riscv/insn_trans/trans_rvzvqdotq.c.inc
target/riscv/helper.h +10 -0
@@ -1285,6 +1285,16 @@ DEF_HELPER_5(vsm4k_vi, void, ptr, ptr, i32, env, i32) DEF_HELPER_4(vsm4r_vv, void, ptr, ptr, env, i32)DEF_HELPER_4 (vsm4r_vs, void, ptr, ptr, env, i32) +/* Vector dot-product functions */ +DEF_HELPER_6(vqdot_vv, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqdotu_vv, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqdotsu_vv, void, ptr, ptr, ptr, ptr, env, i32) + +DEF_HELPER_6(vqdot_vx, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqdotu_vx, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqdotsu_vx, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6 (vqdotus_vx, void, ptr, ptr, tl, ptr, env, i32) + /* CFI (zicfiss) helpers */#ifndef CONFIG_USER_ONLY DEF_HELPER_1 (ssamoswap_disabled, void, env)
target/riscv/insn32.decode +9 -0
@@ -1084,3 +1084,12 @@ sb_aqrl 00111 . . ..... ..... 000 ..... 0101111 @atom_st sh_aqrl 00111 . . ..... ..... 001 ..... 0101111 @atom_st sw_aqrl 00111 . . ..... ..... 010 ..... 0101111 @atom_st sd_aqrl 00111 . . ..... ..... 011 ..... 0101111 @atom_st + +# *** Zvqdotq Vector Dot-Product Extension *** +vqdot_vv 101100 . ..... ..... 010 ..... 1010111 @r_vm +vqdot_vx 101100 . ..... ..... 110 ..... 1010111 @r_vm +vqdotu_vv 101000 . ..... ..... 010 ..... 1010111 @r_vm +vqdotu_vx 101000 . ..... ..... 110 ..... 1010111 @r_vm +vqdotsu_vv 101010 . ..... ..... 010 ..... 1010111 @r_vm +vqdotsu_vx 101010 . ..... ..... 110 ..... 1010111 @r_vm +vqdotus_vx 101110 . ..... ..... 110 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvzvqdotq.c.inc new file +61 -0
61 lines not on this page · raw message
target/riscv/translate.c +1 -0
@@ -1207,6 +1207,7 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)#include "insn_trans/trans_rvzfh.c.inc" #include "insn_trans/trans_rvk.c.inc" #include "insn_trans/trans_rvvk.c.inc" +#include "insn_trans/trans_rvzvqdotq.c.inc" #include "insn_trans/trans_privileged.c.inc" #include "insn_trans/trans_svinval.c.inc" #include "insn_trans/trans_rvbf16.c.inc"
target/riscv/vector_helper.c +57 -0
66 lines not on this page · raw message
Signature · 1 line
2.43.7
PATCH v5 3/4 target/riscv: Expose Zvqdotq extension as a cpu property
In reply to Max Chou--- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/riscv/cpu.c +1 -0
@@ -1377,6 +1377,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = {/* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = {MULTI_EXT_CFG_BOOL ("x-svukte" , ext_svukte, false), +MULTI_EXT_CFG_BOOL ("x-zvqdotq" , ext_zvqdotq, false), { }, };
Signature · 1 line
2.43.7
PATCH v5 4/4 disas/riscv: Support the Zvqdotq extension
In reply to Max ChouThe Zvqdotq provides following instructions:
- vqdot.[vv,vx] Vector 8-bit Signed-Signed Dot Product
- vqdotu.[vv,vx] Vector 8-bit Unsigned Dot Product
- vqdotsu.[vv,vx] Vector 8-bit Signed-Unsigned Dot Product
- vqdotus.vx Vector 8-bit Unsigned-Signed Dot Product
--- disas/riscv.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
disas/riscv.c +21 -0
@@ -984,6 +984,13 @@ typedef enum { rv_op_ssamoswap_d =953 , rv_op_c_sspush =954 , rv_op_c_sspopchk =955 , + rv_op_vqdot_vv =956 , + rv_op_vqdot_vx =957 , + rv_op_vqdotu_vv =958 , + rv_op_vqdotu_vx =959 , + rv_op_vqdotsu_vv =960 , + rv_op_vqdotsu_vx =961 , + rv_op_vqdotus_vx =962 , } rv_op;/* register names */
@@ -2254,6 +2261,13 @@ const rv_opcode_data rvi_opcode_data[] = { rv_op_sspush, 0 }, {"c.sspopchk" , rv_codec_cmop_ss, rv_fmt_rs1,NULL , rv_op_sspopchk, rv_op_sspopchk, 0 }, + { "vqdot.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 }, + { "vqdot.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 }, + { "vqdotu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 }, + { "vqdotu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 }, + { "vqdotsu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 }, + { "vqdotsu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 }, + { "vqdotus.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 }, };/* CSR names */
@@ -3738,8 +3752,11 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)case 37 : op = rv_op_vmul_vv;break ;case 38 : op = rv_op_vmulhsu_vv;break ;case 39 : op = rv_op_vmulh_vv;break ; +case 40 : op = rv_op_vqdotu_vv;break ;case 41 : op = rv_op_vmadd_vv;break ; +case 42 : op = rv_op_vqdotsu_vv;break ;case 43 : op = rv_op_vnmsub_vv;break ; +case 44 : op = rv_op_vqdot_vv;break ;case 45 : op = rv_op_vmacc_vv;break ;case 47 : op = rv_op_vnmsac_vv;break ;case 48 : op = rv_op_vwaddu_vv;break ;
@@ -3945,9 +3962,13 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)case 37 : op = rv_op_vmul_vx;break ;case 38 : op = rv_op_vmulhsu_vx;break ;case 39 : op = rv_op_vmulh_vx;break ; +case 40 : op = rv_op_vqdotu_vx;break ;case 41 : op = rv_op_vmadd_vx;break ; +case 42 : op = rv_op_vqdotsu_vx;break ;case 43 : op = rv_op_vnmsub_vx;break ; +case 44 : op = rv_op_vqdot_vx;break ;case 45 : op = rv_op_vmacc_vx;break ; +case 46 : op = rv_op_vqdotus_vx;break ;case 47 : op = rv_op_vnmsac_vx;break ;case 48 : op = rv_op_vwaddu_vx;break ;case 49 : op = rv_op_vwadd_vx;break ;
Signature · 1 line
2.43.7