PageRenderTime 41ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/arch/s390/include/asm/sfp-machine.h

https://bitbucket.org/ndreys/linux-sunxi
C++ Header | 142 lines | 96 code | 15 blank | 31 comment | 4 complexity | 2d7f7484449b243a53adcec02ace7625 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  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. #define _FP_W_TYPE_SIZE 32
  24. #define _FP_W_TYPE unsigned int
  25. #define _FP_WS_TYPE signed int
  26. #define _FP_I_TYPE int
  27. #define _FP_MUL_MEAT_S(R,X,Y) \
  28. _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
  29. #define _FP_MUL_MEAT_D(R,X,Y) \
  30. _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  31. #define _FP_MUL_MEAT_Q(R,X,Y) \
  32. _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  33. #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y)
  34. #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
  35. #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
  36. #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
  37. #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
  38. #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
  39. #define _FP_NANSIGN_S 0
  40. #define _FP_NANSIGN_D 0
  41. #define _FP_NANSIGN_Q 0
  42. #define _FP_KEEPNANFRACP 1
  43. /*
  44. * If one NaN is signaling and the other is not,
  45. * we choose that one, otherwise we choose X.
  46. */
  47. #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
  48. do { \
  49. if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
  50. && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
  51. { \
  52. R##_s = Y##_s; \
  53. _FP_FRAC_COPY_##wc(R,Y); \
  54. } \
  55. else \
  56. { \
  57. R##_s = X##_s; \
  58. _FP_FRAC_COPY_##wc(R,X); \
  59. } \
  60. R##_c = FP_CLS_NAN; \
  61. } while (0)
  62. /* Some assembly to speed things up. */
  63. #define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) ({ \
  64. unsigned int __r2 = (x2) + (y2); \
  65. unsigned int __r1 = (x1); \
  66. unsigned int __r0 = (x0); \
  67. asm volatile( \
  68. " 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 volatile( \
  78. " alr %1,%2\n" \
  79. " brc 12,0f\n" \
  80. " ahi %0,1\n" \
  81. "0:" \
  82. : "+&d" (__r2), "+&d" (__r1) \
  83. : "d" (y1) : "cc"); \
  84. (r2) = __r2; \
  85. (r1) = __r1; \
  86. (r0) = __r0; \
  87. })
  88. #define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) ({ \
  89. unsigned int __r2 = (x2) - (y2); \
  90. unsigned int __r1 = (x1); \
  91. unsigned int __r0 = (x0); \
  92. asm volatile( \
  93. " slr %2,%3\n" \
  94. " brc 3,0f\n" \
  95. " lhi 0,1\n" \
  96. " slr %1,0\n" \
  97. " brc 3,0f\n" \
  98. " slr %0,0\n" \
  99. "0:" \
  100. : "+&d" (__r2), "+&d" (__r1), "+&d" (__r0) \
  101. : "d" (y0) : "cc", "0"); \
  102. asm volatile( \
  103. " slr %1,%2\n" \
  104. " brc 3,0f\n" \
  105. " ahi %0,-1\n" \
  106. "0:" \
  107. : "+&d" (__r2), "+&d" (__r1) \
  108. : "d" (y1) : "cc"); \
  109. (r2) = __r2; \
  110. (r1) = __r1; \
  111. (r0) = __r0; \
  112. })
  113. #define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) __FP_FRAC_SUB_3(x2,x1,x0,x2,x1,x0,y2,y1,y0)
  114. /* Obtain the current rounding mode. */
  115. #define FP_ROUNDMODE mode
  116. /* Exception flags. */
  117. #define FP_EX_INVALID 0x800000
  118. #define FP_EX_DIVZERO 0x400000
  119. #define FP_EX_OVERFLOW 0x200000
  120. #define FP_EX_UNDERFLOW 0x100000
  121. #define FP_EX_INEXACT 0x080000
  122. /* We write the results always */
  123. #define FP_INHIBIT_RESULTS 0
  124. #endif