sfp-machine_64.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Machine-dependent software floating-point definitions.
  2. Sparc64 kernel version.
  3. Copyright (C) 1997,1998,1999 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. The GNU C Library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public License as
  10. published by the Free Software Foundation; either version 2 of the
  11. License, or (at your option) any later version.
  12. The GNU C Library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Library General Public License for more details.
  16. You should have received a copy of the GNU Library General Public
  17. License along with the GNU C Library; see the file COPYING.LIB. If
  18. not, write to the Free Software Foundation, Inc.,
  19. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  20. #ifndef _SFP_MACHINE_H
  21. #define _SFP_MACHINE_H
  22. #define _FP_W_TYPE_SIZE 64
  23. #define _FP_W_TYPE unsigned long
  24. #define _FP_WS_TYPE signed long
  25. #define _FP_I_TYPE long
  26. #define _FP_MUL_MEAT_S(R,X,Y) \
  27. _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
  28. #define _FP_MUL_MEAT_D(R,X,Y) \
  29. _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  30. #define _FP_MUL_MEAT_Q(R,X,Y) \
  31. _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  32. #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
  33. #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
  34. #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
  35. #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
  36. #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
  37. #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
  38. #define _FP_NANSIGN_S 0
  39. #define _FP_NANSIGN_D 0
  40. #define _FP_NANSIGN_Q 0
  41. #define _FP_KEEPNANFRACP 1
  42. /* If one NaN is signaling and the other is not,
  43. * we choose that one, otherwise we choose X.
  44. */
  45. /* For _Qp_* and _Q_*, this should prefer X, for
  46. * CPU instruction emulation this should prefer Y.
  47. * (see SPAMv9 B.2.2 section).
  48. */
  49. #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
  50. do { \
  51. if ((_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs) \
  52. && !(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
  53. { \
  54. R##_s = X##_s; \
  55. _FP_FRAC_COPY_##wc(R,X); \
  56. } \
  57. else \
  58. { \
  59. R##_s = Y##_s; \
  60. _FP_FRAC_COPY_##wc(R,Y); \
  61. } \
  62. R##_c = FP_CLS_NAN; \
  63. } while (0)
  64. /* Obtain the current rounding mode. */
  65. #ifndef FP_ROUNDMODE
  66. #define FP_ROUNDMODE ((current_thread_info()->xfsr[0] >> 30) & 0x3)
  67. #endif
  68. /* Exception flags. */
  69. #define FP_EX_INVALID (1 << 4)
  70. #define FP_EX_OVERFLOW (1 << 3)
  71. #define FP_EX_UNDERFLOW (1 << 2)
  72. #define FP_EX_DIVZERO (1 << 1)
  73. #define FP_EX_INEXACT (1 << 0)
  74. #define FP_HANDLE_EXCEPTIONS return _fex
  75. #define FP_INHIBIT_RESULTS ((current_thread_info()->xfsr[0] >> 23) & _fex)
  76. #define FP_TRAPPING_EXCEPTIONS ((current_thread_info()->xfsr[0] >> 23) & 0x1f)
  77. #endif