single.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Software floating-point emulation.
  2. Definitions for IEEE Single Precision.
  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 __MATH_EMU_SINGLE_H__
  22. #define __MATH_EMU_SINGLE_H__
  23. #if _FP_W_TYPE_SIZE < 32
  24. #error "Here's a nickel kid. Go buy yourself a real computer."
  25. #endif
  26. #define _FP_FRACBITS_S 24
  27. #define _FP_FRACXBITS_S (_FP_W_TYPE_SIZE - _FP_FRACBITS_S)
  28. #define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
  29. #define _FP_WFRACXBITS_S (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S)
  30. #define _FP_EXPBITS_S 8
  31. #define _FP_EXPBIAS_S 127
  32. #define _FP_EXPMAX_S 255
  33. #define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
  34. #define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
  35. #define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
  36. /* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
  37. chosen by the target machine. */
  38. union _FP_UNION_S
  39. {
  40. float flt;
  41. struct {
  42. #if __BYTE_ORDER == __BIG_ENDIAN
  43. unsigned sign : 1;
  44. unsigned exp : _FP_EXPBITS_S;
  45. unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
  46. #else
  47. unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
  48. unsigned exp : _FP_EXPBITS_S;
  49. unsigned sign : 1;
  50. #endif
  51. } bits __attribute__((packed));
  52. };
  53. #define FP_DECL_S(X) _FP_DECL(1,X)
  54. #define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
  55. #define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
  56. #define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
  57. #define FP_PACK_RAW_SP(val,X) \
  58. do { \
  59. if (!FP_INHIBIT_RESULTS) \
  60. _FP_PACK_RAW_1_P(S,val,X); \
  61. } while (0)
  62. #define FP_UNPACK_S(X,val) \
  63. do { \
  64. _FP_UNPACK_RAW_1(S,X,val); \
  65. _FP_UNPACK_CANONICAL(S,1,X); \
  66. } while (0)
  67. #define FP_UNPACK_SP(X,val) \
  68. do { \
  69. _FP_UNPACK_RAW_1_P(S,X,val); \
  70. _FP_UNPACK_CANONICAL(S,1,X); \
  71. } while (0)
  72. #define FP_PACK_S(val,X) \
  73. do { \
  74. _FP_PACK_CANONICAL(S,1,X); \
  75. _FP_PACK_RAW_1(S,val,X); \
  76. } while (0)
  77. #define FP_PACK_SP(val,X) \
  78. do { \
  79. _FP_PACK_CANONICAL(S,1,X); \
  80. if (!FP_INHIBIT_RESULTS) \
  81. _FP_PACK_RAW_1_P(S,val,X); \
  82. } while (0)
  83. #define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X)
  84. #define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
  85. #define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
  86. #define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
  87. #define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
  88. #define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
  89. #define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
  90. #define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
  91. #define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
  92. #define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
  93. #define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
  94. #define FP_TO_INT_ROUND_S(r,X,rsz,rsg) _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
  95. #define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
  96. #define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X)
  97. #define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X)
  98. #endif /* __MATH_EMU_SINGLE_H__ */