chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / ports / sysdeps / alpha / soft-fp / sfp-machine.h
1 /* Machine-dependent software floating-point definitions.
2    Alpha userland IEEE 128-bit version.
3    Copyright (C) 2004 Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5    Contributed by Richard Henderson (rth@cygnus.com),
6                   Jakub Jelinek (jj@ultra.linux.cz) and
7                   David S. Miller (davem@redhat.com).
8
9    The GNU C Library is free software; you can redistribute it and/or
10    modify it under the terms of the GNU Lesser General Public
11    License as published by the Free Software Foundation; either
12    version 2.1 of the License, or (at your option) any later version.
13
14    The GNU C Library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    Lesser General Public License for more details.
18
19    You should have received a copy of the GNU Lesser General Public
20    License along with the GNU C Library; if not, write to the Free
21    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22    02111-1307 USA.  */
23
24 #include <fenv_libc.h>
25
26 #define _FP_W_TYPE_SIZE         64
27 #define _FP_W_TYPE              unsigned long
28 #define _FP_WS_TYPE             signed long
29 #define _FP_I_TYPE              long
30
31 #define _FP_MUL_MEAT_S(R,X,Y)                                   \
32   _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
33 #define _FP_MUL_MEAT_D(R,X,Y)                                   \
34   _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
35 #define _FP_MUL_MEAT_Q(R,X,Y)                                   \
36   _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
37
38 #define _FP_DIV_MEAT_S(R,X,Y)   _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
39 #define _FP_DIV_MEAT_D(R,X,Y)   _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
40 #define _FP_DIV_MEAT_Q(R,X,Y)   _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
41
42 #define _FP_NANFRAC_S           ((_FP_QNANBIT_S << 1) - 1)
43 #define _FP_NANFRAC_D           ((_FP_QNANBIT_D << 1) - 1)
44 #define _FP_NANFRAC_Q           ((_FP_QNANBIT_Q << 1) - 1), -1
45 #define _FP_NANSIGN_S           0
46 #define _FP_NANSIGN_D           0
47 #define _FP_NANSIGN_Q           0
48
49 #define _FP_KEEPNANFRACP 1
50
51 /* Alpha Architecture Handbook, 4.7.10.4 sez that we should prefer any
52    type of NaN in Fb, then Fa.  */
53 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)                      \
54   do {                                                          \
55     R##_s = Y##_s;                                              \
56     _FP_FRAC_COPY_##wc(R,X);                                    \
57     R##_c = FP_CLS_NAN;                                         \
58   } while (0)
59
60 /* Rounding mode settings.  */
61 #define FP_RND_NEAREST          FE_TONEAREST
62 #define FP_RND_ZERO             FE_TOWARDZERO
63 #define FP_RND_PINF             FE_UPWARD
64 #define FP_RND_MINF             FE_DOWNWARD
65
66 /* Obtain the current rounding mode.  It's given as an argument to
67    all the Ots functions, with 4 meaning "dynamic".  */
68 #define FP_ROUNDMODE            _round
69
70 /* Exception flags. */
71 #define FP_EX_INVALID           FE_INVALID
72 #define FP_EX_OVERFLOW          FE_OVERFLOW
73 #define FP_EX_UNDERFLOW         FE_UNDERFLOW
74 #define FP_EX_DIVZERO           FE_DIVBYZERO
75 #define FP_EX_INEXACT           FE_INEXACT
76
77 #define FP_INIT_ROUNDMODE                                       \
78 do {                                                            \
79   if (__builtin_expect (_round == 4, 0))                        \
80     {                                                           \
81       unsigned long t;                                          \
82       __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(t));       \
83       _round = (t >> FPCR_ROUND_SHIFT) & 3;                     \
84     }                                                           \
85 } while (0)
86
87 #define FP_HANDLE_EXCEPTIONS                                    \
88 do {                                                            \
89   if (__builtin_expect (_fex, 0))                               \
90     {                                                           \
91       unsigned long t = __ieee_get_fp_control ();               \
92       __ieee_set_fp_control (t | _fex);                         \
93     }                                                           \
94 } while (0)