All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes
@ 2017-02-10  7:23 Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 1/7] softfloat: Add round-to-odd rounding mode Bharata B Rao
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao

This series contains 2 new instructions (xscvqpudz, xscvqpuwz) and
round-to-odd variants of 6 instructions (xsaddqpo, xsmulqpo, xsdivqpo,
xscvqpdpo, xssqrtqpo, xssubqpo)
 
This also includes softfloat enhancements that are needed by
the above instructions. These softfloat patches have been posted
separately earlier and reviewed. Including them here as the new
instructions here depend on them.

I also saw that target-s390 also needs float128_to_uint64() and
float128_to_uint32(). Implemented the latter in this series and
made fixes in s390 code to use them. Note that s390 changes have
been compile-tested only. The last two patches ideally needn't
be part of this series, but included them here as s390 fixes
depend on the softfloat changes that are part of this patchset.

Bharata B Rao (7):
  softfloat: Add round-to-odd rounding mode
  softfloat: Add float128_to_uint64_round_to_zero()
  softfloat: Add float128_to_uint32_round_to_zero()
  target-ppc: Implement round to odd variants of quad FP instructions
  target-ppc: Add xscvqpudz and xscvqpuwz instructions
  softfloat: Add float128_to_uint32()
  target-s390: Use float128_to_uint[64/32] where required

 fpu/softfloat.c                     | 125 +++++++++++++++++++++++++++++++++++-
 include/fpu/softfloat.h             |   6 ++
 target/ppc/fpu_helper.c             |  44 ++++++-------
 target/ppc/helper.h                 |   2 +
 target/ppc/translate/vsx-impl.inc.c |   2 +
 target/ppc/translate/vsx-ops.inc.c  |   4 +-
 target/s390x/fpu_helper.c           |   6 +-
 7 files changed, 161 insertions(+), 28 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1/7] softfloat: Add round-to-odd rounding mode
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
@ 2017-02-10  7:23 ` Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 2/7] softfloat: Add float128_to_uint64_round_to_zero() Bharata B Rao
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao

Power ISA 3.0 introduces a few quadruple precision floating point
instructions that support round-to-odd rounding mode. The
round-to-odd mode is explained as under:

Let Z be the intermediate arithmetic result or the operand of a convert
operation. If Z can be represented exactly in the target format, the
result is Z. Otherwise the result is either Z1 or Z2 whichever is odd.
Here Z1 and Z2 are the next larger and smaller numbers representable
in the target format respectively.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
Posted ealier separately at:
https://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg01030.html

 fpu/softfloat.c         | 21 ++++++++++++++++++++-
 include/fpu/softfloat.h |  2 ++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index c295f31..5ccba76 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -623,6 +623,9 @@ static float64 roundAndPackFloat64(flag zSign, int zExp, uint64_t zSig,
     case float_round_down:
         roundIncrement = zSign ? 0x3ff : 0;
         break;
+    case float_round_to_odd:
+        roundIncrement = (zSig & 0x400) ? 0 : 0x3ff;
+        break;
     default:
         abort();
     }
@@ -632,8 +635,10 @@ static float64 roundAndPackFloat64(flag zSign, int zExp, uint64_t zSig,
              || (    ( zExp == 0x7FD )
                   && ( (int64_t) ( zSig + roundIncrement ) < 0 ) )
            ) {
+            bool overflow_to_inf = roundingMode != float_round_to_odd &&
+                                   roundIncrement != 0;
             float_raise(float_flag_overflow | float_flag_inexact, status);
-            return packFloat64( zSign, 0x7FF, - ( roundIncrement == 0 ));
+            return packFloat64(zSign, 0x7FF, -(!overflow_to_inf));
         }
         if ( zExp < 0 ) {
             if (status->flush_to_zero) {
@@ -651,6 +656,13 @@ static float64 roundAndPackFloat64(flag zSign, int zExp, uint64_t zSig,
             if (isTiny && roundBits) {
                 float_raise(float_flag_underflow, status);
             }
+            if (roundingMode == float_round_to_odd) {
+                /*
+                 * For round-to-odd case, the roundIncrement depends on
+                 * zSig which just changed.
+                 */
+                roundIncrement = (zSig & 0x400) ? 0 : 0x3ff;
+            }
         }
     }
     if (roundBits) {
@@ -1149,6 +1161,9 @@ static float128 roundAndPackFloat128(flag zSign, int32_t zExp,
     case float_round_down:
         increment = zSign && zSig2;
         break;
+    case float_round_to_odd:
+        increment = !(zSig1 & 0x1) && zSig2;
+        break;
     default:
         abort();
     }
@@ -1168,6 +1183,7 @@ static float128 roundAndPackFloat128(flag zSign, int32_t zExp,
             if (    ( roundingMode == float_round_to_zero )
                  || ( zSign && ( roundingMode == float_round_up ) )
                  || ( ! zSign && ( roundingMode == float_round_down ) )
+                 || (roundingMode == float_round_to_odd)
                ) {
                 return
                     packFloat128(
@@ -1215,6 +1231,9 @@ static float128 roundAndPackFloat128(flag zSign, int32_t zExp,
             case float_round_down:
                 increment = zSign && zSig2;
                 break;
+            case float_round_to_odd:
+                increment = !(zSig1 & 0x1) && zSig2;
+                break;
             default:
                 abort();
             }
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 842ec6b..8a39028 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -180,6 +180,8 @@ enum {
     float_round_up           = 2,
     float_round_to_zero      = 3,
     float_round_ties_away    = 4,
+    /* Not an IEEE rounding mode: round to the closest odd mantissa value */
+    float_round_to_odd       = 5,
 };
 
 /*----------------------------------------------------------------------------
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 2/7] softfloat: Add float128_to_uint64_round_to_zero()
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 1/7] softfloat: Add round-to-odd rounding mode Bharata B Rao
@ 2017-02-10  7:23 ` Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 3/7] softfloat: Add float128_to_uint32_round_to_zero() Bharata B Rao
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao

Implement float128_to_uint64() and use that to implement
float128_to_uint64_round_to_zero()

This is required by xscvqpudz instruction of PowerPC ISA 3.0.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
Ealier posted separately at:
https://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg01326.html

 fpu/softfloat.c         | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/fpu/softfloat.h |  2 ++
 2 files changed, 61 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 5ccba76..47e4646 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -6128,6 +6128,65 @@ int64_t float128_to_int64_round_to_zero(float128 a, float_status *status)
 }
 
 /*----------------------------------------------------------------------------
+| Returns the result of converting the quadruple-precision floating-point value
+| `a' to the 64-bit unsigned integer format.  The conversion is
+| performed according to the IEC/IEEE Standard for Binary Floating-Point
+| Arithmetic---which means in particular that the conversion is rounded
+| according to the current rounding mode.  If `a' is a NaN, the largest
+| positive integer is returned.  If the conversion overflows, the
+| largest unsigned integer is returned.  If 'a' is negative, the value is
+| rounded and zero is returned; negative values that do not round to zero
+| will raise the inexact exception.
+*----------------------------------------------------------------------------*/
+
+uint64_t float128_to_uint64(float128 a, float_status *status)
+{
+    flag aSign;
+    int aExp;
+    int shiftCount;
+    uint64_t aSig0, aSig1;
+
+    aSig0 = extractFloat128Frac0(a);
+    aSig1 = extractFloat128Frac1(a);
+    aExp = extractFloat128Exp(a);
+    aSign = extractFloat128Sign(a);
+    if (aSign && (aExp > 0x3FFE)) {
+        float_raise(float_flag_invalid, status);
+        if (float128_is_any_nan(a)) {
+            return LIT64(0xFFFFFFFFFFFFFFFF);
+        } else {
+            return 0;
+        }
+    }
+    if (aExp) {
+        aSig0 |= LIT64(0x0001000000000000);
+    }
+    shiftCount = 0x402F - aExp;
+    if (shiftCount <= 0) {
+        if (0x403E < aExp) {
+            float_raise(float_flag_invalid, status);
+            return LIT64(0xFFFFFFFFFFFFFFFF);
+        }
+        shortShift128Left(aSig0, aSig1, -shiftCount, &aSig0, &aSig1);
+    } else {
+        shift64ExtraRightJamming(aSig0, aSig1, shiftCount, &aSig0, &aSig1);
+    }
+    return roundAndPackUint64(aSign, aSig0, aSig1, status);
+}
+
+uint64_t float128_to_uint64_round_to_zero(float128 a, float_status *status)
+{
+    uint64_t v;
+    signed char current_rounding_mode = status->float_rounding_mode;
+
+    set_float_rounding_mode(float_round_to_zero, status);
+    v = float128_to_uint64(a, status);
+    set_float_rounding_mode(current_rounding_mode, status);
+
+    return v;
+}
+
+/*----------------------------------------------------------------------------
 | Returns the result of converting the quadruple-precision floating-point
 | value `a' to the single-precision floating-point format.  The conversion
 | is performed according to the IEC/IEEE Standard for Binary Floating-Point
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 8a39028..a09ad0e 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -714,6 +714,8 @@ int32_t float128_to_int32(float128, float_status *status);
 int32_t float128_to_int32_round_to_zero(float128, float_status *status);
 int64_t float128_to_int64(float128, float_status *status);
 int64_t float128_to_int64_round_to_zero(float128, float_status *status);
+uint64_t float128_to_uint64(float128, float_status *status);
+uint64_t float128_to_uint64_round_to_zero(float128, float_status *status);
 float32 float128_to_float32(float128, float_status *status);
 float64 float128_to_float64(float128, float_status *status);
 floatx80 float128_to_floatx80(float128, float_status *status);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 3/7] softfloat: Add float128_to_uint32_round_to_zero()
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 1/7] softfloat: Add round-to-odd rounding mode Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 2/7] softfloat: Add float128_to_uint64_round_to_zero() Bharata B Rao
@ 2017-02-10  7:23 ` Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 4/7] target-ppc: Implement round to odd variants of quad FP instructions Bharata B Rao
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao

float128_to_uint32_round_to_zero() is needed by xscvqpuwz instruction
of PowerPC ISA 3.0.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
Earlier posted separately at:
https://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg01326.html

 fpu/softfloat.c         | 28 ++++++++++++++++++++++++++++
 include/fpu/softfloat.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 47e4646..485a006 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -6188,6 +6188,34 @@ uint64_t float128_to_uint64_round_to_zero(float128 a, float_status *status)
 
 /*----------------------------------------------------------------------------
 | Returns the result of converting the quadruple-precision floating-point
+| value `a' to the 32-bit unsigned integer format.  The conversion
+| is performed according to the IEC/IEEE Standard for Binary Floating-Point
+| Arithmetic except that the conversion is always rounded toward zero.
+| If `a' is a NaN, the largest positive integer is returned.  Otherwise,
+| if the conversion overflows, the largest unsigned integer is returned.
+| If 'a' is negative, the value is rounded and zero is returned; negative
+| values that do not round to zero will raise the inexact exception.
+*----------------------------------------------------------------------------*/
+
+uint32_t float128_to_uint32_round_to_zero(float128 a, float_status *status)
+{
+    uint64_t v;
+    uint32_t res;
+    int old_exc_flags = get_float_exception_flags(status);
+
+    v = float128_to_uint64_round_to_zero(a, status);
+    if (v > 0xffffffff) {
+        res = 0xffffffff;
+    } else {
+        return v;
+    }
+    set_float_exception_flags(old_exc_flags, status);
+    float_raise(float_flag_invalid, status);
+    return res;
+}
+
+/*----------------------------------------------------------------------------
+| Returns the result of converting the quadruple-precision floating-point
 | value `a' to the single-precision floating-point format.  The conversion
 | is performed according to the IEC/IEEE Standard for Binary Floating-Point
 | Arithmetic.
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index a09ad0e..f1288ef 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -716,6 +716,7 @@ int64_t float128_to_int64(float128, float_status *status);
 int64_t float128_to_int64_round_to_zero(float128, float_status *status);
 uint64_t float128_to_uint64(float128, float_status *status);
 uint64_t float128_to_uint64_round_to_zero(float128, float_status *status);
+uint32_t float128_to_uint32_round_to_zero(float128, float_status *status);
 float32 float128_to_float32(float128, float_status *status);
 float64 float128_to_float64(float128, float_status *status);
 floatx80 float128_to_floatx80(float128, float_status *status);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 4/7] target-ppc: Implement round to odd variants of quad FP instructions
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
                   ` (2 preceding siblings ...)
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 3/7] softfloat: Add float128_to_uint32_round_to_zero() Bharata B Rao
@ 2017-02-10  7:23 ` Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 5/7] target-ppc: Add xscvqpudz and xscvqpuwz instructions Bharata B Rao
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao, Jose Ricardo Ziviani

xsaddqpo:  VSX Scalar Add Quad-Precision using round to Odd
xsmulqo:   VSX Scalar Multiply Quad-Precision using round to Odd
xsdivqpo:  VSX Scalar Divide Quad-Precision using round to Odd
xscvqpdpo: VSX Scalar round & Convert Quad-Precision format to
           Double-Precision format using round to Odd
xssqrtqpo: VSX Scalar Square Root Quad-Precision using round to Odd
xssubqpo:  VSX Scalar Subtract Quad-Precision using round to Odd

In addition, fix the invalid bitmask in the instruction encoding
of xssqrtqp[o].

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
CC: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
---
 target/ppc/fpu_helper.c            | 42 ++++++++++++++++++--------------------
 target/ppc/translate/vsx-ops.inc.c |  2 +-
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 1b6cd3b..96f9801 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -1850,12 +1850,11 @@ void helper_xsaddqp(CPUPPCState *env, uint32_t opcode)
     getVSR(rD(opcode) + 32, &xt, env);
     helper_reset_fpstatus(env);
 
+    tstat = env->fp_status;
     if (unlikely(Rc(opcode) != 0)) {
-        /* TODO: Support xsadddpo after round-to-odd is implemented */
-        abort();
+        tstat.float_rounding_mode = float_round_to_odd;
     }
 
-    tstat = env->fp_status;
     set_float_exception_flags(0, &tstat);
     xt.f128 = float128_add(xa.f128, xb.f128, &tstat);
     env->fp_status.float_exception_flags |= tstat.float_exception_flags;
@@ -1930,19 +1929,18 @@ VSX_MUL(xvmulsp, 4, float32, VsrW(i), 0, 0)
 void helper_xsmulqp(CPUPPCState *env, uint32_t opcode)
 {
     ppc_vsr_t xt, xa, xb;
+    float_status tstat;
 
     getVSR(rA(opcode) + 32, &xa, env);
     getVSR(rB(opcode) + 32, &xb, env);
     getVSR(rD(opcode) + 32, &xt, env);
 
+    helper_reset_fpstatus(env);
+    tstat = env->fp_status;
     if (unlikely(Rc(opcode) != 0)) {
-        /* TODO: Support xsmulpo after round-to-odd is implemented */
-        abort();
+        tstat.float_rounding_mode = float_round_to_odd;
     }
 
-    helper_reset_fpstatus(env);
-
-    float_status tstat = env->fp_status;
     set_float_exception_flags(0, &tstat);
     xt.f128 = float128_mul(xa.f128, xb.f128, &tstat);
     env->fp_status.float_exception_flags |= tstat.float_exception_flags;
@@ -2019,18 +2017,18 @@ VSX_DIV(xvdivsp, 4, float32, VsrW(i), 0, 0)
 void helper_xsdivqp(CPUPPCState *env, uint32_t opcode)
 {
     ppc_vsr_t xt, xa, xb;
+    float_status tstat;
 
     getVSR(rA(opcode) + 32, &xa, env);
     getVSR(rB(opcode) + 32, &xb, env);
     getVSR(rD(opcode) + 32, &xt, env);
 
+    helper_reset_fpstatus(env);
+    tstat = env->fp_status;
     if (unlikely(Rc(opcode) != 0)) {
-        /* TODO: Support xsdivqpo after round-to-odd is implemented */
-        abort();
+        tstat.float_rounding_mode = float_round_to_odd;
     }
 
-    helper_reset_fpstatus(env);
-    float_status tstat = env->fp_status;
     set_float_exception_flags(0, &tstat);
     xt.f128 = float128_div(xa.f128, xb.f128, &tstat);
     env->fp_status.float_exception_flags |= tstat.float_exception_flags;
@@ -2954,18 +2952,20 @@ VSX_CVT_FP_TO_FP_HP(xvcvhpsp, 4, float16, float32, VsrH(2 * i + 1), VsrW(i), 0)
 void helper_xscvqpdp(CPUPPCState *env, uint32_t opcode)
 {
     ppc_vsr_t xt, xb;
+    float_status tstat;
 
     getVSR(rB(opcode) + 32, &xb, env);
     memset(&xt, 0, sizeof(xt));
 
+    tstat = env->fp_status;
     if (unlikely(Rc(opcode) != 0)) {
-        /* TODO: Support xscvqpdpo after round-to-odd is implemented */
-        abort();
+        tstat.float_rounding_mode = float_round_to_odd;
     }
 
-    xt.VsrD(0) = float128_to_float64(xb.f128, &env->fp_status);
+    xt.VsrD(0) = float128_to_float64(xb.f128, &tstat);
+    env->fp_status.float_exception_flags |= tstat.float_exception_flags;
     if (unlikely(float128_is_signaling_nan(xb.f128,
-                                           &env->fp_status))) {
+                                           &tstat))) {
         float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0);
         xt.VsrD(0) = float64_snan_to_qnan(xt.VsrD(0));
     }
@@ -3496,12 +3496,11 @@ void helper_xssqrtqp(CPUPPCState *env, uint32_t opcode)
     memset(&xt, 0, sizeof(xt));
     helper_reset_fpstatus(env);
 
+    tstat = env->fp_status;
     if (unlikely(Rc(opcode) != 0)) {
-        /* TODO: Support xsadddpo after round-to-odd is implemented */
-        abort();
+        tstat.float_rounding_mode = float_round_to_odd;
     }
 
-    tstat = env->fp_status;
     set_float_exception_flags(0, &tstat);
     xt.f128 = float128_sqrt(xb.f128, &tstat);
     env->fp_status.float_exception_flags |= tstat.float_exception_flags;
@@ -3534,12 +3533,11 @@ void helper_xssubqp(CPUPPCState *env, uint32_t opcode)
     getVSR(rD(opcode) + 32, &xt, env);
     helper_reset_fpstatus(env);
 
+    tstat = env->fp_status;
     if (unlikely(Rc(opcode) != 0)) {
-        /* TODO: Support xssubqp after round-to-odd is implemented */
-        abort();
+        tstat.float_rounding_mode = float_round_to_odd;
     }
 
-    tstat = env->fp_status;
     set_float_exception_flags(0, &tstat);
     xt.f128 = float128_sub(xa.f128, xb.f128, &tstat);
     env->fp_status.float_exception_flags |= tstat.float_exception_flags;
diff --git a/target/ppc/translate/vsx-ops.inc.c b/target/ppc/translate/vsx-ops.inc.c
index c1b71ad..e20ca32 100644
--- a/target/ppc/translate/vsx-ops.inc.c
+++ b/target/ppc/translate/vsx-ops.inc.c
@@ -115,7 +115,7 @@ GEN_VSX_XFORM_300_EO(name, opc2, opc3 | 0x18, opc4 | 0x1, inval)
 
 GEN_VSX_Z23FORM_300(xsrqpi, 0x05, 0x0, 0x0, 0x0),
 GEN_VSX_Z23FORM_300(xsrqpxp, 0x05, 0x1, 0x0, 0x0),
-GEN_VSX_XFORM_300_EO(xssqrtqp, 0x04, 0x19, 0x1B, 0x00000001),
+GEN_VSX_XFORM_300_EO(xssqrtqp, 0x04, 0x19, 0x1B, 0x0),
 GEN_VSX_XFORM_300(xssubqp, 0x04, 0x10, 0x0),
 
 GEN_XX2FORM(xsabsdp, 0x12, 0x15, PPC2_VSX),
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 5/7] target-ppc: Add xscvqpudz and xscvqpuwz instructions
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
                   ` (3 preceding siblings ...)
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 4/7] target-ppc: Implement round to odd variants of quad FP instructions Bharata B Rao
@ 2017-02-10  7:23 ` Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 6/7] softfloat: Add float128_to_uint32() Bharata B Rao
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao

xscvqpudz: VSX Scalar truncate & Convert Quad-Precision format to
           Unsigned Doubleword format
xscvqpuwz: VSX Scalar truncate & Convert Quad-Precision format to
           Unsigned Word format

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 target/ppc/fpu_helper.c             | 2 ++
 target/ppc/helper.h                 | 2 ++
 target/ppc/translate/vsx-impl.inc.c | 2 ++
 target/ppc/translate/vsx-ops.inc.c  | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 96f9801..58aee64 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -3086,6 +3086,8 @@ VSX_CVT_FP_TO_INT_VECTOR(xscvqpsdz, float128, int64, f128, VsrD(0),          \
 
 VSX_CVT_FP_TO_INT_VECTOR(xscvqpswz, float128, int32, f128, VsrD(0),          \
                   0xffffffff80000000ULL)
+VSX_CVT_FP_TO_INT_VECTOR(xscvqpudz, float128, uint64, f128, VsrD(0), 0x0ULL)
+VSX_CVT_FP_TO_INT_VECTOR(xscvqpuwz, float128, uint32, f128, VsrD(0), 0x0ULL)
 
 /* VSX_CVT_INT_TO_FP - VSX integer to floating point conversion
  *   op    - instruction mnemonic
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 007a837..6d77661 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -442,6 +442,8 @@ DEF_HELPER_2(xscvdpspn, i64, env, i64)
 DEF_HELPER_2(xscvqpdp, void, env, i32)
 DEF_HELPER_2(xscvqpsdz, void, env, i32)
 DEF_HELPER_2(xscvqpswz, void, env, i32)
+DEF_HELPER_2(xscvqpudz, void, env, i32)
+DEF_HELPER_2(xscvqpuwz, void, env, i32)
 DEF_HELPER_2(xscvhpdp, void, env, i32)
 DEF_HELPER_2(xscvsdqp, void, env, i32)
 DEF_HELPER_2(xscvspdp, void, env, i32)
diff --git a/target/ppc/translate/vsx-impl.inc.c b/target/ppc/translate/vsx-impl.inc.c
index 8de8cd0..7f12908 100644
--- a/target/ppc/translate/vsx-impl.inc.c
+++ b/target/ppc/translate/vsx-impl.inc.c
@@ -819,6 +819,8 @@ GEN_VSX_HELPER_XT_XB_ENV(xscvdpspn, 0x16, 0x10, 0, PPC2_VSX207)
 GEN_VSX_HELPER_2(xscvqpdp, 0x04, 0x1A, 0x14, PPC2_ISA300)
 GEN_VSX_HELPER_2(xscvqpsdz, 0x04, 0x1A, 0x19, PPC2_ISA300)
 GEN_VSX_HELPER_2(xscvqpswz, 0x04, 0x1A, 0x09, PPC2_ISA300)
+GEN_VSX_HELPER_2(xscvqpudz, 0x04, 0x1A, 0x11, PPC2_ISA300)
+GEN_VSX_HELPER_2(xscvqpuwz, 0x04, 0x1A, 0x01, PPC2_ISA300)
 GEN_VSX_HELPER_2(xscvhpdp, 0x16, 0x15, 0x10, PPC2_ISA300)
 GEN_VSX_HELPER_2(xscvsdqp, 0x04, 0x1A, 0x0A, PPC2_ISA300)
 GEN_VSX_HELPER_2(xscvspdp, 0x12, 0x14, 0, PPC2_VSX)
diff --git a/target/ppc/translate/vsx-ops.inc.c b/target/ppc/translate/vsx-ops.inc.c
index e20ca32..5030c4a 100644
--- a/target/ppc/translate/vsx-ops.inc.c
+++ b/target/ppc/translate/vsx-ops.inc.c
@@ -131,6 +131,8 @@ GEN_VSX_XFORM_300_EO(xscvdpqp, 0x04, 0x1A, 0x16, 0x00000001),
 GEN_VSX_XFORM_300_EO(xscvqpdp, 0x04, 0x1A, 0x14, 0x0),
 GEN_VSX_XFORM_300_EO(xscvqpsdz, 0x04, 0x1A, 0x19, 0x00000001),
 GEN_VSX_XFORM_300_EO(xscvqpswz, 0x04, 0x1A, 0x09, 0x00000001),
+GEN_VSX_XFORM_300_EO(xscvqpudz, 0x04, 0x1A, 0x11, 0x00000001),
+GEN_VSX_XFORM_300_EO(xscvqpuwz, 0x04, 0x1A, 0x01, 0x00000001),
 
 #ifdef TARGET_PPC64
 GEN_XX2FORM_EO(xsxexpdp, 0x16, 0x15, 0x00, PPC2_ISA300),
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 6/7] softfloat: Add float128_to_uint32()
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
                   ` (4 preceding siblings ...)
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 5/7] target-ppc: Add xscvqpudz and xscvqpuwz instructions Bharata B Rao
@ 2017-02-10  7:23 ` Bharata B Rao
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 7/7] target-s390: Use float128_to_uint[64/32] where required Bharata B Rao
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao,
	Christian Borntraeger, Cornelia Huck

float128_to_uint32() is needed by target/s390.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
CC: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 fpu/softfloat.c         | 17 +++++++++++++++++
 include/fpu/softfloat.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 485a006..ef6f2d0 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -6186,6 +6186,23 @@ uint64_t float128_to_uint64_round_to_zero(float128 a, float_status *status)
     return v;
 }
 
+uint32_t float128_to_uint32(float128 a, float_status *status)
+{
+    uint64_t v;
+    uint32_t res;
+    int old_exc_flags = get_float_exception_flags(status);
+
+    v = float128_to_uint64(a, status);
+    if (v > 0xffffffff) {
+        res = 0xffffffff;
+    } else {
+        return v;
+    }
+    set_float_exception_flags(old_exc_flags, status);
+    float_raise(float_flag_invalid, status);
+    return res;
+}
+
 /*----------------------------------------------------------------------------
 | Returns the result of converting the quadruple-precision floating-point
 | value `a' to the 32-bit unsigned integer format.  The conversion
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index f1288ef..a57a027 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -716,6 +716,7 @@ int64_t float128_to_int64(float128, float_status *status);
 int64_t float128_to_int64_round_to_zero(float128, float_status *status);
 uint64_t float128_to_uint64(float128, float_status *status);
 uint64_t float128_to_uint64_round_to_zero(float128, float_status *status);
+uint32_t float128_to_uint32(float128, float_status *status);
 uint32_t float128_to_uint32_round_to_zero(float128, float_status *status);
 float32 float128_to_float32(float128, float_status *status);
 float64 float128_to_float64(float128, float_status *status);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 7/7] target-s390: Use float128_to_uint[64/32] where required
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
                   ` (5 preceding siblings ...)
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 6/7] softfloat: Add float128_to_uint32() Bharata B Rao
@ 2017-02-10  7:23 ` Bharata B Rao
  2017-02-13  1:40 ` [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes David Gibson
  2017-02-13  1:43 ` David Gibson
  8 siblings, 0 replies; 10+ messages in thread
From: Bharata B Rao @ 2017-02-10  7:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, david, rth, nikunj, Bharata B Rao,
	Christian Borntraeger, Cornelia Huck

Use float126_to_uint[64/32] instead of using int versions of the same.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
CC: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target/s390x/fpu_helper.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c
index e604e9f..9aa94d9 100644
--- a/target/s390x/fpu_helper.c
+++ b/target/s390x/fpu_helper.c
@@ -515,8 +515,7 @@ uint64_t HELPER(clgxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
 {
     int hold = swap_round_mode(env, m3);
     float128 v2 = make_float128(h, l);
-    /* ??? Not 100% correct.  */
-    uint64_t ret = float128_to_int64(v2, &env->fpu_status);
+    uint64_t ret = float128_to_uint64(v2, &env->fpu_status);
     set_float_rounding_mode(hold, &env->fpu_status);
     handle_exceptions(env, GETPC());
     return ret;
@@ -547,8 +546,7 @@ uint64_t HELPER(clfxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
 {
     int hold = swap_round_mode(env, m3);
     float128 v2 = make_float128(h, l);
-    /* Not 100% correct.  */
-    uint32_t ret = float128_to_int64(v2, &env->fpu_status);
+    uint32_t ret = float128_to_uint32(v2, &env->fpu_status);
     set_float_rounding_mode(hold, &env->fpu_status);
     handle_exceptions(env, GETPC());
     return ret;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
                   ` (6 preceding siblings ...)
  2017-02-10  7:23 ` [Qemu-devel] [PATCH 7/7] target-s390: Use float128_to_uint[64/32] where required Bharata B Rao
@ 2017-02-13  1:40 ` David Gibson
  2017-02-13  1:43 ` David Gibson
  8 siblings, 0 replies; 10+ messages in thread
From: David Gibson @ 2017-02-13  1:40 UTC (permalink / raw)
  To: Bharata B Rao; +Cc: qemu-devel, qemu-ppc, rth, nikunj

[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]

On Fri, Feb 10, 2017 at 12:53:04PM +0530, Bharata B Rao wrote:
1;4601;0c> This series contains 2 new instructions (xscvqpudz, xscvqpuwz) and
> round-to-odd variants of 6 instructions (xsaddqpo, xsmulqpo, xsdivqpo,
> xscvqpdpo, xssqrtqpo, xssubqpo)
>  
> This also includes softfloat enhancements that are needed by
> the above instructions. These softfloat patches have been posted
> separately earlier and reviewed. Including them here as the new
> instructions here depend on them.
> 
> I also saw that target-s390 also needs float128_to_uint64() and
> float128_to_uint32(). Implemented the latter in this series and
> made fixes in s390 code to use them. Note that s390 changes have
> been compile-tested only. The last two patches ideally needn't
> be part of this series, but included them here as s390 fixes
> depend on the softfloat changes that are part of this patchset.

I've applied 1-3 to ppc-for-2.9, still looking at the rest.

> 
> Bharata B Rao (7):
>   softfloat: Add round-to-odd rounding mode
>   softfloat: Add float128_to_uint64_round_to_zero()
>   softfloat: Add float128_to_uint32_round_to_zero()
>   target-ppc: Implement round to odd variants of quad FP instructions
>   target-ppc: Add xscvqpudz and xscvqpuwz instructions
>   softfloat: Add float128_to_uint32()
>   target-s390: Use float128_to_uint[64/32] where required
> 
>  fpu/softfloat.c                     | 125 +++++++++++++++++++++++++++++++++++-
>  include/fpu/softfloat.h             |   6 ++
>  target/ppc/fpu_helper.c             |  44 ++++++-------
>  target/ppc/helper.h                 |   2 +
>  target/ppc/translate/vsx-impl.inc.c |   2 +
>  target/ppc/translate/vsx-ops.inc.c  |   4 +-
>  target/s390x/fpu_helper.c           |   6 +-
>  7 files changed, 161 insertions(+), 28 deletions(-)
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes
  2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
                   ` (7 preceding siblings ...)
  2017-02-13  1:40 ` [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes David Gibson
@ 2017-02-13  1:43 ` David Gibson
  8 siblings, 0 replies; 10+ messages in thread
From: David Gibson @ 2017-02-13  1:43 UTC (permalink / raw)
  To: Bharata B Rao; +Cc: qemu-devel, qemu-ppc, rth, nikunj

[-- Attachment #1: Type: text/plain, Size: 2033 bytes --]

On Fri, Feb 10, 2017 at 12:53:04PM +0530, Bharata B Rao wrote:
> This series contains 2 new instructions (xscvqpudz, xscvqpuwz) and
> round-to-odd variants of 6 instructions (xsaddqpo, xsmulqpo, xsdivqpo,
> xscvqpdpo, xssqrtqpo, xssubqpo)
>  
> This also includes softfloat enhancements that are needed by
> the above instructions. These softfloat patches have been posted
> separately earlier and reviewed. Including them here as the new
> instructions here depend on them.
> 
> I also saw that target-s390 also needs float128_to_uint64() and
> float128_to_uint32(). Implemented the latter in this series and
> made fixes in s390 code to use them. Note that s390 changes have
> been compile-tested only. The last two patches ideally needn't
> be part of this series, but included them here as s390 fixes
> depend on the softfloat changes that are part of this patchset.

4 & 5 also applied to my tree.  6 & 7 I'll leave to go through the
s390 tree.

> 
> Bharata B Rao (7):
>   softfloat: Add round-to-odd rounding mode
>   softfloat: Add float128_to_uint64_round_to_zero()
>   softfloat: Add float128_to_uint32_round_to_zero()
>   target-ppc: Implement round to odd variants of quad FP instructions
>   target-ppc: Add xscvqpudz and xscvqpuwz instructions
>   softfloat: Add float128_to_uint32()
>   target-s390: Use float128_to_uint[64/32] where required
> 
>  fpu/softfloat.c                     | 125 +++++++++++++++++++++++++++++++++++-
>  include/fpu/softfloat.h             |   6 ++
>  target/ppc/fpu_helper.c             |  44 ++++++-------
>  target/ppc/helper.h                 |   2 +
>  target/ppc/translate/vsx-impl.inc.c |   2 +
>  target/ppc/translate/vsx-ops.inc.c  |   4 +-
>  target/s390x/fpu_helper.c           |   6 +-
>  7 files changed, 161 insertions(+), 28 deletions(-)
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-02-13  2:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10  7:23 [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes Bharata B Rao
2017-02-10  7:23 ` [Qemu-devel] [PATCH 1/7] softfloat: Add round-to-odd rounding mode Bharata B Rao
2017-02-10  7:23 ` [Qemu-devel] [PATCH 2/7] softfloat: Add float128_to_uint64_round_to_zero() Bharata B Rao
2017-02-10  7:23 ` [Qemu-devel] [PATCH 3/7] softfloat: Add float128_to_uint32_round_to_zero() Bharata B Rao
2017-02-10  7:23 ` [Qemu-devel] [PATCH 4/7] target-ppc: Implement round to odd variants of quad FP instructions Bharata B Rao
2017-02-10  7:23 ` [Qemu-devel] [PATCH 5/7] target-ppc: Add xscvqpudz and xscvqpuwz instructions Bharata B Rao
2017-02-10  7:23 ` [Qemu-devel] [PATCH 6/7] softfloat: Add float128_to_uint32() Bharata B Rao
2017-02-10  7:23 ` [Qemu-devel] [PATCH 7/7] target-s390: Use float128_to_uint[64/32] where required Bharata B Rao
2017-02-13  1:40 ` [Qemu-devel] [PATCH 0/7] POWER9 TCG and softfloat enablements - part16 + s390 float fixes David Gibson
2017-02-13  1:43 ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.