diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/math-emu/soft-fp.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/math-emu/soft-fp.h')
-rw-r--r-- | include/math-emu/soft-fp.h | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/include/math-emu/soft-fp.h b/include/math-emu/soft-fp.h new file mode 100644 index 000000000000..d02eb64a865b --- /dev/null +++ b/include/math-emu/soft-fp.h | |||
@@ -0,0 +1,181 @@ | |||
1 | /* Software floating-point emulation. | ||
2 | Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Contributed by Richard Henderson (rth@cygnus.com), | ||
5 | Jakub Jelinek (jj@ultra.linux.cz), | ||
6 | David S. Miller (davem@redhat.com) and | ||
7 | Peter Maydell (pmaydell@chiark.greenend.org.uk). | ||
8 | |||
9 | The GNU C Library is free software; you can redistribute it and/or | ||
10 | modify it under the terms of the GNU Library General Public License as | ||
11 | published by the Free Software Foundation; either version 2 of the | ||
12 | License, or (at your option) any later version. | ||
13 | |||
14 | The GNU C Library is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | Library General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU Library General Public | ||
20 | License along with the GNU C Library; see the file COPYING.LIB. If | ||
21 | not, write to the Free Software Foundation, Inc., | ||
22 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
23 | |||
24 | #ifndef __MATH_EMU_SOFT_FP_H__ | ||
25 | #define __MATH_EMU_SOFT_FP_H__ | ||
26 | |||
27 | #include <asm/sfp-machine.h> | ||
28 | |||
29 | /* Allow sfp-machine to have its own byte order definitions. */ | ||
30 | #ifndef __BYTE_ORDER | ||
31 | #include <endian.h> | ||
32 | #endif | ||
33 | |||
34 | #define _FP_WORKBITS 3 | ||
35 | #define _FP_WORK_LSB ((_FP_W_TYPE)1 << 3) | ||
36 | #define _FP_WORK_ROUND ((_FP_W_TYPE)1 << 2) | ||
37 | #define _FP_WORK_GUARD ((_FP_W_TYPE)1 << 1) | ||
38 | #define _FP_WORK_STICKY ((_FP_W_TYPE)1 << 0) | ||
39 | |||
40 | #ifndef FP_RND_NEAREST | ||
41 | # define FP_RND_NEAREST 0 | ||
42 | # define FP_RND_ZERO 1 | ||
43 | # define FP_RND_PINF 2 | ||
44 | # define FP_RND_MINF 3 | ||
45 | #ifndef FP_ROUNDMODE | ||
46 | # define FP_ROUNDMODE FP_RND_NEAREST | ||
47 | #endif | ||
48 | #endif | ||
49 | |||
50 | /* By default don't care about exceptions. */ | ||
51 | #ifndef FP_EX_INVALID | ||
52 | #define FP_EX_INVALID 0 | ||
53 | #endif | ||
54 | #ifndef FP_EX_OVERFLOW | ||
55 | #define FP_EX_OVERFLOW 0 | ||
56 | #endif | ||
57 | #ifndef FP_EX_UNDERFLOW | ||
58 | #define FP_EX_UNDERFLOW | ||
59 | #endif | ||
60 | #ifndef FP_EX_DIVZERO | ||
61 | #define FP_EX_DIVZERO 0 | ||
62 | #endif | ||
63 | #ifndef FP_EX_INEXACT | ||
64 | #define FP_EX_INEXACT 0 | ||
65 | #endif | ||
66 | #ifndef FP_EX_DENORM | ||
67 | #define FP_EX_DENORM 0 | ||
68 | #endif | ||
69 | |||
70 | #ifdef _FP_DECL_EX | ||
71 | #define FP_DECL_EX \ | ||
72 | int _fex = 0; \ | ||
73 | _FP_DECL_EX | ||
74 | #else | ||
75 | #define FP_DECL_EX int _fex = 0 | ||
76 | #endif | ||
77 | |||
78 | #ifndef FP_INIT_ROUNDMODE | ||
79 | #define FP_INIT_ROUNDMODE do {} while (0) | ||
80 | #endif | ||
81 | |||
82 | #ifndef FP_HANDLE_EXCEPTIONS | ||
83 | #define FP_HANDLE_EXCEPTIONS do {} while (0) | ||
84 | #endif | ||
85 | |||
86 | /* By default we never flush denormal input operands to signed zero. */ | ||
87 | #ifndef FP_DENORM_ZERO | ||
88 | #define FP_DENORM_ZERO 0 | ||
89 | #endif | ||
90 | |||
91 | #ifndef FP_INHIBIT_RESULTS | ||
92 | /* By default we write the results always. | ||
93 | * sfp-machine may override this and e.g. | ||
94 | * check if some exceptions are unmasked | ||
95 | * and inhibit it in such a case. | ||
96 | */ | ||
97 | #define FP_INHIBIT_RESULTS 0 | ||
98 | #endif | ||
99 | |||
100 | #define FP_SET_EXCEPTION(ex) \ | ||
101 | _fex |= (ex) | ||
102 | |||
103 | #define FP_UNSET_EXCEPTION(ex) \ | ||
104 | _fex &= ~(ex) | ||
105 | |||
106 | #define FP_CLEAR_EXCEPTIONS \ | ||
107 | _fex = 0 | ||
108 | |||
109 | #define _FP_ROUND_NEAREST(wc, X) \ | ||
110 | do { \ | ||
111 | if ((_FP_FRAC_LOW_##wc(X) & 15) != _FP_WORK_ROUND) \ | ||
112 | _FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \ | ||
113 | } while (0) | ||
114 | |||
115 | #define _FP_ROUND_ZERO(wc, X) 0 | ||
116 | |||
117 | #define _FP_ROUND_PINF(wc, X) \ | ||
118 | do { \ | ||
119 | if (!X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \ | ||
120 | _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \ | ||
121 | } while (0) | ||
122 | |||
123 | #define _FP_ROUND_MINF(wc, X) \ | ||
124 | do { \ | ||
125 | if (X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \ | ||
126 | _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \ | ||
127 | } while (0) | ||
128 | |||
129 | #define _FP_ROUND(wc, X) \ | ||
130 | do { \ | ||
131 | if (_FP_FRAC_LOW_##wc(X) & 7) \ | ||
132 | FP_SET_EXCEPTION(FP_EX_INEXACT); \ | ||
133 | switch (FP_ROUNDMODE) \ | ||
134 | { \ | ||
135 | case FP_RND_NEAREST: \ | ||
136 | _FP_ROUND_NEAREST(wc,X); \ | ||
137 | break; \ | ||
138 | case FP_RND_ZERO: \ | ||
139 | _FP_ROUND_ZERO(wc,X); \ | ||
140 | break; \ | ||
141 | case FP_RND_PINF: \ | ||
142 | _FP_ROUND_PINF(wc,X); \ | ||
143 | break; \ | ||
144 | case FP_RND_MINF: \ | ||
145 | _FP_ROUND_MINF(wc,X); \ | ||
146 | break; \ | ||
147 | } \ | ||
148 | } while (0) | ||
149 | |||
150 | #define FP_CLS_NORMAL 0 | ||
151 | #define FP_CLS_ZERO 1 | ||
152 | #define FP_CLS_INF 2 | ||
153 | #define FP_CLS_NAN 3 | ||
154 | |||
155 | #define _FP_CLS_COMBINE(x,y) (((x) << 2) | (y)) | ||
156 | |||
157 | #include <math-emu/op-1.h> | ||
158 | #include <math-emu/op-2.h> | ||
159 | #include <math-emu/op-4.h> | ||
160 | #include <math-emu/op-8.h> | ||
161 | #include <math-emu/op-common.h> | ||
162 | |||
163 | /* Sigh. Silly things longlong.h needs. */ | ||
164 | #define UWtype _FP_W_TYPE | ||
165 | #define W_TYPE_SIZE _FP_W_TYPE_SIZE | ||
166 | |||
167 | typedef int SItype __attribute__((mode(SI))); | ||
168 | typedef int DItype __attribute__((mode(DI))); | ||
169 | typedef unsigned int USItype __attribute__((mode(SI))); | ||
170 | typedef unsigned int UDItype __attribute__((mode(DI))); | ||
171 | #if _FP_W_TYPE_SIZE == 32 | ||
172 | typedef unsigned int UHWtype __attribute__((mode(HI))); | ||
173 | #elif _FP_W_TYPE_SIZE == 64 | ||
174 | typedef USItype UHWtype; | ||
175 | #endif | ||
176 | |||
177 | #ifndef umul_ppmm | ||
178 | #include <stdlib/longlong.h> | ||
179 | #endif | ||
180 | |||
181 | #endif /* __MATH_EMU_SOFT_FP_H__ */ | ||