2014-09-17 Joseph Myers <joseph@codesourcery.com>
+ * soft-fp/extended.h: Fix comment formatting.
+ * soft-fp/op-1.h: Likewise.
+ * soft-fp/op-2.h: Likewise.
+ * soft-fp/op-4.h: Likewise.
+ * soft-fp/op-8.h: Likewise.
+ * soft-fp/op-common.h: Likewise.
+ * soft-fp/soft-fp.h: Likewise.
+
* soft-fp/op-common.h (_FP_TO_INT): Correct formatting.
2014-09-16 Joseph Myers <joseph@codesourcery.com>
# define FP_SQRT_E(R, X) _FP_SQRT (E, 4, R, X)
# define FP_FMA_E(R, X, Y, Z) _FP_FMA (E, 4, 8, R, X, Y, Z)
-/*
- * Square root algorithms:
- * We have just one right now, maybe Newton approximation
- * should be added for those machines where division is fast.
- * This has special _E version because standard _4 square
- * root would not work (it has to start normally with the
- * second word and not the first), but as we have to do it
- * anyway, we optimize it by doing most of the calculations
- * in two UWtype registers instead of four.
- */
+/* Square root algorithms:
+ We have just one right now, maybe Newton approximation
+ should be added for those machines where division is fast.
+ This has special _E version because standard _4 square
+ root would not work (it has to start normally with the
+ second word and not the first), but as we have to do it
+ anyway, we optimize it by doing most of the calculations
+ in two UWtype registers instead of four. */
# define _FP_SQRT_MEAT_E(R, S, T, X, q) \
do \
# define FP_SQRT_E(R, X) _FP_SQRT (E, 2, R, X)
# define FP_FMA_E(R, X, Y, Z) _FP_FMA (E, 2, 4, R, X, Y, Z)
-/*
- * Square root algorithms:
- * We have just one right now, maybe Newton approximation
- * should be added for those machines where division is fast.
- * We optimize it by doing most of the calculations
- * in one UWtype registers instead of two, although we don't
- * have to.
- */
+/* Square root algorithms:
+ We have just one right now, maybe Newton approximation
+ should be added for those machines where division is fast.
+ We optimize it by doing most of the calculations
+ in one UWtype registers instead of two, although we don't
+ have to. */
# define _FP_SQRT_MEAT_E(R, S, T, X, q) \
do \
{ \
#define _FP_FRAC_DEC_1(X, Y) (X##_f -= Y##_f)
#define _FP_FRAC_CLZ_1(z, X) __FP_CLZ (z, X##_f)
-/* Predicates */
+/* Predicates. */
#define _FP_FRAC_NEGP_1(X) ((_FP_WS_TYPE) X##_f < 0)
#define _FP_FRAC_ZEROP_1(X) (X##_f == 0)
#define _FP_FRAC_OVERP_1(fs, X) (X##_f & _FP_OVERFLOW_##fs)
#define _FP_MINFRAC_1 1
#define _FP_MAXFRAC_1 (~(_FP_WS_TYPE) 0)
-/*
- * Unpack the raw bits of a native fp value. Do not classify or
- * normalize the data.
- */
+/* Unpack the raw bits of a native fp value. Do not classify or
+ normalize the data. */
#define _FP_UNPACK_RAW_1(fs, X, val) \
do \
} \
while (0)
-/*
- * Repack the raw bits of a native fp value.
- */
+/* Repack the raw bits of a native fp value. */
#define _FP_PACK_RAW_1(fs, val, X) \
do \
while (0)
-/*
- * Multiplication algorithms:
- */
+/* Multiplication algorithms: */
/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
multiplication immediately. */
_FP_W_TYPE _FP_MUL_MEAT_DW_1_hard_yh, _FP_MUL_MEAT_DW_1_hard_yl; \
_FP_FRAC_DECL_2 (_FP_MUL_MEAT_DW_1_hard_a); \
\
- /* split the words in half */ \
+ /* Split the words in half. */ \
_FP_MUL_MEAT_DW_1_hard_xh = X##_f >> (_FP_W_TYPE_SIZE/2); \
_FP_MUL_MEAT_DW_1_hard_xl \
= X##_f & (((_FP_W_TYPE) 1 << (_FP_W_TYPE_SIZE/2)) - 1); \
_FP_MUL_MEAT_DW_1_hard_yl \
= Y##_f & (((_FP_W_TYPE) 1 << (_FP_W_TYPE_SIZE/2)) - 1); \
\
- /* multiply the pieces */ \
+ /* Multiply the pieces. */ \
R##_f0 = _FP_MUL_MEAT_DW_1_hard_xl * _FP_MUL_MEAT_DW_1_hard_yl; \
_FP_MUL_MEAT_DW_1_hard_a_f0 \
= _FP_MUL_MEAT_DW_1_hard_xh * _FP_MUL_MEAT_DW_1_hard_yl; \
= _FP_MUL_MEAT_DW_1_hard_xl * _FP_MUL_MEAT_DW_1_hard_yh; \
R##_f1 = _FP_MUL_MEAT_DW_1_hard_xh * _FP_MUL_MEAT_DW_1_hard_yh; \
\
- /* reassemble into two full words */ \
+ /* Reassemble into two full words. */ \
if ((_FP_MUL_MEAT_DW_1_hard_a_f0 += _FP_MUL_MEAT_DW_1_hard_a_f1) \
< _FP_MUL_MEAT_DW_1_hard_a_f1) \
R##_f1 += (_FP_W_TYPE) 1 << (_FP_W_TYPE_SIZE/2); \
_FP_FRAC_DECL_2 (_FP_MUL_MEAT_1_hard_z); \
_FP_MUL_MEAT_DW_1_hard (wfracbits, _FP_MUL_MEAT_1_hard_z, X, Y); \
\
- /* normalize */ \
+ /* Normalize. */ \
_FP_FRAC_SRS_2 (_FP_MUL_MEAT_1_hard_z, \
wfracbits - 1, 2*wfracbits); \
R##_f = _FP_MUL_MEAT_1_hard_z_f0; \
while (0)
-/*
- * Division algorithms:
- */
+/* Division algorithms: */
/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
division immediately. Give this macro either _FP_DIV_HELP_imm for
while (0)
-/*
- * Square root algorithms:
- * We have just one right now, maybe Newton approximation
- * should be added for those machines where division is fast.
- */
+/* Square root algorithms:
+ We have just one right now, maybe Newton approximation
+ should be added for those machines where division is fast. */
#define _FP_SQRT_MEAT_1(R, S, T, X, q) \
do \
} \
while (0)
-/*
- * Assembly/disassembly for converting to/from integral types.
- * No shifting or overflow handled here.
- */
+/* Assembly/disassembly for converting to/from integral types.
+ No shifting or overflow handled here. */
#define _FP_FRAC_ASSEMBLE_1(r, X, rsize) (r = X##_f)
#define _FP_FRAC_DISASSEMBLE_1(X, r, rsize) (X##_f = r)
-/*
- * Convert FP values between word sizes
- */
+/* Convert FP values between word sizes. */
#define _FP_FRAC_COPY_1_1(D, S) (D##_f = S##_f)
} \
while (0)
-/* Predicates */
+/* Predicates. */
#define _FP_FRAC_NEGP_2(X) ((_FP_WS_TYPE) X##_f1 < 0)
#define _FP_FRAC_ZEROP_2(X) ((X##_f1 | X##_f0) == 0)
#define _FP_FRAC_OVERP_2(fs, X) (_FP_FRAC_HIGH_##fs (X) & _FP_OVERFLOW_##fs)
#define _FP_MINFRAC_2 0, 1
#define _FP_MAXFRAC_2 (~(_FP_WS_TYPE) 0), (~(_FP_WS_TYPE) 0)
-/*
- * Internals
- */
+/* Internals. */
#define __FP_FRAC_SET_2(X, I1, I0) (X##_f0 = I0, X##_f1 = I1)
#endif
-/*
- * Unpack the raw bits of a native fp value. Do not classify or
- * normalize the data.
- */
+/* Unpack the raw bits of a native fp value. Do not classify or
+ normalize the data. */
#define _FP_UNPACK_RAW_2(fs, X, val) \
do \
while (0)
-/*
- * Repack the raw bits of a native fp value.
- */
+/* Repack the raw bits of a native fp value. */
#define _FP_PACK_RAW_2(fs, val, X) \
do \
while (0)
-/*
- * Multiplication algorithms:
- */
+/* Multiplication algorithms: */
/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
} \
while (0)
-/*
- * Division algorithms:
- */
+/* Division algorithms: */
#define _FP_DIV_MEAT_2_udiv(fs, R, X, Y) \
do \
} \
\
/* Normalize, i.e. make the most significant bit of the \
- denominator set. */ \
+ denominator set. */ \
_FP_FRAC_SLL_2 (Y, _FP_WFRACXBITS_##fs); \
\
udiv_qrnnd (R##_f1, _FP_DIV_MEAT_2_udiv_r_f1, \
while (0)
-/*
- * Square root algorithms:
- * We have just one right now, maybe Newton approximation
- * should be added for those machines where division is fast.
- */
+/* Square root algorithms:
+ We have just one right now, maybe Newton approximation
+ should be added for those machines where division is fast. */
#define _FP_SQRT_MEAT_2(R, S, T, X, q) \
do \
while (0)
-/*
- * Assembly/disassembly for converting to/from integral types.
- * No shifting or overflow handled here.
- */
+/* Assembly/disassembly for converting to/from integral types.
+ No shifting or overflow handled here. */
#define _FP_FRAC_ASSEMBLE_2(r, X, rsize) \
(void) ((rsize <= _FP_W_TYPE_SIZE) \
} \
while (0)
-/*
- * Convert FP values between word sizes
- */
+/* Convert FP values between word sizes. */
#define _FP_FRAC_COPY_1_2(D, S) (D##_f = S##_f0)
} \
while (0)
-/* This one was broken too */
+/* This one was broken too. */
#define _FP_FRAC_SRL_4(X, N) \
do \
{ \
/* Right shift with sticky-lsb.
- * What this actually means is that we do a standard right-shift,
- * but that if any of the bits that fall off the right hand side
- * were one then we always set the LSbit.
- */
+ What this actually means is that we do a standard right-shift,
+ but that if any of the bits that fall off the right hand side
+ were one then we always set the LSbit. */
#define _FP_FRAC_SRST_4(X, S, N, size) \
do \
{ \
} \
while (0)
-/*
- * Multiplication algorithms:
- */
+/* Multiplication algorithms: */
/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
} \
while (0)
-/*
- * Helper utility for _FP_DIV_MEAT_4_udiv:
- * pppp = m * nnn
- */
+/* Helper utility for _FP_DIV_MEAT_4_udiv:
+ * pppp = m * nnn. */
#define umul_ppppmnnn(p3, p2, p1, p0, m, n2, n1, n0) \
do \
{ \
} \
while (0)
-/*
- * Division algorithms:
- */
+/* Division algorithms: */
#define _FP_DIV_MEAT_4_udiv(fs, R, X, Y) \
do \
R##_e--; \
\
/* Normalize, i.e. make the most significant bit of the \
- denominator set. */ \
+ denominator set. */ \
_FP_FRAC_SLL_4 (Y, _FP_WFRACXBITS_##fs); \
\
for (_FP_DIV_MEAT_4_udiv_i = 3; ; _FP_DIV_MEAT_4_udiv_i--) \
while (0)
-/*
- * Square root algorithms:
- * We have just one right now, maybe Newton approximation
- * should be added for those machines where division is fast.
- */
+/* Square root algorithms:
+ We have just one right now, maybe Newton approximation
+ should be added for those machines where division is fast. */
#define _FP_SQRT_MEAT_4(R, S, T, X, q) \
do \
while (0)
-/*
- * Internals
- */
+/* Internals. */
#define __FP_FRAC_SET_4(X, I3, I2, I1, I0) \
(X##_f[3] = I3, X##_f[2] = I2, X##_f[1] = I1, X##_f[0] = I0)
#endif
/* Convert FP values between word sizes. This appears to be more
- * complicated than I'd have expected it to be, so these might be
- * wrong... These macros are in any case somewhat bogus because they
- * use information about what various FRAC_n variables look like
- * internally [eg, that 2 word vars are X_f0 and x_f1]. But so do
- * the ones in op-2.h and op-1.h.
- */
+ complicated than I'd have expected it to be, so these might be
+ wrong... These macros are in any case somewhat bogus because they
+ use information about what various FRAC_n variables look like
+ internally [eg, that 2 word vars are X_f0 and x_f1]. But so do
+ the ones in op-2.h and op-1.h. */
#define _FP_FRAC_COPY_1_4(D, S) (D##_f = S##_f[0])
#define _FP_FRAC_COPY_2_4(D, S) \
while (0)
/* Assembly/disassembly for converting to/from integral types.
- * No shifting or overflow handled here.
- */
-/* Put the FP value X into r, which is an integer of size rsize. */
+ No shifting or overflow handled here. */
+/* Put the FP value X into r, which is an integer of size rsize. */
#define _FP_FRAC_ASSEMBLE_4(r, X, rsize) \
do \
{ \
} \
else \
{ \
- /* I'm feeling lazy so we deal with int == 3words (implausible)*/ \
- /* and int == 4words as a single case. */ \
+ /* I'm feeling lazy so we deal with int == 3words \
+ (implausible) and int == 4words as a single case. */ \
r = X##_f[3]; \
r = (rsize <= _FP_W_TYPE_SIZE ? 0 : r << _FP_W_TYPE_SIZE); \
r += X##_f[2]; \
while (0)
/* "No disassemble Number Five!" */
-/* move an integer of size rsize into X's fractional part. We rely on
- * the _f[] array consisting of words of size _FP_W_TYPE_SIZE to avoid
- * having to mask the values we store into it.
- */
+/* Move an integer of size rsize into X's fractional part. We rely on
+ the _f[] array consisting of words of size _FP_W_TYPE_SIZE to avoid
+ having to mask the values we store into it. */
#define _FP_FRAC_DISASSEMBLE_4(X, r, rsize) \
do \
{ \
<http://www.gnu.org/licenses/>. */
/* We need just a few things from here for op-4, if we ever need some
- other macros, they can be added. */
+ other macros, they can be added. */
#define _FP_FRAC_DECL_8(X) _FP_W_TYPE X##_f[8]
#define _FP_FRAC_HIGH_8(X) (X##_f[7])
#define _FP_FRAC_LOW_8(X) (X##_f[0])
/* Right shift with sticky-lsb.
- * What this actually means is that we do a standard right-shift,
- * but that if any of the bits that fall off the right hand side
- * were one then we always set the LSbit.
- */
+ What this actually means is that we do a standard right-shift,
+ but that if any of the bits that fall off the right hand side
+ were one then we always set the LSbit. */
#define _FP_FRAC_SRS_8(X, N, size) \
do \
{ \
} \
for (; _FP_FRAC_SRS_8_i < 8; ++_FP_FRAC_SRS_8_i) \
X##_f[_FP_FRAC_SRS_8_i] = 0; \
- /* don't fix the LSB until the very end when we're sure f[0] is \
- stable */ \
+ /* Don't fix the LSB until the very end when we're sure f[0] is \
+ stable. */ \
X##_f[0] |= (_FP_FRAC_SRS_8_s != 0); \
} \
while (0)
? (_FP_FRAC_HIGH_##fs (X) & _FP_QNANBIT_SH_##fs) \
: !(_FP_FRAC_HIGH_##fs (X) & _FP_QNANBIT_SH_##fs))
-/*
- * Finish truly unpacking a native fp value by classifying the kind
- * of fp value and normalizing both the exponent and the fraction.
- */
+/* Finish truly unpacking a native fp value by classifying the kind
+ of fp value and normalizing both the exponent and the fraction. */
#define _FP_UNPACK_CANONICAL(fs, wc, X) \
do \
X##_c = FP_CLS_ZERO; \
else \
{ \
- /* a denormalized number */ \
+ /* A denormalized number. */ \
_FP_I_TYPE _FP_UNPACK_CANONICAL_shift; \
_FP_FRAC_CLZ_##wc (_FP_UNPACK_CANONICAL_shift, \
X); \
else \
{ \
X##_c = FP_CLS_NAN; \
- /* Check for signaling NaN */ \
+ /* Check for signaling NaN. */ \
if (_FP_FRAC_SNANP (fs, X)) \
FP_SET_EXCEPTION (FP_EX_INVALID); \
} \
} \
while (0)
-/*
- * Before packing the bits back into the native fp result, take care
- * of such mundane things as rounding and overflow. Also, for some
- * kinds of fp values, the original parts may not have been fully
- * extracted -- but that is ok, we can regenerate them now.
- */
+/* Before packing the bits back into the native fp result, take care
+ of such mundane things as rounding and overflow. Also, for some
+ kinds of fp values, the original parts may not have been fully
+ extracted -- but that is ok, we can regenerate them now. */
#define _FP_PACK_CANONICAL(fs, wc, X) \
do \
_FP_FRAC_SRL_##wc (X, _FP_WORKBITS); \
if (X##_e >= _FP_EXPMAX_##fs) \
{ \
- /* overflow */ \
+ /* Overflow. */ \
switch (FP_ROUNDMODE) \
{ \
case FP_RND_NEAREST: \
} \
if (X##_c == FP_CLS_INF) \
{ \
- /* Overflow to infinity */ \
+ /* Overflow to infinity. */ \
X##_e = _FP_EXPMAX_##fs; \
_FP_FRAC_SET_##wc (X, _FP_ZEROFRAC_##wc); \
} \
else \
{ \
- /* Overflow to maximum normal */ \
+ /* Overflow to maximum normal. */ \
X##_e = _FP_EXPMAX_##fs - 1; \
_FP_FRAC_SET_##wc (X, _FP_MAXFRAC_##wc); \
} \
} \
else \
{ \
- /* we've got a denormalized number */ \
+ /* We've got a denormalized number. */ \
int _FP_PACK_CANONICAL_is_tiny = 1; \
if (_FP_TININESS_AFTER_ROUNDING && X##_e == 0) \
{ \
} \
else \
{ \
- /* underflow to zero */ \
+ /* Underflow to zero. */ \
X##_e = 0; \
if (!_FP_FRAC_ZEROP_##wc (X)) \
{ \
while (0)
/* This one accepts raw argument and not cooked, returns
- * 1 if X is a signaling NaN.
- */
+ 1 if X is a signaling NaN. */
#define _FP_ISSIGNAN(fs, wc, X) \
({ \
int _FP_ISSIGNAN_ret = 0; \
while (0)
-/*
- * Main negation routine. The input value is raw.
- */
+/* Main negation routine. The input value is raw. */
#define _FP_NEG(fs, wc, R, X) \
do \
while (0)
-/*
- * Main multiplication routine. The input values should be cooked.
- */
+/* Main multiplication routine. The input values should be cooked. */
#define _FP_MUL(fs, wc, R, X, Y) \
do \
while (0)
-/*
- * Main division routine. The input values should be cooked.
- */
+/* Main division routine. The input values should be cooked. */
#define _FP_DIV(fs, wc, R, X, Y) \
do \
while (0)
-/*
- * Main differential comparison routine. The inputs should be raw not
- * cooked. The return is -1,0,1 for normal values, 2 otherwise.
- */
+/* Main differential comparison routine. The inputs should be raw not
+ cooked. The return is -1,0,1 for normal values, 2 otherwise. */
#define _FP_CMP(fs, wc, ret, X, Y, un) \
do \
{ \
- /* NANs are unordered */ \
+ /* NANs are unordered. */ \
if ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc (X)) \
|| (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc (Y))) \
{ \
#define _FP_CMP_EQ(fs, wc, ret, X, Y) \
do \
{ \
- /* NANs are unordered */ \
+ /* NANs are unordered. */ \
if ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc (X)) \
|| (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc (Y))) \
{ \
} \
while (0)
-/*
- * Main square root routine. The input value should be cooked.
- */
+/* Main square root routine. The input value should be cooked. */
#define _FP_SQRT(fs, wc, R, X) \
do \
} \
while (0)
-/*
- * Convert from FP to integer. Input is raw.
- */
+/* Convert from FP to integer. Input is raw. */
/* RSIGNED can have following values:
- * 0: the number is required to be 0..(2^rsize)-1, if not, NV is set plus
- * the result is either 0 or (2^rsize)-1 depending on the sign in such
- * case.
- * 1: the number is required to be -(2^(rsize-1))..(2^(rsize-1))-1, if not,
- * NV is set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
- * depending on the sign in such case.
- * -1: the number is required to be -(2^(rsize-1))..(2^rsize)-1, if not, NV is
- * set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
- * depending on the sign in such case.
- */
+ 0: the number is required to be 0..(2^rsize)-1, if not, NV is set plus
+ the result is either 0 or (2^rsize)-1 depending on the sign in such
+ case.
+ 1: the number is required to be -(2^(rsize-1))..(2^(rsize-1))-1, if not,
+ NV is set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
+ depending on the sign in such case.
+ -1: the number is required to be -(2^(rsize-1))..(2^rsize)-1, if not, NV is
+ set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
+ depending on the sign in such case. */
#define _FP_TO_INT(fs, wc, r, X, rsize, rsigned) \
do \
{ \
} \
while (0)
-/*
- * Helper primitives.
- */
+/* Helper primitives. */
/* Count leading zeros in a word. */
# include "sfp-machine.h"
#endif
-/* Allow sfp-machine to have its own byte order definitions. */
+/* Allow sfp-machine to have its own byte order definitions. */
#ifndef __BYTE_ORDER
# ifdef _LIBC
# include <endian.h>
# define FP_ROUNDMODE FP_RND_NEAREST
#endif
-/* By default don't care about exceptions. */
+/* By default don't care about exceptions. */
#ifndef FP_EX_INVALID
# define FP_EX_INVALID 0
#endif
#ifndef FP_INHIBIT_RESULTS
/* By default we write the results always.
- * sfp-machine may override this and e.g.
- * check if some exceptions are unmasked
- * and inhibit it in such a case.
- */
+ sfp-machine may override this and e.g.
+ check if some exceptions are unmasked
+ and inhibit it in such a case. */
# define FP_INHIBIT_RESULTS 0
#endif