@samitouri / QOSamiQemu / commits / 41084b10c0

target/arm: Implement FMLALB, FMLALT (FP8 to FP16) for SVE

Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260609192110.752384-31-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Richard Henderson committed Jun 9, 2026 at 12:20 UTC 41084b10c0d3c2d5b945f847321a98d52ee0ca41
3 files changed +45
target/arm/cpu-features.h
+5
@@ -1570,6 +1570,11 @@ static inline bool isar_feature_aa64_sve_b16b16(const ARMISARegisters *id)
1570 return FIELD_EX64_IDREG(id, ID_AA64ZFR0, B16B16);
1571 }
1572
1573 +static inline bool isar_feature_aa64_ssve_f8fma(const ARMISARegisters *id)
1574 +{
1575 + return FIELD_EX64_IDREG(id, ID_AA64SMFR0, SF8FMA);
1576 +}
1577 +
1578 static inline bool isar_feature_aa64_sme_b16b16(const ARMISARegisters *id)
1579 {
1580 return FIELD_EX64_IDREG(id, ID_AA64SMFR0, B16B16);
target/arm/tcg/sve.decode
+7
@@ -29,6 +29,7 @@
29 %imm9_16_10 16:s6 10:3
30 %size_23 23:2
31 %dtype_23_13 23:2 13:2
32 +%index4_19_10 19:2 10:2
33 %index3_22_19 22:1 19:2
34 %index3_22_17 22:1 17:2
35 %index3_22_12 22:2 12:1
@@ -73,6 +74,7 @@
74 &rri rd rn imm
75 &rr_dbm rd rn dbm
76 &rrri rd rn rm imm
77 +&rxx rd rn rm idxn idxm
78 &rri_esz rd rn imm esz
79 &rrri_esz rd rn rm imm esz
80 &rrr_esz rd rn rm esz
@@ -1864,6 +1866,8 @@ BFMLALT_zzzw 01100100 11 1 ..... 10 0 00 1 ..... ..... @rda_rn_rm_ex esz=2
1866 BFMLSLB_zzzw 01100100 11 1 ..... 10 1 00 0 ..... ..... @rda_rn_rm_ex esz=2
1867 BFMLSLT_zzzw 01100100 11 1 ..... 10 1 00 1 ..... ..... @rda_rn_rm_ex esz=2
1868
1869 +FMLAL_hb 01100100 10 1 rm:5 100 idxn:1 10 rn:5 rd:5 &rxx idxm=0
1870 +
1871 ### SVE2 floating-point dot-product
1872 FDOT_zzzz 01100100 00 1 ..... 10 0 00 0 ..... ..... @rda_rn_rm_ex esz=2
1873 BFDOT_zzzz 01100100 01 1 ..... 10 0 00 0 ..... ..... @rda_rn_rm_ex esz=2
@@ -1880,6 +1884,9 @@ BFMLALT_zzxw 01100100 11 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2
1884 BFMLSLB_zzxw 01100100 11 1 ..... 0110.0 ..... ..... @rrxr_3a esz=2
1885 BFMLSLT_zzxw 01100100 11 1 ..... 0110.1 ..... ..... @rrxr_3a esz=2
1886
1887 +FMLAL_idx_hb 01100100 idxn:1 01 .. rm:3 0101 .. rn:5 rd:5 \
1888 + &rxx idxm=%index4_19_10
1889 +
1890 ### SVE2 floating-point dot-product (indexed)
1891
1892 FDOT_zzxz 01100100 00 1 ..... 010000 ..... ..... @rrxr_2 esz=2
target/arm/tcg/translate-sve.c
+33
@@ -8355,3 +8355,36 @@ static bool trans_LUTI4_2h(DisasContext *s, arg_LUTI4_2h *a)
8355 }
8356 return true;
8357 }
8358 +
8359 +static bool do_fmla_fp8(DisasContext *s, arg_rxx *a, gen_helper_gvec_3_ptr *fn)
8360 +{
8361 + bool fp8fma = dc_isar_feature(aa64_f8fma, s);
8362 + bool ssve_fp8fma = dc_isar_feature(aa64_ssve_f8fma, s);
8363 + bool ok = false;
8364 +
8365 + /* Feature detection and enabling are complex here. */
8366 + if (!(ssve_fp8fma || (fp8fma && dc_isar_feature(aa64_sve2, s)))) {
8367 + return false;
8368 + }
8369 + if (fpmr_access_check(s)) {
8370 + if (fp8fma) {
8371 + s->is_nonstreaming = !ssve_fp8fma;
8372 + ok = sve_access_check(s);
8373 + } else {
8374 + ok = sme_sm_enabled_check(s);
8375 + }
8376 + }
8377 +
8378 + if (ok) {
8379 + unsigned vsz = vec_full_reg_size(s);
8380 + tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd),
8381 + vec_full_reg_offset(s, a->rn),
8382 + vec_full_reg_offset(s, a->rm),
8383 + tcg_env, vsz, vsz,
8384 + a->idxn | (a->idxm << 2), fn);
8385 + }
8386 + return true;
8387 +}
8388 +
8389 +TRANS(FMLAL_hb, do_fmla_fp8, a, gen_helper_gvec_fmla_hb)
8390 +TRANS(FMLAL_idx_hb, do_fmla_fp8, a, gen_helper_gvec_fmla_idx_hb)