Home | History | Annotate | Line # | Download | only in nds32
sfp-machine.h revision 1.7
      1  1.1  mrg /* Machine settings for software floating-point emulation
      2  1.1  mrg    of Andes NDS32 cpu for GNU compiler
      3  1.7  mrg    Copyright (C) 2012-2022 Free Software Foundation, Inc.
      4  1.1  mrg    Contributed by Andes Technology Corporation.
      5  1.1  mrg 
      6  1.1  mrg    This file is part of GNU C Library.
      7  1.1  mrg 
      8  1.1  mrg    The GNU C Library is free software; you can redistribute it and/or
      9  1.1  mrg    modify it under the terms of the GNU Lesser General Public
     10  1.1  mrg    License as published by the Free Software Foundation; either
     11  1.1  mrg    version 2.1 of the License, or (at your option) any later version.
     12  1.1  mrg 
     13  1.1  mrg    In addition to the permissions in the GNU Lesser General Public
     14  1.1  mrg    License, the Free Software Foundation gives you unlimited
     15  1.1  mrg    permission to link the compiled version of this file into
     16  1.1  mrg    combinations with other programs, and to distribute those
     17  1.1  mrg    combinations without any restriction coming from the use of this
     18  1.1  mrg    file.  (The Lesser General Public License restrictions do apply in
     19  1.1  mrg    other respects; for example, they cover modification of the file,
     20  1.1  mrg    and distribution when not linked into a combine executable.)
     21  1.1  mrg 
     22  1.1  mrg    The GNU C Library is distributed in the hope that it will be useful,
     23  1.1  mrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
     24  1.1  mrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     25  1.1  mrg    Lesser General Public License for more details.
     26  1.1  mrg 
     27  1.1  mrg    You should have received a copy of the GNU Lesser General Public
     28  1.1  mrg    License along with the GNU C Library; if not, see
     29  1.1  mrg    <http://www.gnu.org/licenses/>.  */
     30  1.1  mrg 
     31  1.1  mrg #define _FP_W_TYPE_SIZE		32
     32  1.1  mrg #define _FP_W_TYPE		unsigned long
     33  1.1  mrg #define _FP_WS_TYPE		signed long
     34  1.1  mrg #define _FP_I_TYPE		long
     35  1.1  mrg 
     36  1.1  mrg /* The type of the result of a floating point comparison.  This must
     37  1.1  mrg    match `__libgcc_cmp_return__' in GCC for the target.  */
     38  1.1  mrg typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
     39  1.1  mrg #define CMPtype __gcc_CMPtype
     40  1.1  mrg 
     41  1.1  mrg #define _FP_MUL_MEAT_S(R,X,Y)				\
     42  1.1  mrg   _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
     43  1.1  mrg #define _FP_MUL_MEAT_D(R,X,Y)				\
     44  1.1  mrg   _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
     45  1.1  mrg #define _FP_MUL_MEAT_Q(R,X,Y)				\
     46  1.1  mrg   _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
     47  1.1  mrg 
     48  1.1  mrg #define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_loop(S,R,X,Y)
     49  1.1  mrg #define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
     50  1.1  mrg #define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
     51  1.1  mrg 
     52  1.1  mrg #define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
     53  1.1  mrg #define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
     54  1.1  mrg #define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
     55  1.1  mrg #define _FP_NANSIGN_S		0
     56  1.1  mrg #define _FP_NANSIGN_D		0
     57  1.1  mrg #define _FP_NANSIGN_Q		0
     58  1.1  mrg 
     59  1.1  mrg #define _FP_KEEPNANFRACP 1
     60  1.1  mrg #define _FP_QNANNEGATEDP 0
     61  1.1  mrg 
     62  1.1  mrg /* Someone please check this.  */
     63  1.1  mrg #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
     64  1.1  mrg   do {								\
     65  1.1  mrg     if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)		\
     66  1.1  mrg 	&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))	\
     67  1.1  mrg       {								\
     68  1.1  mrg 	R##_s = Y##_s;						\
     69  1.1  mrg 	_FP_FRAC_COPY_##wc(R,Y);				\
     70  1.1  mrg       }								\
     71  1.1  mrg     else							\
     72  1.1  mrg       {								\
     73  1.1  mrg 	R##_s = X##_s;						\
     74  1.1  mrg 	_FP_FRAC_COPY_##wc(R,X);				\
     75  1.1  mrg       }								\
     76  1.1  mrg     R##_c = FP_CLS_NAN;						\
     77  1.1  mrg   } while (0)
     78  1.1  mrg 
     79  1.4  mrg #ifdef NDS32_ABI_2FP_PLUS
     80  1.4  mrg #define FP_RND_NEAREST		0x0
     81  1.4  mrg #define FP_RND_PINF		0x1
     82  1.4  mrg #define FP_RND_MINF		0x2
     83  1.4  mrg #define FP_RND_ZERO		0x3
     84  1.4  mrg #define FP_RND_MASK		0x3
     85  1.4  mrg 
     86  1.4  mrg #define _FP_DECL_EX \
     87  1.4  mrg   unsigned long int _fcsr __attribute__ ((unused)) = FP_RND_NEAREST
     88  1.4  mrg 
     89  1.4  mrg #define FP_INIT_ROUNDMODE			\
     90  1.4  mrg   do {						\
     91  1.4  mrg     _fcsr = __builtin_nds32_fmfcsr ();		\
     92  1.4  mrg   } while (0)
     93  1.4  mrg 
     94  1.4  mrg #define FP_ROUNDMODE (_fcsr & FP_RND_MASK)
     95  1.4  mrg 
     96  1.4  mrg #endif
     97  1.4  mrg 
     98  1.1  mrg /* Not checked.  */
     99  1.1  mrg #define _FP_TININESS_AFTER_ROUNDING 0
    100  1.1  mrg 
    101  1.1  mrg #define	__LITTLE_ENDIAN	1234
    102  1.1  mrg #define	__BIG_ENDIAN	4321
    103  1.1  mrg 
    104  1.1  mrg #if defined __big_endian__
    105  1.1  mrg # define __BYTE_ORDER __BIG_ENDIAN
    106  1.1  mrg #else
    107  1.1  mrg # define __BYTE_ORDER __LITTLE_ENDIAN
    108  1.1  mrg #endif
    109  1.1  mrg 
    110  1.1  mrg /* Define ALIASNAME as a strong alias for NAME.  */
    111  1.1  mrg # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
    112  1.1  mrg # define _strong_alias(name, aliasname) \
    113  1.1  mrg   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
    114