target/arm: Implement FEAT_FP8
v2 cover target/arm: Implement FEAT_FP8
Changes for v2:
- Implement FEAT_LUT, a prerequisite missed in v1. Sorted the final "enable FEAT_FP8" after "enable FEAT_LUT".
And I should have mentioned before: this needs a firmware update for
tests/functional/aarch64/test_rme_virt.py
tests/functional/aarch64/test_rme_sbsaref.py
for the new cpu state in FEAT_FPMR, as the kernel we run tries to use the advertised FPMR and we get a trap to EL3. Once again I wish TF-A would filter the reported ID registers to match the features for which it is configured.
Pierrick, are you happy to continue hosting these images, or should we nominate a Linaro host for these?
r~
Richard Henderson (40):
target/arm: Implement ID_AA64ISAR3
target/arm: Implement FEAT_FAMINMAX for AdvSIMD target/arm: Implement FEAT_FAMINMAX for SME
target/arm: Implement FEAT_FAMINMAX for SVE
target/arm: Enable FEAT_FAMINMAX for -cpu max
target/arm: Update SCR bits for Arm ARM M.a.a
target/arm: Update HCRX bits for Arm ARM M.a.a
target/arm: Introduce FPMR
target/arm: Update SCTLR bits for FEAT_FPMR
target/arm: Enable EnFPM bits for FEAT_FPMR
target/arm: Clear FPMR on ResetSVEState
target/arm: Add FPMR_EL to TBFLAGS
target/arm: Trap direct acceses to FPMR
target/arm: Enable FEAT_FPMR for -cpu max
target/arm: Implement ID_AA64FPFR0
target/arm: Add isar_feature_aa64_f8cvt
target/arm: Implement FSCALE for AdvSIMD
target/arm: Implement FSCALE for SME
fpu: Add scalbn argument to fp8 conversion routines
fpu: Add conversions between float16 and float8 formats target/arm: Split vector-type.h from cpu.h
target/arm: Move vectors_overlap to vec_internal.h target/arm: Implement BF1CVTL, BF1CVTL2, BF2CVTL, BF2CVTL2 for AdvSIMD target/arm: Implement BF1CVT, BF1CVTLT, BF2CVT, BF2CVTLT for SVE target/arm: Rename SME BFCVT patterns to BFCVT_hs target/arm: Implement BF1CVT, BF1CVTL, BF2CVT, BF2CVTL for SME target/arm: Implement F1CVTL, F1CVTL2, F2CVTL, F2CVTL2 for AdvSIMD target/arm: Implement F1CVT, F1CVTLT, F2CVT, F2CVTLT for SVE target/arm: Implement F1CVT, F1CVTL, F2CVT, F2CVTL for SME target/arm: Implement BFCVTN for SVE
target/arm: Implement FCVTN (16- to 8-bit fp) for AdvSIMD target/arm: Implement FCVTN, FCVTN2 (32- to 8-bit fp) for AdvSIMD target/arm: Implement FCVTN (16- to 8-bit fp) for SVE target/arm: Implement FCVTNB, FCVTNT for SVE
target/arm: Implement FCVT (FP16 to FP8) for SME target/arm: Implement FCVT, FCVTN (FP32 to FP8) for SME target/arm: Implement LUTI2, LUTI4 for AdvSIMD
target/arm: Implement LUTI2, LUTI4 for SVE
target/arm: Enable FEAT_LUT for -cpu max
target/arm: Enable FEAT_FP8 for -cpu max
include/fpu/softfloat.h | 22 +- target/arm/cpregs.h | 5 + target/arm/cpu-features.h | 66 +++ target/arm/cpu.h | 52 +-- target/arm/helper-fp8.h | 14 + target/arm/internals.h | 13 +- target/arm/tcg/helper-a64-defs.h | 11 + target/arm/tcg/helper-defs.h | 5 + target/arm/tcg/helper-fp8-defs.h | 25 ++ target/arm/tcg/helper-sme-defs.h | 2 +- target/arm/tcg/helper-sve-defs.h | 14 + target/arm/tcg/translate-a64.h | 1 + target/arm/tcg/translate.h | 10 + target/arm/tcg/vec_internal.h | 19 + target/arm/vector-type.h | 44 ++ fpu/softfloat.c | 73 ++- target/arm/helper.c | 43 +- target/arm/machine.c | 20 + target/arm/tcg/cpu64.c | 13 + target/arm/tcg/fp8_helper.c | 742 +++++++++++++++++++++++++++++++ target/arm/tcg/hflags.c | 41 ++ target/arm/tcg/sme_helper.c | 8 +- target/arm/tcg/sve_helper.c | 8 + target/arm/tcg/translate-a64.c | 133 ++++++ target/arm/tcg/translate-sme.c | 85 +++- target/arm/tcg/translate-sve.c | 111 +++++ target/arm/tcg/vec_helper.c | 52 +++ target/arm/tcg/vec_helper64.c | 51 +++ docs/system/arm/emulation.rst | 4 + target/arm/cpu-sysregs.h.inc | 2 + target/arm/tcg/a64.decode | 23 + target/arm/tcg/meson.build | 1 + target/arm/tcg/sme.decode | 28 +- target/arm/tcg/sve.decode | 29 +- 34 files changed, 1691 insertions(+), 79 deletions(-) create mode 100644 target/arm/helper-fp8.h create mode 100644 target/arm/tcg/helper-fp8-defs.h create mode 100644 target/arm/vector-type.h create mode 100644 target/arm/tcg/fp8_helper.c
Signature · 1 line
2.43.0
PATCH v2 1/40 target/arm: Implement ID_AA64ISAR3
--- target/arm/cpu-features.h | 9 +++++++++ target/arm/helper.c | 8 ++++++-- target/arm/cpu-sysregs.h.inc | 1 + 3 files changed, 16 insertions(+), 2 deletions(-)
target/arm/cpu-features.h +9 -0
@@ -244,6 +244,15 @@ FIELD(ID_AA64ISAR2, CSSC, 52, 4) FIELD(ID_AA64ISAR2, LUT, 56, 4) FIELD(ID_AA64ISAR2, ATS1A, 60, 4) +FIELD(ID_AA64ISAR3, CPA, 0, 4) +FIELD(ID_AA64ISAR3, FAMINMAX, 4, 4) +FIELD(ID_AA64ISAR3, TLBIW, 8, 4) +FIELD(ID_AA64ISAR3, PACM, 12, 4) +FIELD(ID_AA64ISAR3, LSFE, 16, 4) +FIELD(ID_AA64ISAR3, OCCMO, 20, 4) +FIELD(ID_AA64ISAR3, LSUI, 24, 4) +FIELD(ID_AA64ISAR3, FPRCVT, 28, 4) + FIELD(ID_AA64PFR0, EL0, 0, 4) FIELD(ID_AA64PFR0, EL1, 4, 4)FIELD (ID_AA64PFR0 ,EL2 ,8 ,4 )
target/arm/helper.c +6 -2
@@ -6552,11 +6552,11 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_tid3, .resetvalue = GET_IDREG(isar, ID_AA64ISAR2)}, - { .name = "ID_AA64ISAR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, + { .name = "ID_AA64ISAR3_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_tid3, - .resetvalue = 0 }, + .resetvalue = GET_IDREG(isar, ID_AA64ISAR3) }, { .name = "ID_AA64ISAR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST,
@@ -6785,6 +6785,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)R_ID_AA64ISAR2_BC_MASK |R_ID_AA64ISAR2_RPRFM_MASK | R_ID_AA64ISAR2_CSSC_MASK }, + { .name = "ID_AA64ISAR3_EL1", + .exported_bits =R_ID_AA64ISAR3_FAMINMAX_MASK | +R_ID_AA64ISAR3_LSFE_MASK | + R_ID_AA64ISAR3_FPRCVT_MASK }, { .name = "ID_AA64ISAR*_EL1_RESERVED", .is_glob = true }, };
target/arm/cpu-sysregs.h.inc +1 -0
@@ -10,6 +10,7 @@ DEF(ID_AA64AFR1_EL1, 3, 0, 0, 5, 5) DEF(ID_AA64ISAR0_EL1, 3, 0, 0, 6, 0) DEF(ID_AA64ISAR1_EL1, 3, 0, 0, 6, 1) DEF(ID_AA64ISAR2_EL1, 3, 0, 0, 6, 2) +DEF(ID_AA64ISAR3_EL1, 3, 0, 0, 6, 3) DEF(ID_AA64MMFR0_EL1, 3, 0, 0, 7, 0) DEF(ID_AA64MMFR1_EL1, 3, 0, 0, 7, 1) DEF(ID_AA64MMFR2_EL1, 3, 0, 0, 7, 2)
Signature · 1 line
2.43.0
PATCH v2 2/40 target/arm: Implement FEAT_FAMINMAX for AdvSIMD
In reply to Richard Henderson--- target/arm/cpu-features.h | 5 +++++ target/arm/tcg/helper-a64-defs.h | 7 +++++++ target/arm/tcg/vec_internal.h | 7 +++++++ target/arm/tcg/translate-a64.c | 14 +++++++++++++ target/arm/tcg/vec_helper64.c | 35 ++++++++++++++++++++++++++++++++ target/arm/tcg/a64.decode | 5 +++++ 6 files changed, 73 insertions(+)
target/arm/cpu-features.h +5 -0
@@ -1053,6 +1053,11 @@ static inline bool isar_feature_aa64_ats1a(const ARMISARegisters *id)return FIELD_EX64_IDREG (id,ID_AA64ISAR2 ,ATS1A ); } +static inline bool isar_feature_aa64_faminmax (const ARMISARegisters *id) +{ +return FIELD_EX64_IDREG (id,ID_AA64ISAR3 ,FAMINMAX ) !=0 ; +} +static inline bool isar_feature_aa64_fp_simd (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically. */
target/arm/tcg/helper-a64-defs.h +7 -0
@@ -145,6 +145,13 @@ DEF_HELPER_FLAGS_5(gvec_fmulx_idx_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, DEF_HELPER_FLAGS_5(gvec_fmulx_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) DEF_HELPER_FLAGS_5(gvec_fmulx_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_famax_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_famin_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_famax_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_famin_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_famax_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_famin_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +#ifndef CONFIG_USER_ONLY DEF_HELPER_2(exception_return, void, env, i64)#endif
target/arm/tcg/vec_internal.h +7 -0
@@ -342,6 +342,13 @@ bfloat16 helper_sme2_ah_fmin_b16(bfloat16 a, bfloat16 b, float_status *fpst);float32 sve_f16_to_f32 (float16 f,float_status *fpst);float16 sve_f32_to_f16 (float32 f,float_status *fpst); +float16 float16_famax (float16 ,float16 ,float_status *); +float16 float16_famin (float16 ,float16 ,float_status *); +float32 float32_famax (float32 ,float32 ,float_status *); +float32 float32_famin (float32 ,float32 ,float_status *); +float64 float64_famax (float64 ,float64 ,float_status *); +float64 float64_famin (float64 ,float64 ,float_status *); +/* * Decode helper functions for predicate as counter. */
target/arm/tcg/translate-a64.c +14 -0
@@ -6477,6 +6477,20 @@ static gen_helper_gvec_3_ptr * const f_vector_fminnmp[3] = { }; TRANS(FMINNMP_v, do_fp3_vector, a, 0, f_vector_fminnmp) +static gen_helper_gvec_3_ptr *const f_vector_famax[3 ] = { + gen_helper_gvec_famax_h, + gen_helper_gvec_famax_s, + gen_helper_gvec_famax_d, +}; +TRANS_FEAT(FAMAX, aa64_faminmax, do_fp3_vector, a, 0, f_vector_famax) + +static gen_helper_gvec_3_ptr *const f_vector_famin[3 ] = { + gen_helper_gvec_famin_h, + gen_helper_gvec_famin_s, + gen_helper_gvec_famin_d, +}; +TRANS_FEAT(FAMIN, aa64_faminmax, do_fp3_vector, a, 0, f_vector_famin) +static bool do_fmlal (DisasContext *s,arg_qrrr_e *a,bool is_s,bool is_2) {if (fp_access_check (s)) {
target/arm/tcg/vec_helper64.c +35 -0
@@ -140,3 +140,38 @@ void HELPER(simd_tblx)(void *vd, void *vm, CPUARMState *env, uint32_t desc)memcpy (vd, &result,16 );clear_tail (vd, oprsz,simd_maxsz (desc)); } + +#define DO_FAMINMAX (NAME ,TYPE ,FN ) \ +TYPE TYPE##_##NAME(TYPE a, TYPE b, float_status *s) \ +{ \ + bool save_fz = get_flush_to_zero(s); \ + bool save_fiz = get_flush_inputs_to_zero(s); \ + int new_flags, save_flags = get_float_exception_flags(s); \ + \ + set_flush_to_zero(0, s); \ + set_flush_inputs_to_zero(0, s); \ + TYPE r = TYPE##_##FN(TYPE##_abs(a), TYPE##_abs(b), s); \ + \ + set_flush_to_zero(save_fz, s); \ + set_flush_inputs_to_zero(save_fiz, s); \ + new_flags = get_float_exception_flags(s); \ + new_flags = (save_flags & float_flag_input_denormal_used) \ + | (new_flags & ~float_flag_input_denormal_used); \ + set_float_exception_flags(new_flags, s); \ + \ + return r; \ +} + +DO_FAMINMAX(famax, float16, max) +DO_FAMINMAX(famin, float16, min) +DO_FAMINMAX(famax, float32, max) +DO_FAMINMAX(famin, float32, min) +DO_FAMINMAX(famax, float64, max) +DO_FAMINMAX(famin, float64, min) + +DO_3OP(gvec_famax_h, float16_famax, float16) +DO_3OP(gvec_famin_h, float16_famin, float16) +DO_3OP(gvec_famax_s, float32_famax, float32) +DO_3OP(gvec_famin_s, float32_famin, float32) +DO_3OP(gvec_famax_d, float64_famax, float64) +DO_3OP (gvec_famin_d, float64_famin, float64)
target/arm/tcg/a64.decode +5 -0
@@ -1193,6 +1193,11 @@ RSUBHN 0.10 1110 ..1 ..... 01100 0 ..... ..... @qrrr_e PMULL_p8 0.00 1110 001 ..... 11100 0 ..... ..... @qrrr_b PMULL_p64 0.00 1110 111 ..... 11100 0 ..... ..... @qrrr_b +FAMAX 0.00 1110 110 ..... 00011 1 ..... ..... @qrrr_h +FAMAX 0.00 1110 1.1 ..... 11011 1 ..... ..... @qrrr_sd +FAMIN 0.10 1110 110 ..... 00011 1 ..... ..... @qrrr_h +FAMIN 0.10 1110 1.1 ..... 11011 1 ..... ..... @qrrr_sd + ### Advanced SIMD scalar x indexed element FMUL_si 0101 1111 00 .. .... 1001 . 0 ..... ..... @rrx_h
Signature · 1 line
2.43.0
PATCH v2 3/40 target/arm: Implement FEAT_FAMINMAX for SME
In reply to Richard HendersonSince there is no bfloat16 variant of FAMINMAX, check for missing function pointer in do_z2z_nn_fpst.
--- target/arm/cpu-features.h | 5 +++++ target/arm/tcg/translate-sme.c | 23 +++++++++++++++++++++-- target/arm/tcg/sme.decode | 5 +++++ 3 files changed, 31 insertions(+), 2 deletions(-)
target/arm/cpu-features.h +5 -0
@@ -1574,6 +1574,11 @@ static inline bool isar_feature_aa64_sme2_f64f64(const ARMISARegisters *id)return isar_feature_aa64_sme2 (id) &&isar_feature_aa64_sme_f64f64 (id); } +static inline bool isar_feature_aa64_sme2_faminmax (const ARMISARegisters *id) +{ +return isar_feature_aa64_sme2 (id) &&isar_feature_aa64_faminmax (id); +} +static inline bool isar_feature_aa64_sve_i8mm (const ARMISARegisters *id) {return isar_feature_aa64_sve (id) &&isar_feature_aa64_sme_sve_i8mm (id);
target/arm/tcg/translate-sme.c +21 -2
@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "cpu.h" +#include "helper-a64.h" #include "helper-sme.h" #include "helper-sve.h" #include "translate.h"
@@ -741,9 +742,12 @@ static bool do_z2z_nn_fpst(DisasContext *s, arg_z2z_en *a, gen_helper_gvec_3_ptr * const fns[4]) {int esz = a->esz, n, dn, dm, vsz; -gen_helper_gvec_3_ptr *fn; +gen_helper_gvec_3_ptr *fn = fns[esz];TCGv_ptr fpst; +if (fn ==NULL ) { +return false; + }if (esz ==MO_8 && !dc_isar_feature (aa64_sme_b16b16, s)) {return false; }
@@ -752,7 +756,6 @@ static bool do_z2z_nn_fpst(DisasContext *s, arg_z2z_en *a, } fpst =fpstatus_ptr (esz ==MO_16 ?FPST_A64_F16 :FPST_A64 ); - fn = fns[esz]; n = a->n; dn = a->zdn; dm = a->zm;
@@ -811,6 +814,22 @@ static gen_helper_gvec_3_ptr * const f_vector_fminnm[4] = { TRANS_FEAT(FMINNM_n1, aa64_sme2, do_z2z_n1_fpst, a, f_vector_fminnm) TRANS_FEAT(FMINNM_nn, aa64_sme2, do_z2z_nn_fpst, a, f_vector_fminnm) +static gen_helper_gvec_3_ptr *const f_vector_famax[4 ] = { +NULL , + gen_helper_gvec_famax_h, + gen_helper_gvec_famax_s, + gen_helper_gvec_famax_d, +}; +TRANS_FEAT(FAMAX_nn, aa64_sme2_faminmax, do_z2z_nn_fpst, a, f_vector_famax) + +static gen_helper_gvec_3_ptr *const f_vector_famin[4 ] = { +NULL , + gen_helper_gvec_famin_h, + gen_helper_gvec_famin_s, + gen_helper_gvec_famin_d, +}; +TRANS_FEAT (FAMIN_nn, aa64_sme2_faminmax, do_z2z_nn_fpst, a, f_vector_famin) + /* Add/Sub vector Z[m] to each Z[n*N] with result in ZA[d*N]. */static bool do_azz_n1 (DisasContext *s,arg_azz_n *a,int esz,GVecGen3FnVar *fn)
target/arm/tcg/sme.decode +5 -0
@@ -286,6 +286,11 @@ URSHL_nn 1100000 1 .. 1 ..... 1011.0 10001 .... 1 @z2z_4x4 SQDMULH_nn 1100000 1 .. 1 ..... 1011.1 00000 .... 0 @z2z_2x2 SQDMULH_nn 1100000 1 .. 1 ..... 1011.1 00000 .... 0 @z2z_4x4 +FAMAX_nn 1100000 1 .. 1 ..... 1011.0 01010 .... 0 @z2z_2x2 +FAMAX_nn 1100000 1 .. 1 ..... 1011.0 01010 .... 0 @z2z_4x4 +FAMIN_nn 1100000 1 .. 1 ..... 1011.0 01010 .... 1 @z2z_2x2 +FAMIN_nn 1100000 1 .. 1 ..... 1011.0 01010 .... 1 @z2z_4x4 + ### SME2 Multi-vector Multiple and Single Array Vectors &azz_n n off rv zn zm
Signature · 1 line
2.43.0
PATCH v2 4/40 target/arm: Implement FEAT_FAMINMAX for SVE
In reply to Richard Henderson--- target/arm/cpu-features.h | 11 +++++++++++ target/arm/tcg/helper-sve-defs.h | 14 ++++++++++++++ target/arm/tcg/sve_helper.c | 8 ++++++++ target/arm/tcg/translate-sve.c | 2 ++ target/arm/tcg/sve.decode | 2 ++ 5 files changed, 37 insertions(+)
target/arm/cpu-features.h +11 -0
@@ -1549,6 +1549,11 @@ static inline bool isar_feature_aa64_sme_or_sve2(const ARMISARegisters *id)return isar_feature_aa64_sme (id) ||isar_feature_aa64_sve2 (id); } +static inline bool isar_feature_aa64_sme2_or_sve2 (const ARMISARegisters *id) +{ +return isar_feature_aa64_sme2 (id) ||isar_feature_aa64_sve2 (id); +} +static inline bool isar_feature_aa64_sme_or_sve2p1 (const ARMISARegisters *id) {return isar_feature_aa64_sme (id) ||isar_feature_aa64_sve2p1 (id);
@@ -1589,6 +1594,12 @@ static inline bool isar_feature_aa64_sve_bf16(const ARMISARegisters *id)return isar_feature_aa64_sve (id) &&isar_feature_aa64_sme_sve_bf16 (id); } +static inline bool +isar_feature_aa64_sme2_or_sve2_faminmax (const ARMISARegisters *id) +{ +return isar_feature_aa64_sme2_or_sve2 (id) &&isar_feature_aa64_faminmax (id); +} +/* * Feature tests for "does this exist in either 32-bit or 64-bit?" */
target/arm/tcg/helper-sve-defs.h +14 -0
@@ -3166,3 +3166,17 @@ DEF_HELPER_FLAGS_5(sve2p1_st1ss_le_c, TCG_CALL_NO_WG, void, env, ptr, tl, i32, i DEF_HELPER_FLAGS_5(sve2p1_st1ss_be_c, TCG_CALL_NO_WG, void, env, ptr, tl, i32, i64) DEF_HELPER_FLAGS_5(sve2p1_st1dd_le_c, TCG_CALL_NO_WG, void, env, ptr, tl, i32, i64) DEF_HELPER_FLAGS_5(sve2p1_st1dd_be_c, TCG_CALL_NO_WG, void, env, ptr, tl, i32, i64) + +DEF_HELPER_FLAGS_6 (sve2_famax_h,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_6 (sve2_famax_s,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_6 (sve2_famax_d,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, fpst, i32) + +DEF_HELPER_FLAGS_6 (sve2_famin_h,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_6 (sve2_famin_s,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_6 (sve2_famin_d,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, fpst, i32)
target/arm/tcg/sve_helper.c +8 -0
@@ -4742,6 +4742,14 @@ DO_ZPZZ_FP(sve_fmulx_h, uint16_t, H1_2, helper_advsimd_mulxh) DO_ZPZZ_FP(sve_fmulx_s, uint32_t, H1_4, helper_vfp_mulxs) DO_ZPZZ_FP(sve_fmulx_d, uint64_t, H1_8, helper_vfp_mulxd) +DO_ZPZZ_FP(sve2_famax_h, uint16_t, H1_2, float16_famax) +DO_ZPZZ_FP(sve2_famax_s, uint32_t, H1_4, float32_famax) +DO_ZPZZ_FP(sve2_famax_d, uint64_t, H1_8, float64_famax) + +DO_ZPZZ_FP(sve2_famin_h, uint16_t, H1_2, float16_famin) +DO_ZPZZ_FP(sve2_famin_s, uint32_t, H1_4, float32_famin) +DO_ZPZZ_FP(sve2_famin_d, uint64_t, H1_8, float64_famin) +#undef DO_ZPZZ_FP/* Three-operand expander, with one scalar operand, controlled by
target/arm/tcg/translate-sve.c +2 -0
@@ -4252,6 +4252,8 @@ DO_ZPZZ_AH_FP(FABD, aa64_sme_or_sve, sve_fabd, sve_ah_fabd) DO_ZPZZ_FP(FSCALE, aa64_sme_or_sve, sve_fscalbn) DO_ZPZZ_FP(FDIV, aa64_sme_or_sve, sve_fdiv) DO_ZPZZ_FP(FMULX, aa64_sme_or_sve, sve_fmulx) +DO_ZPZZ_FP(FAMAX, aa64_sme2_or_sve2_faminmax, sve2_famax) +DO_ZPZZ_FP(FAMIN, aa64_sme2_or_sve2_faminmax, sve2_famin)typedef void gen_helper_sve_fp2scalar (TCGv_ptr ,TCGv_ptr ,TCGv_ptr ,TCGv_i64 ,TCGv_ptr ,TCGv_i32 );
target/arm/tcg/sve.decode +2 -0
@@ -1130,6 +1130,8 @@ FSCALE 01100101 .. 00 1001 100 ... ..... ..... @rdn_pg_rm FMULX 01100101 .. 00 1010 100 ... ..... ..... @rdn_pg_rm FDIV 01100101 .. 00 1100 100 ... ..... ..... @rdm_pg_rn # FDIVR FDIV 01100101 .. 00 1101 100 ... ..... ..... @rdn_pg_rm +FAMAX 01100101 .. 00 1110 100 ... ..... ..... @rdn_pg_rm +FAMIN 01100101 .. 00 1111 100 ... ..... ..... @rdn_pg_rm # SVE floating-point arithmetic with immediate (predicated) FADD_zpzi 01100101 .. 011 000 100 ... 0000 . ..... @rdn_i1
Signature · 1 line
2.43.0
PATCH v2 5/40 target/arm: Enable FEAT_FAMINMAX for -cpu max
In reply to Richard Henderson--- target/arm/tcg/cpu64.c | 4 ++++ docs/system/arm/emulation.rst | 1 + 2 files changed, 5 insertions(+)
target/arm/tcg/cpu64.c +4 -0
@@ -1256,6 +1256,10 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR2 ,ATS1A ,1 );/* FEAT_ATS1A */ SET_IDREG (isar,ID_AA64ISAR2 , t); + t =GET_IDREG (isar,ID_AA64ISAR3 ); + t =FIELD_DP64 (t,ID_AA64ISAR3 ,FAMINMAX ,1 );/* FEAT_FAMINMAX */ +SET_IDREG (isar,ID_AA64ISAR3 , t); + t =GET_IDREG (isar,ID_AA64PFR0 ); t =FIELD_DP64 (t,ID_AA64PFR0 ,FP ,1 );/* FEAT_FP16 */ t =FIELD_DP64 (t,ID_AA64PFR0 ,ADVSIMD ,1 );/* FEAT_FP16 */
docs/system/arm/emulation.rst +1 -0
@@ -66,6 +66,7 @@ the following architecture extensions: - FEAT_EVT (Enhanced Virtualization Traps) - FEAT_F32MM (Single-precision Matrix Multiplication) - FEAT_F64MM (Double-precision Matrix Multiplication) +- FEAT_FAMINMAX (Floating-point maximum and minimum absolute value instructions) - FEAT_FCMA (Floating-point complex number instructions) - FEAT_FGT (Fine-Grained Traps) - FEAT_FHM (Floating-point half-precision multiplication instructions)
Signature · 1 line
2.43.0
PATCH v2 6/40 target/arm: Update SCR bits for Arm ARM M.a.a
In reply to Richard Henderson--- target/arm/cpu.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
target/arm/cpu.h +11 -0
@@ -1794,6 +1794,17 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)#define SCR_AIEN (1ULL << 46)#define SCR_GPF (1ULL << 48)#define SCR_MECEN (1ULL << 49) +#define SCR_ENFPM (1ULL << 50) +#define SCR_TMEA (1ULL << 51) +#define SCR_TWERR (1ULL << 52) +#define SCR_PFAREN (1ULL << 53) +#define SCR_SRMASKEN (1ULL << 54) +#define SCR_ENIDCP128 (1ULL << 55) +#define SCR_DSE (1ULL << 57) +#define SCR_ENDSE (1ULL << 58) +#define SCR_FGTEN2 (1ULL << 59) +#define SCR_HDBSSEN (1ULL << 60) +#define SCR_HACEBSEN (1ULL << 61)#define SCR_NSE (1ULL << 62)/* GCSCR_ELx fields */
Signature · 1 line
2.43.0
PATCH v2 7/40 target/arm: Update HCRX bits for Arm ARM M.a.a
In reply to Richard Henderson--- target/arm/internals.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/arm/internals.h +3 -1
@@ -252,7 +252,9 @@ FIELD(VSTCR, SA, 30, 1)#define HCRX_TCR2EN (1ULL << 14)#define HCRX_SCTLR2EN (1ULL << 15)#define HCRX_GCSEN (1ULL << 22) - +#define HCRX_ENFPM (1ULL << 23) +#define HCRX_PACMEN (1ULL << 24) +#define HCRX_SRMASKEN (1ULL << 26)#define HPFAR_NS (1ULL << 63)#define HSTR_TTEE (1 << 16)
Signature · 1 line
2.43.0
PATCH v2 8/40 target/arm: Introduce FPMR
In reply to Richard HendersonIntroduce the special register FPMR and its fields. Migrate it when present.
--- target/arm/cpregs.h | 5 +++++ target/arm/cpu-features.h | 5 +++++ target/arm/cpu.h | 1 + target/arm/internals.h | 9 +++++++++ target/arm/helper.c | 12 +++++++++++- target/arm/machine.c | 20 ++++++++++++++++++++ 6 files changed, 51 insertions(+), 1 deletion(-)
target/arm/cpregs.h +5 -0
@@ -149,6 +149,11 @@ enum {* should not trap to EL2 when HCR_EL2.NV is set. */ ARM_CP_NV_NO_TRAP =1 <<22 , +/* +* Flag: Access check for this sysreg is constrained by the +* ARM pseudocode function CheckFPMREnabled(). +*/ + ARM_CP_FPMR = 1 << 23, };/*
target/arm/cpu-features.h +5 -0
@@ -1173,6 +1173,11 @@ static inline bool isar_feature_aa64_gcs(const ARMISARegisters *id)return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,GCS ) !=0 ; } +static inline bool isar_feature_aa64_fpmr (const ARMISARegisters *id) +{ +return FIELD_EX64_IDREG (id,ID_AA64PFR2 ,FPMR ) !=0 ; +} +static inline bool isar_feature_aa64_tgran4_lpa2 (const ARMISARegisters *id) {return FIELD_SEX64_IDREG (id,ID_AA64MMFR0 ,TGRAN4 ) >=1 ;
target/arm/cpu.h +1 -0
@@ -692,6 +692,7 @@ typedef struct CPUArchState {*/ uint64_t fpsr;uint64_t fpcr; +uint64_t fpmr;uint32_t xregs[16 ];
target/arm/internals.h +9 -0
@@ -286,6 +286,15 @@ FIELD(CNTHCTL, EVNTIS, 17, 1) FIELD(CNTHCTL, CNTVMASK, 18, 1) FIELD(CNTHCTL, CNTPMASK, 19, 1) +FIELD(FPMR, F8S1, 0, 3) +FIELD(FPMR, F8S2, 3, 3) +FIELD(FPMR, F8D, 6, 3) +FIELD(FPMR, OSM, 14, 1) +FIELD(FPMR, OSC, 15, 1) +FIELD(FPMR, LSCALE, 16, 7) +FIELD(FPMR, NSCALE, 24, 8) +FIELD (FPMR ,LSCALE2 ,32 ,6 ) +/* We use a few fake FSR values for internal purposes in M profile. * M profile cores don't have A/R format FSRs, but currently our * get_phys_addr() code assumes A/R profile and reports failures via
target/arm/helper.c +11 -1
@@ -6286,6 +6286,14 @@ static const ARMCPRegInfo aie_reginfo[] = { .type = ARM_CP_CONST, .resetvalue = 0 }, }; +static const ARMCPRegInfo fpmr_reginfo[] = { + { .name ="FPMR" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =3 , .crn =4 , .crm =4 , .opc2 =2 , + .access =PL0_RW , .type =ARM_CP_FPU |ARM_CP_FPMR , + .fieldoffset = offsetof(CPUARMState, vfp.fpmr), + } +}; +void register_cp_regs_for_features (ARMCPU *cpu) {/* Register all the coprocessor registers based on feature bits */
@@ -7535,10 +7543,12 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, mec_mte_reginfo); } } -if (cpu_isar_feature (aa64_aie, cpu)) {define_arm_cp_regs (cpu, aie_reginfo); } +if (cpu_isar_feature (aa64_fpmr, cpu)) { +define_arm_cp_regs (cpu, fpmr_reginfo); + }if (cpu_isar_feature (any_predinv, cpu)) {define_arm_cp_regs (cpu, predinv_reginfo);
target/arm/machine.c +20 -0
@@ -960,6 +960,25 @@ static const VMStateDescription vmstate_syndrome64 = { }, }; +static bool fpmr_needed (void *opaque) +{ +ARMCPU *cpu = opaque; + +return arm_feature (&cpu->env,ARM_FEATURE_AARCH64 ) + &&cpu_isar_feature (aa64_fpmr, cpu); +} + +static const VMStateDescription vmstate_fpmr = { + .name ="cpu/fpmr" , + .version_id =1 , + .minimum_version_id =1 , + .needed = fpmr_needed, + .fields = (const VMStateField []) { +VMSTATE_UINT64 (env.vfp.fpmr,ARMCPU ), +VMSTATE_END_OF_LIST () + }, +}; +static int cpu_pre_save (void *opaque) {ARMCPU *cpu = opaque;
@@ -1310,6 +1329,7 @@ const VMStateDescription vmstate_arm_cpu = { &vmstate_syndrome64, &vmstate_pstate64, &vmstate_event, + &vmstate_fpmr, NULL } };
Signature · 1 line
2.43.0
PATCH v2 9/40 target/arm: Update SCTLR bits for FEAT_FPMR
In reply to Richard Henderson--- target/arm/cpu.h | 1 + 1 file changed, 1 insertion(+)
target/arm/cpu.h +1 -0
@@ -1459,6 +1459,7 @@ void pmu_init(ARMCPU *cpu);#define SCTLR_DSSBS_32 (1U << 31)/* v8.5, AArch32 only */ #define SCTLR_CMOW (1ULL << 32)/* FEAT_CMOW */ #define SCTLR_MSCEN (1ULL << 33)/* FEAT_MOPS */ +#define SCTLR_EnFPM (1ULL << 34)/* FEAT_FPMR */ #define SCTLR_BT0 (1ULL << 35)/* v8.5-BTI */ #define SCTLR_BT1 (1ULL << 36)/* v8.5-BTI */ #define SCTLR_ITFSB (1ULL << 37)/* v8.5-MemTag */
Signature · 1 line
2.43.0
PATCH v2 10/40 target/arm: Enable EnFPM bits for FEAT_FPMR
In reply to Richard Henderson--- target/arm/helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)
target/arm/helper.c +9 -0
@@ -787,6 +787,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)if (cpu_isar_feature (aa64_mec, cpu)) { valid_mask |=SCR_MECEN ; } +if (cpu_isar_feature (aa64_fpmr, cpu)) { + valid_mask |=SCR_ENFPM ; + } }else { valid_mask &= ~(SCR_RW |SCR_ST );if (cpu_isar_feature (aa32_ras, cpu)) {
@@ -4030,6 +4033,9 @@ static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,if (cpu_isar_feature (aa64_gcs, cpu)) { valid_mask |=HCRX_GCSEN ; } +if (cpu_isar_feature (aa64_fpmr, cpu)) { + valid_mask |=HCRX_ENFPM ; + }/* Clear RES0 bits. */ env->cp15.hcrx_el2 = value & valid_mask;
@@ -4103,6 +4109,9 @@ uint64_t arm_hcrx_el2_eff(CPUARMState *env)if (cpu_isar_feature (aa64_gcs, cpu)) { hcrx |=HCRX_GCSEN ; } +if (cpu_isar_feature (aa64_fpmr, cpu)) { + hcrx |=HCRX_ENFPM ; + }return hcrx; }if (arm_feature (env,ARM_FEATURE_EL3 ) && !(env->cp15.scr_el3 &SCR_HXEN )) {
Signature · 1 line
2.43.0
PATCH v2 11/40 target/arm: Clear FPMR on ResetSVEState
In reply to Richard HendersonFPMR is cleared when entering or exiting Streaming Mode.
--- target/arm/helper.c | 1 + 1 file changed, 1 insertion(+)
target/arm/helper.c +1 -0
@@ -4913,6 +4913,7 @@ static void arm_reset_sve_state(CPUARMState *env)/* Recall that FFR is stored as pregs[16]. */ memset (env->vfp.pregs,0 ,sizeof (env->vfp.pregs));vfp_set_fpsr (env,0x0800009f ); + env->vfp.fpmr =0 ; }void aarch64_set_svcr (CPUARMState *env,uint64_t new,uint64_t mask)
Signature · 1 line
2.43.0
PATCH v2 12/40 target/arm: Add FPMR_EL to TBFLAGS
In reply to Richard HendersonPrepare to perform access checks for direct and
indirect uses of FPMR.
--- target/arm/cpu.h | 1 + target/arm/tcg/translate.h | 2 ++ target/arm/tcg/hflags.c | 41 ++++++++++++++++++++++++++++++++++ target/arm/tcg/translate-a64.c | 1 + 4 files changed, 45 insertions(+)
target/arm/cpu.h +1 -0
@@ -2536,6 +2536,7 @@ FIELD(TBFLAG_A64, ZT0EXC_EL, 39, 2) FIELD(TBFLAG_A64, GCS_EN, 41, 1) FIELD(TBFLAG_A64, GCS_RVCEN, 42, 1) FIELD(TBFLAG_A64, GCSSTR_EL, 43, 2) +FIELD (TBFLAG_A64 ,FPMR_EL ,45 ,2 )/* * Helpers for using the above. Note that only the A64 accessors use
target/arm/tcg/translate.h +2 -0
@@ -199,6 +199,8 @@ typedef struct DisasContext {uint8_t gm_blocksize;/* True if the current insn_start has been updated. */ bool insn_start_updated; +/* FMPR exception EL or 0 if enabled. */ +uint8_t fpmr_el;/* Offset from VNCR_EL2 when FEAT_NV2 redirects this reg to memory */ uint32_t nv2_redirect_offset; } DisasContext;
target/arm/tcg/hflags.c +41 -0
53 lines not on this page · raw message
target/arm/tcg/translate-a64.c +1 -0
@@ -10725,6 +10725,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->gcs_en =EX_TBFLAG_A64 (tb_flags,GCS_EN ); dc->gcs_rvcen =EX_TBFLAG_A64 (tb_flags,GCS_RVCEN ); dc->gcsstr_el =EX_TBFLAG_A64 (tb_flags,GCSSTR_EL ); + dc->fpmr_el =EX_TBFLAG_A64 (tb_flags,FPMR_EL ); dc->vec_len =0 ; dc->vec_stride =0 ; dc->cp_regs = arm_cpu->cp_regs;
Signature · 1 line
2.43.0
PATCH v2 13/40 target/arm: Trap direct acceses to FPMR
In reply to Richard Henderson--- target/arm/tcg/translate-a64.c | 4 ++++ 1 file changed, 4 insertions(+)
target/arm/tcg/translate-a64.c +4 -0
@@ -2898,6 +2898,10 @@ static void handle_sys(DisasContext *s, bool isread, }if (!skip_fp_access_checks) { +if ((ri->type &ARM_CP_FPMR ) && s->fpmr_el !=0 ) { +gen_exception_insn_el (s,0 ,EXCP_UDEF , syndrome, s->fpmr_el); +return ; + }if ((ri->type &ARM_CP_FPU ) && !fp_access_check_only (s)) {return ; }else if ((ri->type &ARM_CP_SVE ) && !sve_access_check (s)) {
Signature · 1 line
2.43.0
PATCH v2 14/40 target/arm: Enable FEAT_FPMR for -cpu max
In reply to Richard Henderson--- target/arm/tcg/cpu64.c | 4 ++++ docs/system/arm/emulation.rst | 1 + 2 files changed, 5 insertions(+)
target/arm/tcg/cpu64.c +4 -0
@@ -1287,6 +1287,10 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64PFR1 ,GCS ,1 );/* FEAT_GCS */ SET_IDREG (isar,ID_AA64PFR1 , t); + t =GET_IDREG (isar,ID_AA64PFR2 ); + t =FIELD_DP64 (t,ID_AA64PFR2 ,FPMR ,1 );/* FEAT_FPMR */ +SET_IDREG (isar,ID_AA64PFR2 , t); + t =GET_IDREG (isar,ID_AA64MMFR0 ); t =FIELD_DP64 (t,ID_AA64MMFR0 ,PARANGE ,6 );/* FEAT_LPA: 52 bits */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN16 ,1 );/* 16k pages supported */
docs/system/arm/emulation.rst +1 -0
@@ -75,6 +75,7 @@ the following architecture extensions: - FEAT_FPAC (Faulting on AUT* instructions) - FEAT_FPACCOMBINE (Faulting on combined pointer authentication instructions) - FEAT_FPACC_SPEC (Speculative behavior of combined pointer authentication instructions) +- FEAT_FPMR (Floating-point mode register) - FEAT_FRINTTS (Floating-point to integer instructions) - FEAT_FlagM (Flag manipulation instructions v2) - FEAT_FlagM2 (Enhancements to flag manipulation instructions)
Signature · 1 line
2.43.0
PATCH v2 15/40 target/arm: Implement ID_AA64FPFR0
In reply to Richard Henderson--- target/arm/cpu-features.h | 9 +++++++++ target/arm/helper.c | 13 +++++++++++-- target/arm/cpu-sysregs.h.inc | 1 + 3 files changed, 21 insertions(+), 2 deletions(-)
target/arm/cpu-features.h +9 -0
@@ -401,6 +401,15 @@ FIELD(ID_AA64SMFR0, I16I64, 52, 4) FIELD(ID_AA64SMFR0, SMEVER, 56, 4) FIELD(ID_AA64SMFR0, FA64, 63, 1) +FIELD(ID_AA64FPFR0, F8E5M2, 0, 1) +FIELD(ID_AA64FPFR0, F8E4M3, 1, 1) +FIELD(ID_AA64FPFR0, F8MM4, 26, 1) +FIELD(ID_AA64FPFR0, F8MM8, 27, 1) +FIELD(ID_AA64FPFR0, F8DP2, 28, 1) +FIELD(ID_AA64FPFR0, F8DP4, 29, 1) +FIELD(ID_AA64FPFR0, F8FMA, 30, 1) +FIELD(ID_AA64FPFR0, F8CVT, 31, 1) + FIELD(ID_DFR0, COPDBG, 0, 4) FIELD(ID_DFR0, COPSDBG, 4, 4)FIELD (ID_DFR0 ,MMAPDBG ,8 ,4 )
target/arm/helper.c +11 -2
@@ -6510,11 +6510,11 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_tid3, .resetvalue = 0 }, - { .name = "ID_AA64PFR7_EL1_RESERVED", .state = ARM_CP_STATE_AA64, + { .name = "ID_AA64FPFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_tid3, - .resetvalue = 0 }, + .resetvalue = GET_IDREG(isar, ID_AA64FPFR0) }, { .name = "ID_AA64DFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST,
@@ -6745,6 +6745,15 @@ void register_cp_regs_for_features(ARMCPU *cpu)R_ID_AA64SMFR0_I16I64_MASK |R_ID_AA64SMFR0_SMEVER_MASK | R_ID_AA64SMFR0_FA64_MASK }, + { .name = "ID_AA64FPFR0_EL1", + .exported_bits =R_ID_AA64FPFR0_F8E5M2_MASK | +R_ID_AA64FPFR0_F8E4M3_MASK | +R_ID_AA64FPFR0_F8MM4_MASK | +R_ID_AA64FPFR0_F8MM8_MASK | +R_ID_AA64FPFR0_F8DP2_MASK | +R_ID_AA64FPFR0_F8DP4_MASK | +R_ID_AA64FPFR0_F8FMA_MASK | + R_ID_AA64FPFR0_F8CVT_MASK }, { .name = "ID_AA64MMFR0_EL1", .exported_bits = R_ID_AA64MMFR0_ECV_MASK, .fixed_bits = (0xfu << R_ID_AA64MMFR0_TGRAN64_SHIFT) |
target/arm/cpu-sysregs.h.inc +1 -0
@@ -3,6 +3,7 @@ DEF(ID_AA64PFR0_EL1, 3, 0, 0, 4, 0) DEF(ID_AA64PFR1_EL1, 3, 0, 0, 4, 1) DEF(ID_AA64PFR2_EL1, 3, 0, 0, 4, 2) DEF(ID_AA64SMFR0_EL1, 3, 0, 0, 4, 5) +DEF(ID_AA64FPFR0_EL1, 3, 0, 0, 4, 7) DEF(ID_AA64DFR0_EL1, 3, 0, 0, 5, 0) DEF(ID_AA64DFR1_EL1, 3, 0, 0, 5, 1) DEF(ID_AA64AFR0_EL1, 3, 0, 0, 5, 4)
Signature · 1 line
2.43.0
PATCH v2 16/40 target/arm: Add isar_feature_aa64_f8cvt
In reply to Richard Henderson--- target/arm/cpu-features.h | 5 +++++ 1 file changed, 5 insertions(+)
target/arm/cpu-features.h +5 -0
@@ -1550,6 +1550,11 @@ static inline bool isar_feature_aa64_sme2p1(const ARMISARegisters *id)return FIELD_EX64_IDREG (id,ID_AA64SMFR0 ,SMEVER ) >=2 ; } +static inline bool isar_feature_aa64_f8cvt (const ARMISARegisters *id) +{ +return FIELD_EX64_IDREG (id,ID_AA64FPFR0 ,F8CVT ); +} +/* * Combinations of feature tests, for ease of use with TRANS_FEAT. */
Signature · 1 line
2.43.0
PATCH v2 17/40 target/arm: Implement FSCALE for AdvSIMD
In reply to Richard Henderson--- target/arm/tcg/helper-a64-defs.h | 4 ++++ target/arm/tcg/vec_internal.h | 4 ++++ target/arm/tcg/translate-a64.c | 7 +++++++ target/arm/tcg/vec_helper64.c | 16 ++++++++++++++++ target/arm/tcg/a64.decode | 3 +++ 5 files changed, 34 insertions(+)
target/arm/tcg/helper-a64-defs.h +4 -0
@@ -152,6 +152,10 @@ DEF_HELPER_FLAGS_5(gvec_famin_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32 DEF_HELPER_FLAGS_5(gvec_famax_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) DEF_HELPER_FLAGS_5(gvec_famin_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_fscale_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_fscale_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_5(gvec_fscale_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, fpst, i32) +#ifndef CONFIG_USER_ONLY DEF_HELPER_2(exception_return, void, env, i64)#endif
target/arm/tcg/vec_internal.h +4 -0
@@ -349,6 +349,10 @@ float32 float32_famin(float32, float32, float_status *);float64 float64_famax (float64 ,float64 ,float_status *);float64 float64_famin (float64 ,float64 ,float_status *); +#define float16_fscale float16_scalbn +#define float32_fscale float32_scalbn +float64 float64_fscale (float64 ,int64_t ,float_status *); +/* * Decode helper functions for predicate as counter. */
target/arm/tcg/translate-a64.c +7 -0
@@ -6495,6 +6495,13 @@ static gen_helper_gvec_3_ptr * const f_vector_famin[3] = { }; TRANS_FEAT(FAMIN, aa64_faminmax, do_fp3_vector, a, 0, f_vector_famin) +static gen_helper_gvec_3_ptr *const f_vector_fscale[3 ] = { + gen_helper_gvec_fscale_h, + gen_helper_gvec_fscale_s, + gen_helper_gvec_fscale_d, +}; +TRANS_FEAT(FSCALE, aa64_f8cvt, do_fp3_vector, a, 0, f_vector_fscale) +static bool do_fmlal (DisasContext *s,arg_qrrr_e *a,bool is_s,bool is_2) {if (fp_access_check (s)) {
target/arm/tcg/vec_helper64.c +16 -0
@@ -175,3 +175,19 @@ DO_3OP(gvec_famax_s, float32_famax, float32) DO_3OP(gvec_famin_s, float32_famin, float32) DO_3OP(gvec_famax_d, float64_famax, float64) DO_3OP(gvec_famin_d, float64_famin, float64) + +float64 float64_fscale (float64 n,int64_t m,float_status *s) +{ +/* +* Given the 'int' parameter of float64_scalbn, we have to saturate +* the 'int64_t' parameter of the operation to some value. Since +* float64 has an 11-bit exponent, saturating to 12 bits is sufficient +* to ensure that DBL_TRUE_MIN can be made to overflow. +*/ +int sat_m =MIN (MAX (m,-0xfff ),0xfff ); +return float64_scalbn (n, sat_m, s); +} + +DO_3OP(gvec_fscale_h, float16_fscale, int16_t) +DO_3OP(gvec_fscale_s, float32_fscale, int32_t) +DO_3OP (gvec_fscale_d, float64_fscale, int64_t)
target/arm/tcg/a64.decode +3 -0
@@ -1198,6 +1198,9 @@ FAMAX 0.00 1110 1.1 ..... 11011 1 ..... ..... @qrrr_sd FAMIN 0.10 1110 110 ..... 00011 1 ..... ..... @qrrr_h FAMIN 0.10 1110 1.1 ..... 11011 1 ..... ..... @qrrr_sd +FSCALE 0.10 1110 110 ..... 00111 1 ..... ..... @qrrr_h +FSCALE 0.10 1110 1.1 ..... 11111 1 ..... ..... @qrrr_sd + ### Advanced SIMD scalar x indexed element FMUL_si 0101 1111 00 .. .... 1001 . 0 ..... ..... @rrx_h
Signature · 1 line
2.43.0
PATCH v2 18/40 target/arm: Implement FSCALE for SME
In reply to Richard Henderson--- target/arm/cpu-features.h | 5 +++++ target/arm/tcg/translate-sme.c | 15 +++++++++++++-- target/arm/tcg/sme.decode | 6 ++++++ 3 files changed, 24 insertions(+), 2 deletions(-)
target/arm/cpu-features.h +5 -0
@@ -1603,6 +1603,11 @@ static inline bool isar_feature_aa64_sme2_faminmax(const ARMISARegisters *id)return isar_feature_aa64_sme2 (id) &&isar_feature_aa64_faminmax (id); } +static inline bool isar_feature_aa64_sme2_f8cvt (const ARMISARegisters *id) +{ +return isar_feature_aa64_sme2 (id) &&isar_feature_aa64_f8cvt (id); +} +static inline bool isar_feature_aa64_sve_i8mm (const ARMISARegisters *id) {return isar_feature_aa64_sve (id) &&isar_feature_aa64_sme_sve_i8mm (id);
target/arm/tcg/translate-sme.c +13 -2
@@ -706,9 +706,12 @@ static bool do_z2z_n1_fpst(DisasContext *s, arg_z2z_en *a, {int esz = a->esz, n, dn, vsz, mofs;bool overlap = false; -gen_helper_gvec_3_ptr *fn; +gen_helper_gvec_3_ptr *fn = fns[esz];TCGv_ptr fpst; +if (fn ==NULL ) { +return false; + }/* These insns use MO_8 to encode BFloat16. */ if (esz ==MO_8 && !dc_isar_feature (aa64_sme_b16b16, s)) {return false;
@@ -718,7 +721,6 @@ static bool do_z2z_n1_fpst(DisasContext *s, arg_z2z_en *a, } fpst =fpstatus_ptr (esz ==MO_16 ?FPST_A64_F16 :FPST_A64 ); - fn = fns[esz]; n = a->n; dn = a->zdn; mofs =vec_full_reg_offset (s, a->zm);
@@ -830,6 +832,15 @@ static gen_helper_gvec_3_ptr * const f_vector_famin[4] = { }; TRANS_FEAT(FAMIN_nn, aa64_sme2_faminmax, do_z2z_nn_fpst, a, f_vector_famin) +static gen_helper_gvec_3_ptr *const f_vector_fscale[4 ] = { +NULL , + gen_helper_gvec_fscale_h, + gen_helper_gvec_fscale_s, + gen_helper_gvec_fscale_d, +}; +TRANS_FEAT(FSCALE_n1, aa64_sme2_f8cvt, do_z2z_n1_fpst, a, f_vector_fscale) +TRANS_FEAT (FSCALE_nn, aa64_sme2_f8cvt, do_z2z_nn_fpst, a, f_vector_fscale) + /* Add/Sub vector Z[m] to each Z[n*N] with result in ZA[d*N]. */static bool do_azz_n1 (DisasContext *s,arg_azz_n *a,int esz,GVecGen3FnVar *fn)
target/arm/tcg/sme.decode +6 -0
@@ -250,6 +250,9 @@ ADD_n1 1100000 1 .. 10 .... 1010.0 11000 .... 0 @z2z_4x1 SQDMULH_n1 1100000 1 .. 10 .... 1010.1 00000 .... 0 @z2z_2x1 SQDMULH_n1 1100000 1 .. 10 .... 1010.1 00000 .... 0 @z2z_4x1 +FSCALE_n1 1100000 1 .. 10 .... 1010.0 01100 .... 0 @z2z_2x1 +FSCALE_n1 1100000 1 .. 10 .... 1010.0 01100 .... 0 @z2z_4x1 + ### SME2 Multi-vector Multiple Vectors SVE Destructive %zm_ax2 17:4 !function=times_2
@@ -291,6 +294,9 @@ FAMAX_nn 1100000 1 .. 1 ..... 1011.0 01010 .... 0 @z2z_4x4 FAMIN_nn 1100000 1 .. 1 ..... 1011.0 01010 .... 1 @z2z_2x2 FAMIN_nn 1100000 1 .. 1 ..... 1011.0 01010 .... 1 @z2z_4x4 +FSCALE_nn 1100000 1 .. 1 ..... 1011.0 01100 .... 0 @z2z_2x2 +FSCALE_nn 1100000 1 .. 1 ..... 1011.0 01100 .... 0 @z2z_4x4 + ### SME2 Multi-vector Multiple and Single Array Vectors &azz_n n off rv zn zm
Signature · 1 line
2.43.0
PATCH v2 19/40 fpu: Add scalbn argument to fp8 conversion routines
In reply to Richard HendersonAll Arm fp8 conversions have a power-of-2 scaling factor.
--- include/fpu/softfloat.h | 16 ++++++++++------ fpu/softfloat.c | 35 +++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 20 deletions(-)
include/fpu/softfloat.h +10 -6
@@ -195,13 +195,17 @@ float128 uint128_to_float128(Int128, float_status *status);float8_e4m3 float4_e2m1_to_float8_e4m3 (float4_e2m1 ,float_status *status); -bfloat16 float8_e4m3_to_bfloat16 (float8_e4m3 ,float_status *status); -float8_e4m3 bfloat16_to_float8_e4m3 (bfloat16 ,bool sat,float_status *status); -float8_e4m3 float32_to_float8_e4m3 (float32 ,bool sat,float_status *status); +bfloat16 float8_e4m3_to_bfloat16 (float8_e4m3 ,int scale,float_status *status); +float8_e4m3 bfloat16_to_float8_e4m3 (bfloat16 ,int scale, +bool sat,float_status *status); +float8_e4m3 float32_to_float8_e4m3 (float32 ,int scale, +bool sat,float_status *status); -bfloat16 float8_e5m2_to_bfloat16 (float8_e5m2 ,float_status *status); -float8_e5m2 bfloat16_to_float8_e5m2 (bfloat16 ,bool sat,float_status *status); -float8_e5m2 float32_to_float8_e5m2 (float32 ,bool sat,float_status *status); +bfloat16 float8_e5m2_to_bfloat16 (float8_e5m2 ,int scale,float_status *status); +float8_e5m2 bfloat16_to_float8_e5m2 (bfloat16 ,int scale, +bool sat,float_status *status); +float8_e5m2 float32_to_float8_e5m2 (float32 ,int scale, +bool sat,float_status *status);/*---------------------------------------------------------------------------- | Software half-precision conversion routines.
fpu/softfloat.c +21 -14
@@ -2853,7 +2853,8 @@ static void parts_float_to_ahp(FloatParts64 *a, float_status *s) } } -static void parts_float_to_e5m2 (FloatParts64 *a,float_status *s,bool saturate) +static void parts_float_to_e5m2 (FloatParts64 *a,float_status *s, +int scale,bool saturate) {switch (a->cls) {case float_class_snan:
@@ -2873,8 +2874,10 @@ static void parts_float_to_e5m2(FloatParts64 *a, float_status *s, bool saturate)case float_class_denormal:float_raise (float_flag_input_denormal_used, s); -break ; +/* fall through */ case float_class_normal: + a->exp +=MIN (MAX (scale,-0x7f ),0x7f ); +break ;case float_class_zero:break ;default :
@@ -2955,21 +2958,21 @@ float8_e4m3 float4_e2m1_to_float8_e4m3(float4_e2m1 a, float_status *s)return float8_e4m3_round_pack_canonical (&p, s, false); } -bfloat16 float8_e4m3_to_bfloat16 (float8_e4m3 a,float_status *s) +bfloat16 float8_e4m3_to_bfloat16 (float8_e4m3 a,int scale,float_status *s) {FloatParts64 p;float8_e4m3_unpack_canonical (&p, a, s); -parts_float_to_float (&p, s); +parts_scalbn (&p, scale, s);return bfloat16_round_pack_canonical (&p, s); } -bfloat16 float8_e5m2_to_bfloat16 (float8_e5m2 a,float_status *s) +bfloat16 float8_e5m2_to_bfloat16 (float8_e5m2 a,int scale,float_status *s) {FloatParts64 p;float8_e5m2_unpack_canonical (&p, a, s); -parts_float_to_float (&p, s); +parts_scalbn (&p, scale, s);return bfloat16_round_pack_canonical (&p, s); }
@@ -2993,21 +2996,23 @@ float64 float16_to_float64(float16 a, bool ieee, float_status *s)return float64_round_pack_canonical (&p, s); } -float8_e4m3 float32_to_float8_e4m3 (float32 a,bool saturate,float_status *s) +float8_e4m3 float32_to_float8_e4m3 (float32 a,int scale, +bool saturate,float_status *s) {FloatParts64 p;float32_unpack_canonical (&p, a, s); -parts_float_to_float (&p, s); +parts_scalbn (&p, scale, s);return float8_e4m3_round_pack_canonical (&p, s, saturate); } -float8_e5m2 float32_to_float8_e5m2 (float32 a,bool saturate,float_status *s) +float8_e5m2 float32_to_float8_e5m2 (float32 a,int scale, +bool saturate,float_status *s) {FloatParts64 p;float32_unpack_canonical (&p, a, s); -parts_float_to_e5m2 (&p, s, saturate); +parts_float_to_e5m2 (&p, s, scale, saturate);return float8_e5m2_round_pack_canonical (&p, s, saturate); }
@@ -3078,21 +3083,23 @@ float32 float64_to_float32(float64 a, float_status *s)return float32_round_pack_canonical (&p, s); } -float8_e4m3 bfloat16_to_float8_e4m3 (bfloat16 a,bool saturate,float_status *s) +float8_e4m3 bfloat16_to_float8_e4m3 (bfloat16 a,int scale, +bool saturate,float_status *s) {FloatParts64 p;bfloat16_unpack_canonical (&p, a, s); -parts_float_to_float (&p, s); +parts_scalbn (&p, scale, s);return float8_e4m3_round_pack_canonical (&p, s, saturate); } -float8_e5m2 bfloat16_to_float8_e5m2 (bfloat16 a,bool saturate,float_status *s) +float8_e5m2 bfloat16_to_float8_e5m2 (bfloat16 a,int scale, +bool saturate,float_status *s) {FloatParts64 p;bfloat16_unpack_canonical (&p, a, s); -parts_float_to_e5m2 (&p, s, saturate); +parts_float_to_e5m2 (&p, s, scale, saturate);return float8_e5m2_round_pack_canonical (&p, s, saturate); }
Signature · 1 line
2.43.0
PATCH v2 20/40 fpu: Add conversions between float16 and float8 formats
In reply to Richard Henderson--- include/fpu/softfloat.h | 8 +++++++- fpu/softfloat.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-)
include/fpu/softfloat.h +7 -1
@@ -196,16 +196,22 @@ float128 uint128_to_float128(Int128, float_status *status);float8_e4m3 float4_e2m1_to_float8_e4m3 (float4_e2m1 ,float_status *status);bfloat16 float8_e4m3_to_bfloat16 (float8_e4m3 ,int scale,float_status *status); +float16 float8_e4m3_to_float16 (float8_e4m3 ,int scale,float_status *status);float8_e4m3 bfloat16_to_float8_e4m3 (bfloat16 ,int scale,bool sat,float_status *status); +float8_e4m3 float16_to_float8_e4m3 (float16 ,int scale, +bool sat,float_status *status);float8_e4m3 float32_to_float8_e4m3 (float32 ,int scale,bool sat,float_status *status);bfloat16 float8_e5m2_to_bfloat16 (float8_e5m2 ,int scale,float_status *status); +float16 float8_e5m2_to_float16 (float8_e5m2 ,int scale,float_status *status);float8_e5m2 bfloat16_to_float8_e5m2 (bfloat16 ,int scale,bool sat,float_status *status); +float8_e5m2 float16_to_float8_e5m2 (float16 ,int scale, +bool sat,float_status *status);float8_e5m2 float32_to_float8_e5m2 (float32 ,int scale, -bool sat,float_status *status); +bool sat,float_status *status);/*---------------------------------------------------------------------------- | Software half-precision conversion routines.
fpu/softfloat.c +38 -0
@@ -2958,6 +2958,15 @@ float8_e4m3 float4_e2m1_to_float8_e4m3(float4_e2m1 a, float_status *s)return float8_e4m3_round_pack_canonical (&p, s, false); } +float16 float8_e4m3_to_float16 (float8_e4m3 a,int scale,float_status *s) +{ +FloatParts64 p; + +float8_e4m3_unpack_canonical (&p, a, s); +parts_scalbn (&p, scale, s); +return float16_round_pack_canonical (&p, s); +} +bfloat16 float8_e4m3_to_bfloat16 (float8_e4m3 a,int scale,float_status *s) {FloatParts64 p;
@@ -2967,6 +2976,15 @@ bfloat16 float8_e4m3_to_bfloat16(float8_e4m3 a, int scale, float_status *s)return bfloat16_round_pack_canonical (&p, s); } +float16 float8_e5m2_to_float16 (float8_e5m2 a,int scale,float_status *s) +{ +FloatParts64 p; + +float8_e5m2_unpack_canonical (&p, a, s); +parts_scalbn (&p, scale, s); +return float16_round_pack_canonical (&p, s); +} +bfloat16 float8_e5m2_to_bfloat16 (float8_e5m2 a,int scale,float_status *s) {FloatParts64 p;
@@ -2976,6 +2994,26 @@ bfloat16 float8_e5m2_to_bfloat16(float8_e5m2 a, int scale, float_status *s)return bfloat16_round_pack_canonical (&p, s); } +float8_e4m3 float16_to_float8_e4m3 (float16 a,int scale, +bool saturate,float_status *s) +{ +FloatParts64 p; + +float16_unpack_canonical (&p, a, s); +parts_scalbn (&p, scale, s); +return float8_e4m3_round_pack_canonical (&p, s, saturate); +} + +float8_e5m2 float16_to_float8_e5m2 (float16 a,int scale, +bool saturate,float_status *s) +{ +FloatParts64 p; + +float16_unpack_canonical (&p, a, s); +parts_float_to_e5m2 (&p, s, scale, saturate); +return float8_e5m2_round_pack_canonical (&p, s, saturate); +} +float32 float16_to_float32 (float16 a,bool ieee,float_status *s) {const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp;
Signature · 1 line
2.43.0
PATCH v2 21/40 target/arm: Split vector-type.h from cpu.h
In reply to Richard HendersonWe want to be able to reference ARMVectorType etc from common code, so move it out of cpu.h.
--- target/arm/cpu.h | 38 +--------------------------------- target/arm/vector-type.h | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 target/arm/vector-type.h
target/arm/cpu.h +1 -37
@@ -35,6 +35,7 @@#include "target/arm/gtimer.h" #include "target/arm/cpu-sysregs.h" #include "target/arm/mmuidx.h" +#include "target/arm/vector-type.h" #define EXCP_UDEF 1/* undefined instruction */ #define EXCP_SWI 2/* software interrupt */
@@ -140,43 +141,6 @@ typedef struct ARMGenericTimer {uint64_t ctl;/* Timer Control register */ } ARMGenericTimer; -/* Define a maximum sized vector register. -* For 32-bit, this is a 128-bit NEON/AdvSIMD register. -* For 64-bit, this is a 2048-bit SVE register. -* -* Note that the mapping between S, D, and Q views of the register bank -* differs between AArch64 and AArch32. -* In AArch32: -* Qn = regs[n].d[1]:regs[n].d[0] -* Dn = regs[n / 2].d[n & 1] -* Sn = regs[n / 4].d[n % 4 / 2], -* bits 31..0 for even n, and bits 63..32 for odd n -* (and regs[16] to regs[31] are inaccessible) -* In AArch64: -* Zn = regs[n].d[*] -* Qn = regs[n].d[1]:regs[n].d[0] -* Dn = regs[n].d[0] -* Sn = regs[n].d[0] bits 31..0 -* Hn = regs[n].d[0] bits 15..0 -* -* This corresponds to the architecturally defined mapping between -* the two execution states, and means we do not need to explicitly -* map these registers when changing states. -* -* Align the data for use with TCG host vector operations. -*/ - -#define ARM_MAX_VQ 16 - -typedef struct ARMVectorReg { - uint64_t d[2 * ARM_MAX_VQ] QEMU_ALIGNED(16); -}ARMVectorReg ; - -/* In AArch32 mode, predicate registers do not exist at all. */ -typedef struct ARMPredicateReg { - uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); -}ARMPredicateReg ; -/* In AArch32 mode, PAC keys do not exist at all. */ typedef struct ARMPACKey { uint64_t lo, hi;
target/arm/vector-type.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 22/40 target/arm: Move vectors_overlap to vec_internal.h
In reply to Richard HendersonWe will shortly need this outside of sme_helper.c.
--- target/arm/tcg/vec_internal.h | 8 ++++++++ target/arm/tcg/sme_helper.c | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-)
target/arm/tcg/vec_internal.h +8 -0
@@ -21,6 +21,7 @@#define TARGET_ARM_VEC_INTERNAL_H #include "fpu/softfloat.h" +#include "vector-type.h" typedef struct CPUArchState CPUARMState ;
@@ -461,6 +462,13 @@ static inline void depositn(uint64_t *p, unsigned pos, } } +/* Determine if [x, x+nx) overlaps [y, y+ny). */ +static inline bool vectors_overlap (ARMVectorReg *x,unsigned nx, +ARMVectorReg *y,unsigned ny) +{ +return !(x + nx <= y || y + ny <= x); +} +#define DO_3OP (NAME ,FUNC ,TYPE ) \ void HELPER(NAME)(void *vd, void *vn, void *vm, \ float_status * stat, uint32_t desc) \
target/arm/tcg/sme_helper.c +0 -6
@@ -33,12 +33,6 @@#define HELPER_H "tcg/helper-sme-defs.h"#include "exec/helper-info.c.inc" -static bool vectors_overlap (ARMVectorReg *x,unsigned nx, -ARMVectorReg *y,unsigned ny) -{ -return !(x + nx <= y || y + ny <= x); -} -void helper_set_svcr (CPUARMState *env,uint32_t val,uint32_t mask) {aarch64_set_svcr (env, val, mask);
Signature · 1 line
2.43.0
PATCH v2 23/40 target/arm: Implement BF1CVTL, BF1CVTL2, BF2CVTL, BF2CVTL2 for AdvSIMD
In reply to Richard Henderson--- target/arm/helper-fp8.h | 14 ++++ target/arm/tcg/helper-fp8-defs.h | 6 ++ target/arm/tcg/translate-a64.h | 1 + target/arm/tcg/fp8_helper.c | 123 +++++++++++++++++++++++++++++++ target/arm/tcg/translate-a64.c | 34 +++++++++ target/arm/tcg/a64.decode | 3 + target/arm/tcg/meson.build | 1 + 7 files changed, 182 insertions(+) create mode 100644 target/arm/helper-fp8.h create mode 100644 target/arm/tcg/helper-fp8-defs.h create mode 100644 target/arm/tcg/fp8_helper.c
target/arm/helper-fp8.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef HELPER_FP8_H +#define HELPER_FP8_H + +#include "exec/helper-proto-common.h" +#include "exec/helper-gen-common.h" + +#define HELPER_H "tcg/helper-fp8-defs.h" +#include "exec/helper-proto.h.inc" +#include "exec/helper-gen.h.inc" +#undef HELPER_H + +#endif /* HELPER_FP8_H */
target/arm/tcg/helper-fp8-defs.h new file +6 -0
@@ -0,0 +1,6 @@ +/* +* AArch64 FP8 helper definitions +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +DEF_HELPER_FLAGS_4 (advsimd_bfcvtl,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/translate-a64.h +1 -0
@@ -25,6 +25,7 @@ TCGv_i64 read_cpu_reg_sp(DisasContext *s, int reg, int sf);void write_fp_dreg (DisasContext *s,int reg,TCGv_i64 v);bool logic_imm_decode_wmask (uint64_t *result,unsigned int immn,unsigned int imms,unsigned int immr); +bool fpmr_access_check (DisasContext *s);bool sve_access_check (DisasContext *s);bool sme_enabled_check (DisasContext *s);bool sme_enabled_check_with_svcr (DisasContext *s,unsigned );
target/arm/tcg/fp8_helper.c new file +123 -0
123 lines not on this page · raw message
target/arm/tcg/translate-a64.c +34 -0
@@ -21,6 +21,7 @@#include "helper-a64.h" #include "helper-sme.h" #include "helper-sve.h" +#include "helper-fp8.h" #include "translate.h" #include "translate-a64.h" #include "qemu/log.h"
@@ -1456,6 +1457,24 @@ static bool fp_access_check(DisasContext *s)return fp_access_check_only (s) &&nonstreaming_check (s); } +/* +* Check that FPMR access is enabled, for an indirect reference by a +* vector instruction. See CheckFPMREnabled(). +*/ +bool fpmr_access_check (DisasContext *s) +{ +if (s->fpmr_el) { +/* +* While denied direct access to the FPMR raises SystemRegisterTrap +* and targets a specific EL, denied indirect access to the FPMR +* results in a simple UNDEFINED to the default exception level. +*/ +unallocated_encoding (s); +return false; + } +return true; +} +/* * Return <0 for non-supported element sizes, with MO_16 controlled by * FEAT_FP16; return 0 for fp disabled; otherwise return >0 for success.
@@ -10611,6 +10630,21 @@ static bool trans_FCVTL_v(DisasContext *s, arg_qrr_e *a)return true; } +static bool do_f8cvt (DisasContext *s,arg_qrr_e *a, +gen_helper_gvec_2_ptr *fn,bool issrc2) +{ +if (fpmr_access_check (s) &&fp_access_check (s)) { +tcg_gen_gvec_2_ptr (vec_full_reg_offset (s, a->rd), +vec_full_reg_offset (s, a->rn), + tcg_env,16 ,vec_full_reg_size (s), + issrc2 | (a->q <<1 ) | (FPST_A64 <<2 ), fn); + } +return true; +} + +TRANS_FEAT(BF1CVTL, aa64_f8cvt, do_f8cvt, a, gen_helper_advsimd_bfcvtl, false) +TRANS_FEAT(BF2CVTL, aa64_f8cvt, do_f8cvt, a, gen_helper_advsimd_bfcvtl, true) +static bool trans_OK (DisasContext *s,arg_OK *a) {return true;
target/arm/tcg/a64.decode +3 -0
@@ -1910,6 +1910,9 @@ URSQRTE_v 0.10 1110 101 00001 11001 0 ..... ..... @qrr_s FCVTL_v 0.00 1110 0.1 00001 01111 0 ..... ..... @qrr_sd +BF1CVTL 0.10 1110 101 00001 01111 0 ..... ..... @qrr_h +BF2CVTL 0.10 1110 111 00001 01111 0 ..... ..... @qrr_h + &fcvt_q rd rn esz q shift @fcvtq_h . q:1 . ...... 001 .... ...... rn:5 rd:5 \ &fcvt_q esz=1 shift=%fcvt_f_sh_h
target/arm/tcg/meson.build +1 -0
@@ -47,6 +47,7 @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'sme_helper.c', 'sve_helper.c', 'vec_helper64.c', + 'fp8_helper.c', )) arm_common_system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('cpu-v7m.c'))
Signature · 1 line
2.43.0
PATCH v2 24/40 target/arm: Implement BF1CVT, BF1CVTLT, BF2CVT, BF2CVTLT for SVE
In reply to Richard Henderson--- target/arm/cpu-features.h | 6 ++++++ target/arm/tcg/helper-fp8-defs.h | 1 + target/arm/tcg/fp8_helper.c | 28 ++++++++++++++++++++++++++++ target/arm/tcg/translate-sve.c | 23 +++++++++++++++++++++++ target/arm/tcg/sve.decode | 6 ++++++ 5 files changed, 64 insertions(+)
target/arm/cpu-features.h +6 -0
@@ -1624,6 +1624,12 @@ isar_feature_aa64_sme2_or_sve2_faminmax(const ARMISARegisters *id)return isar_feature_aa64_sme2_or_sve2 (id) &&isar_feature_aa64_faminmax (id); } +static inline bool +isar_feature_aa64_sme2_or_sve2_f8cvt (const ARMISARegisters *id) +{ +return isar_feature_aa64_sme2_or_sve2 (id) &&isar_feature_aa64_f8cvt (id); +} +/* * Feature tests for "does this exist in either 32-bit or 64-bit?" */
target/arm/tcg/helper-fp8-defs.h +1 -0
@@ -4,3 +4,4 @@*/ DEF_HELPER_FLAGS_4(advsimd_bfcvtl, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4 (sve2_bfcvt,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +28 -0
@@ -121,3 +121,31 @@ void HELPER(advsimd_bfcvtl)(void *vd, void *vn, CPUARMState *env, uint32_t desc)fp8_finish (env, &ctx);clear_tail (vd,16 ,simd_maxsz (desc)); } + +void HELPER (sve2_bfcvt )(void *vd,void *vn,CPUARMState *env,uint32_t desc) +{ +FP8Context ctx =fp8_src_start (env, desc,0x3f ); +uint8_t *n = vn; +uint16_t *d = vd; +size_t nelem =simd_oprsz (desc) /2 ; + +switch (ctx.f8fmt) { +case OFP8_E5M2 : +for (size_t i =0 ; i < nelem; ++i) { +float8_e5m2 e = n[H1 (2 * i + ctx.high)]; + d[H2 (i)] =float8_e5m2_to_bfloat16 (e, ctx.scale, &ctx.stat); + } +break ; +case OFP8_E4M3 : +for (size_t i =0 ; i < nelem; ++i) { +float8_e4m3 e = n[H1 (2 * i + ctx.high)]; + d[H2 (i)] =float8_e4m3_to_bfloat16 (e, ctx.scale, &ctx.stat); + } +break ; +default : +bfloat16_invalid_input (d, nelem, &ctx.stat); +break ; + } + +fp8_finish (env, &ctx); +}
target/arm/tcg/translate-sve.c +23 -0
@@ -21,6 +21,7 @@#include "cpu.h" #include "helper-sme.h" #include "helper-sve.h" +#include "helper-fp8.h" #include "translate.h" #include "translate-a64.h" #include "fpu/softfloat.h"
@@ -4066,6 +4067,28 @@ TRANS_FEAT(FRSQRTE, aa64_sme_or_sve, gen_gvec_fpst_ah_arg_zz, s->fpcr_ah && dc_isar_feature(aa64_rpres, s) ? frsqrte_rpres_fns[a->esz] : frsqrte_fns[a->esz], a, 0) +static bool do_f8cvt (DisasContext *s,arg_rr_esz *a, +gen_helper_gvec_2_ptr *fn,bool issrc2,bool isodd) +{ +if (fpmr_access_check (s) &&sve_access_check (s)) { +unsigned vsz =vec_full_reg_size (s); +tcg_gen_gvec_2_ptr (vec_full_reg_offset (s, a->rd), +vec_full_reg_offset (s, a->rn), + tcg_env, vsz, vsz, + issrc2 | (isodd <<1 ) | (FPST_A64 <<2 ), fn); + } +return true; +} + +TRANS_FEAT (BF1CVT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_bfcvt, false, false) +TRANS_FEAT (BF2CVT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_bfcvt, true, false) +TRANS_FEAT (BF1CVTLT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_bfcvt, false, true) +TRANS_FEAT (BF2CVTLT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_bfcvt, true, true) +/* *** SVE Floating Point Compare with Zero Group */
target/arm/tcg/sve.decode +6 -0
@@ -108,6 +108,7 @@ # Two operand @pd_pn ........ esz:2 .. .... ....... rn:4 . rd:4 &rr_esz @rd_rn ........ esz:2 ...... ...... rn:5 rd:5 &rr_esz +@rd_rn_e0 ........ .. ...... ...... rn:5 rd:5 &rr_esz esz=0 @rd_rnx2 ........ ... ..... ...... ..... rd:5 &rr_esz rn=%rn_ax2 # Two operand with governing predicate, flags setting
@@ -1090,6 +1091,11 @@ FMINQV 01100100 .. 010 111 101 ... ..... ..... @rd_pg_rn FRECPE 01100101 .. 001 110 001100 ..... ..... @rd_rn FRSQRTE 01100101 .. 001 111 001100 ..... ..... @rd_rn +BF1CVT 01100101 00 001 000 001110 ..... ..... @rd_rn_e0 +BF2CVT 01100101 00 001 000 001111 ..... ..... @rd_rn_e0 +BF1CVTLT 01100101 00 001 001 001110 ..... ..... @rd_rn_e0 +BF2CVTLT 01100101 00 001 001 001111 ..... ..... @rd_rn_e0 + ### SVE FP Compare with Zero Group FCMGE_ppz0 01100101 .. 0100 00 001 ... ..... 0 .... @pd_pg_rn
Signature · 1 line
2.43.0
PATCH v2 25/40 target/arm: Rename SME BFCVT patterns to BFCVT_hs
In reply to Richard HendersonThe existing pattern is BFCVT (BFloat16 to 8-bit floating-point). In preparation for introducing more insns of the same name, append the operand sizes.
--- target/arm/tcg/helper-sme-defs.h | 2 +- target/arm/tcg/sme_helper.c | 2 +- target/arm/tcg/translate-sme.c | 4 ++-- target/arm/tcg/sme.decode | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
target/arm/tcg/helper-sme-defs.h +1 -1
@@ -250,7 +250,7 @@ DEF_HELPER_FLAGS_5(sme2_umlsll_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, DEF_HELPER_FLAGS_5(sme2_usmlall_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sme2_sumlall_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) -DEF_HELPER_FLAGS_4(sme2_bfcvt, TCG_CALL_NO_RWG, void, ptr, ptr, fpst, i32) +DEF_HELPER_FLAGS_4(sme2_bfcvt_hs, TCG_CALL_NO_RWG, void, ptr, ptr, fpst, i32) DEF_HELPER_FLAGS_4(sme2_bfcvtn, TCG_CALL_NO_RWG, void, ptr, ptr, fpst, i32) DEF_HELPER_FLAGS_4(sme2_fcvt_n, TCG_CALL_NO_RWG, void, ptr, ptr, fpst, i32)DEF_HELPER_FLAGS_4 (sme2_fcvtn,TCG_CALL_NO_RWG , void, ptr, ptr, fpst, i32)
target/arm/tcg/sme_helper.c +1 -1
@@ -1742,7 +1742,7 @@ DO_MLALL_IDX(sme2_sumlall_idx_s, uint32_t, int8_t, uint8_t, H4, H1, +)#undef DO_MLALL_IDX/* Convert and compress */ -void HELPER (sme2_bfcvt )(void *vd,void *vs,float_status *fpst,uint32_t desc) +void HELPER (sme2_bfcvt_hs )(void *vd,void *vs,float_status *fpst,uint32_t desc) {ARMVectorReg scratch;size_t oprsz =simd_oprsz (desc);
target/arm/tcg/translate-sme.c +2 -2
@@ -1447,8 +1447,8 @@ static bool do_zz_fpst(DisasContext *s, arg_zz_n *a, int data,return true; } -TRANS_FEAT (BFCVT , aa64_sme2, do_zz_fpst, a,0 , - FPST_A64, gen_helper_sme2_bfcvt) +TRANS_FEAT (BFCVT_hs, aa64_sme2, do_zz_fpst, a,0 , + FPST_A64, gen_helper_sme2_bfcvt_hs)TRANS_FEAT (BFCVTN , aa64_sme2, do_zz_fpst, a,0 , FPST_A64, gen_helper_sme2_bfcvtn) TRANS_FEAT(FCVT_n, aa64_sme2, do_zz_fpst, a, 0,
target/arm/tcg/sme.decode +1 -1
@@ -789,7 +789,7 @@ SUB_aaz_d 11000001 111 000010 .. 111 ...00 11 ... @az_4x4_o3 @zz_4x2_n1 ........ ... ..... ...... .... . ..... \ &zz_n n=1 zd=%zd_ax4 zn=%zn_ax2 -BFCVT 11000001 011 00000 111000 ....0 ..... @zz_1x2 +BFCVT_hs 11000001 011 00000 111000 ....0 ..... @zz_1x2 BFCVTN 11000001 011 00000 111000 ....1 ..... @zz_1x2 FCVT_n 11000001 001 00000 111000 ....0 ..... @zz_1x2
Signature · 1 line
2.43.0
PATCH v2 26/40 target/arm: Implement BF1CVT, BF1CVTL, BF2CVT, BF2CVTL for SME
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 + target/arm/tcg/fp8_helper.c | 79 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-sme.c | 19 ++++++++ target/arm/tcg/sme.decode | 5 ++ 4 files changed, 105 insertions(+)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -5,3 +5,5 @@ DEF_HELPER_FLAGS_4(advsimd_bfcvtl, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_bfcvt, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4(sme2_bfcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4 (sme2_bfcvtl_hb,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +79 -0
82 lines not on this page · raw message
target/arm/tcg/translate-sme.c +19 -0
@@ -22,6 +22,7 @@#include "helper-a64.h" #include "helper-sme.h" #include "helper-sve.h" +#include "helper-fp8.h" #include "translate.h" #include "translate-a64.h"
@@ -1531,6 +1532,24 @@ TRANS_FEAT(UUNPK_4bh, aa64_sme2, do_zz, a, 0, gen_helper_sme2_uunpk4_bh) TRANS_FEAT(UUNPK_4hs, aa64_sme2, do_zz, a, 0, gen_helper_sme2_uunpk4_hs) TRANS_FEAT(UUNPK_4sd, aa64_sme2, do_zz, a, 0, gen_helper_sme2_uunpk4_sd) +static bool do_f8cvt (DisasContext *s,arg_zz_n *a, +gen_helper_gvec_2_ptr *fn,bool issrc2) +{ +if (fpmr_access_check (s) &&sme_sm_enabled_check (s)) { +int svl =streaming_vec_reg_size (s); +tcg_gen_gvec_2_ptr (vec_full_reg_offset (s, a->zd), +vec_full_reg_offset (s, a->zn), + tcg_env, svl, svl, + issrc2 | (FPST_ZA <<2 ), fn); + } +return true; +} + +TRANS_FEAT(BF1CVT, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvt_hb, 0) +TRANS_FEAT(BF2CVT, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvt_hb, 1) +TRANS_FEAT(BF1CVTL, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvtl_hb, 0) +TRANS_FEAT(BF2CVTL, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvtl_hb, 1) +static bool do_zipuzp_4 (DisasContext *s,arg_zz_e *a,gen_helper_gvec_2 *const fn[5 ]) {
target/arm/tcg/sme.decode +5 -0
@@ -853,6 +853,11 @@ UUNPK_4bh 11000001 011 10101 111000 ....0 ...01 @zz_4x2_n1 UUNPK_4hs 11000001 101 10101 111000 ....0 ...01 @zz_4x2_n1 UUNPK_4sd 11000001 111 10101 111000 ....0 ...01 @zz_4x2_n1 +BF1CVT 11000001 011 00110 111000 ..... ....0 @zz_2x1 +BF2CVT 11000001 111 00110 111000 ..... ....0 @zz_2x1 +BF1CVTL 11000001 011 00110 111000 ..... ....1 @zz_2x1 +BF2CVTL 11000001 111 00110 111000 ..... ....1 @zz_2x1 + ZIP_4 11000001 esz:2 1 10110 111000 ...00 ... 00 \ &zz_e zd=%zd_ax4 zn=%zn_ax4 ZIP_4 11000001 001 10111 111000 ...00 ... 00 \
Signature · 1 line
2.43.0
PATCH v2 27/40 target/arm: Implement F1CVTL, F1CVTL2, F2CVTL, F2CVTL2 for AdvSIMD
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 ++ target/arm/tcg/fp8_helper.c | 42 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-a64.c | 3 +++ target/arm/tcg/a64.decode | 3 +++ 4 files changed, 50 insertions(+)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -7,3 +7,5 @@ DEF_HELPER_FLAGS_4(advsimd_bfcvtl, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_bfcvt, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_bfcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_bfcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) + +DEF_HELPER_FLAGS_4 (advsimd_fcvtl_hb,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +42 -0
54 lines not on this page · raw message
target/arm/tcg/translate-a64.c +3 -0
@@ -10642,6 +10642,9 @@ static bool do_f8cvt(DisasContext *s, arg_qrr_e *a,return true; } +TRANS_FEAT(F1CVTL, aa64_f8cvt, do_f8cvt, a, gen_helper_advsimd_fcvtl_hb, false) +TRANS_FEAT(F2CVTL, aa64_f8cvt, do_f8cvt, a, gen_helper_advsimd_fcvtl_hb, true) + TRANS_FEAT(BF1CVTL, aa64_f8cvt, do_f8cvt, a, gen_helper_advsimd_bfcvtl, false)TRANS_FEAT (BF2CVTL , aa64_f8cvt, do_f8cvt, a, gen_helper_advsimd_bfcvtl, true)
target/arm/tcg/a64.decode +3 -0
@@ -1910,6 +1910,9 @@ URSQRTE_v 0.10 1110 101 00001 11001 0 ..... ..... @qrr_s FCVTL_v 0.00 1110 0.1 00001 01111 0 ..... ..... @qrr_sd +F1CVTL 0.10 1110 001 00001 01111 0 ..... ..... @qrr_h +F2CVTL 0.10 1110 011 00001 01111 0 ..... ..... @qrr_h + BF1CVTL 0.10 1110 101 00001 01111 0 ..... ..... @qrr_h BF2CVTL 0.10 1110 111 00001 01111 0 ..... ..... @qrr_h
Signature · 1 line
2.43.0
PATCH v2 28/40 target/arm: Implement F1CVT, F1CVTLT, F2CVT, F2CVTLT for SVE
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 1 + target/arm/tcg/fp8_helper.c | 28 ++++++++++++++++++++++++++++ target/arm/tcg/translate-sve.c | 9 +++++++++ target/arm/tcg/sve.decode | 5 +++++ 4 files changed, 43 insertions(+)
target/arm/tcg/helper-fp8-defs.h +1 -0
@@ -9,3 +9,4 @@ DEF_HELPER_FLAGS_4(sme2_bfcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_bfcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(advsimd_fcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4 (sve2_fcvt_hb,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +28 -0
@@ -192,6 +192,34 @@ void HELPER(sve2_bfcvt)(void *vd, void *vn, CPUARMState *env, uint32_t desc)fp8_finish (env, &ctx); } +void HELPER (sve2_fcvt_hb )(void *vd,void *vn,CPUARMState *env,uint32_t desc) +{ +FP8Context ctx =fp8_src_start (env, desc,0xf ); +uint8_t *n = vn; +uint16_t *d = vd; +size_t nelem =simd_oprsz (desc) /2 ; + +switch (ctx.f8fmt) { +case OFP8_E5M2 : +for (size_t i =0 ; i < nelem; ++i) { +float8_e5m2 e = n[H1 (2 * i + ctx.high)]; + d[H2 (i)] =float8_e5m2_to_float16 (e, ctx.scale, &ctx.stat); + } +break ; +case OFP8_E4M3 : +for (size_t i =0 ; i < nelem; ++i) { +float8_e4m3 e = n[H1 (2 * i + ctx.high)]; + d[H2 (i)] =float8_e4m3_to_float16 (e, ctx.scale, &ctx.stat); + } +break ; +default : +float16_invalid_input (d, nelem, &ctx.stat); +break ; + } + +fp8_finish (env, &ctx); +} +void HELPER (sme2_bfcvt_hb )(void *vd,void *vn,CPUARMState *env,uint32_t desc) {FP8Context ctx =fp8_src_start (env, desc,0x3f );
target/arm/tcg/translate-sve.c +9 -0
@@ -4080,6 +4080,15 @@ static bool do_f8cvt(DisasContext *s, arg_rr_esz *a,return true; } +TRANS_FEAT (F1CVT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_fcvt_hb, false, false) +TRANS_FEAT (F2CVT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_fcvt_hb, true, false) +TRANS_FEAT (F1CVTLT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_fcvt_hb, false, true) +TRANS_FEAT (F2CVTLT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, + gen_helper_sve2_fcvt_hb, true, true) +TRANS_FEAT (BF1CVT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, gen_helper_sve2_bfcvt, false, false) TRANS_FEAT(BF2CVT, aa64_sme2_or_sve2_f8cvt, do_f8cvt, a,
target/arm/tcg/sve.decode +5 -0
@@ -1091,6 +1091,11 @@ FMINQV 01100100 .. 010 111 101 ... ..... ..... @rd_pg_rn FRECPE 01100101 .. 001 110 001100 ..... ..... @rd_rn FRSQRTE 01100101 .. 001 111 001100 ..... ..... @rd_rn +F1CVT 01100101 00 001 000 001100 ..... ..... @rd_rn_e0 +F2CVT 01100101 00 001 000 001101 ..... ..... @rd_rn_e0 +F1CVTLT 01100101 00 001 001 001100 ..... ..... @rd_rn_e0 +F2CVTLT 01100101 00 001 001 001101 ..... ..... @rd_rn_e0 + BF1CVT 01100101 00 001 000 001110 ..... ..... @rd_rn_e0 BF2CVT 01100101 00 001 000 001111 ..... ..... @rd_rn_e0 BF1CVTLT 01100101 00 001 001 001110 ..... ..... @rd_rn_e0
Signature · 1 line
2.43.0
PATCH v2 29/40 target/arm: Implement F1CVT, F1CVTL, F2CVT, F2CVTL for SME
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 + target/arm/tcg/fp8_helper.c | 79 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-sme.c | 5 ++ target/arm/tcg/sme.decode | 5 ++ 4 files changed, 91 insertions(+)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -10,3 +10,5 @@ DEF_HELPER_FLAGS_4(sme2_bfcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(advsimd_fcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_fcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4(sme2_fcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4 (sme2_fcvtl_hb,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +79 -0
88 lines not on this page · raw message
target/arm/tcg/translate-sme.c +5 -0
@@ -1545,6 +1545,11 @@ static bool do_f8cvt(DisasContext *s, arg_zz_n *a,return true; } +TRANS_FEAT(F1CVT, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_fcvt_hb, 0) +TRANS_FEAT(F2CVT, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_fcvt_hb, 1) +TRANS_FEAT(F1CVTL, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_fcvtl_hb, 0) +TRANS_FEAT(F2CVTL, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_fcvtl_hb, 1) + TRANS_FEAT(BF1CVT, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvt_hb, 0) TRANS_FEAT(BF2CVT, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvt_hb, 1)TRANS_FEAT (BF1CVTL , aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvtl_hb,0 )
target/arm/tcg/sme.decode +5 -0
@@ -853,6 +853,11 @@ UUNPK_4bh 11000001 011 10101 111000 ....0 ...01 @zz_4x2_n1 UUNPK_4hs 11000001 101 10101 111000 ....0 ...01 @zz_4x2_n1 UUNPK_4sd 11000001 111 10101 111000 ....0 ...01 @zz_4x2_n1 +F1CVT 11000001 001 00110 111000 ..... ....0 @zz_2x1 +F2CVT 11000001 101 00110 111000 ..... ....0 @zz_2x1 +F1CVTL 11000001 001 00110 111000 ..... ....1 @zz_2x1 +F2CVTL 11000001 101 00110 111000 ..... ....1 @zz_2x1 + BF1CVT 11000001 011 00110 111000 ..... ....0 @zz_2x1 BF2CVT 11000001 111 00110 111000 ..... ....0 @zz_2x1 BF1CVTL 11000001 011 00110 111000 ..... ....1 @zz_2x1
Signature · 1 line
2.43.0
PATCH v2 30/40 target/arm: Implement BFCVTN for SVE
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 ++ target/arm/tcg/fp8_helper.c | 55 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-sve.c | 3 ++ target/arm/tcg/sve.decode | 2 ++ 4 files changed, 62 insertions(+)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -12,3 +12,5 @@ DEF_HELPER_FLAGS_4(advsimd_fcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_fcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_fcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_fcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) + +DEF_HELPER_FLAGS_4 (sve2_bfcvtn_bh,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +55 -0
70 lines not on this page · raw message
target/arm/tcg/translate-sve.c +3 -0
@@ -4098,6 +4098,9 @@ TRANS_FEAT(BF1CVTLT, aa64_sme2_or_sve2_f8cvt, do_f8cvt, a,TRANS_FEAT (BF2CVTLT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, gen_helper_sve2_bfcvt, true, true) +TRANS_FEAT (BFCVTN , aa64_sme2_or_sve2_f8cvt, do_f8cvt, + a, gen_helper_sve2_bfcvtn_bh, false, false) +/* *** SVE Floating Point Compare with Zero Group */
target/arm/tcg/sve.decode +2 -0
@@ -1101,6 +1101,8 @@ BF2CVT 01100101 00 001 000 001111 ..... ..... @rd_rn_e0 BF1CVTLT 01100101 00 001 001 001110 ..... ..... @rd_rn_e0 BF2CVTLT 01100101 00 001 001 001111 ..... ..... @rd_rn_e0 +BFCVTN 01100101 00 001 010 001110 ....0 ..... @rd_rnx2 esz=1 + ### SVE FP Compare with Zero Group FCMGE_ppz0 01100101 .. 0100 00 001 ... ..... 0 .... @pd_pg_rn
Signature · 1 line
2.43.0
PATCH v2 31/40 target/arm: Implement FCVTN (16- to 8-bit fp) for AdvSIMD
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 ++ target/arm/tcg/fp8_helper.c | 48 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-a64.c | 15 ++++++++++ target/arm/tcg/a64.decode | 2 ++ 4 files changed, 67 insertions(+)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -14,3 +14,5 @@ DEF_HELPER_FLAGS_4(sme2_fcvt_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_fcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_bfcvtn_bh, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) + +DEF_HELPER_FLAGS_5 (gvec_fcvt_bh,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +48 -0
51 lines not on this page · raw message
target/arm/tcg/translate-a64.c +15 -0
@@ -6521,6 +6521,21 @@ static gen_helper_gvec_3_ptr * const f_vector_fscale[3] = { }; TRANS_FEAT(FSCALE, aa64_f8cvt, do_fp3_vector, a, 0, f_vector_fscale) +static bool trans_FCVTN_bh (DisasContext *s,arg_qrrr_e *a) +{ +if (!dc_isar_feature (aa64_f8cvt, s)) { +return false; + } +if (fpmr_access_check (s) &&fp_access_check (s)) { +tcg_gen_gvec_3_ptr (vec_full_reg_offset (s, a->rd), +vec_full_reg_offset (s, a->rn), +vec_full_reg_offset (s, a->rm), + tcg_env, a->q ?16 :8 ,vec_full_reg_size (s), +FPST_A64 <<2 , gen_helper_gvec_fcvt_bh); + } +return true; +} +static bool do_fmlal (DisasContext *s,arg_qrrr_e *a,bool is_s,bool is_2) {if (fp_access_check (s)) {
target/arm/tcg/a64.decode +2 -0
@@ -1201,6 +1201,8 @@ FAMIN 0.10 1110 1.1 ..... 11011 1 ..... ..... @qrrr_sd FSCALE 0.10 1110 110 ..... 00111 1 ..... ..... @qrrr_h FSCALE 0.10 1110 1.1 ..... 11111 1 ..... ..... @qrrr_sd +FCVTN_bh 0.00 1110 010 ..... 11110 1 ..... ..... @qrrr_h + ### Advanced SIMD scalar x indexed element FMUL_si 0101 1111 00 .. .... 1001 . 0 ..... ..... @rrx_h
Signature · 1 line
2.43.0
PATCH v2 32/40 target/arm: Implement FCVTN, FCVTN2 (32- to 8-bit fp) for AdvSIMD
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 ++ target/arm/tcg/fp8_helper.c | 42 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-a64.c | 16 ++++++++++++ target/arm/tcg/a64.decode | 1 + 4 files changed, 61 insertions(+)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -16,3 +16,5 @@ DEF_HELPER_FLAGS_4(sme2_fcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_bfcvtn_bh, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_5(gvec_fcvt_bh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, env, i32) + +DEF_HELPER_FLAGS_5 (advsimd_fcvt_bs,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +42 -0
45 lines not on this page · raw message
target/arm/tcg/translate-a64.c +16 -0
@@ -6536,6 +6536,22 @@ static bool trans_FCVTN_bh(DisasContext *s, arg_qrrr_e *a)return true; } +static bool trans_FCVTN_bs (DisasContext *s,arg_qrrr_e *a) +{ +if (!dc_isar_feature (aa64_f8cvt, s)) { +return false; + } +if (fpmr_access_check (s) &&fp_access_check (s)) { +tcg_gen_gvec_3_ptr (vec_full_reg_offset (s, a->rd), +vec_full_reg_offset (s, a->rn), +vec_full_reg_offset (s, a->rm), + tcg_env,16 ,vec_full_reg_size (s), + (a->q <<1 ) |FPST_A64 <<2 , + gen_helper_advsimd_fcvt_bs); + } +return true; +} +static bool do_fmlal (DisasContext *s,arg_qrrr_e *a,bool is_s,bool is_2) {if (fp_access_check (s)) {
target/arm/tcg/a64.decode +1 -0
@@ -1202,6 +1202,7 @@ FSCALE 0.10 1110 110 ..... 00111 1 ..... ..... @qrrr_h FSCALE 0.10 1110 1.1 ..... 11111 1 ..... ..... @qrrr_sd FCVTN_bh 0.00 1110 010 ..... 11110 1 ..... ..... @qrrr_h +FCVTN_bs 0.00 1110 000 ..... 11110 1 ..... ..... @qrrr_h ### Advanced SIMD scalar x indexed element
Signature · 1 line
2.43.0
PATCH v2 33/40 target/arm: Implement FCVTN (16- to 8-bit fp) for SVE
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 1 + target/arm/tcg/fp8_helper.c | 40 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-sve.c | 2 ++ target/arm/tcg/sve.decode | 1 + 4 files changed, 44 insertions(+)
target/arm/tcg/helper-fp8-defs.h +1 -0
@@ -16,5 +16,6 @@ DEF_HELPER_FLAGS_4(sme2_fcvtl_hb, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_bfcvtn_bh, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_5(gvec_fcvt_bh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4(sve2_fcvtn_bh, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32)DEF_HELPER_FLAGS_5 (advsimd_fcvt_bs,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +40 -0
@@ -481,6 +481,46 @@ void HELPER(gvec_fcvt_bh)(void *vd, void *vn, void *vm,clear_tail (vd, oprsz,simd_maxsz (desc)); } +void HELPER (sve2_fcvtn_bh )(void *vd,void *vn,CPUARMState *env,uint32_t desc) +{ +FP8Context ctx =fp8_dst_start (env, desc); +uint16_t *n0 = vn; +uint16_t *n1 = vn +sizeof (ARMVectorReg); +uint8_t *d = vd; +bool osc =FIELD_EX64 (env->vfp.fpmr,FPMR ,OSC ); +size_t oprsz =simd_oprsz (desc); +size_t nelem = oprsz /2 ; + +switch (ctx.f8fmt) { +case OFP8_E5M2 : +for (size_t i =0 ; i < nelem; ++i) { +float16 e0 = n0[H2 (i)]; +float16 e1 = n1[H2 (i)]; + d[H1 (2 * i +0 )] = +float16_to_float8_e5m2 (e0, ctx.scale, osc, &ctx.stat); + d[H1 (2 * i +1 )] = +float16_to_float8_e5m2 (e1, ctx.scale, osc, &ctx.stat); + } +break ; +case OFP8_E4M3 : +for (size_t i =0 ; i < nelem; ++i) { +float16 e0 = n0[H2 (i)]; +float16 e1 = n1[H2 (i)]; + d[H1 (2 * i +0 )] = +float16_to_float8_e4m3 (e0, ctx.scale, osc, &ctx.stat); + d[H1 (2 * i +1 )] = +float16_to_float8_e4m3 (e1, ctx.scale, osc, &ctx.stat); + } +break ; +default : +float8_invalid_output (d, oprsz, &ctx.stat); +break ; + } + +fp8_finish (env, &ctx); +} + +void HELPER (advsimd_fcvt_bs )(void *vd,void *vn,void *vm,CPUARMState *env,uint32_t desc) {
target/arm/tcg/translate-sve.c +2 -0
@@ -4098,6 +4098,8 @@ TRANS_FEAT(BF1CVTLT, aa64_sme2_or_sve2_f8cvt, do_f8cvt, a,TRANS_FEAT (BF2CVTLT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, gen_helper_sve2_bfcvt, true, true) +TRANS_FEAT (FCVTN , aa64_sme2_or_sve2_f8cvt, do_f8cvt, + a, gen_helper_sve2_fcvtn_bh, false, false)TRANS_FEAT (BFCVTN , aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, gen_helper_sve2_bfcvtn_bh, false, false)
target/arm/tcg/sve.decode +1 -0
@@ -1101,6 +1101,7 @@ BF2CVT 01100101 00 001 000 001111 ..... ..... @rd_rn_e0 BF1CVTLT 01100101 00 001 001 001110 ..... ..... @rd_rn_e0 BF2CVTLT 01100101 00 001 001 001111 ..... ..... @rd_rn_e0 +FCVTN 01100101 00 001 010 001100 ....0 ..... @rd_rnx2 esz=1 BFCVTN 01100101 00 001 010 001110 ....0 ..... @rd_rnx2 esz=1 ### SVE FP Compare with Zero Group
Signature · 1 line
2.43.0
PATCH v2 34/40 target/arm: Implement FCVTNB, FCVTNT for SVE
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 + target/arm/tcg/fp8_helper.c | 85 +++++++++++++++++++++++++++++++- target/arm/tcg/translate-sve.c | 4 ++ target/arm/tcg/sve.decode | 2 + 4 files changed, 92 insertions(+), 1 deletion(-)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -19,3 +19,5 @@ DEF_HELPER_FLAGS_5(gvec_fcvt_bh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_fcvtn_bh, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_5(advsimd_fcvt_bs, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4(sve2_fcvtnb_bs, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4 (sve2_fcvtnt_bs,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +84 -1
94 lines not on this page · raw message
target/arm/tcg/translate-sve.c +4 -0
@@ -4102,6 +4102,10 @@ TRANS_FEAT(FCVTN, aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, gen_helper_sve2_fcvtn_bh, false, false) TRANS_FEAT(BFCVTN, aa64_sme2_or_sve2_f8cvt, do_f8cvt, a, gen_helper_sve2_bfcvtn_bh, false, false) +TRANS_FEAT(FCVTNB, aa64_sme2_or_sve2_f8cvt, do_f8cvt, + a, gen_helper_sve2_fcvtnb_bs, false, false) +TRANS_FEAT (FCVTNT , aa64_sme2_or_sve2_f8cvt, do_f8cvt, + a, gen_helper_sve2_fcvtnt_bs, false, false)/* *** SVE Floating Point Compare with Zero Group
target/arm/tcg/sve.decode +2 -0
@@ -1103,6 +1103,8 @@ BF2CVTLT 01100101 00 001 001 001111 ..... ..... @rd_rn_e0 FCVTN 01100101 00 001 010 001100 ....0 ..... @rd_rnx2 esz=1 BFCVTN 01100101 00 001 010 001110 ....0 ..... @rd_rnx2 esz=1 +FCVTNB 01100101 00 001 010 001101 ....0 ..... @rd_rnx2 esz=1 +FCVTNT 01100101 00 001 010 001111 ....0 ..... @rd_rnx2 esz=1 ### SVE FP Compare with Zero Group
Signature · 1 line
2.43.0
PATCH v2 35/40 target/arm: Implement FCVT (FP16 to FP8) for SME
In reply to Richard Henderson--- target/arm/tcg/translate-sme.c | 16 ++++++++++++++++ target/arm/tcg/sme.decode | 2 ++ 2 files changed, 18 insertions(+)
target/arm/tcg/translate-sme.c +16 -0
@@ -1555,6 +1555,22 @@ TRANS_FEAT(BF2CVT, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvt_hb, 1) TRANS_FEAT(BF1CVTL, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvtl_hb, 0) TRANS_FEAT(BF2CVTL, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_bfcvtl_hb, 1) +static bool trans_FCVT_bh (DisasContext *s,arg_zz_n *a) +{ +if (!dc_isar_feature (aa64_sme2_f8cvt, s)) { +return false; + } +if (fpmr_access_check (s) &&sme_sm_enabled_check (s)) { +int svl =streaming_vec_reg_size (s); +tcg_gen_gvec_3_ptr (vec_full_reg_offset (s, a->zd), +vec_full_reg_offset (s, a->zn), +vec_full_reg_offset (s, a->zn +1 ), + tcg_env, svl, svl, +FPST_ZA <<2 , gen_helper_gvec_fcvt_bh); + } +return true; +} +static bool do_zipuzp_4 (DisasContext *s,arg_zz_e *a,gen_helper_gvec_2 *const fn[5 ]) {
target/arm/tcg/sme.decode +2 -0
@@ -863,6 +863,8 @@ BF2CVT 11000001 111 00110 111000 ..... ....0 @zz_2x1 BF1CVTL 11000001 011 00110 111000 ..... ....1 @zz_2x1 BF2CVTL 11000001 111 00110 111000 ..... ....1 @zz_2x1 +FCVT_bh 11000001 001 00100 111000 ....0 ..... @zz_1x2 + ZIP_4 11000001 esz:2 1 10110 111000 ...00 ... 00 \ &zz_e zd=%zd_ax4 zn=%zn_ax4 ZIP_4 11000001 001 10111 111000 ...00 ... 00 \
Signature · 1 line
2.43.0
PATCH v2 36/40 target/arm: Implement FCVT, FCVTN (FP32 to FP8) for SME
In reply to Richard Henderson--- target/arm/tcg/helper-fp8-defs.h | 2 + target/arm/tcg/fp8_helper.c | 95 ++++++++++++++++++++++++++++++++ target/arm/tcg/translate-sme.c | 3 + target/arm/tcg/sme.decode | 3 + 4 files changed, 103 insertions(+)
target/arm/tcg/helper-fp8-defs.h +2 -0
@@ -21,3 +21,5 @@ DEF_HELPER_FLAGS_4(sve2_fcvtn_bh, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_5(advsimd_fcvt_bs, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_fcvtnb_bs, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sve2_fcvtnt_bs, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4(sme2_fcvt_bs, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) +DEF_HELPER_FLAGS_4 (sme2_fcvtn_bs,TCG_CALL_NO_RWG , void, ptr, ptr, env, i32)
target/arm/tcg/fp8_helper.c +95 -0
98 lines not on this page · raw message
target/arm/tcg/translate-sme.c +3 -0
@@ -1571,6 +1571,9 @@ static bool trans_FCVT_bh(DisasContext *s, arg_zz_n *a)return true; } +TRANS_FEAT(FCVT_bs, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_fcvt_bs, 0) +TRANS_FEAT(FCVTN_bs, aa64_sme2_f8cvt, do_f8cvt, a, gen_helper_sme2_fcvtn_bs, 0) +static bool do_zipuzp_4 (DisasContext *s,arg_zz_e *a,gen_helper_gvec_2 *const fn[5 ]) {
target/arm/tcg/sme.decode +3 -0
@@ -865,6 +865,9 @@ BF2CVTL 11000001 111 00110 111000 ..... ....1 @zz_2x1 FCVT_bh 11000001 001 00100 111000 ....0 ..... @zz_1x2 +FCVT_bs 11000001 001 10100 111000 ...00 ..... @zz_1x4 +FCVTN_bs 11000001 001 10100 111000 ...01 ..... @zz_1x4 + ZIP_4 11000001 esz:2 1 10110 111000 ...00 ... 00 \ &zz_e zd=%zd_ax4 zn=%zn_ax4 ZIP_4 11000001 001 10111 111000 ...00 ... 00 \
Signature · 1 line
2.43.0
PATCH v2 37/40 target/arm: Implement LUTI2, LUTI4 for AdvSIMD
In reply to Richard Henderson--- target/arm/tcg/helper-defs.h | 5 ++++ target/arm/tcg/translate-a64.c | 38 +++++++++++++++++++++++++ target/arm/tcg/vec_helper.c | 52 ++++++++++++++++++++++++++++++++++ target/arm/tcg/a64.decode | 6 ++++ 4 files changed, 101 insertions(+)
target/arm/tcg/helper-defs.h +5 -0
@@ -1122,3 +1122,8 @@ DEF_HELPER_FLAGS_4(sme2_luti4_2s, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_luti4_4h, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) DEF_HELPER_FLAGS_4(sme2_luti4_4s, TCG_CALL_NO_RWG, void, ptr, ptr, env, i32) + +DEF_HELPER_FLAGS_4(gvec_luti2_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_luti2_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_luti4_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4 (gvec_luti4_h,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, i32)
target/arm/tcg/translate-a64.c +38 -0
@@ -5404,6 +5404,44 @@ static bool trans_TBL_TBX(DisasContext *s, arg_TBL_TBX *a)return true; } +static bool do_lut_1 (DisasContext *s,arg_rrx_e *a,gen_helper_gvec_3 *fn) +{ +if (fp_access_check (s)) { +gen_gvec_op3_ool (s, true, a->rd, a->rn, a->rm, a->idx, fn); + } +return true; +} + +TRANS_FEAT(LUTI2_1b, aa64_lut, do_lut_1, a, gen_helper_gvec_luti2_b) +TRANS_FEAT(LUTI2_1h, aa64_lut, do_lut_1, a, gen_helper_gvec_luti2_h) +TRANS_FEAT(LUTI4_1b, aa64_lut, do_lut_1, a, gen_helper_gvec_luti4_b) + +static bool trans_LUTI4_2h (DisasContext *s,arg_rrx_e *a) +{ +if (!dc_isar_feature (aa64_lut, s)) { +return false; + } +if (fp_access_check (s)) { +/* +* (Ab)use preg_tmp to merge two disjoint 128-bit quantities +* into a sequential 256-bit table. +*/ +QEMU_BUILD_BUG_ON (sizeof_field (CPUARMState, vfp.preg_tmp) <32 ); + unsigned tmp_ofs = offsetof(CPUARMState, vfp.preg_tmp); +unsigned rn0_ofs =vec_full_reg_offset (s, a->rn); +unsigned rn1_ofs =vec_full_reg_offset (s, (a->rn +1 ) %32 ); + +tcg_gen_gvec_mov (MO_64 , tmp_ofs, rn0_ofs,16 ,16 ); +tcg_gen_gvec_mov (MO_64 , tmp_ofs +16 , rn1_ofs,16 ,16 ); + +tcg_gen_gvec_3_ool (vec_full_reg_offset (s, a->rd), tmp_ofs, +vec_full_reg_offset (s, a->rm), +16 ,vec_full_reg_size (s), + a->idx, gen_helper_gvec_luti4_h); + } +return true; +} +typedef int simd_permute_idx_fn (int i,int part,int elements); static bool do_simd_permute(DisasContext *s, arg_qrrr_e *a,
target/arm/tcg/vec_helper.c +52 -0
55 lines not on this page · raw message
target/arm/tcg/a64.decode +6 -0
@@ -1344,6 +1344,12 @@ EXT_q 0110 1110 00 0 rm:5 0 imm:4 0 rn:5 rd:5 TBL_TBX 0 q:1 00 1110 000 rm:5 0 len:2 tbx:1 00 rn:5 rd:5 +LUTI2_1b 0100 1110 100 rm:5 0 idx:2 100 rn:5 rd:5 &rrx_e esz=0 +LUTI2_1h 0100 1110 110 rm:5 0 idx:3 00 rn:5 rd:5 &rrx_e esz=1 + +LUTI4_1b 0100 1110 010 rm:5 0 idx:1 1000 rn:5 rd:5 &rrx_e esz=0 +LUTI4_2h 0100 1110 010 rm:5 0 idx:2 100 rn:5 rd:5 &rrx_e esz=1 + # Advanced SIMD Permute UZP1 0.00 1110 .. 0 ..... 0 001 10 ..... ..... @qrrr_e
Signature · 1 line
2.43.0
PATCH v2 38/40 target/arm: Implement LUTI2, LUTI4 for SVE
In reply to Richard Henderson--- target/arm/cpu-features.h | 6 +++ target/arm/tcg/translate.h | 8 ++++ target/arm/tcg/translate-a64.c | 1 + target/arm/tcg/translate-sve.c | 68 ++++++++++++++++++++++++++++++++++ target/arm/tcg/sve.decode | 11 +++++- 5 files changed, 93 insertions(+), 1 deletion(-)
target/arm/cpu-features.h +6 -0
@@ -1630,6 +1630,12 @@ isar_feature_aa64_sme2_or_sve2_f8cvt(const ARMISARegisters *id)return isar_feature_aa64_sme2_or_sve2 (id) &&isar_feature_aa64_f8cvt (id); } +static inline bool +isar_feature_aa64_sme2_or_sve2_lut (const ARMISARegisters *id) +{ +return isar_feature_aa64_sme2_or_sve2 (id) &&isar_feature_aa64_lut (id); +} +/* * Feature tests for "does this exist in either 32-bit or 64-bit?" */
target/arm/tcg/translate.h +8 -0
@@ -90,6 +90,7 @@ typedef struct DisasContext {int vl;/* current vector length in bytes */ int svl;/* current streaming vector length in bytes */ int max_svl;/* maximum implemented streaming vector length */ +int max_any_vl;/* maximum implemented vector length */ bool vfp_enabled;/* FP enabled via FPSCR.EN */ int vec_len;int vec_stride;
@@ -884,4 +885,11 @@ static inline void gen_restore_rmode(TCGv_i32 old, TCGv_ptr fpst) return dc_isar_feature(FEAT, s) && FUNC(s, __VA_ARGS__); \ } +#define TRANS_FEAT_SME1_NONSTREAMING (NAME ,FEAT ,FUNC , ...) \ + static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ + { \ + s->is_nonstreaming = !dc_isar_feature(aa64_sme2, s); \ + return dc_isar_feature(FEAT, s) && FUNC(s, __VA_ARGS__); \ + } +#endif /* TARGET_ARM_TRANSLATE_H */
target/arm/tcg/translate-a64.c +1 -0
@@ -10819,6 +10819,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->vl = (EX_TBFLAG_A64 (tb_flags,VL ) +1 ) *16 ; dc->svl = (EX_TBFLAG_A64 (tb_flags,SVL ) +1 ) *16 ; dc->max_svl = arm_cpu->sme_max_vq *16 ; + dc->max_any_vl =MAX (dc->max_svl, arm_cpu->sve_max_vq *16 ); dc->pauth_active =EX_TBFLAG_A64 (tb_flags,PAUTH_ACTIVE ); dc->bt =EX_TBFLAG_A64 (tb_flags,BT ); dc->btype =EX_TBFLAG_A64 (tb_flags,BTYPE );
target/arm/tcg/translate-sve.c +68 -0
71 lines not on this page · raw message
target/arm/tcg/sve.decode +10 -1
@@ -31,6 +31,7 @@ %dtype_23_13 23:2 13:2 %index3_22_19 22:1 19:2 %index3_22_17 22:1 17:2 +%index3_22_12 22:2 12:1 %index3_19_11 19:2 11:1 %index2_20_11 20:1 11:1
@@ -1737,11 +1738,19 @@ RSUBHNT 01000101 .. 1 ..... 011 111 ..... ..... @rd_rn_rm MATCH 01000101 .. 1 ..... 100 ... ..... 0 .... @pd_pg_rn_rm NMATCH 01000101 .. 1 ..... 100 ... ..... 1 .... @pd_pg_rn_rm -### SVE2 Histogram Computation +### SVE2 Histogram Computation and Lookup Table HISTCNT 01000101 .. 1 ..... 110 ... ..... ..... @rd_pg_rn_rm HISTSEG 01000101 .. 1 ..... 101 000 ..... ..... @rd_rn_rm +LUTI2_1b 01000101 index:2 1 rm:5 101100 rn:5 rd:5 &rrx_esz esz=0 +LUTI2_1h 01000101 .. 1 rm:5 101.10 rn:5 rd:5 \ + &rrx_esz esz=1 index=%index3_22_12 + +LUTI4_1b 01000101 index:1 11 rm:5 101001 rn:5 rd:5 &rrx_esz esz=0 +LUTI4_1h 01000101 index:2 1 rm:5 101111 rn:5 rd:5 &rrx_esz esz=1 +LUTI4_2h 01000101 index:2 1 rm:5 101101 rn:5 rd:5 &rrx_esz esz=1 + ## SVE2 floating-point pairwise operations FADDP 01100100 .. 010 00 0 100 ... ..... ..... @rdn_pg_rm
Signature · 1 line
2.43.0
PATCH v2 39/40 target/arm: Enable FEAT_LUT for -cpu max
In reply to Richard Henderson--- target/arm/tcg/cpu64.c | 1 + docs/system/arm/emulation.rst | 1 + 2 files changed, 2 insertions(+)
target/arm/tcg/cpu64.c +1 -0
@@ -1253,6 +1253,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR2 ,BC ,1 );/* FEAT_HBC */ t =FIELD_DP64 (t,ID_AA64ISAR2 ,WFXT ,2 );/* FEAT_WFxT */ t =FIELD_DP64 (t,ID_AA64ISAR2 ,CSSC ,1 );/* FEAT_CSSC */ + t =FIELD_DP64 (t,ID_AA64ISAR2 ,LUT ,1 );/* FEAT_LUT */ t =FIELD_DP64 (t,ID_AA64ISAR2 ,ATS1A ,1 );/* FEAT_ATS1A */ SET_IDREG (isar,ID_AA64ISAR2 , t);
docs/system/arm/emulation.rst +1 -0
@@ -99,6 +99,7 @@ the following architecture extensions: - FEAT_LSE (Large System Extensions) - FEAT_LSE2 (Large System Extensions v2) - FEAT_LSE128 (128-bit Atomics) +- FEAT_LUT (Lookup table instructions with 2-bit and 4-bit indices) - FEAT_LVA (Large Virtual Address space) - FEAT_MEC (Memory Encryption Contexts)
Signature · 1 line
2.43.0
PATCH v2 40/40 target/arm: Enable FEAT_FP8 for -cpu max
In reply to Richard Henderson--- target/arm/tcg/cpu64.c | 4 ++++ docs/system/arm/emulation.rst | 1 + 2 files changed, 5 insertions(+)
target/arm/tcg/cpu64.c +4 -0
@@ -1381,6 +1381,10 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64SMFR0 ,FA64 ,1 );/* FEAT_SME_FA64 */ SET_IDREG (isar,ID_AA64SMFR0 , t); + t =GET_IDREG (isar,ID_AA64FPFR0 ); + t =FIELD_DP64 (t,ID_AA64FPFR0 ,F8CVT ,1 );/* FEAT_FP8 */ +SET_IDREG (isar,ID_AA64FPFR0 , t); +/* Replicate the same data to the 32-bit id registers. */ aa32_max_features (cpu);
docs/system/arm/emulation.rst +1 -0
@@ -72,6 +72,7 @@ the following architecture extensions: - FEAT_FHM (Floating-point half-precision multiplication instructions) - FEAT_FP (Floating Point extensions) - FEAT_FP16 (Half-precision floating-point data processing) +- FEAT_FP8 (FP8 convert instructions) - FEAT_FPAC (Faulting on AUT* instructions) - FEAT_FPACCOMBINE (Faulting on combined pointer authentication instructions) - FEAT_FPACC_SPEC (Speculative behavior of combined pointer authentication instructions)
Signature · 1 line
2.43.0