(root)/
gcc-13.2.0/
libgcc/
config/
mips/
sfp-machine.h
       1  /* softfp machine description for MIPS.
       2     Copyright (C) 2009-2023 Free Software Foundation, Inc.
       3  
       4  This file is part of GCC.
       5  
       6  GCC is free software; you can redistribute it and/or modify it under
       7  the terms of the GNU General Public License as published by the Free
       8  Software Foundation; either version 3, or (at your option) any later
       9  version.
      10  
      11  GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12  WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14  for more details.
      15  
      16  Under Section 7 of GPL version 3, you are granted additional
      17  permissions described in the GCC Runtime Library Exception, version
      18  3.1, as published by the Free Software Foundation.
      19  
      20  You should have received a copy of the GNU General Public License and
      21  a copy of the GCC Runtime Library Exception along with this program;
      22  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      23  <http://www.gnu.org/licenses/>.  */
      24  
      25  #ifdef __mips64
      26  #define _FP_W_TYPE_SIZE		64
      27  #define _FP_W_TYPE		unsigned long long
      28  #define _FP_WS_TYPE		signed long long
      29  #define _FP_I_TYPE		long long
      30  
      31  typedef int TItype __attribute__ ((mode (TI)));
      32  typedef unsigned int UTItype __attribute__ ((mode (TI)));
      33  #define TI_BITS (__CHAR_BIT__ * (int) sizeof (TItype))
      34  
      35  #define _FP_MUL_MEAT_S(R,X,Y)				\
      36    _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
      37  #define _FP_MUL_MEAT_D(R,X,Y)				\
      38    _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
      39  #define _FP_MUL_MEAT_Q(R,X,Y)				\
      40    _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
      41  
      42  #define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
      43  #define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
      44  #define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_2_udiv(Q,R,X,Y)
      45  
      46  #ifdef __mips_nan2008
      47  # define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
      48  # define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1)
      49  # define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1
      50  #else
      51  # define _FP_NANFRAC_S		(_FP_QNANBIT_S - 1)
      52  # define _FP_NANFRAC_D		(_FP_QNANBIT_D - 1)
      53  # define _FP_NANFRAC_Q		(_FP_QNANBIT_Q - 1), -1
      54  #endif
      55  #else
      56  #define _FP_W_TYPE_SIZE		32
      57  #define _FP_W_TYPE		unsigned int
      58  #define _FP_WS_TYPE		signed int
      59  #define _FP_I_TYPE		int
      60  
      61  #define _FP_MUL_MEAT_S(R,X,Y)				\
      62    _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
      63  #define _FP_MUL_MEAT_D(R,X,Y)				\
      64    _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
      65  #define _FP_MUL_MEAT_Q(R,X,Y)				\
      66    _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
      67  
      68  #define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
      69  #define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
      70  #define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
      71  
      72  #ifdef __mips_nan2008
      73  # define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
      74  # define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
      75  # define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
      76  #else
      77  # define _FP_NANFRAC_S		(_FP_QNANBIT_S - 1)
      78  # define _FP_NANFRAC_D		(_FP_QNANBIT_D - 1), -1
      79  # define _FP_NANFRAC_Q		(_FP_QNANBIT_Q - 1), -1, -1, -1
      80  #endif
      81  #endif
      82  
      83  /* The type of the result of a floating point comparison.  This must
      84     match __libgcc_cmp_return__ in GCC for the target.  */
      85  typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
      86  #define CMPtype __gcc_CMPtype
      87  
      88  #define _FP_NANSIGN_S		0
      89  #define _FP_NANSIGN_D		0
      90  #define _FP_NANSIGN_Q		0
      91  
      92  #define _FP_KEEPNANFRACP 1
      93  #ifdef __mips_nan2008
      94  # define _FP_QNANNEGATEDP 0
      95  #else
      96  # define _FP_QNANNEGATEDP 1
      97  #endif
      98  
      99  #ifdef __mips_nan2008
     100  /* NaN payloads should be preserved for NAN2008.  */
     101  # define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)	\
     102    do						\
     103      {						\
     104        R##_s = X##_s;				\
     105        _FP_FRAC_COPY_##wc (R, X);		\
     106        R##_c = FP_CLS_NAN;			\
     107      }						\
     108    while (0)
     109  #else
     110  /* Comment from glibc: */
     111  /* From my experiments it seems X is chosen unless one of the
     112     NaNs is sNaN,  in which case the result is NANSIGN/NANFRAC.  */
     113  # define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
     114    do {								\
     115      if ((_FP_FRAC_HIGH_RAW_##fs(X) |				\
     116  	 _FP_FRAC_HIGH_RAW_##fs(Y)) & _FP_QNANBIT_##fs)		\
     117        {								\
     118  	R##_s = _FP_NANSIGN_##fs;				\
     119  	_FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs);			\
     120        }								\
     121      else							\
     122        {								\
     123  	R##_s = X##_s;						\
     124  	_FP_FRAC_COPY_##wc(R,X);				\
     125        }								\
     126      R##_c = FP_CLS_NAN;						\
     127    } while (0)
     128  #endif
     129  
     130  #ifdef __mips_hard_float
     131  #define FP_EX_INVALID           0x40
     132  #define FP_EX_DIVZERO           0x20
     133  #define FP_EX_OVERFLOW          0x10
     134  #define FP_EX_UNDERFLOW         0x08
     135  #define FP_EX_INEXACT           0x04
     136  #define FP_EX_ALL \
     137  	(FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \
     138  	 | FP_EX_INEXACT)
     139  
     140  #define FP_EX_ENABLE_SHIFT	5
     141  #define FP_EX_CAUSE_SHIFT	10
     142  
     143  #define FP_RND_NEAREST		0x0
     144  #define FP_RND_ZERO		0x1
     145  #define FP_RND_PINF		0x2
     146  #define FP_RND_MINF		0x3
     147  #define FP_RND_MASK		0x3
     148  
     149  #define _FP_DECL_EX \
     150    unsigned long int _fcsr __attribute__ ((unused)) = FP_RND_NEAREST
     151  
     152  #define FP_INIT_ROUNDMODE			\
     153    do {						\
     154      _fcsr = __builtin_mips_get_fcsr ();		\
     155    } while (0)
     156  
     157  #define FP_ROUNDMODE (_fcsr & FP_RND_MASK)
     158  
     159  #define FP_TRAPPING_EXCEPTIONS ((_fcsr >> FP_EX_ENABLE_SHIFT) & FP_EX_ALL)
     160  
     161  #define FP_HANDLE_EXCEPTIONS				\
     162    do {							\
     163      _fcsr &= ~(FP_EX_ALL << FP_EX_CAUSE_SHIFT);		\
     164      /* Also clear Unimplemented Operation.  */		\
     165      _fcsr &= ~(1 << 17);				\
     166      _fcsr |= _fex | (_fex << FP_EX_CAUSE_SHIFT);	\
     167      __builtin_mips_set_fcsr (_fcsr);			\
     168    } while (0)
     169  
     170  #else
     171  #define FP_EX_INVALID           (1 << 4)
     172  #define FP_EX_DIVZERO           (1 << 3)
     173  #define FP_EX_OVERFLOW          (1 << 2)
     174  #define FP_EX_UNDERFLOW         (1 << 1)
     175  #define FP_EX_INEXACT           (1 << 0)
     176  #endif
     177  
     178  #define _FP_TININESS_AFTER_ROUNDING 1
     179  
     180  #define	__LITTLE_ENDIAN	1234
     181  #define	__BIG_ENDIAN	4321
     182  
     183  #if defined _MIPSEB
     184  # define __BYTE_ORDER __BIG_ENDIAN
     185  #else
     186  # define __BYTE_ORDER __LITTLE_ENDIAN
     187  #endif
     188  
     189  /* Define ALIASNAME as a strong alias for NAME.  */
     190  # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
     191  # define _strong_alias(name, aliasname) \
     192    extern __typeof (name) aliasname __attribute__ ((alias (#name)));