alpha: Fix soft-fp breakage
authorRichard Henderson <rth@twiddle.net>
Mon, 17 Nov 2014 17:20:02 +0000 (09:20 -0800)
committerRichard Henderson <rth@twiddle.net>
Mon, 17 Nov 2014 17:20:02 +0000 (09:20 -0800)
Commit 5c0508a318af0a6c8be2a4cb2e3b76896218bf35 broke the Alpha
port, as the extra parenthesis got in the way of some token pasting
that we were doing in a redefined raw unpack macro.

Avoid this situation in the future by not attempting to redefine a
basic macro, but rather work from the outermost public interface.
The compiler does in fact see through the added indirection.

* sysdeps/alpha/soft-fp/local-soft-fp.h (_FP_UNPACK_RAW_2): Remove.
(_FP_PACK_RAW_2): Remove.
(AXP_DECL_RETURN_Q): Rename from FP_DECL_RETURN, use _FP_UNION_Q.
(AXP_RETURN_Q): Rename from FP_RETURN, use _FP_UNION_Q.
(AXP_UNPACK_RAW_Q, AXP_UNPACK_SEMIRAW_Q, AXP_UNPACK_Q): New.
(AXP_PACK_RAW_Q, AXP_PACK_SEMIRAW_Q, AXP_PACK_Q): New.
* sysdeps/alpha/soft-fp/ots_add.c (_OtsAddX): Update to match.
* sysdeps/alpha/soft-fp/ots_cmp.c (internal_equality): Likewise.
* sysdeps/alpha/soft-fp/ots_cmpe.c (internal_compare): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtqux.c (_OtsCvtQUX): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtqx.c (_OtsCvtQX): Likewise.
* sysdeps/alpha/soft-fp/ots_cvttx.c (_OtsConvertFloatTX): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtxq.c (_OtsCvtXQ): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtxt.c (_OtsConvertFloatXT): Likewise.
* sysdeps/alpha/soft-fp/ots_div.c (_OtsDivX): Likewise.
* sysdeps/alpha/soft-fp/ots_mul.c (_OtsMulX): Likewise.
* sysdeps/alpha/soft-fp/ots_nintxq.c (_OtsNintXQ): Likewise.
* sysdeps/alpha/soft-fp/ots_sub.c (_OtsSubX): Likewise.

14 files changed:
ChangeLog
sysdeps/alpha/soft-fp/local-soft-fp.h
sysdeps/alpha/soft-fp/ots_add.c
sysdeps/alpha/soft-fp/ots_cmp.c
sysdeps/alpha/soft-fp/ots_cmpe.c
sysdeps/alpha/soft-fp/ots_cvtqux.c
sysdeps/alpha/soft-fp/ots_cvtqx.c
sysdeps/alpha/soft-fp/ots_cvttx.c
sysdeps/alpha/soft-fp/ots_cvtxq.c
sysdeps/alpha/soft-fp/ots_cvtxt.c
sysdeps/alpha/soft-fp/ots_div.c
sysdeps/alpha/soft-fp/ots_mul.c
sysdeps/alpha/soft-fp/ots_nintxq.c
sysdeps/alpha/soft-fp/ots_sub.c

index ccdf3e78733c93936ec018170cefa7fe84640be0..17ec07b9d238bbda435b6afbd283ea1bc24acc32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+
+2014-11-17  Richard Henderson  <rth@redhat.com>
+
+       * sysdeps/alpha/soft-fp/local-soft-fp.h (_FP_UNPACK_RAW_2): Remove.
+       (_FP_PACK_RAW_2): Remove.
+       (AXP_DECL_RETURN_Q): Rename from FP_DECL_RETURN, use _FP_UNION_Q.
+       (AXP_RETURN_Q): Rename from FP_RETURN, use _FP_UNION_Q.
+       (AXP_UNPACK_RAW_Q, AXP_UNPACK_SEMIRAW_Q, AXP_UNPACK_Q): New.
+       (AXP_PACK_RAW_Q, AXP_PACK_SEMIRAW_Q, AXP_PACK_Q): New.
+       * sysdeps/alpha/soft-fp/ots_add.c (_OtsAddX): Update to match.
+       * sysdeps/alpha/soft-fp/ots_cmp.c (internal_equality): Likewise.
+       * sysdeps/alpha/soft-fp/ots_cmpe.c (internal_compare): Likewise.
+       * sysdeps/alpha/soft-fp/ots_cvtqux.c (_OtsCvtQUX): Likewise.
+       * sysdeps/alpha/soft-fp/ots_cvtqx.c (_OtsCvtQX): Likewise.
+       * sysdeps/alpha/soft-fp/ots_cvttx.c (_OtsConvertFloatTX): Likewise.
+       * sysdeps/alpha/soft-fp/ots_cvtxq.c (_OtsCvtXQ): Likewise.
+       * sysdeps/alpha/soft-fp/ots_cvtxt.c (_OtsConvertFloatXT): Likewise.
+       * sysdeps/alpha/soft-fp/ots_div.c (_OtsDivX): Likewise.
+       * sysdeps/alpha/soft-fp/ots_mul.c (_OtsMulX): Likewise.
+       * sysdeps/alpha/soft-fp/ots_nintxq.c (_OtsNintXQ): Likewise.
+       * sysdeps/alpha/soft-fp/ots_sub.c (_OtsSubX): Likewise.
+
 2014-11-14  Roland McGrath  <roland@hack.frob.com>
 
        * signal/signal.h [__USE_MISC]
index e93a2ad06493089ba4856d46671400b554d7c58a..d562e0829e19822ece92474068895f004394f9aa 100644 (file)
@@ -5,40 +5,51 @@
 /* Helpers for the Ots functions which receive long double arguments
    in two integer registers, and return values in $16+$17.  */
 
-#undef _FP_UNPACK_RAW_2
-#define _FP_UNPACK_RAW_2(fs, X, val)                    \
-  do {                                                  \
-    union _FP_UNION_##fs _flo;                         \
+#define AXP_UNPACK_RAW_Q(X, val)                       \
+  do {                                                 \
+    union _FP_UNION_Q _flo;                            \
     _flo.longs.a = val##l;                             \
     _flo.longs.b = val##h;                             \
-    X##_f0 = _flo.bits.frac0;                          \
-    X##_f1 = _flo.bits.frac1;                          \
-    X##_e  = _flo.bits.exp;                            \
-    X##_s  = _flo.bits.sign;                           \
+    FP_UNPACK_RAW_QP(X, &_flo);                                \
   } while (0)
 
-#undef _FP_PACK_RAW_2
-#define _FP_PACK_RAW_2(fs, val, X)                      \
-  do {                                                  \
-    union _FP_UNION_##fs _flo;                         \
-    _flo.bits.frac0 = X##_f0;                          \
-    _flo.bits.frac1 = X##_f1;                          \
-    _flo.bits.exp   = X##_e;                           \
-    _flo.bits.sign  = X##_s;                           \
-    val##l = _flo.longs.a;                             \
-    val##h = _flo.longs.b;                             \
+#define AXP_UNPACK_SEMIRAW_Q(X, val)                   \
+  do {                                                 \
+    union _FP_UNION_Q _flo;                            \
+    _flo.longs.a = val##l;                             \
+    _flo.longs.b = val##h;                             \
+    FP_UNPACK_SEMIRAW_QP(X, &_flo);                    \
+  } while (0)
+
+#define AXP_UNPACK_Q(X, val)                           \
+  do {                                                 \
+    AXP_UNPACK_RAW_Q(X, val);                          \
+    _FP_UNPACK_CANONICAL(Q, 2, X);                     \
+  } while (0)
+
+#define AXP_PACK_RAW_Q(val, X) FP_PACK_RAW_QP(&val##_flo, X)
+
+#define AXP_PACK_SEMIRAW_Q(val, X)                     \
+  do {                                                 \
+    _FP_PACK_SEMIRAW(Q, 2, X);                         \
+    AXP_PACK_RAW_Q(val, X);                            \
   } while (0)
 
-#define FP_DECL_RETURN(X) \
-  long X##l, X##h
+#define AXP_PACK_Q(val, X)                             \
+  do {                                                 \
+    _FP_PACK_CANONICAL(Q, 2, X);                       \
+    AXP_PACK_RAW_Q(val, X);                            \
+  } while (0)
+
+#define AXP_DECL_RETURN_Q(X) union _FP_UNION_Q X##_flo
 
 /* ??? We don't have a real way to tell the compiler that we're wanting
    to return values in $16+$17.  Instead use a volatile asm to make sure
    that the values are live, and just hope that nothing kills the values
    in between here and the end of the function.  */
-#define FP_RETURN(X)                           \
-do {                                           \
-  register long r16 __asm__("16") = X##l;      \
-  register long r17 __asm__("17") = X##h;      \
-  asm volatile ("" : : "r"(r16), "r"(r17));    \
-} while (0)
+#define AXP_RETURN_Q(X)                                        \
+  do {                                                 \
+    register long r16 __asm__("16") = X##_flo.longs.a; \
+    register long r17 __asm__("17") = X##_flo.longs.b; \
+    asm volatile ("" : : "r"(r16), "r"(r17));          \
+  } while (0)
index 9cd56553ea7ed0c098c700c12189cadec505035d..fc85747b4f3e9341a2c6d07006564e451d4b94ba 100644 (file)
@@ -25,14 +25,14 @@ _OtsAddX(long al, long ah, long bl, long bh, long _round)
 {
   FP_DECL_EX;
   FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
-  FP_DECL_RETURN(c);
+  AXP_DECL_RETURN_Q(c);
 
   FP_INIT_ROUNDMODE;
-  FP_UNPACK_SEMIRAW_Q(A, a);
-  FP_UNPACK_SEMIRAW_Q(B, b);
+  AXP_UNPACK_SEMIRAW_Q(A, a);
+  AXP_UNPACK_SEMIRAW_Q(B, b);
   FP_ADD_Q(C, A, B);
-  FP_PACK_SEMIRAW_Q(c, C);
+  AXP_PACK_SEMIRAW_Q(c, C);
   FP_HANDLE_EXCEPTIONS;
 
-  FP_RETURN(c);
+  AXP_RETURN_Q(c);
 }
index c28aa4f60843c0b9a68491e556dcfe577c7472bb..a441a92d3ba6d78a9701f8e1e7c8f46d633174c2 100644 (file)
@@ -27,8 +27,8 @@ internal_equality (long al, long ah, long bl, long bh, long neq)
   FP_DECL_Q(A); FP_DECL_Q(B);
   long r;
 
-  FP_UNPACK_RAW_Q(A, a);
-  FP_UNPACK_RAW_Q(B, b);
+  AXP_UNPACK_RAW_Q(A, a);
+  AXP_UNPACK_RAW_Q(B, b);
 
   if ((A_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2(A))
        || (B_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2(B)))
index 41586eee263494ee431d0066cdbbc3b7dd222f6e..97f9e7ea8172193df4961ba6ad5d88e8d1782d5b 100644 (file)
@@ -27,8 +27,8 @@ internal_compare (long al, long ah, long bl, long bh)
   FP_DECL_Q(A); FP_DECL_Q(B);
   long r;
 
-  FP_UNPACK_RAW_Q(A, a);
-  FP_UNPACK_RAW_Q(B, b);
+  AXP_UNPACK_RAW_Q(A, a);
+  AXP_UNPACK_RAW_Q(B, b);
   FP_CMP_Q (r, A, B, 2, 2);
 
   FP_HANDLE_EXCEPTIONS;
index 5562098381b7b607478f50f2ba8588ae31535227..677b0b1a6acf39a83a454c10f3b9c2845a09577e 100644 (file)
@@ -30,10 +30,10 @@ _OtsCvtQUX (unsigned long a)
 {
   FP_DECL_EX;
   FP_DECL_Q(C);
-  FP_DECL_RETURN(c);
+  AXP_DECL_RETURN_Q(c);
 
   FP_FROM_INT_Q(C, a, 64, unsigned long);
-  FP_PACK_RAW_Q(c, C);
+  AXP_PACK_RAW_Q(c, C);
 
-  FP_RETURN(c);
+  AXP_RETURN_Q(c);
 }
index f062a081ec3efe75fe89e01b116525d6a773d00c..ab81149910433e376a4b9c0ef26aa0b51d4fff9f 100644 (file)
@@ -30,9 +30,9 @@ _OtsCvtQX (long a)
 {
   FP_DECL_EX;
   FP_DECL_Q(C);
-  FP_DECL_RETURN(c);
+  AXP_DECL_RETURN_Q(c);
 
   FP_FROM_INT_Q(C, a, 64, unsigned long);
-  FP_PACK_RAW_Q(c, C);
-  FP_RETURN(c);
+  AXP_PACK_RAW_Q(c, C);
+  AXP_RETURN_Q(c);
 }
index a01cd950910a70a03ba754d9d6535ffecb7fc704..2376e8a3cf4cd1a11b573cfcdeee45aeba2ce3fd 100644 (file)
@@ -32,7 +32,7 @@ _OtsConvertFloatTX(double a)
   FP_DECL_EX;
   FP_DECL_D(A);
   FP_DECL_Q(C);
-  FP_DECL_RETURN(c);
+  AXP_DECL_RETURN_Q(c);
 
   FP_UNPACK_RAW_D(A, a);
 #if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
@@ -40,8 +40,8 @@ _OtsConvertFloatTX(double a)
 #else
   FP_EXTEND(Q,D,2,1,C,A);
 #endif
-  FP_PACK_RAW_Q(c, C);
+  AXP_PACK_RAW_Q(c, C);
   FP_HANDLE_EXCEPTIONS;
 
-  FP_RETURN(c);
+  AXP_RETURN_Q(c);
 }
index 2447a381ac9c0a77baab4da437f22c90be744844..9eb2a0dbfb2afd970c38f54a7826903fa96d5aa0 100644 (file)
@@ -33,7 +33,7 @@ _OtsCvtXQ (long al, long ah, long _round)
   _round = _round & 3;
 
   FP_INIT_ROUNDMODE;
-  FP_UNPACK_RAW_Q(A, a);
+  AXP_UNPACK_RAW_Q(A, a);
   FP_TO_INT_Q(r, A, 64, s);
   FP_HANDLE_EXCEPTIONS;
 
index 94e3f3193ed112061d46e4007febb4be6ea8824d..bfc8b7b05a7c0a211c637016c8ce202ad4bb0a07 100644 (file)
@@ -30,7 +30,7 @@ _OtsConvertFloatXT (long al, long ah, long _round)
   double r;
 
   FP_INIT_ROUNDMODE;
-  FP_UNPACK_SEMIRAW_Q(A, a);
+  AXP_UNPACK_SEMIRAW_Q(A, a);
 #if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
   FP_TRUNC(D,Q,2,4,R,A);
 #else
index 4d1c8543f50c5ea472d8dd9300fe6b86b5c3bbf6..c57cec92611064c97f4dc0f7b73797b0b0fa4735 100644 (file)
@@ -25,14 +25,14 @@ _OtsDivX(long al, long ah, long bl, long bh, long _round)
 {
   FP_DECL_EX;
   FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
-  FP_DECL_RETURN(c);
+  AXP_DECL_RETURN_Q(c);
 
   FP_INIT_ROUNDMODE;
-  FP_UNPACK_Q(A, a);
-  FP_UNPACK_Q(B, b);
+  AXP_UNPACK_Q(A, a);
+  AXP_UNPACK_Q(B, b);
   FP_DIV_Q(C, A, B);
-  FP_PACK_Q(c, C);
+  AXP_PACK_Q(c, C);
   FP_HANDLE_EXCEPTIONS;
 
-  FP_RETURN(c);
+  AXP_RETURN_Q(c);
 }
index 39fe8234dbef165ecd4be549ca28d2861e2e74c4..5ae1e68cacf77c81b2a98642cb31f7a3506f4139 100644 (file)
@@ -25,14 +25,14 @@ _OtsMulX(long al, long ah, long bl, long bh, long _round)
 {
   FP_DECL_EX;
   FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
-  FP_DECL_RETURN(c);
+  AXP_DECL_RETURN_Q(c);
 
   FP_INIT_ROUNDMODE;
-  FP_UNPACK_Q(A, a);
-  FP_UNPACK_Q(B, b);
+  AXP_UNPACK_Q(A, a);
+  AXP_UNPACK_Q(B, b);
   FP_MUL_Q(C, A, B);
-  FP_PACK_Q(c, C);
+  AXP_PACK_Q(c, C);
   FP_HANDLE_EXCEPTIONS;
 
-  FP_RETURN(c);
+  AXP_RETURN_Q(c);
 }
index cfdf38649d861353d011ef61d71f7f5182c73f5d..6bfedcae3be9ffa10c2b7a3843f519e7025d7108 100644 (file)
@@ -33,7 +33,7 @@ _OtsNintXQ (long al, long ah, long _round)
   _round = _round & 3;
 
   FP_INIT_ROUNDMODE;
-  FP_UNPACK_SEMIRAW_Q(A, a);
+  AXP_UNPACK_SEMIRAW_Q(A, a);
 
   /* Build 0.5 * sign(A) */
   B_e = _FP_EXPBIAS_Q;
index 6deb9d9425e38d95a3dfdb48fa4443ce9d653f78..41938cfcc0238908a6773842225556c67adcd82d 100644 (file)
@@ -25,14 +25,14 @@ _OtsSubX(long al, long ah, long bl, long bh, long _round)
 {
   FP_DECL_EX;
   FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
-  FP_DECL_RETURN(c);
+  AXP_DECL_RETURN_Q(c);
 
   FP_INIT_ROUNDMODE;
-  FP_UNPACK_SEMIRAW_Q(A, a);
-  FP_UNPACK_SEMIRAW_Q(B, b);
+  AXP_UNPACK_SEMIRAW_Q(A, a);
+  AXP_UNPACK_SEMIRAW_Q(B, b);
   FP_SUB_Q(C, A, B);
-  FP_PACK_SEMIRAW_Q(c, C);
+  AXP_PACK_SEMIRAW_Q(c, C);
   FP_HANDLE_EXCEPTIONS;
 
-  FP_RETURN(c);
+  AXP_RETURN_Q(c);
 }