Re: [PATCH v3 09/34] target/arm/tcg: Move VFP helpers from helper-a64.c to vfp_helper.c

2023-06-20 Thread Richard Henderson

On 6/19/23 17:42, Philippe Mathieu-Daudé wrote:

Keep the VFP helpers in the same file, guarding them with #ifdef'ry.

Signed-off-by: Philippe Mathieu-Daudé
---
  target/arm/tcg/helper-a64.c | 87 --
  target/arm/vfp_helper.c | 93 -
  2 files changed, 92 insertions(+), 88 deletions(-)


I'm not keen on this.  First, because we have not yet disentangled vfp_helper.c from the 
bits required by KVM, so to move the rest into tcg/.  Second because large ifdef blocks 
are a sign that something wants splitting anyway.


Perhaps tcg/vfp_a64_helper.c?  There's probably a better name we could use...


r~



[PATCH v3 09/34] target/arm/tcg: Move VFP helpers from helper-a64.c to vfp_helper.c

2023-06-19 Thread Philippe Mathieu-Daudé
Keep the VFP helpers in the same file, guarding them with #ifdef'ry.

Signed-off-by: Philippe Mathieu-Daudé 
---
 target/arm/tcg/helper-a64.c | 87 --
 target/arm/vfp_helper.c | 93 -
 2 files changed, 92 insertions(+), 88 deletions(-)

diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
index 1c9370f07b..c43f22e7d4 100644
--- a/target/arm/tcg/helper-a64.c
+++ b/target/arm/tcg/helper-a64.c
@@ -93,93 +93,6 @@ void HELPER(msr_i_daifclear)(CPUARMState *env, uint32_t imm)
 arm_rebuild_hflags(env);
 }
 
-/* Convert a softfloat float_relation_ (as returned by
- * the float*_compare functions) to the correct ARM
- * NZCV flag state.
- */
-static inline uint32_t float_rel_to_flags(int res)
-{
-uint64_t flags;
-switch (res) {
-case float_relation_equal:
-flags = PSTATE_Z | PSTATE_C;
-break;
-case float_relation_less:
-flags = PSTATE_N;
-break;
-case float_relation_greater:
-flags = PSTATE_C;
-break;
-case float_relation_unordered:
-default:
-flags = PSTATE_C | PSTATE_V;
-break;
-}
-return flags;
-}
-
-uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status)
-{
-return float_rel_to_flags(float16_compare_quiet(x, y, fp_status));
-}
-
-uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status)
-{
-return float_rel_to_flags(float16_compare(x, y, fp_status));
-}
-
-uint64_t HELPER(vfp_cmps_a64)(float32 x, float32 y, void *fp_status)
-{
-return float_rel_to_flags(float32_compare_quiet(x, y, fp_status));
-}
-
-uint64_t HELPER(vfp_cmpes_a64)(float32 x, float32 y, void *fp_status)
-{
-return float_rel_to_flags(float32_compare(x, y, fp_status));
-}
-
-uint64_t HELPER(vfp_cmpd_a64)(float64 x, float64 y, void *fp_status)
-{
-return float_rel_to_flags(float64_compare_quiet(x, y, fp_status));
-}
-
-uint64_t HELPER(vfp_cmped_a64)(float64 x, float64 y, void *fp_status)
-{
-return float_rel_to_flags(float64_compare(x, y, fp_status));
-}
-
-float32 HELPER(vfp_mulxs)(float32 a, float32 b, void *fpstp)
-{
-float_status *fpst = fpstp;
-
-a = float32_squash_input_denormal(a, fpst);
-b = float32_squash_input_denormal(b, fpst);
-
-if ((float32_is_zero(a) && float32_is_infinity(b)) ||
-(float32_is_infinity(a) && float32_is_zero(b))) {
-/* 2.0 with the sign bit set to sign(A) XOR sign(B) */
-return make_float32((1U << 30) |
-((float32_val(a) ^ float32_val(b)) & (1U << 31)));
-}
-return float32_mul(a, b, fpst);
-}
-
-float64 HELPER(vfp_mulxd)(float64 a, float64 b, void *fpstp)
-{
-float_status *fpst = fpstp;
-
-a = float64_squash_input_denormal(a, fpst);
-b = float64_squash_input_denormal(b, fpst);
-
-if ((float64_is_zero(a) && float64_is_infinity(b)) ||
-(float64_is_infinity(a) && float64_is_zero(b))) {
-/* 2.0 with the sign bit set to sign(A) XOR sign(B) */
-return make_float64((1ULL << 62) |
-((float64_val(a) ^ float64_val(b)) & (1ULL << 
63)));
-}
-return float64_mul(a, b, fpst);
-}
-
 /* 64bit/double versions of the neon float compare functions */
 uint64_t HELPER(neon_ceq_f64)(float64 a, float64 b, void *fpstp)
 {
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
index 36906db8e0..0a5b2993a4 100644
--- a/target/arm/vfp_helper.c
+++ b/target/arm/vfp_helper.c
@@ -1326,4 +1326,95 @@ void HELPER(check_hcr_el2_trap)(CPUARMState *env, 
uint32_t rt, uint32_t reg)
 raise_exception(env, EXCP_HYP_TRAP, syndrome, 2);
 }
 
-#endif
+#ifdef TARGET_AARCH64
+
+/* Convert a softfloat float_relation_ (as returned by
+ * the float*_compare functions) to the correct ARM
+ * NZCV flag state.
+ */
+static inline uint32_t float_rel_to_flags(int res)
+{
+uint64_t flags;
+switch (res) {
+case float_relation_equal:
+flags = PSTATE_Z | PSTATE_C;
+break;
+case float_relation_less:
+flags = PSTATE_N;
+break;
+case float_relation_greater:
+flags = PSTATE_C;
+break;
+case float_relation_unordered:
+default:
+flags = PSTATE_C | PSTATE_V;
+break;
+}
+return flags;
+}
+
+uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status)
+{
+return float_rel_to_flags(float16_compare_quiet(x, y, fp_status));
+}
+
+uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status)
+{
+return float_rel_to_flags(float16_compare(x, y, fp_status));
+}
+
+uint64_t HELPER(vfp_cmps_a64)(float32 x, float32 y, void *fp_status)
+{
+return float_rel_to_flags(float32_compare_quiet(x, y, fp_status));
+}
+
+uint64_t HELPER(vfp_cmpes_a64)(float32 x, float32 y, void *fp_status)
+{
+return float_rel_to_flags(float32_compare(x, y, fp_status));
+}
+
+uint64_t HELPER(vfp_cmpd_a64)(float64 x, float64 y, void *fp_status)
+{
+return