sfp-machine.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* softfp machine description for PA-RISC.
  2. Copyright (C) 2009-2022 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. #ifdef __LP64__
  20. #define _FP_W_TYPE_SIZE 64
  21. #define _FP_W_TYPE unsigned long
  22. #define _FP_WS_TYPE signed long
  23. #define _FP_I_TYPE long
  24. typedef int TItype __attribute__ ((mode (TI)));
  25. typedef unsigned int UTItype __attribute__ ((mode (TI)));
  26. #define TI_BITS (__CHAR_BIT__ * (int) sizeof (TItype))
  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_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  31. #define _FP_MUL_MEAT_Q(R,X,Y) \
  32. _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  33. #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
  34. #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
  35. #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
  36. #define _FP_NANFRAC_S (_FP_QNANBIT_S - 1)
  37. #define _FP_NANFRAC_D (_FP_QNANBIT_D - 1)
  38. #define _FP_NANFRAC_Q (_FP_QNANBIT_Q - 1), -1
  39. #else
  40. #define _FP_W_TYPE_SIZE 32
  41. #define _FP_W_TYPE unsigned int
  42. #define _FP_WS_TYPE signed int
  43. #define _FP_I_TYPE int
  44. #define _FP_MUL_MEAT_S(R,X,Y) \
  45. _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
  46. #define _FP_MUL_MEAT_D(R,X,Y) \
  47. _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  48. #define _FP_MUL_MEAT_Q(R,X,Y) \
  49. _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  50. #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
  51. #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
  52. #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
  53. #define _FP_NANFRAC_S (_FP_QNANBIT_S - 1)
  54. #define _FP_NANFRAC_D (_FP_QNANBIT_D - 1), -1
  55. #define _FP_NANFRAC_Q (_FP_QNANBIT_Q - 1), -1, -1, -1
  56. #endif
  57. /* The type of the result of a floating point comparison. This must
  58. match __libgcc_cmp_return__ in GCC for the target. */
  59. typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
  60. #define CMPtype __gcc_CMPtype
  61. #define _FP_NANSIGN_S 0
  62. #define _FP_NANSIGN_D 0
  63. #define _FP_NANSIGN_Q 0
  64. #define _FP_KEEPNANFRACP 1
  65. #define _FP_QNANNEGATEDP 1
  66. /* Comment from glibc: */
  67. /* From my experiments it seems X is chosen unless one of the
  68. NaNs is sNaN, in which case the result is NANSIGN/NANFRAC. */
  69. # define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
  70. do { \
  71. if ((_FP_FRAC_HIGH_RAW_##fs(X) | \
  72. _FP_FRAC_HIGH_RAW_##fs(Y)) & _FP_QNANBIT_##fs) \
  73. { \
  74. R##_s = _FP_NANSIGN_##fs; \
  75. _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
  76. } \
  77. else \
  78. { \
  79. R##_s = X##_s; \
  80. _FP_FRAC_COPY_##wc(R,X); \
  81. } \
  82. R##_c = FP_CLS_NAN; \
  83. } while (0)
  84. #define FP_RND_NEAREST (0 << 9)
  85. #define FP_RND_ZERO (1 << 9)
  86. #define FP_RND_PINF (2 << 9)
  87. #define FP_RND_MINF (3 << 9)
  88. #define FP_RND_MASK (3 << 9)
  89. #define FP_EX_INEXACT 0x01
  90. #define FP_EX_UNDERFLOW 0x02
  91. #define FP_EX_OVERFLOW 0x04
  92. #define FP_EX_DIVZERO 0x08
  93. #define FP_EX_INVALID 0x10
  94. #define FP_EX_ALL 0x1F
  95. #define FP_EX_SHIFT 27
  96. #define _FP_TININESS_AFTER_ROUNDING 1
  97. #define _FP_DECL_EX \
  98. unsigned int _fcsr __attribute__ ((unused)) = FP_RND_NEAREST
  99. /* Get floating-point status. */
  100. #define _FPU_GETCW(cw) \
  101. ({ \
  102. union { unsigned long long __fpreg; \
  103. unsigned int __halfreg[2]; } __fullfp; \
  104. /* Get the current status word. */ \
  105. __asm__ ("fstd %%fr0,0(%1)\n\t" \
  106. "fldd 0(%1),%%fr0\n\t" \
  107. : "=m" (__fullfp.__fpreg) \
  108. : "r" (&__fullfp.__fpreg) \
  109. : "%r0"); \
  110. cw = __fullfp.__halfreg[0]; \
  111. })
  112. #define FP_INIT_ROUNDMODE _FPU_GETCW(_fcsr)
  113. #define FP_ROUNDMODE (_fcsr & FP_RND_MASK)
  114. #define FP_TRAPPING_EXCEPTIONS (_fcsr & FP_EX_ALL)
  115. void __sfp_handle_exceptions (int);
  116. #define FP_HANDLE_EXCEPTIONS \
  117. do { \
  118. if (__builtin_expect (_fex, 0)) \
  119. __sfp_handle_exceptions (_fex); \
  120. } while (0)
  121. #define __LITTLE_ENDIAN 1234
  122. #define __BIG_ENDIAN 4321
  123. #define __BYTE_ORDER __BIG_ENDIAN
  124. /* Define ALIASNAME as a strong alias for NAME. */
  125. # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
  126. # define _strong_alias(name, aliasname) \
  127. extern __typeof (name) aliasname __attribute__ ((alias (#name)));