^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* Software floating-point emulation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) Definitions for IEEE Single Precision.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) This file is part of the GNU C Library.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Contributed by Richard Henderson (rth@cygnus.com),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Jakub Jelinek (jj@ultra.linux.cz),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) David S. Miller (davem@redhat.com) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) Peter Maydell (pmaydell@chiark.greenend.org.uk).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) The GNU C Library is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) modify it under the terms of the GNU Library General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) published by the Free Software Foundation; either version 2 of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) The GNU C Library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Library General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) You should have received a copy of the GNU Library General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) License along with the GNU C Library; see the file COPYING.LIB. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) not, write to the Free Software Foundation, Inc.,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #ifndef __MATH_EMU_SINGLE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define __MATH_EMU_SINGLE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #if _FP_W_TYPE_SIZE < 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #error "Here's a nickel kid. Go buy yourself a real computer."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define _FP_FRACBITS_S 24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define _FP_FRACXBITS_S (_FP_W_TYPE_SIZE - _FP_FRACBITS_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define _FP_WFRACXBITS_S (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define _FP_EXPBITS_S 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define _FP_EXPBIAS_S 127
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define _FP_EXPMAX_S 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) chosen by the target machine. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) union _FP_UNION_S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) float flt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #if __BYTE_ORDER == __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned sign : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned exp : _FP_EXPBITS_S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned exp : _FP_EXPBITS_S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) unsigned sign : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) } bits __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define FP_DECL_S(X) _FP_DECL(1,X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define FP_PACK_RAW_SP(val,X) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (!FP_INHIBIT_RESULTS) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) _FP_PACK_RAW_1_P(S,val,X); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define FP_UNPACK_S(X,val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) _FP_UNPACK_RAW_1(S,X,val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) _FP_UNPACK_CANONICAL(S,1,X); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define FP_UNPACK_SP(X,val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) _FP_UNPACK_RAW_1_P(S,X,val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) _FP_UNPACK_CANONICAL(S,1,X); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define FP_PACK_S(val,X) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) _FP_PACK_CANONICAL(S,1,X); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) _FP_PACK_RAW_1(S,val,X); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define FP_PACK_SP(val,X) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) _FP_PACK_CANONICAL(S,1,X); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) if (!FP_INHIBIT_RESULTS) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) _FP_PACK_RAW_1_P(S,val,X); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define FP_TO_INT_ROUND_S(r,X,rsz,rsg) _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif /* __MATH_EMU_SINGLE_H__ */