Skip to contentSkip to conversation

target-arm: Implement ARMv8 FP VMAXNM and VMINNM instructions.

PATCH Superseded Will Newton 1 participant 1 message Nov 28, 2013

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 3/4 target-arm: Implement ARMv8 FP VMAXNM and VMINNM instructions.

This adds support for the ARMv8 floating point VMAXNM and VMINNM instructions.

---
 target-arm/helper.c    | 41 +++++++++++++++++++++++++++++++++++++++++
 target-arm/helper.h    |  5 +++++
 target-arm/translate.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)

Changes in v6:
- New patch

target-arm/helper.c +41 -0
index 3445813..e5428d1 100644
@@ -4079,3 +4079,44 @@ float64 VFP_HELPER(muladd, d)(float64 a, float64 b, float64 c, void *fpstp)
     float_status *fpst = fpstp;
     return float64_muladd(a, b, c, 0, fpst);
 }
+
+/* ARMv8 VMAXNM/VMINNM */
+float32 VFP_HELPER(maxnm, s)(float32 a, float32 b, void *fpstp)
+{
+    float_status *fpst = fpstp;
+    if (float32_is_quiet_nan(a) && !float32_is_quiet_nan(b))
+        return b;
+    else if (float32_is_quiet_nan(b) && !float32_is_quiet_nan(a))
+        return a;
+    return float32_max(a, b, fpst);
+}
+
+float64 VFP_HELPER(maxnm, d)(float64 a, float64 b, void *fpstp)
+{
+    float_status *fpst = fpstp;
+    if (float64_is_quiet_nan(a) && !float64_is_quiet_nan(b))
+        return b;
+    else if (float64_is_quiet_nan(b) && !float64_is_quiet_nan(a))
+        return a;
+    return float64_max(a, b, fpst);
+}
+
+float32 VFP_HELPER(minnm, s)(float32 a, float32 b, void *fpstp)
+{
+    float_status *fpst = fpstp;
+    if (float32_is_quiet_nan(a) && !float32_is_quiet_nan(b))
+        return b;
+    else if (float32_is_quiet_nan(b) && !float32_is_quiet_nan(a))
+        return a;
+    return float32_min(a, b, fpst);
+}
+
+float64 VFP_HELPER(minnm, d)(float64 a, float64 b, void *fpstp)
+{
+    float_status *fpst = fpstp;
+    if (float64_is_quiet_nan(a) && !float64_is_quiet_nan(b))
+        return b;
+    else if (float64_is_quiet_nan(b) && !float64_is_quiet_nan(a))
+        return a;
+    return float64_min(a, b, fpst);
+}
target-arm/helper.h +5 -0
index cac9564..d459a39 100644
@@ -132,6 +132,11 @@ DEF_HELPER_2(neon_fcvt_f32_to_f16, i32, f32, env)
 DEF_HELPER_4(vfp_muladdd, f64, f64, f64, f64, ptr)
 DEF_HELPER_4(vfp_muladds, f32, f32, f32, f32, ptr)
 
+DEF_HELPER_3(vfp_maxnmd, f64, f64, f64, ptr)
+DEF_HELPER_3(vfp_maxnms, f32, f32, f32, ptr)
+DEF_HELPER_3(vfp_minnmd, f64, f64, f64, ptr)
+DEF_HELPER_3(vfp_minnms, f32, f32, f32, ptr)
+
 DEF_HELPER_3(recps_f32, f32, f32, f32, env)
 DEF_HELPER_3(rsqrts_f32, f32, f32, f32, env)
 DEF_HELPER_2(recpe_f32, f32, f32, env)
target-arm/translate.c +43 -0

49 lines not on this page · raw message

Signature · 1 line
1.8.1.4