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