]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/mips/sfp-machine.h
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / mips / sfp-machine.h
CommitLineData
9bcbf352 1/* softfp machine description for MIPS.
f1717362 2 Copyright (C) 2009-2016 Free Software Foundation, Inc.
9bcbf352 3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16Under Section 7 of GPL version 3, you are granted additional
17permissions described in the GCC Runtime Library Exception, version
183.1, as published by the Free Software Foundation.
19
20You should have received a copy of the GNU General Public License and
21a copy of the GCC Runtime Library Exception along with this program;
22see 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
31typedef int TItype __attribute__ ((mode (TI)));
32typedef 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. */
85typedef 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/* 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) \
103 do { \
104 if ((_FP_FRAC_HIGH_RAW_##fs(X) | \
105 _FP_FRAC_HIGH_RAW_##fs(Y)) & _FP_QNANBIT_##fs) \
106 { \
107 R##_s = _FP_NANSIGN_##fs; \
108 _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
109 } \
110 else \
111 { \
112 R##_s = X##_s; \
113 _FP_FRAC_COPY_##wc(R,X); \
114 } \
115 R##_c = FP_CLS_NAN; \
116 } while (0)
117
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
124#define FP_EX_ALL \
125 (FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \
126 | FP_EX_INEXACT)
127
128#define FP_EX_ENABLE_SHIFT 5
129#define FP_EX_CAUSE_SHIFT 10
130
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
136
137#define _FP_DECL_EX \
138 unsigned long int _fcsr __attribute__ ((unused)) = FP_RND_NEAREST
139
140#define FP_INIT_ROUNDMODE \
141 do { \
142 _fcsr = __builtin_mips_get_fcsr (); \
143 } while (0)
144
145#define FP_ROUNDMODE (_fcsr & FP_RND_MASK)
146
147#define FP_TRAPPING_EXCEPTIONS ((_fcsr >> FP_EX_ENABLE_SHIFT) & FP_EX_ALL)
148
149#define FP_HANDLE_EXCEPTIONS \
150 do { \
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); \
156 } while (0);
157
158#else
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)
164#endif
165
8f687340 166#define _FP_TININESS_AFTER_ROUNDING 1
167
9bcbf352 168#define __LITTLE_ENDIAN 1234
169#define __BIG_ENDIAN 4321
170
171#if defined _MIPSEB
172# define __BYTE_ORDER __BIG_ENDIAN
173#else
174# define __BYTE_ORDER __LITTLE_ENDIAN
175#endif
176
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)));