testFunction.c revision 1.4 1 /* $NetBSD: testFunction.c,v 1.4 2002/02/21 07:38:16 itojun Exp $ */
2
3 /* This is a derivative work. */
4
5 /*-
6 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Ross Harvey.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the NetBSD
23 * Foundation, Inc. and its contributors.
24 * 4. Neither the name of The NetBSD Foundation nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41 /*
42 ===============================================================================
43
44 This C source file is part of TestFloat, Release 2a, a package of programs
45 for testing the correctness of floating-point arithmetic complying to the
46 IEC/IEEE Standard for Floating-Point.
47
48 Written by John R. Hauser. More information is available through the Web
49 page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
50
51 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
52 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
53 TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
54 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
55 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
56
57 Derivative works are acceptable, even for commercial purposes, so long as
58 (1) they include prominent notice that the work is derivative, and (2) they
59 include prominent notice akin to these four paragraphs for those parts of
60 this code that are retained.
61
62 ===============================================================================
63 */
64
65 #include "milieu.h"
66 #include "softfloat.h"
67 #include "testCases.h"
68 #include "testLoops.h"
69 #include "systmodes.h"
70 #include "systflags.h"
71 #include "systfloat.h"
72 #include "testFunction.h"
73
74 const functionT functions[ NUM_FUNCTIONS ] = {
75 { 0, 0, 0, 0 },
76 { "int32_to_float32", 1, FALSE, TRUE },
77 { "int32_to_float64", 1, FALSE, FALSE },
78 { "int32_to_floatx80", 1, FALSE, FALSE },
79 { "int32_to_float128", 1, FALSE, FALSE },
80 { "int64_to_float32", 1, FALSE, TRUE },
81 { "int64_to_float64", 1, FALSE, TRUE },
82 { "int64_to_floatx80", 1, FALSE, FALSE },
83 { "int64_to_float128", 1, FALSE, FALSE },
84 { "float32_to_int32", 1, FALSE, TRUE },
85 { "float32_to_int32_round_to_zero", 1, FALSE, FALSE },
86 { "float32_to_int64", 1, FALSE, TRUE },
87 { "float32_to_int64_round_to_zero", 1, FALSE, FALSE },
88 { "float32_to_float64", 1, FALSE, FALSE },
89 { "float32_to_floatx80", 1, FALSE, FALSE },
90 { "float32_to_float128", 1, FALSE, FALSE },
91 { "float32_round_to_int", 1, FALSE, TRUE },
92 { "float32_add", 2, FALSE, TRUE },
93 { "float32_sub", 2, FALSE, TRUE },
94 { "float32_mul", 2, FALSE, TRUE },
95 { "float32_div", 2, FALSE, TRUE },
96 { "float32_rem", 2, FALSE, FALSE },
97 { "float32_sqrt", 1, FALSE, TRUE },
98 { "float32_eq", 2, FALSE, FALSE },
99 { "float32_le", 2, FALSE, FALSE },
100 { "float32_lt", 2, FALSE, FALSE },
101 { "float32_eq_signaling", 2, FALSE, FALSE },
102 { "float32_le_quiet", 2, FALSE, FALSE },
103 { "float32_lt_quiet", 2, FALSE, FALSE },
104 { "float64_to_int32", 1, FALSE, TRUE },
105 { "float64_to_int32_round_to_zero", 1, FALSE, FALSE },
106 { "float64_to_int64", 1, FALSE, TRUE },
107 { "float64_to_int64_round_to_zero", 1, FALSE, FALSE },
108 { "float64_to_float32", 1, FALSE, TRUE },
109 { "float64_to_floatx80", 1, FALSE, FALSE },
110 { "float64_to_float128", 1, FALSE, FALSE },
111 { "float64_round_to_int", 1, FALSE, TRUE },
112 { "float64_add", 2, FALSE, TRUE },
113 { "float64_sub", 2, FALSE, TRUE },
114 { "float64_mul", 2, FALSE, TRUE },
115 { "float64_div", 2, FALSE, TRUE },
116 { "float64_rem", 2, FALSE, FALSE },
117 { "float64_sqrt", 1, FALSE, TRUE },
118 { "float64_eq", 2, FALSE, FALSE },
119 { "float64_le", 2, FALSE, FALSE },
120 { "float64_lt", 2, FALSE, FALSE },
121 { "float64_eq_signaling", 2, FALSE, FALSE },
122 { "float64_le_quiet", 2, FALSE, FALSE },
123 { "float64_lt_quiet", 2, FALSE, FALSE },
124 { "floatx80_to_int32", 1, FALSE, TRUE },
125 { "floatx80_to_int32_round_to_zero", 1, FALSE, FALSE },
126 { "floatx80_to_int64", 1, FALSE, TRUE },
127 { "floatx80_to_int64_round_to_zero", 1, FALSE, FALSE },
128 { "floatx80_to_float32", 1, FALSE, TRUE },
129 { "floatx80_to_float64", 1, FALSE, TRUE },
130 { "floatx80_to_float128", 1, FALSE, FALSE },
131 { "floatx80_round_to_int", 1, FALSE, TRUE },
132 { "floatx80_add", 2, TRUE, TRUE },
133 { "floatx80_sub", 2, TRUE, TRUE },
134 { "floatx80_mul", 2, TRUE, TRUE },
135 { "floatx80_div", 2, TRUE, TRUE },
136 { "floatx80_rem", 2, FALSE, FALSE },
137 { "floatx80_sqrt", 1, TRUE, TRUE },
138 { "floatx80_eq", 2, FALSE, FALSE },
139 { "floatx80_le", 2, FALSE, FALSE },
140 { "floatx80_lt", 2, FALSE, FALSE },
141 { "floatx80_eq_signaling", 2, FALSE, FALSE },
142 { "floatx80_le_quiet", 2, FALSE, FALSE },
143 { "floatx80_lt_quiet", 2, FALSE, FALSE },
144 { "float128_to_int32", 1, FALSE, TRUE },
145 { "float128_to_int32_round_to_zero", 1, FALSE, FALSE },
146 { "float128_to_int64", 1, FALSE, TRUE },
147 { "float128_to_int64_round_to_zero", 1, FALSE, FALSE },
148 { "float128_to_float32", 1, FALSE, TRUE },
149 { "float128_to_float64", 1, FALSE, TRUE },
150 { "float128_to_floatx80", 1, FALSE, TRUE },
151 { "float128_round_to_int", 1, FALSE, TRUE },
152 { "float128_add", 2, FALSE, TRUE },
153 { "float128_sub", 2, FALSE, TRUE },
154 { "float128_mul", 2, FALSE, TRUE },
155 { "float128_div", 2, FALSE, TRUE },
156 { "float128_rem", 2, FALSE, FALSE },
157 { "float128_sqrt", 1, FALSE, TRUE },
158 { "float128_eq", 2, FALSE, FALSE },
159 { "float128_le", 2, FALSE, FALSE },
160 { "float128_lt", 2, FALSE, FALSE },
161 { "float128_eq_signaling", 2, FALSE, FALSE },
162 { "float128_le_quiet", 2, FALSE, FALSE },
163 { "float128_lt_quiet", 2, FALSE, FALSE },
164 };
165
166 const flag functionExists[ NUM_FUNCTIONS ] = {
167 0,
168 #ifdef SYST_INT32_TO_FLOAT32
169 1,
170 #else
171 0,
172 #endif
173 #ifdef SYST_INT32_TO_FLOAT64
174 1,
175 #else
176 0,
177 #endif
178 #ifdef SYST_INT32_TO_FLOATX80
179 1,
180 #else
181 0,
182 #endif
183 #ifdef SYST_INT32_TO_FLOAT128
184 1,
185 #else
186 0,
187 #endif
188 #ifdef SYST_INT64_TO_FLOAT32
189 1,
190 #else
191 0,
192 #endif
193 #ifdef SYST_INT64_TO_FLOAT64
194 1,
195 #else
196 0,
197 #endif
198 #ifdef SYST_INT64_TO_FLOATX80
199 1,
200 #else
201 0,
202 #endif
203 #ifdef SYST_INT64_TO_FLOAT128
204 1,
205 #else
206 0,
207 #endif
208 #ifdef SYST_FLOAT32_TO_INT32
209 1,
210 #else
211 0,
212 #endif
213 #ifdef SYST_FLOAT32_TO_INT32_ROUND_TO_ZERO
214 1,
215 #else
216 0,
217 #endif
218 #ifdef SYST_FLOAT32_TO_INT64
219 1,
220 #else
221 0,
222 #endif
223 #ifdef SYST_FLOAT32_TO_INT64_ROUND_TO_ZERO
224 1,
225 #else
226 0,
227 #endif
228 #ifdef SYST_FLOAT32_TO_FLOAT64
229 1,
230 #else
231 0,
232 #endif
233 #ifdef SYST_FLOAT32_TO_FLOATX80
234 1,
235 #else
236 0,
237 #endif
238 #ifdef SYST_FLOAT32_TO_FLOAT128
239 1,
240 #else
241 0,
242 #endif
243 #ifdef SYST_FLOAT32_ROUND_TO_INT
244 1,
245 #else
246 0,
247 #endif
248 #ifdef SYST_FLOAT32_ADD
249 1,
250 #else
251 0,
252 #endif
253 #ifdef SYST_FLOAT32_SUB
254 1,
255 #else
256 0,
257 #endif
258 #ifdef SYST_FLOAT32_MUL
259 1,
260 #else
261 0,
262 #endif
263 #ifdef SYST_FLOAT32_DIV
264 1,
265 #else
266 0,
267 #endif
268 #ifdef SYST_FLOAT32_REM
269 1,
270 #else
271 0,
272 #endif
273 #ifdef SYST_FLOAT32_SQRT
274 1,
275 #else
276 0,
277 #endif
278 #ifdef SYST_FLOAT32_EQ
279 1,
280 #else
281 0,
282 #endif
283 #ifdef SYST_FLOAT32_LE
284 1,
285 #else
286 0,
287 #endif
288 #ifdef SYST_FLOAT32_LT
289 1,
290 #else
291 0,
292 #endif
293 #ifdef SYST_FLOAT32_EQ_SIGNALING
294 1,
295 #else
296 0,
297 #endif
298 #ifdef SYST_FLOAT32_LE_QUIET
299 1,
300 #else
301 0,
302 #endif
303 #ifdef SYST_FLOAT32_LT_QUIET
304 1,
305 #else
306 0,
307 #endif
308 #ifdef SYST_FLOAT64_TO_INT32
309 1,
310 #else
311 0,
312 #endif
313 #ifdef SYST_FLOAT64_TO_INT32_ROUND_TO_ZERO
314 1,
315 #else
316 0,
317 #endif
318 #ifdef SYST_FLOAT64_TO_INT64
319 1,
320 #else
321 0,
322 #endif
323 #ifdef SYST_FLOAT64_TO_INT64_ROUND_TO_ZERO
324 1,
325 #else
326 0,
327 #endif
328 #ifdef SYST_FLOAT64_TO_FLOAT32
329 1,
330 #else
331 0,
332 #endif
333 #ifdef SYST_FLOAT64_TO_FLOATX80
334 1,
335 #else
336 0,
337 #endif
338 #ifdef SYST_FLOAT64_TO_FLOAT128
339 1,
340 #else
341 0,
342 #endif
343 #ifdef SYST_FLOAT64_ROUND_TO_INT
344 1,
345 #else
346 0,
347 #endif
348 #ifdef SYST_FLOAT64_ADD
349 1,
350 #else
351 0,
352 #endif
353 #ifdef SYST_FLOAT64_SUB
354 1,
355 #else
356 0,
357 #endif
358 #ifdef SYST_FLOAT64_MUL
359 1,
360 #else
361 0,
362 #endif
363 #ifdef SYST_FLOAT64_DIV
364 1,
365 #else
366 0,
367 #endif
368 #ifdef SYST_FLOAT64_REM
369 1,
370 #else
371 0,
372 #endif
373 #ifdef SYST_FLOAT64_SQRT
374 1,
375 #else
376 0,
377 #endif
378 #ifdef SYST_FLOAT64_EQ
379 1,
380 #else
381 0,
382 #endif
383 #ifdef SYST_FLOAT64_LE
384 1,
385 #else
386 0,
387 #endif
388 #ifdef SYST_FLOAT64_LT
389 1,
390 #else
391 0,
392 #endif
393 #ifdef SYST_FLOAT64_EQ_SIGNALING
394 1,
395 #else
396 0,
397 #endif
398 #ifdef SYST_FLOAT64_LE_QUIET
399 1,
400 #else
401 0,
402 #endif
403 #ifdef SYST_FLOAT64_LT_QUIET
404 1,
405 #else
406 0,
407 #endif
408 #ifdef SYST_FLOATX80_TO_INT32
409 1,
410 #else
411 0,
412 #endif
413 #ifdef SYST_FLOATX80_TO_INT32_ROUND_TO_ZERO
414 1,
415 #else
416 0,
417 #endif
418 #ifdef SYST_FLOATX80_TO_INT64
419 1,
420 #else
421 0,
422 #endif
423 #ifdef SYST_FLOATX80_TO_INT64_ROUND_TO_ZERO
424 1,
425 #else
426 0,
427 #endif
428 #ifdef SYST_FLOATX80_TO_FLOAT32
429 1,
430 #else
431 0,
432 #endif
433 #ifdef SYST_FLOATX80_TO_FLOAT64
434 1,
435 #else
436 0,
437 #endif
438 #ifdef SYST_FLOATX80_TO_FLOAT128
439 1,
440 #else
441 0,
442 #endif
443 #ifdef SYST_FLOATX80_ROUND_TO_INT
444 1,
445 #else
446 0,
447 #endif
448 #ifdef SYST_FLOATX80_ADD
449 1,
450 #else
451 0,
452 #endif
453 #ifdef SYST_FLOATX80_SUB
454 1,
455 #else
456 0,
457 #endif
458 #ifdef SYST_FLOATX80_MUL
459 1,
460 #else
461 0,
462 #endif
463 #ifdef SYST_FLOATX80_DIV
464 1,
465 #else
466 0,
467 #endif
468 #ifdef SYST_FLOATX80_REM
469 1,
470 #else
471 0,
472 #endif
473 #ifdef SYST_FLOATX80_SQRT
474 1,
475 #else
476 0,
477 #endif
478 #ifdef SYST_FLOATX80_EQ
479 1,
480 #else
481 0,
482 #endif
483 #ifdef SYST_FLOATX80_LE
484 1,
485 #else
486 0,
487 #endif
488 #ifdef SYST_FLOATX80_LT
489 1,
490 #else
491 0,
492 #endif
493 #ifdef SYST_FLOATX80_EQ_SIGNALING
494 1,
495 #else
496 0,
497 #endif
498 #ifdef SYST_FLOATX80_LE_QUIET
499 1,
500 #else
501 0,
502 #endif
503 #ifdef SYST_FLOATX80_LT_QUIET
504 1,
505 #else
506 0,
507 #endif
508 #ifdef SYST_FLOAT128_TO_INT32
509 1,
510 #else
511 0,
512 #endif
513 #ifdef SYST_FLOAT128_TO_INT32_ROUND_TO_ZERO
514 1,
515 #else
516 0,
517 #endif
518 #ifdef SYST_FLOAT128_TO_INT64
519 1,
520 #else
521 0,
522 #endif
523 #ifdef SYST_FLOAT128_TO_INT64_ROUND_TO_ZERO
524 1,
525 #else
526 0,
527 #endif
528 #ifdef SYST_FLOAT128_TO_FLOAT32
529 1,
530 #else
531 0,
532 #endif
533 #ifdef SYST_FLOAT128_TO_FLOAT64
534 1,
535 #else
536 0,
537 #endif
538 #ifdef SYST_FLOAT128_TO_FLOATX80
539 1,
540 #else
541 0,
542 #endif
543 #ifdef SYST_FLOAT128_ROUND_TO_INT
544 1,
545 #else
546 0,
547 #endif
548 #ifdef SYST_FLOAT128_ADD
549 1,
550 #else
551 0,
552 #endif
553 #ifdef SYST_FLOAT128_SUB
554 1,
555 #else
556 0,
557 #endif
558 #ifdef SYST_FLOAT128_MUL
559 1,
560 #else
561 0,
562 #endif
563 #ifdef SYST_FLOAT128_DIV
564 1,
565 #else
566 0,
567 #endif
568 #ifdef SYST_FLOAT128_REM
569 1,
570 #else
571 0,
572 #endif
573 #ifdef SYST_FLOAT128_SQRT
574 1,
575 #else
576 0,
577 #endif
578 #ifdef SYST_FLOAT128_EQ
579 1,
580 #else
581 0,
582 #endif
583 #ifdef SYST_FLOAT128_LE
584 1,
585 #else
586 0,
587 #endif
588 #ifdef SYST_FLOAT128_LT
589 1,
590 #else
591 0,
592 #endif
593 #ifdef SYST_FLOAT128_EQ_SIGNALING
594 1,
595 #else
596 0,
597 #endif
598 #ifdef SYST_FLOAT128_LE_QUIET
599 1,
600 #else
601 0,
602 #endif
603 #ifdef SYST_FLOAT128_LT_QUIET
604 1,
605 #else
606 0,
607 #endif
608 };
609
610 static void
611 testFunctionVariety(
612 uint8 functionCode, int8 roundingPrecision, int8 roundingMode )
613 {
614 uint8 roundingCode;
615
616 functionName = functions[ functionCode ].name;
617 #ifdef FLOATX80
618 if ( roundingPrecision == 32 ) {
619 roundingPrecisionName = "32";
620 }
621 else if ( roundingPrecision == 64 ) {
622 roundingPrecisionName = "64";
623 }
624 else if ( roundingPrecision == 80 ) {
625 roundingPrecisionName = "80";
626 }
627 else {
628 roundingPrecision = 80;
629 roundingPrecisionName = 0;
630 }
631 floatx80_rounding_precision = roundingPrecision;
632 syst_float_set_rounding_precision( roundingPrecision );
633 #endif
634 switch ( roundingMode ) {
635 case 0:
636 roundingModeName = 0;
637 roundingCode = float_round_nearest_even;
638 break;
639 case ROUND_NEAREST_EVEN:
640 roundingModeName = "nearest_even";
641 roundingCode = float_round_nearest_even;
642 break;
643 case ROUND_TO_ZERO:
644 roundingModeName = "to_zero";
645 roundingCode = float_round_to_zero;
646 break;
647 case ROUND_DOWN:
648 roundingModeName = "down";
649 roundingCode = float_round_down;
650 break;
651 case ROUND_UP:
652 roundingModeName = "up";
653 roundingCode = float_round_up;
654 break;
655 }
656 float_rounding_mode = roundingCode;
657 syst_float_set_rounding_mode( roundingCode );
658 fputs( "Testing ", stderr );
659 writeFunctionName( stderr );
660 fputs( ".\n", stderr );
661 switch ( functionCode ) {
662 #ifdef SYST_INT32_TO_FLOAT32
663 case INT32_TO_FLOAT32:
664 test_a_int32_z_float32( int32_to_float32, syst_int32_to_float32 );
665 break;
666 #endif
667 #ifdef SYST_INT32_TO_FLOAT64
668 case INT32_TO_FLOAT64:
669 test_a_int32_z_float64( int32_to_float64, syst_int32_to_float64 );
670 break;
671 #endif
672 #ifdef SYST_INT32_TO_FLOATX80
673 case INT32_TO_FLOATX80:
674 test_a_int32_z_floatx80( int32_to_floatx80, syst_int32_to_floatx80 );
675 break;
676 #endif
677 #ifdef SYST_INT32_TO_FLOAT128
678 case INT32_TO_FLOAT128:
679 test_a_int32_z_float128( int32_to_float128, syst_int32_to_float128 );
680 break;
681 #endif
682 #ifdef SYST_INT64_TO_FLOAT32
683 case INT64_TO_FLOAT32:
684 test_a_int64_z_float32( int64_to_float32, syst_int64_to_float32 );
685 break;
686 #endif
687 #ifdef SYST_INT64_TO_FLOAT64
688 case INT64_TO_FLOAT64:
689 test_a_int64_z_float64( int64_to_float64, syst_int64_to_float64 );
690 break;
691 #endif
692 #ifdef SYST_INT64_TO_FLOATX80
693 case INT64_TO_FLOATX80:
694 test_a_int64_z_floatx80( int64_to_floatx80, syst_int64_to_floatx80 );
695 break;
696 #endif
697 #ifdef SYST_INT64_TO_FLOAT128
698 case INT64_TO_FLOAT128:
699 test_a_int64_z_float128( int64_to_float128, syst_int64_to_float128 );
700 break;
701 #endif
702 #ifdef SYST_FLOAT32_TO_INT32
703 case FLOAT32_TO_INT32:
704 test_a_float32_z_int32( float32_to_int32, syst_float32_to_int32 );
705 break;
706 #endif
707 #ifdef SYST_FLOAT32_TO_INT32_ROUND_TO_ZERO
708 case FLOAT32_TO_INT32_ROUND_TO_ZERO:
709 test_a_float32_z_int32(
710 float32_to_int32_round_to_zero,
711 syst_float32_to_int32_round_to_zero
712 );
713 break;
714 #endif
715 #ifdef SYST_FLOAT32_TO_INT64
716 case FLOAT32_TO_INT64:
717 test_a_float32_z_int64( float32_to_int64, syst_float32_to_int64 );
718 break;
719 #endif
720 #ifdef SYST_FLOAT32_TO_INT64_ROUND_TO_ZERO
721 case FLOAT32_TO_INT64_ROUND_TO_ZERO:
722 test_a_float32_z_int64(
723 float32_to_int64_round_to_zero,
724 syst_float32_to_int64_round_to_zero
725 );
726 break;
727 #endif
728 #ifdef SYST_FLOAT32_TO_FLOAT64
729 case FLOAT32_TO_FLOAT64:
730 test_a_float32_z_float64(
731 float32_to_float64, syst_float32_to_float64 );
732 break;
733 #endif
734 #ifdef SYST_FLOAT32_TO_FLOATX80
735 case FLOAT32_TO_FLOATX80:
736 test_a_float32_z_floatx80(
737 float32_to_floatx80, syst_float32_to_floatx80 );
738 break;
739 #endif
740 #ifdef SYST_FLOAT32_TO_FLOAT128
741 case FLOAT32_TO_FLOAT128:
742 test_a_float32_z_float128(
743 float32_to_float128, syst_float32_to_float128 );
744 break;
745 #endif
746 #ifdef SYST_FLOAT32_ROUND_TO_INT
747 case FLOAT32_ROUND_TO_INT:
748 test_az_float32( float32_round_to_int, syst_float32_round_to_int );
749 break;
750 #endif
751 #ifdef SYST_FLOAT32_ADD
752 case FLOAT32_ADD:
753 test_abz_float32( float32_add, syst_float32_add );
754 break;
755 #endif
756 #ifdef SYST_FLOAT32_SUB
757 case FLOAT32_SUB:
758 test_abz_float32( float32_sub, syst_float32_sub );
759 break;
760 #endif
761 #ifdef SYST_FLOAT32_MUL
762 case FLOAT32_MUL:
763 test_abz_float32( float32_mul, syst_float32_mul );
764 break;
765 #endif
766 #ifdef SYST_FLOAT32_DIV
767 case FLOAT32_DIV:
768 test_abz_float32( float32_div, syst_float32_div );
769 break;
770 #endif
771 #ifdef SYST_FLOAT32_REM
772 case FLOAT32_REM:
773 test_abz_float32( float32_rem, syst_float32_rem );
774 break;
775 #endif
776 #ifdef SYST_FLOAT32_SQRT
777 case FLOAT32_SQRT:
778 test_az_float32( float32_sqrt, syst_float32_sqrt );
779 break;
780 #endif
781 #ifdef SYST_FLOAT32_EQ
782 case FLOAT32_EQ:
783 test_ab_float32_z_flag( float32_eq, syst_float32_eq );
784 break;
785 #endif
786 #ifdef SYST_FLOAT32_LE
787 case FLOAT32_LE:
788 test_ab_float32_z_flag( float32_le, syst_float32_le );
789 break;
790 #endif
791 #ifdef SYST_FLOAT32_LT
792 case FLOAT32_LT:
793 test_ab_float32_z_flag( float32_lt, syst_float32_lt );
794 break;
795 #endif
796 #ifdef SYST_FLOAT32_EQ_SIGNALING
797 case FLOAT32_EQ_SIGNALING:
798 test_ab_float32_z_flag(
799 float32_eq_signaling, syst_float32_eq_signaling );
800 break;
801 #endif
802 #ifdef SYST_FLOAT32_LE_QUIET
803 case FLOAT32_LE_QUIET:
804 test_ab_float32_z_flag( float32_le_quiet, syst_float32_le_quiet );
805 break;
806 #endif
807 #ifdef SYST_FLOAT32_LT_QUIET
808 case FLOAT32_LT_QUIET:
809 test_ab_float32_z_flag( float32_lt_quiet, syst_float32_lt_quiet );
810 break;
811 #endif
812 #ifdef SYST_FLOAT64_TO_INT32
813 case FLOAT64_TO_INT32:
814 test_a_float64_z_int32( float64_to_int32, syst_float64_to_int32 );
815 break;
816 #endif
817 #ifdef SYST_FLOAT64_TO_INT32_ROUND_TO_ZERO
818 case FLOAT64_TO_INT32_ROUND_TO_ZERO:
819 test_a_float64_z_int32(
820 float64_to_int32_round_to_zero,
821 syst_float64_to_int32_round_to_zero
822 );
823 break;
824 #endif
825 #ifdef SYST_FLOAT64_TO_INT64
826 case FLOAT64_TO_INT64:
827 test_a_float64_z_int64( float64_to_int64, syst_float64_to_int64 );
828 break;
829 #endif
830 #ifdef SYST_FLOAT64_TO_INT64_ROUND_TO_ZERO
831 case FLOAT64_TO_INT64_ROUND_TO_ZERO:
832 test_a_float64_z_int64(
833 float64_to_int64_round_to_zero,
834 syst_float64_to_int64_round_to_zero
835 );
836 break;
837 #endif
838 #ifdef SYST_FLOAT64_TO_FLOAT32
839 case FLOAT64_TO_FLOAT32:
840 test_a_float64_z_float32(
841 float64_to_float32, syst_float64_to_float32 );
842 break;
843 #endif
844 #ifdef SYST_FLOAT64_TO_FLOATX80
845 case FLOAT64_TO_FLOATX80:
846 test_a_float64_z_floatx80(
847 float64_to_floatx80, syst_float64_to_floatx80 );
848 break;
849 #endif
850 #ifdef SYST_FLOAT64_TO_FLOAT128
851 case FLOAT64_TO_FLOAT128:
852 test_a_float64_z_float128(
853 float64_to_float128, syst_float64_to_float128 );
854 break;
855 #endif
856 #ifdef SYST_FLOAT64_ROUND_TO_INT
857 case FLOAT64_ROUND_TO_INT:
858 test_az_float64( float64_round_to_int, syst_float64_round_to_int );
859 break;
860 #endif
861 #ifdef SYST_FLOAT64_ADD
862 case FLOAT64_ADD:
863 test_abz_float64( float64_add, syst_float64_add );
864 break;
865 #endif
866 #ifdef SYST_FLOAT64_SUB
867 case FLOAT64_SUB:
868 test_abz_float64( float64_sub, syst_float64_sub );
869 break;
870 #endif
871 #ifdef SYST_FLOAT64_MUL
872 case FLOAT64_MUL:
873 test_abz_float64( float64_mul, syst_float64_mul );
874 break;
875 #endif
876 #ifdef SYST_FLOAT64_DIV
877 case FLOAT64_DIV:
878 test_abz_float64( float64_div, syst_float64_div );
879 break;
880 #endif
881 #ifdef SYST_FLOAT64_REM
882 case FLOAT64_REM:
883 test_abz_float64( float64_rem, syst_float64_rem );
884 break;
885 #endif
886 #ifdef SYST_FLOAT64_SQRT
887 case FLOAT64_SQRT:
888 test_az_float64( float64_sqrt, syst_float64_sqrt );
889 break;
890 #endif
891 #ifdef SYST_FLOAT64_EQ
892 case FLOAT64_EQ:
893 test_ab_float64_z_flag( float64_eq, syst_float64_eq );
894 break;
895 #endif
896 #ifdef SYST_FLOAT64_LE
897 case FLOAT64_LE:
898 test_ab_float64_z_flag( float64_le, syst_float64_le );
899 break;
900 #endif
901 #ifdef SYST_FLOAT64_LT
902 case FLOAT64_LT:
903 test_ab_float64_z_flag( float64_lt, syst_float64_lt );
904 break;
905 #endif
906 #ifdef SYST_FLOAT64_EQ_SIGNALING
907 case FLOAT64_EQ_SIGNALING:
908 test_ab_float64_z_flag(
909 float64_eq_signaling, syst_float64_eq_signaling );
910 break;
911 #endif
912 #ifdef SYST_FLOAT64_LE_QUIET
913 case FLOAT64_LE_QUIET:
914 test_ab_float64_z_flag( float64_le_quiet, syst_float64_le_quiet );
915 break;
916 #endif
917 #ifdef SYST_FLOAT64_LT_QUIET
918 case FLOAT64_LT_QUIET:
919 test_ab_float64_z_flag( float64_lt_quiet, syst_float64_lt_quiet );
920 break;
921 #endif
922 #ifdef SYST_FLOATX80_TO_INT32
923 case FLOATX80_TO_INT32:
924 test_a_floatx80_z_int32( floatx80_to_int32, syst_floatx80_to_int32 );
925 break;
926 #endif
927 #ifdef SYST_FLOATX80_TO_INT32_ROUND_TO_ZERO
928 case FLOATX80_TO_INT32_ROUND_TO_ZERO:
929 test_a_floatx80_z_int32(
930 floatx80_to_int32_round_to_zero,
931 syst_floatx80_to_int32_round_to_zero
932 );
933 break;
934 #endif
935 #ifdef SYST_FLOATX80_TO_INT64
936 case FLOATX80_TO_INT64:
937 test_a_floatx80_z_int64( floatx80_to_int64, syst_floatx80_to_int64 );
938 break;
939 #endif
940 #ifdef SYST_FLOATX80_TO_INT64_ROUND_TO_ZERO
941 case FLOATX80_TO_INT64_ROUND_TO_ZERO:
942 test_a_floatx80_z_int64(
943 floatx80_to_int64_round_to_zero,
944 syst_floatx80_to_int64_round_to_zero
945 );
946 break;
947 #endif
948 #ifdef SYST_FLOATX80_TO_FLOAT32
949 case FLOATX80_TO_FLOAT32:
950 test_a_floatx80_z_float32(
951 floatx80_to_float32, syst_floatx80_to_float32 );
952 break;
953 #endif
954 #ifdef SYST_FLOATX80_TO_FLOAT64
955 case FLOATX80_TO_FLOAT64:
956 test_a_floatx80_z_float64(
957 floatx80_to_float64, syst_floatx80_to_float64 );
958 break;
959 #endif
960 #ifdef SYST_FLOATX80_TO_FLOAT128
961 case FLOATX80_TO_FLOAT128:
962 test_a_floatx80_z_float128(
963 floatx80_to_float128, syst_floatx80_to_float128 );
964 break;
965 #endif
966 #ifdef SYST_FLOATX80_ROUND_TO_INT
967 case FLOATX80_ROUND_TO_INT:
968 test_az_floatx80( floatx80_round_to_int, syst_floatx80_round_to_int );
969 break;
970 #endif
971 #ifdef SYST_FLOATX80_ADD
972 case FLOATX80_ADD:
973 test_abz_floatx80( floatx80_add, syst_floatx80_add );
974 break;
975 #endif
976 #ifdef SYST_FLOATX80_SUB
977 case FLOATX80_SUB:
978 test_abz_floatx80( floatx80_sub, syst_floatx80_sub );
979 break;
980 #endif
981 #ifdef SYST_FLOATX80_MUL
982 case FLOATX80_MUL:
983 test_abz_floatx80( floatx80_mul, syst_floatx80_mul );
984 break;
985 #endif
986 #ifdef SYST_FLOATX80_DIV
987 case FLOATX80_DIV:
988 test_abz_floatx80( floatx80_div, syst_floatx80_div );
989 break;
990 #endif
991 #ifdef SYST_FLOATX80_REM
992 case FLOATX80_REM:
993 test_abz_floatx80( floatx80_rem, syst_floatx80_rem );
994 break;
995 #endif
996 #ifdef SYST_FLOATX80_SQRT
997 case FLOATX80_SQRT:
998 test_az_floatx80( floatx80_sqrt, syst_floatx80_sqrt );
999 break;
1000 #endif
1001 #ifdef SYST_FLOATX80_EQ
1002 case FLOATX80_EQ:
1003 test_ab_floatx80_z_flag( floatx80_eq, syst_floatx80_eq );
1004 break;
1005 #endif
1006 #ifdef SYST_FLOATX80_LE
1007 case FLOATX80_LE:
1008 test_ab_floatx80_z_flag( floatx80_le, syst_floatx80_le );
1009 break;
1010 #endif
1011 #ifdef SYST_FLOATX80_LT
1012 case FLOATX80_LT:
1013 test_ab_floatx80_z_flag( floatx80_lt, syst_floatx80_lt );
1014 break;
1015 #endif
1016 #ifdef SYST_FLOATX80_EQ_SIGNALING
1017 case FLOATX80_EQ_SIGNALING:
1018 test_ab_floatx80_z_flag(
1019 floatx80_eq_signaling, syst_floatx80_eq_signaling );
1020 break;
1021 #endif
1022 #ifdef SYST_FLOATX80_LE_QUIET
1023 case FLOATX80_LE_QUIET:
1024 test_ab_floatx80_z_flag( floatx80_le_quiet, syst_floatx80_le_quiet );
1025 break;
1026 #endif
1027 #ifdef SYST_FLOATX80_LT_QUIET
1028 case FLOATX80_LT_QUIET:
1029 test_ab_floatx80_z_flag( floatx80_lt_quiet, syst_floatx80_lt_quiet );
1030 break;
1031 #endif
1032 #ifdef SYST_FLOAT128_TO_INT32
1033 case FLOAT128_TO_INT32:
1034 test_a_float128_z_int32( float128_to_int32, syst_float128_to_int32 );
1035 break;
1036 #endif
1037 #ifdef SYST_FLOAT128_TO_INT32_ROUND_TO_ZERO
1038 case FLOAT128_TO_INT32_ROUND_TO_ZERO:
1039 test_a_float128_z_int32(
1040 float128_to_int32_round_to_zero,
1041 syst_float128_to_int32_round_to_zero
1042 );
1043 break;
1044 #endif
1045 #ifdef SYST_FLOAT128_TO_INT64
1046 case FLOAT128_TO_INT64:
1047 test_a_float128_z_int64( float128_to_int64, syst_float128_to_int64 );
1048 break;
1049 #endif
1050 #ifdef SYST_FLOAT128_TO_INT64_ROUND_TO_ZERO
1051 case FLOAT128_TO_INT64_ROUND_TO_ZERO:
1052 test_a_float128_z_int64(
1053 float128_to_int64_round_to_zero,
1054 syst_float128_to_int64_round_to_zero
1055 );
1056 break;
1057 #endif
1058 #ifdef SYST_FLOAT128_TO_FLOAT32
1059 case FLOAT128_TO_FLOAT32:
1060 test_a_float128_z_float32(
1061 float128_to_float32, syst_float128_to_float32 );
1062 break;
1063 #endif
1064 #ifdef SYST_FLOAT128_TO_FLOAT64
1065 case FLOAT128_TO_FLOAT64:
1066 test_a_float128_z_float64(
1067 float128_to_float64, syst_float128_to_float64 );
1068 break;
1069 #endif
1070 #ifdef SYST_FLOAT128_TO_FLOATX80
1071 case FLOAT128_TO_FLOATX80:
1072 test_a_float128_z_floatx80(
1073 float128_to_floatx80, syst_float128_to_floatx80 );
1074 break;
1075 #endif
1076 #ifdef SYST_FLOAT128_ROUND_TO_INT
1077 case FLOAT128_ROUND_TO_INT:
1078 test_az_float128( float128_round_to_int, syst_float128_round_to_int );
1079 break;
1080 #endif
1081 #ifdef SYST_FLOAT128_ADD
1082 case FLOAT128_ADD:
1083 test_abz_float128( float128_add, syst_float128_add );
1084 break;
1085 #endif
1086 #ifdef SYST_FLOAT128_SUB
1087 case FLOAT128_SUB:
1088 test_abz_float128( float128_sub, syst_float128_sub );
1089 break;
1090 #endif
1091 #ifdef SYST_FLOAT128_MUL
1092 case FLOAT128_MUL:
1093 test_abz_float128( float128_mul, syst_float128_mul );
1094 break;
1095 #endif
1096 #ifdef SYST_FLOAT128_DIV
1097 case FLOAT128_DIV:
1098 test_abz_float128( float128_div, syst_float128_div );
1099 break;
1100 #endif
1101 #ifdef SYST_FLOAT128_REM
1102 case FLOAT128_REM:
1103 test_abz_float128( float128_rem, syst_float128_rem );
1104 break;
1105 #endif
1106 #ifdef SYST_FLOAT128_SQRT
1107 case FLOAT128_SQRT:
1108 test_az_float128( float128_sqrt, syst_float128_sqrt );
1109 break;
1110 #endif
1111 #ifdef SYST_FLOAT128_EQ
1112 case FLOAT128_EQ:
1113 test_ab_float128_z_flag( float128_eq, syst_float128_eq );
1114 break;
1115 #endif
1116 #ifdef SYST_FLOAT128_LE
1117 case FLOAT128_LE:
1118 test_ab_float128_z_flag( float128_le, syst_float128_le );
1119 break;
1120 #endif
1121 #ifdef SYST_FLOAT128_LT
1122 case FLOAT128_LT:
1123 test_ab_float128_z_flag( float128_lt, syst_float128_lt );
1124 break;
1125 #endif
1126 #ifdef SYST_FLOAT128_EQ_SIGNALING
1127 case FLOAT128_EQ_SIGNALING:
1128 test_ab_float128_z_flag(
1129 float128_eq_signaling, syst_float128_eq_signaling );
1130 break;
1131 #endif
1132 #ifdef SYST_FLOAT128_LE_QUIET
1133 case FLOAT128_LE_QUIET:
1134 test_ab_float128_z_flag( float128_le_quiet, syst_float128_le_quiet );
1135 break;
1136 #endif
1137 #ifdef SYST_FLOAT128_LT_QUIET
1138 case FLOAT128_LT_QUIET:
1139 test_ab_float128_z_flag( float128_lt_quiet, syst_float128_lt_quiet );
1140 break;
1141 #endif
1142 }
1143 if ( ( errorStop && anyErrors ) || stop ) exitWithStatus();
1144
1145 }
1146
1147 void
1148 testFunction(
1149 uint8 functionCode, int8 roundingPrecisionIn, int8 roundingModeIn )
1150 {
1151 int8 roundingPrecision, roundingMode;
1152
1153 roundingPrecision = 32;
1154 for (;;) {
1155 if ( ! functions[ functionCode ].roundingPrecision ) {
1156 roundingPrecision = 0;
1157 }
1158 else if ( roundingPrecisionIn ) {
1159 roundingPrecision = roundingPrecisionIn;
1160 }
1161 for ( roundingMode = 1;
1162 roundingMode < NUM_ROUNDINGMODES;
1163 ++roundingMode
1164 ) {
1165 if ( ! functions[ functionCode ].roundingMode ) {
1166 roundingMode = 0;
1167 }
1168 else if ( roundingModeIn ) {
1169 roundingMode = roundingModeIn;
1170 }
1171 testFunctionVariety(
1172 functionCode, roundingPrecision, roundingMode );
1173 if ( roundingModeIn || ! roundingMode ) break;
1174 }
1175 if ( roundingPrecisionIn || ! roundingPrecision ) break;
1176 if ( roundingPrecision == 80 ) {
1177 break;
1178 }
1179 else if ( roundingPrecision == 64 ) {
1180 roundingPrecision = 80;
1181 }
1182 else if ( roundingPrecision == 32 ) {
1183 roundingPrecision = 64;
1184 }
1185 }
1186
1187 }
1188
1189