162306a36Sopenharmony_ci/* Software floating-point emulation. 262306a36Sopenharmony_ci Definitions for IEEE Single Precision. 362306a36Sopenharmony_ci Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. 462306a36Sopenharmony_ci This file is part of the GNU C Library. 562306a36Sopenharmony_ci Contributed by Richard Henderson (rth@cygnus.com), 662306a36Sopenharmony_ci Jakub Jelinek (jj@ultra.linux.cz), 762306a36Sopenharmony_ci David S. Miller (davem@redhat.com) and 862306a36Sopenharmony_ci Peter Maydell (pmaydell@chiark.greenend.org.uk). 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci The GNU C Library is free software; you can redistribute it and/or 1162306a36Sopenharmony_ci modify it under the terms of the GNU Library General Public License as 1262306a36Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 1362306a36Sopenharmony_ci License, or (at your option) any later version. 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci The GNU C Library is distributed in the hope that it will be useful, 1662306a36Sopenharmony_ci but WITHOUT ANY WARRANTY; without even the implied warranty of 1762306a36Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1862306a36Sopenharmony_ci Library General Public License for more details. 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci You should have received a copy of the GNU Library General Public 2162306a36Sopenharmony_ci License along with the GNU C Library; see the file COPYING.LIB. If 2262306a36Sopenharmony_ci not, write to the Free Software Foundation, Inc., 2362306a36Sopenharmony_ci 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#ifndef __MATH_EMU_SINGLE_H__ 2662306a36Sopenharmony_ci#define __MATH_EMU_SINGLE_H__ 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#if _FP_W_TYPE_SIZE < 32 2962306a36Sopenharmony_ci#error "Here's a nickel kid. Go buy yourself a real computer." 3062306a36Sopenharmony_ci#endif 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define _FP_FRACBITS_S 24 3362306a36Sopenharmony_ci#define _FP_FRACXBITS_S (_FP_W_TYPE_SIZE - _FP_FRACBITS_S) 3462306a36Sopenharmony_ci#define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S) 3562306a36Sopenharmony_ci#define _FP_WFRACXBITS_S (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S) 3662306a36Sopenharmony_ci#define _FP_EXPBITS_S 8 3762306a36Sopenharmony_ci#define _FP_EXPBIAS_S 127 3862306a36Sopenharmony_ci#define _FP_EXPMAX_S 255 3962306a36Sopenharmony_ci#define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2)) 4062306a36Sopenharmony_ci#define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1)) 4162306a36Sopenharmony_ci#define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S)) 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci/* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be 4462306a36Sopenharmony_ci chosen by the target machine. */ 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ciunion _FP_UNION_S 4762306a36Sopenharmony_ci{ 4862306a36Sopenharmony_ci float flt; 4962306a36Sopenharmony_ci struct { 5062306a36Sopenharmony_ci#if __BYTE_ORDER == __BIG_ENDIAN 5162306a36Sopenharmony_ci unsigned sign : 1; 5262306a36Sopenharmony_ci unsigned exp : _FP_EXPBITS_S; 5362306a36Sopenharmony_ci unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0); 5462306a36Sopenharmony_ci#else 5562306a36Sopenharmony_ci unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0); 5662306a36Sopenharmony_ci unsigned exp : _FP_EXPBITS_S; 5762306a36Sopenharmony_ci unsigned sign : 1; 5862306a36Sopenharmony_ci#endif 5962306a36Sopenharmony_ci } bits __attribute__((packed)); 6062306a36Sopenharmony_ci}; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define FP_DECL_S(X) _FP_DECL(1,X) 6362306a36Sopenharmony_ci#define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val) 6462306a36Sopenharmony_ci#define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val) 6562306a36Sopenharmony_ci#define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X) 6662306a36Sopenharmony_ci#define FP_PACK_RAW_SP(val,X) \ 6762306a36Sopenharmony_ci do { \ 6862306a36Sopenharmony_ci if (!FP_INHIBIT_RESULTS) \ 6962306a36Sopenharmony_ci _FP_PACK_RAW_1_P(S,val,X); \ 7062306a36Sopenharmony_ci } while (0) 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#define FP_UNPACK_S(X,val) \ 7362306a36Sopenharmony_ci do { \ 7462306a36Sopenharmony_ci _FP_UNPACK_RAW_1(S,X,val); \ 7562306a36Sopenharmony_ci _FP_UNPACK_CANONICAL(S,1,X); \ 7662306a36Sopenharmony_ci } while (0) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define FP_UNPACK_SP(X,val) \ 7962306a36Sopenharmony_ci do { \ 8062306a36Sopenharmony_ci _FP_UNPACK_RAW_1_P(S,X,val); \ 8162306a36Sopenharmony_ci _FP_UNPACK_CANONICAL(S,1,X); \ 8262306a36Sopenharmony_ci } while (0) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define FP_PACK_S(val,X) \ 8562306a36Sopenharmony_ci do { \ 8662306a36Sopenharmony_ci _FP_PACK_CANONICAL(S,1,X); \ 8762306a36Sopenharmony_ci _FP_PACK_RAW_1(S,val,X); \ 8862306a36Sopenharmony_ci } while (0) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define FP_PACK_SP(val,X) \ 9162306a36Sopenharmony_ci do { \ 9262306a36Sopenharmony_ci _FP_PACK_CANONICAL(S,1,X); \ 9362306a36Sopenharmony_ci if (!FP_INHIBIT_RESULTS) \ 9462306a36Sopenharmony_ci _FP_PACK_RAW_1_P(S,val,X); \ 9562306a36Sopenharmony_ci } while (0) 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X) 9862306a36Sopenharmony_ci#define FP_NEG_S(R,X) _FP_NEG(S,1,R,X) 9962306a36Sopenharmony_ci#define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y) 10062306a36Sopenharmony_ci#define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y) 10162306a36Sopenharmony_ci#define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y) 10262306a36Sopenharmony_ci#define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y) 10362306a36Sopenharmony_ci#define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X) 10462306a36Sopenharmony_ci#define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q) 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un) 10762306a36Sopenharmony_ci#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y) 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg) 11062306a36Sopenharmony_ci#define FP_TO_INT_ROUND_S(r,X,rsz,rsg) _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg) 11162306a36Sopenharmony_ci#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt) 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci#define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X) 11462306a36Sopenharmony_ci#define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X) 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci#endif /* __MATH_EMU_SINGLE_H__ */ 117