From 82f4a7e135e88634b4282339e67c41f152aa9be0 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 1 Mar 2021 17:25:16 -0500 Subject: [PATCH] target/arm: Implement fp16 for Neon pairwise fp ops Convert the Neon pairwise fp ops to use a single gvic-style helper to do the full operation instead of one helper call for each 32-bit part. This allows us to use the same framework to implement the fp16. Backports 1dc587ee9bfe804406eb3e0bacf47a80644d8abc --- qemu/aarch64.h | 6 ++++ qemu/aarch64eb.h | 6 ++++ qemu/arm.h | 6 ++++ qemu/armeb.h | 6 ++++ qemu/header_gen.py | 6 ++++ qemu/m68k.h | 6 ++++ qemu/mips.h | 6 ++++ qemu/mips64.h | 6 ++++ qemu/mips64el.h | 6 ++++ qemu/mipsel.h | 6 ++++ qemu/powerpc.h | 6 ++++ qemu/riscv32.h | 6 ++++ qemu/riscv64.h | 6 ++++ qemu/sparc.h | 6 ++++ qemu/sparc64.h | 6 ++++ qemu/target/arm/helper.h | 7 +++++ qemu/target/arm/translate-neon.inc.c | 43 ++++++++++---------------- qemu/target/arm/vec_helper.c | 45 ++++++++++++++++++++++++++++ qemu/x86_64.h | 6 ++++ 19 files changed, 164 insertions(+), 27 deletions(-) diff --git a/qemu/aarch64.h b/qemu/aarch64.h index 1e09f386..d89f010b 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_aarch64 #define helper_neon_paddl_u16 helper_neon_paddl_u16_aarch64 #define helper_neon_paddl_u32 helper_neon_paddl_u32_aarch64 +#define helper_neon_paddh helper_neon_paddh_aarch64 +#define helper_neon_padds helper_neon_padds_aarch64 #define helper_neon_pmax_s16 helper_neon_pmax_s16_aarch64 #define helper_neon_pmax_s8 helper_neon_pmax_s8_aarch64 #define helper_neon_pmax_u16 helper_neon_pmax_u16_aarch64 #define helper_neon_pmax_u8 helper_neon_pmax_u8_aarch64 +#define helper_neon_pmaxh helper_neon_pmaxh_aarch64 +#define helper_neon_pmaxs helper_neon_pmaxs_aarch64 #define helper_neon_pmin_s16 helper_neon_pmin_s16_aarch64 #define helper_neon_pmin_s8 helper_neon_pmin_s8_aarch64 #define helper_neon_pmin_u16 helper_neon_pmin_u16_aarch64 #define helper_neon_pmin_u8 helper_neon_pmin_u8_aarch64 +#define helper_neon_pminh helper_neon_pminh_aarch64 +#define helper_neon_pmins helper_neon_pmins_aarch64 #define helper_neon_pmull_h helper_neon_pmull_h_aarch64 #define helper_neon_qabs_s16 helper_neon_qabs_s16_aarch64 #define helper_neon_qabs_s32 helper_neon_qabs_s32_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index 374c6f1e..e83bd9e8 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_aarch64eb #define helper_neon_paddl_u16 helper_neon_paddl_u16_aarch64eb #define helper_neon_paddl_u32 helper_neon_paddl_u32_aarch64eb +#define helper_neon_paddh helper_neon_paddh_aarch64eb +#define helper_neon_padds helper_neon_padds_aarch64eb #define helper_neon_pmax_s16 helper_neon_pmax_s16_aarch64eb #define helper_neon_pmax_s8 helper_neon_pmax_s8_aarch64eb #define helper_neon_pmax_u16 helper_neon_pmax_u16_aarch64eb #define helper_neon_pmax_u8 helper_neon_pmax_u8_aarch64eb +#define helper_neon_pmaxh helper_neon_pmaxh_aarch64eb +#define helper_neon_pmaxs helper_neon_pmaxs_aarch64eb #define helper_neon_pmin_s16 helper_neon_pmin_s16_aarch64eb #define helper_neon_pmin_s8 helper_neon_pmin_s8_aarch64eb #define helper_neon_pmin_u16 helper_neon_pmin_u16_aarch64eb #define helper_neon_pmin_u8 helper_neon_pmin_u8_aarch64eb +#define helper_neon_pminh helper_neon_pminh_aarch64eb +#define helper_neon_pmins helper_neon_pmins_aarch64eb #define helper_neon_pmull_h helper_neon_pmull_h_aarch64eb #define helper_neon_qabs_s16 helper_neon_qabs_s16_aarch64eb #define helper_neon_qabs_s32 helper_neon_qabs_s32_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 6fae7a9f..11a4895c 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_arm #define helper_neon_paddl_u16 helper_neon_paddl_u16_arm #define helper_neon_paddl_u32 helper_neon_paddl_u32_arm +#define helper_neon_paddh helper_neon_paddh_arm +#define helper_neon_padds helper_neon_padds_arm #define helper_neon_pmax_s16 helper_neon_pmax_s16_arm #define helper_neon_pmax_s8 helper_neon_pmax_s8_arm #define helper_neon_pmax_u16 helper_neon_pmax_u16_arm #define helper_neon_pmax_u8 helper_neon_pmax_u8_arm +#define helper_neon_pmaxh helper_neon_pmaxh_arm +#define helper_neon_pmaxs helper_neon_pmaxs_arm #define helper_neon_pmin_s16 helper_neon_pmin_s16_arm #define helper_neon_pmin_s8 helper_neon_pmin_s8_arm #define helper_neon_pmin_u16 helper_neon_pmin_u16_arm #define helper_neon_pmin_u8 helper_neon_pmin_u8_arm +#define helper_neon_pminh helper_neon_pminh_arm +#define helper_neon_pmins helper_neon_pmins_arm #define helper_neon_pmull_h helper_neon_pmull_h_arm #define helper_neon_qabs_s16 helper_neon_qabs_s16_arm #define helper_neon_qabs_s32 helper_neon_qabs_s32_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index 08dd3c3b..8e8f5aba 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_armeb #define helper_neon_paddl_u16 helper_neon_paddl_u16_armeb #define helper_neon_paddl_u32 helper_neon_paddl_u32_armeb +#define helper_neon_paddh helper_neon_paddh_armeb +#define helper_neon_padds helper_neon_padds_armeb #define helper_neon_pmax_s16 helper_neon_pmax_s16_armeb #define helper_neon_pmax_s8 helper_neon_pmax_s8_armeb #define helper_neon_pmax_u16 helper_neon_pmax_u16_armeb #define helper_neon_pmax_u8 helper_neon_pmax_u8_armeb +#define helper_neon_pmaxh helper_neon_pmaxh_armeb +#define helper_neon_pmaxs helper_neon_pmaxs_armeb #define helper_neon_pmin_s16 helper_neon_pmin_s16_armeb #define helper_neon_pmin_s8 helper_neon_pmin_s8_armeb #define helper_neon_pmin_u16 helper_neon_pmin_u16_armeb #define helper_neon_pmin_u8 helper_neon_pmin_u8_armeb +#define helper_neon_pminh helper_neon_pminh_armeb +#define helper_neon_pmins helper_neon_pmins_armeb #define helper_neon_pmull_h helper_neon_pmull_h_armeb #define helper_neon_qabs_s16 helper_neon_qabs_s16_armeb #define helper_neon_qabs_s32 helper_neon_qabs_s32_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 13ff98bd..61d3f30d 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -1713,14 +1713,20 @@ symbols = ( 'helper_neon_padd_u8', 'helper_neon_paddl_u16', 'helper_neon_paddl_u32', + 'helper_neon_paddh', + 'helper_neon_padds', 'helper_neon_pmax_s16', 'helper_neon_pmax_s8', 'helper_neon_pmax_u16', 'helper_neon_pmax_u8', + 'helper_neon_pmaxh', + 'helper_neon_pmaxs', 'helper_neon_pmin_s16', 'helper_neon_pmin_s8', 'helper_neon_pmin_u16', 'helper_neon_pmin_u8', + 'helper_neon_pminh', + 'helper_neon_pmins', 'helper_neon_pmull_h', 'helper_neon_qabs_s16', 'helper_neon_qabs_s32', diff --git a/qemu/m68k.h b/qemu/m68k.h index 82dbf472..b20a29e4 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_m68k #define helper_neon_paddl_u16 helper_neon_paddl_u16_m68k #define helper_neon_paddl_u32 helper_neon_paddl_u32_m68k +#define helper_neon_paddh helper_neon_paddh_m68k +#define helper_neon_padds helper_neon_padds_m68k #define helper_neon_pmax_s16 helper_neon_pmax_s16_m68k #define helper_neon_pmax_s8 helper_neon_pmax_s8_m68k #define helper_neon_pmax_u16 helper_neon_pmax_u16_m68k #define helper_neon_pmax_u8 helper_neon_pmax_u8_m68k +#define helper_neon_pmaxh helper_neon_pmaxh_m68k +#define helper_neon_pmaxs helper_neon_pmaxs_m68k #define helper_neon_pmin_s16 helper_neon_pmin_s16_m68k #define helper_neon_pmin_s8 helper_neon_pmin_s8_m68k #define helper_neon_pmin_u16 helper_neon_pmin_u16_m68k #define helper_neon_pmin_u8 helper_neon_pmin_u8_m68k +#define helper_neon_pminh helper_neon_pminh_m68k +#define helper_neon_pmins helper_neon_pmins_m68k #define helper_neon_pmull_h helper_neon_pmull_h_m68k #define helper_neon_qabs_s16 helper_neon_qabs_s16_m68k #define helper_neon_qabs_s32 helper_neon_qabs_s32_m68k diff --git a/qemu/mips.h b/qemu/mips.h index 5e87413a..43fb3d9d 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_mips #define helper_neon_paddl_u16 helper_neon_paddl_u16_mips #define helper_neon_paddl_u32 helper_neon_paddl_u32_mips +#define helper_neon_paddh helper_neon_paddh_mips +#define helper_neon_padds helper_neon_padds_mips #define helper_neon_pmax_s16 helper_neon_pmax_s16_mips #define helper_neon_pmax_s8 helper_neon_pmax_s8_mips #define helper_neon_pmax_u16 helper_neon_pmax_u16_mips #define helper_neon_pmax_u8 helper_neon_pmax_u8_mips +#define helper_neon_pmaxh helper_neon_pmaxh_mips +#define helper_neon_pmaxs helper_neon_pmaxs_mips #define helper_neon_pmin_s16 helper_neon_pmin_s16_mips #define helper_neon_pmin_s8 helper_neon_pmin_s8_mips #define helper_neon_pmin_u16 helper_neon_pmin_u16_mips #define helper_neon_pmin_u8 helper_neon_pmin_u8_mips +#define helper_neon_pminh helper_neon_pminh_mips +#define helper_neon_pmins helper_neon_pmins_mips #define helper_neon_pmull_h helper_neon_pmull_h_mips #define helper_neon_qabs_s16 helper_neon_qabs_s16_mips #define helper_neon_qabs_s32 helper_neon_qabs_s32_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index 06e76bfc..3a29995e 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_mips64 #define helper_neon_paddl_u16 helper_neon_paddl_u16_mips64 #define helper_neon_paddl_u32 helper_neon_paddl_u32_mips64 +#define helper_neon_paddh helper_neon_paddh_mips64 +#define helper_neon_padds helper_neon_padds_mips64 #define helper_neon_pmax_s16 helper_neon_pmax_s16_mips64 #define helper_neon_pmax_s8 helper_neon_pmax_s8_mips64 #define helper_neon_pmax_u16 helper_neon_pmax_u16_mips64 #define helper_neon_pmax_u8 helper_neon_pmax_u8_mips64 +#define helper_neon_pmaxh helper_neon_pmaxh_mips64 +#define helper_neon_pmaxs helper_neon_pmaxs_mips64 #define helper_neon_pmin_s16 helper_neon_pmin_s16_mips64 #define helper_neon_pmin_s8 helper_neon_pmin_s8_mips64 #define helper_neon_pmin_u16 helper_neon_pmin_u16_mips64 #define helper_neon_pmin_u8 helper_neon_pmin_u8_mips64 +#define helper_neon_pminh helper_neon_pminh_mips64 +#define helper_neon_pmins helper_neon_pmins_mips64 #define helper_neon_pmull_h helper_neon_pmull_h_mips64 #define helper_neon_qabs_s16 helper_neon_qabs_s16_mips64 #define helper_neon_qabs_s32 helper_neon_qabs_s32_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index f6846a37..1501d781 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_mips64el #define helper_neon_paddl_u16 helper_neon_paddl_u16_mips64el #define helper_neon_paddl_u32 helper_neon_paddl_u32_mips64el +#define helper_neon_paddh helper_neon_paddh_mips64el +#define helper_neon_padds helper_neon_padds_mips64el #define helper_neon_pmax_s16 helper_neon_pmax_s16_mips64el #define helper_neon_pmax_s8 helper_neon_pmax_s8_mips64el #define helper_neon_pmax_u16 helper_neon_pmax_u16_mips64el #define helper_neon_pmax_u8 helper_neon_pmax_u8_mips64el +#define helper_neon_pmaxh helper_neon_pmaxh_mips64el +#define helper_neon_pmaxs helper_neon_pmaxs_mips64el #define helper_neon_pmin_s16 helper_neon_pmin_s16_mips64el #define helper_neon_pmin_s8 helper_neon_pmin_s8_mips64el #define helper_neon_pmin_u16 helper_neon_pmin_u16_mips64el #define helper_neon_pmin_u8 helper_neon_pmin_u8_mips64el +#define helper_neon_pminh helper_neon_pminh_mips64el +#define helper_neon_pmins helper_neon_pmins_mips64el #define helper_neon_pmull_h helper_neon_pmull_h_mips64el #define helper_neon_qabs_s16 helper_neon_qabs_s16_mips64el #define helper_neon_qabs_s32 helper_neon_qabs_s32_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index 914691cb..a1219f88 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_mipsel #define helper_neon_paddl_u16 helper_neon_paddl_u16_mipsel #define helper_neon_paddl_u32 helper_neon_paddl_u32_mipsel +#define helper_neon_paddh helper_neon_paddh_mipsel +#define helper_neon_padds helper_neon_padds_mipsel #define helper_neon_pmax_s16 helper_neon_pmax_s16_mipsel #define helper_neon_pmax_s8 helper_neon_pmax_s8_mipsel #define helper_neon_pmax_u16 helper_neon_pmax_u16_mipsel #define helper_neon_pmax_u8 helper_neon_pmax_u8_mipsel +#define helper_neon_pmaxh helper_neon_pmaxh_mipsel +#define helper_neon_pmaxs helper_neon_pmaxs_mipsel #define helper_neon_pmin_s16 helper_neon_pmin_s16_mipsel #define helper_neon_pmin_s8 helper_neon_pmin_s8_mipsel #define helper_neon_pmin_u16 helper_neon_pmin_u16_mipsel #define helper_neon_pmin_u8 helper_neon_pmin_u8_mipsel +#define helper_neon_pminh helper_neon_pminh_mipsel +#define helper_neon_pmins helper_neon_pmins_mipsel #define helper_neon_pmull_h helper_neon_pmull_h_mipsel #define helper_neon_qabs_s16 helper_neon_qabs_s16_mipsel #define helper_neon_qabs_s32 helper_neon_qabs_s32_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index bde8cf29..26226f3b 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_powerpc #define helper_neon_paddl_u16 helper_neon_paddl_u16_powerpc #define helper_neon_paddl_u32 helper_neon_paddl_u32_powerpc +#define helper_neon_paddh helper_neon_paddh_powerpc +#define helper_neon_padds helper_neon_padds_powerpc #define helper_neon_pmax_s16 helper_neon_pmax_s16_powerpc #define helper_neon_pmax_s8 helper_neon_pmax_s8_powerpc #define helper_neon_pmax_u16 helper_neon_pmax_u16_powerpc #define helper_neon_pmax_u8 helper_neon_pmax_u8_powerpc +#define helper_neon_pmaxh helper_neon_pmaxh_powerpc +#define helper_neon_pmaxs helper_neon_pmaxs_powerpc #define helper_neon_pmin_s16 helper_neon_pmin_s16_powerpc #define helper_neon_pmin_s8 helper_neon_pmin_s8_powerpc #define helper_neon_pmin_u16 helper_neon_pmin_u16_powerpc #define helper_neon_pmin_u8 helper_neon_pmin_u8_powerpc +#define helper_neon_pminh helper_neon_pminh_powerpc +#define helper_neon_pmins helper_neon_pmins_powerpc #define helper_neon_pmull_h helper_neon_pmull_h_powerpc #define helper_neon_qabs_s16 helper_neon_qabs_s16_powerpc #define helper_neon_qabs_s32 helper_neon_qabs_s32_powerpc diff --git a/qemu/riscv32.h b/qemu/riscv32.h index 881e6b58..74103514 100644 --- a/qemu/riscv32.h +++ b/qemu/riscv32.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_riscv32 #define helper_neon_paddl_u16 helper_neon_paddl_u16_riscv32 #define helper_neon_paddl_u32 helper_neon_paddl_u32_riscv32 +#define helper_neon_paddh helper_neon_paddh_riscv32 +#define helper_neon_padds helper_neon_padds_riscv32 #define helper_neon_pmax_s16 helper_neon_pmax_s16_riscv32 #define helper_neon_pmax_s8 helper_neon_pmax_s8_riscv32 #define helper_neon_pmax_u16 helper_neon_pmax_u16_riscv32 #define helper_neon_pmax_u8 helper_neon_pmax_u8_riscv32 +#define helper_neon_pmaxh helper_neon_pmaxh_riscv32 +#define helper_neon_pmaxs helper_neon_pmaxs_riscv32 #define helper_neon_pmin_s16 helper_neon_pmin_s16_riscv32 #define helper_neon_pmin_s8 helper_neon_pmin_s8_riscv32 #define helper_neon_pmin_u16 helper_neon_pmin_u16_riscv32 #define helper_neon_pmin_u8 helper_neon_pmin_u8_riscv32 +#define helper_neon_pminh helper_neon_pminh_riscv32 +#define helper_neon_pmins helper_neon_pmins_riscv32 #define helper_neon_pmull_h helper_neon_pmull_h_riscv32 #define helper_neon_qabs_s16 helper_neon_qabs_s16_riscv32 #define helper_neon_qabs_s32 helper_neon_qabs_s32_riscv32 diff --git a/qemu/riscv64.h b/qemu/riscv64.h index 6ef43bb6..e466d78d 100644 --- a/qemu/riscv64.h +++ b/qemu/riscv64.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_riscv64 #define helper_neon_paddl_u16 helper_neon_paddl_u16_riscv64 #define helper_neon_paddl_u32 helper_neon_paddl_u32_riscv64 +#define helper_neon_paddh helper_neon_paddh_riscv64 +#define helper_neon_padds helper_neon_padds_riscv64 #define helper_neon_pmax_s16 helper_neon_pmax_s16_riscv64 #define helper_neon_pmax_s8 helper_neon_pmax_s8_riscv64 #define helper_neon_pmax_u16 helper_neon_pmax_u16_riscv64 #define helper_neon_pmax_u8 helper_neon_pmax_u8_riscv64 +#define helper_neon_pmaxh helper_neon_pmaxh_riscv64 +#define helper_neon_pmaxs helper_neon_pmaxs_riscv64 #define helper_neon_pmin_s16 helper_neon_pmin_s16_riscv64 #define helper_neon_pmin_s8 helper_neon_pmin_s8_riscv64 #define helper_neon_pmin_u16 helper_neon_pmin_u16_riscv64 #define helper_neon_pmin_u8 helper_neon_pmin_u8_riscv64 +#define helper_neon_pminh helper_neon_pminh_riscv64 +#define helper_neon_pmins helper_neon_pmins_riscv64 #define helper_neon_pmull_h helper_neon_pmull_h_riscv64 #define helper_neon_qabs_s16 helper_neon_qabs_s16_riscv64 #define helper_neon_qabs_s32 helper_neon_qabs_s32_riscv64 diff --git a/qemu/sparc.h b/qemu/sparc.h index 002c203c..6426646a 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_sparc #define helper_neon_paddl_u16 helper_neon_paddl_u16_sparc #define helper_neon_paddl_u32 helper_neon_paddl_u32_sparc +#define helper_neon_paddh helper_neon_paddh_sparc +#define helper_neon_padds helper_neon_padds_sparc #define helper_neon_pmax_s16 helper_neon_pmax_s16_sparc #define helper_neon_pmax_s8 helper_neon_pmax_s8_sparc #define helper_neon_pmax_u16 helper_neon_pmax_u16_sparc #define helper_neon_pmax_u8 helper_neon_pmax_u8_sparc +#define helper_neon_pmaxh helper_neon_pmaxh_sparc +#define helper_neon_pmaxs helper_neon_pmaxs_sparc #define helper_neon_pmin_s16 helper_neon_pmin_s16_sparc #define helper_neon_pmin_s8 helper_neon_pmin_s8_sparc #define helper_neon_pmin_u16 helper_neon_pmin_u16_sparc #define helper_neon_pmin_u8 helper_neon_pmin_u8_sparc +#define helper_neon_pminh helper_neon_pminh_sparc +#define helper_neon_pmins helper_neon_pmins_sparc #define helper_neon_pmull_h helper_neon_pmull_h_sparc #define helper_neon_qabs_s16 helper_neon_qabs_s16_sparc #define helper_neon_qabs_s32 helper_neon_qabs_s32_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 6f0f62e2..6f84dc4e 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_sparc64 #define helper_neon_paddl_u16 helper_neon_paddl_u16_sparc64 #define helper_neon_paddl_u32 helper_neon_paddl_u32_sparc64 +#define helper_neon_paddh helper_neon_paddh_sparc64 +#define helper_neon_padds helper_neon_padds_sparc64 #define helper_neon_pmax_s16 helper_neon_pmax_s16_sparc64 #define helper_neon_pmax_s8 helper_neon_pmax_s8_sparc64 #define helper_neon_pmax_u16 helper_neon_pmax_u16_sparc64 #define helper_neon_pmax_u8 helper_neon_pmax_u8_sparc64 +#define helper_neon_pmaxh helper_neon_pmaxh_sparc64 +#define helper_neon_pmaxs helper_neon_pmaxs_sparc64 #define helper_neon_pmin_s16 helper_neon_pmin_s16_sparc64 #define helper_neon_pmin_s8 helper_neon_pmin_s8_sparc64 #define helper_neon_pmin_u16 helper_neon_pmin_u16_sparc64 #define helper_neon_pmin_u8 helper_neon_pmin_u8_sparc64 +#define helper_neon_pminh helper_neon_pminh_sparc64 +#define helper_neon_pmins helper_neon_pmins_sparc64 #define helper_neon_pmull_h helper_neon_pmull_h_sparc64 #define helper_neon_qabs_s16 helper_neon_qabs_s16_sparc64 #define helper_neon_qabs_s32 helper_neon_qabs_s32_sparc64 diff --git a/qemu/target/arm/helper.h b/qemu/target/arm/helper.h index 6b099a00..cbef235c 100644 --- a/qemu/target/arm/helper.h +++ b/qemu/target/arm/helper.h @@ -605,6 +605,13 @@ DEF_HELPER_FLAGS_5(gvec_fcmlas_idx, TCG_CALL_NO_RWG, DEF_HELPER_FLAGS_5(gvec_fcmlad, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(neon_paddh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(neon_pmaxh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(neon_pminh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +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_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) diff --git a/qemu/target/arm/translate-neon.inc.c b/qemu/target/arm/translate-neon.inc.c index 02cd322d..4e46e647 100644 --- a/qemu/target/arm/translate-neon.inc.c +++ b/qemu/target/arm/translate-neon.inc.c @@ -1132,10 +1132,10 @@ static bool trans_VMINNM_fp_3s(DisasContext *s, arg_3same *a) return do_3same(s, a, gen_VMINNM_fp32_3s); } -static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn) +static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, + gen_helper_gvec_3_ptr *fn) { - /* FP operations handled pairwise 32 bits at a time */ - TCGv_i32 tmp, tmp2, tmp3; + /* FP pairwise operations */ TCGv_ptr fpstatus; TCGContext *tcg_ctx = s->uc->tcg_ctx; @@ -1155,26 +1155,13 @@ static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn) assert(a->q == 0); /* enforced by decode patterns */ - /* - * Note that we have to be careful not to clobber the source operands - * in the "vm == vd" case by storing the result of the first pass too - * early. Since Q is 0 there are always just two passes, so instead - * of a complicated loop over each pass we just unroll. - */ - fpstatus = fpstatus_ptr(tcg_ctx, FPST_STD); - tmp = neon_load_reg(s, a->vn, 0); - tmp2 = neon_load_reg(s, a->vn, 1); - fn(tcg_ctx, tmp, tmp, tmp2, fpstatus); - tcg_temp_free_i32(tcg_ctx, tmp2); - - tmp3 = neon_load_reg(s, a->vm, 0); - tmp2 = neon_load_reg(s, a->vm, 1); - fn(tcg_ctx, tmp3, tmp3, tmp2, fpstatus); - tcg_temp_free_i32(tcg_ctx, tmp2); + fpstatus = fpstatus_ptr(tcg_ctx, a->size != 0 ? FPST_STD_F16 : FPST_STD); + tcg_gen_gvec_3_ptr(tcg_ctx, vfp_reg_offset(1, a->vd), + vfp_reg_offset(1, a->vn), + vfp_reg_offset(1, a->vm), + fpstatus, 8, 8, 0, fn); tcg_temp_free_ptr(tcg_ctx, fpstatus); - neon_store_reg(s, a->vd, 0, tmp); - neon_store_reg(s, a->vd, 1, tmp3); return true; } @@ -1186,15 +1173,17 @@ static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn) static bool trans_##INSN##_fp_3s(DisasContext *s, arg_3same *a) \ { \ if (a->size != 0) { \ - /* TODO fp16 support */ \ - return false; \ + if (!dc_isar_feature(aa32_fp16_arith, s)) { \ + return false; \ + } \ + return do_3same_fp_pair(s, a, FUNC##h); \ } \ - return do_3same_fp_pair(s, a, FUNC); \ + return do_3same_fp_pair(s, a, FUNC##s); \ } -DO_3S_FP_PAIR(VPADD, gen_helper_vfp_adds) -DO_3S_FP_PAIR(VPMAX, gen_helper_vfp_maxs) -DO_3S_FP_PAIR(VPMIN, gen_helper_vfp_mins) +DO_3S_FP_PAIR(VPADD, gen_helper_neon_padd) +DO_3S_FP_PAIR(VPMAX, gen_helper_neon_pmax) +DO_3S_FP_PAIR(VPMIN, gen_helper_neon_pmin) static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) { diff --git a/qemu/target/arm/vec_helper.c b/qemu/target/arm/vec_helper.c index 11643a76..836d5cbb 100644 --- a/qemu/target/arm/vec_helper.c +++ b/qemu/target/arm/vec_helper.c @@ -1771,3 +1771,48 @@ DO_ABA(gvec_uaba_s, uint32_t) DO_ABA(gvec_uaba_d, uint64_t) #undef DO_ABA + +#define DO_NEON_PAIRWISE(NAME, OP) \ + void HELPER(NAME##s)(void *vd, void *vn, void *vm, \ + void *stat, uint32_t oprsz) \ + { \ + float_status *fpst = stat; \ + float32 *d = vd; \ + float32 *n = vn; \ + float32 *m = vm; \ + float32 r0, r1; \ + \ + /* Read all inputs before writing outputs in case vm == vd */ \ + r0 = float32_##OP(n[H4(0)], n[H4(1)], fpst); \ + r1 = float32_##OP(m[H4(0)], m[H4(1)], fpst); \ + \ + d[H4(0)] = r0; \ + d[H4(1)] = r1; \ + } \ + \ + void HELPER(NAME##h)(void *vd, void *vn, void *vm, \ + void *stat, uint32_t oprsz) \ + { \ + float_status *fpst = stat; \ + float16 *d = vd; \ + float16 *n = vn; \ + float16 *m = vm; \ + float16 r0, r1, r2, r3; \ + \ + /* Read all inputs before writing outputs in case vm == vd */ \ + r0 = float16_##OP(n[H2(0)], n[H2(1)], fpst); \ + r1 = float16_##OP(n[H2(2)], n[H2(3)], fpst); \ + r2 = float16_##OP(m[H2(0)], m[H2(1)], fpst); \ + r3 = float16_##OP(m[H2(2)], m[H2(3)], fpst); \ + \ + d[H4(0)] = r0; \ + d[H4(1)] = r1; \ + d[H4(2)] = r2; \ + d[H4(3)] = r3; \ + } + +DO_NEON_PAIRWISE(neon_padd, add) +DO_NEON_PAIRWISE(neon_pmax, max) +DO_NEON_PAIRWISE(neon_pmin, min) + +#undef DO_NEON_PAIRWISE diff --git a/qemu/x86_64.h b/qemu/x86_64.h index 7e5af7a6..9d7cbe63 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -1707,14 +1707,20 @@ #define helper_neon_padd_u8 helper_neon_padd_u8_x86_64 #define helper_neon_paddl_u16 helper_neon_paddl_u16_x86_64 #define helper_neon_paddl_u32 helper_neon_paddl_u32_x86_64 +#define helper_neon_paddh helper_neon_paddh_x86_64 +#define helper_neon_padds helper_neon_padds_x86_64 #define helper_neon_pmax_s16 helper_neon_pmax_s16_x86_64 #define helper_neon_pmax_s8 helper_neon_pmax_s8_x86_64 #define helper_neon_pmax_u16 helper_neon_pmax_u16_x86_64 #define helper_neon_pmax_u8 helper_neon_pmax_u8_x86_64 +#define helper_neon_pmaxh helper_neon_pmaxh_x86_64 +#define helper_neon_pmaxs helper_neon_pmaxs_x86_64 #define helper_neon_pmin_s16 helper_neon_pmin_s16_x86_64 #define helper_neon_pmin_s8 helper_neon_pmin_s8_x86_64 #define helper_neon_pmin_u16 helper_neon_pmin_u16_x86_64 #define helper_neon_pmin_u8 helper_neon_pmin_u8_x86_64 +#define helper_neon_pminh helper_neon_pminh_x86_64 +#define helper_neon_pmins helper_neon_pmins_x86_64 #define helper_neon_pmull_h helper_neon_pmull_h_x86_64 #define helper_neon_qabs_s16 helper_neon_qabs_s16_x86_64 #define helper_neon_qabs_s32 helper_neon_qabs_s32_x86_64