Skip to contentSkip to conversation

target/riscv: Add Zvdota/Zvbdota families of dot-product extensions

PATCH New Max Chou 1 participant 39 messages Dec 1

Subsystems (2)
lore
Share & tools
lore

Max Chou

author
#0 lore raw

cover target/riscv: Add Zvdota/Zvbdota families of dot-product extensions

This patchset introduces the Zvdota/Zvbdota families of dot-product extensions based on the freeze ISA specification
(https://github.com/riscv/riscv-isa-manual/releases/tag/zvdota-0.9 v0.9 freeze)
- Zvdota: Zvqwdota8i/Zvqwdota16i/Zvfwdota16bf/Zvfqwdota8f
- Zvbdota: Zvqwbdota8i/Zvqwbdota16i/Zvfwbdota16bf/Zvfqwbdota8f/Zvfbdota32f

This patchset assigns the Zvdota/Zvbdota cpu properties as the experimental cpu isa extension properties. These experimental cpu isa extension properties will be replaced after the Zvdota/Zvbdota isa specification is ratified.

The toolchains support Zvdota/Zvbdota families extensions:
- LLVM (after 23.1.0)
- Support v0.2 Zvdota/Zvbdota extensions
- https://releases.llvm.org/23.1.0/docs/RISCVUsage.html
- llvm/llvm-project#196467, commit d25ec4b84487, merged 2026-05-27.
- https://github.com/llvm/llvm-project/pull/196467
- GCC (reviewing)
- Upstream patchset: <[email protected]>

Changes since RFC <[email protected]>:
- Rebase on the latest riscv-to-apply.next branch (commit id: 4ac269e)
- Fix the OFP8 checking functions patch description typo.
- Use g_autofree for the temporary floating-point input arrays.
- Simplify the RVBNA final accumulator addition exception flag handling.
- Remove the unused FP16 RVBNA function and declaration.
- Share the scalar and batched integer dot-product helper implementation.
- Gather the broadcast vs1 input once for active batched fp outputs.
- Share the batched translation setup and reuse the common scalar vector translation setup.
- Consolidate the batched destination capacity and tail handling.
- Add the review and test tags recorded in the v1 patches.

References:
- riscv-isa-manual tag: https://github.com/riscv/riscv-isa-manual/releases/tag/zvdota-0.9

rnax

Max Chou (38):
fpu/softfloat: Support OCP(Open Compute Project) OFP8 checking
functions
target/riscv: Introduce riscv_init_fp_status target/riscv: rvv: Introduce RVBNA algorithm for Zvdota/Zvbdota
extensions
target/riscv: Add cfg property for Zvqwdota8i extension target/riscv: Add implied rules for Zvqwdota8i extension target/riscv: rvv: Implement Zvqwdota8i instructions disas/riscv: Support Zvqwdota8i extension target/riscv: Add Zvqwdota16i cpu property target/riscv: Add Zvqwdota16i dependency imply rule target/riscv: rvv: Implement Zvqwdota16i instructions target/riscv: Add cfg property for Zvfwdota16bf extension target/riscv: Add implied rules for Zvfwdota16bf extension target/riscv: rvv: Implement Zvfwdota16bf instruction disas/riscv: Support Zvfwdota16bf extension target/riscv: Add cfg property for Zvfqwdota8f extension target/riscv: Add implied rules for Zvfqwdota8f extension target/riscv: rvv: Implement Zvfqwdota8f instructions disas/riscv: Support Zvfqwdota8f extension target/riscv: Add cfg property for Zvqwbdota8i extension target/riscv: Add implied rules for Zvqwbdota8i extension target/riscv: rvv: Implement Zvqwbdota8i instructions disas/riscv: Support Zvqwbdota8i extension target/riscv: Add cfg property for Zvqwbdota16i extension target/riscv: Add implied rules for Zvqwbdota16i extension target/riscv: rvv: Implement Zvqwbdota16i instructions target/riscv: Add cfg property for Zvfwbdota16bf extension target/riscv: Add implied rules for Zvfwbdota16bf extension target/riscv: rvv: Implement Zvfwbdota16bf instruction disas/riscv: Support Zvfwbdota16bf extension target/riscv: Add cfg property for Zvfqwbdota8f extension target/riscv: Add implied rules for Zvfqwbdota8f extension target/riscv: rvv: Implement Zvfqwbdota8f instructions disas/riscv: Support Zvfqwbdota8f extension target/riscv: Add cfg property for Zvfbdota32f extension target/riscv: Add implied rules for Zvfbdota32f extension target/riscv: rvv: Implement Zvfbdota32f instructions disas/riscv: Support Zvfbdota32f extension tests/tcg/riscv64: Add test for Zvdota/Zvbdota extensions

 MAINTAINERS                                 |   6 +
 disas/riscv-op.c.inc                        |  12 +
 disas/riscv.c                               |  26 ++
 disas/riscv.h                               |   2 +
 fpu/softfloat-specialize.c.inc              |  55 ++++
 include/fpu/softfloat.h                     |  70 ++++
 target/riscv/cpu.c                          | 121 ++++++-
 target/riscv/cpu_cfg_fields.h.inc           |   9 +
 target/riscv/helper.h                       |  29 ++
 target/riscv/insn32.decode                  |  25 ++
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 203 ++++++++++++
 target/riscv/tcg/meson.build                |   2 +-
 target/riscv/tcg/rvbna.c                    | 182 +++++++++++
 target/riscv/tcg/rvbna.h                    |  37 +++
 target/riscv/tcg/tcg-cpu.c                  |  45 +++
 target/riscv/tcg/vector_helper.c            | 288 +++++++++++++++-
 tests/tcg/riscv64/system/meson.build        |  12 +
 tests/tcg/riscv64/test-zvdota.S             | 343 ++++++++++++++++++++
 18 files changed, 1460 insertions(+), 7 deletions(-)
 create mode 100644 target/riscv/tcg/rvbna.c
 create mode 100644 target/riscv/tcg/rvbna.h
 create mode 100644 tests/tcg/riscv64/test-zvdota.S
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/38 fpu/softfloat: Support OCP(Open Compute Project) OFP8 checking functions

Include following checking functions like other fp types:
- *_nan_is_snan
- *_is_quiet_nan
- *_is_signaling_nan
- *_is_any_nan
- *_is_neg
- *_is_infinity
- *_is_zero
- *_is_zero_or_denormal
- *_is_normal

---
 fpu/softfloat-specialize.c.inc | 55 ++++++++++++++++++++++++++
 include/fpu/softfloat.h        | 70 ++++++++++++++++++++++++++++++++++
 2 files changed, 125 insertions(+)
fpu/softfloat-specialize.c.inc +55 -0
index 8b765ef623f..22a3188f99b 100644
@@ -255,6 +255,61 @@ floatx80 floatx80_default_inf(bool zSign, float_status *status)
     return packFloatx80(zSign, 0x7fff, z ? 0 : (1ULL << 63));
 }
 
+/*----------------------------------------------------------------------------
+| Determine if a OCP FP8 E4M3 NaN is signaling NaN.
+| E4M3 has only one NaN encoding, so classification is policy-based.
+*----------------------------------------------------------------------------*/
+
+static bool float8_e4m3_nan_is_snan(float8_e4m3 a, float_status *status)
+{
+    return get_float_e4m3_nan_is_snan(status);
+}
+
+/*----------------------------------------------------------------------------
+| Returns 1 if the OCP FP8 E4M3 value `a' is a quiet NaN; otherwise returns 0.
+*----------------------------------------------------------------------------*/
+
+bool float8_e4m3_is_quiet_nan(float8_e4m3 a_, float_status *status)
+{
+    return float8_e4m3_is_any_nan(a_) && !float8_e4m3_nan_is_snan(a_, status);
+}
+
+/*----------------------------------------------------------------------------
+| Returns 1 if the OCP FP8 E4M3 value `a' is a signaling NaN; otherwise 0.
+*----------------------------------------------------------------------------*/
+
+bool float8_e4m3_is_signaling_nan(float8_e4m3 a_, float_status *status)
+{
+    return float8_e4m3_is_any_nan(a_) && float8_e4m3_nan_is_snan(a_, status);
+}
+
+/*----------------------------------------------------------------------------
+| Determine if a OCP FP8 E5M2 NaN is signaling NaN.
+*----------------------------------------------------------------------------*/
+
+static bool float8_e5m2_nan_is_snan(float8_e5m2 a, float_status *status)
+{
+    return frac_msb_is_snan((a >> 1) & 1, status);
+}
+
+/*----------------------------------------------------------------------------
+| Returns 1 if the OCP FP8 E5M2 value `a' is a quiet NaN; otherwise returns 0.
+*----------------------------------------------------------------------------*/
+
+bool float8_e5m2_is_quiet_nan(float8_e5m2 a_, float_status *status)
+{
+    return float8_e5m2_is_any_nan(a_) && !float8_e5m2_nan_is_snan(a_, status);
+}
+
+/*----------------------------------------------------------------------------
+| Returns 1 if the OCP FP8 E5M2 value `a' is a signaling NaN; otherwise 0.
+*----------------------------------------------------------------------------*/
+
+bool float8_e5m2_is_signaling_nan(float8_e5m2 a_, float_status *status)
+{
+    return float8_e5m2_is_any_nan(a_) && float8_e5m2_nan_is_snan(a_, status);
+}
+
 /*----------------------------------------------------------------------------
 | Determine if a float16 NaN is signaling NaN.
 *----------------------------------------------------------------------------*/
include/fpu/softfloat.h +70 -0

76 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#2 lore raw

PATCH 2/38 target/riscv: Introduce riscv_init_fp_status

In reply to Max Chou

Create a function to set all default controls for the float_status. And set e4m3_nan_is_snan to false to follow the RISC-V isa extensions.

---
 target/riscv/cpu.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
target/riscv/cpu.c +10 -3
index 44348ed2e70..2e5c27639b5 100644
@@ -992,6 +992,14 @@ static bool riscv_cpu_has_work(CPUState *cs)
 }
 #endif /* !CONFIG_USER_ONLY */
 
+static void riscv_init_fp_status(float_status *s)
+{
+    set_default_nan_mode(1, s);
+    /* Default NaN value: sign bit clear, frac msb set */
+    set_float_default_nan_pattern(0b01000000, s);
+    set_float_e4m3_nan_is_snan(false, s);
+}
+
 static void riscv_cpu_reset_hold(Object *obj, ResetType type)
 {
     CPUState *cs = CPU(obj);
@@ -1117,11 +1125,10 @@ static void riscv_cpu_reset_hold(Object *obj, ResetType type)
     env->xl = riscv_cpu_mxl(env);
     cs->exception_index = RISCV_EXCP_NONE;
     env->load_res = -1;
-    set_default_nan_mode(1, &env->fp_status);
-    /* Default NaN value: sign bit clear, frac msb set */
-    set_float_default_nan_pattern(0b01000000, &env->fp_status);
     env->vill = true;
 
+    riscv_init_fp_status(&env->fp_status);
+
 #ifndef CONFIG_USER_ONLY
 #ifdef CONFIG_TCG
     env->debug_mode = false;
Signature · 1 line
2.43.0
author
#3 lore raw

PATCH 3/38 target/riscv: rvv: Introduce RVBNA algorithm for Zvdota/Zvbdota extensions

In reply to Max Chou

The RISC-V Bulk Normalization Algorithm (RVBNA) is a scheme employed by multiple RISC-V extensions (e.g. Zvdota/Zvbdota family) for efficient computation of floating-point dot products.

---
 MAINTAINERS                      |   6 +
 target/riscv/tcg/meson.build     |   2 +-
 target/riscv/tcg/rvbna.c         | 182 +++++++++++++++++++++++++++++++
 target/riscv/tcg/rvbna.h         |  37 +++++++
 target/riscv/tcg/vector_helper.c |   1 +
 5 files changed, 227 insertions(+), 1 deletion(-)
 create mode 100644 target/riscv/tcg/rvbna.c
 create mode 100644 target/riscv/tcg/rvbna.h
MAINTAINERS +6 -0
index 47eefdf2c39..f7edaeb3521 100644
@@ -416,6 +416,12 @@ F: target/riscv/tcg/xsf_helper.c
 F: disas/riscv-xsf*
 F: tests/tcg/riscv64/test-xsfvqmacc.S
 
+RISC-V Bulk Normalization Algorithm (RVBNA)
+M: Max Chou <[email protected]>
+L: [email protected]
+S: Supported
+F: target/riscv/tcg/rvbna.*
+
 RENESAS RX CPUs
 R: Yoshinori Sato <[email protected]>
 S: Orphan
target/riscv/tcg/meson.build +1 -1
index 86805b30cbc..3b7821178fc 100644
@@ -10,6 +10,7 @@ riscv_ss.add(files(
   'fpu_helper.c',
   'm128_helper.c',
   'op_helper.c',
+  'rvbna.c',
   'translate.c',
   'tcg-cpu.c',
   'vcrypto_helper.c',
@@ -27,4 +28,3 @@ riscv_system_ss.add(files(
   'th_csr.c',
 ))
 
-
target/riscv/tcg/rvbna.c new file +182 -0

182 lines not on this page · raw message

target/riscv/tcg/rvbna.h new file +37 -0
new file mode 100644
index 00000000000..97aed9b372e
@@ -0,0 +1,37 @@
+/*
+ * RISC-V Bulk Normalization Algorithm (RVBNA)
+ *
+ * Copyright (c) 2026 SiFive, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TARGET_RISCV_TCG_RVBNA_H
+#define TARGET_RISCV_TCG_RVBNA_H
+
+#include "fpu/softfloat.h"
+
+float32 rvbna_final_f32_add(float32 partial, float32 accumulator,
+                            float_status *fp_status);
+
+float32 rvbna_dot_float8_e4m3_float8_e4m3(const float8_e4m3 a[],
+                                          const float8_e4m3 b[],
+                                          uint32_t n_prod,
+                                          float_status *fp_status);
+float32 rvbna_dot_float8_e4m3_float8_e5m2(const float8_e4m3 a[],
+                                          const float8_e5m2 b[],
+                                          uint32_t n_prod,
+                                          float_status *fp_status);
+float32 rvbna_dot_float8_e5m2_float8_e4m3(const float8_e5m2 a[],
+                                          const float8_e4m3 b[],
+                                          uint32_t n_prod,
+                                          float_status *fp_status);
+float32 rvbna_dot_float8_e5m2_float8_e5m2(const float8_e5m2 a[],
+                                          const float8_e5m2 b[],
+                                          uint32_t n_prod,
+                                          float_status *fp_status);
+float32 rvbna_dot_bfloat16_bfloat16(const bfloat16 a[], const bfloat16 b[],
+                                    uint32_t n_prod,
+                                    float_status *fp_status);
+
+#endif
target/riscv/tcg/vector_helper.c +1 -0
index 917a48b5106..172ae0f11dc 100644
@@ -31,6 +31,7 @@
 #include "tcg/tcg-gvec-desc.h"
 #include "internals.h"
 #include "vector_internals.h"
+#include "rvbna.h"
 #include <math.h>
 
 static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
Signature · 1 line
2.43.0
author
#4 lore raw

PATCH 4/38 target/riscv: Add cfg property for Zvqwdota8i extension

In reply to Max Chou

Add CPU configuration for the Zvqwdota8i extension which depends on the Zve32x extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 6 ++++--
 4 files changed, 12 insertions(+), 2 deletions(-)
target/riscv/cpu.c +2 -0
index 2e5c27639b5..6a98759b787 100644
@@ -250,6 +250,8 @@ 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_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwdota8i, PRIV_VERSION_1_13_0,
+                                    ext_zvqwdota8i),
     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(sdext, PRIV_VERSION_1_12_0, ext_sdext),
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 85fc3ad8bb8..0c08d688ac1 100644
@@ -106,6 +106,7 @@ BOOL_FIELD(ext_zvfbfmin)
 BOOL_FIELD(ext_zvfbfwma)
 BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
+BOOL_FIELD(ext_zvqwdota8i)
 BOOL_FIELD(ext_sdext)
 BOOL_FIELD(ext_sdtrig)
 BOOL_FIELD(ext_smaia)
target/riscv/tcg/tcg-cpu.c +5 -0
index 5834ec1524f..1c51ea94489 100644
@@ -691,6 +691,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         }
     }
 
+    if (cpu->cfg.ext_zvqwdota8i && !cpu->cfg.ext_zve32x) {
+        error_setg(errp, "Zvqwdota8i extension depends on Zve32x extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +4 -2
index 172ae0f11dc..4ba0a89f4b5 100644
@@ -39,7 +39,8 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
     int xlen = riscv_cpu_xlen(env);
     target_ulong reserved = 0;
 
-    if (riscv_cpu_cfg(env)->ext_zvfbfa) {
+    if (riscv_cpu_cfg(env)->ext_zvfbfa ||
+        riscv_cpu_cfg(env)->ext_zvqwdota8i) {
         reserved = vtype & MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT,
                                            xlen - 1 - R_VTYPE_RESERVED_SHIFT);
     } else {
@@ -88,7 +89,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
 
     switch (vsew) {
     case MO_8:
-        ill_altfmt &= !(cpu->cfg.ext_zvfbfa);
+        ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
+                        cpu->cfg.ext_zvqwdota8i);
         break;
     case MO_16:
         ill_altfmt &= !(cpu->cfg.ext_zvfbfa);
Signature · 1 line
2.43.0
author
#5 lore raw

PATCH 5/38 target/riscv: Add implied rules for Zvqwdota8i extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvqwdota8i extension.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 6a98759b787..71363c47d19 100644
@@ -2874,6 +2874,15 @@ static RISCVCPUImpliedExtsRule ZVFHMIN_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVQWDOTA8I_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvqwdota8i),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve32x),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVKN_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvkn),
     .implied_multi_exts = {
@@ -3078,6 +3087,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVKS_IMPLIED,
     &ZVKSC_IMPLIED,
     &ZVKSG_IMPLIED,
+    &ZVQWDOTA8I_IMPLIED,
     &SHA_IMPLIED,
     &SSCFG_IMPLIED,
     &SUPM_IMPLIED,
Signature · 1 line
2.43.0
author
#6 lore raw

PATCH 6/38 target/riscv: rvv: Implement Zvqwdota8i instructions

In reply to Max Chou

Implement the vqwdotau.vv and vqwdotas.vv instructions from the Zvqwdota8i extension. These instructions compute a dot product between two 8-bit integer vectors, accumulating into a 32-bit scalar in vd[0].

---
 target/riscv/helper.h                       |  4 ++
 target/riscv/insn32.decode                  |  4 ++
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 40 ++++++++++++
 target/riscv/tcg/vector_helper.c            | 70 +++++++++++++++++++++
 4 files changed, 118 insertions(+)
target/riscv/helper.h +4 -0
index 1cffcad580c..54df39944e2 100644
@@ -1387,6 +1387,10 @@ DEF_HELPER_1(ssamoswap_disabled, void, env)
 /* Zalrsc SC write probe */
 DEF_HELPER_FLAGS_3(sc_probe_write, TCG_CALL_NO_WG, void, env, tl, tl)
 
+/* Zvqwdota8i - 8-bit integer dot product */
+DEF_HELPER_6(vqwdotau_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
+DEF_HELPER_6(vqwdotas_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
+
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
 DEF_HELPER_5(sf_vqmacc_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +4 -0
index 795badc8a7d..cc7d639ab73 100644
@@ -1097,3 +1097,7 @@ vwabda_vv     111101 . ..... ..... 000 ..... 1010111 @r_vm
 vwabda_vx     111101 . ..... ..... 100 ..... 1010111 @r_vm
 vwabdau_vv    111110 . ..... ..... 000 ..... 1010111 @r_vm
 vwabdau_vx    111110 . ..... ..... 100 ..... 1010111 @r_vm
+
+# *** Zvqwdota8i 8-bit Integer Dot-Product Extension ***
+vqwdotau_vv  100110 . ..... ..... 000 ..... 1110111 @r_vm
+vqwdotas_vv  100111 . ..... ..... 000 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +40 -0
index a1807cc911c..b52b58a9e40 100644
@@ -4135,3 +4135,43 @@ GEN_ABD_OPIVV_WIDEN_TRANS(vwabda_vv, vwabd_vv_check)
 GEN_ABD_OPIVX_WIDEN_TRANS(vwabda_vx, vwabd_vx_check)
 GEN_ABD_OPIVV_WIDEN_TRANS(vwabdau_vv, vwabd_vv_check)
 GEN_ABD_OPIVX_WIDEN_TRANS(vwabdau_vx, vwabd_vx_check)
+
+/*
+ * Zvdota/Zvbdota families of dot-product extensions
+ */
+#define GEN_ZVDOTA_INT_TRANS(NAME, CHECK)                                    \
+static bool trans_##NAME(DisasContext *s, arg_rmrr *a)                       \
+{                                                                            \
+    static gen_helper_gvec_4_ptr * const fns[2] = {                          \
+        gen_helper_##NAME##_b, NULL                                          \
+    };                                                                       \
+    if (CHECK(s, a)) {                                                       \
+        return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s);    \
+    }                                                                        \
+    return false;                                                            \
+}
+
+static bool vext_zvdota_base_check(DisasContext *s, arg_rmrr * a)
+{
+    return require_rvv(s) &&
+           vext_check_isa_ill(s) &&
+           s->vstart_eq_zero &&
+           require_align(a->rs1, s->lmul) &&
+           require_align(a->rs2, s->lmul) &&
+           require_vm(a->vm, a->rd) &&
+           require_noover(a->rd, 0, a->rs1, s->lmul) &&
+           require_noover(a->rd, 0, a->rs2, s->lmul) &&
+           vext_check_input_eew(s, a->rs1, s->sew, a->rs2, s->sew, a->vm);
+}
+
+/*
+ * Zvqwdota8i - 8-bit integer dot-product extension
+ */
+static bool vext_vqwdota_check(DisasContext *s, arg_rmrr *a)
+{
+    return vext_zvdota_base_check(s, a) &&
+           (s->cfg_ptr->ext_zvqwdota8i && s->sew == MO_8);
+}
+
+GEN_ZVDOTA_INT_TRANS(vqwdotau_vv, vext_vqwdota_check)
+GEN_ZVDOTA_INT_TRANS(vqwdotas_vv, vext_vqwdota_check)
target/riscv/tcg/vector_helper.c +70 -0

73 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#7 lore raw

PATCH 7/38 disas/riscv: Support Zvqwdota8i extension

In reply to Max Chou

Adds support of Zvqwdota8i extensions:
- vqwdotau.vv
- vqwdotas.vv

---
 disas/riscv-op.c.inc | 2 ++
 disas/riscv.c        | 6 ++++++
 2 files changed, 8 insertions(+)
disas/riscv-op.c.inc +2 -0
index 425473ee61b..ec767ccbf8b 100644
@@ -770,6 +770,8 @@ OP(vnsrl_wx, "vnsrl.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm)
 OP(vor_vi, "vor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm)
 OP(vor_vv, "vor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vor_vx, "vor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm)
+OP(vqwdotas_vv, "vqwdotas.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
+OP(vqwdotau_vv, "vqwdotau.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vredand_vs, "vredand.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vredmax_vs, "vredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vredmaxu_vs, "vredmaxu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
disas/riscv.c +6 -0
index ca0d6e90b37..2acded0c915 100644
@@ -2634,6 +2634,12 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
             }
             break;
         case 29:
+            if (((inst >> 12) & 0b111) == 0) {
+                switch ((inst >> 26) & 0b111111) {
+                case 38: return &op_vqwdotau_vv;
+                case 39: return &op_vqwdotas_vv;
+                }
+            }
             if (((inst >> 25) & 1) == 1 && ((inst >> 12) & 0b111) == 2) {
                 switch ((inst >> 26) & 0b111111) {
                 case 32: return &op_vsm3me_vv;
Signature · 1 line
2.43.0
author
#8 lore raw

PATCH 8/38 target/riscv: Add Zvqwdota16i cpu property

In reply to Max Chou

Add CPU configuration property of Zvqwdota16i extension which depends on the Zve64x extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 4 +++-
 4 files changed, 11 insertions(+), 1 deletion(-)
target/riscv/cpu.c +2 -0
index 71363c47d19..2edaeabf3c9 100644
@@ -250,6 +250,8 @@ 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_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwdota16i, PRIV_VERSION_1_13_0,
+                                    ext_zvqwdota16i),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwdota8i, PRIV_VERSION_1_13_0,
                                     ext_zvqwdota8i),
     ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx),
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 0c08d688ac1..8bac69a17f7 100644
@@ -106,6 +106,7 @@ BOOL_FIELD(ext_zvfbfmin)
 BOOL_FIELD(ext_zvfbfwma)
 BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
+BOOL_FIELD(ext_zvqwdota16i)
 BOOL_FIELD(ext_zvqwdota8i)
 BOOL_FIELD(ext_sdext)
 BOOL_FIELD(ext_sdtrig)
target/riscv/tcg/tcg-cpu.c +5 -0
index 1c51ea94489..54749125acf 100644
@@ -696,6 +696,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvqwdota16i && !cpu->cfg.ext_zve64x) {
+        error_setg(errp, "Zvqwdota16i extension depends on Zve64x extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +3 -1
index 9cca73033f2..f273c8b0264 100644
@@ -40,6 +40,7 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
     target_ulong reserved = 0;
 
     if (riscv_cpu_cfg(env)->ext_zvfbfa ||
+        riscv_cpu_cfg(env)->ext_zvqwdota16i ||
         riscv_cpu_cfg(env)->ext_zvqwdota8i) {
         reserved = vtype & MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT,
                                            xlen - 1 - R_VTYPE_RESERVED_SHIFT);
@@ -93,7 +94,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
                         cpu->cfg.ext_zvqwdota8i);
         break;
     case MO_16:
-        ill_altfmt &= !(cpu->cfg.ext_zvfbfa);
+        ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
+                        cpu->cfg.ext_zvqwdota16i);
         break;
     default:
         break;
Signature · 1 line
2.43.0
author
#9 lore raw

PATCH 9/38 target/riscv: Add Zvqwdota16i dependency imply rule

In reply to Max Chou

According to the Zvbdota isa spec, Zvqwdota16i requires Zve64x.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 2edaeabf3c9..652e508f12f 100644
@@ -2876,6 +2876,15 @@ static RISCVCPUImpliedExtsRule ZVFHMIN_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVQWDOTA16I_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvqwdota16i),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve64x),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVQWDOTA8I_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvqwdota8i),
     .implied_multi_exts = {
@@ -3089,6 +3098,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVKS_IMPLIED,
     &ZVKSC_IMPLIED,
     &ZVKSG_IMPLIED,
+    &ZVQWDOTA16I_IMPLIED,
     &ZVQWDOTA8I_IMPLIED,
     &SHA_IMPLIED,
     &SSCFG_IMPLIED,
Signature · 1 line
2.43.0
author
#10 lore raw

PATCH 10/38 target/riscv: rvv: Implement Zvqwdota16i instructions

In reply to Max Chou

Extend existing vqwdota* instructions to support both SEW=8 (Zvqwdota8i) and SEW=16 (Zvqwdota16i).

---
 target/riscv/helper.h                       | 4 +++-
 target/riscv/insn32.decode                  | 2 +-
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 7 ++++---
 target/riscv/tcg/vector_helper.c            | 6 +++++-
 4 files changed, 13 insertions(+), 6 deletions(-)
target/riscv/helper.h +3 -1
index 54df39944e2..db3ff132fa5 100644
@@ -1387,9 +1387,11 @@ DEF_HELPER_1(ssamoswap_disabled, void, env)
 /* Zalrsc SC write probe */
 DEF_HELPER_FLAGS_3(sc_probe_write, TCG_CALL_NO_WG, void, env, tl, tl)
 
-/* Zvqwdota8i - 8-bit integer dot product */
+/* Zvqwdota8i/Zvqwdota16i - 8/16-bit integer dot product */
 DEF_HELPER_6(vqwdotau_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
 DEF_HELPER_6(vqwdotas_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
+DEF_HELPER_6(vqwdotau_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
+DEF_HELPER_6(vqwdotas_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
 
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +1 -1
index cc7d639ab73..b8a5d0567b1 100644
@@ -1098,6 +1098,6 @@ vwabda_vx     111101 . ..... ..... 100 ..... 1010111 @r_vm
 vwabdau_vv    111110 . ..... ..... 000 ..... 1010111 @r_vm
 vwabdau_vx    111110 . ..... ..... 100 ..... 1010111 @r_vm
 
-# *** Zvqwdota8i 8-bit Integer Dot-Product Extension ***
+# *** Zvqwdota8i/Zvqwdota16i Integer Dot-Product Extension ***
 vqwdotau_vv  100110 . ..... ..... 000 ..... 1110111 @r_vm
 vqwdotas_vv  100111 . ..... ..... 000 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +4 -3
index b52b58a9e40..dc794d13b7a 100644
@@ -4143,7 +4143,7 @@ GEN_ABD_OPIVX_WIDEN_TRANS(vwabdau_vx, vwabd_vx_check)
 static bool trans_##NAME(DisasContext *s, arg_rmrr *a)                       \
 {                                                                            \
     static gen_helper_gvec_4_ptr * const fns[2] = {                          \
-        gen_helper_##NAME##_b, NULL                                          \
+        gen_helper_##NAME##_b, gen_helper_##NAME##_h,                        \
     };                                                                       \
     if (CHECK(s, a)) {                                                       \
         return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s);    \
@@ -4165,12 +4165,13 @@ static bool vext_zvdota_base_check(DisasContext *s, arg_rmrr * a)
 }
 
 /*
- * Zvqwdota8i - 8-bit integer dot-product extension
+ * Zvqwdota8i/Zvqwdota16i - 8/16-bit integer dot-product extension
  */
 static bool vext_vqwdota_check(DisasContext *s, arg_rmrr *a)
 {
     return vext_zvdota_base_check(s, a) &&
-           (s->cfg_ptr->ext_zvqwdota8i && s->sew == MO_8);
+           ((s->cfg_ptr->ext_zvqwdota8i && s->sew == MO_8) ||
+            (s->cfg_ptr->ext_zvqwdota16i && s->sew == MO_16));
 }
 
 GEN_ZVDOTA_INT_TRANS(vqwdotau_vv, vext_vqwdota_check)
target/riscv/tcg/vector_helper.c +5 -1
index f273c8b0264..936a9557b8b 100644
@@ -6029,9 +6029,11 @@ static void do_##NAME(void *vd, void *v0, void *vs1, void *vs2,      \
 
 GEN_OP_DOTA_INT(dotau_b, 32, 8, uint8_t, H4, H1)
 GEN_OP_DOTA_INT(dotas_b, 32, 8, int8_t, H4, H1)
+GEN_OP_DOTA_INT(dotau_h, 64, 16, uint16_t, H8, H2)
+GEN_OP_DOTA_INT(dotas_h, 64, 16, int16_t, H8, H2)
 
 /*
- * Zvqwdota8i - 8-bit integer dot product
+ * Zvqwdota8i/Zvqwdota16i - 8/16-bit integer dot product
  */
 #define GEN_VEXT_ZVDOTA_INT(NAME, OP)                        \
 void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,  \
@@ -6042,3 +6044,5 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,  \
 
 GEN_VEXT_ZVDOTA_INT(vqwdotau_vv_b, do_dotau_b)
 GEN_VEXT_ZVDOTA_INT(vqwdotas_vv_b, do_dotas_b)
+GEN_VEXT_ZVDOTA_INT(vqwdotau_vv_h, do_dotau_h)
+GEN_VEXT_ZVDOTA_INT(vqwdotas_vv_h, do_dotas_h)
Signature · 1 line
2.43.0
author
#11 lore raw

PATCH 11/38 target/riscv: Add cfg property for Zvfwdota16bf extension

In reply to Max Chou

Add CPU configuration property of Zvfwdota16bf extension which depends on the Zve32f extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 2 ++
 4 files changed, 10 insertions(+)
target/riscv/cpu.c +2 -0
index 652e508f12f..51986c44b05 100644
@@ -236,6 +236,8 @@ const RISCVIsaExtData isa_edata_arr[] = {
     ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma),
     ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),
     ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin),
+    ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfwdota16bf, PRIV_VERSION_1_13_0,
+                                    ext_zvfwdota16bf),
     ISA_EXT_DATA_ENTRY(zvkb, PRIV_VERSION_1_12_0, ext_zvkb),
     ISA_EXT_DATA_ENTRY(zvkg, PRIV_VERSION_1_12_0, ext_zvkg),
     ISA_EXT_DATA_ENTRY(zvkn, PRIV_VERSION_1_12_0, ext_zvkn),
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 8bac69a17f7..30c404863c8 100644
@@ -106,6 +106,7 @@ BOOL_FIELD(ext_zvfbfmin)
 BOOL_FIELD(ext_zvfbfwma)
 BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
+BOOL_FIELD(ext_zvfwdota16bf)
 BOOL_FIELD(ext_zvqwdota16i)
 BOOL_FIELD(ext_zvqwdota8i)
 BOOL_FIELD(ext_sdext)
target/riscv/tcg/tcg-cpu.c +5 -0
index 54749125acf..91e009072e6 100644
@@ -701,6 +701,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvfwdota16bf && !cpu->cfg.ext_zve32f) {
+        error_setg(errp, "Zvfwdota16bf extension depends on Zve32f extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +2 -0
index 936a9557b8b..ee327b30d7a 100644
@@ -40,6 +40,7 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
     target_ulong reserved = 0;
 
     if (riscv_cpu_cfg(env)->ext_zvfbfa ||
+        riscv_cpu_cfg(env)->ext_zvfwdota16bf ||
         riscv_cpu_cfg(env)->ext_zvqwdota16i ||
         riscv_cpu_cfg(env)->ext_zvqwdota8i) {
         reserved = vtype & MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT,
@@ -95,6 +96,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
         break;
     case MO_16:
         ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
+                        cpu->cfg.ext_zvfwdota16bf ||
                         cpu->cfg.ext_zvqwdota16i);
         break;
     default:
Signature · 1 line
2.43.0
author
#12 lore raw

PATCH 12/38 target/riscv: Add implied rules for Zvfwdota16bf extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvfwdota16bf extension recursively.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 51986c44b05..c606c41b6fe 100644
@@ -2896,6 +2896,15 @@ static RISCVCPUImpliedExtsRule ZVQWDOTA8I_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVFWDOTA16BF_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvfwdota16bf),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve32f),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVKN_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvkn),
     .implied_multi_exts = {
@@ -3093,6 +3102,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVFBFWMA_IMPLIED,
     &ZVFH_IMPLIED,
     &ZVFHMIN_IMPLIED,
+    &ZVFWDOTA16BF_IMPLIED,
     &ZVKN_IMPLIED,
     &ZVKNC_IMPLIED,
     &ZVKNG_IMPLIED,
Signature · 1 line
2.43.0
author
#13 lore raw

PATCH 13/38 target/riscv: rvv: Implement Zvfwdota16bf instruction

In reply to Max Chou

Implement the vfwdota.vv instruction from the Zvfwdota16bf extension. This instruction computes a dot product between two BF16 vectors, accumulating into an FP32 scalar in vd[0].

---
 target/riscv/helper.h                       |  3 +
 target/riscv/insn32.decode                  |  3 +
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 23 ++++++
 target/riscv/tcg/vector_helper.c            | 79 +++++++++++++++++++++
 4 files changed, 108 insertions(+)
target/riscv/helper.h +3 -0
index db3ff132fa5..a234ad5da22 100644
@@ -1393,6 +1393,9 @@ DEF_HELPER_6(vqwdotas_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
 DEF_HELPER_6(vqwdotau_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
 DEF_HELPER_6(vqwdotas_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
 
+/* Zvfwdota16bf - BF16 dot product */
+DEF_HELPER_6(vfwdota_vv, void, ptr, ptr, ptr, ptr, env, i32)
+
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
 DEF_HELPER_5(sf_vqmacc_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +3 -0
index b8a5d0567b1..d800ad99451 100644
@@ -1101,3 +1101,6 @@ vwabdau_vx    111110 . ..... ..... 100 ..... 1010111 @r_vm
 # *** Zvqwdota8i/Zvqwdota16i Integer Dot-Product Extension ***
 vqwdotau_vv  100110 . ..... ..... 000 ..... 1110111 @r_vm
 vqwdotas_vv  100111 . ..... ..... 000 ..... 1110111 @r_vm
+
+# *** Zvfwdota16bf BF16 Dot-Product Extension ***
+vfwdota_vv  100100 . ..... ..... 001 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +23 -0
index dc794d13b7a..f0eb749e48b 100644
@@ -4176,3 +4176,26 @@ static bool vext_vqwdota_check(DisasContext *s, arg_rmrr *a)
 
 GEN_ZVDOTA_INT_TRANS(vqwdotau_vv, vext_vqwdota_check)
 GEN_ZVDOTA_INT_TRANS(vqwdotas_vv, vext_vqwdota_check)
+
+#define GEN_ZVDOTA_FP_TRANS(NAME, CHECK)                 \
+static bool trans_##NAME(DisasContext *s, arg_rmrr *a)   \
+{                                                        \
+    if (CHECK(s, a)) {                                   \
+        gen_set_rm(s, RISCV_FRM_DYN);                    \
+        return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, \
+                           gen_helper_##NAME, s);        \
+    }                                                    \
+    return false;                                        \
+}
+
+/*
+ * Zvfwdota16bf - BF16 dot-product extension
+ */
+static bool vext_vfwdota_check(DisasContext *s, arg_rmrr * a)
+{
+    return s->mstatus_fs != EXT_STATUS_DISABLED &&
+           vext_zvdota_base_check(s, a) &&
+           (s->cfg_ptr->ext_zvfwdota16bf && s->sew == MO_16 && s->altfmt == 1);
+}
+
+GEN_ZVDOTA_FP_TRANS(vfwdota_vv, vext_vfwdota_check)
target/riscv/tcg/vector_helper.c +79 -0

82 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#14 lore raw

PATCH 14/38 disas/riscv: Support Zvfwdota16bf extension

In reply to Max Chou

Add disassembler support for the vfwdota.vv instruction from the Zvfwdota16bf extension.

---
 disas/riscv-op.c.inc | 1 +
 disas/riscv.c        | 4 ++++
 2 files changed, 5 insertions(+)
disas/riscv-op.c.inc +1 -0
index ec767ccbf8b..aeb9423f130 100644
@@ -614,6 +614,7 @@ OP(vfwcvt_rtz_xu_f_v, "vfwcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
 OP(vfwcvt_x_f_v, "vfwcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
 OP(vfwcvt_xu_f_v, "vfwcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
 OP(vfwcvtbf16_f_f_v, "vfwcvtbf16.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
+OP(vfwdota_vv, "vfwdota.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vfwmacc_vf, "vfwmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm)
 OP(vfwmacc_vv, "vfwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm)
 OP(vfwmaccbf16_vf, "vfwmaccbf16.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm)
disas/riscv.c +4 -0
index 2acded0c915..62feb4c653e 100644
@@ -2640,6 +2640,10 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 case 39: return &op_vqwdotas_vv;
                 }
             }
+            if (((inst >> 12) & 0b111) == 1 &&
+                ((inst >> 26) & 0b111111) == 36) {
+                return &op_vfwdota_vv;
+            }
             if (((inst >> 25) & 1) == 1 && ((inst >> 12) & 0b111) == 2) {
                 switch ((inst >> 26) & 0b111111) {
                 case 32: return &op_vsm3me_vv;
Signature · 1 line
2.43.0
author
#15 lore raw

PATCH 15/38 target/riscv: Add cfg property for Zvfqwdota8f extension

In reply to Max Chou

Add CPU configuration property of Zvfqwdota8f extension which depends on the Zve32f extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 2 ++
 4 files changed, 10 insertions(+)
target/riscv/cpu.c +2 -0
index c606c41b6fe..2f9b9636838 100644
@@ -236,6 +236,8 @@ const RISCVIsaExtData isa_edata_arr[] = {
     ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma),
     ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),
     ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin),
+    ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfqwdota8f, PRIV_VERSION_1_13_0,
+                                    ext_zvfqwdota8f),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfwdota16bf, PRIV_VERSION_1_13_0,
                                     ext_zvfwdota16bf),
     ISA_EXT_DATA_ENTRY(zvkb, PRIV_VERSION_1_12_0, ext_zvkb),
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 30c404863c8..b18abdd8b9b 100644
@@ -106,6 +106,7 @@ BOOL_FIELD(ext_zvfbfmin)
 BOOL_FIELD(ext_zvfbfwma)
 BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
+BOOL_FIELD(ext_zvfqwdota8f)
 BOOL_FIELD(ext_zvfwdota16bf)
 BOOL_FIELD(ext_zvqwdota16i)
 BOOL_FIELD(ext_zvqwdota8i)
target/riscv/tcg/tcg-cpu.c +5 -0
index 91e009072e6..72ce0b4fbd0 100644
@@ -706,6 +706,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvfqwdota8f && !cpu->cfg.ext_zve32f) {
+        error_setg(errp, "Zvfqwdota8f extension depends on Zve32f extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +2 -0
index 3320ae7370f..a5b6ad8c7cc 100644
@@ -40,6 +40,7 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
     target_ulong reserved = 0;
 
     if (riscv_cpu_cfg(env)->ext_zvfbfa ||
+        riscv_cpu_cfg(env)->ext_zvfqwdota8f ||
         riscv_cpu_cfg(env)->ext_zvfwdota16bf ||
         riscv_cpu_cfg(env)->ext_zvqwdota16i ||
         riscv_cpu_cfg(env)->ext_zvqwdota8i) {
@@ -92,6 +93,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
     switch (vsew) {
     case MO_8:
         ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
+                        cpu->cfg.ext_zvfqwdota8f ||
                         cpu->cfg.ext_zvqwdota8i);
         break;
     case MO_16:
Signature · 1 line
2.43.0
author
#16 lore raw

PATCH 16/38 target/riscv: Add implied rules for Zvfqwdota8f extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvfqwdota8f extension recursively.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 2f9b9636838..c28e674bd3a 100644
@@ -2898,6 +2898,15 @@ static RISCVCPUImpliedExtsRule ZVQWDOTA8I_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVFQWDOTA8F_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvfqwdota8f),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve32f),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVFWDOTA16BF_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvfwdota16bf),
     .implied_multi_exts = {
@@ -3104,6 +3113,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVFBFWMA_IMPLIED,
     &ZVFH_IMPLIED,
     &ZVFHMIN_IMPLIED,
+    &ZVFQWDOTA8F_IMPLIED,
     &ZVFWDOTA16BF_IMPLIED,
     &ZVKN_IMPLIED,
     &ZVKNC_IMPLIED,
Signature · 1 line
2.43.0
author
#17 lore raw

PATCH 17/38 target/riscv: rvv: Implement Zvfqwdota8f instructions

In reply to Max Chou

Implements the Zvfqwdota8f OCP FP8 dot-product instructions:
- vfqwdota.vv: vs2 is E4M3, vs1 format selected by altfmt (0=E4M3, 1=E5M2)
- vfqwdota.alt.vv: vs2 is E5M2, vs1 format selected by altfmt (0=E4M3, 1=E5M2)

---
 target/riscv/helper.h                       |  4 +++
 target/riscv/insn32.decode                  |  4 +++
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 13 +++++++++
 target/riscv/tcg/vector_helper.c            | 30 ++++++++++++++++++++-
 4 files changed, 50 insertions(+), 1 deletion(-)
target/riscv/helper.h +4 -0
index a234ad5da22..5dfbe59ea0d 100644
@@ -1396,6 +1396,10 @@ DEF_HELPER_6(vqwdotas_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
 /* Zvfwdota16bf - BF16 dot product */
 DEF_HELPER_6(vfwdota_vv, void, ptr, ptr, ptr, ptr, env, i32)
 
+/* Zvfqwdota8f - OCP FP8 dot product */
+DEF_HELPER_6(vfqwdota_vv, void, ptr, ptr, ptr, ptr, env, i32)
+DEF_HELPER_6(vfqwdota_alt_vv, void, ptr, ptr, ptr, ptr, env, i32)
+
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
 DEF_HELPER_5(sf_vqmacc_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +4 -0
index d800ad99451..def5785f8e2 100644
@@ -1104,3 +1104,7 @@ vqwdotas_vv  100111 . ..... ..... 000 ..... 1110111 @r_vm
 
 # *** Zvfwdota16bf BF16 Dot-Product Extension ***
 vfwdota_vv  100100 . ..... ..... 001 ..... 1110111 @r_vm
+
+# *** Zvfqwdota8f OCP FP8 Dot-Product Extension ***
+vfqwdota_vv     100110 . ..... ..... 001 ..... 1110111 @r_vm
+vfqwdota_alt_vv 100111 . ..... ..... 001 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +13 -0
index f0eb749e48b..fcad57f9dfd 100644
@@ -4199,3 +4199,16 @@ static bool vext_vfwdota_check(DisasContext *s, arg_rmrr * a)
 }
 
 GEN_ZVDOTA_FP_TRANS(vfwdota_vv, vext_vfwdota_check)
+
+/*
+ * Zvfqwdota8f - OCP FP8 dot-product extension
+ */
+static bool vext_vfqwdota_check(DisasContext *s, arg_rmrr *a)
+{
+    return s->mstatus_fs != EXT_STATUS_DISABLED &&
+           vext_zvdota_base_check(s, a) &&
+           (s->cfg_ptr->ext_zvfqwdota8f && s->sew == MO_8);
+}
+
+GEN_ZVDOTA_FP_TRANS(vfqwdota_vv, vext_vfqwdota_check)
+GEN_ZVDOTA_FP_TRANS(vfqwdota_alt_vv, vext_vfqwdota_check)
target/riscv/tcg/vector_helper.c +29 -1
index a5b6ad8c7cc..4b16ee9d1d7 100644
@@ -6058,6 +6058,30 @@ static inline float32 op_rvbna_bf16(const bfloat16 *a, const bfloat16 *b,
     return rvbna_dot_bfloat16_bfloat16(a, b, n_prod, status);
 }
 
+#define GEN_RVBNA_FP8(TYPE_VS2)                                          \
+static inline float32 op_rvbna_##TYPE_VS2(const uint8_t *a,              \
+                                          const uint8_t *b,              \
+                                          uint32_t n_prod, bool altfmt,  \
+                                          float_status *status)          \
+{                                                                        \
+    FloatSNaNRule snan_rule = get_snan_rule(status);                     \
+    float32 result;                                                      \
+                                                                         \
+    set_snan_rule(float_snan_never, status);                             \
+    if (altfmt) {                                                        \
+        result = rvbna_dot_float8_##TYPE_VS2##_float8_e5m2(a, b, n_prod, \
+                                                           status);      \
+    } else {                                                             \
+        result = rvbna_dot_float8_##TYPE_VS2##_float8_e4m3(a, b, n_prod, \
+                                                           status);      \
+    }                                                                    \
+    set_snan_rule(snan_rule, status);                                    \
+    return result;                                                       \
+}
+
+GEN_RVBNA_FP8(e4m3)
+GEN_RVBNA_FP8(e5m2)
+
 #define GEN_OP_DOTA_FP(TYPE_VS2, TYPE, HS)                               \
 static void do_dota_##TYPE_VS2(void *vd, void *v0, void *vs1, void *vs2, \
                                uint32_t ci, bool batched,                \
@@ -6117,9 +6141,11 @@ static void do_dota_##TYPE_VS2(void *vd, void *v0, void *vs1, void *vs2, \
 }
 
 GEN_OP_DOTA_FP(bf16, bfloat16, H2)
+GEN_OP_DOTA_FP(e4m3, uint8_t, H1)
+GEN_OP_DOTA_FP(e5m2, uint8_t, H1)
 
 /*
- * Zvfwdota16bf - BF16 dot product
+ * Zvfwdota16bf/Zvfqwdota8f - BF16/OFP8 dot product
  */
 #define GEN_VEXT_ZVDOTA_FP(NAME, OP)                         \
 void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,  \
@@ -6129,3 +6155,5 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,  \
 }
 
 GEN_VEXT_ZVDOTA_FP(vfwdota_vv, do_dota_bf16)
+GEN_VEXT_ZVDOTA_FP(vfqwdota_vv, do_dota_e4m3)
+GEN_VEXT_ZVDOTA_FP(vfqwdota_alt_vv, do_dota_e5m2)
Signature · 1 line
2.43.0
author
#18 lore raw

PATCH 18/38 disas/riscv: Support Zvfqwdota8f extension

In reply to Max Chou

Adds support to disassemble Zvfqwdota8f instructions.
- vfqwdota.vv
- vfqwdota.alt.vv

---
 disas/riscv-op.c.inc | 2 ++
 disas/riscv.c        | 9 ++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
disas/riscv-op.c.inc +2 -0
index aeb9423f130..5ba29f52976 100644
@@ -583,6 +583,8 @@ OP(vfnmsac_vf, "vfnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm)
 OP(vfnmsac_vv, "vfnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm)
 OP(vfnmsub_vf, "vfnmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm)
 OP(vfnmsub_vv, "vfnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm)
+OP(vfqwdota_alt_vv, "vfqwdota.alt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
+OP(vfqwdota_vv, "vfqwdota.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vfrdiv_vf, "vfrdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm)
 OP(vfrec7_v, "vfrec7.v", rv_codec_v_r, rv_fmt_vd_vs2)
 OP(vfredmax_vs, "vfredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
disas/riscv.c +6 -3
index 62feb4c653e..0f609cc06b4 100644
@@ -2640,9 +2640,12 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 case 39: return &op_vqwdotas_vv;
                 }
             }
-            if (((inst >> 12) & 0b111) == 1 &&
-                ((inst >> 26) & 0b111111) == 36) {
-                return &op_vfwdota_vv;
+            if (((inst >> 12) & 0b111) == 1) {
+                switch ((inst >> 26) & 0b111111) {
+                case 36: return &op_vfwdota_vv;
+                case 38: return &op_vfqwdota_vv;
+                case 39: return &op_vfqwdota_alt_vv;
+                }
             }
             if (((inst >> 25) & 1) == 1 && ((inst >> 12) & 0b111) == 2) {
                 switch ((inst >> 26) & 0b111111) {
Signature · 1 line
2.43.0
author
#19 lore raw

PATCH 19/38 target/riscv: Add cfg property for Zvqwbdota8i extension

In reply to Max Chou

Add CPU configuration for the Zvqwbdota8i extension which depends on the Zve32x extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 2 ++
 4 files changed, 10 insertions(+)
target/riscv/cpu.c +2 -0
index c28e674bd3a..516e7187497 100644
@@ -254,6 +254,8 @@ 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_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwbdota8i, PRIV_VERSION_1_13_0,
+                                    ext_zvqwbdota8i),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwdota16i, PRIV_VERSION_1_13_0,
                                     ext_zvqwdota16i),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwdota8i, PRIV_VERSION_1_13_0,
target/riscv/cpu_cfg_fields.h.inc +1 -0
index b18abdd8b9b..3d822432d48 100644
@@ -108,6 +108,7 @@ BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
 BOOL_FIELD(ext_zvfqwdota8f)
 BOOL_FIELD(ext_zvfwdota16bf)
+BOOL_FIELD(ext_zvqwbdota8i)
 BOOL_FIELD(ext_zvqwdota16i)
 BOOL_FIELD(ext_zvqwdota8i)
 BOOL_FIELD(ext_sdext)
target/riscv/tcg/tcg-cpu.c +5 -0
index 72ce0b4fbd0..782e38b608e 100644
@@ -711,6 +711,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvqwbdota8i && !cpu->cfg.ext_zve32x) {
+        error_setg(errp, "Zvqwbdota8i extension depends on Zve32x extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +2 -0
index 4b16ee9d1d7..7cb8dd0a07d 100644
@@ -42,6 +42,7 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
     if (riscv_cpu_cfg(env)->ext_zvfbfa ||
         riscv_cpu_cfg(env)->ext_zvfqwdota8f ||
         riscv_cpu_cfg(env)->ext_zvfwdota16bf ||
+        riscv_cpu_cfg(env)->ext_zvqwbdota8i ||
         riscv_cpu_cfg(env)->ext_zvqwdota16i ||
         riscv_cpu_cfg(env)->ext_zvqwdota8i) {
         reserved = vtype & MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT,
@@ -94,6 +95,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
     case MO_8:
         ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
                         cpu->cfg.ext_zvfqwdota8f ||
+                        cpu->cfg.ext_zvqwbdota8i ||
                         cpu->cfg.ext_zvqwdota8i);
         break;
     case MO_16:
Signature · 1 line
2.43.0
author
#20 lore raw

PATCH 20/38 target/riscv: Add implied rules for Zvqwbdota8i extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvqwbdota8i extension recursively.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 516e7187497..b8fc8d2ac8a 100644
@@ -2918,6 +2918,15 @@ static RISCVCPUImpliedExtsRule ZVFWDOTA16BF_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVQWBDOTA8I_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvqwbdota8i),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve32x),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVKN_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvkn),
     .implied_multi_exts = {
@@ -3124,6 +3133,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVKS_IMPLIED,
     &ZVKSC_IMPLIED,
     &ZVKSG_IMPLIED,
+    &ZVQWBDOTA8I_IMPLIED,
     &ZVQWDOTA16I_IMPLIED,
     &ZVQWDOTA8I_IMPLIED,
     &SHA_IMPLIED,
Signature · 1 line
2.43.0
author
#21 lore raw

PATCH 21/38 target/riscv: rvv: Implement Zvqwbdota8i instructions

In reply to Max Chou

Implements the Zvqwbdota8i INT8 dot-product instructions:
- vqwbdotau.vv
- vqwbdotas.vv

The vqwbdotau.vv and vqwbdotas.vv instructions perform batched dot-product operations on 8-bit integer vectors, computing 8 parallel dot products and accumulating into 32-bit integers.

---
 target/riscv/helper.h                       |  4 ++
 target/riscv/insn32.decode                  |  4 ++
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 79 +++++++++++++++++++++
 target/riscv/tcg/vector_helper.c            | 13 ++++
 4 files changed, 100 insertions(+)
target/riscv/helper.h +4 -0
index 5dfbe59ea0d..81f9db1a801 100644
@@ -1400,6 +1400,10 @@ DEF_HELPER_6(vfwdota_vv, void, ptr, ptr, ptr, ptr, env, i32)
 DEF_HELPER_6(vfqwdota_vv, void, ptr, ptr, ptr, ptr, env, i32)
 DEF_HELPER_6(vfqwdota_alt_vv, void, ptr, ptr, ptr, ptr, env, i32)
 
+/* Zvqwbdota8i - 8-bit integer batched dot product */
+DEF_HELPER_7(vqwbdotau_vv_b, void, ptr, ptr, ptr, ptr, i32, env, i32)
+DEF_HELPER_7(vqwbdotas_vv_b, void, ptr, ptr, ptr, ptr, i32, env, i32)
+
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
 DEF_HELPER_5(sf_vqmacc_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +4 -0
index def5785f8e2..bf325229100 100644
@@ -1108,3 +1108,7 @@ vfwdota_vv  100100 . ..... ..... 001 ..... 1110111 @r_vm
 # *** Zvfqwdota8f OCP FP8 Dot-Product Extension ***
 vfqwdota_vv     100110 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwdota_alt_vv 100111 . ..... ..... 001 ..... 1110111 @r_vm
+
+# *** Zvqwbdota8i 8-bit Integer Batched Dot-Product Extension ***
+vqwbdotau_vv  101110 . ..... ..... 000 ..... 1110111 @r_vm
+vqwbdotas_vv  101111 . ..... ..... 000 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +79 -0

82 lines not on this page · raw message

target/riscv/tcg/vector_helper.c +13 -0
index 7cb8dd0a07d..0e3ed41d433 100644
@@ -6053,6 +6053,19 @@ GEN_VEXT_ZVDOTA_INT(vqwdotas_vv_b, do_dotas_b)
 GEN_VEXT_ZVDOTA_INT(vqwdotau_vv_h, do_dotau_h)
 GEN_VEXT_ZVDOTA_INT(vqwdotas_vv_h, do_dotas_h)
 
+/*
+ * Zvqwbdota8i - 8-bit integer batched dot product
+ */
+#define GEN_VEXT_ZVBDOTA_INT(NAME, OP)                               \
+void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,          \
+                  uint32_t ci, CPURISCVState *env, uint32_t desc)    \
+{                                                                    \
+    OP(vd, v0, vs1, vs2, ci, true, env, desc);                       \
+}
+
+GEN_VEXT_ZVBDOTA_INT(vqwbdotau_vv_b, do_dotau_b)
+GEN_VEXT_ZVBDOTA_INT(vqwbdotas_vv_b, do_dotas_b)
+
 static inline float32 op_rvbna_bf16(const bfloat16 *a, const bfloat16 *b,
                                     uint32_t n_prod, bool altfmt,
                                     float_status *status)
Signature · 1 line
2.43.0
author
#22 lore raw

PATCH 22/38 disas/riscv: Support Zvqwbdota8i extension

In reply to Max Chou

Adds support to disassemble Zvqwbdota8i instructions.
- vqwbdotau.vv
- vqwbdotas.vv

Zvbdota instructions encode the batch-column immediate (ci) in rs2[2:0] and the vs2 base-register group in rs2[7:3].
Add rv_codec_v_r_ci that splits rs2 into dec->rs2 (base register) and dec->imm (ci), and add rv_fmt_vd_vs2_vs1_ci_vm to print them separately.

---
 disas/riscv-op.c.inc | 2 ++
 disas/riscv.c        | 9 +++++++++
 disas/riscv.h        | 2 ++
 3 files changed, 13 insertions(+)
disas/riscv-op.c.inc +2 -0
index 5ba29f52976..bb01ebb8a6c 100644
@@ -773,6 +773,8 @@ OP(vnsrl_wx, "vnsrl.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm)
 OP(vor_vi, "vor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm)
 OP(vor_vv, "vor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vor_vx, "vor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm)
+OP(vqwbdotas_vv, "vqwbdotas.vv", rv_codec_v_r_ci, rv_fmt_vd_vs2_vs1_ci_vm)
+OP(vqwbdotau_vv, "vqwbdotau.vv", rv_codec_v_r_ci, rv_fmt_vd_vs2_vs1_ci_vm)
 OP(vqwdotas_vv, "vqwdotas.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vqwdotau_vv, "vqwdotau.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vredand_vs, "vredand.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
disas/riscv.c +9 -0
index 0f609cc06b4..0534b8f4d64 100644
@@ -2638,6 +2638,8 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 switch ((inst >> 26) & 0b111111) {
                 case 38: return &op_vqwdotau_vv;
                 case 39: return &op_vqwdotas_vv;
+                case 46: return &op_vqwbdotau_vv;
+                case 47: return &op_vqwbdotas_vv;
                 }
             }
             if (((inst >> 12) & 0b111) == 1) {
@@ -2999,6 +3001,13 @@ static void decode_inst_operands(rv_decode *dec, rv_isa isa,
         dec->rs2 = operand_rs2(inst);
         dec->vm = operand_vm(inst);
         break;
+    case rv_codec_v_r_ci:
+        dec->rd = operand_rd(inst);
+        dec->rs1 = operand_rs1(inst);
+        dec->rs2 = operand_rs2(inst) & ~0x7;
+        dec->imm = (operand_rs2(inst) & 0x7) << 3;
+        dec->vm = operand_vm(inst);
+        break;
     case rv_codec_v_ldst:
         dec->rd = operand_rd(inst);
         dec->rs1 = operand_rs1(inst);
disas/riscv.h +2 -0
index 4f1ffc4ae02..34050583c96 100644
@@ -138,6 +138,7 @@ typedef enum {
     rv_codec_k_bs,
     rv_codec_k_rnum,
     rv_codec_v_r,
+    rv_codec_v_r_ci,
     rv_codec_v_ldst,
     rv_codec_v_i,
     rv_codec_v_i_u,
@@ -254,6 +255,7 @@ typedef struct {
 #define rv_fmt_vd_vs2_vs1             "O\tD,F,E"
 #define rv_fmt_vd_vs2_vs1_vl          "O\tD,F,El"
 #define rv_fmt_vd_vs2_vs1_vm          "O\tD,F,Em"
+#define rv_fmt_vd_vs2_vs1_ci_vm       "O\tD,F,E,im"
 #define rv_fmt_vd_vs2_rs1_vl          "O\tD,F,1l"
 #define rv_fmt_vd_vs2_fs1_vl          "O\tD,F,4l"
 #define rv_fmt_vd_vs2_rs1_vm          "O\tD,F,1m"
Signature · 1 line
2.43.0
author
#23 lore raw

PATCH 23/38 target/riscv: Add cfg property for Zvqwbdota16i extension

In reply to Max Chou

Add CPU configuration property of Zvqwbdota16i extension which depends on the Zve64x extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 2 ++
 4 files changed, 10 insertions(+)
target/riscv/cpu.c +2 -0
index b8fc8d2ac8a..8f0908db28d 100644
@@ -254,6 +254,8 @@ 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_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwbdota16i, PRIV_VERSION_1_13_0,
+                                    ext_zvqwbdota16i),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwbdota8i, PRIV_VERSION_1_13_0,
                                     ext_zvqwbdota8i),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvqwdota16i, PRIV_VERSION_1_13_0,
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 3d822432d48..83a3d8a7f9d 100644
@@ -108,6 +108,7 @@ BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
 BOOL_FIELD(ext_zvfqwdota8f)
 BOOL_FIELD(ext_zvfwdota16bf)
+BOOL_FIELD(ext_zvqwbdota16i)
 BOOL_FIELD(ext_zvqwbdota8i)
 BOOL_FIELD(ext_zvqwdota16i)
 BOOL_FIELD(ext_zvqwdota8i)
target/riscv/tcg/tcg-cpu.c +5 -0
index 782e38b608e..8735cf94f35 100644
@@ -716,6 +716,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvqwbdota16i && !cpu->cfg.ext_zve64x) {
+        error_setg(errp, "Zvqwbdota16i extension depends on Zve64x extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +2 -0
index 0e3ed41d433..0c876377b50 100644
@@ -42,6 +42,7 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
     if (riscv_cpu_cfg(env)->ext_zvfbfa ||
         riscv_cpu_cfg(env)->ext_zvfqwdota8f ||
         riscv_cpu_cfg(env)->ext_zvfwdota16bf ||
+        riscv_cpu_cfg(env)->ext_zvqwbdota16i ||
         riscv_cpu_cfg(env)->ext_zvqwbdota8i ||
         riscv_cpu_cfg(env)->ext_zvqwdota16i ||
         riscv_cpu_cfg(env)->ext_zvqwdota8i) {
@@ -101,6 +102,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
     case MO_16:
         ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
                         cpu->cfg.ext_zvfwdota16bf ||
+                        cpu->cfg.ext_zvqwbdota16i ||
                         cpu->cfg.ext_zvqwdota16i);
         break;
     default:
Signature · 1 line
2.43.0
author
#24 lore raw

PATCH 24/38 target/riscv: Add implied rules for Zvqwbdota16i extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvqwbdota16i extension recursively.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 8f0908db28d..48278cf7fcc 100644
@@ -2929,6 +2929,15 @@ static RISCVCPUImpliedExtsRule ZVQWBDOTA8I_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVQWBDOTA16I_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvqwbdota16i),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve64x),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVKN_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvkn),
     .implied_multi_exts = {
@@ -3135,6 +3144,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVKS_IMPLIED,
     &ZVKSC_IMPLIED,
     &ZVKSG_IMPLIED,
+    &ZVQWBDOTA16I_IMPLIED,
     &ZVQWBDOTA8I_IMPLIED,
     &ZVQWDOTA16I_IMPLIED,
     &ZVQWDOTA8I_IMPLIED,
Signature · 1 line
2.43.0
author
#25 lore raw

PATCH 25/38 target/riscv: rvv: Implement Zvqwbdota16i instructions

In reply to Max Chou

Extend the vqwbdotau.vv and vqwbdotas.vv instructions to support both 8-bit (Zvqwbdota8i) and 16-bit (Zvqwbdota16i) batched dot-product operations.

---
 target/riscv/helper.h                       | 4 +++-
 target/riscv/insn32.decode                  | 2 +-
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 7 ++++---
 target/riscv/tcg/vector_helper.c            | 4 +++-
 4 files changed, 11 insertions(+), 6 deletions(-)
target/riscv/helper.h +3 -1
index 81f9db1a801..8493b140059 100644
@@ -1400,9 +1400,11 @@ DEF_HELPER_6(vfwdota_vv, void, ptr, ptr, ptr, ptr, env, i32)
 DEF_HELPER_6(vfqwdota_vv, void, ptr, ptr, ptr, ptr, env, i32)
 DEF_HELPER_6(vfqwdota_alt_vv, void, ptr, ptr, ptr, ptr, env, i32)
 
-/* Zvqwbdota8i - 8-bit integer batched dot product */
+/* Zvqwbdota8i/Zvqwbdota16i - 8/16-bit integer batched dot product */
 DEF_HELPER_7(vqwbdotau_vv_b, void, ptr, ptr, ptr, ptr, i32, env, i32)
 DEF_HELPER_7(vqwbdotas_vv_b, void, ptr, ptr, ptr, ptr, i32, env, i32)
+DEF_HELPER_7(vqwbdotau_vv_h, void, ptr, ptr, ptr, ptr, i32, env, i32)
+DEF_HELPER_7(vqwbdotas_vv_h, void, ptr, ptr, ptr, ptr, i32, env, i32)
 
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +1 -1
index bf325229100..8a06547a570 100644
@@ -1109,6 +1109,6 @@ vfwdota_vv  100100 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwdota_vv     100110 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwdota_alt_vv 100111 . ..... ..... 001 ..... 1110111 @r_vm
 
-# *** Zvqwbdota8i 8-bit Integer Batched Dot-Product Extension ***
+# *** Zvqwbdota8i/Zvqwbdota16i Integer Batched Dot-Product Extension ***
 vqwbdotau_vv  101110 . ..... ..... 000 ..... 1110111 @r_vm
 vqwbdotas_vv  101111 . ..... ..... 000 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +4 -3
index 6e1fc5fde4b..7d5bb1a1139 100644
@@ -4252,7 +4252,7 @@ static bool zvbdota_trans(DisasContext *s, arg_rmrr *a, int32_t vd_eew,
 static bool trans_##NAME(DisasContext *s, arg_rmrr *a)       \
 {                                                            \
     static gen_helper_zvbdota * const fns[2] = {             \
-        gen_helper_##NAME##_b, NULL,                         \
+        gen_helper_##NAME##_b, gen_helper_##NAME##_h,        \
     };                                                       \
     if (CHECK(s, a)) {                                       \
         return zvbdota_trans(s, a, s->sew + 2, fns[s->sew]); \
@@ -4280,13 +4280,14 @@ static bool vext_zvbdota_base_check(DisasContext *s, arg_rmrr * a,
            vext_check_input_eew(s, a->rs1, s->sew, rs2, s->sew, a->vm);
 }
 
-/* Zvqwbdota8i: 8-bit integer batched dot-product extension */
+/* Zvqwbdota8i/Zvqwbdota16i - 8/16-bit integer batched dot-product extension */
 static bool vext_vqwbdota_check(DisasContext *s, arg_rmrr *a)
 {
     int32_t sew = s->sew;
     int32_t vd_eew = sew + 2;
     return vext_zvbdota_base_check(s, a, vd_eew) &&
-           (s->cfg_ptr->ext_zvqwbdota8i && sew == MO_8);
+           ((s->cfg_ptr->ext_zvqwbdota8i && sew == MO_8) ||
+            (s->cfg_ptr->ext_zvqwbdota16i && s->sew == MO_16));
 }
 
 GEN_ZVBDOTA_INT_TRANS(vqwbdotau_vv, vext_vqwbdota_check)
target/riscv/tcg/vector_helper.c +3 -1
index 0c876377b50..3dc9d2feba1 100644
@@ -6056,7 +6056,7 @@ GEN_VEXT_ZVDOTA_INT(vqwdotau_vv_h, do_dotau_h)
 GEN_VEXT_ZVDOTA_INT(vqwdotas_vv_h, do_dotas_h)
 
 /*
- * Zvqwbdota8i - 8-bit integer batched dot product
+ * Zvqwbdota8i/Zvqwbdota16i - 8/16-bit integer batched dot product
  */
 #define GEN_VEXT_ZVBDOTA_INT(NAME, OP)                               \
 void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,          \
@@ -6067,6 +6067,8 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,          \
 
 GEN_VEXT_ZVBDOTA_INT(vqwbdotau_vv_b, do_dotau_b)
 GEN_VEXT_ZVBDOTA_INT(vqwbdotas_vv_b, do_dotas_b)
+GEN_VEXT_ZVBDOTA_INT(vqwbdotau_vv_h, do_dotau_h)
+GEN_VEXT_ZVBDOTA_INT(vqwbdotas_vv_h, do_dotas_h)
 
 static inline float32 op_rvbna_bf16(const bfloat16 *a, const bfloat16 *b,
                                     uint32_t n_prod, bool altfmt,
Signature · 1 line
2.43.0
author
#26 lore raw

PATCH 26/38 target/riscv: Add cfg property for Zvfwbdota16bf extension

In reply to Max Chou

Add CPU configuration property of Zvfwbdota16bf extension which depends on the Zve32f extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 2 ++
 4 files changed, 10 insertions(+)
target/riscv/cpu.c +2 -0
index 48278cf7fcc..49ee8b3d1cb 100644
@@ -238,6 +238,8 @@ const RISCVIsaExtData isa_edata_arr[] = {
     ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfqwdota8f, PRIV_VERSION_1_13_0,
                                     ext_zvfqwdota8f),
+    ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfwbdota16bf, PRIV_VERSION_1_13_0,
+                                    ext_zvfwbdota16bf),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfwdota16bf, PRIV_VERSION_1_13_0,
                                     ext_zvfwdota16bf),
     ISA_EXT_DATA_ENTRY(zvkb, PRIV_VERSION_1_12_0, ext_zvkb),
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 83a3d8a7f9d..80750db1ccd 100644
@@ -107,6 +107,7 @@ BOOL_FIELD(ext_zvfbfwma)
 BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
 BOOL_FIELD(ext_zvfqwdota8f)
+BOOL_FIELD(ext_zvfwbdota16bf)
 BOOL_FIELD(ext_zvfwdota16bf)
 BOOL_FIELD(ext_zvqwbdota16i)
 BOOL_FIELD(ext_zvqwbdota8i)
target/riscv/tcg/tcg-cpu.c +5 -0
index 8735cf94f35..8684e4c709c 100644
@@ -721,6 +721,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvfwbdota16bf && !cpu->cfg.ext_zve32f) {
+        error_setg(errp, "Zvfwbdota16bf extension depends on Zve32f extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +2 -0
index 3dc9d2feba1..6e4c3196f9f 100644
@@ -41,6 +41,7 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
 
     if (riscv_cpu_cfg(env)->ext_zvfbfa ||
         riscv_cpu_cfg(env)->ext_zvfqwdota8f ||
+        riscv_cpu_cfg(env)->ext_zvfwbdota16bf ||
         riscv_cpu_cfg(env)->ext_zvfwdota16bf ||
         riscv_cpu_cfg(env)->ext_zvqwbdota16i ||
         riscv_cpu_cfg(env)->ext_zvqwbdota8i ||
@@ -101,6 +102,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
         break;
     case MO_16:
         ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
+                        cpu->cfg.ext_zvfwbdota16bf ||
                         cpu->cfg.ext_zvfwdota16bf ||
                         cpu->cfg.ext_zvqwbdota16i ||
                         cpu->cfg.ext_zvqwdota16i);
Signature · 1 line
2.43.0
author
#27 lore raw

PATCH 27/38 target/riscv: Add implied rules for Zvfwbdota16bf extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvfwbdota16bf extension recursively.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 49ee8b3d1cb..69997c5d8b4 100644
@@ -2913,6 +2913,15 @@ static RISCVCPUImpliedExtsRule ZVFQWDOTA8F_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVFWBDOTA16BF_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvfwbdota16bf),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve32f),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVFWDOTA16BF_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvfwdota16bf),
     .implied_multi_exts = {
@@ -3138,6 +3147,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVFH_IMPLIED,
     &ZVFHMIN_IMPLIED,
     &ZVFQWDOTA8F_IMPLIED,
+    &ZVFWBDOTA16BF_IMPLIED,
     &ZVFWDOTA16BF_IMPLIED,
     &ZVKN_IMPLIED,
     &ZVKNC_IMPLIED,
Signature · 1 line
2.43.0
author
#28 lore raw

PATCH 28/38 target/riscv: rvv: Implement Zvfwbdota16bf instruction

In reply to Max Chou

Implement the vfwbdota.vv instruction from the Zvfwbdota16bf extension.
This instruction performs a batched dot-product operation on BF16 vectors, accumulating into FP32

---
 target/riscv/helper.h                       |  3 +++
 target/riscv/insn32.decode                  |  3 +++
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 22 +++++++++++++++++++++
 target/riscv/tcg/vector_helper.c            | 12 +++++++++++
 4 files changed, 40 insertions(+)
target/riscv/helper.h +3 -0
index 8493b140059..a486f1b77fb 100644
@@ -1406,6 +1406,9 @@ DEF_HELPER_7(vqwbdotas_vv_b, void, ptr, ptr, ptr, ptr, i32, env, i32)
 DEF_HELPER_7(vqwbdotau_vv_h, void, ptr, ptr, ptr, ptr, i32, env, i32)
 DEF_HELPER_7(vqwbdotas_vv_h, void, ptr, ptr, ptr, ptr, i32, env, i32)
 
+/* Zvfwbdota16bf - BF16 batched dot product */
+DEF_HELPER_7(vfwbdota_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
+
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
 DEF_HELPER_5(sf_vqmacc_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +3 -0
index 8a06547a570..00ed64b73fd 100644
@@ -1105,6 +1105,9 @@ vqwdotas_vv  100111 . ..... ..... 000 ..... 1110111 @r_vm
 # *** Zvfwdota16bf BF16 Dot-Product Extension ***
 vfwdota_vv  100100 . ..... ..... 001 ..... 1110111 @r_vm
 
+# *** Zvfwbdota16bf BF16 Batched Dot-Product Extension ***
+vfwbdota_vv 101100 . ..... ..... 001 ..... 1110111 @r_vm
+
 # *** Zvfqwdota8f OCP FP8 Dot-Product Extension ***
 vfqwdota_vv     100110 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwdota_alt_vv 100111 . ..... ..... 001 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +22 -0
index 7d5bb1a1139..4eb12f62d4b 100644
@@ -4292,3 +4292,25 @@ static bool vext_vqwbdota_check(DisasContext *s, arg_rmrr *a)
 
 GEN_ZVBDOTA_INT_TRANS(vqwbdotau_vv, vext_vqwbdota_check)
 GEN_ZVBDOTA_INT_TRANS(vqwbdotas_vv, vext_vqwbdota_check)
+
+#define GEN_ZVBDOTA_FP_TRANS(NAME, CHECK, EEW_VD)                \
+static bool trans_##NAME(DisasContext *s, arg_rmrr * a)          \
+{                                                                \
+    if (CHECK(s, a)) {                                           \
+        gen_set_rm(s, RISCV_FRM_DYN);                            \
+        return zvbdota_trans(s, a, EEW_VD, gen_helper_##NAME);   \
+    }                                                            \
+    return false;                                                \
+}
+
+/* Zvfwbdota16bf - BF16 batched dot-product extension */
+static bool vext_vfwbdota_check(DisasContext *s, arg_rmrr * a)
+{
+    int32_t sew = s->sew;
+    int32_t vd_eew = sew + 1;
+    return s->mstatus_fs != EXT_STATUS_DISABLED &&
+           vext_zvbdota_base_check(s, a, vd_eew) &&
+           (s->cfg_ptr->ext_zvfwbdota16bf && s->sew == MO_16 && s->altfmt == 1);
+}
+
+GEN_ZVBDOTA_FP_TRANS(vfwbdota_vv, vext_vfwbdota_check, MO_32)
target/riscv/tcg/vector_helper.c +12 -0
index 6e4c3196f9f..855b5b1d734 100644
@@ -6178,3 +6178,15 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,  \
 GEN_VEXT_ZVDOTA_FP(vfwdota_vv, do_dota_bf16)
 GEN_VEXT_ZVDOTA_FP(vfqwdota_vv, do_dota_e4m3)
 GEN_VEXT_ZVDOTA_FP(vfqwdota_alt_vv, do_dota_e5m2)
+
+/*
+ * Zvfwbdota16bf - BF16 batched dot product
+ */
+#define GEN_VEXT_ZVBDOTA_FP(NAME, OP)                                \
+void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,          \
+                  uint32_t ci, CPURISCVState *env, uint32_t desc)    \
+{                                                                    \
+    OP(vd, v0, vs1, vs2, ci, true, env, desc);                       \
+}
+
+GEN_VEXT_ZVBDOTA_FP(vfwbdota_vv, do_dota_bf16)
Signature · 1 line
2.43.0
author
#29 lore raw

PATCH 29/38 disas/riscv: Support Zvfwbdota16bf extension

In reply to Max Chou

Adds support to disassemble Zvfwbdota16bf instructions.
- vfwbdota.vv

---
 disas/riscv-op.c.inc | 1 +
 disas/riscv.c        | 1 +
 2 files changed, 2 insertions(+)
disas/riscv-op.c.inc +1 -0
index bb01ebb8a6c..b24ffb45d8e 100644
@@ -608,6 +608,7 @@ OP(vfwadd_vf, "vfwadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm)
 OP(vfwadd_vv, "vfwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vfwadd_wf, "vfwadd.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm)
 OP(vfwadd_wv, "vfwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
+OP(vfwbdota_vv, "vfwbdota.vv", rv_codec_v_r_ci, rv_fmt_vd_vs2_vs1_ci_vm)
 OP(vfwcvt_f_f_v, "vfwcvt.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
 OP(vfwcvt_f_x_v, "vfwcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
 OP(vfwcvt_f_xu_v, "vfwcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
disas/riscv.c +1 -0
index 0534b8f4d64..af41c2204f5 100644
@@ -2647,6 +2647,7 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 case 36: return &op_vfwdota_vv;
                 case 38: return &op_vfqwdota_vv;
                 case 39: return &op_vfqwdota_alt_vv;
+                case 44: return &op_vfwbdota_vv;
                 }
             }
             if (((inst >> 25) & 1) == 1 && ((inst >> 12) & 0b111) == 2) {
Signature · 1 line
2.43.0
author
#30 lore raw

PATCH 30/38 target/riscv: Add cfg property for Zvfqwbdota8f extension

In reply to Max Chou

Add CPU configuration property of Zvfqwbdota8f extension which depends on the Zve32f extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 target/riscv/tcg/vector_helper.c  | 2 ++
 4 files changed, 10 insertions(+)
target/riscv/cpu.c +2 -0
index 69997c5d8b4..2e1fcd3d1ba 100644
@@ -236,6 +236,8 @@ const RISCVIsaExtData isa_edata_arr[] = {
     ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma),
     ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),
     ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin),
+    ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfqwbdota8f, PRIV_VERSION_1_13_0,
+                                    ext_zvfqwbdota8f),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfqwdota8f, PRIV_VERSION_1_13_0,
                                     ext_zvfqwdota8f),
     ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfwbdota16bf, PRIV_VERSION_1_13_0,
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 80750db1ccd..0385b58de0a 100644
@@ -106,6 +106,7 @@ BOOL_FIELD(ext_zvfbfmin)
 BOOL_FIELD(ext_zvfbfwma)
 BOOL_FIELD(ext_zvfh)
 BOOL_FIELD(ext_zvfhmin)
+BOOL_FIELD(ext_zvfqwbdota8f)
 BOOL_FIELD(ext_zvfqwdota8f)
 BOOL_FIELD(ext_zvfwbdota16bf)
 BOOL_FIELD(ext_zvfwdota16bf)
target/riscv/tcg/tcg-cpu.c +5 -0
index 8684e4c709c..a52637f5ca9 100644
@@ -726,6 +726,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvfqwbdota8f && !cpu->cfg.ext_zve32f) {
+        error_setg(errp, "Zvfqwbdota8f extension depends on Zve32f extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
target/riscv/tcg/vector_helper.c +2 -0
index 855b5b1d734..40da1e43546 100644
@@ -40,6 +40,7 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)
     target_ulong reserved = 0;
 
     if (riscv_cpu_cfg(env)->ext_zvfbfa ||
+        riscv_cpu_cfg(env)->ext_zvfqwbdota8f ||
         riscv_cpu_cfg(env)->ext_zvfqwdota8f ||
         riscv_cpu_cfg(env)->ext_zvfwbdota16bf ||
         riscv_cpu_cfg(env)->ext_zvfwdota16bf ||
@@ -96,6 +97,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
     switch (vsew) {
     case MO_8:
         ill_altfmt &= !(cpu->cfg.ext_zvfbfa ||
+                        cpu->cfg.ext_zvfqwbdota8f ||
                         cpu->cfg.ext_zvfqwdota8f ||
                         cpu->cfg.ext_zvqwbdota8i ||
                         cpu->cfg.ext_zvqwdota8i);
Signature · 1 line
2.43.0
author
#31 lore raw

PATCH 31/38 target/riscv: Add implied rules for Zvfqwbdota8f extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvfqwbdota8f extension recursively.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 2e1fcd3d1ba..085f3c1e986 100644
@@ -2915,6 +2915,15 @@ static RISCVCPUImpliedExtsRule ZVFQWDOTA8F_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVFQWBDOTA8F_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvfqwbdota8f),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve32f),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVFWBDOTA16BF_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvfwbdota16bf),
     .implied_multi_exts = {
@@ -3148,6 +3157,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVFBFWMA_IMPLIED,
     &ZVFH_IMPLIED,
     &ZVFHMIN_IMPLIED,
+    &ZVFQWBDOTA8F_IMPLIED,
     &ZVFQWDOTA8F_IMPLIED,
     &ZVFWBDOTA16BF_IMPLIED,
     &ZVFWDOTA16BF_IMPLIED,
Signature · 1 line
2.43.0
author
#32 lore raw

PATCH 32/38 target/riscv: rvv: Implement Zvfqwbdota8f instructions

In reply to Max Chou

Support the Zvfqwbdota8f OCP FP8 batched dot-product instructions. These instructions perform 8 parallel dot products between OCP FP8 vectors, accumulating into FP32 elements.

---
 target/riscv/helper.h                       |  4 ++++
 target/riscv/insn32.decode                  |  4 ++++
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 13 +++++++++++++
 target/riscv/tcg/vector_helper.c            |  4 +++-
 4 files changed, 24 insertions(+), 1 deletion(-)
target/riscv/helper.h +4 -0
index a486f1b77fb..e0dbf60b3aa 100644
@@ -1409,6 +1409,10 @@ DEF_HELPER_7(vqwbdotas_vv_h, void, ptr, ptr, ptr, ptr, i32, env, i32)
 /* Zvfwbdota16bf - BF16 batched dot product */
 DEF_HELPER_7(vfwbdota_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
 
+/* Zvfqwbdota8f - OCP FP8 batched dot product */
+DEF_HELPER_7(vfqwbdota_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
+DEF_HELPER_7(vfqwbdota_alt_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
+
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
 DEF_HELPER_5(sf_vqmacc_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +4 -0
index 00ed64b73fd..48597915f7b 100644
@@ -1108,6 +1108,10 @@ vfwdota_vv  100100 . ..... ..... 001 ..... 1110111 @r_vm
 # *** Zvfwbdota16bf BF16 Batched Dot-Product Extension ***
 vfwbdota_vv 101100 . ..... ..... 001 ..... 1110111 @r_vm
 
+# *** Zvfqwbdota8f OCP FP8 Batched Dot-Product Extension ***
+vfqwbdota_vv     101110 . ..... ..... 001 ..... 1110111 @r_vm
+vfqwbdota_alt_vv 101111 . ..... ..... 001 ..... 1110111 @r_vm
+
 # *** Zvfqwdota8f OCP FP8 Dot-Product Extension ***
 vfqwdota_vv     100110 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwdota_alt_vv 100111 . ..... ..... 001 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +13 -0
index 4eb12f62d4b..6f8f283fc16 100644
@@ -4314,3 +4314,16 @@ static bool vext_vfwbdota_check(DisasContext *s, arg_rmrr * a)
 }
 
 GEN_ZVBDOTA_FP_TRANS(vfwbdota_vv, vext_vfwbdota_check, MO_32)
+
+/* Zvfqwbdota8f - OCP FP8 batched dot-product extension */
+static bool vext_vfqwbdota_check(DisasContext *s, arg_rmrr * a)
+{
+    int32_t sew = s->sew;
+    int32_t vd_eew = sew + 2;
+    return s->mstatus_fs != EXT_STATUS_DISABLED &&
+           vext_zvbdota_base_check(s, a, vd_eew) &&
+           (s->cfg_ptr->ext_zvfqwbdota8f && sew == MO_8);
+}
+
+GEN_ZVBDOTA_FP_TRANS(vfqwbdota_vv, vext_vfqwbdota_check, MO_32)
+GEN_ZVBDOTA_FP_TRANS(vfqwbdota_alt_vv, vext_vfqwbdota_check, MO_32)
target/riscv/tcg/vector_helper.c +3 -1
index 40da1e43546..5210fb5d3c0 100644
@@ -6182,7 +6182,7 @@ GEN_VEXT_ZVDOTA_FP(vfqwdota_vv, do_dota_e4m3)
 GEN_VEXT_ZVDOTA_FP(vfqwdota_alt_vv, do_dota_e5m2)
 
 /*
- * Zvfwbdota16bf - BF16 batched dot product
+ * Zvfwbdota16bf/Zvfqwbdota8f - BF16/OFP8 batched dot product
  */
 #define GEN_VEXT_ZVBDOTA_FP(NAME, OP)                                \
 void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,          \
@@ -6192,3 +6192,5 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2,          \
 }
 
 GEN_VEXT_ZVBDOTA_FP(vfwbdota_vv, do_dota_bf16)
+GEN_VEXT_ZVBDOTA_FP(vfqwbdota_vv, do_dota_e4m3)
+GEN_VEXT_ZVBDOTA_FP(vfqwbdota_alt_vv, do_dota_e5m2)
Signature · 1 line
2.43.0
author
#33 lore raw

PATCH 33/38 disas/riscv: Support Zvfqwbdota8f extension

In reply to Max Chou

Adds support to disassemble Zvfqwbdota8f instructions.
- vfqwbdota.vv
- vfqwbdota.alt.vv

---
 disas/riscv-op.c.inc | 3 +++
 disas/riscv.c        | 2 ++
 2 files changed, 5 insertions(+)
disas/riscv-op.c.inc +3 -0
index b24ffb45d8e..58f6ddac35a 100644
@@ -583,6 +583,9 @@ OP(vfnmsac_vf, "vfnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm)
 OP(vfnmsac_vv, "vfnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm)
 OP(vfnmsub_vf, "vfnmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm)
 OP(vfnmsub_vv, "vfnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm)
+OP(vfqwbdota_alt_vv, "vfqwbdota.alt.vv", rv_codec_v_r_ci,
+   rv_fmt_vd_vs2_vs1_ci_vm)
+OP(vfqwbdota_vv, "vfqwbdota.vv", rv_codec_v_r_ci, rv_fmt_vd_vs2_vs1_ci_vm)
 OP(vfqwdota_alt_vv, "vfqwdota.alt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vfqwdota_vv, "vfqwdota.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vfrdiv_vf, "vfrdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm)
disas/riscv.c +2 -0
index af41c2204f5..a124cbb4bbe 100644
@@ -2648,6 +2648,8 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 case 38: return &op_vfqwdota_vv;
                 case 39: return &op_vfqwdota_alt_vv;
                 case 44: return &op_vfwbdota_vv;
+                case 46: return &op_vfqwbdota_vv;
+                case 47: return &op_vfqwbdota_alt_vv;
                 }
             }
             if (((inst >> 25) & 1) == 1 && ((inst >> 12) & 0b111) == 2) {
Signature · 1 line
2.43.0
author
#34 lore raw

PATCH 34/38 target/riscv: Add cfg property for Zvfbdota32f extension

In reply to Max Chou

Add CPU configuration property of Zvfbdota32f extension which depends on the Zve32f extension per the specification.

---
 target/riscv/cpu.c                | 2 ++
 target/riscv/cpu_cfg_fields.h.inc | 1 +
 target/riscv/tcg/tcg-cpu.c        | 5 +++++
 3 files changed, 8 insertions(+)
target/riscv/cpu.c +2 -0
index 085f3c1e986..6a3875f61f0 100644
@@ -231,6 +231,8 @@ const RISCVIsaExtData isa_edata_arr[] = {
     ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f),
     ISA_EXT_DATA_ENTRY(zve64d, PRIV_VERSION_1_10_0, ext_zve64d),
     ISA_EXT_DATA_ENTRY(zve64x, PRIV_VERSION_1_10_0, ext_zve64x),
+    ISA_EXPERIMENTAL_EXT_DATA_ENTRY(zvfbdota32f, PRIV_VERSION_1_13_0,
+                                    ext_zvfbdota32f),
     ISA_EXT_DATA_ENTRY(zvfbfa, PRIV_VERSION_1_13_0, ext_zvfbfa),
     ISA_EXT_DATA_ENTRY(zvfbfmin, PRIV_VERSION_1_12_0, ext_zvfbfmin),
     ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma),
target/riscv/cpu_cfg_fields.h.inc +1 -0
index 0385b58de0a..d85dd2cfd53 100644
@@ -101,6 +101,7 @@ BOOL_FIELD(ext_zvks)
 BOOL_FIELD(ext_zvksc)
 BOOL_FIELD(ext_zvksg)
 BOOL_FIELD(ext_zmmul)
+BOOL_FIELD(ext_zvfbdota32f)
 BOOL_FIELD(ext_zvfbfa)
 BOOL_FIELD(ext_zvfbfmin)
 BOOL_FIELD(ext_zvfbfwma)
target/riscv/tcg/tcg-cpu.c +5 -0
index a52637f5ca9..32b6f9894fc 100644
@@ -731,6 +731,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
         return;
     }
 
+    if (cpu->cfg.ext_zvfbdota32f && !cpu->cfg.ext_zve32f) {
+        error_setg(errp, "Zvfbdota32f extension depends on Zve32f extension");
+        return;
+    }
+
     if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {
         error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx");
         return;
Signature · 1 line
2.43.0
author
#35 lore raw

PATCH 35/38 target/riscv: Add implied rules for Zvfbdota32f extension

In reply to Max Chou

Add implied rules to enable the implied extensions of Zvfbdota32f extension recursively.

---
 target/riscv/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
target/riscv/cpu.c +10 -0
index 6a3875f61f0..9a1c20006b7 100644
@@ -2926,6 +2926,15 @@ static RISCVCPUImpliedExtsRule ZVFQWBDOTA8F_IMPLIED = {
     },
 };
 
+static RISCVCPUImpliedExtsRule ZVFBDOTA32F_IMPLIED = {
+    .ext = CPU_CFG_OFFSET(ext_zvfbdota32f),
+    .implied_multi_exts = {
+        CPU_CFG_OFFSET(ext_zve32f),
+
+        RISCV_IMPLIED_EXTS_RULE_END
+    },
+};
+
 static RISCVCPUImpliedExtsRule ZVFWBDOTA16BF_IMPLIED = {
     .ext = CPU_CFG_OFFSET(ext_zvfwbdota16bf),
     .implied_multi_exts = {
@@ -3154,6 +3163,7 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
     &ZVE64D_IMPLIED,
     &ZVE64F_IMPLIED,
     &ZVE64X_IMPLIED,
+    &ZVFBDOTA32F_IMPLIED,
     &ZVFBFA_IMPLIED,
     &ZVFBFMIN_IMPLIED,
     &ZVFBFWMA_IMPLIED,
Signature · 1 line
2.43.0
author
#36 lore raw

PATCH 36/38 target/riscv: rvv: Implement Zvfbdota32f instructions

In reply to Max Chou

Add support for the Zvfbdota32f FP32 batched dot-product instruction. The vfbdota.vv instruction performs 8 parallel dot products between FP32 vectors, accumulating into FP32 elements.

---
 target/riscv/helper.h                       |  3 ++
 target/riscv/insn32.decode                  |  3 ++
 target/riscv/tcg/insn_trans/trans_rvv.c.inc | 11 +++++
 target/riscv/tcg/vector_helper.c            | 55 +++++++++++++++++++++
 4 files changed, 72 insertions(+)
target/riscv/helper.h +3 -0
index e0dbf60b3aa..f2688f75e96 100644
@@ -1413,6 +1413,9 @@ DEF_HELPER_7(vfwbdota_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
 DEF_HELPER_7(vfqwbdota_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
 DEF_HELPER_7(vfqwbdota_alt_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
 
+/* Zvfbdota32f - FP32 batched dot product */
+DEF_HELPER_7(vfbdota_vv, void, ptr, ptr, ptr, ptr, i32, env, i32)
+
 /* SiFive Custom int8 Matrix-Multiply */
 DEF_HELPER_5(sf_vqmaccu_4x8x4, void, ptr, ptr, ptr, env, i32)
 DEF_HELPER_5(sf_vqmacc_4x8x4, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +3 -0
index 48597915f7b..7fdb7eb54da 100644
@@ -1112,6 +1112,9 @@ vfwbdota_vv 101100 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwbdota_vv     101110 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwbdota_alt_vv 101111 . ..... ..... 001 ..... 1110111 @r_vm
 
+# *** Zvfbdota32f FP32 Batched Dot-Product Extension ***
+vfbdota_vv  101011 . ..... ..... 001 ..... 1110111 @r_vm
+
 # *** Zvfqwdota8f OCP FP8 Dot-Product Extension ***
 vfqwdota_vv     100110 . ..... ..... 001 ..... 1110111 @r_vm
 vfqwdota_alt_vv 100111 . ..... ..... 001 ..... 1110111 @r_vm
target/riscv/tcg/insn_trans/trans_rvv.c.inc +11 -0
index 6f8f283fc16..3ff8174186b 100644
@@ -4327,3 +4327,14 @@ static bool vext_vfqwbdota_check(DisasContext *s, arg_rmrr * a)
 
 GEN_ZVBDOTA_FP_TRANS(vfqwbdota_vv, vext_vfqwbdota_check, MO_32)
 GEN_ZVBDOTA_FP_TRANS(vfqwbdota_alt_vv, vext_vfqwbdota_check, MO_32)
+
+/* Zvfbdota32f - FP32 batched dot-product extension */
+static bool vext_vfbdota_check(DisasContext *s, arg_rmrr * a)
+{
+    int32_t sew = s->sew;
+    return s->mstatus_fs != EXT_STATUS_DISABLED &&
+           vext_zvbdota_base_check(s, a, sew) &&
+           (s->cfg_ptr->ext_zvfbdota32f && sew == MO_32);
+}
+
+GEN_ZVBDOTA_FP_TRANS(vfbdota_vv, vext_vfbdota_check, MO_32)
target/riscv/tcg/vector_helper.c +55 -0

58 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#37 lore raw

PATCH 37/38 disas/riscv: Support Zvfbdota32f extension

In reply to Max Chou

Adds support to disassemble Zvfbdota32f instructions.
- vfbdota.vv

---
 disas/riscv-op.c.inc | 1 +
 disas/riscv.c        | 1 +
 2 files changed, 2 insertions(+)
disas/riscv-op.c.inc +1 -0
index 58f6ddac35a..779fc26a27c 100644
@@ -538,6 +538,7 @@ OP(vdivu_vv, "vdivu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
 OP(vdivu_vx, "vdivu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm)
 OP(vfadd_vf, "vfadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm)
 OP(vfadd_vv, "vfadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm)
+OP(vfbdota_vv, "vfbdota.vv", rv_codec_v_r_ci, rv_fmt_vd_vs2_vs1_ci_vm)
 OP(vfclass_v, "vfclass.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
 OP(vfcvt_f_x_v, "vfcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
 OP(vfcvt_f_xu_v, "vfcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm)
disas/riscv.c +1 -0
index a124cbb4bbe..8330ba34a30 100644
@@ -2647,6 +2647,7 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 case 36: return &op_vfwdota_vv;
                 case 38: return &op_vfqwdota_vv;
                 case 39: return &op_vfqwdota_alt_vv;
+                case 43: return &op_vfbdota_vv;
                 case 44: return &op_vfwbdota_vv;
                 case 46: return &op_vfqwbdota_vv;
                 case 47: return &op_vfqwbdota_alt_vv;
Signature · 1 line
2.43.0
author
#38 lore raw

PATCH 38/38 tests/tcg/riscv64: Add test for Zvdota/Zvbdota extensions

In reply to Max Chou

Add a test that exercises the RISC-V Zvdota/Zvbdota instructions.

---
 tests/tcg/riscv64/system/meson.build |  12 +
 tests/tcg/riscv64/test-zvdota.S      | 343 +++++++++++++++++++++++++++
 2 files changed, 355 insertions(+)
 create mode 100644 tests/tcg/riscv64/test-zvdota.S
tests/tcg/riscv64/system/meson.build +12 -0
index cdd2e99d22a..bb910fd49a9 100644
@@ -116,6 +116,18 @@ tests += {
   }
 }
 
+dot_cpu = ('rv64,v=true,vlen=512' +
+           ',x-zvqwdota8i=true,x-zvqwdota16i=true' +
+           ',x-zvqwbdota8i=true,x-zvqwbdota16i=true' +
+           ',x-zvfwdota16bf=true,x-zvfwbdota16bf=true' +
+           ',x-zvfqwdota8f=true,x-zvfqwbdota8f=true,x-zvfbdota32f=true')
+tests += {
+  'test-zvdota.S': {
+    'cflags': cflags,
+    'qemu_args': ['-cpu', dot_cpu, qemu_args],
+  }
+}
+
 if 'qemu-system-riscv64' in emulators
   tcg_tests += {
     'riscv64-softmmu': {
tests/tcg/riscv64/test-zvdota.S new file +343 -0

343 lines not on this page · raw message

Signature · 1 line
2.43.0