]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgcc/config/mips/sfp-machine.h
1 /* softfp machine description for MIPS.
2 Copyright (C) 2009-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
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
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
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.
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/>. */
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
31 typedef int TItype
__attribute__ ((mode (TI
)));
32 typedef unsigned int UTItype
__attribute__ ((mode (TI
)));
33 #define TI_BITS (__CHAR_BIT__ * (int) sizeof (TItype))
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)
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)
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
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
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
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)
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)
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
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
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
88 #define _FP_NANSIGN_S 0
89 #define _FP_NANSIGN_D 0
90 #define _FP_NANSIGN_Q 0
92 #define _FP_KEEPNANFRACP 1
94 # define _FP_QNANNEGATEDP 0
96 # define _FP_QNANNEGATEDP 1
99 /* Comment from glibc: */
100 /* From my experiments it seems X is chosen unless one of the
101 NaNs is sNaN, in which case the result is NANSIGN/NANFRAC. */
102 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
104 if ((_FP_FRAC_HIGH_RAW_##fs(X) | \
105 _FP_FRAC_HIGH_RAW_##fs(Y)) & _FP_QNANBIT_##fs) \
107 R##_s = _FP_NANSIGN_##fs; \
108 _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
113 _FP_FRAC_COPY_##wc(R,X); \
115 R##_c = FP_CLS_NAN; \
118 #ifdef __mips_hard_float
119 #define FP_EX_INVALID 0x40
120 #define FP_EX_DIVZERO 0x20
121 #define FP_EX_OVERFLOW 0x10
122 #define FP_EX_UNDERFLOW 0x08
123 #define FP_EX_INEXACT 0x04
125 (FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \
128 #define FP_EX_ENABLE_SHIFT 5
129 #define FP_EX_CAUSE_SHIFT 10
131 #define FP_RND_NEAREST 0x0
132 #define FP_RND_ZERO 0x1
133 #define FP_RND_PINF 0x2
134 #define FP_RND_MINF 0x3
135 #define FP_RND_MASK 0x3
137 #define _FP_DECL_EX \
138 unsigned long int _fcsr __attribute__ ((unused)) = FP_RND_NEAREST
140 #define FP_INIT_ROUNDMODE \
142 _fcsr = __builtin_mips_get_fcsr (); \
145 #define FP_ROUNDMODE (_fcsr & FP_RND_MASK)
147 #define FP_TRAPPING_EXCEPTIONS ((_fcsr >> FP_EX_ENABLE_SHIFT) & FP_EX_ALL)
149 #define FP_HANDLE_EXCEPTIONS \
151 _fcsr &= ~(FP_EX_ALL << FP_EX_CAUSE_SHIFT); \
152 /* Also clear Unimplemented Operation. */ \
153 _fcsr &= ~(1 << 17); \
154 _fcsr |= _fex | (_fex << FP_EX_CAUSE_SHIFT); \
155 __builtin_mips_set_fcsr (_fcsr); \
159 #define FP_EX_INVALID (1 << 4)
160 #define FP_EX_DIVZERO (1 << 3)
161 #define FP_EX_OVERFLOW (1 << 2)
162 #define FP_EX_UNDERFLOW (1 << 1)
163 #define FP_EX_INEXACT (1 << 0)
166 #define _FP_TININESS_AFTER_ROUNDING 1
168 #define __LITTLE_ENDIAN 1234
169 #define __BIG_ENDIAN 4321
172 # define __BYTE_ORDER __BIG_ENDIAN
174 # define __BYTE_ORDER __LITTLE_ENDIAN
177 /* Define ALIASNAME as a strong alias for NAME. */
178 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
179 # define _strong_alias(name, aliasname) \
180 extern __typeof (name) aliasname __attribute__ ((alias (#name)));