1 |
|
---|
2 | /*============================================================================
|
---|
3 |
|
---|
4 | This C header file is part of TestFloat, Release 3e, a package of programs for
|
---|
5 | testing the correctness of floating-point arithmetic complying with the IEEE
|
---|
6 | Standard for Floating-Point, by John R. Hauser.
|
---|
7 |
|
---|
8 | Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
|
---|
9 | California. All rights reserved.
|
---|
10 |
|
---|
11 | Redistribution and use in source and binary forms, with or without
|
---|
12 | modification, are permitted provided that the following conditions are met:
|
---|
13 |
|
---|
14 | 1. Redistributions of source code must retain the above copyright notice,
|
---|
15 | this list of conditions, and the following disclaimer.
|
---|
16 |
|
---|
17 | 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
18 | this list of conditions, and the following disclaimer in the documentation
|
---|
19 | and/or other materials provided with the distribution.
|
---|
20 |
|
---|
21 | 3. Neither the name of the University nor the names of its contributors may
|
---|
22 | be used to endorse or promote products derived from this software without
|
---|
23 | specific prior written permission.
|
---|
24 |
|
---|
25 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
---|
26 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
---|
28 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
---|
29 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
31 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
32 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
35 |
|
---|
36 | =============================================================================*/
|
---|
37 |
|
---|
38 | #include <stdbool.h>
|
---|
39 | #include <stdint.h>
|
---|
40 | #include "softfloat.h"
|
---|
41 |
|
---|
42 | extern uint_fast8_t slowfloat_roundingMode;
|
---|
43 | extern uint_fast8_t slowfloat_detectTininess;
|
---|
44 | extern uint_fast8_t slowfloat_exceptionFlags;
|
---|
45 | #ifdef EXTFLOAT80
|
---|
46 | extern uint_fast8_t slow_extF80_roundingPrecision;
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | #ifdef FLOAT16
|
---|
50 | float16_t slow_ui32_to_f16( uint32_t );
|
---|
51 | #endif
|
---|
52 | float32_t slow_ui32_to_f32( uint32_t );
|
---|
53 | #ifdef FLOAT64
|
---|
54 | float64_t slow_ui32_to_f64( uint32_t );
|
---|
55 | #endif
|
---|
56 | #ifdef EXTFLOAT80
|
---|
57 | void slow_ui32_to_extF80M( uint32_t, extFloat80_t * );
|
---|
58 | #endif
|
---|
59 | #ifdef FLOAT128
|
---|
60 | void slow_ui32_to_f128M( uint32_t, float128_t * );
|
---|
61 | #endif
|
---|
62 | #ifdef FLOAT16
|
---|
63 | float16_t slow_ui64_to_f16( uint64_t );
|
---|
64 | #endif
|
---|
65 | float32_t slow_ui64_to_f32( uint64_t );
|
---|
66 | #ifdef FLOAT64
|
---|
67 | float64_t slow_ui64_to_f64( uint64_t );
|
---|
68 | #endif
|
---|
69 | #ifdef EXTFLOAT80
|
---|
70 | void slow_ui64_to_extF80M( uint64_t, extFloat80_t * );
|
---|
71 | #endif
|
---|
72 | #ifdef FLOAT128
|
---|
73 | void slow_ui64_to_f128M( uint64_t, float128_t * );
|
---|
74 | #endif
|
---|
75 | #ifdef FLOAT16
|
---|
76 | float16_t slow_i32_to_f16( int32_t );
|
---|
77 | #endif
|
---|
78 | float32_t slow_i32_to_f32( int32_t );
|
---|
79 | #ifdef FLOAT64
|
---|
80 | float64_t slow_i32_to_f64( int32_t );
|
---|
81 | #endif
|
---|
82 | #ifdef EXTFLOAT80
|
---|
83 | void slow_i32_to_extF80M( int32_t, extFloat80_t * );
|
---|
84 | #endif
|
---|
85 | #ifdef FLOAT128
|
---|
86 | void slow_i32_to_f128M( int32_t, float128_t * );
|
---|
87 | #endif
|
---|
88 | #ifdef FLOAT16
|
---|
89 | float16_t slow_i64_to_f16( int64_t );
|
---|
90 | #endif
|
---|
91 | float32_t slow_i64_to_f32( int64_t );
|
---|
92 | #ifdef FLOAT64
|
---|
93 | float64_t slow_i64_to_f64( int64_t );
|
---|
94 | #endif
|
---|
95 | #ifdef EXTFLOAT80
|
---|
96 | void slow_i64_to_extF80M( int64_t, extFloat80_t * );
|
---|
97 | #endif
|
---|
98 | #ifdef FLOAT128
|
---|
99 | void slow_i64_to_f128M( int64_t, float128_t * );
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | #ifdef FLOAT16
|
---|
103 | uint_fast32_t slow_f16_to_ui32( float16_t, uint_fast8_t, bool );
|
---|
104 | uint_fast64_t slow_f16_to_ui64( float16_t, uint_fast8_t, bool );
|
---|
105 | int_fast32_t slow_f16_to_i32( float16_t, uint_fast8_t, bool );
|
---|
106 | int_fast64_t slow_f16_to_i64( float16_t, uint_fast8_t, bool );
|
---|
107 | uint_fast32_t slow_f16_to_ui32_r_minMag( float16_t, bool );
|
---|
108 | uint_fast64_t slow_f16_to_ui64_r_minMag( float16_t, bool );
|
---|
109 | int_fast32_t slow_f16_to_i32_r_minMag( float16_t, bool );
|
---|
110 | int_fast64_t slow_f16_to_i64_r_minMag( float16_t, bool );
|
---|
111 | float32_t slow_f16_to_f32( float16_t );
|
---|
112 | #ifdef FLOAT64
|
---|
113 | float64_t slow_f16_to_f64( float16_t );
|
---|
114 | #endif
|
---|
115 | #ifdef EXTFLOAT80
|
---|
116 | void slow_f16_to_extF80M( float16_t, extFloat80_t * );
|
---|
117 | #endif
|
---|
118 | #ifdef FLOAT128
|
---|
119 | void slow_f16_to_f128M( float16_t, float128_t * );
|
---|
120 | #endif
|
---|
121 | float16_t slow_f16_roundToInt( float16_t, uint_fast8_t, bool );
|
---|
122 | float16_t slow_f16_add( float16_t, float16_t );
|
---|
123 | float16_t slow_f16_sub( float16_t, float16_t );
|
---|
124 | float16_t slow_f16_mul( float16_t, float16_t );
|
---|
125 | float16_t slow_f16_mulAdd( float16_t, float16_t, float16_t );
|
---|
126 | float16_t slow_f16_div( float16_t, float16_t );
|
---|
127 | float16_t slow_f16_rem( float16_t, float16_t );
|
---|
128 | float16_t slow_f16_sqrt( float16_t );
|
---|
129 | bool slow_f16_eq( float16_t, float16_t );
|
---|
130 | bool slow_f16_le( float16_t, float16_t );
|
---|
131 | bool slow_f16_lt( float16_t, float16_t );
|
---|
132 | bool slow_f16_eq_signaling( float16_t, float16_t );
|
---|
133 | bool slow_f16_le_quiet( float16_t, float16_t );
|
---|
134 | bool slow_f16_lt_quiet( float16_t, float16_t );
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | uint_fast32_t slow_f32_to_ui32( float32_t, uint_fast8_t, bool );
|
---|
138 | uint_fast64_t slow_f32_to_ui64( float32_t, uint_fast8_t, bool );
|
---|
139 | int_fast32_t slow_f32_to_i32( float32_t, uint_fast8_t, bool );
|
---|
140 | int_fast64_t slow_f32_to_i64( float32_t, uint_fast8_t, bool );
|
---|
141 | uint_fast32_t slow_f32_to_ui32_r_minMag( float32_t, bool );
|
---|
142 | uint_fast64_t slow_f32_to_ui64_r_minMag( float32_t, bool );
|
---|
143 | int_fast32_t slow_f32_to_i32_r_minMag( float32_t, bool );
|
---|
144 | int_fast64_t slow_f32_to_i64_r_minMag( float32_t, bool );
|
---|
145 | #ifdef FLOAT16
|
---|
146 | float16_t slow_f32_to_f16( float32_t );
|
---|
147 | #endif
|
---|
148 | #ifdef FLOAT64
|
---|
149 | float64_t slow_f32_to_f64( float32_t );
|
---|
150 | #endif
|
---|
151 | #ifdef EXTFLOAT80
|
---|
152 | void slow_f32_to_extF80M( float32_t, extFloat80_t * );
|
---|
153 | #endif
|
---|
154 | #ifdef FLOAT128
|
---|
155 | void slow_f32_to_f128M( float32_t, float128_t * );
|
---|
156 | #endif
|
---|
157 | float32_t slow_f32_roundToInt( float32_t, uint_fast8_t, bool );
|
---|
158 | float32_t slow_f32_add( float32_t, float32_t );
|
---|
159 | float32_t slow_f32_sub( float32_t, float32_t );
|
---|
160 | float32_t slow_f32_mul( float32_t, float32_t );
|
---|
161 | float32_t slow_f32_mulAdd( float32_t, float32_t, float32_t );
|
---|
162 | float32_t slow_f32_div( float32_t, float32_t );
|
---|
163 | float32_t slow_f32_rem( float32_t, float32_t );
|
---|
164 | float32_t slow_f32_sqrt( float32_t );
|
---|
165 | bool slow_f32_eq( float32_t, float32_t );
|
---|
166 | bool slow_f32_le( float32_t, float32_t );
|
---|
167 | bool slow_f32_lt( float32_t, float32_t );
|
---|
168 | bool slow_f32_eq_signaling( float32_t, float32_t );
|
---|
169 | bool slow_f32_le_quiet( float32_t, float32_t );
|
---|
170 | bool slow_f32_lt_quiet( float32_t, float32_t );
|
---|
171 |
|
---|
172 | #ifdef FLOAT64
|
---|
173 | uint_fast32_t slow_f64_to_ui32( float64_t, uint_fast8_t, bool );
|
---|
174 | uint_fast64_t slow_f64_to_ui64( float64_t, uint_fast8_t, bool );
|
---|
175 | int_fast32_t slow_f64_to_i32( float64_t, uint_fast8_t, bool );
|
---|
176 | int_fast64_t slow_f64_to_i64( float64_t, uint_fast8_t, bool );
|
---|
177 | uint_fast32_t slow_f64_to_ui32_r_minMag( float64_t, bool );
|
---|
178 | uint_fast64_t slow_f64_to_ui64_r_minMag( float64_t, bool );
|
---|
179 | int_fast32_t slow_f64_to_i32_r_minMag( float64_t, bool );
|
---|
180 | int_fast64_t slow_f64_to_i64_r_minMag( float64_t, bool );
|
---|
181 | #ifdef FLOAT16
|
---|
182 | float16_t slow_f64_to_f16( float64_t );
|
---|
183 | #endif
|
---|
184 | float32_t slow_f64_to_f32( float64_t );
|
---|
185 | #ifdef EXTFLOAT80
|
---|
186 | void slow_f64_to_extF80M( float64_t, extFloat80_t * );
|
---|
187 | #endif
|
---|
188 | #ifdef FLOAT128
|
---|
189 | void slow_f64_to_f128M( float64_t, float128_t * );
|
---|
190 | #endif
|
---|
191 | float64_t slow_f64_roundToInt( float64_t, uint_fast8_t, bool );
|
---|
192 | float64_t slow_f64_add( float64_t, float64_t );
|
---|
193 | float64_t slow_f64_sub( float64_t, float64_t );
|
---|
194 | float64_t slow_f64_mul( float64_t, float64_t );
|
---|
195 | float64_t slow_f64_mulAdd( float64_t, float64_t, float64_t );
|
---|
196 | float64_t slow_f64_div( float64_t, float64_t );
|
---|
197 | float64_t slow_f64_rem( float64_t, float64_t );
|
---|
198 | float64_t slow_f64_sqrt( float64_t );
|
---|
199 | bool slow_f64_eq( float64_t, float64_t );
|
---|
200 | bool slow_f64_le( float64_t, float64_t );
|
---|
201 | bool slow_f64_lt( float64_t, float64_t );
|
---|
202 | bool slow_f64_eq_signaling( float64_t, float64_t );
|
---|
203 | bool slow_f64_le_quiet( float64_t, float64_t );
|
---|
204 | bool slow_f64_lt_quiet( float64_t, float64_t );
|
---|
205 | #endif
|
---|
206 |
|
---|
207 | #ifdef EXTFLOAT80
|
---|
208 | uint_fast32_t slow_extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool );
|
---|
209 | uint_fast64_t slow_extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool );
|
---|
210 | int_fast32_t slow_extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool );
|
---|
211 | int_fast64_t slow_extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool );
|
---|
212 | uint_fast32_t slow_extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
|
---|
213 | uint_fast64_t slow_extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
|
---|
214 | int_fast32_t slow_extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
|
---|
215 | int_fast64_t slow_extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
|
---|
216 | #ifdef FLOAT16
|
---|
217 | float16_t slow_extF80M_to_f16( const extFloat80_t * );
|
---|
218 | #endif
|
---|
219 | float32_t slow_extF80M_to_f32( const extFloat80_t * );
|
---|
220 | #ifdef FLOAT64
|
---|
221 | float64_t slow_extF80M_to_f64( const extFloat80_t * );
|
---|
222 | #endif
|
---|
223 | #ifdef FLOAT128
|
---|
224 | void slow_extF80M_to_f128M( const extFloat80_t *, float128_t * );
|
---|
225 | #endif
|
---|
226 | void
|
---|
227 | slow_extF80M_roundToInt(
|
---|
228 | const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * );
|
---|
229 | void
|
---|
230 | slow_extF80M_add(
|
---|
231 | const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
---|
232 | void
|
---|
233 | slow_extF80M_sub(
|
---|
234 | const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
---|
235 | void
|
---|
236 | slow_extF80M_mul(
|
---|
237 | const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
---|
238 | void
|
---|
239 | slow_extF80M_mulAdd(
|
---|
240 | const extFloat80_t *,
|
---|
241 | const extFloat80_t *,
|
---|
242 | const extFloat80_t *,
|
---|
243 | extFloat80_t *
|
---|
244 | );
|
---|
245 | void
|
---|
246 | slow_extF80M_div(
|
---|
247 | const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
---|
248 | void
|
---|
249 | slow_extF80M_rem(
|
---|
250 | const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
---|
251 | void slow_extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
|
---|
252 | bool slow_extF80M_eq( const extFloat80_t *, const extFloat80_t * );
|
---|
253 | bool slow_extF80M_le( const extFloat80_t *, const extFloat80_t * );
|
---|
254 | bool slow_extF80M_lt( const extFloat80_t *, const extFloat80_t * );
|
---|
255 | bool slow_extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
|
---|
256 | bool slow_extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
|
---|
257 | bool slow_extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
|
---|
258 | #endif
|
---|
259 |
|
---|
260 | #ifdef FLOAT128
|
---|
261 | uint_fast32_t slow_f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
|
---|
262 | uint_fast64_t slow_f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
|
---|
263 | int_fast32_t slow_f128M_to_i32( const float128_t *, uint_fast8_t, bool );
|
---|
264 | int_fast64_t slow_f128M_to_i64( const float128_t *, uint_fast8_t, bool );
|
---|
265 | uint_fast32_t slow_f128M_to_ui32_r_minMag( const float128_t *, bool );
|
---|
266 | uint_fast64_t slow_f128M_to_ui64_r_minMag( const float128_t *, bool );
|
---|
267 | int_fast32_t slow_f128M_to_i32_r_minMag( const float128_t *, bool );
|
---|
268 | int_fast64_t slow_f128M_to_i64_r_minMag( const float128_t *, bool );
|
---|
269 | #ifdef FLOAT16
|
---|
270 | float16_t slow_f128M_to_f16( const float128_t * );
|
---|
271 | #endif
|
---|
272 | float32_t slow_f128M_to_f32( const float128_t * );
|
---|
273 | #ifdef FLOAT64
|
---|
274 | float64_t slow_f128M_to_f64( const float128_t * );
|
---|
275 | #endif
|
---|
276 | #ifdef EXTFLOAT80
|
---|
277 | void slow_f128M_to_extF80M( const float128_t *, extFloat80_t * );
|
---|
278 | #endif
|
---|
279 | void
|
---|
280 | slow_f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
|
---|
281 | void slow_f128M_add( const float128_t *, const float128_t *, float128_t * );
|
---|
282 | void slow_f128M_sub( const float128_t *, const float128_t *, float128_t * );
|
---|
283 | void slow_f128M_mul( const float128_t *, const float128_t *, float128_t * );
|
---|
284 | void
|
---|
285 | slow_f128M_mulAdd(
|
---|
286 | const float128_t *, const float128_t *, const float128_t *, float128_t *
|
---|
287 | );
|
---|
288 | void slow_f128M_div( const float128_t *, const float128_t *, float128_t * );
|
---|
289 | void slow_f128M_rem( const float128_t *, const float128_t *, float128_t * );
|
---|
290 | void slow_f128M_sqrt( const float128_t *, float128_t * );
|
---|
291 | bool slow_f128M_eq( const float128_t *, const float128_t * );
|
---|
292 | bool slow_f128M_le( const float128_t *, const float128_t * );
|
---|
293 | bool slow_f128M_lt( const float128_t *, const float128_t * );
|
---|
294 | bool slow_f128M_eq_signaling( const float128_t *, const float128_t * );
|
---|
295 | bool slow_f128M_le_quiet( const float128_t *, const float128_t * );
|
---|
296 | bool slow_f128M_lt_quiet( const float128_t *, const float128_t * );
|
---|
297 | #endif
|
---|
298 |
|
---|