1 |
|
---|
2 | /*============================================================================
|
---|
3 |
|
---|
4 | This C source 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, 2016, 2017 The Regents of the
|
---|
9 | University of 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 "platform.h"
|
---|
40 | #include "functions.h"
|
---|
41 |
|
---|
42 | #define ARG_1 FUNC_ARG_UNARY
|
---|
43 | #define ARG_2 FUNC_ARG_BINARY
|
---|
44 | #define ARG_R FUNC_ARG_ROUNDINGMODE
|
---|
45 | #define ARG_E FUNC_ARG_EXACT
|
---|
46 | #define EFF_P FUNC_EFF_ROUNDINGPRECISION
|
---|
47 | #define EFF_R FUNC_EFF_ROUNDINGMODE
|
---|
48 | #define EFF_T FUNC_EFF_TININESSMODE
|
---|
49 | #define EFF_T_REDP FUNC_EFF_TININESSMODE_REDUCEDPREC
|
---|
50 |
|
---|
51 | /*----------------------------------------------------------------------------
|
---|
52 | | Warning: This array must match the list of macros defined in "functions.h".
|
---|
53 | *----------------------------------------------------------------------------*/
|
---|
54 | const struct functionInfo functionInfos[NUM_FUNCTIONS] = {
|
---|
55 | { 0, 0 },
|
---|
56 | /*------------------------------------------------------------------------
|
---|
57 | *------------------------------------------------------------------------*/
|
---|
58 | #ifdef FLOAT16
|
---|
59 | { "ui32_to_f16", ARG_1 | EFF_R },
|
---|
60 | #endif
|
---|
61 | { "ui32_to_f32", ARG_1 | EFF_R },
|
---|
62 | #ifdef FLOAT64
|
---|
63 | { "ui32_to_f64", ARG_1 },
|
---|
64 | #endif
|
---|
65 | #ifdef EXTFLOAT80
|
---|
66 | { "ui32_to_extF80", ARG_1 },
|
---|
67 | #endif
|
---|
68 | #ifdef FLOAT128
|
---|
69 | { "ui32_to_f128", ARG_1 },
|
---|
70 | #endif
|
---|
71 | #ifdef FLOAT16
|
---|
72 | { "ui64_to_f16", ARG_1 | EFF_R },
|
---|
73 | #endif
|
---|
74 | { "ui64_to_f32", ARG_1 | EFF_R },
|
---|
75 | #ifdef FLOAT64
|
---|
76 | { "ui64_to_f64", ARG_1 | EFF_R },
|
---|
77 | #endif
|
---|
78 | #ifdef EXTFLOAT80
|
---|
79 | { "ui64_to_extF80", ARG_1 },
|
---|
80 | #endif
|
---|
81 | #ifdef FLOAT128
|
---|
82 | { "ui64_to_f128", ARG_1 },
|
---|
83 | #endif
|
---|
84 | #ifdef FLOAT16
|
---|
85 | { "i32_to_f16", ARG_1 | EFF_R },
|
---|
86 | #endif
|
---|
87 | { "i32_to_f32", ARG_1 | EFF_R },
|
---|
88 | #ifdef FLOAT64
|
---|
89 | { "i32_to_f64", ARG_1 },
|
---|
90 | #endif
|
---|
91 | #ifdef EXTFLOAT80
|
---|
92 | { "i32_to_extF80", ARG_1 },
|
---|
93 | #endif
|
---|
94 | #ifdef FLOAT128
|
---|
95 | { "i32_to_f128", ARG_1 },
|
---|
96 | #endif
|
---|
97 | #ifdef FLOAT16
|
---|
98 | { "i64_to_f16", ARG_1 | EFF_R },
|
---|
99 | #endif
|
---|
100 | { "i64_to_f32", ARG_1 | EFF_R },
|
---|
101 | #ifdef FLOAT64
|
---|
102 | { "i64_to_f64", ARG_1 | EFF_R },
|
---|
103 | #endif
|
---|
104 | #ifdef EXTFLOAT80
|
---|
105 | { "i64_to_extF80", ARG_1 },
|
---|
106 | #endif
|
---|
107 | #ifdef FLOAT128
|
---|
108 | { "i64_to_f128", ARG_1 },
|
---|
109 | #endif
|
---|
110 | /*------------------------------------------------------------------------
|
---|
111 | *------------------------------------------------------------------------*/
|
---|
112 | #ifdef FLOAT16
|
---|
113 | { "f16_to_ui32", ARG_1 | ARG_R | ARG_E },
|
---|
114 | { "f16_to_ui64", ARG_1 | ARG_R | ARG_E },
|
---|
115 | { "f16_to_i32", ARG_1 | ARG_R | ARG_E },
|
---|
116 | { "f16_to_i64", ARG_1 | ARG_R | ARG_E },
|
---|
117 | { "f16_to_ui32_r_minMag", ARG_1 | ARG_E },
|
---|
118 | { "f16_to_ui64_r_minMag", ARG_1 | ARG_E },
|
---|
119 | { "f16_to_i32_r_minMag", ARG_1 | ARG_E },
|
---|
120 | { "f16_to_i64_r_minMag", ARG_1 | ARG_E },
|
---|
121 | { "f16_to_f32", ARG_1 },
|
---|
122 | #ifdef FLOAT64
|
---|
123 | { "f16_to_f64", ARG_1 },
|
---|
124 | #endif
|
---|
125 | #ifdef EXTFLOAT80
|
---|
126 | { "f16_to_extF80", ARG_1 },
|
---|
127 | #endif
|
---|
128 | #ifdef FLOAT128
|
---|
129 | { "f16_to_f128", ARG_1 },
|
---|
130 | #endif
|
---|
131 | { "f16_roundToInt", ARG_1 | ARG_R | ARG_E },
|
---|
132 | { "f16_add", ARG_2 | EFF_R },
|
---|
133 | { "f16_sub", ARG_2 | EFF_R },
|
---|
134 | { "f16_mul", ARG_2 | EFF_R | EFF_T },
|
---|
135 | { "f16_mulAdd", EFF_R | EFF_T },
|
---|
136 | { "f16_div", ARG_2 | EFF_R },
|
---|
137 | { "f16_rem", ARG_2 },
|
---|
138 | { "f16_sqrt", ARG_1 | EFF_R },
|
---|
139 | { "f16_eq", ARG_2 },
|
---|
140 | { "f16_le", ARG_2 },
|
---|
141 | { "f16_lt", ARG_2 },
|
---|
142 | { "f16_eq_signaling", ARG_2 },
|
---|
143 | { "f16_le_quiet", ARG_2 },
|
---|
144 | { "f16_lt_quiet", ARG_2 },
|
---|
145 | #endif
|
---|
146 | /*------------------------------------------------------------------------
|
---|
147 | *------------------------------------------------------------------------*/
|
---|
148 | { "f32_to_ui32", ARG_1 | ARG_R | ARG_E },
|
---|
149 | { "f32_to_ui64", ARG_1 | ARG_R | ARG_E },
|
---|
150 | { "f32_to_i32", ARG_1 | ARG_R | ARG_E },
|
---|
151 | { "f32_to_i64", ARG_1 | ARG_R | ARG_E },
|
---|
152 | { "f32_to_ui32_r_minMag", ARG_1 | ARG_E },
|
---|
153 | { "f32_to_ui64_r_minMag", ARG_1 | ARG_E },
|
---|
154 | { "f32_to_i32_r_minMag", ARG_1 | ARG_E },
|
---|
155 | { "f32_to_i64_r_minMag", ARG_1 | ARG_E },
|
---|
156 | #ifdef FLOAT16
|
---|
157 | { "f32_to_f16", ARG_1 | EFF_R | EFF_T },
|
---|
158 | #endif
|
---|
159 | #ifdef FLOAT64
|
---|
160 | { "f32_to_f64", ARG_1 },
|
---|
161 | #endif
|
---|
162 | #ifdef EXTFLOAT80
|
---|
163 | { "f32_to_extF80", ARG_1 },
|
---|
164 | #endif
|
---|
165 | #ifdef FLOAT128
|
---|
166 | { "f32_to_f128", ARG_1 },
|
---|
167 | #endif
|
---|
168 | { "f32_roundToInt", ARG_1 | ARG_R | ARG_E },
|
---|
169 | { "f32_add", ARG_2 | EFF_R },
|
---|
170 | { "f32_sub", ARG_2 | EFF_R },
|
---|
171 | { "f32_mul", ARG_2 | EFF_R | EFF_T },
|
---|
172 | { "f32_mulAdd", EFF_R | EFF_T },
|
---|
173 | { "f32_div", ARG_2 | EFF_R },
|
---|
174 | { "f32_rem", ARG_2 },
|
---|
175 | { "f32_sqrt", ARG_1 | EFF_R },
|
---|
176 | { "f32_eq", ARG_2 },
|
---|
177 | { "f32_le", ARG_2 },
|
---|
178 | { "f32_lt", ARG_2 },
|
---|
179 | { "f32_eq_signaling", ARG_2 },
|
---|
180 | { "f32_le_quiet", ARG_2 },
|
---|
181 | { "f32_lt_quiet", ARG_2 },
|
---|
182 | /*------------------------------------------------------------------------
|
---|
183 | *------------------------------------------------------------------------*/
|
---|
184 | #ifdef FLOAT64
|
---|
185 | { "f64_to_ui32", ARG_1 | ARG_R | ARG_E },
|
---|
186 | { "f64_to_ui64", ARG_1 | ARG_R | ARG_E },
|
---|
187 | { "f64_to_i32", ARG_1 | ARG_R | ARG_E },
|
---|
188 | { "f64_to_i64", ARG_1 | ARG_R | ARG_E },
|
---|
189 | { "f64_to_ui32_r_minMag", ARG_1 | ARG_E },
|
---|
190 | { "f64_to_ui64_r_minMag", ARG_1 | ARG_E },
|
---|
191 | { "f64_to_i32_r_minMag", ARG_1 | ARG_E },
|
---|
192 | { "f64_to_i64_r_minMag", ARG_1 | ARG_E },
|
---|
193 | #ifdef FLOAT16
|
---|
194 | { "f64_to_f16", ARG_1 | EFF_R | EFF_T },
|
---|
195 | #endif
|
---|
196 | { "f64_to_f32", ARG_1 | EFF_R | EFF_T },
|
---|
197 | #ifdef EXTFLOAT80
|
---|
198 | { "f64_to_extF80", ARG_1 },
|
---|
199 | #endif
|
---|
200 | #ifdef FLOAT128
|
---|
201 | { "f64_to_f128", ARG_1 },
|
---|
202 | #endif
|
---|
203 | { "f64_roundToInt", ARG_1 | ARG_R | ARG_E },
|
---|
204 | { "f64_add", ARG_2 | EFF_R },
|
---|
205 | { "f64_sub", ARG_2 | EFF_R },
|
---|
206 | { "f64_mul", ARG_2 | EFF_R | EFF_T },
|
---|
207 | { "f64_mulAdd", EFF_R | EFF_T },
|
---|
208 | { "f64_div", ARG_2 | EFF_R },
|
---|
209 | { "f64_rem", ARG_2 },
|
---|
210 | { "f64_sqrt", ARG_1 | EFF_R },
|
---|
211 | { "f64_eq", ARG_2 },
|
---|
212 | { "f64_le", ARG_2 },
|
---|
213 | { "f64_lt", ARG_2 },
|
---|
214 | { "f64_eq_signaling", ARG_2 },
|
---|
215 | { "f64_le_quiet", ARG_2 },
|
---|
216 | { "f64_lt_quiet", ARG_2 },
|
---|
217 | #endif
|
---|
218 | /*------------------------------------------------------------------------
|
---|
219 | *------------------------------------------------------------------------*/
|
---|
220 | #ifdef EXTFLOAT80
|
---|
221 | { "extF80_to_ui32", ARG_1 | ARG_R | ARG_E },
|
---|
222 | { "extF80_to_ui64", ARG_1 | ARG_R | ARG_E },
|
---|
223 | { "extF80_to_i32", ARG_1 | ARG_R | ARG_E },
|
---|
224 | { "extF80_to_i64", ARG_1 | ARG_R | ARG_E },
|
---|
225 | { "extF80_to_ui32_r_minMag", ARG_1 | ARG_E },
|
---|
226 | { "extF80_to_ui64_r_minMag", ARG_1 | ARG_E },
|
---|
227 | { "extF80_to_i32_r_minMag", ARG_1 | ARG_E },
|
---|
228 | { "extF80_to_i64_r_minMag", ARG_1 | ARG_E },
|
---|
229 | #ifdef FLOAT16
|
---|
230 | { "extF80_to_f16", ARG_1 | EFF_R | EFF_T },
|
---|
231 | #endif
|
---|
232 | { "extF80_to_f32", ARG_1 | EFF_R | EFF_T },
|
---|
233 | #ifdef FLOAT64
|
---|
234 | { "extF80_to_f64", ARG_1 | EFF_R | EFF_T },
|
---|
235 | #endif
|
---|
236 | #ifdef FLOAT128
|
---|
237 | { "extF80_to_f128", ARG_1 },
|
---|
238 | #endif
|
---|
239 | { "extF80_roundToInt", ARG_1 | ARG_R | ARG_E },
|
---|
240 | { "extF80_add", ARG_2 | EFF_P | EFF_R | EFF_T_REDP },
|
---|
241 | { "extF80_sub", ARG_2 | EFF_P | EFF_R | EFF_T_REDP },
|
---|
242 | { "extF80_mul", ARG_2 | EFF_P | EFF_R | EFF_T | EFF_T_REDP },
|
---|
243 | { "extF80_div", ARG_2 | EFF_P | EFF_R | EFF_T_REDP },
|
---|
244 | { "extF80_rem", ARG_2 },
|
---|
245 | { "extF80_sqrt", ARG_1 | EFF_P | EFF_R },
|
---|
246 | { "extF80_eq", ARG_2 },
|
---|
247 | { "extF80_le", ARG_2 },
|
---|
248 | { "extF80_lt", ARG_2 },
|
---|
249 | { "extF80_eq_signaling", ARG_2 },
|
---|
250 | { "extF80_le_quiet", ARG_2 },
|
---|
251 | { "extF80_lt_quiet", ARG_2 },
|
---|
252 | #endif
|
---|
253 | /*------------------------------------------------------------------------
|
---|
254 | *------------------------------------------------------------------------*/
|
---|
255 | #ifdef FLOAT128
|
---|
256 | { "f128_to_ui32", ARG_1 | ARG_R | ARG_E },
|
---|
257 | { "f128_to_ui64", ARG_1 | ARG_R | ARG_E },
|
---|
258 | { "f128_to_i32", ARG_1 | ARG_R | ARG_E },
|
---|
259 | { "f128_to_i64", ARG_1 | ARG_R | ARG_E },
|
---|
260 | { "f128_to_ui32_r_minMag", ARG_1 | ARG_E },
|
---|
261 | { "f128_to_ui64_r_minMag", ARG_1 | ARG_E },
|
---|
262 | { "f128_to_i32_r_minMag", ARG_1 | ARG_E },
|
---|
263 | { "f128_to_i64_r_minMag", ARG_1 | ARG_E },
|
---|
264 | #ifdef FLOAT16
|
---|
265 | { "f128_to_f16", ARG_1 | EFF_R | EFF_T },
|
---|
266 | #endif
|
---|
267 | { "f128_to_f32", ARG_1 | EFF_R | EFF_T },
|
---|
268 | #ifdef FLOAT64
|
---|
269 | { "f128_to_f64", ARG_1 | EFF_R | EFF_T },
|
---|
270 | #endif
|
---|
271 | #ifdef EXTFLOAT80
|
---|
272 | { "f128_to_extF80", ARG_1 | EFF_R | EFF_T },
|
---|
273 | #endif
|
---|
274 | { "f128_roundToInt", ARG_1 | ARG_R | ARG_E },
|
---|
275 | { "f128_add", ARG_2 | EFF_R },
|
---|
276 | { "f128_sub", ARG_2 | EFF_R },
|
---|
277 | { "f128_mul", ARG_2 | EFF_R | EFF_T },
|
---|
278 | { "f128_mulAdd", EFF_R | EFF_T },
|
---|
279 | { "f128_div", ARG_2 | EFF_R },
|
---|
280 | { "f128_rem", ARG_2 },
|
---|
281 | { "f128_sqrt", ARG_1 | EFF_R },
|
---|
282 | { "f128_eq", ARG_2 },
|
---|
283 | { "f128_le", ARG_2 },
|
---|
284 | { "f128_lt", ARG_2 },
|
---|
285 | { "f128_eq_signaling", ARG_2 },
|
---|
286 | { "f128_le_quiet", ARG_2 },
|
---|
287 | { "f128_lt_quiet", ARG_2 },
|
---|
288 | #endif
|
---|
289 | };
|
---|
290 |
|
---|