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