sfp-machine.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* Machine-dependent software floating-point definitions.
  2. Alpha userland IEEE 128-bit version.
  3. Copyright (C) 2004-2026 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library. If not, see
  15. <https://www.gnu.org/licenses/>. */
  16. #include <fenv_libc.h>
  17. #define _FP_W_TYPE_SIZE 64
  18. #define _FP_W_TYPE unsigned long
  19. #define _FP_WS_TYPE signed long
  20. #define _FP_I_TYPE long
  21. #define _FP_MUL_MEAT_S(R,X,Y) \
  22. _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
  23. #define _FP_MUL_MEAT_D(R,X,Y) \
  24. _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  25. #define _FP_MUL_MEAT_Q(R,X,Y) \
  26. _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  27. #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
  28. #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
  29. #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
  30. #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
  31. #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
  32. #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
  33. #define _FP_NANSIGN_S 0
  34. #define _FP_NANSIGN_D 0
  35. #define _FP_NANSIGN_Q 0
  36. #define _FP_KEEPNANFRACP 1
  37. #define _FP_QNANNEGATEDP 0
  38. /* Alpha Architecture Handbook, 4.7.10.4 sez that we should prefer any
  39. type of NaN in Fb, then Fa. */
  40. #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
  41. do { \
  42. R##_s = Y##_s; \
  43. _FP_FRAC_COPY_##wc(R,X); \
  44. R##_c = FP_CLS_NAN; \
  45. } while (0)
  46. /* Rounding mode settings. */
  47. #define FP_RND_NEAREST FE_TONEAREST
  48. #define FP_RND_ZERO FE_TOWARDZERO
  49. #define FP_RND_PINF FE_UPWARD
  50. #define FP_RND_MINF FE_DOWNWARD
  51. /* Obtain the current rounding mode. It's given as an argument to
  52. all the Ots functions, with 4 meaning "dynamic". */
  53. #define FP_ROUNDMODE _round
  54. /* Exception flags. */
  55. #define FP_EX_INVALID FE_INVALID
  56. #define FP_EX_OVERFLOW FE_OVERFLOW
  57. #define FP_EX_UNDERFLOW FE_UNDERFLOW
  58. #define FP_EX_DIVZERO FE_DIVBYZERO
  59. #define FP_EX_INEXACT FE_INEXACT
  60. #define _FP_TININESS_AFTER_ROUNDING 1
  61. #define FP_INIT_ROUNDMODE \
  62. do { \
  63. if (__builtin_expect (_round == 4, 0)) \
  64. { \
  65. unsigned long t; \
  66. __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(t)); \
  67. _round = (t >> FPCR_ROUND_SHIFT) & 3; \
  68. } \
  69. } while (0)
  70. /* We copy the libm function into libc for soft-fp. */
  71. extern int __feraiseexcept (int __excepts) attribute_hidden;
  72. #define FP_HANDLE_EXCEPTIONS \
  73. do { \
  74. if (__builtin_expect (_fex, 0)) \
  75. __feraiseexcept (_fex); \
  76. } while (0)
  77. #define FP_TRAPPING_EXCEPTIONS \
  78. ((__ieee_get_fp_control () & SWCR_ENABLE_MASK) << SWCR_ENABLE_SHIFT)