target/arm: Implement fp16 for VCEQ, VCGE, VCGT comparisons

Convert the Neon floating-point vector comparison ops VCEQ,
VCGE and VCGT over to using a gvec helper and use this to
implement the fp16 case.

(We put the float16_ceq() etc functions above the DO_2OP()
macro definition because later when we convert the
compare-against-zero instructions we'll want their
definitions to be visible at that point in the source file.)

Backports ad505db233b89b7fd4b5a98b6f0e8ac8d05b11db
This commit is contained in:
Peter Maydell 2021-03-01 16:44:06 -05:00 committed by Lioncash
parent 0e8fd4cd0c
commit 4eb39f1b2f
19 changed files with 152 additions and 3 deletions

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_aarch64
#define helper_gvec_fcadds helper_gvec_fcadds_aarch64
#define helper_gvec_fcaddd helper_gvec_fcaddd_aarch64
#define helper_gvec_fceq_h helper_gvec_fceq_h_aarch64
#define helper_gvec_fceq_s helper_gvec_fceq_s_aarch64
#define helper_gvec_fcge_h helper_gvec_fcge_h_aarch64
#define helper_gvec_fcge_s helper_gvec_fcge_s_aarch64
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_aarch64
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_aarch64
#define helper_gvec_fcmlad helper_gvec_fcmlad_aarch64
#define helper_gvec_fcmlah helper_gvec_fcmlah_aarch64
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_aarch64

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_aarch64eb
#define helper_gvec_fcadds helper_gvec_fcadds_aarch64eb
#define helper_gvec_fcaddd helper_gvec_fcaddd_aarch64eb
#define helper_gvec_fceq_h helper_gvec_fceq_h_aarch64eb
#define helper_gvec_fceq_s helper_gvec_fceq_s_aarch64eb
#define helper_gvec_fcge_h helper_gvec_fcge_h_aarch64eb
#define helper_gvec_fcge_s helper_gvec_fcge_s_aarch64eb
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_aarch64eb
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_aarch64eb
#define helper_gvec_fcmlad helper_gvec_fcmlad_aarch64eb
#define helper_gvec_fcmlah helper_gvec_fcmlah_aarch64eb
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_aarch64eb

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_arm
#define helper_gvec_fcadds helper_gvec_fcadds_arm
#define helper_gvec_fcaddd helper_gvec_fcaddd_arm
#define helper_gvec_fceq_h helper_gvec_fceq_h_arm
#define helper_gvec_fceq_s helper_gvec_fceq_s_arm
#define helper_gvec_fcge_h helper_gvec_fcge_h_arm
#define helper_gvec_fcge_s helper_gvec_fcge_s_arm
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_arm
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_arm
#define helper_gvec_fcmlad helper_gvec_fcmlad_arm
#define helper_gvec_fcmlah helper_gvec_fcmlah_arm
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_arm

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_armeb
#define helper_gvec_fcadds helper_gvec_fcadds_armeb
#define helper_gvec_fcaddd helper_gvec_fcaddd_armeb
#define helper_gvec_fceq_h helper_gvec_fceq_h_armeb
#define helper_gvec_fceq_s helper_gvec_fceq_s_armeb
#define helper_gvec_fcge_h helper_gvec_fcge_h_armeb
#define helper_gvec_fcge_s helper_gvec_fcge_s_armeb
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_armeb
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_armeb
#define helper_gvec_fcmlad helper_gvec_fcmlad_armeb
#define helper_gvec_fcmlah helper_gvec_fcmlah_armeb
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_armeb

View file

@ -1278,6 +1278,12 @@ symbols = (
'helper_gvec_fcaddh',
'helper_gvec_fcadds',
'helper_gvec_fcaddd',
'helper_gvec_fceq_h',
'helper_gvec_fceq_s',
'helper_gvec_fcge_h',
'helper_gvec_fcge_s',
'helper_gvec_fcgt_h',
'helper_gvec_fcgt_s',
'helper_gvec_fcmlad',
'helper_gvec_fcmlah',
'helper_gvec_fcmlah_idx',

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_m68k
#define helper_gvec_fcadds helper_gvec_fcadds_m68k
#define helper_gvec_fcaddd helper_gvec_fcaddd_m68k
#define helper_gvec_fceq_h helper_gvec_fceq_h_m68k
#define helper_gvec_fceq_s helper_gvec_fceq_s_m68k
#define helper_gvec_fcge_h helper_gvec_fcge_h_m68k
#define helper_gvec_fcge_s helper_gvec_fcge_s_m68k
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_m68k
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_m68k
#define helper_gvec_fcmlad helper_gvec_fcmlad_m68k
#define helper_gvec_fcmlah helper_gvec_fcmlah_m68k
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_m68k

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_mips
#define helper_gvec_fcadds helper_gvec_fcadds_mips
#define helper_gvec_fcaddd helper_gvec_fcaddd_mips
#define helper_gvec_fceq_h helper_gvec_fceq_h_mips
#define helper_gvec_fceq_s helper_gvec_fceq_s_mips
#define helper_gvec_fcge_h helper_gvec_fcge_h_mips
#define helper_gvec_fcge_s helper_gvec_fcge_s_mips
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_mips
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_mips
#define helper_gvec_fcmlad helper_gvec_fcmlad_mips
#define helper_gvec_fcmlah helper_gvec_fcmlah_mips
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_mips

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_mips64
#define helper_gvec_fcadds helper_gvec_fcadds_mips64
#define helper_gvec_fcaddd helper_gvec_fcaddd_mips64
#define helper_gvec_fceq_h helper_gvec_fceq_h_mips64
#define helper_gvec_fceq_s helper_gvec_fceq_s_mips64
#define helper_gvec_fcge_h helper_gvec_fcge_h_mips64
#define helper_gvec_fcge_s helper_gvec_fcge_s_mips64
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_mips64
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_mips64
#define helper_gvec_fcmlad helper_gvec_fcmlad_mips64
#define helper_gvec_fcmlah helper_gvec_fcmlah_mips64
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_mips64

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_mips64el
#define helper_gvec_fcadds helper_gvec_fcadds_mips64el
#define helper_gvec_fcaddd helper_gvec_fcaddd_mips64el
#define helper_gvec_fceq_h helper_gvec_fceq_h_mips64el
#define helper_gvec_fceq_s helper_gvec_fceq_s_mips64el
#define helper_gvec_fcge_h helper_gvec_fcge_h_mips64el
#define helper_gvec_fcge_s helper_gvec_fcge_s_mips64el
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_mips64el
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_mips64el
#define helper_gvec_fcmlad helper_gvec_fcmlad_mips64el
#define helper_gvec_fcmlah helper_gvec_fcmlah_mips64el
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_mips64el

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_mipsel
#define helper_gvec_fcadds helper_gvec_fcadds_mipsel
#define helper_gvec_fcaddd helper_gvec_fcaddd_mipsel
#define helper_gvec_fceq_h helper_gvec_fceq_h_mipsel
#define helper_gvec_fceq_s helper_gvec_fceq_s_mipsel
#define helper_gvec_fcge_h helper_gvec_fcge_h_mipsel
#define helper_gvec_fcge_s helper_gvec_fcge_s_mipsel
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_mipsel
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_mipsel
#define helper_gvec_fcmlad helper_gvec_fcmlad_mipsel
#define helper_gvec_fcmlah helper_gvec_fcmlah_mipsel
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_mipsel

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_powerpc
#define helper_gvec_fcadds helper_gvec_fcadds_powerpc
#define helper_gvec_fcaddd helper_gvec_fcaddd_powerpc
#define helper_gvec_fceq_h helper_gvec_fceq_h_powerpc
#define helper_gvec_fceq_s helper_gvec_fceq_s_powerpc
#define helper_gvec_fcge_h helper_gvec_fcge_h_powerpc
#define helper_gvec_fcge_s helper_gvec_fcge_s_powerpc
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_powerpc
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_powerpc
#define helper_gvec_fcmlad helper_gvec_fcmlad_powerpc
#define helper_gvec_fcmlah helper_gvec_fcmlah_powerpc
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_powerpc

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_riscv32
#define helper_gvec_fcadds helper_gvec_fcadds_riscv32
#define helper_gvec_fcaddd helper_gvec_fcaddd_riscv32
#define helper_gvec_fceq_h helper_gvec_fceq_h_riscv32
#define helper_gvec_fceq_s helper_gvec_fceq_s_riscv32
#define helper_gvec_fcge_h helper_gvec_fcge_h_riscv32
#define helper_gvec_fcge_s helper_gvec_fcge_s_riscv32
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_riscv32
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_riscv32
#define helper_gvec_fcmlad helper_gvec_fcmlad_riscv32
#define helper_gvec_fcmlah helper_gvec_fcmlah_riscv32
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_riscv32

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_riscv64
#define helper_gvec_fcadds helper_gvec_fcadds_riscv64
#define helper_gvec_fcaddd helper_gvec_fcaddd_riscv64
#define helper_gvec_fceq_h helper_gvec_fceq_h_riscv64
#define helper_gvec_fceq_s helper_gvec_fceq_s_riscv64
#define helper_gvec_fcge_h helper_gvec_fcge_h_riscv64
#define helper_gvec_fcge_s helper_gvec_fcge_s_riscv64
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_riscv64
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_riscv64
#define helper_gvec_fcmlad helper_gvec_fcmlad_riscv64
#define helper_gvec_fcmlah helper_gvec_fcmlah_riscv64
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_riscv64

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_sparc
#define helper_gvec_fcadds helper_gvec_fcadds_sparc
#define helper_gvec_fcaddd helper_gvec_fcaddd_sparc
#define helper_gvec_fceq_h helper_gvec_fceq_h_sparc
#define helper_gvec_fceq_s helper_gvec_fceq_s_sparc
#define helper_gvec_fcge_h helper_gvec_fcge_h_sparc
#define helper_gvec_fcge_s helper_gvec_fcge_s_sparc
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_sparc
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_sparc
#define helper_gvec_fcmlad helper_gvec_fcmlad_sparc
#define helper_gvec_fcmlah helper_gvec_fcmlah_sparc
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_sparc

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_sparc64
#define helper_gvec_fcadds helper_gvec_fcadds_sparc64
#define helper_gvec_fcaddd helper_gvec_fcaddd_sparc64
#define helper_gvec_fceq_h helper_gvec_fceq_h_sparc64
#define helper_gvec_fceq_s helper_gvec_fceq_s_sparc64
#define helper_gvec_fcge_h helper_gvec_fcge_h_sparc64
#define helper_gvec_fcge_s helper_gvec_fcge_s_sparc64
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_sparc64
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_sparc64
#define helper_gvec_fcmlad helper_gvec_fcmlad_sparc64
#define helper_gvec_fcmlah helper_gvec_fcmlah_sparc64
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_sparc64

View file

@ -630,6 +630,15 @@ DEF_HELPER_FLAGS_5(gvec_fmul_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fabd_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fabd_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fceq_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fceq_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fcge_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fcge_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fcgt_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_fcgt_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_ftsmul_h, TCG_CALL_NO_RWG,
void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(gvec_ftsmul_s, TCG_CALL_NO_RWG,

View file

@ -1131,6 +1131,9 @@ DO_3S_FP_GVEC(VADD, gen_helper_gvec_fadd_s, gen_helper_gvec_fadd_h)
DO_3S_FP_GVEC(VSUB, gen_helper_gvec_fsub_s, gen_helper_gvec_fsub_h)
DO_3S_FP_GVEC(VABD, gen_helper_gvec_fabd_s, gen_helper_gvec_fabd_h)
DO_3S_FP_GVEC(VMUL, gen_helper_gvec_fmul_s, gen_helper_gvec_fmul_h)
DO_3S_FP_GVEC(VCEQ, gen_helper_gvec_fceq_s, gen_helper_gvec_fceq_h)
DO_3S_FP_GVEC(VCGE, gen_helper_gvec_fcge_s, gen_helper_gvec_fcge_h)
DO_3S_FP_GVEC(VCGT, gen_helper_gvec_fcgt_s, gen_helper_gvec_fcgt_h)
/*
* For all the functions using this macro, size == 1 means fp16,
@ -1146,9 +1149,6 @@ DO_3S_FP_GVEC(VMUL, gen_helper_gvec_fmul_s, gen_helper_gvec_fmul_h)
return do_3same_fp(s, a, FUNC, READS_VD); \
}
DO_3S_FP(VCEQ, gen_helper_neon_ceq_f32, false)
DO_3S_FP(VCGE, gen_helper_neon_cge_f32, false)
DO_3S_FP(VCGT, gen_helper_neon_cgt_f32, false)
DO_3S_FP(VACGE, gen_helper_neon_acge_f32, false)
DO_3S_FP(VACGT, gen_helper_neon_acgt_f32, false)
DO_3S_FP(VMAX, gen_helper_vfp_maxs, false)

View file

@ -657,6 +657,41 @@ void HELPER(gvec_fcmlad)(void *vd, void *vn, void *vm,
clear_tail(d, opr_sz, simd_maxsz(desc));
}
/*
* Floating point comparisons producing an integer result (all 1s or all 0s).
* Note that EQ doesn't signal InvalidOp for QNaNs but GE and GT do.
* Softfloat routines return 0/1, which we convert to the 0/-1 Neon requires.
*/
static uint16_t float16_ceq(float16 op1, float16 op2, float_status *stat)
{
return -float16_eq_quiet(op1, op2, stat);
}
static uint32_t float32_ceq(float32 op1, float32 op2, float_status *stat)
{
return -float32_eq_quiet(op1, op2, stat);
}
static uint16_t float16_cge(float16 op1, float16 op2, float_status *stat)
{
return -float16_le(op2, op1, stat);
}
static uint32_t float32_cge(float32 op1, float32 op2, float_status *stat)
{
return -float32_le(op2, op1, stat);
}
static uint16_t float16_cgt(float16 op1, float16 op2, float_status *stat)
{
return -float16_lt(op2, op1, stat);
}
static uint32_t float32_cgt(float32 op1, float32 op2, float_status *stat)
{
return -float32_lt(op2, op1, stat);
}
#define DO_2OP(NAME, FUNC, TYPE) \
void HELPER(NAME)(void *vd, void *vn, void *stat, uint32_t desc) \
{ \
@ -748,6 +783,15 @@ DO_3OP(gvec_ftsmul_d, float64_ftsmul, float64)
DO_3OP(gvec_fabd_h, float16_abd, float16)
DO_3OP(gvec_fabd_s, float32_abd, float32)
DO_3OP(gvec_fceq_h, float16_ceq, float16)
DO_3OP(gvec_fceq_s, float32_ceq, float32)
DO_3OP(gvec_fcge_h, float16_cge, float16)
DO_3OP(gvec_fcge_s, float32_cge, float32)
DO_3OP(gvec_fcgt_h, float16_cgt, float16)
DO_3OP(gvec_fcgt_s, float32_cgt, float32)
#ifdef TARGET_AARCH64
DO_3OP(gvec_recps_h, helper_recpsf_f16, float16)

View file

@ -1272,6 +1272,12 @@
#define helper_gvec_fcaddh helper_gvec_fcaddh_x86_64
#define helper_gvec_fcadds helper_gvec_fcadds_x86_64
#define helper_gvec_fcaddd helper_gvec_fcaddd_x86_64
#define helper_gvec_fceq_h helper_gvec_fceq_h_x86_64
#define helper_gvec_fceq_s helper_gvec_fceq_s_x86_64
#define helper_gvec_fcge_h helper_gvec_fcge_h_x86_64
#define helper_gvec_fcge_s helper_gvec_fcge_s_x86_64
#define helper_gvec_fcgt_h helper_gvec_fcgt_h_x86_64
#define helper_gvec_fcgt_s helper_gvec_fcgt_s_x86_64
#define helper_gvec_fcmlad helper_gvec_fcmlad_x86_64
#define helper_gvec_fcmlah helper_gvec_fcmlah_x86_64
#define helper_gvec_fcmlah_idx helper_gvec_fcmlah_idx_x86_64