18c2ecf20Sopenharmony_ci/* Software floating-point emulation. 28c2ecf20Sopenharmony_ci Definitions for IEEE Single Precision. 38c2ecf20Sopenharmony_ci Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. 48c2ecf20Sopenharmony_ci This file is part of the GNU C Library. 58c2ecf20Sopenharmony_ci Contributed by Richard Henderson (rth@cygnus.com), 68c2ecf20Sopenharmony_ci Jakub Jelinek (jj@ultra.linux.cz), 78c2ecf20Sopenharmony_ci David S. Miller (davem@redhat.com) and 88c2ecf20Sopenharmony_ci Peter Maydell (pmaydell@chiark.greenend.org.uk). 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci The GNU C Library is free software; you can redistribute it and/or 118c2ecf20Sopenharmony_ci modify it under the terms of the GNU Library General Public License as 128c2ecf20Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 138c2ecf20Sopenharmony_ci License, or (at your option) any later version. 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci The GNU C Library is distributed in the hope that it will be useful, 168c2ecf20Sopenharmony_ci but WITHOUT ANY WARRANTY; without even the implied warranty of 178c2ecf20Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 188c2ecf20Sopenharmony_ci Library General Public License for more details. 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci You should have received a copy of the GNU Library General Public 218c2ecf20Sopenharmony_ci License along with the GNU C Library; see the file COPYING.LIB. If 228c2ecf20Sopenharmony_ci not, write to the Free Software Foundation, Inc., 238c2ecf20Sopenharmony_ci 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#ifndef __MATH_EMU_SINGLE_H__ 268c2ecf20Sopenharmony_ci#define __MATH_EMU_SINGLE_H__ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#if _FP_W_TYPE_SIZE < 32 298c2ecf20Sopenharmony_ci#error "Here's a nickel kid. Go buy yourself a real computer." 308c2ecf20Sopenharmony_ci#endif 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define _FP_FRACBITS_S 24 338c2ecf20Sopenharmony_ci#define _FP_FRACXBITS_S (_FP_W_TYPE_SIZE - _FP_FRACBITS_S) 348c2ecf20Sopenharmony_ci#define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S) 358c2ecf20Sopenharmony_ci#define _FP_WFRACXBITS_S (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S) 368c2ecf20Sopenharmony_ci#define _FP_EXPBITS_S 8 378c2ecf20Sopenharmony_ci#define _FP_EXPBIAS_S 127 388c2ecf20Sopenharmony_ci#define _FP_EXPMAX_S 255 398c2ecf20Sopenharmony_ci#define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2)) 408c2ecf20Sopenharmony_ci#define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1)) 418c2ecf20Sopenharmony_ci#define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S)) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be 448c2ecf20Sopenharmony_ci chosen by the target machine. */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciunion _FP_UNION_S 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci float flt; 498c2ecf20Sopenharmony_ci struct { 508c2ecf20Sopenharmony_ci#if __BYTE_ORDER == __BIG_ENDIAN 518c2ecf20Sopenharmony_ci unsigned sign : 1; 528c2ecf20Sopenharmony_ci unsigned exp : _FP_EXPBITS_S; 538c2ecf20Sopenharmony_ci unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0); 548c2ecf20Sopenharmony_ci#else 558c2ecf20Sopenharmony_ci unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0); 568c2ecf20Sopenharmony_ci unsigned exp : _FP_EXPBITS_S; 578c2ecf20Sopenharmony_ci unsigned sign : 1; 588c2ecf20Sopenharmony_ci#endif 598c2ecf20Sopenharmony_ci } bits __attribute__((packed)); 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define FP_DECL_S(X) _FP_DECL(1,X) 638c2ecf20Sopenharmony_ci#define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val) 648c2ecf20Sopenharmony_ci#define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val) 658c2ecf20Sopenharmony_ci#define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X) 668c2ecf20Sopenharmony_ci#define FP_PACK_RAW_SP(val,X) \ 678c2ecf20Sopenharmony_ci do { \ 688c2ecf20Sopenharmony_ci if (!FP_INHIBIT_RESULTS) \ 698c2ecf20Sopenharmony_ci _FP_PACK_RAW_1_P(S,val,X); \ 708c2ecf20Sopenharmony_ci } while (0) 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define FP_UNPACK_S(X,val) \ 738c2ecf20Sopenharmony_ci do { \ 748c2ecf20Sopenharmony_ci _FP_UNPACK_RAW_1(S,X,val); \ 758c2ecf20Sopenharmony_ci _FP_UNPACK_CANONICAL(S,1,X); \ 768c2ecf20Sopenharmony_ci } while (0) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define FP_UNPACK_SP(X,val) \ 798c2ecf20Sopenharmony_ci do { \ 808c2ecf20Sopenharmony_ci _FP_UNPACK_RAW_1_P(S,X,val); \ 818c2ecf20Sopenharmony_ci _FP_UNPACK_CANONICAL(S,1,X); \ 828c2ecf20Sopenharmony_ci } while (0) 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define FP_PACK_S(val,X) \ 858c2ecf20Sopenharmony_ci do { \ 868c2ecf20Sopenharmony_ci _FP_PACK_CANONICAL(S,1,X); \ 878c2ecf20Sopenharmony_ci _FP_PACK_RAW_1(S,val,X); \ 888c2ecf20Sopenharmony_ci } while (0) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define FP_PACK_SP(val,X) \ 918c2ecf20Sopenharmony_ci do { \ 928c2ecf20Sopenharmony_ci _FP_PACK_CANONICAL(S,1,X); \ 938c2ecf20Sopenharmony_ci if (!FP_INHIBIT_RESULTS) \ 948c2ecf20Sopenharmony_ci _FP_PACK_RAW_1_P(S,val,X); \ 958c2ecf20Sopenharmony_ci } while (0) 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X) 988c2ecf20Sopenharmony_ci#define FP_NEG_S(R,X) _FP_NEG(S,1,R,X) 998c2ecf20Sopenharmony_ci#define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y) 1008c2ecf20Sopenharmony_ci#define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y) 1018c2ecf20Sopenharmony_ci#define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y) 1028c2ecf20Sopenharmony_ci#define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y) 1038c2ecf20Sopenharmony_ci#define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X) 1048c2ecf20Sopenharmony_ci#define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un) 1078c2ecf20Sopenharmony_ci#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y) 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg) 1108c2ecf20Sopenharmony_ci#define FP_TO_INT_ROUND_S(r,X,rsz,rsg) _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg) 1118c2ecf20Sopenharmony_ci#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X) 1148c2ecf20Sopenharmony_ci#define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#endif /* __MATH_EMU_SINGLE_H__ */ 117