target/arm: Implement fp16 for Neon float-integer VCVT

Convert the Neon float-integer VCVT insns to gvec, and use this
to implement fp16 support for them.

Note that unlike the VFP int<->fp16 VCVT insns we converted
earlier and which convert to/from a 32-bit integer, these
Neon insns convert to/from 16-bit integers. So we can use
the existing vfp conversion helpers for the f32<->u32/i32
case but need to provide our own for f16<->u16/i16.

Backports 7782a9afec81d1efe23572135c1ed777691ccde5
This commit is contained in:
Peter Maydell 2021-03-01 17:29:00 -05:00 committed by Lioncash
parent 82f4a7e135
commit c324c6817e
19 changed files with 170 additions and 11 deletions

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_aarch64
#define helper_neon_zip16 helper_neon_zip16_aarch64
#define helper_neon_zip8 helper_neon_zip8_aarch64
#define helper_gvec_sstoh helper_gvec_sstoh_aarch64
#define helper_gvec_sitos helper_gvec_sitos_aarch64
#define helper_gvec_ustoh helper_gvec_ustoh_aarch64
#define helper_gvec_uitos helper_gvec_uitos_aarch64
#define helper_gvec_tosszh helper_gvec_tosszh_aarch64
#define helper_gvec_tosizs helper_gvec_tosizs_aarch64
#define helper_gvec_touszh helper_gvec_touszh_aarch64
#define helper_gvec_touizs helper_gvec_touizs_aarch64
#define helper_power_down helper_power_down_aarch64
#define helper_pre_hvc helper_pre_hvc_aarch64
#define helper_pre_smc helper_pre_smc_aarch64

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_aarch64eb
#define helper_neon_zip16 helper_neon_zip16_aarch64eb
#define helper_neon_zip8 helper_neon_zip8_aarch64eb
#define helper_gvec_sstoh helper_gvec_sstoh_aarch64eb
#define helper_gvec_sitos helper_gvec_sitos_aarch64eb
#define helper_gvec_ustoh helper_gvec_ustoh_aarch64eb
#define helper_gvec_uitos helper_gvec_uitos_aarch64eb
#define helper_gvec_tosszh helper_gvec_tosszh_aarch64eb
#define helper_gvec_tosizs helper_gvec_tosizs_aarch64eb
#define helper_gvec_touszh helper_gvec_touszh_aarch64eb
#define helper_gvec_touizs helper_gvec_touizs_aarch64eb
#define helper_power_down helper_power_down_aarch64eb
#define helper_pre_hvc helper_pre_hvc_aarch64eb
#define helper_pre_smc helper_pre_smc_aarch64eb

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_arm
#define helper_neon_zip16 helper_neon_zip16_arm
#define helper_neon_zip8 helper_neon_zip8_arm
#define helper_gvec_sstoh helper_gvec_sstoh_arm
#define helper_gvec_sitos helper_gvec_sitos_arm
#define helper_gvec_ustoh helper_gvec_ustoh_arm
#define helper_gvec_uitos helper_gvec_uitos_arm
#define helper_gvec_tosszh helper_gvec_tosszh_arm
#define helper_gvec_tosizs helper_gvec_tosizs_arm
#define helper_gvec_touszh helper_gvec_touszh_arm
#define helper_gvec_touizs helper_gvec_touizs_arm
#define helper_power_down helper_power_down_arm
#define helper_pre_hvc helper_pre_hvc_arm
#define helper_pre_smc helper_pre_smc_arm

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_armeb
#define helper_neon_zip16 helper_neon_zip16_armeb
#define helper_neon_zip8 helper_neon_zip8_armeb
#define helper_gvec_sstoh helper_gvec_sstoh_armeb
#define helper_gvec_sitos helper_gvec_sitos_armeb
#define helper_gvec_ustoh helper_gvec_ustoh_armeb
#define helper_gvec_uitos helper_gvec_uitos_armeb
#define helper_gvec_tosszh helper_gvec_tosszh_armeb
#define helper_gvec_tosizs helper_gvec_tosizs_armeb
#define helper_gvec_touszh helper_gvec_touszh_armeb
#define helper_gvec_touizs helper_gvec_touizs_armeb
#define helper_power_down helper_power_down_armeb
#define helper_pre_hvc helper_pre_hvc_armeb
#define helper_pre_smc helper_pre_smc_armeb

View file

@ -1834,6 +1834,14 @@ symbols = (
'helper_neon_widen_u8',
'helper_neon_zip16',
'helper_neon_zip8',
'helper_gvec_sstoh',
'helper_gvec_sitos',
'helper_gvec_ustoh',
'helper_gvec_uitos',
'helper_gvec_tosszh',
'helper_gvec_tosizs',
'helper_gvec_touszh',
'helper_gvec_touizs',
'helper_power_down',
'helper_pre_hvc',
'helper_pre_smc',

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_m68k
#define helper_neon_zip16 helper_neon_zip16_m68k
#define helper_neon_zip8 helper_neon_zip8_m68k
#define helper_gvec_sstoh helper_gvec_sstoh_m68k
#define helper_gvec_sitos helper_gvec_sitos_m68k
#define helper_gvec_ustoh helper_gvec_ustoh_m68k
#define helper_gvec_uitos helper_gvec_uitos_m68k
#define helper_gvec_tosszh helper_gvec_tosszh_m68k
#define helper_gvec_tosizs helper_gvec_tosizs_m68k
#define helper_gvec_touszh helper_gvec_touszh_m68k
#define helper_gvec_touizs helper_gvec_touizs_m68k
#define helper_power_down helper_power_down_m68k
#define helper_pre_hvc helper_pre_hvc_m68k
#define helper_pre_smc helper_pre_smc_m68k

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_mips
#define helper_neon_zip16 helper_neon_zip16_mips
#define helper_neon_zip8 helper_neon_zip8_mips
#define helper_gvec_sstoh helper_gvec_sstoh_mips
#define helper_gvec_sitos helper_gvec_sitos_mips
#define helper_gvec_ustoh helper_gvec_ustoh_mips
#define helper_gvec_uitos helper_gvec_uitos_mips
#define helper_gvec_tosszh helper_gvec_tosszh_mips
#define helper_gvec_tosizs helper_gvec_tosizs_mips
#define helper_gvec_touszh helper_gvec_touszh_mips
#define helper_gvec_touizs helper_gvec_touizs_mips
#define helper_power_down helper_power_down_mips
#define helper_pre_hvc helper_pre_hvc_mips
#define helper_pre_smc helper_pre_smc_mips

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_mips64
#define helper_neon_zip16 helper_neon_zip16_mips64
#define helper_neon_zip8 helper_neon_zip8_mips64
#define helper_gvec_sstoh helper_gvec_sstoh_mips64
#define helper_gvec_sitos helper_gvec_sitos_mips64
#define helper_gvec_ustoh helper_gvec_ustoh_mips64
#define helper_gvec_uitos helper_gvec_uitos_mips64
#define helper_gvec_tosszh helper_gvec_tosszh_mips64
#define helper_gvec_tosizs helper_gvec_tosizs_mips64
#define helper_gvec_touszh helper_gvec_touszh_mips64
#define helper_gvec_touizs helper_gvec_touizs_mips64
#define helper_power_down helper_power_down_mips64
#define helper_pre_hvc helper_pre_hvc_mips64
#define helper_pre_smc helper_pre_smc_mips64

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_mips64el
#define helper_neon_zip16 helper_neon_zip16_mips64el
#define helper_neon_zip8 helper_neon_zip8_mips64el
#define helper_gvec_sstoh helper_gvec_sstoh_mips64el
#define helper_gvec_sitos helper_gvec_sitos_mips64el
#define helper_gvec_ustoh helper_gvec_ustoh_mips64el
#define helper_gvec_uitos helper_gvec_uitos_mips64el
#define helper_gvec_tosszh helper_gvec_tosszh_mips64el
#define helper_gvec_tosizs helper_gvec_tosizs_mips64el
#define helper_gvec_touszh helper_gvec_touszh_mips64el
#define helper_gvec_touizs helper_gvec_touizs_mips64el
#define helper_power_down helper_power_down_mips64el
#define helper_pre_hvc helper_pre_hvc_mips64el
#define helper_pre_smc helper_pre_smc_mips64el

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_mipsel
#define helper_neon_zip16 helper_neon_zip16_mipsel
#define helper_neon_zip8 helper_neon_zip8_mipsel
#define helper_gvec_sstoh helper_gvec_sstoh_mipsel
#define helper_gvec_sitos helper_gvec_sitos_mipsel
#define helper_gvec_ustoh helper_gvec_ustoh_mipsel
#define helper_gvec_uitos helper_gvec_uitos_mipsel
#define helper_gvec_tosszh helper_gvec_tosszh_mipsel
#define helper_gvec_tosizs helper_gvec_tosizs_mipsel
#define helper_gvec_touszh helper_gvec_touszh_mipsel
#define helper_gvec_touizs helper_gvec_touizs_mipsel
#define helper_power_down helper_power_down_mipsel
#define helper_pre_hvc helper_pre_hvc_mipsel
#define helper_pre_smc helper_pre_smc_mipsel

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_powerpc
#define helper_neon_zip16 helper_neon_zip16_powerpc
#define helper_neon_zip8 helper_neon_zip8_powerpc
#define helper_gvec_sstoh helper_gvec_sstoh_powerpc
#define helper_gvec_sitos helper_gvec_sitos_powerpc
#define helper_gvec_ustoh helper_gvec_ustoh_powerpc
#define helper_gvec_uitos helper_gvec_uitos_powerpc
#define helper_gvec_tosszh helper_gvec_tosszh_powerpc
#define helper_gvec_tosizs helper_gvec_tosizs_powerpc
#define helper_gvec_touszh helper_gvec_touszh_powerpc
#define helper_gvec_touizs helper_gvec_touizs_powerpc
#define helper_power_down helper_power_down_powerpc
#define helper_pre_hvc helper_pre_hvc_powerpc
#define helper_pre_smc helper_pre_smc_powerpc

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_riscv32
#define helper_neon_zip16 helper_neon_zip16_riscv32
#define helper_neon_zip8 helper_neon_zip8_riscv32
#define helper_gvec_sstoh helper_gvec_sstoh_riscv32
#define helper_gvec_sitos helper_gvec_sitos_riscv32
#define helper_gvec_ustoh helper_gvec_ustoh_riscv32
#define helper_gvec_uitos helper_gvec_uitos_riscv32
#define helper_gvec_tosszh helper_gvec_tosszh_riscv32
#define helper_gvec_tosizs helper_gvec_tosizs_riscv32
#define helper_gvec_touszh helper_gvec_touszh_riscv32
#define helper_gvec_touizs helper_gvec_touizs_riscv32
#define helper_power_down helper_power_down_riscv32
#define helper_pre_hvc helper_pre_hvc_riscv32
#define helper_pre_smc helper_pre_smc_riscv32

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_riscv64
#define helper_neon_zip16 helper_neon_zip16_riscv64
#define helper_neon_zip8 helper_neon_zip8_riscv64
#define helper_gvec_sstoh helper_gvec_sstoh_riscv64
#define helper_gvec_sitos helper_gvec_sitos_riscv64
#define helper_gvec_ustoh helper_gvec_ustoh_riscv64
#define helper_gvec_uitos helper_gvec_uitos_riscv64
#define helper_gvec_tosszh helper_gvec_tosszh_riscv64
#define helper_gvec_tosizs helper_gvec_tosizs_riscv64
#define helper_gvec_touszh helper_gvec_touszh_riscv64
#define helper_gvec_touizs helper_gvec_touizs_riscv64
#define helper_power_down helper_power_down_riscv64
#define helper_pre_hvc helper_pre_hvc_riscv64
#define helper_pre_smc helper_pre_smc_riscv64

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_sparc
#define helper_neon_zip16 helper_neon_zip16_sparc
#define helper_neon_zip8 helper_neon_zip8_sparc
#define helper_gvec_sstoh helper_gvec_sstoh_sparc
#define helper_gvec_sitos helper_gvec_sitos_sparc
#define helper_gvec_ustoh helper_gvec_ustoh_sparc
#define helper_gvec_uitos helper_gvec_uitos_sparc
#define helper_gvec_tosszh helper_gvec_tosszh_sparc
#define helper_gvec_tosizs helper_gvec_tosizs_sparc
#define helper_gvec_touszh helper_gvec_touszh_sparc
#define helper_gvec_touizs helper_gvec_touizs_sparc
#define helper_power_down helper_power_down_sparc
#define helper_pre_hvc helper_pre_hvc_sparc
#define helper_pre_smc helper_pre_smc_sparc

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_sparc64
#define helper_neon_zip16 helper_neon_zip16_sparc64
#define helper_neon_zip8 helper_neon_zip8_sparc64
#define helper_gvec_sstoh helper_gvec_sstoh_sparc64
#define helper_gvec_sitos helper_gvec_sitos_sparc64
#define helper_gvec_ustoh helper_gvec_ustoh_sparc64
#define helper_gvec_uitos helper_gvec_uitos_sparc64
#define helper_gvec_tosszh helper_gvec_tosszh_sparc64
#define helper_gvec_tosizs helper_gvec_tosizs_sparc64
#define helper_gvec_touszh helper_gvec_touszh_sparc64
#define helper_gvec_touizs helper_gvec_touizs_sparc64
#define helper_power_down helper_power_down_sparc64
#define helper_pre_hvc helper_pre_hvc_sparc64
#define helper_pre_smc helper_pre_smc_sparc64

View file

@ -612,6 +612,15 @@ DEF_HELPER_FLAGS_5(neon_padds, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(neon_pmaxs, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(neon_pmins, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_sstoh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_sitos, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_ustoh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_uitos, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_tosszh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_tosizs, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_touszh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_touizs, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_frecpe_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_frecpe_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(gvec_frecpe_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)

View file

@ -3765,17 +3765,6 @@ static bool do_2misc_fp(DisasContext *s, arg_2misc *a,
return true;
}
#define DO_2MISC_FP(INSN, FUNC) \
static bool trans_##INSN(DisasContext *s, arg_2misc *a) \
{ \
return do_2misc_fp(s, a, FUNC); \
}
DO_2MISC_FP(VCVT_FS, gen_helper_vfp_sitos)
DO_2MISC_FP(VCVT_FU, gen_helper_vfp_uitos)
DO_2MISC_FP(VCVT_SF, gen_helper_vfp_tosizs)
DO_2MISC_FP(VCVT_UF, gen_helper_vfp_touizs)
#define DO_2MISC_FP_VEC(INSN, HFUNC, SFUNC) \
static void gen_##INSN(TCGContext *s, unsigned vece, uint32_t rd_ofs, \
uint32_t rm_ofs, \
@ -3809,6 +3798,10 @@ DO_2MISC_FP_VEC(VCGE0_F, gen_helper_gvec_fcge0_h, gen_helper_gvec_fcge0_s)
DO_2MISC_FP_VEC(VCEQ0_F, gen_helper_gvec_fceq0_h, gen_helper_gvec_fceq0_s)
DO_2MISC_FP_VEC(VCLT0_F, gen_helper_gvec_fclt0_h, gen_helper_gvec_fclt0_s)
DO_2MISC_FP_VEC(VCLE0_F, gen_helper_gvec_fcle0_h, gen_helper_gvec_fcle0_s)
DO_2MISC_FP_VEC(VCVT_FS, gen_helper_gvec_sstoh, gen_helper_gvec_sitos)
DO_2MISC_FP_VEC(VCVT_FU, gen_helper_gvec_ustoh, gen_helper_gvec_uitos)
DO_2MISC_FP_VEC(VCVT_SF, gen_helper_gvec_tosszh, gen_helper_gvec_tosizs)
DO_2MISC_FP_VEC(VCVT_UF, gen_helper_gvec_touszh, gen_helper_gvec_touizs)
static bool trans_VRINTX(DisasContext *s, arg_2misc *a)
{

View file

@ -712,6 +712,26 @@ static uint32_t float32_acgt(float32 op1, float32 op2, float_status *stat)
return -float32_lt(float32_abs(op2), float32_abs(op1), stat);
}
static int16_t vfp_tosszh(float16 x, void *fpstp)
{
float_status *fpst = fpstp;
if (float16_is_any_nan(x)) {
float_raise(float_flag_invalid, fpst);
return 0;
}
return float16_to_int16_round_to_zero(x, fpst);
}
static uint16_t vfp_touszh(float16 x, void *fpstp)
{
float_status *fpst = fpstp;
if (float16_is_any_nan(x)) {
float_raise(float_flag_invalid, fpst);
return 0;
}
return float16_to_uint16_round_to_zero(x, fpst);
}
#define DO_2OP(NAME, FUNC, TYPE) \
void HELPER(NAME)(void *vd, void *vn, void *stat, uint32_t desc) \
{ \
@ -731,6 +751,15 @@ DO_2OP(gvec_frsqrte_h, helper_rsqrte_f16, float16)
DO_2OP(gvec_frsqrte_s, helper_rsqrte_f32, float32)
DO_2OP(gvec_frsqrte_d, helper_rsqrte_f64, float64)
DO_2OP(gvec_sitos, helper_vfp_sitos, int32_t)
DO_2OP(gvec_uitos, helper_vfp_uitos, uint32_t)
DO_2OP(gvec_tosizs, helper_vfp_tosizs, float32)
DO_2OP(gvec_touizs, helper_vfp_touizs, float32)
DO_2OP(gvec_sstoh, int16_to_float16, int16_t)
DO_2OP(gvec_ustoh, uint16_to_float16, uint16_t)
DO_2OP(gvec_tosszh, vfp_tosszh, float16)
DO_2OP(gvec_touszh, vfp_touszh, float16)
#define WRAP_CMP0_FWD(FN, CMPOP, TYPE) \
static TYPE TYPE##_##FN##0(TYPE op, float_status *stat) \
{ \

View file

@ -1828,6 +1828,14 @@
#define helper_neon_widen_u8 helper_neon_widen_u8_x86_64
#define helper_neon_zip16 helper_neon_zip16_x86_64
#define helper_neon_zip8 helper_neon_zip8_x86_64
#define helper_gvec_sstoh helper_gvec_sstoh_x86_64
#define helper_gvec_sitos helper_gvec_sitos_x86_64
#define helper_gvec_ustoh helper_gvec_ustoh_x86_64
#define helper_gvec_uitos helper_gvec_uitos_x86_64
#define helper_gvec_tosszh helper_gvec_tosszh_x86_64
#define helper_gvec_tosizs helper_gvec_tosizs_x86_64
#define helper_gvec_touszh helper_gvec_touszh_x86_64
#define helper_gvec_touizs helper_gvec_touizs_x86_64
#define helper_power_down helper_power_down_x86_64
#define helper_pre_hvc helper_pre_hvc_x86_64
#define helper_pre_smc helper_pre_smc_x86_64