target/arm: Implement VFP fp16 for VABS, VNEG, VSQRT

Implement VFP fp16 for VABS, VNEG and VSQRT. This is all
the fp16 insns that use the DO_VFP_2OP macro, because there
is no fp16 version of VMOV_reg.

Notes:
* the gen_helper_vfp_negh already exists as we needed to create
it for the fp16 multiply-add insns
* as usual we need to use the f16 version of the fp_status;
this is only relevant for VSQRT

Backports ce2d65a5d191380756cdac7a1fd1ba76bd1621cf
This commit is contained in:
Peter Maydell 2021-02-28 04:46:28 -05:00 committed by Lioncash
parent f3af6b8c25
commit 2d9abf7c0b
20 changed files with 87 additions and 0 deletions

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_aarch64
#define helper_v8m_stackcheck helper_v8m_stackcheck_aarch64
#define helper_vfp_absd helper_vfp_absd_aarch64
#define helper_vfp_absh helper_vfp_absh_aarch64
#define helper_vfp_abss helper_vfp_abss_aarch64
#define helper_vfp_addd helper_vfp_addd_aarch64
#define helper_vfp_addh helper_vfp_addh_aarch64
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_aarch64
#define helper_vfp_sltos helper_vfp_sltos_aarch64
#define helper_vfp_sqrtd helper_vfp_sqrtd_aarch64
#define helper_vfp_sqrth helper_vfp_sqrth_aarch64
#define helper_vfp_sqrts helper_vfp_sqrts_aarch64
#define helper_vfp_sqtod helper_vfp_sqtod_aarch64
#define helper_vfp_sqtoh helper_vfp_sqtoh_aarch64

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_aarch64eb
#define helper_v8m_stackcheck helper_v8m_stackcheck_aarch64eb
#define helper_vfp_absd helper_vfp_absd_aarch64eb
#define helper_vfp_absh helper_vfp_absh_aarch64eb
#define helper_vfp_abss helper_vfp_abss_aarch64eb
#define helper_vfp_addd helper_vfp_addd_aarch64eb
#define helper_vfp_addh helper_vfp_addh_aarch64eb
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_aarch64eb
#define helper_vfp_sltos helper_vfp_sltos_aarch64eb
#define helper_vfp_sqrtd helper_vfp_sqrtd_aarch64eb
#define helper_vfp_sqrth helper_vfp_sqrth_aarch64eb
#define helper_vfp_sqrts helper_vfp_sqrts_aarch64eb
#define helper_vfp_sqtod helper_vfp_sqtod_aarch64eb
#define helper_vfp_sqtoh helper_vfp_sqtoh_aarch64eb

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_arm
#define helper_v8m_stackcheck helper_v8m_stackcheck_arm
#define helper_vfp_absd helper_vfp_absd_arm
#define helper_vfp_absh helper_vfp_absh_arm
#define helper_vfp_abss helper_vfp_abss_arm
#define helper_vfp_addd helper_vfp_addd_arm
#define helper_vfp_addh helper_vfp_addh_arm
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_arm
#define helper_vfp_sltos helper_vfp_sltos_arm
#define helper_vfp_sqrtd helper_vfp_sqrtd_arm
#define helper_vfp_sqrth helper_vfp_sqrth_arm
#define helper_vfp_sqrts helper_vfp_sqrts_arm
#define helper_vfp_sqtod helper_vfp_sqtod_arm
#define helper_vfp_sqtoh helper_vfp_sqtoh_arm

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_armeb
#define helper_v8m_stackcheck helper_v8m_stackcheck_armeb
#define helper_vfp_absd helper_vfp_absd_armeb
#define helper_vfp_absh helper_vfp_absh_armeb
#define helper_vfp_abss helper_vfp_abss_armeb
#define helper_vfp_addd helper_vfp_addd_armeb
#define helper_vfp_addh helper_vfp_addh_armeb
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_armeb
#define helper_vfp_sltos helper_vfp_sltos_armeb
#define helper_vfp_sqrtd helper_vfp_sqrtd_armeb
#define helper_vfp_sqrth helper_vfp_sqrth_armeb
#define helper_vfp_sqrts helper_vfp_sqrts_armeb
#define helper_vfp_sqtod helper_vfp_sqtod_armeb
#define helper_vfp_sqtoh helper_vfp_sqtoh_armeb

View file

@ -1892,6 +1892,7 @@ symbols = (
'helper_v7m_vlstm',
'helper_v8m_stackcheck',
'helper_vfp_absd',
'helper_vfp_absh',
'helper_vfp_abss',
'helper_vfp_addd',
'helper_vfp_addh',
@ -1943,6 +1944,7 @@ symbols = (
'helper_vfp_sltoh',
'helper_vfp_sltos',
'helper_vfp_sqrtd',
'helper_vfp_sqrth',
'helper_vfp_sqrts',
'helper_vfp_sqtod',
'helper_vfp_sqtoh',

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_m68k
#define helper_v8m_stackcheck helper_v8m_stackcheck_m68k
#define helper_vfp_absd helper_vfp_absd_m68k
#define helper_vfp_absh helper_vfp_absh_m68k
#define helper_vfp_abss helper_vfp_abss_m68k
#define helper_vfp_addd helper_vfp_addd_m68k
#define helper_vfp_addh helper_vfp_addh_m68k
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_m68k
#define helper_vfp_sltos helper_vfp_sltos_m68k
#define helper_vfp_sqrtd helper_vfp_sqrtd_m68k
#define helper_vfp_sqrth helper_vfp_sqrth_m68k
#define helper_vfp_sqrts helper_vfp_sqrts_m68k
#define helper_vfp_sqtod helper_vfp_sqtod_m68k
#define helper_vfp_sqtoh helper_vfp_sqtoh_m68k

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_mips
#define helper_v8m_stackcheck helper_v8m_stackcheck_mips
#define helper_vfp_absd helper_vfp_absd_mips
#define helper_vfp_absh helper_vfp_absh_mips
#define helper_vfp_abss helper_vfp_abss_mips
#define helper_vfp_addd helper_vfp_addd_mips
#define helper_vfp_addh helper_vfp_addh_mips
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_mips
#define helper_vfp_sltos helper_vfp_sltos_mips
#define helper_vfp_sqrtd helper_vfp_sqrtd_mips
#define helper_vfp_sqrth helper_vfp_sqrth_mips
#define helper_vfp_sqrts helper_vfp_sqrts_mips
#define helper_vfp_sqtod helper_vfp_sqtod_mips
#define helper_vfp_sqtoh helper_vfp_sqtoh_mips

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_mips64
#define helper_v8m_stackcheck helper_v8m_stackcheck_mips64
#define helper_vfp_absd helper_vfp_absd_mips64
#define helper_vfp_absh helper_vfp_absh_mips64
#define helper_vfp_abss helper_vfp_abss_mips64
#define helper_vfp_addd helper_vfp_addd_mips64
#define helper_vfp_addh helper_vfp_addh_mips64
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_mips64
#define helper_vfp_sltos helper_vfp_sltos_mips64
#define helper_vfp_sqrtd helper_vfp_sqrtd_mips64
#define helper_vfp_sqrth helper_vfp_sqrth_mips64
#define helper_vfp_sqrts helper_vfp_sqrts_mips64
#define helper_vfp_sqtod helper_vfp_sqtod_mips64
#define helper_vfp_sqtoh helper_vfp_sqtoh_mips64

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_mips64el
#define helper_v8m_stackcheck helper_v8m_stackcheck_mips64el
#define helper_vfp_absd helper_vfp_absd_mips64el
#define helper_vfp_absh helper_vfp_absh_mips64el
#define helper_vfp_abss helper_vfp_abss_mips64el
#define helper_vfp_addd helper_vfp_addd_mips64el
#define helper_vfp_addh helper_vfp_addh_mips64el
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_mips64el
#define helper_vfp_sltos helper_vfp_sltos_mips64el
#define helper_vfp_sqrtd helper_vfp_sqrtd_mips64el
#define helper_vfp_sqrth helper_vfp_sqrth_mips64el
#define helper_vfp_sqrts helper_vfp_sqrts_mips64el
#define helper_vfp_sqtod helper_vfp_sqtod_mips64el
#define helper_vfp_sqtoh helper_vfp_sqtoh_mips64el

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_mipsel
#define helper_v8m_stackcheck helper_v8m_stackcheck_mipsel
#define helper_vfp_absd helper_vfp_absd_mipsel
#define helper_vfp_absh helper_vfp_absh_mipsel
#define helper_vfp_abss helper_vfp_abss_mipsel
#define helper_vfp_addd helper_vfp_addd_mipsel
#define helper_vfp_addh helper_vfp_addh_mipsel
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_mipsel
#define helper_vfp_sltos helper_vfp_sltos_mipsel
#define helper_vfp_sqrtd helper_vfp_sqrtd_mipsel
#define helper_vfp_sqrth helper_vfp_sqrth_mipsel
#define helper_vfp_sqrts helper_vfp_sqrts_mipsel
#define helper_vfp_sqtod helper_vfp_sqtod_mipsel
#define helper_vfp_sqtoh helper_vfp_sqtoh_mipsel

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_powerpc
#define helper_v8m_stackcheck helper_v8m_stackcheck_powerpc
#define helper_vfp_absd helper_vfp_absd_powerpc
#define helper_vfp_absh helper_vfp_absh_powerpc
#define helper_vfp_abss helper_vfp_abss_powerpc
#define helper_vfp_addd helper_vfp_addd_powerpc
#define helper_vfp_addh helper_vfp_addh_powerpc
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_powerpc
#define helper_vfp_sltos helper_vfp_sltos_powerpc
#define helper_vfp_sqrtd helper_vfp_sqrtd_powerpc
#define helper_vfp_sqrth helper_vfp_sqrth_powerpc
#define helper_vfp_sqrts helper_vfp_sqrts_powerpc
#define helper_vfp_sqtod helper_vfp_sqtod_powerpc
#define helper_vfp_sqtoh helper_vfp_sqtoh_powerpc

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_riscv32
#define helper_v8m_stackcheck helper_v8m_stackcheck_riscv32
#define helper_vfp_absd helper_vfp_absd_riscv32
#define helper_vfp_absh helper_vfp_absh_riscv32
#define helper_vfp_abss helper_vfp_abss_riscv32
#define helper_vfp_addd helper_vfp_addd_riscv32
#define helper_vfp_addh helper_vfp_addh_riscv32
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_riscv32
#define helper_vfp_sltos helper_vfp_sltos_riscv32
#define helper_vfp_sqrtd helper_vfp_sqrtd_riscv32
#define helper_vfp_sqrth helper_vfp_sqrth_riscv32
#define helper_vfp_sqrts helper_vfp_sqrts_riscv32
#define helper_vfp_sqtod helper_vfp_sqtod_riscv32
#define helper_vfp_sqtoh helper_vfp_sqtoh_riscv32

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_riscv64
#define helper_v8m_stackcheck helper_v8m_stackcheck_riscv64
#define helper_vfp_absd helper_vfp_absd_riscv64
#define helper_vfp_absh helper_vfp_absh_riscv64
#define helper_vfp_abss helper_vfp_abss_riscv64
#define helper_vfp_addd helper_vfp_addd_riscv64
#define helper_vfp_addh helper_vfp_addh_riscv64
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_riscv64
#define helper_vfp_sltos helper_vfp_sltos_riscv64
#define helper_vfp_sqrtd helper_vfp_sqrtd_riscv64
#define helper_vfp_sqrth helper_vfp_sqrth_riscv64
#define helper_vfp_sqrts helper_vfp_sqrts_riscv64
#define helper_vfp_sqtod helper_vfp_sqtod_riscv64
#define helper_vfp_sqtoh helper_vfp_sqtoh_riscv64

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_sparc
#define helper_v8m_stackcheck helper_v8m_stackcheck_sparc
#define helper_vfp_absd helper_vfp_absd_sparc
#define helper_vfp_absh helper_vfp_absh_sparc
#define helper_vfp_abss helper_vfp_abss_sparc
#define helper_vfp_addd helper_vfp_addd_sparc
#define helper_vfp_addh helper_vfp_addh_sparc
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_sparc
#define helper_vfp_sltos helper_vfp_sltos_sparc
#define helper_vfp_sqrtd helper_vfp_sqrtd_sparc
#define helper_vfp_sqrth helper_vfp_sqrth_sparc
#define helper_vfp_sqrts helper_vfp_sqrts_sparc
#define helper_vfp_sqtod helper_vfp_sqtod_sparc
#define helper_vfp_sqtoh helper_vfp_sqtoh_sparc

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_sparc64
#define helper_v8m_stackcheck helper_v8m_stackcheck_sparc64
#define helper_vfp_absd helper_vfp_absd_sparc64
#define helper_vfp_absh helper_vfp_absh_sparc64
#define helper_vfp_abss helper_vfp_abss_sparc64
#define helper_vfp_addd helper_vfp_addd_sparc64
#define helper_vfp_addh helper_vfp_addh_sparc64
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_sparc64
#define helper_vfp_sltos helper_vfp_sltos_sparc64
#define helper_vfp_sqrtd helper_vfp_sqrtd_sparc64
#define helper_vfp_sqrth helper_vfp_sqrth_sparc64
#define helper_vfp_sqrts helper_vfp_sqrts_sparc64
#define helper_vfp_sqtod helper_vfp_sqtod_sparc64
#define helper_vfp_sqtoh helper_vfp_sqtoh_sparc64

View file

@ -126,8 +126,10 @@ DEF_HELPER_3(vfp_minnumd, f64, f64, f64, ptr)
DEF_HELPER_1(vfp_negh, f16, f16)
DEF_HELPER_1(vfp_negs, f32, f32)
DEF_HELPER_1(vfp_negd, f64, f64)
DEF_HELPER_1(vfp_absh, f16, f16)
DEF_HELPER_1(vfp_abss, f32, f32)
DEF_HELPER_1(vfp_absd, f64, f64)
DEF_HELPER_2(vfp_sqrth, f16, f16, env)
DEF_HELPER_2(vfp_sqrts, f32, f32, env)
DEF_HELPER_2(vfp_sqrtd, f64, f64, env)
DEF_HELPER_3(vfp_cmps, void, f32, f32, env)

View file

@ -1490,6 +1490,39 @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
return true;
}
static bool do_vfp_2op_hp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
{
/*
* Do a half-precision operation. Functionally this is
* the same as do_vfp_2op_sp(), except:
* - it doesn't need the VFP vector handling (fp16 is a
* v8 feature, and in v8 VFP vectors don't exist)
* - it does the aa32_fp16_arith feature test
*/
TCGv_i32 f0;
TCGContext *tcg_ctx = s->uc->tcg_ctx;
if (!dc_isar_feature(aa32_fp16_arith, s)) {
return false;
}
if (s->vec_len != 0 || s->vec_stride != 0) {
return false;
}
if (!vfp_access_check(s)) {
return true;
}
f0 = tcg_temp_new_i32(tcg_ctx);
neon_load_reg32(s, f0, vm);
fn(tcg_ctx, f0, f0);
neon_store_reg32(s, f0, vd);
tcg_temp_free_i32(tcg_ctx, f0);
return true;
}
static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm)
{
TCGContext *tcg_ctx = s->uc->tcg_ctx;
@ -2272,12 +2305,18 @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a)
DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32)
DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64)
DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh)
DO_VFP_2OP(VABS, sp, gen_helper_vfp_abss)
DO_VFP_2OP(VABS, dp, gen_helper_vfp_absd)
DO_VFP_2OP(VNEG, hp, gen_helper_vfp_negh)
DO_VFP_2OP(VNEG, sp, gen_helper_vfp_negs)
DO_VFP_2OP(VNEG, dp, gen_helper_vfp_negd)
static void gen_VSQRT_hp(TCGContext *tcg_ctx, TCGv_i32 vd, TCGv_i32 vm)
{
gen_helper_vfp_sqrth(tcg_ctx, vd, vm, tcg_ctx->cpu_env);
}
static void gen_VSQRT_sp(TCGContext *tcg_ctx, TCGv_i32 vd, TCGv_i32 vm)
{
@ -2289,6 +2328,7 @@ static void gen_VSQRT_dp(TCGContext *tcg_ctx, TCGv_i64 vd, TCGv_i64 vm)
gen_helper_vfp_sqrtd(tcg_ctx, vd, vm, tcg_ctx->cpu_env);
}
DO_VFP_2OP(VSQRT, hp, gen_VSQRT_hp)
DO_VFP_2OP(VSQRT, sp, gen_VSQRT_sp)
DO_VFP_2OP(VSQRT, dp, gen_VSQRT_dp)

View file

@ -162,12 +162,15 @@ VMOV_imm_dp ---- 1110 1.11 .... .... 1011 0000 .... \
VMOV_reg_sp ---- 1110 1.11 0000 .... 1010 01.0 .... @vfp_dm_ss
VMOV_reg_dp ---- 1110 1.11 0000 .... 1011 01.0 .... @vfp_dm_dd
VABS_hp ---- 1110 1.11 0000 .... 1001 11.0 .... @vfp_dm_ss
VABS_sp ---- 1110 1.11 0000 .... 1010 11.0 .... @vfp_dm_ss
VABS_dp ---- 1110 1.11 0000 .... 1011 11.0 .... @vfp_dm_dd
VNEG_hp ---- 1110 1.11 0001 .... 1001 01.0 .... @vfp_dm_ss
VNEG_sp ---- 1110 1.11 0001 .... 1010 01.0 .... @vfp_dm_ss
VNEG_dp ---- 1110 1.11 0001 .... 1011 01.0 .... @vfp_dm_dd
VSQRT_hp ---- 1110 1.11 0001 .... 1001 11.0 .... @vfp_dm_ss
VSQRT_sp ---- 1110 1.11 0001 .... 1010 11.0 .... @vfp_dm_ss
VSQRT_dp ---- 1110 1.11 0001 .... 1011 11.0 .... @vfp_dm_dd

View file

@ -279,6 +279,11 @@ float64 VFP_HELPER(neg, d)(float64 a)
return float64_chs(a);
}
dh_ctype_f16 VFP_HELPER(abs, h)(dh_ctype_f16 a)
{
return float16_abs(a);
}
float32 VFP_HELPER(abs, s)(float32 a)
{
return float32_abs(a);
@ -289,6 +294,11 @@ float64 VFP_HELPER(abs, d)(float64 a)
return float64_abs(a);
}
dh_ctype_f16 VFP_HELPER(sqrt, h)(dh_ctype_f16 a, CPUARMState *env)
{
return float16_sqrt(a, &env->vfp.fp_status_f16);
}
float32 VFP_HELPER(sqrt, s)(float32 a, CPUARMState *env)
{
return float32_sqrt(a, &env->vfp.fp_status);

View file

@ -1886,6 +1886,7 @@
#define helper_v7m_vlstm helper_v7m_vlstm_x86_64
#define helper_v8m_stackcheck helper_v8m_stackcheck_x86_64
#define helper_vfp_absd helper_vfp_absd_x86_64
#define helper_vfp_absh helper_vfp_absh_x86_64
#define helper_vfp_abss helper_vfp_abss_x86_64
#define helper_vfp_addd helper_vfp_addd_x86_64
#define helper_vfp_addh helper_vfp_addh_x86_64
@ -1937,6 +1938,7 @@
#define helper_vfp_sltoh helper_vfp_sltoh_x86_64
#define helper_vfp_sltos helper_vfp_sltos_x86_64
#define helper_vfp_sqrtd helper_vfp_sqrtd_x86_64
#define helper_vfp_sqrth helper_vfp_sqrth_x86_64
#define helper_vfp_sqrts helper_vfp_sqrts_x86_64
#define helper_vfp_sqtod helper_vfp_sqtod_x86_64
#define helper_vfp_sqtoh helper_vfp_sqtoh_x86_64