[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/22] target/arm: Use macros instead of open-coding fp16 convers
From: |
Peter Maydell |
Subject: |
[PATCH 14/22] target/arm: Use macros instead of open-coding fp16 conversion helpers |
Date: |
Mon, 24 Aug 2020 15:29:26 +0100 |
Now the VFP_CONV_FIX macros can handle fp16's distinction between the
width of the operation and the width of the type used to pass operands,
use the macros rather than the open-coded functions.
This creates an extra six helper functions, all of which we are going
to need for the AArch32 VFP fp16 instructions.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/helper.h | 6 +++
target/arm/vfp_helper.c | 86 +++--------------------------------------
2 files changed, 12 insertions(+), 80 deletions(-)
diff --git a/target/arm/helper.h b/target/arm/helper.h
index 278b4e47fd2..eefd1ac2a72 100644
--- a/target/arm/helper.h
+++ b/target/arm/helper.h
@@ -164,6 +164,10 @@ DEF_HELPER_2(vfp_tosizh, s32, f16, ptr)
DEF_HELPER_2(vfp_tosizs, s32, f32, ptr)
DEF_HELPER_2(vfp_tosizd, s32, f64, ptr)
+DEF_HELPER_3(vfp_toshh_round_to_zero, i32, f32, i32, ptr)
+DEF_HELPER_3(vfp_toslh_round_to_zero, i32, f32, i32, ptr)
+DEF_HELPER_3(vfp_touhh_round_to_zero, i32, f32, i32, ptr)
+DEF_HELPER_3(vfp_toulh_round_to_zero, i32, f32, i32, ptr)
DEF_HELPER_3(vfp_toshs_round_to_zero, i32, f32, i32, ptr)
DEF_HELPER_3(vfp_tosls_round_to_zero, i32, f32, i32, ptr)
DEF_HELPER_3(vfp_touhs_round_to_zero, i32, f32, i32, ptr)
@@ -202,6 +206,8 @@ DEF_HELPER_3(vfp_sqtod, f64, i64, i32, ptr)
DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr)
DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr)
DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr)
+DEF_HELPER_3(vfp_shtoh, f32, i32, i32, ptr)
+DEF_HELPER_3(vfp_uhtoh, f32, i32, i32, ptr)
DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr)
DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr)
DEF_HELPER_3(vfp_sqtoh, f16, i64, i32, ptr)
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
index 7f7dbe4257f..c88ace3c566 100644
--- a/target/arm/vfp_helper.c
+++ b/target/arm/vfp_helper.c
@@ -434,92 +434,18 @@ VFP_CONV_FIX_A64(sq, s, 32, float32, 64, int64)
VFP_CONV_FIX(uh, s, 32, float32, 32, uint16)
VFP_CONV_FIX(ul, s, 32, float32, 32, uint32)
VFP_CONV_FIX_A64(uq, s, 32, float32, 64, uint64)
+VFP_CONV_FIX(sh, h, 16, float32, 32, int16)
+VFP_CONV_FIX(sl, h, 16, float32, 32, int32)
+VFP_CONV_FIX_A64(sq, h, 16, float32, 64, int64)
+VFP_CONV_FIX(uh, h, 16, float32, 32, uint16)
+VFP_CONV_FIX(ul, h, 16, float32, 32, uint32)
+VFP_CONV_FIX_A64(uq, h, 16, float32, 64, uint64)
#undef VFP_CONV_FIX
#undef VFP_CONV_FIX_FLOAT
#undef VFP_CONV_FLOAT_FIX_ROUND
#undef VFP_CONV_FIX_A64
-uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst)
-{
- return int32_to_float16_scalbn(x, -shift, fpst);
-}
-
-uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
-{
- return uint32_to_float16_scalbn(x, -shift, fpst);
-}
-
-uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
-{
- return int64_to_float16_scalbn(x, -shift, fpst);
-}
-
-uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
-{
- return uint64_to_float16_scalbn(x, -shift, fpst);
-}
-
-uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst)
-{
- if (unlikely(float16_is_any_nan(x))) {
- float_raise(float_flag_invalid, fpst);
- return 0;
- }
- return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst),
- shift, fpst);
-}
-
-uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst)
-{
- if (unlikely(float16_is_any_nan(x))) {
- float_raise(float_flag_invalid, fpst);
- return 0;
- }
- return float16_to_uint16_scalbn(x, get_float_rounding_mode(fpst),
- shift, fpst);
-}
-
-uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst)
-{
- if (unlikely(float16_is_any_nan(x))) {
- float_raise(float_flag_invalid, fpst);
- return 0;
- }
- return float16_to_int32_scalbn(x, get_float_rounding_mode(fpst),
- shift, fpst);
-}
-
-uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst)
-{
- if (unlikely(float16_is_any_nan(x))) {
- float_raise(float_flag_invalid, fpst);
- return 0;
- }
- return float16_to_uint32_scalbn(x, get_float_rounding_mode(fpst),
- shift, fpst);
-}
-
-uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst)
-{
- if (unlikely(float16_is_any_nan(x))) {
- float_raise(float_flag_invalid, fpst);
- return 0;
- }
- return float16_to_int64_scalbn(x, get_float_rounding_mode(fpst),
- shift, fpst);
-}
-
-uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst)
-{
- if (unlikely(float16_is_any_nan(x))) {
- float_raise(float_flag_invalid, fpst);
- return 0;
- }
- return float16_to_uint64_scalbn(x, get_float_rounding_mode(fpst),
- shift, fpst);
-}
-
/* Set the current fp rounding mode and return the old one.
* The argument is a softfloat float_round_ value.
*/
--
2.20.1
- [PATCH 09/22] target/arm: Implement VFP fp16 for VMOV immediate, (continued)
- [PATCH 09/22] target/arm: Implement VFP fp16 for VMOV immediate, Peter Maydell, 2020/08/24
- [PATCH 10/22] target/arm: Implement VFP fp16 VCMP, Peter Maydell, 2020/08/24
- [PATCH 11/22] target/arm: Implement VFP fp16 VLDR and VSTR, Peter Maydell, 2020/08/24
- [PATCH 12/22] target/arm: Implement VFP fp16 VCVT between float and integer, Peter Maydell, 2020/08/24
- [PATCH 15/22] target/arm: Implement VFP fp16 VCVT between float and fixed-point, Peter Maydell, 2020/08/24
- [PATCH 14/22] target/arm: Use macros instead of open-coding fp16 conversion helpers,
Peter Maydell <=
- [PATCH 13/22] target/arm: Make VFP_CONV_FIX macros take separate float type and float size, Peter Maydell, 2020/08/24
- [PATCH 16/22] target/arm: Implement VFP vp16 VCVT-with-specified-rounding-mode, Peter Maydell, 2020/08/24
- [PATCH 17/22] target/arm: Implement VFP fp16 VSEL, Peter Maydell, 2020/08/24
- [PATCH 18/22] target/arm: Implement VFP fp16 VRINT*, Peter Maydell, 2020/08/24
- [PATCH 19/22] target/arm: Implement new VFP fp16 insn VINS, Peter Maydell, 2020/08/24