sfp-machine.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Machine-dependent software floating-point definitions.
  2. S/390 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),
  7. David S. Miller (davem@redhat.com) and
  8. Peter Maydell (pmaydell@chiark.greenend.org.uk).
  9. The GNU C Library is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU Library General Public License as
  11. published by the Free Software Foundation; either version 2 of the
  12. License, or (at your option) any later version.
  13. The GNU C Library is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. Library General Public License for more details.
  17. You should have received a copy of the GNU Library General Public
  18. License along with the GNU C Library; see the file COPYING.LIB. If
  19. not, write to the Free Software Foundation, Inc.,
  20. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  21. #ifndef _SFP_MACHINE_H
  22. #define _SFP_MACHINE_H
  23. #include <linux/config.h>
  24. #define _FP_W_TYPE_SIZE 32
  25. #define _FP_W_TYPE unsigned long
  26. #define _FP_WS_TYPE signed long
  27. #define _FP_I_TYPE long
  28. #define _FP_MUL_MEAT_S(R,X,Y) \
  29. _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
  30. #define _FP_MUL_MEAT_D(R,X,Y) \
  31. _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  32. #define _FP_MUL_MEAT_Q(R,X,Y) \
  33. _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  34. #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y)
  35. #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
  36. #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
  37. #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
  38. #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
  39. #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
  40. #define _FP_NANSIGN_S 0
  41. #define _FP_NANSIGN_D 0
  42. #define _FP_NANSIGN_Q 0
  43. #define _FP_KEEPNANFRACP 1
  44. /*
  45. * If one NaN is signaling and the other is not,
  46. * we choose that one, otherwise we choose X.
  47. */
  48. #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
  49. do { \
  50. if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
  51. && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
  52. { \
  53. R##_s = Y##_s; \
  54. _FP_FRAC_COPY_##wc(R,Y); \
  55. } \
  56. else \
  57. { \
  58. R##_s = X##_s; \
  59. _FP_FRAC_COPY_##wc(R,X); \
  60. } \
  61. R##_c = FP_CLS_NAN; \
  62. } while (0)
  63. /* Some assembly to speed things up. */
  64. #define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) ({ \
  65. unsigned int __r2 = (x2) + (y2); \
  66. unsigned int __r1 = (x1); \
  67. unsigned int __r0 = (x0); \
  68. __asm__ (" alr %2,%3\n" \
  69. " brc 12,0f\n" \
  70. " lhi 0,1\n" \
  71. " alr %1,0\n" \
  72. " brc 12,0f\n" \
  73. " alr %0,0\n" \
  74. "0:" \
  75. : "+&d" (__r2), "+&d" (__r1), "+&d" (__r0) \
  76. : "d" (y0), "i" (1) : "cc", "0" ); \
  77. __asm__ (" alr %1,%2\n" \
  78. " brc 12,0f\n" \
  79. " ahi %0,1\n" \
  80. "0:" \
  81. : "+&d" (__r2), "+&d" (__r1) \
  82. : "d" (y1) : "cc" ); \
  83. (r2) = __r2; \
  84. (r1) = __r1; \
  85. (r0) = __r0; \
  86. })
  87. #define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) ({ \
  88. unsigned int __r2 = (x2) - (y2); \
  89. unsigned int __r1 = (x1); \
  90. unsigned int __r0 = (x0); \
  91. __asm__ (" slr %2,%3\n" \
  92. " brc 3,0f\n" \
  93. " lhi 0,1\n" \
  94. " slr %1,0\n" \
  95. " brc 3,0f\n" \
  96. " slr %0,0\n" \
  97. "0:" \
  98. : "+&d" (__r2), "+&d" (__r1), "+&d" (__r0) \
  99. : "d" (y0) : "cc", "0" ); \
  100. __asm__ (" slr %1,%2\n" \
  101. " brc 3,0f\n" \
  102. " ahi %0,-1\n" \
  103. "0:" \
  104. : "+&d" (__r2), "+&d" (__r1) \
  105. : "d" (y1) : "cc" ); \
  106. (r2) = __r2; \
  107. (r1) = __r1; \
  108. (r0) = __r0; \
  109. })
  110. #define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) __FP_FRAC_SUB_3(x2,x1,x0,x2,x1,x0,y2,y1,y0)
  111. /* Obtain the current rounding mode. */
  112. #define FP_ROUNDMODE mode
  113. /* Exception flags. */
  114. #define FP_EX_INVALID 0x800000
  115. #define FP_EX_DIVZERO 0x400000
  116. #define FP_EX_OVERFLOW 0x200000
  117. #define FP_EX_UNDERFLOW 0x100000
  118. #define FP_EX_INEXACT 0x080000
  119. /* We write the results always */
  120. #define FP_INHIBIT_RESULTS 0
  121. #endif