Back to home page

OSCL-LXR

 
 

    


0001 /* Machine-dependent software floating-point definitions.
0002    Sparc userland (_Q_*) version.
0003    Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
0004    This file is part of the GNU C Library.
0005    Contributed by Richard Henderson (rth@cygnus.com),
0006           Jakub Jelinek (jj@ultra.linux.cz),
0007           David S. Miller (davem@redhat.com) and
0008           Peter Maydell (pmaydell@chiark.greenend.org.uk).
0009 
0010    The GNU C Library is free software; you can redistribute it and/or
0011    modify it under the terms of the GNU Library General Public License as
0012    published by the Free Software Foundation; either version 2 of the
0013    License, or (at your option) any later version.
0014 
0015    The GNU C Library is distributed in the hope that it will be useful,
0016    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018    Library General Public License for more details.
0019 
0020    You should have received a copy of the GNU Library General Public
0021    License along with the GNU C Library; see the file COPYING.LIB.  If
0022    not, write to the Free Software Foundation, Inc.,
0023    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
0024 
0025 #ifndef _SFP_MACHINE_H
0026 #define _SFP_MACHINE_H
0027 
0028 
0029 #define _FP_W_TYPE_SIZE     32
0030 #define _FP_W_TYPE      unsigned long
0031 #define _FP_WS_TYPE     signed long
0032 #define _FP_I_TYPE      long
0033 
0034 #define _FP_MUL_MEAT_S(R,X,Y)                   \
0035   _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
0036 #define _FP_MUL_MEAT_D(R,X,Y)                   \
0037   _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
0038 #define _FP_MUL_MEAT_Q(R,X,Y)                   \
0039   _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
0040 
0041 #define _FP_DIV_MEAT_S(R,X,Y)   _FP_DIV_MEAT_1_udiv(S,R,X,Y)
0042 #define _FP_DIV_MEAT_D(R,X,Y)   _FP_DIV_MEAT_2_udiv(D,R,X,Y)
0043 #define _FP_DIV_MEAT_Q(R,X,Y)   _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
0044 
0045 #define _FP_NANFRAC_S       ((_FP_QNANBIT_S << 1) - 1)
0046 #define _FP_NANFRAC_D       ((_FP_QNANBIT_D << 1) - 1), -1
0047 #define _FP_NANFRAC_Q       ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
0048 #define _FP_NANSIGN_S       0
0049 #define _FP_NANSIGN_D       0
0050 #define _FP_NANSIGN_Q       0
0051 
0052 #define _FP_KEEPNANFRACP 1
0053 
0054 /* If one NaN is signaling and the other is not,
0055  * we choose that one, otherwise we choose X.
0056  */
0057 /* For _Qp_* and _Q_*, this should prefer X, for
0058  * CPU instruction emulation this should prefer Y.
0059  * (see SPAMv9 B.2.2 section).
0060  */
0061 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)          \
0062   do {                              \
0063     if ((_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)      \
0064     && !(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
0065       {                             \
0066     R##_s = X##_s;                      \
0067     _FP_FRAC_COPY_##wc(R,X);                \
0068       }                             \
0069     else                            \
0070       {                             \
0071     R##_s = Y##_s;                      \
0072     _FP_FRAC_COPY_##wc(R,Y);                \
0073       }                             \
0074     R##_c = FP_CLS_NAN;                     \
0075   } while (0)
0076 
0077 /* Some assembly to speed things up. */
0078 #define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0)         \
0079   __asm__ ("addcc %r7,%8,%2\n\t"                    \
0080        "addxcc %r5,%6,%1\n\t"                   \
0081        "addx %r3,%4,%0\n"                       \
0082        : "=r" (r2),                         \
0083          "=&r" (r1),                        \
0084          "=&r" (r0)                         \
0085        : "%rJ" ((USItype)(x2)),                 \
0086          "rI" ((USItype)(y2)),                  \
0087          "%rJ" ((USItype)(x1)),                 \
0088          "rI" ((USItype)(y1)),                  \
0089          "%rJ" ((USItype)(x0)),                 \
0090          "rI" ((USItype)(y0))                   \
0091        : "cc")
0092 
0093 #define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0)         \
0094   __asm__ ("subcc %r7,%8,%2\n\t"                    \
0095         "subxcc %r5,%6,%1\n\t"                  \
0096         "subx %r3,%4,%0\n"                      \
0097        : "=r" (r2),                         \
0098          "=&r" (r1),                        \
0099          "=&r" (r0)                         \
0100        : "%rJ" ((USItype)(x2)),                 \
0101          "rI" ((USItype)(y2)),                  \
0102          "%rJ" ((USItype)(x1)),                 \
0103          "rI" ((USItype)(y1)),                  \
0104          "%rJ" ((USItype)(x0)),                 \
0105          "rI" ((USItype)(y0))                   \
0106        : "cc")
0107 
0108 #define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)        \
0109   do {                                  \
0110     /* We need to fool gcc,  as we need to pass more than 10        \
0111        input/outputs.  */                       \
0112     register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2");        \
0113     __asm__ __volatile__ (                      \
0114         "addcc %r8,%9,%1\n\t"                   \
0115         "addxcc %r6,%7,%0\n\t"                  \
0116         "addxcc %r4,%5,%%g2\n\t"                    \
0117         "addx %r2,%3,%%g1\n\t"                  \
0118        : "=&r" (r1),                        \
0119          "=&r" (r0)                         \
0120        : "%rJ" ((USItype)(x3)),                 \
0121          "rI" ((USItype)(y3)),                  \
0122          "%rJ" ((USItype)(x2)),                 \
0123          "rI" ((USItype)(y2)),                  \
0124          "%rJ" ((USItype)(x1)),                 \
0125          "rI" ((USItype)(y1)),                  \
0126          "%rJ" ((USItype)(x0)),                 \
0127          "rI" ((USItype)(y0))                   \
0128        : "cc", "g1", "g2");                     \
0129     __asm__ __volatile__ ("" : "=r" (_t1), "=r" (_t2));         \
0130     r3 = _t1; r2 = _t2;                         \
0131   } while (0)
0132 
0133 #define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)        \
0134   do {                                  \
0135     /* We need to fool gcc,  as we need to pass more than 10        \
0136        input/outputs.  */                       \
0137     register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2");        \
0138     __asm__ __volatile__ (                      \
0139         "subcc %r8,%9,%1\n\t"                   \
0140         "subxcc %r6,%7,%0\n\t"                  \
0141         "subxcc %r4,%5,%%g2\n\t"                    \
0142         "subx %r2,%3,%%g1\n\t"                  \
0143        : "=&r" (r1),                        \
0144          "=&r" (r0)                         \
0145        : "%rJ" ((USItype)(x3)),                 \
0146          "rI" ((USItype)(y3)),                  \
0147          "%rJ" ((USItype)(x2)),                 \
0148          "rI" ((USItype)(y2)),                  \
0149          "%rJ" ((USItype)(x1)),                 \
0150          "rI" ((USItype)(y1)),                  \
0151          "%rJ" ((USItype)(x0)),                 \
0152          "rI" ((USItype)(y0))                   \
0153        : "cc", "g1", "g2");                     \
0154     __asm__ __volatile__ ("" : "=r" (_t1), "=r" (_t2));         \
0155     r3 = _t1; r2 = _t2;                         \
0156   } while (0)
0157 
0158 #define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) __FP_FRAC_SUB_3(x2,x1,x0,x2,x1,x0,y2,y1,y0)
0159 
0160 #define __FP_FRAC_DEC_4(x3,x2,x1,x0,y3,y2,y1,y0) __FP_FRAC_SUB_4(x3,x2,x1,x0,x3,x2,x1,x0,y3,y2,y1,y0)
0161 
0162 #define __FP_FRAC_ADDI_4(x3,x2,x1,x0,i)                 \
0163   __asm__ ("addcc %3,%4,%3\n\t"                     \
0164        "addxcc %2,%%g0,%2\n\t"                  \
0165        "addxcc %1,%%g0,%1\n\t"                  \
0166        "addx %0,%%g0,%0\n\t"                    \
0167        : "=&r" (x3),                        \
0168          "=&r" (x2),                        \
0169          "=&r" (x1),                        \
0170          "=&r" (x0)                         \
0171        : "rI" ((USItype)(i)),                   \
0172          "0" ((USItype)(x3)),                   \
0173          "1" ((USItype)(x2)),                   \
0174          "2" ((USItype)(x1)),                   \
0175          "3" ((USItype)(x0))                    \
0176        : "cc")
0177 
0178 #ifndef CONFIG_SMP
0179 extern struct task_struct *last_task_used_math;
0180 #endif
0181 
0182 /* Obtain the current rounding mode. */
0183 #ifndef FP_ROUNDMODE
0184 #ifdef CONFIG_SMP
0185 #define FP_ROUNDMODE    ((current->thread.fsr >> 30) & 0x3)
0186 #else
0187 #define FP_ROUNDMODE    ((last_task_used_math->thread.fsr >> 30) & 0x3)
0188 #endif
0189 #endif
0190 
0191 /* Exception flags. */
0192 #define FP_EX_INVALID       (1 << 4)
0193 #define FP_EX_OVERFLOW      (1 << 3)
0194 #define FP_EX_UNDERFLOW     (1 << 2)
0195 #define FP_EX_DIVZERO       (1 << 1)
0196 #define FP_EX_INEXACT       (1 << 0)
0197 
0198 #define FP_HANDLE_EXCEPTIONS return _fex
0199 
0200 #ifdef CONFIG_SMP
0201 #define FP_INHIBIT_RESULTS ((current->thread.fsr >> 23) & _fex)
0202 #else
0203 #define FP_INHIBIT_RESULTS ((last_task_used_math->thread.fsr >> 23) & _fex)
0204 #endif
0205 
0206 #ifdef CONFIG_SMP
0207 #define FP_TRAPPING_EXCEPTIONS ((current->thread.fsr >> 23) & 0x1f)
0208 #else
0209 #define FP_TRAPPING_EXCEPTIONS ((last_task_used_math->thread.fsr >> 23) & 0x1f)
0210 #endif
0211 
0212 #endif