1/* Soft-FP definitions for Altera Nios II.
2   Copyright (C) 2013-2022 Free Software Foundation, Inc.
3
4This file is free software; you can redistribute it and/or modify it
5under the terms of the GNU General Public License as published by the
6Free Software Foundation; either version 3, or (at your option) any
7later version.
8
9This file is distributed in the hope that it will be useful, but
10WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12General Public License for more details.
13
14Under Section 7 of GPL version 3, you are granted additional
15permissions described in the GCC Runtime Library Exception, version
163.1, as published by the Free Software Foundation.
17
18You should have received a copy of the GNU General Public License and
19a copy of the GCC Runtime Library Exception along with this program;
20see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
21<http://www.gnu.org/licenses/>.  */
22
23#define _FP_W_TYPE_SIZE		32
24#define _FP_W_TYPE		unsigned long
25#define _FP_WS_TYPE		signed long
26#define _FP_I_TYPE		long
27
28#define _FP_MUL_MEAT_S(R,X,Y)				\
29  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
30#define _FP_MUL_MEAT_D(R,X,Y)				\
31  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
32#define _FP_MUL_MEAT_Q(R,X,Y)				\
33  _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
34
35#define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_loop(S,R,X,Y)
36#define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
37#define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
38
39#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
40#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
41#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
42#define _FP_NANSIGN_S		0
43#define _FP_NANSIGN_D		0
44#define _FP_NANSIGN_Q		0
45
46#define _FP_KEEPNANFRACP 1
47#define _FP_QNANNEGATEDP 0
48
49/* Someone please check this.  */
50#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
51  do {								\
52    if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)		\
53	&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))	\
54      {								\
55	R##_s = Y##_s;						\
56	_FP_FRAC_COPY_##wc(R,Y);				\
57      }								\
58    else							\
59      {								\
60	R##_s = X##_s;						\
61	_FP_FRAC_COPY_##wc(R,X);				\
62      }								\
63    R##_c = FP_CLS_NAN;						\
64  } while (0)
65
66/* Not checked.  */
67#define _FP_TININESS_AFTER_ROUNDING 0
68
69#define	__LITTLE_ENDIAN	1234
70#define	__BIG_ENDIAN	4321
71
72#ifdef __nios2_little_endian__
73#define __BYTE_ORDER __LITTLE_ENDIAN
74#else
75#define __BYTE_ORDER __BIG_ENDIAN
76#endif
77
78/* Define ALIASNAME as a strong alias for NAME.  */
79# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
80# define _strong_alias(name, aliasname) \
81  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
82