]> Git Repo - qemu.git/blame - fpu/softfloat-native.h
enable APIC by default
[qemu.git] / fpu / softfloat-native.h
CommitLineData
158142c2
FB
1/* Native implementation of soft float functions */
2#include <math.h>
3#if defined(_BSD) && !defined(__APPLE__)
4#include <ieeefp.h>
5#else
6#include <fenv.h>
7#endif
8
9typedef float float32;
10typedef double float64;
11#ifdef FLOATX80
12typedef long double floatx80;
13#endif
14
15typedef union {
16 float32 f;
17 uint32_t i;
18} float32u;
19typedef union {
20 float64 f;
21 uint64_t i;
22} float64u;
23#ifdef FLOATX80
24typedef union {
25 floatx80 f;
26 struct {
27 uint64_t low;
28 uint16_t high;
29 } i;
30} floatx80u;
31#endif
32
33/*----------------------------------------------------------------------------
34| Software IEC/IEEE floating-point rounding mode.
35*----------------------------------------------------------------------------*/
36#if defined(_BSD) && !defined(__APPLE__)
37enum {
38 float_round_nearest_even = FP_RN,
39 float_round_down = FE_RM,
40 float_round_up = FE_RP,
41 float_round_to_zero = FE_RZ
42};
43#elif defined(__arm__)
44enum {
45 float_round_nearest_even = 0,
46 float_round_down = 1,
47 float_round_up = 2,
48 float_round_to_zero = 3
49};
50#else
51enum {
52 float_round_nearest_even = FE_TONEAREST,
53 float_round_down = FE_DOWNWARD,
54 float_round_up = FE_UPWARD,
55 float_round_to_zero = FE_TOWARDZERO
56};
57#endif
58
59typedef struct float_status {
60 signed char float_rounding_mode;
61#ifdef FLOATX80
62 signed char floatx80_rounding_precision;
63#endif
64} float_status;
65
66void set_float_rounding_mode(int val STATUS_PARAM);
67#ifdef FLOATX80
68void set_floatx80_rounding_precision(int val STATUS_PARAM);
69#endif
70
71/*----------------------------------------------------------------------------
72| Software IEC/IEEE integer-to-floating-point conversion routines.
73*----------------------------------------------------------------------------*/
74float32 int32_to_float32( int STATUS_PARAM);
75float64 int32_to_float64( int STATUS_PARAM);
76#ifdef FLOATX80
77floatx80 int32_to_floatx80( int STATUS_PARAM);
78#endif
79#ifdef FLOAT128
80float128 int32_to_float128( int STATUS_PARAM);
81#endif
82float32 int64_to_float32( int64_t STATUS_PARAM);
83float64 int64_to_float64( int64_t STATUS_PARAM);
84#ifdef FLOATX80
85floatx80 int64_to_floatx80( int64_t STATUS_PARAM);
86#endif
87#ifdef FLOAT128
88float128 int64_to_float128( int64_t STATUS_PARAM);
89#endif
90
91/*----------------------------------------------------------------------------
92| Software IEC/IEEE single-precision conversion routines.
93*----------------------------------------------------------------------------*/
94int float32_to_int32( float32 STATUS_PARAM);
95int float32_to_int32_round_to_zero( float32 STATUS_PARAM);
96int64_t float32_to_int64( float32 STATUS_PARAM);
97int64_t float32_to_int64_round_to_zero( float32 STATUS_PARAM);
98float64 float32_to_float64( float32 STATUS_PARAM);
99#ifdef FLOATX80
100floatx80 float32_to_floatx80( float32 STATUS_PARAM);
101#endif
102#ifdef FLOAT128
103float128 float32_to_float128( float32 STATUS_PARAM);
104#endif
105
106/*----------------------------------------------------------------------------
107| Software IEC/IEEE single-precision operations.
108*----------------------------------------------------------------------------*/
109float32 float32_round_to_int( float32 STATUS_PARAM);
110INLINE float32 float32_add( float32 a, float32 b STATUS_PARAM)
111{
112 return a + b;
113}
114INLINE float32 float32_sub( float32 a, float32 b STATUS_PARAM)
115{
116 return a - b;
117}
118INLINE float32 float32_mul( float32 a, float32 b STATUS_PARAM)
119{
120 return a * b;
121}
122INLINE float32 float32_div( float32 a, float32 b STATUS_PARAM)
123{
124 return a / b;
125}
126float32 float32_rem( float32, float32 STATUS_PARAM);
127float32 float32_sqrt( float32 STATUS_PARAM);
128INLINE char float32_eq( float32 a, float32 b STATUS_PARAM)
129{
158142c2
FB
130 return a == b;
131}
132INLINE char float32_le( float32 a, float32 b STATUS_PARAM)
133{
134 return a <= b;
135}
136INLINE char float32_lt( float32 a, float32 b STATUS_PARAM)
137{
138 return a < b;
139}
140INLINE char float32_eq_signaling( float32 a, float32 b STATUS_PARAM)
141{
b109f9f8 142 return a <= b && a >= b;
158142c2
FB
143}
144INLINE char float32_le_quiet( float32 a, float32 b STATUS_PARAM)
145{
146 return islessequal(a, b);
147}
148INLINE char float32_lt_quiet( float32 a, float32 b STATUS_PARAM)
149{
150 return isless(a, b);
151}
b109f9f8
FB
152INLINE char float32_unordered( float32 a, float32 b STATUS_PARAM)
153{
154 return isunordered(a, b);
155
156}
157char float32_compare( float32, float32 STATUS_PARAM );
158char float32_compare_quiet( float32, float32 STATUS_PARAM );
158142c2
FB
159char float32_is_signaling_nan( float32 );
160
161INLINE float32 float32_abs(float32 a)
162{
163 return fabsf(a);
164}
165
166INLINE float32 float32_chs(float32 a)
167{
168 return -a;
169}
170
171/*----------------------------------------------------------------------------
172| Software IEC/IEEE double-precision conversion routines.
173*----------------------------------------------------------------------------*/
174int float64_to_int32( float64 STATUS_PARAM );
175int float64_to_int32_round_to_zero( float64 STATUS_PARAM );
176int64_t float64_to_int64( float64 STATUS_PARAM );
177int64_t float64_to_int64_round_to_zero( float64 STATUS_PARAM );
178float32 float64_to_float32( float64 STATUS_PARAM );
179#ifdef FLOATX80
180floatx80 float64_to_floatx80( float64 STATUS_PARAM );
181#endif
182#ifdef FLOAT128
183float128 float64_to_float128( float64 STATUS_PARAM );
184#endif
185
186/*----------------------------------------------------------------------------
187| Software IEC/IEEE double-precision operations.
188*----------------------------------------------------------------------------*/
189float64 float64_round_to_int( float64 STATUS_PARAM );
190INLINE float64 float64_add( float64 a, float64 b STATUS_PARAM)
191{
192 return a + b;
193}
194INLINE float64 float64_sub( float64 a, float64 b STATUS_PARAM)
195{
196 return a - b;
197}
198INLINE float64 float64_mul( float64 a, float64 b STATUS_PARAM)
199{
200 return a * b;
201}
202INLINE float64 float64_div( float64 a, float64 b STATUS_PARAM)
203{
204 return a / b;
205}
206float64 float64_rem( float64, float64 STATUS_PARAM );
207float64 float64_sqrt( float64 STATUS_PARAM );
208INLINE char float64_eq( float64 a, float64 b STATUS_PARAM)
209{
210 return a == b;
211}
212INLINE char float64_le( float64 a, float64 b STATUS_PARAM)
213{
214 return a <= b;
215}
216INLINE char float64_lt( float64 a, float64 b STATUS_PARAM)
217{
218 return a < b;
219}
220INLINE char float64_eq_signaling( float64 a, float64 b STATUS_PARAM)
221{
b109f9f8 222 return a <= b && a >= b;
158142c2
FB
223}
224INLINE char float64_le_quiet( float64 a, float64 b STATUS_PARAM)
225{
226 return islessequal(a, b);
227}
228INLINE char float64_lt_quiet( float64 a, float64 b STATUS_PARAM)
229{
230 return isless(a, b);
231
232}
b109f9f8
FB
233INLINE char float64_unordered( float64 a, float64 b STATUS_PARAM)
234{
235 return isunordered(a, b);
236
237}
238char float64_compare( float64, float64 STATUS_PARAM );
239char float64_compare_quiet( float64, float64 STATUS_PARAM );
158142c2
FB
240char float64_is_signaling_nan( float64 );
241
242INLINE float64 float64_abs(float64 a)
243{
244 return fabs(a);
245}
246
247INLINE float64 float64_chs(float64 a)
248{
249 return -a;
250}
251
252#ifdef FLOATX80
253
254/*----------------------------------------------------------------------------
255| Software IEC/IEEE extended double-precision conversion routines.
256*----------------------------------------------------------------------------*/
257int floatx80_to_int32( floatx80 STATUS_PARAM );
258int floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
259int64_t floatx80_to_int64( floatx80 STATUS_PARAM);
260int64_t floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM);
261float32 floatx80_to_float32( floatx80 STATUS_PARAM );
262float64 floatx80_to_float64( floatx80 STATUS_PARAM );
263#ifdef FLOAT128
264float128 floatx80_to_float128( floatx80 STATUS_PARAM );
265#endif
266
267/*----------------------------------------------------------------------------
268| Software IEC/IEEE extended double-precision operations.
269*----------------------------------------------------------------------------*/
270floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM );
271INLINE floatx80 floatx80_add( floatx80 a, floatx80 b STATUS_PARAM)
272{
273 return a + b;
274}
275INLINE floatx80 floatx80_sub( floatx80 a, floatx80 b STATUS_PARAM)
276{
277 return a - b;
278}
279INLINE floatx80 floatx80_mul( floatx80 a, floatx80 b STATUS_PARAM)
280{
281 return a * b;
282}
283INLINE floatx80 floatx80_div( floatx80 a, floatx80 b STATUS_PARAM)
284{
285 return a / b;
286}
287floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM );
288floatx80 floatx80_sqrt( floatx80 STATUS_PARAM );
289INLINE char floatx80_eq( floatx80 a, floatx80 b STATUS_PARAM)
290{
291 return a == b;
292}
293INLINE char floatx80_le( floatx80 a, floatx80 b STATUS_PARAM)
294{
295 return a <= b;
296}
297INLINE char floatx80_lt( floatx80 a, floatx80 b STATUS_PARAM)
298{
299 return a < b;
300}
301INLINE char floatx80_eq_signaling( floatx80 a, floatx80 b STATUS_PARAM)
302{
b109f9f8 303 return a <= b && a >= b;
158142c2
FB
304}
305INLINE char floatx80_le_quiet( floatx80 a, floatx80 b STATUS_PARAM)
306{
307 return islessequal(a, b);
308}
309INLINE char floatx80_lt_quiet( floatx80 a, floatx80 b STATUS_PARAM)
310{
311 return isless(a, b);
312
313}
b109f9f8
FB
314INLINE char floatx80_unordered( floatx80 a, floatx80 b STATUS_PARAM)
315{
316 return isunordered(a, b);
317
318}
319char floatx80_compare( floatx80, floatx80 STATUS_PARAM );
320char floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM );
158142c2
FB
321char floatx80_is_signaling_nan( floatx80 );
322
323INLINE floatx80 floatx80_abs(floatx80 a)
324{
325 return fabsl(a);
326}
327
328INLINE floatx80 floatx80_chs(floatx80 a)
329{
330 return -a;
331}
332#endif
This page took 0.06867 seconds and 4 git commands to generate.