162306a36Sopenharmony_ci/* Machine-dependent software floating-point definitions.
262306a36Sopenharmony_ci   Sparc64 kernel version.
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) and
762306a36Sopenharmony_ci		  David S. Miller (davem@redhat.com).
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci   The GNU C Library is free software; you can redistribute it and/or
1062306a36Sopenharmony_ci   modify it under the terms of the GNU Library General Public License as
1162306a36Sopenharmony_ci   published by the Free Software Foundation; either version 2 of the
1262306a36Sopenharmony_ci   License, or (at your option) any later version.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci   The GNU C Library is distributed in the hope that it will be useful,
1562306a36Sopenharmony_ci   but WITHOUT ANY WARRANTY; without even the implied warranty of
1662306a36Sopenharmony_ci   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1762306a36Sopenharmony_ci   Library General Public License for more details.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci   You should have received a copy of the GNU Library General Public
2062306a36Sopenharmony_ci   License along with the GNU C Library; see the file COPYING.LIB.  If
2162306a36Sopenharmony_ci   not, write to the Free Software Foundation, Inc.,
2262306a36Sopenharmony_ci   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#ifndef _SFP_MACHINE_H
2562306a36Sopenharmony_ci#define _SFP_MACHINE_H
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#define _FP_W_TYPE_SIZE		64
2862306a36Sopenharmony_ci#define _FP_W_TYPE		unsigned long
2962306a36Sopenharmony_ci#define _FP_WS_TYPE		signed long
3062306a36Sopenharmony_ci#define _FP_I_TYPE		long
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#define _FP_MUL_MEAT_S(R,X,Y)					\
3362306a36Sopenharmony_ci  _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
3462306a36Sopenharmony_ci#define _FP_MUL_MEAT_D(R,X,Y)					\
3562306a36Sopenharmony_ci  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
3662306a36Sopenharmony_ci#define _FP_MUL_MEAT_Q(R,X,Y)					\
3762306a36Sopenharmony_ci  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
4062306a36Sopenharmony_ci#define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
4162306a36Sopenharmony_ci#define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_2_udiv(Q,R,X,Y)
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
4462306a36Sopenharmony_ci#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1)
4562306a36Sopenharmony_ci#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1
4662306a36Sopenharmony_ci#define _FP_NANSIGN_S		0
4762306a36Sopenharmony_ci#define _FP_NANSIGN_D		0
4862306a36Sopenharmony_ci#define _FP_NANSIGN_Q		0
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define _FP_KEEPNANFRACP 1
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* If one NaN is signaling and the other is not,
5362306a36Sopenharmony_ci * we choose that one, otherwise we choose X.
5462306a36Sopenharmony_ci */
5562306a36Sopenharmony_ci/* For _Qp_* and _Q_*, this should prefer X, for
5662306a36Sopenharmony_ci * CPU instruction emulation this should prefer Y.
5762306a36Sopenharmony_ci * (see SPAMv9 B.2.2 section).
5862306a36Sopenharmony_ci */
5962306a36Sopenharmony_ci#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
6062306a36Sopenharmony_ci  do {								\
6162306a36Sopenharmony_ci    if ((_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)		\
6262306a36Sopenharmony_ci	&& !(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs))	\
6362306a36Sopenharmony_ci      {								\
6462306a36Sopenharmony_ci	R##_s = X##_s;						\
6562306a36Sopenharmony_ci	_FP_FRAC_COPY_##wc(R,X);				\
6662306a36Sopenharmony_ci      }								\
6762306a36Sopenharmony_ci    else							\
6862306a36Sopenharmony_ci      {								\
6962306a36Sopenharmony_ci	R##_s = Y##_s;						\
7062306a36Sopenharmony_ci	_FP_FRAC_COPY_##wc(R,Y);				\
7162306a36Sopenharmony_ci      }								\
7262306a36Sopenharmony_ci    R##_c = FP_CLS_NAN;						\
7362306a36Sopenharmony_ci  } while (0)
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci/* Obtain the current rounding mode. */
7662306a36Sopenharmony_ci#ifndef FP_ROUNDMODE
7762306a36Sopenharmony_ci#define FP_ROUNDMODE	((current_thread_info()->xfsr[0] >> 30) & 0x3)
7862306a36Sopenharmony_ci#endif
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* Exception flags. */
8162306a36Sopenharmony_ci#define FP_EX_INVALID		(1 << 4)
8262306a36Sopenharmony_ci#define FP_EX_OVERFLOW		(1 << 3)
8362306a36Sopenharmony_ci#define FP_EX_UNDERFLOW		(1 << 2)
8462306a36Sopenharmony_ci#define FP_EX_DIVZERO		(1 << 1)
8562306a36Sopenharmony_ci#define FP_EX_INEXACT		(1 << 0)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define FP_HANDLE_EXCEPTIONS return _fex
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#define FP_INHIBIT_RESULTS ((current_thread_info()->xfsr[0] >> 23) & _fex)
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define FP_TRAPPING_EXCEPTIONS ((current_thread_info()->xfsr[0] >> 23) & 0x1f)
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#endif
94