In <https://sourceware.org/ml/libc-alpha/2013-06/msg00851.html>, I
fixed a bug caused by multiple soft-fp macros using the same variable
names, resulting in shadowing when one macro called another that used
the same variable name, with an argument involving the variable in the
outer macro. The fix was to rename the local variables so their names
included the containing macro name, to ensure uniqueness.
I noted then that this would make sense more systematically for all
variables in any soft-fp macro. Since then, I've used such variable
names in new soft-fp macros. This patch now converts existing macros
in extended.h and op-common.h to use this convention. (op-[1248].h
are intended to be converted separately.)
(Name conflicts could arise for label names as well, but because those
are function-scope in C any such conflict will give an immediate
compile error rather than a subtle bug, so there's no need for
preemptive renaming in that case.)
Tested for powerpc32 (soft-float) and mips64 that this makes no change
to the disassembly of installed shared libraries.
* soft-fp/extended.h (FP_UNPACK_RAW_E): Rename local variables to
include macro name.
(FP_UNPACK_RAW_EP): Likewise.
(FP_PACK_RAW_E): Likewise.
(FP_PACK_RAW_EP): Likewise.
* soft-fp/op-common.h (_FP_UNPACK_CANONICAL): Likewise.
(_FP_ISSIGNAN): Likewise.
(_FP_ADD_INTERNAL): Likewise.
(_FP_FMA): Likewise.
(_FP_CMP): Likewise.
(_FP_SQRT): Likewise.
(_FP_TO_INT): Likewise.
(_FP_FROM_INT): Likewise.
(FP_EXTEND): Likewise.
(_FP_DIV_MEAT_N_loop): Likewise.
+2014-06-30 Joseph Myers <joseph@codesourcery.com>
+
+ * soft-fp/extended.h (FP_UNPACK_RAW_E): Rename local variables to
+ include macro name.
+ (FP_UNPACK_RAW_EP): Likewise.
+ (FP_PACK_RAW_E): Likewise.
+ (FP_PACK_RAW_EP): Likewise.
+ * soft-fp/op-common.h (_FP_UNPACK_CANONICAL): Likewise.
+ (_FP_ISSIGNAN): Likewise.
+ (_FP_ADD_INTERNAL): Likewise.
+ (_FP_FMA): Likewise.
+ (_FP_CMP): Likewise.
+ (_FP_SQRT): Likewise.
+ (_FP_TO_INT): Likewise.
+ (_FP_FROM_INT): Likewise.
+ (FP_EXTEND): Likewise.
+ (_FP_DIV_MEAT_N_loop): Likewise.
+
2014-06-30 Maciej W. Rozycki <macro@codesourcery.com>
* sysdeps/unix/sysv/linux/bits/socket.h: Adjust macro formatting
2014-06-30 Maciej W. Rozycki <macro@codesourcery.com>
* sysdeps/unix/sysv/linux/bits/socket.h: Adjust macro formatting
# define FP_DECL_E(X) _FP_DECL (4, X)
# define FP_DECL_E(X) _FP_DECL (4, X)
-# define FP_UNPACK_RAW_E(X, val) \
- do \
- { \
- union _FP_UNION_E _flo; \
- _flo.flt = (val); \
- \
- X##_f[2] = 0; \
- X##_f[3] = 0; \
- X##_f[0] = _flo.bits.frac0; \
- X##_f[1] = _flo.bits.frac1; \
- X##_e = _flo.bits.exp; \
- X##_s = _flo.bits.sign; \
- } \
+# define FP_UNPACK_RAW_E(X, val) \
+ do \
+ { \
+ union _FP_UNION_E FP_UNPACK_RAW_E_flo; \
+ FP_UNPACK_RAW_E_flo.flt = (val); \
+ \
+ X##_f[2] = 0; \
+ X##_f[3] = 0; \
+ X##_f[0] = FP_UNPACK_RAW_E_flo.bits.frac0; \
+ X##_f[1] = FP_UNPACK_RAW_E_flo.bits.frac1; \
+ X##_e = FP_UNPACK_RAW_E_flo.bits.exp; \
+ X##_s = FP_UNPACK_RAW_E_flo.bits.sign; \
+ } \
-# define FP_UNPACK_RAW_EP(X, val) \
- do \
- { \
- union _FP_UNION_E *_flo = (union _FP_UNION_E *) (val); \
- \
- X##_f[2] = 0; \
- X##_f[3] = 0; \
- X##_f[0] = _flo->bits.frac0; \
- X##_f[1] = _flo->bits.frac1; \
- X##_e = _flo->bits.exp; \
- X##_s = _flo->bits.sign; \
- } \
+# define FP_UNPACK_RAW_EP(X, val) \
+ do \
+ { \
+ union _FP_UNION_E *FP_UNPACK_RAW_EP_flo \
+ = (union _FP_UNION_E *) (val); \
+ \
+ X##_f[2] = 0; \
+ X##_f[3] = 0; \
+ X##_f[0] = FP_UNPACK_RAW_EP_flo->bits.frac0; \
+ X##_f[1] = FP_UNPACK_RAW_EP_flo->bits.frac1; \
+ X##_e = FP_UNPACK_RAW_EP_flo->bits.exp; \
+ X##_s = FP_UNPACK_RAW_EP_flo->bits.sign; \
+ } \
while (0)
# define FP_PACK_RAW_E(val, X) \
do \
{ \
while (0)
# define FP_PACK_RAW_E(val, X) \
do \
{ \
- union _FP_UNION_E _flo; \
+ union _FP_UNION_E FP_PACK_RAW_E_flo; \
\
if (X##_e) \
X##_f[1] |= _FP_IMPLBIT_E; \
else \
X##_f[1] &= ~(_FP_IMPLBIT_E); \
\
if (X##_e) \
X##_f[1] |= _FP_IMPLBIT_E; \
else \
X##_f[1] &= ~(_FP_IMPLBIT_E); \
- _flo.bits.frac0 = X##_f[0]; \
- _flo.bits.frac1 = X##_f[1]; \
- _flo.bits.exp = X##_e; \
- _flo.bits.sign = X##_s; \
+ FP_PACK_RAW_E_flo.bits.frac0 = X##_f[0]; \
+ FP_PACK_RAW_E_flo.bits.frac1 = X##_f[1]; \
+ FP_PACK_RAW_E_flo.bits.exp = X##_e; \
+ FP_PACK_RAW_E_flo.bits.sign = X##_s; \
+ (val) = FP_PACK_RAW_E_flo.flt; \
-# define FP_PACK_RAW_EP(val, X) \
- do \
- { \
- if (!FP_INHIBIT_RESULTS) \
- { \
- union _FP_UNION_E *_flo = (union _FP_UNION_E *) (val); \
- \
- if (X##_e) \
- X##_f[1] |= _FP_IMPLBIT_E; \
- else \
- X##_f[1] &= ~(_FP_IMPLBIT_E); \
- _flo->bits.frac0 = X##_f[0]; \
- _flo->bits.frac1 = X##_f[1]; \
- _flo->bits.exp = X##_e; \
- _flo->bits.sign = X##_s; \
- } \
- } \
+# define FP_PACK_RAW_EP(val, X) \
+ do \
+ { \
+ if (!FP_INHIBIT_RESULTS) \
+ { \
+ union _FP_UNION_E *FP_PACK_RAW_EP_flo \
+ = (union _FP_UNION_E *) (val); \
+ \
+ if (X##_e) \
+ X##_f[1] |= _FP_IMPLBIT_E; \
+ else \
+ X##_f[1] &= ~(_FP_IMPLBIT_E); \
+ FP_PACK_RAW_EP_flo->bits.frac0 = X##_f[0]; \
+ FP_PACK_RAW_EP_flo->bits.frac1 = X##_f[1]; \
+ FP_PACK_RAW_EP_flo->bits.exp = X##_e; \
+ FP_PACK_RAW_EP_flo->bits.sign = X##_s; \
+ } \
+ } \
while (0)
# define FP_UNPACK_E(X, val) \
while (0)
# define FP_UNPACK_E(X, val) \
# define FP_UNPACK_RAW_E(X, val) \
do \
{ \
# define FP_UNPACK_RAW_E(X, val) \
do \
{ \
- union _FP_UNION_E _flo; \
- _flo.flt = (val); \
+ union _FP_UNION_E FP_UNPACK_RAW_E_flo; \
+ FP_UNPACK_RAW_E_flo.flt = (val); \
- X##_f0 = _flo.bits.frac; \
+ X##_f0 = FP_UNPACK_RAW_E_flo.bits.frac; \
- X##_e = _flo.bits.exp; \
- X##_s = _flo.bits.sign; \
+ X##_e = FP_UNPACK_RAW_E_flo.bits.exp; \
+ X##_s = FP_UNPACK_RAW_E_flo.bits.sign; \
-# define FP_UNPACK_RAW_EP(X, val) \
- do \
- { \
- union _FP_UNION_E *_flo = (union _FP_UNION_E *) (val); \
- \
- X##_f0 = _flo->bits.frac; \
- X##_f1 = 0; \
- X##_e = _flo->bits.exp; \
- X##_s = _flo->bits.sign; \
- } \
+# define FP_UNPACK_RAW_EP(X, val) \
+ do \
+ { \
+ union _FP_UNION_E *FP_UNPACK_RAW_EP_flo \
+ = (union _FP_UNION_E *) (val); \
+ \
+ X##_f0 = FP_UNPACK_RAW_EP_flo->bits.frac; \
+ X##_f1 = 0; \
+ X##_e = FP_UNPACK_RAW_EP_flo->bits.exp; \
+ X##_s = FP_UNPACK_RAW_EP_flo->bits.sign; \
+ } \
while (0)
# define FP_PACK_RAW_E(val, X) \
do \
{ \
while (0)
# define FP_PACK_RAW_E(val, X) \
do \
{ \
- union _FP_UNION_E _flo; \
+ union _FP_UNION_E FP_PACK_RAW_E_flo; \
\
if (X##_e) \
X##_f0 |= _FP_IMPLBIT_E; \
else \
X##_f0 &= ~(_FP_IMPLBIT_E); \
\
if (X##_e) \
X##_f0 |= _FP_IMPLBIT_E; \
else \
X##_f0 &= ~(_FP_IMPLBIT_E); \
- _flo.bits.frac = X##_f0; \
- _flo.bits.exp = X##_e; \
- _flo.bits.sign = X##_s; \
+ FP_PACK_RAW_E_flo.bits.frac = X##_f0; \
+ FP_PACK_RAW_E_flo.bits.exp = X##_e; \
+ FP_PACK_RAW_E_flo.bits.sign = X##_s; \
+ (val) = FP_PACK_RAW_E_flo.flt; \
-# define FP_PACK_RAW_EP(fs, val, X) \
- do \
- { \
- if (!FP_INHIBIT_RESULTS) \
- { \
- union _FP_UNION_E *_flo = (union _FP_UNION_E *) (val); \
- \
- if (X##_e) \
- X##_f0 |= _FP_IMPLBIT_E; \
- else \
- X##_f0 &= ~(_FP_IMPLBIT_E); \
- _flo->bits.frac = X##_f0; \
- _flo->bits.exp = X##_e; \
- _flo->bits.sign = X##_s; \
- } \
- } \
+# define FP_PACK_RAW_EP(fs, val, X) \
+ do \
+ { \
+ if (!FP_INHIBIT_RESULTS) \
+ { \
+ union _FP_UNION_E *FP_PACK_RAW_EP_flo \
+ = (union _FP_UNION_E *) (val); \
+ \
+ if (X##_e) \
+ X##_f0 |= _FP_IMPLBIT_E; \
+ else \
+ X##_f0 &= ~(_FP_IMPLBIT_E); \
+ FP_PACK_RAW_EP_flo->bits.frac = X##_f0; \
+ FP_PACK_RAW_EP_flo->bits.exp = X##_e; \
+ FP_PACK_RAW_EP_flo->bits.sign = X##_s; \
+ } \
+ } \
else \
{ \
/* a denormalized number */ \
else \
{ \
/* a denormalized number */ \
- _FP_I_TYPE _shift; \
- _FP_FRAC_CLZ_##wc (_shift, X); \
- _shift -= _FP_FRACXBITS_##fs; \
- _FP_FRAC_SLL_##wc (X, (_shift+_FP_WORKBITS)); \
- X##_e -= _FP_EXPBIAS_##fs - 1 + _shift; \
+ _FP_I_TYPE _FP_UNPACK_CANONICAL_shift; \
+ _FP_FRAC_CLZ_##wc (_FP_UNPACK_CANONICAL_shift, \
+ X); \
+ _FP_UNPACK_CANONICAL_shift -= _FP_FRACXBITS_##fs; \
+ _FP_FRAC_SLL_##wc (X, (_FP_UNPACK_CANONICAL_shift \
+ + _FP_WORKBITS)); \
+ X##_e -= (_FP_EXPBIAS_##fs - 1 \
+ + _FP_UNPACK_CANONICAL_shift); \
X##_c = FP_CLS_NORMAL; \
FP_SET_EXCEPTION (FP_EX_DENORM); \
} \
X##_c = FP_CLS_NORMAL; \
FP_SET_EXCEPTION (FP_EX_DENORM); \
} \
*/
#define _FP_ISSIGNAN(fs, wc, X) \
({ \
*/
#define _FP_ISSIGNAN(fs, wc, X) \
({ \
+ int _FP_ISSIGNAN_ret = 0; \
if (X##_e == _FP_EXPMAX_##fs) \
{ \
if (!_FP_FRAC_ZEROP_##wc (X) \
&& _FP_FRAC_SNANP (fs, X)) \
if (X##_e == _FP_EXPMAX_##fs) \
{ \
if (!_FP_FRAC_ZEROP_##wc (X) \
&& _FP_FRAC_SNANP (fs, X)) \
+ _FP_ISSIGNAN_ret = 1; \
{ \
/* Addition. */ \
R##_s = X##_s; \
{ \
/* Addition. */ \
R##_s = X##_s; \
- int ediff = X##_e - Y##_e; \
- if (ediff > 0) \
+ int _FP_ADD_INTERNAL_ediff = X##_e - Y##_e; \
+ if (_FP_ADD_INTERNAL_ediff > 0) \
{ \
R##_e = X##_e; \
if (Y##_e == 0) \
{ \
R##_e = X##_e; \
if (Y##_e == 0) \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
- ediff--; \
- if (ediff == 0) \
+ _FP_ADD_INTERNAL_ediff--; \
+ if (_FP_ADD_INTERNAL_ediff == 0) \
{ \
_FP_FRAC_ADD_##wc (R, X, Y); \
goto add3; \
{ \
_FP_FRAC_ADD_##wc (R, X, Y); \
goto add3; \
_FP_FRAC_HIGH_##fs (Y) |= _FP_IMPLBIT_SH_##fs; \
\
add1: \
_FP_FRAC_HIGH_##fs (Y) |= _FP_IMPLBIT_SH_##fs; \
\
add1: \
- /* Shift the mantissa of Y to the right EDIFF steps; \
- remember to account later for the implicit MSB of X. */ \
- if (ediff <= _FP_WFRACBITS_##fs) \
- _FP_FRAC_SRS_##wc (Y, ediff, _FP_WFRACBITS_##fs); \
+ /* Shift the mantissa of Y to the right \
+ _FP_ADD_INTERNAL_EDIFF steps; remember to account \
+ later for the implicit MSB of X. */ \
+ if (_FP_ADD_INTERNAL_ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc (Y, _FP_ADD_INTERNAL_ediff, \
+ _FP_WFRACBITS_##fs); \
else if (!_FP_FRAC_ZEROP_##wc (Y)) \
_FP_FRAC_SET_##wc (Y, _FP_MINFRAC_##wc); \
_FP_FRAC_ADD_##wc (R, X, Y); \
} \
else if (!_FP_FRAC_ZEROP_##wc (Y)) \
_FP_FRAC_SET_##wc (Y, _FP_MINFRAC_##wc); \
_FP_FRAC_ADD_##wc (R, X, Y); \
} \
+ else if (_FP_ADD_INTERNAL_ediff < 0) \
+ _FP_ADD_INTERNAL_ediff = -_FP_ADD_INTERNAL_ediff; \
R##_e = Y##_e; \
if (X##_e == 0) \
{ \
R##_e = Y##_e; \
if (X##_e == 0) \
{ \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
- ediff--; \
- if (ediff == 0) \
+ _FP_ADD_INTERNAL_ediff--; \
+ if (_FP_ADD_INTERNAL_ediff == 0) \
{ \
_FP_FRAC_ADD_##wc (R, Y, X); \
goto add3; \
{ \
_FP_FRAC_ADD_##wc (R, Y, X); \
goto add3; \
_FP_FRAC_HIGH_##fs (X) |= _FP_IMPLBIT_SH_##fs; \
\
add2: \
_FP_FRAC_HIGH_##fs (X) |= _FP_IMPLBIT_SH_##fs; \
\
add2: \
- /* Shift the mantissa of X to the right EDIFF steps; \
- remember to account later for the implicit MSB of Y. */ \
- if (ediff <= _FP_WFRACBITS_##fs) \
- _FP_FRAC_SRS_##wc (X, ediff, _FP_WFRACBITS_##fs); \
+ /* Shift the mantissa of X to the right \
+ _FP_ADD_INTERNAL_EDIFF steps; remember to account \
+ later for the implicit MSB of Y. */ \
+ if (_FP_ADD_INTERNAL_ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc (X, _FP_ADD_INTERNAL_ediff, \
+ _FP_WFRACBITS_##fs); \
else if (!_FP_FRAC_ZEROP_##wc (X)) \
_FP_FRAC_SET_##wc (X, _FP_MINFRAC_##wc); \
_FP_FRAC_ADD_##wc (R, Y, X); \
} \
else \
{ \
else if (!_FP_FRAC_ZEROP_##wc (X)) \
_FP_FRAC_SET_##wc (X, _FP_MINFRAC_##wc); \
_FP_FRAC_ADD_##wc (R, Y, X); \
} \
else \
{ \
+ /* _FP_ADD_INTERNAL_ediff == 0. */ \
if (!_FP_EXP_NORMAL (fs, wc, X)) \
{ \
if (X##_e == 0) \
if (!_FP_EXP_NORMAL (fs, wc, X)) \
{ \
if (X##_e == 0) \
else \
{ \
/* Subtraction. */ \
else \
{ \
/* Subtraction. */ \
- int ediff = X##_e - Y##_e; \
- if (ediff > 0) \
+ int _FP_ADD_INTERNAL_ediff = X##_e - Y##_e; \
+ if (_FP_ADD_INTERNAL_ediff > 0) \
{ \
R##_e = X##_e; \
R##_s = X##_s; \
{ \
R##_e = X##_e; \
R##_s = X##_s; \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
- ediff--; \
- if (ediff == 0) \
+ _FP_ADD_INTERNAL_ediff--; \
+ if (_FP_ADD_INTERNAL_ediff == 0) \
{ \
_FP_FRAC_SUB_##wc (R, X, Y); \
goto sub3; \
{ \
_FP_FRAC_SUB_##wc (R, X, Y); \
goto sub3; \
_FP_FRAC_HIGH_##fs (Y) |= _FP_IMPLBIT_SH_##fs; \
\
sub1: \
_FP_FRAC_HIGH_##fs (Y) |= _FP_IMPLBIT_SH_##fs; \
\
sub1: \
- /* Shift the mantissa of Y to the right EDIFF steps; \
- remember to account later for the implicit MSB of X. */ \
- if (ediff <= _FP_WFRACBITS_##fs) \
- _FP_FRAC_SRS_##wc (Y, ediff, _FP_WFRACBITS_##fs); \
+ /* Shift the mantissa of Y to the right \
+ _FP_ADD_INTERNAL_EDIFF steps; remember to account \
+ later for the implicit MSB of X. */ \
+ if (_FP_ADD_INTERNAL_ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc (Y, _FP_ADD_INTERNAL_ediff, \
+ _FP_WFRACBITS_##fs); \
else if (!_FP_FRAC_ZEROP_##wc (Y)) \
_FP_FRAC_SET_##wc (Y, _FP_MINFRAC_##wc); \
_FP_FRAC_SUB_##wc (R, X, Y); \
} \
else if (!_FP_FRAC_ZEROP_##wc (Y)) \
_FP_FRAC_SET_##wc (Y, _FP_MINFRAC_##wc); \
_FP_FRAC_SUB_##wc (R, X, Y); \
} \
+ else if (_FP_ADD_INTERNAL_ediff < 0) \
+ _FP_ADD_INTERNAL_ediff = -_FP_ADD_INTERNAL_ediff; \
R##_e = Y##_e; \
R##_s = Y##_s; \
if (X##_e == 0) \
R##_e = Y##_e; \
R##_s = Y##_s; \
if (X##_e == 0) \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
else \
{ \
FP_SET_EXCEPTION (FP_EX_DENORM); \
- ediff--; \
- if (ediff == 0) \
+ _FP_ADD_INTERNAL_ediff--; \
+ if (_FP_ADD_INTERNAL_ediff == 0) \
{ \
_FP_FRAC_SUB_##wc (R, Y, X); \
goto sub3; \
{ \
_FP_FRAC_SUB_##wc (R, Y, X); \
goto sub3; \
_FP_FRAC_HIGH_##fs (X) |= _FP_IMPLBIT_SH_##fs; \
\
sub2: \
_FP_FRAC_HIGH_##fs (X) |= _FP_IMPLBIT_SH_##fs; \
\
sub2: \
- /* Shift the mantissa of X to the right EDIFF steps; \
- remember to account later for the implicit MSB of Y. */ \
- if (ediff <= _FP_WFRACBITS_##fs) \
- _FP_FRAC_SRS_##wc (X, ediff, _FP_WFRACBITS_##fs); \
+ /* Shift the mantissa of X to the right \
+ _FP_ADD_INTERNAL_EDIFF steps; remember to account \
+ later for the implicit MSB of Y. */ \
+ if (_FP_ADD_INTERNAL_ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc (X, _FP_ADD_INTERNAL_ediff, \
+ _FP_WFRACBITS_##fs); \
else if (!_FP_FRAC_ZEROP_##wc (X)) \
_FP_FRAC_SET_##wc (X, _FP_MINFRAC_##wc); \
_FP_FRAC_SUB_##wc (R, Y, X); \
else if (!_FP_FRAC_ZEROP_##wc (X)) \
_FP_FRAC_SET_##wc (X, _FP_MINFRAC_##wc); \
_FP_FRAC_SUB_##wc (R, Y, X); \
sub3: \
if (_FP_FRAC_HIGH_##fs (R) & _FP_IMPLBIT_SH_##fs) \
{ \
sub3: \
if (_FP_FRAC_HIGH_##fs (R) & _FP_IMPLBIT_SH_##fs) \
{ \
+ int _FP_ADD_INTERNAL_diff; \
/* Carry into most significant bit of larger one of X and Y, \
canceling it; renormalize. */ \
_FP_FRAC_HIGH_##fs (R) &= _FP_IMPLBIT_SH_##fs - 1; \
norm: \
/* Carry into most significant bit of larger one of X and Y, \
canceling it; renormalize. */ \
_FP_FRAC_HIGH_##fs (R) &= _FP_IMPLBIT_SH_##fs - 1; \
norm: \
- _FP_FRAC_CLZ_##wc (diff, R); \
- diff -= _FP_WFRACXBITS_##fs; \
- _FP_FRAC_SLL_##wc (R, diff); \
- if (R##_e <= diff) \
+ _FP_FRAC_CLZ_##wc (_FP_ADD_INTERNAL_diff, R); \
+ _FP_ADD_INTERNAL_diff -= _FP_WFRACXBITS_##fs; \
+ _FP_FRAC_SLL_##wc (R, _FP_ADD_INTERNAL_diff); \
+ if (R##_e <= _FP_ADD_INTERNAL_diff) \
{ \
/* R is denormalized. */ \
{ \
/* R is denormalized. */ \
- diff = diff - R##_e + 1; \
- _FP_FRAC_SRS_##wc (R, diff, _FP_WFRACBITS_##fs); \
+ _FP_ADD_INTERNAL_diff \
+ = _FP_ADD_INTERNAL_diff - R##_e + 1; \
+ _FP_FRAC_SRS_##wc (R, _FP_ADD_INTERNAL_diff, \
+ _FP_WFRACBITS_##fs); \
R##_e = 0; \
} \
else \
{ \
R##_e = 0; \
} \
else \
{ \
+ R##_e -= _FP_ADD_INTERNAL_diff; \
_FP_FRAC_HIGH_##fs (R) &= ~(_FP_W_TYPE) _FP_IMPLBIT_SH_##fs; \
} \
} \
_FP_FRAC_HIGH_##fs (R) &= ~(_FP_W_TYPE) _FP_IMPLBIT_SH_##fs; \
} \
} \
#define _FP_FMA(fs, wc, dwc, R, X, Y, Z) \
do \
{ \
#define _FP_FMA(fs, wc, dwc, R, X, Y, Z) \
do \
{ \
- FP_DECL_##fs (T); \
- T##_s = X##_s ^ Y##_s; \
- T##_e = X##_e + Y##_e + 1; \
+ FP_DECL_##fs (_FP_FMA_T); \
+ _FP_FMA_T##_s = X##_s ^ Y##_s; \
+ _FP_FMA_T##_e = X##_e + Y##_e + 1; \
switch (_FP_CLS_COMBINE (X##_c, Y##_c)) \
{ \
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_NORMAL): \
switch (_FP_CLS_COMBINE (X##_c, Y##_c)) \
{ \
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_NORMAL): \
\
case FP_CLS_ZERO: \
R##_c = FP_CLS_NORMAL; \
\
case FP_CLS_ZERO: \
R##_c = FP_CLS_NORMAL; \
- R##_s = T##_s; \
- R##_e = T##_e; \
+ R##_s = _FP_FMA_T##_s; \
+ R##_e = _FP_FMA_T##_e; \
\
_FP_MUL_MEAT_##fs (R, X, Y); \
\
\
_FP_MUL_MEAT_##fs (R, X, Y); \
\
break; \
\
case FP_CLS_NORMAL:; \
break; \
\
case FP_CLS_NORMAL:; \
- _FP_FRAC_DECL_##dwc (TD); \
- _FP_FRAC_DECL_##dwc (ZD); \
- _FP_FRAC_DECL_##dwc (RD); \
- _FP_MUL_MEAT_DW_##fs (TD, X, Y); \
- R##_e = T##_e; \
- int tsh = _FP_FRAC_HIGHBIT_DW_##dwc (fs, TD) == 0; \
- T##_e -= tsh; \
- int ediff = T##_e - Z##_e; \
- if (ediff >= 0) \
+ _FP_FRAC_DECL_##dwc (_FP_FMA_TD); \
+ _FP_FRAC_DECL_##dwc (_FP_FMA_ZD); \
+ _FP_FRAC_DECL_##dwc (_FP_FMA_RD); \
+ _FP_MUL_MEAT_DW_##fs (_FP_FMA_TD, X, Y); \
+ R##_e = _FP_FMA_T##_e; \
+ int _FP_FMA_tsh \
+ = _FP_FRAC_HIGHBIT_DW_##dwc (fs, _FP_FMA_TD) == 0; \
+ _FP_FMA_T##_e -= _FP_FMA_tsh; \
+ int _FP_FMA_ediff = _FP_FMA_T##_e - Z##_e; \
+ if (_FP_FMA_ediff >= 0) \
- int shift = _FP_WFRACBITS_##fs - tsh - ediff; \
- if (shift <= -_FP_WFRACBITS_##fs) \
- _FP_FRAC_SET_##dwc (ZD, _FP_MINFRAC_##dwc); \
+ int _FP_FMA_shift \
+ = _FP_WFRACBITS_##fs - _FP_FMA_tsh - _FP_FMA_ediff; \
+ if (_FP_FMA_shift <= -_FP_WFRACBITS_##fs) \
+ _FP_FRAC_SET_##dwc (_FP_FMA_ZD, _FP_MINFRAC_##dwc); \
- _FP_FRAC_COPY_##dwc##_##wc (ZD, Z); \
- if (shift < 0) \
- _FP_FRAC_SRS_##dwc (ZD, -shift, \
+ _FP_FRAC_COPY_##dwc##_##wc (_FP_FMA_ZD, Z); \
+ if (_FP_FMA_shift < 0) \
+ _FP_FRAC_SRS_##dwc (_FP_FMA_ZD, -_FP_FMA_shift, \
_FP_WFRACBITS_DW_##fs); \
_FP_WFRACBITS_DW_##fs); \
- else if (shift > 0) \
- _FP_FRAC_SLL_##dwc (ZD, shift); \
+ else if (_FP_FMA_shift > 0) \
+ _FP_FRAC_SLL_##dwc (_FP_FMA_ZD, _FP_FMA_shift); \
- R##_s = T##_s; \
- if (T##_s == Z##_s) \
- _FP_FRAC_ADD_##dwc (RD, TD, ZD); \
+ R##_s = _FP_FMA_T##_s; \
+ if (_FP_FMA_T##_s == Z##_s) \
+ _FP_FRAC_ADD_##dwc (_FP_FMA_RD, _FP_FMA_TD, \
+ _FP_FMA_ZD); \
- _FP_FRAC_SUB_##dwc (RD, TD, ZD); \
- if (_FP_FRAC_NEGP_##dwc (RD)) \
+ _FP_FRAC_SUB_##dwc (_FP_FMA_RD, _FP_FMA_TD, \
+ _FP_FMA_ZD); \
+ if (_FP_FRAC_NEGP_##dwc (_FP_FMA_RD)) \
- _FP_FRAC_SUB_##dwc (RD, ZD, TD); \
+ _FP_FRAC_SUB_##dwc (_FP_FMA_RD, _FP_FMA_ZD, \
+ _FP_FMA_TD); \
{ \
R##_e = Z##_e; \
R##_s = Z##_s; \
{ \
R##_e = Z##_e; \
R##_s = Z##_s; \
- _FP_FRAC_COPY_##dwc##_##wc (ZD, Z); \
- _FP_FRAC_SLL_##dwc (ZD, _FP_WFRACBITS_##fs); \
- int shift = -ediff - tsh; \
- if (shift >= _FP_WFRACBITS_DW_##fs) \
- _FP_FRAC_SET_##dwc (TD, _FP_MINFRAC_##dwc); \
- else if (shift > 0) \
- _FP_FRAC_SRS_##dwc (TD, shift, \
+ _FP_FRAC_COPY_##dwc##_##wc (_FP_FMA_ZD, Z); \
+ _FP_FRAC_SLL_##dwc (_FP_FMA_ZD, _FP_WFRACBITS_##fs); \
+ int _FP_FMA_shift = -_FP_FMA_ediff - _FP_FMA_tsh; \
+ if (_FP_FMA_shift >= _FP_WFRACBITS_DW_##fs) \
+ _FP_FRAC_SET_##dwc (_FP_FMA_TD, _FP_MINFRAC_##dwc); \
+ else if (_FP_FMA_shift > 0) \
+ _FP_FRAC_SRS_##dwc (_FP_FMA_TD, _FP_FMA_shift, \
_FP_WFRACBITS_DW_##fs); \
_FP_WFRACBITS_DW_##fs); \
- if (Z##_s == T##_s) \
- _FP_FRAC_ADD_##dwc (RD, ZD, TD); \
+ if (Z##_s == _FP_FMA_T##_s) \
+ _FP_FRAC_ADD_##dwc (_FP_FMA_RD, _FP_FMA_ZD, \
+ _FP_FMA_TD); \
- _FP_FRAC_SUB_##dwc (RD, ZD, TD); \
+ _FP_FRAC_SUB_##dwc (_FP_FMA_RD, _FP_FMA_ZD, \
+ _FP_FMA_TD); \
- if (_FP_FRAC_ZEROP_##dwc (RD)) \
+ if (_FP_FRAC_ZEROP_##dwc (_FP_FMA_RD)) \
+ if (_FP_FMA_T##_s == Z##_s) \
R##_s = Z##_s; \
else \
R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
R##_s = Z##_s; \
else \
R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
- int rlz; \
- _FP_FRAC_CLZ_##dwc (rlz, RD); \
- rlz -= _FP_WFRACXBITS_DW_##fs; \
- R##_e -= rlz; \
- int shift = _FP_WFRACBITS_##fs - rlz; \
- if (shift > 0) \
- _FP_FRAC_SRS_##dwc (RD, shift, \
+ int _FP_FMA_rlz; \
+ _FP_FRAC_CLZ_##dwc (_FP_FMA_rlz, _FP_FMA_RD); \
+ _FP_FMA_rlz -= _FP_WFRACXBITS_DW_##fs; \
+ R##_e -= _FP_FMA_rlz; \
+ int _FP_FMA_shift = _FP_WFRACBITS_##fs - _FP_FMA_rlz; \
+ if (_FP_FMA_shift > 0) \
+ _FP_FRAC_SRS_##dwc (_FP_FMA_RD, _FP_FMA_shift, \
_FP_WFRACBITS_DW_##fs); \
_FP_WFRACBITS_DW_##fs); \
- else if (shift < 0) \
- _FP_FRAC_SLL_##dwc (RD, -shift); \
- _FP_FRAC_COPY_##wc##_##dwc (R, RD); \
+ else if (_FP_FMA_shift < 0) \
+ _FP_FRAC_SLL_##dwc (_FP_FMA_RD, -_FP_FMA_shift); \
+ _FP_FRAC_COPY_##wc##_##dwc (R, _FP_FMA_RD); \
R##_c = FP_CLS_NORMAL; \
} \
break; \
R##_c = FP_CLS_NORMAL; \
} \
break; \
goto done_fma; \
\
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NAN): \
goto done_fma; \
\
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NAN): \
- _FP_CHOOSENAN (fs, wc, T, X, Y, '*'); \
+ _FP_CHOOSENAN (fs, wc, _FP_FMA_T, X, Y, '*'); \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_INF): \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_ZERO): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_INF): \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_ZERO): \
+ _FP_FMA_T##_s = X##_s; \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_INF): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_ZERO): \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_INF): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_ZERO): \
- _FP_FRAC_COPY_##wc (T, X); \
- T##_c = X##_c; \
+ _FP_FRAC_COPY_##wc (_FP_FMA_T, X); \
+ _FP_FMA_T##_c = X##_c; \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_NAN): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NAN): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_NAN): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_NAN): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NAN): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_NAN): \
+ _FP_FMA_T##_s = Y##_s; \
\
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_INF): \
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_ZERO): \
\
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_INF): \
case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_ZERO): \
- _FP_FRAC_COPY_##wc (T, Y); \
- T##_c = Y##_c; \
+ _FP_FRAC_COPY_##wc (_FP_FMA_T, Y); \
+ _FP_FMA_T##_c = Y##_c; \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_ZERO): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_INF): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_ZERO): \
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_INF): \
- T##_s = _FP_NANSIGN_##fs; \
- T##_c = FP_CLS_NAN; \
- _FP_FRAC_SET_##wc (T, _FP_NANFRAC_##fs); \
+ _FP_FMA_T##_s = _FP_NANSIGN_##fs; \
+ _FP_FMA_T##_c = FP_CLS_NAN; \
+ _FP_FRAC_SET_##wc (_FP_FMA_T, _FP_NANFRAC_##fs); \
FP_SET_EXCEPTION (FP_EX_INVALID); \
break; \
\
FP_SET_EXCEPTION (FP_EX_INVALID); \
break; \
\
} \
\
/* T = X * Y is zero, infinity or NaN. */ \
} \
\
/* T = X * Y is zero, infinity or NaN. */ \
- switch (_FP_CLS_COMBINE (T##_c, Z##_c)) \
+ switch (_FP_CLS_COMBINE (_FP_FMA_T##_c, Z##_c)) \
{ \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NAN): \
{ \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NAN): \
- _FP_CHOOSENAN (fs, wc, R, T, Z, '+'); \
+ _FP_CHOOSENAN (fs, wc, R, _FP_FMA_T, Z, '+'); \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NORMAL): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_ZERO): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_ZERO): \
case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_ZERO): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NORMAL): \
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_ZERO): \
- R##_s = T##_s; \
- _FP_FRAC_COPY_##wc (R, T); \
- R##_c = T##_c; \
+ R##_s = _FP_FMA_T##_s; \
+ _FP_FRAC_COPY_##wc (R, _FP_FMA_T); \
+ R##_c = _FP_FMA_T##_c; \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NAN): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NAN): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_INF): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_INF): \
+ if (_FP_FMA_T##_s == Z##_s) \
{ \
R##_s = Z##_s; \
_FP_FRAC_COPY_##wc (R, Z); \
{ \
R##_s = Z##_s; \
_FP_FRAC_COPY_##wc (R, Z); \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_ZERO): \
break; \
\
case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_ZERO): \
+ if (_FP_FMA_T##_s == Z##_s) \
R##_s = Z##_s; \
else \
R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
R##_s = Z##_s; \
else \
R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
- int __is_zero_x; \
- int __is_zero_y; \
+ int _FP_CMP_is_zero_x; \
+ int _FP_CMP_is_zero_y; \
- __is_zero_x = (!X##_e && _FP_FRAC_ZEROP_##wc (X)) ? 1 : 0; \
- __is_zero_y = (!Y##_e && _FP_FRAC_ZEROP_##wc (Y)) ? 1 : 0; \
+ _FP_CMP_is_zero_x \
+ = (!X##_e && _FP_FRAC_ZEROP_##wc (X)) ? 1 : 0; \
+ _FP_CMP_is_zero_y \
+ = (!Y##_e && _FP_FRAC_ZEROP_##wc (Y)) ? 1 : 0; \
- if (__is_zero_x && __is_zero_y) \
+ if (_FP_CMP_is_zero_x && _FP_CMP_is_zero_y) \
- else if (__is_zero_x) \
+ else if (_FP_CMP_is_zero_x) \
- else if (__is_zero_y) \
+ else if (_FP_CMP_is_zero_y) \
ret = X##_s ? -1 : 1; \
else if (X##_s != Y##_s) \
ret = X##_s ? -1 : 1; \
ret = X##_s ? -1 : 1; \
else if (X##_s != Y##_s) \
ret = X##_s ? -1 : 1; \
#define _FP_SQRT(fs, wc, R, X) \
do \
{ \
#define _FP_SQRT(fs, wc, R, X) \
do \
{ \
- _FP_FRAC_DECL_##wc (T); \
- _FP_FRAC_DECL_##wc (S); \
- _FP_W_TYPE q; \
+ _FP_FRAC_DECL_##wc (_FP_SQRT_T); \
+ _FP_FRAC_DECL_##wc (_FP_SQRT_S); \
+ _FP_W_TYPE _FP_SQRT_q; \
switch (X##_c) \
{ \
case FP_CLS_NAN: \
switch (X##_c) \
{ \
case FP_CLS_NAN: \
if (X##_e & 1) \
_FP_FRAC_SLL_##wc (X, 1); \
R##_e = X##_e >> 1; \
if (X##_e & 1) \
_FP_FRAC_SLL_##wc (X, 1); \
R##_e = X##_e >> 1; \
- _FP_FRAC_SET_##wc (S, _FP_ZEROFRAC_##wc); \
+ _FP_FRAC_SET_##wc (_FP_SQRT_S, _FP_ZEROFRAC_##wc); \
_FP_FRAC_SET_##wc (R, _FP_ZEROFRAC_##wc); \
_FP_FRAC_SET_##wc (R, _FP_ZEROFRAC_##wc); \
- q = _FP_OVERFLOW_##fs >> 1; \
- _FP_SQRT_MEAT_##wc (R, S, T, X, q); \
+ _FP_SQRT_q = _FP_OVERFLOW_##fs >> 1; \
+ _FP_SQRT_MEAT_##wc (R, _FP_SQRT_S, _FP_SQRT_T, X, \
+ _FP_SQRT_q); \
{ \
/* Possibly converting to most negative integer; check the \
mantissa. */ \
{ \
/* Possibly converting to most negative integer; check the \
mantissa. */ \
+ int _FP_TO_INT_inexact = 0; \
(void) ((_FP_FRACBITS_##fs > rsize) \
? ({ \
(void) ((_FP_FRACBITS_##fs > rsize) \
? ({ \
- _FP_FRAC_SRST_##wc (X, inexact, \
+ _FP_FRAC_SRST_##wc (X, _FP_TO_INT_inexact, \
_FP_FRACBITS_##fs - rsize, \
_FP_FRACBITS_##fs); \
0; \
_FP_FRACBITS_##fs - rsize, \
_FP_FRACBITS_##fs); \
0; \
: 0); \
if (!_FP_FRAC_ZEROP_##wc (X)) \
FP_SET_EXCEPTION (FP_EX_INVALID); \
: 0); \
if (!_FP_FRAC_ZEROP_##wc (X)) \
FP_SET_EXCEPTION (FP_EX_INVALID); \
+ else if (_FP_TO_INT_inexact) \
FP_SET_EXCEPTION (FP_EX_INEXACT); \
} \
else \
FP_SET_EXCEPTION (FP_EX_INEXACT); \
} \
else \
- int inexact; \
- _FP_FRAC_SRST_##wc (X, inexact, \
+ int _FP_TO_INT_inexact; \
+ _FP_FRAC_SRST_##wc (X, _FP_TO_INT_inexact, \
(_FP_FRACBITS_##fs + _FP_EXPBIAS_##fs - 1 \
- X##_e), \
_FP_FRACBITS_##fs); \
(_FP_FRACBITS_##fs + _FP_EXPBIAS_##fs - 1 \
- X##_e), \
_FP_FRACBITS_##fs); \
+ if (_FP_TO_INT_inexact) \
FP_SET_EXCEPTION (FP_EX_INEXACT); \
_FP_FRAC_ASSEMBLE_##wc (r, X, rsize); \
} \
FP_SET_EXCEPTION (FP_EX_INEXACT); \
_FP_FRAC_ASSEMBLE_##wc (r, X, rsize); \
} \
+ rtype _FP_FROM_INT_ur; \
\
if ((X##_s = (r < 0))) \
r = -(rtype) r; \
\
\
if ((X##_s = (r < 0))) \
r = -(rtype) r; \
\
+ _FP_FROM_INT_ur = (rtype) r; \
(void) ((rsize <= _FP_W_TYPE_SIZE) \
? ({ \
(void) ((rsize <= _FP_W_TYPE_SIZE) \
? ({ \
- int lz_; \
- __FP_CLZ (lz_, (_FP_W_TYPE) ur_); \
- X##_e = _FP_EXPBIAS_##fs + _FP_W_TYPE_SIZE - 1 - lz_; \
+ int _FP_FROM_INT_lz; \
+ __FP_CLZ (_FP_FROM_INT_lz, \
+ (_FP_W_TYPE) _FP_FROM_INT_ur); \
+ X##_e = (_FP_EXPBIAS_##fs + _FP_W_TYPE_SIZE - 1 \
+ - _FP_FROM_INT_lz); \
}) \
: ((rsize <= 2 * _FP_W_TYPE_SIZE) \
? ({ \
}) \
: ((rsize <= 2 * _FP_W_TYPE_SIZE) \
? ({ \
- int lz_; \
- __FP_CLZ_2 (lz_, \
- (_FP_W_TYPE) (ur_ >> _FP_W_TYPE_SIZE), \
- (_FP_W_TYPE) ur_); \
+ int _FP_FROM_INT_lz; \
+ __FP_CLZ_2 (_FP_FROM_INT_lz, \
+ (_FP_W_TYPE) (_FP_FROM_INT_ur \
+ >> _FP_W_TYPE_SIZE), \
+ (_FP_W_TYPE) _FP_FROM_INT_ur); \
X##_e = (_FP_EXPBIAS_##fs + 2 * _FP_W_TYPE_SIZE - 1 \
X##_e = (_FP_EXPBIAS_##fs + 2 * _FP_W_TYPE_SIZE - 1 \
}) \
: (abort (), 0))); \
\
}) \
: (abort (), 0))); \
\
|| X##_e < _FP_EXPBIAS_##fs + _FP_FRACBITS_##fs) \
{ \
/* Exactly representable; shift left. */ \
|| X##_e < _FP_EXPBIAS_##fs + _FP_FRACBITS_##fs) \
{ \
/* Exactly representable; shift left. */ \
- _FP_FRAC_DISASSEMBLE_##wc (X, ur_, rsize); \
+ _FP_FRAC_DISASSEMBLE_##wc (X, _FP_FROM_INT_ur, rsize); \
if (_FP_EXPBIAS_##fs + _FP_FRACBITS_##fs - 1 - X##_e > 0) \
_FP_FRAC_SLL_##wc (X, (_FP_EXPBIAS_##fs \
+ _FP_FRACBITS_##fs - 1 - X##_e)); \
if (_FP_EXPBIAS_##fs + _FP_FRACBITS_##fs - 1 - X##_e > 0) \
_FP_FRAC_SLL_##wc (X, (_FP_EXPBIAS_##fs \
+ _FP_FRACBITS_##fs - 1 - X##_e)); \
/* More bits in integer than in floating type; need to \
round. */ \
if (_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 < X##_e) \
/* More bits in integer than in floating type; need to \
round. */ \
if (_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 < X##_e) \
- ur_ = ((ur_ >> (X##_e - _FP_EXPBIAS_##fs \
- - _FP_WFRACBITS_##fs + 1)) \
- | ((ur_ << (rsize - (X##_e - _FP_EXPBIAS_##fs \
- - _FP_WFRACBITS_##fs + 1))) \
- != 0)); \
- _FP_FRAC_DISASSEMBLE_##wc (X, ur_, rsize); \
+ _FP_FROM_INT_ur \
+ = ((_FP_FROM_INT_ur >> (X##_e - _FP_EXPBIAS_##fs \
+ - _FP_WFRACBITS_##fs + 1)) \
+ | ((_FP_FROM_INT_ur \
+ << (rsize - (X##_e - _FP_EXPBIAS_##fs \
+ - _FP_WFRACBITS_##fs + 1))) \
+ != 0)); \
+ _FP_FRAC_DISASSEMBLE_##wc (X, _FP_FROM_INT_ur, rsize); \
if ((_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 - X##_e) > 0) \
_FP_FRAC_SLL_##wc (X, (_FP_EXPBIAS_##fs \
+ _FP_WFRACBITS_##fs - 1 - X##_e)); \
if ((_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 - X##_e) > 0) \
_FP_FRAC_SLL_##wc (X, (_FP_EXPBIAS_##fs \
+ _FP_WFRACBITS_##fs - 1 - X##_e)); \
FP_SET_EXCEPTION (FP_EX_DENORM); \
FP_SET_EXCEPTION (FP_EX_DENORM); \
- _FP_FRAC_CLZ_##swc (_lz, S); \
+ _FP_FRAC_CLZ_##swc (FP_EXTEND_lz, S); \
- _lz + _FP_FRACBITS_##dfs \
+ FP_EXTEND_lz + _FP_FRACBITS_##dfs \
- _FP_FRACTBITS_##sfs); \
D##_e = (_FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs + 1 \
- _FP_FRACTBITS_##sfs); \
D##_e = (_FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs + 1 \
- + _FP_FRACXBITS_##sfs - _lz); \
+ + _FP_FRACXBITS_##sfs - FP_EXTEND_lz); \
#define _FP_DIV_MEAT_N_loop(fs, wc, R, X, Y) \
do \
{ \
#define _FP_DIV_MEAT_N_loop(fs, wc, R, X, Y) \
do \
{ \
- int count = _FP_WFRACBITS_##fs; \
- _FP_FRAC_DECL_##wc (u); \
- _FP_FRAC_DECL_##wc (v); \
- _FP_FRAC_COPY_##wc (u, X); \
- _FP_FRAC_COPY_##wc (v, Y); \
+ int _FP_DIV_MEAT_N_loop_count = _FP_WFRACBITS_##fs; \
+ _FP_FRAC_DECL_##wc (_FP_DIV_MEAT_N_loop_u); \
+ _FP_FRAC_DECL_##wc (_FP_DIV_MEAT_N_loop_v); \
+ _FP_FRAC_COPY_##wc (_FP_DIV_MEAT_N_loop_u, X); \
+ _FP_FRAC_COPY_##wc (_FP_DIV_MEAT_N_loop_v, Y); \
_FP_FRAC_SET_##wc (R, _FP_ZEROFRAC_##wc); \
_FP_FRAC_SET_##wc (R, _FP_ZEROFRAC_##wc); \
- /* Normalize U and V. */ \
- _FP_FRAC_SLL_##wc (u, _FP_WFRACXBITS_##fs); \
- _FP_FRAC_SLL_##wc (v, _FP_WFRACXBITS_##fs); \
+ /* Normalize _FP_DIV_MEAT_N_LOOP_U and _FP_DIV_MEAT_N_LOOP_V. */ \
+ _FP_FRAC_SLL_##wc (_FP_DIV_MEAT_N_loop_u, _FP_WFRACXBITS_##fs); \
+ _FP_FRAC_SLL_##wc (_FP_DIV_MEAT_N_loop_v, _FP_WFRACXBITS_##fs); \
/* First round. Since the operands are normalized, either the \
first or second bit will be set in the fraction. Produce a \
normalized result by checking which and adjusting the loop \
count and exponent accordingly. */ \
/* First round. Since the operands are normalized, either the \
first or second bit will be set in the fraction. Produce a \
normalized result by checking which and adjusting the loop \
count and exponent accordingly. */ \
- if (_FP_FRAC_GE_1 (u, v)) \
+ if (_FP_FRAC_GE_1 (_FP_DIV_MEAT_N_loop_u, _FP_DIV_MEAT_N_loop_v)) \
- _FP_FRAC_SUB_##wc (u, u, v); \
+ _FP_FRAC_SUB_##wc (_FP_DIV_MEAT_N_loop_u, \
+ _FP_DIV_MEAT_N_loop_u, \
+ _FP_DIV_MEAT_N_loop_v); \
_FP_FRAC_LOW_##wc (R) |= 1; \
_FP_FRAC_LOW_##wc (R) |= 1; \
+ _FP_DIV_MEAT_N_loop_count--; \
} \
else \
R##_e--; \
/* Subsequent rounds. */ \
do \
{ \
} \
else \
R##_e--; \
/* Subsequent rounds. */ \
do \
{ \
- int msb = (_FP_WS_TYPE) _FP_FRAC_HIGH_##wc (u) < 0; \
- _FP_FRAC_SLL_##wc (u, 1); \
+ int _FP_DIV_MEAT_N_loop_msb \
+ = (_FP_WS_TYPE) _FP_FRAC_HIGH_##wc (_FP_DIV_MEAT_N_loop_u) < 0; \
+ _FP_FRAC_SLL_##wc (_FP_DIV_MEAT_N_loop_u, 1); \
_FP_FRAC_SLL_##wc (R, 1); \
_FP_FRAC_SLL_##wc (R, 1); \
- if (msb || _FP_FRAC_GE_1 (u, v)) \
+ if (_FP_DIV_MEAT_N_loop_msb \
+ || _FP_FRAC_GE_1 (_FP_DIV_MEAT_N_loop_u, \
+ _FP_DIV_MEAT_N_loop_v)) \
- _FP_FRAC_SUB_##wc (u, u, v); \
+ _FP_FRAC_SUB_##wc (_FP_DIV_MEAT_N_loop_u, \
+ _FP_DIV_MEAT_N_loop_u, \
+ _FP_DIV_MEAT_N_loop_v); \
_FP_FRAC_LOW_##wc (R) |= 1; \
} \
} \
_FP_FRAC_LOW_##wc (R) |= 1; \
} \
} \
- while (--count > 0); \
- /* If there's anything left in U, the result is inexact. */ \
- _FP_FRAC_LOW_##wc (R) |= !_FP_FRAC_ZEROP_##wc (u); \
+ while (--_FP_DIV_MEAT_N_loop_count > 0); \
+ /* If there's anything left in _FP_DIV_MEAT_N_LOOP_U, the result \
+ is inexact. */ \
+ _FP_FRAC_LOW_##wc (R) \
+ |= !_FP_FRAC_ZEROP_##wc (_FP_DIV_MEAT_N_loop_u); \