/* Software floating-point emulation. Basic one-word fraction declaration and manipulation. Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson (rth@cygnus.com), Jakub Jelinek (jj@ultra.linux.cz), David S. Miller (davem@redhat.com) and Peter Maydell (pmaydell@chiark.greenend.org.uk).
The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
multiplication immediately. */
#define _FP_MUL_MEAT_1_imm(wfracbits, R, X, Y) \ do { \
R##_f = X##_f * Y##_f; \ /* Normalize since we know where the msb of the multiplicands \ were (bit B), we know that the msb of the of the product is \
at either 2B or 2B-1. */
_FP_FRAC_SRS_1(R, wfracbits-1, 2*wfracbits); \
} while (0)
/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
#define _FP_MUL_MEAT_1_wide(wfracbits, R, X, Y, doit) \ do { \
_FP_W_TYPE _Z_f0, _Z_f1; \
doit(_Z_f1, _Z_f0, X##_f, Y##_f); \ /* Normalize since we know where the msb of the multiplicands \ were (bit B), we know that the msb of the of the product is \
at either 2B or 2B-1. */
_FP_FRAC_SRS_2(_Z, wfracbits-1, 2*wfracbits); \
R##_f = _Z_f0; \
} while (0)
/* Finally, a simple widening multiply algorithm. What fun! */
/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the division immediately. Give this macro either _FP_DIV_HELP_imm for C primitives or _FP_DIV_HELP_ldiv for the ISO function. Which you
choose will depend on what the compiler does with divrem4. */
/* GCC's longlong.h defines a 2W / 1W => (1W,1W) primitive udiv_qrnnd that may be useful in this situation. This first is for a primitive that requires normalization, the second for one that does not. Look
for UDIV_NEEDS_NORMALIZATION to tell which your machine needs. */
#define _FP_DIV_MEAT_1_udiv_norm(fs, R, X, Y) \ do { \
_FP_W_TYPE _nh, _nl, _q, _r, _y; \
\ /* Normalize Y -- i.e. make the most significant bit set. */ \
_y = Y##_f << _FP_WFRACXBITS_##fs; \
\ /* Shift X op correspondingly high, that is, up one full word. */ \ if (X##_f < Y##_f) \
{ \
R##_e--; \
_nl = 0; \
_nh = X##_f; \
} \ else \
{ \
_nl = X##_f << (_FP_W_TYPE_SIZE - 1); \
_nh = X##_f >> 1; \
} \
\
udiv_qrnnd(_q, _r, _nh, _nl, _y); \
R##_f = _q | (_r != 0); \
} while (0)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.