Update copyright dates with scripts/update-copyrights
[glibc.git] / sysdeps / or1k / sfp-machine.h
blob0a5daf847bb49d0ee52f7e65aa5b6960e00630f8
1 /* OpenRISC softfloat definitions.
2 Copyright (C) 2022-2023 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <https://www.gnu.org/licenses/>. */
20 #define _FP_W_TYPE_SIZE 32
21 #define _FP_W_TYPE unsigned long
22 #define _FP_WS_TYPE signed long
23 #define _FP_I_TYPE long
25 #define _FP_MUL_MEAT_S(R,X,Y) \
26 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
27 #define _FP_MUL_MEAT_D(R,X,Y) \
28 _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
29 #define _FP_MUL_MEAT_Q(R,X,Y) \
30 _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
32 #define _FP_MUL_MEAT_DW_S(R,X,Y) \
33 _FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
34 #define _FP_MUL_MEAT_DW_D(R,X,Y) \
35 _FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
36 #define _FP_MUL_MEAT_DW_Q(R,X,Y) \
37 _FP_MUL_MEAT_DW_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
40 #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y)
41 #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
42 #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
44 #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
45 #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
46 #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
47 #define _FP_NANSIGN_S 0
48 #define _FP_NANSIGN_D 0
49 #define _FP_NANSIGN_Q 0
51 #define _FP_KEEPNANFRACP 1
52 #define _FP_QNANNEGATEDP 0
54 /* Someone please check this. */
55 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
56 do { \
57 if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
58 && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
59 { \
60 R##_s = Y##_s; \
61 _FP_FRAC_COPY_##wc(R,Y); \
62 } \
63 else \
64 { \
65 R##_s = X##_s; \
66 _FP_FRAC_COPY_##wc(R,X); \
67 } \
68 R##_c = FP_CLS_NAN; \
69 } while (0)
71 /* Handle getting and setting rounding mode for soft fp operations. */
73 #define FP_RND_NEAREST (0x0 << 1)
74 #define FP_RND_ZERO (0x1 << 1)
75 #define FP_RND_PINF (0x2 << 1)
76 #define FP_RND_MINF (0x3 << 1)
77 #define FP_RND_MASK (0x3 << 1)
79 #define FP_EX_OVERFLOW (1 << 3)
80 #define FP_EX_UNDERFLOW (1 << 4)
81 #define FP_EX_INEXACT (1 << 8)
82 #define FP_EX_INVALID (1 << 9)
83 #define FP_EX_DIVZERO (1 << 11)
84 #define FP_EX_ALL \
85 (FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \
86 | FP_EX_INEXACT)
88 #define _FP_DECL_EX \
89 unsigned int _fpcsr __attribute__ ((unused)) = FP_RND_NEAREST
91 #define FP_ROUNDMODE (_fpcsr & FP_RND_MASK)
93 #define _FP_TININESS_AFTER_ROUNDING 0