1/*	$NetBSD: testFunction.c,v 1.5 2008/04/01 19:20:43 drochner 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 *
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.
32 */
33
34/*
35===============================================================================
36
37This C source file is part of TestFloat, Release 2a, a package of programs
38for testing the correctness of floating-point arithmetic complying to the
39IEC/IEEE Standard for Floating-Point.
40
41Written by John R. Hauser.  More information is available through the Web
42page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
43
44THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
45has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
46TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
47PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
48AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
49
50Derivative works are acceptable, even for commercial purposes, so long as
51(1) they include prominent notice that the work is derivative, and (2) they
52include prominent notice akin to these four paragraphs for those parts of
53this code that are retained.
54
55===============================================================================
56*/
57
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"
66
67const 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 },
157};
158
159const flag functionExists[ NUM_FUNCTIONS ] = {
160    0,
161#ifdef SYST_INT32_TO_FLOAT32
162    1,
163#else
164    0,
165#endif
166#ifdef SYST_INT32_TO_FLOAT64
167    1,
168#else
169    0,
170#endif
171#ifdef SYST_INT32_TO_FLOATX80
172    1,
173#else
174    0,
175#endif
176#ifdef SYST_INT32_TO_FLOAT128
177    1,
178#else
179    0,
180#endif
181#ifdef SYST_INT64_TO_FLOAT32
182    1,
183#else
184    0,
185#endif
186#ifdef SYST_INT64_TO_FLOAT64
187    1,
188#else
189    0,
190#endif
191#ifdef SYST_INT64_TO_FLOATX80
192    1,
193#else
194    0,
195#endif
196#ifdef SYST_INT64_TO_FLOAT128
197    1,
198#else
199    0,
200#endif
201#ifdef SYST_FLOAT32_TO_INT32
202    1,
203#else
204    0,
205#endif
206#ifdef SYST_FLOAT32_TO_INT32_ROUND_TO_ZERO
207    1,
208#else
209    0,
210#endif
211#ifdef SYST_FLOAT32_TO_INT64
212    1,
213#else
214    0,
215#endif
216#ifdef SYST_FLOAT32_TO_INT64_ROUND_TO_ZERO
217    1,
218#else
219    0,
220#endif
221#ifdef SYST_FLOAT32_TO_FLOAT64
222    1,
223#else
224    0,
225#endif
226#ifdef SYST_FLOAT32_TO_FLOATX80
227    1,
228#else
229    0,
230#endif
231#ifdef SYST_FLOAT32_TO_FLOAT128
232    1,
233#else
234    0,
235#endif
236#ifdef SYST_FLOAT32_ROUND_TO_INT
237    1,
238#else
239    0,
240#endif
241#ifdef SYST_FLOAT32_ADD
242    1,
243#else
244    0,
245#endif
246#ifdef SYST_FLOAT32_SUB
247    1,
248#else
249    0,
250#endif
251#ifdef SYST_FLOAT32_MUL
252    1,
253#else
254    0,
255#endif
256#ifdef SYST_FLOAT32_DIV
257    1,
258#else
259    0,
260#endif
261#ifdef SYST_FLOAT32_REM
262    1,
263#else
264    0,
265#endif
266#ifdef SYST_FLOAT32_SQRT
267    1,
268#else
269    0,
270#endif
271#ifdef SYST_FLOAT32_EQ
272    1,
273#else
274    0,
275#endif
276#ifdef SYST_FLOAT32_LE
277    1,
278#else
279    0,
280#endif
281#ifdef SYST_FLOAT32_LT
282    1,
283#else
284    0,
285#endif
286#ifdef SYST_FLOAT32_EQ_SIGNALING
287    1,
288#else
289    0,
290#endif
291#ifdef SYST_FLOAT32_LE_QUIET
292    1,
293#else
294    0,
295#endif
296#ifdef SYST_FLOAT32_LT_QUIET
297    1,
298#else
299    0,
300#endif
301#ifdef SYST_FLOAT64_TO_INT32
302    1,
303#else
304    0,
305#endif
306#ifdef SYST_FLOAT64_TO_INT32_ROUND_TO_ZERO
307    1,
308#else
309    0,
310#endif
311#ifdef SYST_FLOAT64_TO_INT64
312    1,
313#else
314    0,
315#endif
316#ifdef SYST_FLOAT64_TO_INT64_ROUND_TO_ZERO
317    1,
318#else
319    0,
320#endif
321#ifdef SYST_FLOAT64_TO_FLOAT32
322    1,
323#else
324    0,
325#endif
326#ifdef SYST_FLOAT64_TO_FLOATX80
327    1,
328#else
329    0,
330#endif
331#ifdef SYST_FLOAT64_TO_FLOAT128
332    1,
333#else
334    0,
335#endif
336#ifdef SYST_FLOAT64_ROUND_TO_INT
337    1,
338#else
339    0,
340#endif
341#ifdef SYST_FLOAT64_ADD
342    1,
343#else
344    0,
345#endif
346#ifdef SYST_FLOAT64_SUB
347    1,
348#else
349    0,
350#endif
351#ifdef SYST_FLOAT64_MUL
352    1,
353#else
354    0,
355#endif
356#ifdef SYST_FLOAT64_DIV
357    1,
358#else
359    0,
360#endif
361#ifdef SYST_FLOAT64_REM
362    1,
363#else
364    0,
365#endif
366#ifdef SYST_FLOAT64_SQRT
367    1,
368#else
369    0,
370#endif
371#ifdef SYST_FLOAT64_EQ
372    1,
373#else
374    0,
375#endif
376#ifdef SYST_FLOAT64_LE
377    1,
378#else
379    0,
380#endif
381#ifdef SYST_FLOAT64_LT
382    1,
383#else
384    0,
385#endif
386#ifdef SYST_FLOAT64_EQ_SIGNALING
387    1,
388#else
389    0,
390#endif
391#ifdef SYST_FLOAT64_LE_QUIET
392    1,
393#else
394    0,
395#endif
396#ifdef SYST_FLOAT64_LT_QUIET
397    1,
398#else
399    0,
400#endif
401#ifdef SYST_FLOATX80_TO_INT32
402    1,
403#else
404    0,
405#endif
406#ifdef SYST_FLOATX80_TO_INT32_ROUND_TO_ZERO
407    1,
408#else
409    0,
410#endif
411#ifdef SYST_FLOATX80_TO_INT64
412    1,
413#else
414    0,
415#endif
416#ifdef SYST_FLOATX80_TO_INT64_ROUND_TO_ZERO
417    1,
418#else
419    0,
420#endif
421#ifdef SYST_FLOATX80_TO_FLOAT32
422    1,
423#else
424    0,
425#endif
426#ifdef SYST_FLOATX80_TO_FLOAT64
427    1,
428#else
429    0,
430#endif
431#ifdef SYST_FLOATX80_TO_FLOAT128
432    1,
433#else
434    0,
435#endif
436#ifdef SYST_FLOATX80_ROUND_TO_INT
437    1,
438#else
439    0,
440#endif
441#ifdef SYST_FLOATX80_ADD
442    1,
443#else
444    0,
445#endif
446#ifdef SYST_FLOATX80_SUB
447    1,
448#else
449    0,
450#endif
451#ifdef SYST_FLOATX80_MUL
452    1,
453#else
454    0,
455#endif
456#ifdef SYST_FLOATX80_DIV
457    1,
458#else
459    0,
460#endif
461#ifdef SYST_FLOATX80_REM
462    1,
463#else
464    0,
465#endif
466#ifdef SYST_FLOATX80_SQRT
467    1,
468#else
469    0,
470#endif
471#ifdef SYST_FLOATX80_EQ
472    1,
473#else
474    0,
475#endif
476#ifdef SYST_FLOATX80_LE
477    1,
478#else
479    0,
480#endif
481#ifdef SYST_FLOATX80_LT
482    1,
483#else
484    0,
485#endif
486#ifdef SYST_FLOATX80_EQ_SIGNALING
487    1,
488#else
489    0,
490#endif
491#ifdef SYST_FLOATX80_LE_QUIET
492    1,
493#else
494    0,
495#endif
496#ifdef SYST_FLOATX80_LT_QUIET
497    1,
498#else
499    0,
500#endif
501#ifdef SYST_FLOAT128_TO_INT32
502    1,
503#else
504    0,
505#endif
506#ifdef SYST_FLOAT128_TO_INT32_ROUND_TO_ZERO
507    1,
508#else
509    0,
510#endif
511#ifdef SYST_FLOAT128_TO_INT64
512    1,
513#else
514    0,
515#endif
516#ifdef SYST_FLOAT128_TO_INT64_ROUND_TO_ZERO
517    1,
518#else
519    0,
520#endif
521#ifdef SYST_FLOAT128_TO_FLOAT32
522    1,
523#else
524    0,
525#endif
526#ifdef SYST_FLOAT128_TO_FLOAT64
527    1,
528#else
529    0,
530#endif
531#ifdef SYST_FLOAT128_TO_FLOATX80
532    1,
533#else
534    0,
535#endif
536#ifdef SYST_FLOAT128_ROUND_TO_INT
537    1,
538#else
539    0,
540#endif
541#ifdef SYST_FLOAT128_ADD
542    1,
543#else
544    0,
545#endif
546#ifdef SYST_FLOAT128_SUB
547    1,
548#else
549    0,
550#endif
551#ifdef SYST_FLOAT128_MUL
552    1,
553#else
554    0,
555#endif
556#ifdef SYST_FLOAT128_DIV
557    1,
558#else
559    0,
560#endif
561#ifdef SYST_FLOAT128_REM
562    1,
563#else
564    0,
565#endif
566#ifdef SYST_FLOAT128_SQRT
567    1,
568#else
569    0,
570#endif
571#ifdef SYST_FLOAT128_EQ
572    1,
573#else
574    0,
575#endif
576#ifdef SYST_FLOAT128_LE
577    1,
578#else
579    0,
580#endif
581#ifdef SYST_FLOAT128_LT
582    1,
583#else
584    0,
585#endif
586#ifdef SYST_FLOAT128_EQ_SIGNALING
587    1,
588#else
589    0,
590#endif
591#ifdef SYST_FLOAT128_LE_QUIET
592    1,
593#else
594    0,
595#endif
596#ifdef SYST_FLOAT128_LT_QUIET
597    1,
598#else
599    0,
600#endif
601};
602
603static void
604 testFunctionVariety(
605     uint8 functionCode, int8 roundingPrecision, int8 roundingMode )
606{
607    uint8 roundingCode;
608
609    functionName = functions[ functionCode ].name;
610#ifdef FLOATX80
611    if ( roundingPrecision == 32 ) {
612        roundingPrecisionName = "32";
613    }
614    else if ( roundingPrecision == 64 ) {
615        roundingPrecisionName = "64";
616    }
617    else if ( roundingPrecision == 80 ) {
618        roundingPrecisionName = "80";
619    }
620    else {
621        roundingPrecision = 80;
622        roundingPrecisionName = 0;
623    }
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;
650    }
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
707        );
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
720        );
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
817        );
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
830        );
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
927        );
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
940        );
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
1037        );
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
1050        );
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
1137    }
1138    if ( ( errorStop && anyErrors ) || stop ) exitWithStatus();
1139
1140}
1141
1142void
1143 testFunction(
1144     uint8 functionCode, int8 roundingPrecisionIn, int8 roundingModeIn )
1145{
1146    int8 roundingPrecision, roundingMode;
1147
1148    roundingPrecision = 32;
1149    for (;;) {
1150        if ( ! functions[ functionCode ].roundingPrecision ) {
1151            roundingPrecision = 0;
1152        }
1153        else if ( roundingPrecisionIn ) {
1154            roundingPrecision = roundingPrecisionIn;
1155        }
1156        for ( roundingMode = 1;
1157              roundingMode < NUM_ROUNDINGMODES;
1158              ++roundingMode
1159            ) {
1160            if ( ! functions[ functionCode ].roundingMode ) {
1161                roundingMode = 0;
1162            }
1163            else if ( roundingModeIn ) {
1164                roundingMode = roundingModeIn;
1165            }
1166            testFunctionVariety(
1167                functionCode, roundingPrecision, roundingMode );
1168            if ( roundingModeIn || ! roundingMode ) break;
1169        }
1170        if ( roundingPrecisionIn || ! roundingPrecision ) break;
1171        if ( roundingPrecision == 80 ) {
1172            break;
1173        }
1174        else if ( roundingPrecision == 64 ) {
1175            roundingPrecision = 80;
1176        }
1177        else if ( roundingPrecision == 32 ) {
1178            roundingPrecision = 64;
1179        }
1180    }
1181
1182}
1183
1184