alpha: Fix soft-fp breakage

Commit 5c0508a318 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.
This commit is contained in:
Richard Henderson 2014-11-17 09:20:02 -08:00
parent 0781a7772a
commit 4886f34179
14 changed files with 95 additions and 62 deletions

View File

@ -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]

View 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 FP_DECL_RETURN(X) \
long X##l, X##h
#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 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)

View 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);
}

View 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)))

View 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;

View 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);
}

View 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);
}

View 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);
}

View 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;

View 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

View 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);
}

View 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);
}

View 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;

View 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);
}