From d6feb3fa41c6b7ba1b5444ad147d8623138512c2 Mon Sep 17 00:00:00 2001 From: John Hauser Date: Fri, 28 Nov 2014 21:07:26 -0800 Subject: First draft of RC for Release 3, to start review process. --- COPYING.txt | 34 + README.html | 82 + README.txt | 27 + build/Linux-386-GCC/Makefile | 285 +++ build/Linux-386-GCC/platform.h | 42 + doc/TestFloat-general.html | 989 +++++++++ doc/TestFloat-history.html | 156 ++ doc/TestFloat-source.html | 546 +++++ doc/testfloat.html | 259 +++ doc/testfloat_gen.html | 341 +++ doc/testfloat_ver.html | 250 +++ doc/testsoftfloat.html | 229 ++ doc/timesoftfloat.html | 202 ++ source/fail.c | 56 + source/fail.h | 38 + source/functionInfos.c | 212 ++ source/functions.h | 230 ++ source/functions_common.c | 54 + source/genCases.h | 99 + source/genCases_common.c | 55 + source/genCases_extF80.c | 917 ++++++++ source/genCases_f128.c | 1087 +++++++++ source/genCases_f32.c | 661 ++++++ source/genCases_f64.c | 801 +++++++ source/genCases_i32.c | 359 +++ source/genCases_i64.c | 551 +++++ source/genCases_ui32.c | 320 +++ source/genCases_ui64.c | 480 ++++ source/genCases_writeTestsTotal.c | 60 + source/genLoops.c | 2224 +++++++++++++++++++ source/genLoops.h | 277 +++ source/random.c | 135 ++ source/random.h | 46 + source/readHex.c | 187 ++ source/readHex.h | 43 + source/slowfloat.c | 3098 ++++++++++++++++++++++++++ source/slowfloat.h | 220 ++ source/standardFunctionInfos.c | 355 +++ source/subj-C/subjfloat.c | 734 +++++++ source/subj-C/subjfloat_config.h | 94 + source/subjfloat.h | 392 ++++ source/subjfloat_functions.c | 1410 ++++++++++++ source/testLoops.h | 466 ++++ source/testLoops_common.c | 44 + source/test_a_extF80_z_f128.c | 104 + source/test_a_extF80_z_f32.c | 104 + source/test_a_extF80_z_f64.c | 104 + source/test_a_extF80_z_i32_rx.c | 106 + source/test_a_extF80_z_i32_x.c | 105 + source/test_a_extF80_z_i64_rx.c | 106 + source/test_a_extF80_z_i64_x.c | 105 + source/test_a_extF80_z_ui32_rx.c | 106 + source/test_a_extF80_z_ui32_x.c | 105 + source/test_a_extF80_z_ui64_rx.c | 106 + source/test_a_extF80_z_ui64_x.c | 105 + source/test_a_f128_z_extF80.c | 104 + source/test_a_f128_z_f32.c | 104 + source/test_a_f128_z_f64.c | 104 + source/test_a_f128_z_i32_rx.c | 106 + source/test_a_f128_z_i32_x.c | 105 + source/test_a_f128_z_i64_rx.c | 106 + source/test_a_f128_z_i64_x.c | 105 + source/test_a_f128_z_ui32_rx.c | 106 + source/test_a_f128_z_ui32_x.c | 105 + source/test_a_f128_z_ui64_rx.c | 106 + source/test_a_f128_z_ui64_x.c | 105 + source/test_a_f32_z_extF80.c | 103 + source/test_a_f32_z_f128.c | 103 + source/test_a_f32_z_f64.c | 97 + source/test_a_f32_z_i32_rx.c | 101 + source/test_a_f32_z_i32_x.c | 100 + source/test_a_f32_z_i64_rx.c | 102 + source/test_a_f32_z_i64_x.c | 101 + source/test_a_f32_z_ui32_rx.c | 101 + source/test_a_f32_z_ui32_x.c | 100 + source/test_a_f32_z_ui64_rx.c | 101 + source/test_a_f32_z_ui64_x.c | 100 + source/test_a_f64_z_extF80.c | 103 + source/test_a_f64_z_f128.c | 103 + source/test_a_f64_z_f32.c | 97 + source/test_a_f64_z_i32_rx.c | 101 + source/test_a_f64_z_i32_x.c | 100 + source/test_a_f64_z_i64_rx.c | 102 + source/test_a_f64_z_i64_x.c | 101 + source/test_a_f64_z_ui32_rx.c | 101 + source/test_a_f64_z_ui32_x.c | 100 + source/test_a_f64_z_ui64_rx.c | 101 + source/test_a_f64_z_ui64_x.c | 100 + source/test_a_i32_z_extF80.c | 98 + source/test_a_i32_z_f128.c | 98 + source/test_a_i32_z_f32.c | 92 + source/test_a_i32_z_f64.c | 92 + source/test_a_i64_z_extF80.c | 98 + source/test_a_i64_z_f128.c | 98 + source/test_a_i64_z_f32.c | 92 + source/test_a_i64_z_f64.c | 92 + source/test_a_ui32_z_extF80.c | 98 + source/test_a_ui32_z_f128.c | 98 + source/test_a_ui32_z_f32.c | 92 + source/test_a_ui32_z_f64.c | 92 + source/test_a_ui64_z_extF80.c | 98 + source/test_a_ui64_z_f128.c | 98 + source/test_a_ui64_z_f32.c | 92 + source/test_a_ui64_z_f64.c | 92 + source/test_ab_extF80_z_bool.c | 101 + source/test_ab_f128_z_bool.c | 101 + source/test_ab_f32_z_bool.c | 96 + source/test_ab_f64_z_bool.c | 96 + source/test_abcz_f128.c | 126 ++ source/test_abcz_f32.c | 104 + source/test_abcz_f64.c | 104 + source/test_abz_extF80.c | 110 + source/test_abz_f128.c | 106 + source/test_abz_f32.c | 101 + source/test_abz_f64.c | 101 + source/test_az_extF80.c | 104 + source/test_az_extF80_rx.c | 109 + source/test_az_f128.c | 104 + source/test_az_f128_rx.c | 107 + source/test_az_f32.c | 97 + source/test_az_f32_rx.c | 102 + source/test_az_f64.c | 97 + source/test_az_f64_rx.c | 102 + source/testfloat.c | 1351 ++++++++++++ source/testfloat_gen.c | 762 +++++++ source/testfloat_ver.c | 622 ++++++ source/testsoftfloat.c | 938 ++++++++ source/timesoftfloat.c | 3958 +++++++++++++++++++++++++++++++++ source/uint128.c | 96 + source/uint128.h | 63 + source/verCases.h | 141 ++ source/verCases_common.c | 133 ++ source/verCases_writeFunctionName.c | 73 + source/verLoops.c | 4141 +++++++++++++++++++++++++++++++++++ source/verLoops.h | 251 +++ source/writeCase.h | 91 + source/writeCase_a_extF80M.c | 52 + source/writeCase_a_f128M.c | 52 + source/writeCase_a_f32.c | 48 + source/writeCase_a_f64.c | 48 + source/writeCase_a_ui32.c | 48 + source/writeCase_a_ui64.c | 48 + source/writeCase_ab_extF80M.c | 59 + source/writeCase_ab_f128M.c | 56 + source/writeCase_ab_f32.c | 50 + source/writeCase_ab_f64.c | 50 + source/writeCase_abc_extF80M.c | 62 + source/writeCase_abc_f128M.c | 62 + source/writeCase_abc_f32.c | 54 + source/writeCase_abc_f64.c | 54 + source/writeCase_z_bool.c | 56 + source/writeCase_z_extF80M.c | 64 + source/writeCase_z_f128M.c | 64 + source/writeCase_z_f32.c | 60 + source/writeCase_z_f64.c | 60 + source/writeCase_z_ui32.c | 59 + source/writeCase_z_ui64.c | 59 + source/writeHex.c | 193 ++ source/writeHex.h | 53 + 159 files changed, 41196 insertions(+) create mode 100644 COPYING.txt create mode 100644 README.html create mode 100644 README.txt create mode 100644 build/Linux-386-GCC/Makefile create mode 100644 build/Linux-386-GCC/platform.h create mode 100644 doc/TestFloat-general.html create mode 100644 doc/TestFloat-history.html create mode 100644 doc/TestFloat-source.html create mode 100644 doc/testfloat.html create mode 100644 doc/testfloat_gen.html create mode 100644 doc/testfloat_ver.html create mode 100644 doc/testsoftfloat.html create mode 100644 doc/timesoftfloat.html create mode 100644 source/fail.c create mode 100644 source/fail.h create mode 100644 source/functionInfos.c create mode 100644 source/functions.h create mode 100644 source/functions_common.c create mode 100644 source/genCases.h create mode 100644 source/genCases_common.c create mode 100644 source/genCases_extF80.c create mode 100644 source/genCases_f128.c create mode 100644 source/genCases_f32.c create mode 100644 source/genCases_f64.c create mode 100644 source/genCases_i32.c create mode 100644 source/genCases_i64.c create mode 100644 source/genCases_ui32.c create mode 100644 source/genCases_ui64.c create mode 100644 source/genCases_writeTestsTotal.c create mode 100644 source/genLoops.c create mode 100644 source/genLoops.h create mode 100644 source/random.c create mode 100644 source/random.h create mode 100644 source/readHex.c create mode 100644 source/readHex.h create mode 100644 source/slowfloat.c create mode 100644 source/slowfloat.h create mode 100644 source/standardFunctionInfos.c create mode 100644 source/subj-C/subjfloat.c create mode 100644 source/subj-C/subjfloat_config.h create mode 100644 source/subjfloat.h create mode 100644 source/subjfloat_functions.c create mode 100644 source/testLoops.h create mode 100644 source/testLoops_common.c create mode 100644 source/test_a_extF80_z_f128.c create mode 100644 source/test_a_extF80_z_f32.c create mode 100644 source/test_a_extF80_z_f64.c create mode 100644 source/test_a_extF80_z_i32_rx.c create mode 100644 source/test_a_extF80_z_i32_x.c create mode 100644 source/test_a_extF80_z_i64_rx.c create mode 100644 source/test_a_extF80_z_i64_x.c create mode 100644 source/test_a_extF80_z_ui32_rx.c create mode 100644 source/test_a_extF80_z_ui32_x.c create mode 100644 source/test_a_extF80_z_ui64_rx.c create mode 100644 source/test_a_extF80_z_ui64_x.c create mode 100644 source/test_a_f128_z_extF80.c create mode 100644 source/test_a_f128_z_f32.c create mode 100644 source/test_a_f128_z_f64.c create mode 100644 source/test_a_f128_z_i32_rx.c create mode 100644 source/test_a_f128_z_i32_x.c create mode 100644 source/test_a_f128_z_i64_rx.c create mode 100644 source/test_a_f128_z_i64_x.c create mode 100644 source/test_a_f128_z_ui32_rx.c create mode 100644 source/test_a_f128_z_ui32_x.c create mode 100644 source/test_a_f128_z_ui64_rx.c create mode 100644 source/test_a_f128_z_ui64_x.c create mode 100644 source/test_a_f32_z_extF80.c create mode 100644 source/test_a_f32_z_f128.c create mode 100644 source/test_a_f32_z_f64.c create mode 100644 source/test_a_f32_z_i32_rx.c create mode 100644 source/test_a_f32_z_i32_x.c create mode 100644 source/test_a_f32_z_i64_rx.c create mode 100644 source/test_a_f32_z_i64_x.c create mode 100644 source/test_a_f32_z_ui32_rx.c create mode 100644 source/test_a_f32_z_ui32_x.c create mode 100644 source/test_a_f32_z_ui64_rx.c create mode 100644 source/test_a_f32_z_ui64_x.c create mode 100644 source/test_a_f64_z_extF80.c create mode 100644 source/test_a_f64_z_f128.c create mode 100644 source/test_a_f64_z_f32.c create mode 100644 source/test_a_f64_z_i32_rx.c create mode 100644 source/test_a_f64_z_i32_x.c create mode 100644 source/test_a_f64_z_i64_rx.c create mode 100644 source/test_a_f64_z_i64_x.c create mode 100644 source/test_a_f64_z_ui32_rx.c create mode 100644 source/test_a_f64_z_ui32_x.c create mode 100644 source/test_a_f64_z_ui64_rx.c create mode 100644 source/test_a_f64_z_ui64_x.c create mode 100644 source/test_a_i32_z_extF80.c create mode 100644 source/test_a_i32_z_f128.c create mode 100644 source/test_a_i32_z_f32.c create mode 100644 source/test_a_i32_z_f64.c create mode 100644 source/test_a_i64_z_extF80.c create mode 100644 source/test_a_i64_z_f128.c create mode 100644 source/test_a_i64_z_f32.c create mode 100644 source/test_a_i64_z_f64.c create mode 100644 source/test_a_ui32_z_extF80.c create mode 100644 source/test_a_ui32_z_f128.c create mode 100644 source/test_a_ui32_z_f32.c create mode 100644 source/test_a_ui32_z_f64.c create mode 100644 source/test_a_ui64_z_extF80.c create mode 100644 source/test_a_ui64_z_f128.c create mode 100644 source/test_a_ui64_z_f32.c create mode 100644 source/test_a_ui64_z_f64.c create mode 100644 source/test_ab_extF80_z_bool.c create mode 100644 source/test_ab_f128_z_bool.c create mode 100644 source/test_ab_f32_z_bool.c create mode 100644 source/test_ab_f64_z_bool.c create mode 100644 source/test_abcz_f128.c create mode 100644 source/test_abcz_f32.c create mode 100644 source/test_abcz_f64.c create mode 100644 source/test_abz_extF80.c create mode 100644 source/test_abz_f128.c create mode 100644 source/test_abz_f32.c create mode 100644 source/test_abz_f64.c create mode 100644 source/test_az_extF80.c create mode 100644 source/test_az_extF80_rx.c create mode 100644 source/test_az_f128.c create mode 100644 source/test_az_f128_rx.c create mode 100644 source/test_az_f32.c create mode 100644 source/test_az_f32_rx.c create mode 100644 source/test_az_f64.c create mode 100644 source/test_az_f64_rx.c create mode 100644 source/testfloat.c create mode 100644 source/testfloat_gen.c create mode 100644 source/testfloat_ver.c create mode 100644 source/testsoftfloat.c create mode 100644 source/timesoftfloat.c create mode 100644 source/uint128.c create mode 100644 source/uint128.h create mode 100644 source/verCases.h create mode 100644 source/verCases_common.c create mode 100644 source/verCases_writeFunctionName.c create mode 100644 source/verLoops.c create mode 100644 source/verLoops.h create mode 100644 source/writeCase.h create mode 100644 source/writeCase_a_extF80M.c create mode 100644 source/writeCase_a_f128M.c create mode 100644 source/writeCase_a_f32.c create mode 100644 source/writeCase_a_f64.c create mode 100644 source/writeCase_a_ui32.c create mode 100644 source/writeCase_a_ui64.c create mode 100644 source/writeCase_ab_extF80M.c create mode 100644 source/writeCase_ab_f128M.c create mode 100644 source/writeCase_ab_f32.c create mode 100644 source/writeCase_ab_f64.c create mode 100644 source/writeCase_abc_extF80M.c create mode 100644 source/writeCase_abc_f128M.c create mode 100644 source/writeCase_abc_f32.c create mode 100644 source/writeCase_abc_f64.c create mode 100644 source/writeCase_z_bool.c create mode 100644 source/writeCase_z_extF80M.c create mode 100644 source/writeCase_z_f128M.c create mode 100644 source/writeCase_z_f32.c create mode 100644 source/writeCase_z_f64.c create mode 100644 source/writeCase_z_ui32.c create mode 100644 source/writeCase_z_ui64.c create mode 100644 source/writeHex.c create mode 100644 source/writeHex.h diff --git a/COPYING.txt b/COPYING.txt new file mode 100644 index 0000000..c7d4700 --- /dev/null +++ b/COPYING.txt @@ -0,0 +1,34 @@ + +License for Berkeley TestFloat Release 3 + +John R. Hauser +2014 ________ + +The following applies to the whole of TestFloat Release 3 as well as to each +source file individually. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and +binary forms, with or without modification, are permitted provided that the +following conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in +the documentation and/or other materials provided with the distribution. +Neither the name of the Regents nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + diff --git a/README.html b/README.html new file mode 100644 index 0000000..8831206 --- /dev/null +++ b/README.html @@ -0,0 +1,82 @@ + + + + +Berkeley TestFloat Package Overview + + + + +

Package Overview for Berkeley TestFloat Release 3

+ +

+John R. Hauser
+2014 ________
+

+ +

+Berkeley TestFloat is ___. +*** +TestFloat is distributed in the form of C source code. +Building the TestFloat sources creates ___. +

+ +

+The TestFloat package is documented in the following files in the +doc subdirectory: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestFloat-general.html +General documentation for understanding and using the TestFloat programs. +
testfloat_gen.html +Specific documentation for the testfloat_gen program. +
testfloat_ver.html +Specific documentation for the testfloat_ver program. +
testfloat.html +Specific documentation for the all-in-one testfloat program. +
testsoftfloat.html +Specific documentation for the testsoftfloat program. +
timesoftfloat.html +Specific documentation for the timesoftfloat program. +
TestFloat-source.html +Documentation for building TestFloat. +
TestFloat-history.html    +History of the major changes to TestFloat. +
+
+Other files in the package comprise the source code for TestFloat. +

+ + + diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..1f98497 --- /dev/null +++ b/README.txt @@ -0,0 +1,27 @@ + +Package Overview for Berkeley TestFloat Release 3 + +John R. Hauser +2014 ________ + +Berkeley TestFloat is ___. +*** +TestFloat +is distributed in the form of C source code. Building the TestFloat sources +creates ___. + +The TestFloat package is documented in the following files in the "doc" +subdirectory: + + TestFloat-general.html General documentation for understanding and using + the TestFloat programs. + testfloat_gen.html \ + testfloat_ver.html | Specific documentation for each TestFloat + testfloat.html | program. + testsoftfloat.html | + timesoftfloat.html / + TestFloat-source.html Documentation for building TestFloat. + TestFloat-history.html History of the major changes to TestFloat. + +Other files in the package comprise the source code for TestFloat. + diff --git a/build/Linux-386-GCC/Makefile b/build/Linux-386-GCC/Makefile new file mode 100644 index 0000000..3108628 --- /dev/null +++ b/build/Linux-386-GCC/Makefile @@ -0,0 +1,285 @@ + +SOURCE_DIR = ../../source +SOFTFLOAT_DIR = ../../../berkeley-softfloat-rc3 +SOFTFLOAT_INCLUDE_DIR = $(SOFTFLOAT_DIR)/source/include +PLATFORM = Linux-386-GCC + +SOFTFLOAT_H = \ + $(SOFTFLOAT_INCLUDE_DIR)/softfloat_types.h \ + $(SOFTFLOAT_INCLUDE_DIR)/softfloat.h +SOFTFLOAT_LIB = $(SOFTFLOAT_DIR)/build/$(PLATFORM)/softfloat$(LIB) + +TYPE_OPTS = -DEXTFLOAT80 -DFLOAT128 + +DELETE = rm -f +C_INCLUDES = -I. -I$(SOURCE_DIR) -I$(SOFTFLOAT_INCLUDE_DIR) +COMPILE_C = \ + gcc -c -Werror-implicit-function-declaration $(TYPE_OPTS) $(C_INCLUDES) -O2 \ + -o $@ +COMPILE_SLOWFLOAT_C = \ + gcc -c -Werror-implicit-function-declaration $(TYPE_OPTS) $(C_INCLUDES) -O3 \ + -o $@ +MAKELIB = ar crs $@ +LINK = gcc -o $@ + +OBJ = .o +LIB = .a +EXE = + +.PHONY: all +all: \ + testsoftfloat$(EXE) \ + timesoftfloat$(EXE) \ + testfloat_gen$(EXE) \ + testfloat_ver$(EXE) \ + testfloat$(EXE) \ + +OBJS_GENCASES = \ + genCases_ui32$(OBJ) \ + genCases_ui64$(OBJ) \ + genCases_i32$(OBJ) \ + genCases_i64$(OBJ) \ + genCases_f32$(OBJ) \ + genCases_f64$(OBJ) \ + genCases_extF80$(OBJ) \ + genCases_f128$(OBJ) \ + +OBJS_WRITECASE = \ + writeCase_a_ui32$(OBJ) \ + writeCase_a_ui64$(OBJ) \ + writeCase_a_f32$(OBJ) \ + writeCase_ab_f32$(OBJ) \ + writeCase_abc_f32$(OBJ) \ + writeCase_a_f64$(OBJ) \ + writeCase_ab_f64$(OBJ) \ + writeCase_abc_f64$(OBJ) \ + writeCase_a_extF80M$(OBJ) \ + writeCase_ab_extF80M$(OBJ) \ + writeCase_abc_extF80M$(OBJ) \ + writeCase_a_f128M$(OBJ) \ + writeCase_ab_f128M$(OBJ) \ + writeCase_abc_f128M$(OBJ) \ + writeCase_z_bool$(OBJ) \ + writeCase_z_ui32$(OBJ) \ + writeCase_z_ui64$(OBJ) \ + writeCase_z_f32$(OBJ) \ + writeCase_z_f64$(OBJ) \ + writeCase_z_extF80M$(OBJ) \ + writeCase_z_f128M$(OBJ) \ + +OBJS_TEST = \ + test_a_ui32_z_f32$(OBJ) \ + test_a_ui32_z_f64$(OBJ) \ + test_a_ui32_z_extF80$(OBJ) \ + test_a_ui32_z_f128$(OBJ) \ + test_a_ui64_z_f32$(OBJ) \ + test_a_ui64_z_f64$(OBJ) \ + test_a_ui64_z_extF80$(OBJ) \ + test_a_ui64_z_f128$(OBJ) \ + test_a_i32_z_f32$(OBJ) \ + test_a_i32_z_f64$(OBJ) \ + test_a_i32_z_extF80$(OBJ) \ + test_a_i32_z_f128$(OBJ) \ + test_a_i64_z_f32$(OBJ) \ + test_a_i64_z_f64$(OBJ) \ + test_a_i64_z_extF80$(OBJ) \ + test_a_i64_z_f128$(OBJ) \ + test_a_f32_z_ui32_rx$(OBJ) \ + test_a_f32_z_ui64_rx$(OBJ) \ + test_a_f32_z_i32_rx$(OBJ) \ + test_a_f32_z_i64_rx$(OBJ) \ + test_a_f32_z_ui32_x$(OBJ) \ + test_a_f32_z_ui64_x$(OBJ) \ + test_a_f32_z_i32_x$(OBJ) \ + test_a_f32_z_i64_x$(OBJ) \ + test_a_f32_z_f64$(OBJ) \ + test_a_f32_z_extF80$(OBJ) \ + test_a_f32_z_f128$(OBJ) \ + test_az_f32$(OBJ) \ + test_az_f32_rx$(OBJ) \ + test_abz_f32$(OBJ) \ + test_abcz_f32$(OBJ) \ + test_ab_f32_z_bool$(OBJ) \ + test_a_f64_z_ui32_rx$(OBJ) \ + test_a_f64_z_ui64_rx$(OBJ) \ + test_a_f64_z_i32_rx$(OBJ) \ + test_a_f64_z_i64_rx$(OBJ) \ + test_a_f64_z_ui32_x$(OBJ) \ + test_a_f64_z_ui64_x$(OBJ) \ + test_a_f64_z_i32_x$(OBJ) \ + test_a_f64_z_i64_x$(OBJ) \ + test_a_f64_z_f32$(OBJ) \ + test_a_f64_z_extF80$(OBJ) \ + test_a_f64_z_f128$(OBJ) \ + test_az_f64$(OBJ) \ + test_az_f64_rx$(OBJ) \ + test_abz_f64$(OBJ) \ + test_abcz_f64$(OBJ) \ + test_ab_f64_z_bool$(OBJ) \ + test_a_extF80_z_ui32_rx$(OBJ) \ + test_a_extF80_z_ui64_rx$(OBJ) \ + test_a_extF80_z_i32_rx$(OBJ) \ + test_a_extF80_z_i64_rx$(OBJ) \ + test_a_extF80_z_ui32_x$(OBJ) \ + test_a_extF80_z_ui64_x$(OBJ) \ + test_a_extF80_z_i32_x$(OBJ) \ + test_a_extF80_z_i64_x$(OBJ) \ + test_a_extF80_z_f32$(OBJ) \ + test_a_extF80_z_f64$(OBJ) \ + test_a_extF80_z_f128$(OBJ) \ + test_az_extF80$(OBJ) \ + test_az_extF80_rx$(OBJ) \ + test_abz_extF80$(OBJ) \ + test_ab_extF80_z_bool$(OBJ) \ + test_a_f128_z_ui32_rx$(OBJ) \ + test_a_f128_z_ui64_rx$(OBJ) \ + test_a_f128_z_i32_rx$(OBJ) \ + test_a_f128_z_i64_rx$(OBJ) \ + test_a_f128_z_ui32_x$(OBJ) \ + test_a_f128_z_ui64_x$(OBJ) \ + test_a_f128_z_i32_x$(OBJ) \ + test_a_f128_z_i64_x$(OBJ) \ + test_a_f128_z_f32$(OBJ) \ + test_a_f128_z_f64$(OBJ) \ + test_a_f128_z_extF80$(OBJ) \ + test_az_f128$(OBJ) \ + test_az_f128_rx$(OBJ) \ + test_abz_f128$(OBJ) \ + test_abcz_f128$(OBJ) \ + test_ab_f128_z_bool$(OBJ) \ + +OBJS_LIB = \ + uint128$(OBJ) \ + fail$(OBJ) \ + functions_common$(OBJ) \ + functionInfos$(OBJ) \ + standardFunctionInfos$(OBJ) \ + random$(OBJ) \ + genCases_common$(OBJ) \ + $(OBJS_GENCASES) \ + genCases_writeTestsTotal$(OBJ) \ + verCases_common$(OBJ) \ + verCases_writeFunctionName$(OBJ) \ + readHex$(OBJ) \ + writeHex$(OBJ) \ + $(OBJS_WRITECASE) \ + testLoops_common$(OBJ) \ + $(OBJS_TEST) \ + +uint128$(OBJ): platform.h $(SOURCE_DIR)/uint128.h +fail$(OBJ): $(SOURCE_DIR)/fail.h +functions_common$(OBJ): $(SOFTFLOAT_H) $(SOURCE_DIR)/functions.h +functionInfos$(OBJ): $(SOURCE_DIR)/functions.h +random$(OBJ): $(SOURCE_DIR)/random.h +genCases_common$(OBJ): $(SOURCE_DIR)/fail.h $(SOURCE_DIR)/genCases.h +$(OBJS_GENCASES): \ + $(SOURCE_DIR)/random.h $(SOFTFLOAT_H) $(SOURCE_DIR)/genCases.h +genCases_f128$(OBJ): platform.h $(SOURCE_DIR)/uint128.h +genCases_writeTestsTotal$(OBJ): $(SOURCE_DIR)/genCases.h +verCases_common$(OBJ): $(SOURCE_DIR)/verCases.h +verCases_writeFunctionName$(OBJ): $(SOURCE_DIR)/verCases.h +readHex$(OBJ): $(SOURCE_DIR)/readHex.h +writeHex$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOFTFLOAT_H) $(SOURCE_DIR)/writeHex.h +writeCase_common$(OBJ): $(SOURCE_DIR)/writeCase.h +$(OBJS_WRITECASE): \ + $(SOFTFLOAT_H) $(SOURCE_DIR)/writeHex.h $(SOURCE_DIR)/writeCase.h +testLoops_common$(OBJ): $(SOURCE_DIR)/testLoops.h +$(OBJS_TEST): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOFTFLOAT_H) $(SOURCE_DIR)/genCases.h \ + $(SOURCE_DIR)/verCases.h $(SOURCE_DIR)/writeCase.h $(SOURCE_DIR)/testLoops.h +$(OBJS_LIB): %$(OBJ): $(SOURCE_DIR)/%.c + $(COMPILE_C) $(SOURCE_DIR)/$*.c +testfloat$(LIB): $(OBJS_LIB) + $(MAKELIB) $^ +#*** RESTORE: +# standardFunctionInfos$(OBJ): $(SOURCE_DIR)/functions.h + +OBJS_TESTSOFTFLOAT = slowfloat$(OBJ) testsoftfloat$(OBJ) + +slowfloat$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOFTFLOAT_H) $(SOURCE_DIR)/slowfloat.h \ + $(SOURCE_DIR)/slowfloat.c + $(COMPILE_SLOWFLOAT_C) $(SOURCE_DIR)/slowfloat.c +testsoftfloat$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOURCE_DIR)/fail.h $(SOFTFLOAT_H) \ + $(SOURCE_DIR)/slowfloat.h $(SOURCE_DIR)/functions.h \ + $(SOURCE_DIR)/genCases.h $(SOURCE_DIR)/verCases.h $(SOURCE_DIR)/writeCase.h \ + $(SOURCE_DIR)/testLoops.h $(SOURCE_DIR)/testsoftfloat.c + $(COMPILE_C) $(SOURCE_DIR)/testsoftfloat.c + +testsoftfloat$(EXE): $(OBJS_TESTSOFTFLOAT) testfloat$(LIB) $(SOFTFLOAT_LIB) + $(LINK) $^ + +OBJS_TIMESOFTFLOAT = timesoftfloat$(OBJ) + +timesoftfloat$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOURCE_DIR)/fail.h $(SOFTFLOAT_H) \ + $(SOURCE_DIR)/functions.h $(SOURCE_DIR)/timesoftfloat.c + $(COMPILE_C) $(SOURCE_DIR)/timesoftfloat.c + +timesoftfloat$(EXE): $(OBJS_TIMESOFTFLOAT) testfloat$(LIB) $(SOFTFLOAT_LIB) + $(LINK) $^ + +OBJS_TESTFLOAT_GEN = genLoops$(OBJ) testfloat_gen$(OBJ) + +genLoops$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOURCE_DIR)/fail.h $(SOFTFLOAT_H) \ + $(SOURCE_DIR)/genCases.h $(SOURCE_DIR)/writeHex.h $(SOURCE_DIR)/genLoops.h \ + $(SOURCE_DIR)/genLoops.c + $(COMPILE_C) $(SOURCE_DIR)/genLoops.c +testfloat_gen$(OBJ): \ + $(SOURCE_DIR)/fail.h $(SOFTFLOAT_H) $(SOURCE_DIR)/functions.h \ + $(SOURCE_DIR)/genCases.h $(SOURCE_DIR)/genLoops.h \ + $(SOURCE_DIR)/testfloat_gen.c + $(COMPILE_C) $(SOURCE_DIR)/testfloat_gen.c + +testfloat_gen$(EXE): $(OBJS_TESTFLOAT_GEN) testfloat$(LIB) $(SOFTFLOAT_LIB) + $(LINK) $^ + +OBJS_TESTFLOAT_VER = verLoops$(OBJ) testfloat_ver$(OBJ) + +verLoops$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOURCE_DIR)/fail.h $(SOFTFLOAT_H) \ + $(SOURCE_DIR)/readHex.h $(SOURCE_DIR)/verCases.h $(SOURCE_DIR)/writeCase.h \ + $(SOURCE_DIR)/verLoops.h $(SOURCE_DIR)/verLoops.c + $(COMPILE_C) $(SOURCE_DIR)/verLoops.c +testfloat_ver$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOURCE_DIR)/fail.h $(SOFTFLOAT_H) \ + $(SOURCE_DIR)/functions.h $(SOURCE_DIR)/verCases.h \ + $(SOURCE_DIR)/writeCase.h $(SOURCE_DIR)/verLoops.h \ + $(SOURCE_DIR)/testfloat_ver.c + $(COMPILE_C) $(SOURCE_DIR)/testfloat_ver.c + +testfloat_ver$(EXE): $(OBJS_TESTFLOAT_VER) testfloat$(LIB) $(SOFTFLOAT_LIB) + $(LINK) $^ + +OBJS_TESTFLOAT = systfloat$(OBJ) systfloat_functions$(OBJ) testfloat$(OBJ) + +systfloat$(OBJ): \ + $(SOFTFLOAT_H) $(SOURCE_DIR)/systfloat_config.h $(SOURCE_DIR)/systfloat.h \ + $(SOURCE_DIR)/systfloat.c + $(COMPILE_C) $(SOURCE_DIR)/systfloat.c +systfloat_functions$(OBJ): \ + $(SOURCE_DIR)/systfloat_config.h $(SOURCE_DIR)/systfloat.h \ + $(SOURCE_DIR)/functions.h $(SOURCE_DIR)/systfloat_functions.c + $(COMPILE_C) $(SOURCE_DIR)/systfloat_functions.c +testfloat$(OBJ): \ + platform.h $(SOURCE_DIR)/uint128.h $(SOURCE_DIR)/fail.h $(SOFTFLOAT_H) \ + $(SOURCE_DIR)/systfloat_config.h $(SOURCE_DIR)/systfloat.h \ + $(SOURCE_DIR)/functions.h $(SOURCE_DIR)/genCases.h $(SOURCE_DIR)/verCases.h \ + $(SOURCE_DIR)/writeCase.h $(SOURCE_DIR)/testLoops.h $(SOURCE_DIR)/testfloat.c + $(COMPILE_C) $(SOURCE_DIR)/testfloat.c + +testfloat$(EXE): $(OBJS_TESTFLOAT) testfloat$(LIB) $(SOFTFLOAT_LIB) + $(LINK) $^ -lm + +.PHONY: clean +clean: + $(DELETE) $(OBJS_LIB) testfloat$(LIB) + $(DELETE) $(OBJS_TESTSOFTFLOAT) testsoftfloat$(EXE) + $(DELETE) $(OBJS_TIMESOFTFLOAT) timesoftfloat$(EXE) + $(DELETE) $(OBJS_TESTFLOAT_GEN) testfloat_gen$(EXE) + $(DELETE) $(OBJS_TESTFLOAT_VER) testfloat_ver$(EXE) + $(DELETE) $(OBJS_TESTFLOAT) testfloat$(EXE) + diff --git a/build/Linux-386-GCC/platform.h b/build/Linux-386-GCC/platform.h new file mode 100644 index 0000000..2ea4f73 --- /dev/null +++ b/build/Linux-386-GCC/platform.h @@ -0,0 +1,42 @@ + +/*============================================================================ + +*** FIX. + +This C source fragment is part of the SoftFloat IEC/IEEE Floating-point +Arithmetic Package, Release 2b. + +Written by John R. Hauser. This work was made possible in part by the +International Computer Science Institute, located at Suite 600, 1947 Center +Street, Berkeley, California 94704. Funding was partially provided by the +National Science Foundation under grant MIP-9311980. The original version +of this code was written as part of a project to build a fixed-point vector +processor in collaboration with the University of California at Berkeley, +overseen by Profs. Nelson Morgan and John Wawrzynek. More information +is available through the Web page `http://www.cs.berkeley.edu/~jhauser/ +arithmetic/SoftFloat.html'. + +THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has +been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES +RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS +AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES, +COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE +EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE +INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR +OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE. + +Derivative works are acceptable, even for commercial purposes, so long as +(1) the source code for the derivative work includes prominent notice that +the work is derivative, and (2) the source code includes prominent notice with +these four paragraphs for those parts of this code that are retained. + +=============================================================================*/ + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +#define LITTLEENDIAN 1 + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +#define INLINE extern inline + diff --git a/doc/TestFloat-general.html b/doc/TestFloat-general.html new file mode 100644 index 0000000..1618d4a --- /dev/null +++ b/doc/TestFloat-general.html @@ -0,0 +1,989 @@ + + + + +Berkeley TestFloat General Documentation + + + + +

Berkeley TestFloat Release 3: General Documentation

+ +

+John R. Hauser
+2014 ______
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +
+*** REPLACE APOSTROPHES. +
+*** REPLACE EM DASH. +

+ + +

Contents

+ +

+*** CHECK.
+*** FIX FORMATTING. +

+ +
+    Introduction
+    Limitations
+    Acknowledgments and License
+    What TestFloat Does
+    Executing TestFloat
+    Operations Tested by TestFloat
+        Conversion Operations
+        Basic Arithmetic Operations
+        Fused Multiply-Add Operations
+        Remainder Operations
+        Round-to-Integer Operations
+        Comparison Operations
+    Interpreting TestFloat Output
+    Variations Allowed by the IEEE Floating-Point Standard
+        Underflow
+        NaNs
+        Conversions to Integer
+    Contact Information
+
+ + +

1. Introduction

+ +

+Berkeley TestFloat is a small collection of programs for testing that an +implementation of binary floating-point conforms to the IEEE Standard for +Floating-Point Arithmetic. +All operations required by the original 1985 version of the IEEE Floating-Point +Standard can be tested, except for conversions to and from decimal. +The following binary formats can be tested: 32-bit +single-precision, 64-bit double-precision, 80-bit +double-extended-precision, and/or 128-bit quadruple-precision. +TestFloat cannot test decimal floating-point. +

+ +

+Included in the TestFloat package are the testsoftfloat and +timesoftfloat programs for testing the Berkeley SoftFloat software +implementation of floating-point and for measuring its speed. +Information about SoftFloat can be found at the SoftFloat Web page, +http://www.jhauser.us/arithmetic/SoftFloat.html. +The testsoftfloat and timesoftfloat programs are +expected to be of interest only to people compiling the SoftFloat sources. +

+ +

+This document explains how to use the TestFloat programs. +It does not attempt to define or explain much of the IEEE Floating-Point +Standard. +Details about the standard are available elsewhere. +

+ +

+The current version of TestFloat is Release 3. +The set of TestFloat programs as well as the programs' arguments and behavior +have changed some compared to earlier TestFloat releases. +

+ + +

2. Limitations

+ +

+TestFloat output is not always easily interpreted. +Detailed knowledge of the IEEE Floating-Point Standard and its vagaries is +needed to use TestFloat responsibly. +

+ +

+TestFloat performs relatively simple tests designed to check the fundamental +soundness of the floating-point under test. +TestFloat may also at times manage to find rarer and more subtle bugs, but it +will probably only find such bugs by chance. +Software that purposefully seeks out various kinds of subtle floating-point +bugs can be found through links posted on the TestFloat Web page +(http://www.jhauser.us/arithmetic/TestFloat.html). +

+ + +

3. Acknowledgments and License

+ +

+The TestFloat package was written by me, John R. Hauser. +Release 3 of TestFloat is a completely new implementation +supplanting earlier releases. +This project was done in the employ of the University of California, Berkeley, +within the Department of Electrical Engineering and Computer Sciences, first +for the Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab. +The work was officially overseen by Prof. Krste Asanovic, with funding provided +by these sources: +

+ + + + + + + + + +
Par Lab: +Microsoft (Award #024263), Intel (Award #024894), and U.C. Discovery +(Award #DIG07-10227), with additional support from Par Lab affiliates Nokia, +NVIDIA, Oracle, and Samsung. +
ASPIRE Lab: +DARPA PERFECT program (Award #HR0011-12-2-0016), with additional support from +ASPIRE industrial sponsor Intel and ASPIRE affiliates Google, Nokia, NVIDIA, +Oracle, and Samsung. +
+
+

+ +

+The following applies to the whole of TestFloat Release 3 as well +as to each source file individually. +

+ +

+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). +All Rights Reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +

+ +

+Redistributions of source code must retain the above copyright notice, this +list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. +Neither the name of the Regents nor the names of its contributors may be used +to endorse or promote products derived from this software without specific +prior written permission. +

+ +

+IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, +INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF +THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +

+ +

+REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". +REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, +ENHANCEMENTS, OR MODIFICATIONS. +

+ + +

4. What TestFloat Does

+ +

+TestFloat is designed to test a floating-point implementation by comparing its +behavior with that of TestFloat's own internal floating-point implemented in +software. +For each operation to be tested, the TestFloat programs can generate a large +number of test cases, made up of simple pattern tests intermixed with weighted +random inputs. +The cases generated should be adequate for testing carry chain propagations, +plus the rounding of addition, subtraction, multiplication, and simple +operations like conversions. +TestFloat makes a point of checking all boundary cases of the arithmetic, +including underflows, overflows, invalid operations, subnormal inputs, zeros +(positive and negative), infinities, and NaNs. +For the interesting operations like addition and multiplication, millions of +test cases may be checked. +

+ +

+TestFloat is not remarkably good at testing difficult rounding cases for +division and square root. +It also makes no attempt to find bugs specific to SRT division and the like +(such as the infamous Pentium division bug). +Software that tests for such failures can be found through links on the +TestFloat Web page, +http://www.jhauser.us/arithmetic/TestFloat.html. +

+ +

+NOTE!
+It is the responsibility of the user to verify that the discrepancies TestFloat +finds actually represent faults in the implementation being tested. +Advice to help with this task is provided later in this document. +Furthermore, even if TestFloat finds no fault with a floating-point +implementation, that in no way guarantees that the implementation is bug-free. +

+ +

+For each operation, TestFloat can test all five rounding modes defined by the +IEEE Floating-Point Standard. +TestFloat verifies not only that the numeric results of an operation are +correct, but also that the proper floating-point exception flags are raised. +All five exception flags are tested, including the inexact flag. +TestFloat does not attempt to verify that the floating-point exception flags +are actually implemented as sticky flags. +

+ +

+For the 80-bit double-extended-precision format, TestFloat can +test the addition, subtraction, multiplication, division, and square root +operations at all three of the standard rounding precisions. +The rounding precision can be set to 32 bits, equivalent to +single-precision, to 64 bits, equivalent to double-precision, or +to the full 80 bits of the double-extended-precision. +Rounding precision control can be applied only to the double-extended-precision +format and only for the five basic arithmetic operations: addition, +subtraction, multiplication, division, and square root. +Other operations can be tested only at full precision. +

+ +

+As a rule, TestFloat is not particular about the bit patterns of NaNs that +appear as operation results. +Any NaN is considered as good a result as another. +This laxness can be overridden so that TestFloat checks for particular bit +patterns within NaN results. +See section 8 below, Variations Allowed by the IEEE +Floating-Point Standard, plus the -checkNaNs option documented +for programs testfloat_ver and testfloat. +

+ +

+TestFloat normally compares an implementation of floating-point against the +Berkeley SoftFloat software implementation of floating-point, also created by +me. +The SoftFloat functions are linked into each TestFloat program's executable. +Information about SoftFloat can be found at the Web page +http://www.jhauser.us/arithmetic/SoftFloat.html. +

+ +

+For testing SoftFloat itself, the TestFloat package includes a +testsoftfloat program that compares SoftFloat's floating-point +against another software floating-point implementation. +The second software floating-point is simpler and slower than SoftFloat, and is +completely independent of SoftFloat. +Although the second software floating-point cannot be guaranteed to be +bug-free, the chance that it would mimic any of SoftFloat's bugs is low. +Consequently, an error in one or the other floating-point version should appear +as an unexpected difference between the two implementations. +Note that testing SoftFloat should be necessary only when compiling a new +TestFloat executable or when compiling SoftFloat for some other reason. +

+ + +

5. Executing TestFloat

+ +

+The TestFloat package consists of five programs, all intended to be executed +from a command-line interpreter: +

+ + + + + + + + + + + + + + + + + + + + + +
+testfloat_gen    + +Generates test cases for a specific floating-point operation. +
testfloat_ver +Verifies whether the results from executing a floating-point operation are as +expected. +
testfloat +An all-in-one program that generates test cases, executes floating-point +operations, and verifies whether the results match expectations. +
+testsoftfloat    + +Like testfloat, but for testing SoftFloat. +
+timesoftfloat    + +A program for measuring the speed of SoftFloat (included in the TestFloat +package for convenience). +
+
+Each program has its own page of documentation that can be opened through the +links in the table above. +

+ +

+To test a floating-point implementation other than SoftFloat, one of three +different methods can be used. +The first method pipes output from testfloat_gen to a program +that: +(a) reads the incoming test cases, (b) invokes the +floating-point operation being tested, and (c) writes the +operation results to output. +These results can then be piped to testfloat_ver to be checked for +correctness. +Assuming a vertical bar (|) indicates a pipe between programs, the +complete process could be written as a single command like so: +

+     testfloat_gen ... <type> | <program-that-invokes-op> | testfloat_ver ... <function>
+
+The program in the middle is not supplied by TestFloat but must be created +independently. +If for some reason this program cannot take command-line arguments, the +-prefix option of testfloat_gen can communicate +parameters through the pipe. +

+ +

+A second method for running TestFloat is similar but has +testfloat_gen supply not only the test inputs but also the +expected results for each case. +With this additional information, the job done by testfloat_ver +can be folded into the invoking program to give the following command: +

+     testfloat_gen ... <function> | <program-that-invokes-op-and-compares-results>
+
+Again, the program that actually invokes the floating-point operation is not +supplied by TestFloat but must be created independently. +Depending on circumstance, it may be preferable either to let +testfloat_ver check and report suspected errors (first method) or +to include this step in the invoking program (second method). +

+ +

+The third way to use TestFloat is the all-in-one testfloat +program. +This program can perform all the steps of creating test cases, invoking the +floating-point operation, checking the results, and reporting suspected errors. +However, for this to be possible, testfloat must be compiled to +contain the method for invoking the floating-point operations to test. +Each build of testfloat is therefore capable of testing +only the floating-point implementation it was built to invoke. +To test a new implementation of floating-point, a new testfloat +must be created, linked to that specific implementation. +By comparison, the testfloat_gen and testfloat_ver +programs are entirely generic; +one instance is usable for testing any floating-point implementation, because +implementation-specific details are segregated in the custom program that +follows testfloat_gen. +

+ +

+Program testsoftfloat is another all-in-one program specifically +for testing SoftFloat. +

+ +

+Programs testfloat_ver, testfloat, and +testsoftfloat all report status and error information in a common +way. +As it executes, each of these programs writes status information to the +standard error output, which should be the screen by default. +In order for this status to be displayed properly, the standard error stream +should not be redirected to a file. +Any discrepancies that are found are written to the standard output stream, +which is easily redirected to a file if desired. +Unless redirected, reported errors will appear intermixed with the ongoing +status information in the output. +

+ + +

6. Operations Tested by TestFloat

+ +

+TestFloat can test all operations required by the original 1985 IEEE +Floating-Point Standard except for conversions to and from decimal. +These operations are: +

+In addition, TestFloat can also test + +

+ +

+More information about all these operations is given below. +In the operation names used by TestFloat, 32-bit single-precision +is called f32, 64-bit double-precision is +f64, 80-bit double-extended-precision is +extF80, and 128-bit quadruple-precision is +f128. +TestFloat generally uses the same names for operations as Berkeley SoftFloat, +except that TestFloat's names never include the M that SoftFloat +uses to indicate that values are passed through pointers. +

+ +

6.1. Conversion Operations

+ +

+All conversions among the floating-point formats and all conversions between a +floating-point format and 32-bit and 64-bit integers +can be tested. +The conversion operations are: +

+     ui32_to_f32      ui64_to_f32      i32_to_f32       i64_to_f32
+     ui32_to_f64      ui64_to_f64      i32_to_f64       i64_to_f64
+     ui32_to_extF80   ui64_to_extF80   i32_to_extF80    i64_to_extF80
+     ui32_to_f128     ui64_to_f128     i32_to_f128      i64_to_f128
+
+     f32_to_ui32      f64_to_ui32      extF80_to_ui32   f128_to_ui32
+     f32_to_ui64      f64_to_ui64      extF80_to_ui64   f128_to_ui64
+     f32_to_i32       f64_to_i32       extF80_to_i32    f128_to_i32
+     f32_to_i64       f64_to_i64       extF80_to_i64    f128_to_i64
+
+     f32_to_f64       f64_to_f32       extF80_to_f32    f128_to_f32
+     f32_to_extF80    f64_to_extF80    extF80_to_f64    f128_to_f64
+     f32_to_f128      f64_to_f128      extF80_to_f128   f128_to_extF80
+
+Abbreviations ui32 and ui64 indicate +32-bit and 64-bit unsigned integer types, while +i32 and i64 indicate their signed counterparts. +These conversions all round according to the current rounding mode as relevant. +Conversions from a smaller to a larger floating-point format are always exact +and so require no rounding. +Likewise, conversions from 32-bit integers to 64-bit +double-precision or to any larger floating-point format are also exact, as are +conversions from 64-bit integers to 80-bit +double-extended-precision and 128-bit quadruple-precision. +

+ +

+For the all-in-one testfloat program, this list of conversion +operations requires amendment. +For testfloat only, conversions to an integer type have names that +explicitly specify the rounding mode and treatment of inexactness. +Thus, instead of +

+     <float>_to_<int>
+
+as listed above, operations converting to integer type have names of these +forms: +
+     <float>_to_<int>_r_<round>
+     <float>_to_<int>_rx_<round>
+
+The <round> component is one of `near_even', +`near_maxMag', `minMag', `min', or +`max', choosing the rounding mode. +Any other indication of rounding mode is ignored. +The operations with `_r_' in their names never raise the +inexact exception, while those with `_rx_' raise the +inexact exception whenever the result is not exact. +

+ +

+TestFloat assumes that conversions from floating-point to an integer type +should raise the invalid exception if the input cannot be rounded to an +integer representable by the result format. +In such a circumstance, if the result type is an unsigned integer, TestFloat +expects the result of the operation to be the type's largest integer value. +If the result type is a signed integer and conversion overflows, TestFloat +expects the result to be the largest-magnitude integer with the same sign as +the input. +Lastly, when a NaN is converted to a signed integer type, TestFloat allows +either the largest postive or largest-magnitude negative integer to be +returned. +Conversions to integer types are expected never to raise the overflow +exception. +

+ +

6.2. Basic Arithmetic Operations

+ +

+The following standard arithmetic operations can be tested: +

+     f32_add      f32_sub      f32_mul      f32_div      f32_sqrt
+     f64_add      f64_sub      f64_mul      f64_div      f64_sqrt
+     extF80_add   extF80_sub   extF80_mul   extF80_div   extF80_sqrt
+     f128_add     f128_sub     f128_mul     f128_div     f128_sqrt
+
+The double-extended-precision (extF80) operations can be rounded +to reduced precision under rounding precision control. +

+ +

6.3. Fused Multiply-Add Operations

+ +

+For all floating-point formats except 80-bit +double-extended-precision, TestFloat can test the fused multiply-add operation +defined by the 2008 IEEE Floating-Point Standard. +The fused multiply-add operations are: +

+     f32_mulAdd
+     f64_mulAdd
+     f128_mulAdd
+
+

+ +

+If one of the multiplication operands is infinite and the other is zero, +TestFloat expects the fused multiply-add operation to raise the invalid +exception even if the third operand is a NaN. +

+ +

6.4. Remainder Operations

+ +

+For each format, TestFloat can test the IEEE Standard's remainder operation. +These operations are: +

+     f32_rem
+     f64_rem
+     extF80_rem
+     f128_rem
+
+The remainder operations are always exact and so require no rounding. +

+ +

6.5. Round-to-Integer Operations

+ +

+For each format, TestFloat can test the IEEE Standard's round-to-integer +operation. +For most TestFloat programs, these operations are: +

+     f32_roundToInt
+     f64_roundToInt
+     extF80_roundToInt
+     f128_roundToInt
+
+

+ +

+Just as for conversions to integer types (section 6.1 above), the +all-in-one testfloat program is again an exception. +For testfloat only, the round-to-integer operations have names of +these forms: +

+     <float>_roundToInt_r_<round>
+     <float>_roundToInt_x
+
+For the `_r_' versions, the inexact exception is never +raised, and the <round> component specifies the rounding +mode as one of `near_even', `near_maxMag', +`minMag', `min', or `max'. +The usual indication of rounding mode is ignored. +In contrast, the `_x' versions accept the usual indication of +rounding mode and raise the inexact exception whenever the result is not +exact. +This irregular system follows the IEEE Standard's precise specification for the +round-to-integer operations. +

+ +

6.6. Comparison Operations

+ +

+The following floating-point comparison operations can be tested: +

+     f32_eq      f32_le      f32_lt
+     f64_eq      f64_le      f64_lt
+     extF80_eq   extF80_le   extF80_lt
+     f128_eq     f128_le     f128_lt
+
+The abbreviation eq stands for ``equal'' (=), le +stands for ``less than or equal'' (≤), and lt stands for +``less than'' (<). +

+ +

+The IEEE Standard specifies that, by default, the less-than-or-equal and +less-than comparisons raise the invalid exception if either input is any +kind of NaN. +The equality comparisons, on the other hand, are defined by default to raise +the invalid exception only for signaling NaNs, not for quiet NaNs. +For completeness, the following additional operations can be tested if +supported: +

+     f32_eq_signaling      f32_le_quiet      f32_lt_quiet
+     f64_eq_signaling      f64_le_quiet      f64_lt_quiet
+     extF80_eq_signaling   extF80_le_quiet   extF80_lt_quiet
+     f128_eq_signaling     f128_le_quiet     f128_lt_quiet
+
+The signaling equality comparisons are identical to the standard +operations except that the invalid exception should be raised for any +NaN input. +Similarly, the quiet comparison operations should be identical to +their counterparts except that the invalid exception is not raised for +quiet NaNs. +

+ +

+Obviously, no comparison operations ever require rounding. +Any rounding mode is ignored. +

+ + +

7. Interpreting TestFloat Output

+ +

+The ``errors'' reported by TestFloat programs may or may not really represent +errors in the system being tested. +For each test case tried, the results from the floating-point implementation +being tested could differ from the expected results for several reasons: +

+It is the responsibility of the user to determine the causes for the +discrepancies that are reported. +Making this determination can require detailed knowledge about the IEEE +Standard. +Assuming TestFloat is working properly, any differences found will be due to +either the first or last of the reasons above. +Variations in the IEEE Standard that could lead to false error reports are +discussed in section 8, Variations Allowed by the IEEE +Floating-Point Standard. +

+ +

+For each reported error (or apparent error), a line of text is written to the +default output. +If a line would be longer than 79 characters, it is divided. +The first part of each error line begins in the leftmost column, and any +subsequent ``continuation'' lines are indented with a tab. +

+ +

+Each error reported is of the form: +

+     <inputs>  => <observed-output>  expected: <expected-output>
+
+The <inputs> are the inputs to the operation. +Each output (observed and expected) is shown as a pair: the result value +first, followed by the exception flags. +

+ +

+For example, two typical error lines could be +

+     800.7FFF00  87F.000100  => 001.000000 ...ux  expected: 001.000000 ....x
+     081.000004  000.1FFFFF  => 001.000000 ...ux  expected: 001.000000 ....x
+
+In the first line, the inputs are 800.7FFF00 and +87F.000100, and the observed result is 001.000000 +with flags ...ux. +The trusted emulation result is the same but with different flags, +....x. +Items such as 800.7FFF00 composed of hexadecimal digits and a +single period represent floating-point values (here 32-bit +single-precision). +The two instances above were reported as errors because the exception flag +results differ. +

+ +

+Aside from the exception flags, there are nine data types that may be +represented. +Four are floating-point types: 32-bit single-precision, +64-bit double-precision, 80-bit +double-extended-precision, and 128-bit quadruple-precision. +The remaining five types are 32-bit and 64-bit +unsigned integers, 32-bit and 64-bit two's-complement +signed integers, and Boolean values (the results of comparison operations). +Boolean values are represented as a single character, either a 0 +or a 1. +32-bit integers are represented as 8 hexadecimal digits. +Thus, for a signed 32-bit integer, FFFFFFFF is -1, +and 7FFFFFFF is the largest positive value. +64-bit integers are the same except with 16 hexadecimal digits. +

+ +

+Floating-point values are written in a correspondingly primitive form. +Values of the 64-bit double-precision format are represented by 16 +hexadecimal digits that give the raw bits of the floating-point encoding. +A period separates the 3rd and 4th hexadecimal digits to mark the division +between the exponent bits and fraction bits. +Some notable 64-bit double-precision values include: +

+     000.0000000000000    +0
+     3FF.0000000000000     1
+     400.0000000000000     2
+     7FF.0000000000000    +infinity
+
+     800.0000000000000    -0
+     BFF.0000000000000    -1
+     C00.0000000000000    -2
+     FFF.0000000000000    -infinity
+
+     3FE.FFFFFFFFFFFFF    largest representable number less than +1
+
+The following categories are easily distinguished (assuming the +xs are not all 0): +
+     000.xxxxxxxxxxxxx    positive subnormal (denormalized) numbers
+     7FF.xxxxxxxxxxxxx    positive NaNs
+     800.xxxxxxxxxxxxx    negative subnormal numbers
+     FFF.xxxxxxxxxxxxx    negative NaNs
+
+

+ +

+128-bit quadruple-precision values are written the same except +with 4 hexadecimal digits for the sign and exponent and 28 for the fraction. +Notable values include: +

+     0000.0000000000000000000000000000    +0
+     3FFF.0000000000000000000000000000     1
+     4000.0000000000000000000000000000     2
+     7FFF.0000000000000000000000000000    +infinity
+
+     8000.0000000000000000000000000000    -0
+     BFFF.0000000000000000000000000000    -1
+     C000.0000000000000000000000000000    -2
+     FFFF.0000000000000000000000000000    -infinity
+
+     3FFE.FFFFFFFFFFFFFFFFFFFFFFFFFFFF    largest representable number
+                                              less than +1
+
+

+ +

+80-bit double-extended-precision values are a little unusual in +that the leading bit of precision is not hidden as with other formats. +When correctly encoded, the leading significand bit of an 80-bit +double-extended-precision value will be 0 if the value is zero or subnormal, +and will be 1 otherwise. +Hence, the same values listed above appear in 80-bit +double-extended-precision as follows (note the leading 8 digit in +the significands): +

+     0000.0000000000000000    +0
+     3FFF.8000000000000000     1
+     4000.8000000000000000     2
+     7FFF.8000000000000000    +infinity
+
+     8000.0000000000000000    -0
+     BFFF.8000000000000000    -1
+     C000.8000000000000000    -2
+     FFFF.8000000000000000    -infinity
+
+     3FFE.FFFFFFFFFFFFFFFF    largest representable number less than +1
+
+

+ +

+The representation of 32-bit single-precision values is unusual +for a different reason. +Because the subfields of standard 32-bit single-precision do not +fall on neat 4-bit boundaries, single-precision outputs are +slightly perturbed. +These are written as 9 hexadecimal digits, with a period separating the 3rd and +4th hexadecimal digits. +Broken out into bits, the 9 hexademical digits cover the 32-bit +single-precision subfields as follows: +

+     x000 .... ....  .  .... .... .... .... .... ....    sign       (1 bit)
+     .... xxxx xxxx  .  .... .... .... .... .... ....    exponent   (8 bits)
+     .... .... ....  .  0xxx xxxx xxxx xxxx xxxx xxxx    fraction  (23 bits)
+
+As shown in this schematic, the first hexadecimal digit contains only the sign, +and will be either 0 or 8. +The next two digits give the biased exponent as an 8-bit integer. +This is followed by a period and 6 hexadecimal digits of fraction. +The most significant hexadecimal digit of the fraction can be at most +a 7. +

+ +

+Notable single-precision values include: +

+     000.000000    +0
+     07F.000000     1
+     080.000000     2
+     0FF.000000    +infinity
+
+     800.000000    -0
+     87F.000000    -1
+     880.000000    -2
+     8FF.000000    -infinity
+
+     07E.7FFFFF    largest representable number less than +1
+
+Again, certain categories are easily distinguished (assuming the +xs are not all 0): +
+     000.xxxxxx    positive subnormal (denormalized) numbers
+     0FF.xxxxxx    positive NaNs
+     800.xxxxxx    negative subnormal numbers
+     8FF.xxxxxx    negative NaNs
+
+

+ +

+Lastly, exception flag values are represented by five characters, one character +per flag. +Each flag is written as either a letter or a period (.) according +to whether the flag was set or not by the operation. +A period indicates the flag was not set. +The letter used to indicate a set flag depends on the flag: +

+     v    invalid exception
+     i    infinite exception ("divide by zero")
+     o    overflow exception
+     u    underflow exception
+     x    inexact exception
+
+For example, the notation ...ux indicates that the +underflow and inexact exception flags were set and that the other +three flags (invalid, infinite, and overflow) were not +set. +The exception flags are always written following the value returned as the +result of the operation. +

+ + +

8. Variations Allowed by the IEEE Floating-Point Standard

+ +

+The IEEE Floating-Point Standard admits some variation among conforming +implementations. +Because TestFloat expects the two implementations being compared to deliver +bit-for-bit identical results under most circumstances, this leeway in the +standard can result in false errors being reported if the two implementations +do not make the same choices everywhere the standard provides an option. +

+ +

8.1. Underflow

+ +

+The standard specifies that the underflow exception flag is to be raised +when two conditions are met simultaneously: +(1) tininess and (2) loss of accuracy. +

+ +

+A result is tiny when its magnitude is nonzero yet smaller than any normalized +floating-point number. +The standard allows tininess to be determined either before or after a result +is rounded to the destination precision. +If tininess is detected before rounding, some borderline cases will be flagged +as underflows even though the result after rounding actually lies within the +normal floating-point range. +By detecting tininess after rounding, a system can avoid some unnecessary +signaling of underflow. +All the TestFloat programs support options -tininessbefore and +-tininessafter to control whether TestFloat expects tininess on +underflow to be detected before or after rounding. +One or the other is selected as the default when TestFloat is compiled, but +these command options allow the default to be overridden. +

+ +

+Loss of accuracy occurs when the subnormal format is not sufficient to +represent an underflowed result accurately. +The original 1985 version of the IEEE Standard allowed loss of accuracy to be +detected either as an inexact result or as a +denormalization loss; +however, few if any systems ever chose the latter. +The latest standard requires that loss of accuracy be detected as an inexact +result, and TestFloat can test only for this case. +

+ +

8.2. NaNs

+ +

+The IEEE Standard gives the floating-point formats a large number of NaN +encodings and specifies that NaNs are to be returned as results under certain +conditions. +However, the standard allows an implementation almost complete freedom over +which NaN to return in each situation. +

+ +

+By default, TestFloat does not check the bit patterns of NaN results. +When the result of an operation should be a NaN, any NaN is considered as good +as another. +This laxness can be overridden with the -checkNaNs option of +programs testfloat_ver and testfloat. +In order for this option to be sensible, TestFloat must have been compiled so +that its internal floating-point implementation (SoftFloat) generates the +proper NaN results for the system being tested. +

+ +

8.3. Conversions to Integer

+ +

+Conversion of a floating-point value to an integer format will fail if the +source value is a NaN or if it is too large. +The IEEE Standard does not specify what value should be returned as the integer +result in these cases. +Moreover, according to the standard, the invalid exception can be raised +or an unspecified alternative mechanism may be used to signal such cases. +

+ +

+TestFloat assumes that conversions to integer will raise the invalid +exception if the source value cannot be rounded to a representable integer. +In such cases, TestFloat expects the result value to be the largest-magnitude +positive or negative integer as detailed earlier in section 6.1, +Conversion Operations. +The current version of TestFloat provides no means to alter these expectations. +

+ + +

9. Contact Information

+ +

+At the time of this writing, the most up-to-date information about TestFloat +and the latest release can be found at the Web page +http://www.jhauser.us/arithmetic/TestFloat.html. +

+ + + + diff --git a/doc/TestFloat-history.html b/doc/TestFloat-history.html new file mode 100644 index 0000000..daed701 --- /dev/null +++ b/doc/TestFloat-history.html @@ -0,0 +1,156 @@ + + + + +Berkeley TestFloat History + + + + +

History of Berkeley TestFloat, to Release 3

+ +

+John R. Hauser
+2014 _____
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +

+ +

+Releases of Berkeley TestFloat parallel those of Berkeley SoftFloat, on which +TestFloat is based. +Each TestFloat release necessarily incorporates all bug fixes from the +corresponding release of SoftFloat. +

+ + +

Release 3 (2014 December)

+ + + + +

Release 2c (2014 December)

+ + + + +

+There was never a Release 2b. +

+ + +

Release 2a (1998 December)

+ + + + +

Release 2 (1997 June)

+ + + + +

Release 1a (1996 July)

+ + + + +

Release 1 (1996 July)

+ + + + + + diff --git a/doc/TestFloat-source.html b/doc/TestFloat-source.html new file mode 100644 index 0000000..a875479 --- /dev/null +++ b/doc/TestFloat-source.html @@ -0,0 +1,546 @@ + + + + +Berkeley TestFloat Source Documentation + + + + +

Berkeley TestFloat Release 3: Source Documentation

+ +

+John R. Hauser
+2014 _____
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +

+ + +

Contents

+ +

+*** CHECK.
+*** FIX FORMATTING. +

+ +
+1. Introduction
+2. Limitations
+3. Acknowledgments and License
+4. TestFloat Package Directory Structure
+5. Dependence on Berkeley SoftFloat
+6. Issues for Porting TestFloat to a New Target
+    6.1. Standard Headers <stdbool.h> and <stdint.h>
+    6.2. Standard Header <fenv.h>
+    6.3. Macros for Build Options
+    6.4. Specializing the testfloat Program
+    6.5. Improving the Random Number Functions
+7. Contact Information
+
+ + +

1. Introduction

+ +

+This document gives information needed for compiling and/or porting Berkeley +TestFloat, a small collection of programs for testing that an implementation of +binary floating-point conforms to the IEEE Standard for Floating-Point +Arithmetic. +For basic documentation about TestFloat refer to +TestFloat-general.html. +

+ +

+The source code for TestFloat is intended to be relatively machine-independent. +Most programs in the TestFloat package should be compilable with any +ISO-standard C compiler that also supports 64-bit integers. +If the all-in-one testfloat program will be used to test a new +floating-point implementation, additional effort will likely be required to +retarget that program to invoke the new floating-point operations. +TestFloat has been successfully compiled with the GNU C Compiler +(gcc) for several platforms. +

+ +

+Release 3 of TestFloat is a complete rewrite relative to +Release 2 or earlier. +

+ +

+TestFloat depends on Berkeley SoftFloat, which is a software implementation of +binary floating-point that conforms to the IEEE Standard for Floating-Point +Arithmetic. +SoftFloat is not included with the TestFloat sources. +It can be obtained from the Web page +http://www.jhauser.us/arithmetic/SoftFloat.html. +

+ + +

2. Limitations

+ +

+TestFloat assumes the computer has an addressable byte size of either 8 or +16 bits. +(Nearly all computers in use today have 8-bit bytes.) +

+ +

+TestFloat is written entirely in C. +The C compiler used must conform at a minimum to the 1989 ANSI standard for the +C language (same as the 1990 ISO standard) and must in addition support basic +arithmetic on 64-bit integers. +Earlier releases of TestFloat were capable of testing 32-bit +single-precision and 64-bit double-precision floating-point +without requiring compiler support for 64-bit integers, but this +option is not supported with Release 3. +Since 1999, ISO standards for C have mandated compiler support for +64-bit integers. +A compiler conforming to the 1999 C Standard or later is recommended but not +strictly required. +

+ +

+C Standard header files <stdbool.h> and +<stdint.h> are required for defining standard Boolean and +integer types. +If these headers are not supplied with the C compiler, minimal substitutes must +be provided. +TestFloat's dependence on these headers is detailed later in +section 6.1, Standard Headers <stdbool.h> +and <stdint.h>. +

+ + +

3. Acknowledgments and License

+ +

+The TestFloat package was written by me, John R. Hauser. +Release 3 of TestFloat is a completely new implementation +supplanting earlier releases. +This project was done in the employ of the University of California, Berkeley, +within the Department of Electrical Engineering and Computer Sciences, first +for the Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab. +The work was officially overseen by Prof. Krste Asanovic, with funding provided +by these sources: +

+ + + + + + + + + +
Par Lab: +Microsoft (Award #024263), Intel (Award #024894), and U.C. Discovery +(Award #DIG07-10227), with additional support from Par Lab affiliates Nokia, +NVIDIA, Oracle, and Samsung. +
ASPIRE Lab: +DARPA PERFECT program (Award #HR0011-12-2-0016), with additional support from +ASPIRE industrial sponsor Intel and ASPIRE affiliates Google, Nokia, NVIDIA, +Oracle, and Samsung. +
+
+

+ +

+The following applies to the whole of TestFloat Release 3 as well +as to each source file individually. +

+ +

+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). +All Rights Reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +

+ +

+Redistributions of source code must retain the above copyright notice, this +list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. +Neither the name of the Regents nor the names of its contributors may be used +to endorse or promote products derived from this software without specific +prior written permission. +

+ +

+IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, +INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF +THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +

+ +

+REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". +REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, +ENHANCEMENTS, OR MODIFICATIONS. +

+ + +

4. TestFloat Package Directory Structure

+ +

+Because TestFloat is targeted to multiple platforms, its source code is +slightly scattered between target-specific and target-independent directories +and files. +The supplied directory structure is as follows: +

+     doc
+     source
+         subj-C
+     build
+         template
+         Win32-MinGW
+         Linux-386-GCC
+
+The majority of the TestFloat sources are provided in the source +directory. +The subj-C subdirectory contains the sources that +configure the all-in-one testfloat program to test the C +compiler's implementation of the standard C types float, +double, and possibly long double. +The `subj' in subj-C is an abbreviation +of subject, referring to the floating-point that is the subject of the +test. +If testfloat is retargeted to test other floating-point +implementations, the corresponding source files would be expected to be in +other subdirectories alongside subj-C, with names of +the form subj-<target>. +More about retargeting testfloat is found in +section 6.4, Specializing the testfloat +Program. +

+ +

+The build directory is intended to contain a subdirectory for each +target platform for which builds of the TestFloat programs may be created. +For each build target, the target's subdirectory is where all derived object +files and the completed TestFloat executables are created. +The template subdirectory is not an actual build target but +contains sample files for creating new target directories. +

+ +

+Ignoring the template directory, the supplied target directories +are intended to follow a naming system of +<execution-environment>-<compiler>. +For the example targets, +<execution-environment> is Win32 +and Linux-386, and <compiler> is +MinGW and GCC, respectively. +

+ +

+As supplied, each target directory contains two files: +

+     Makefile
+     platform.h
+
+The provided Makefile is written for GNU make. +A build of TestFloat for the specific target is begun by executing the +make command with the target directory as the current directory. +A completely different build tool can be used if an appropriate +Makefile equivalent is created. +

+ +

+The platform.h header file exists to provide a location for +additional C declarations specific to the build target. +Every C source file of TestFloat contains a #include for +platform.h. +In many cases, the contents of platform.h can be as simple as one +or two lines of code. +If the target's compiler or library has bugs or other shortcomings, workarounds +for these issues may be possible with target-specific declarations in +platform.h, without the need to modify the main TestFloat sources. +

+ +

+It may not be necessary to build all of the TestFloat programs. +For testing a floating-point implementation, typically +testfloat_gen and testfloat will not both be used, +and testfloat_ver may not be needed either. +The Makefile (or equivalent) can be modified not to create unneeded programs. +This may be especially relevant for the all-in-one test program +testfloat, which might not build without special attention. +

+ + +

5. Dependence on Berkeley SoftFloat

+ +

+In addition to the distributed sources, TestFloat depends on the existence of a +compatible Berkeley SoftFloat library and the corresponding header file +softfloat.h. +As mentioned earlier, SoftFloat is a separate package available at Web page +http://www.jhauser.us/arithmetic/SoftFloat.html. +The SoftFloat library must be compiled before the TestFloat programs can be +built. +In the example Makefiles, the locations of the SoftFloat header files and +pre-compiled library are specified by these macros: +

+
+
SOFTFLOAT_INCLUDE_DIR +
+The path of the directory containing softfloat.h, as well as other +nonstandard header files referenced by softfloat.h, if any. +
SOFTFLOAT_H +
+A list of the full paths of all SoftFloat header files needed by SoftFloat +clients. This list must include softfloat.h and may also include +other header files referenced by softfloat.h, such as +softfloat_types.h. +This macro is used only to establish build dependencies between the SoftFloat +header files and TestFloat's source files, in case the SoftFloat header files +are changed. +
SOFTFLOAT_LIB +
+The full path of the compiled SoftFloat library (usually +softfloat.a). +
+
+

+ + +

6. Issues for Porting TestFloat to a New Target

+ +

6.1. Standard Headers <stdbool.h> and <stdint.h>

+ +

+The TestFloat sources make use of standard headers +<stdbool.h> and <stdint.h>, which have +been part of the ISO C Standard Library since 1999. +With any recent compiler, these standard headers are likely to be supported, +even if the compiler does not claim complete conformance to the latest ISO C +Standard. +For older or nonstandard compilers, substitutes for +<stdbool.h> and <stdint.h> may need to be +created. +TestFloat depends on these names from <stdbool.h>: +

+     bool
+     true
+     false
+
+and on these names from <stdint.h>: +
+     uint16_t
+     uint32_t
+     uint64_t
+     int32_t
+     int64_t
+     UINT64_C
+     INT64_C
+     uint_least8_t
+     uint_fast8_t
+     uint_fast16_t
+     uint_fast32_t
+     uint_fast64_t
+     int_fast16_t
+     int_fast32_t
+     int_fast64_t
+
+

+ + +

6.2. Standard Header <fenv.h>

+ +

+Because the supplied all-in-one testfloat program tests the +floating-point operations of the C language, it uses the facilities provided by +standard C header <fenv.h> to access the floating-point +environment of C, in particular to set the rounding mode and to access the +floating-point exception flags. +Like <stdbool.h> and <stdint.h>, +<fenv.h> has been part of the ISO C Standard Library since +1999, but older or nonstandard C compilers may not support it. +

+ +

+Some form of standard header <fenv.h> is needed only if the +testfloat program is wanted and the program will not be +retargeted to invoke a floating-point implementation in a way that bypasses the +standard C environment. +Typically, if testfloat is wanted, it will be retargeted to invoke +a new floating-point implementation directly, making +<fenv.h> irrelevant. +For more about retargeting testfloat, see section 6.4 +below, Specializing the testfloat Program. +

+ + +

6.3. Macros for Build Options

+ +

+The TestFloat source files are affected by a few C preprocessor macros: +

+
+
LITTLEENDIAN +
+Must be defined for little-endian machines; +must not be defined for big-endian machines. +
EXTFLOAT80 +
+Must be defined if the TestFloat programs are to support the +80-bit double-extended-precision floating-point format. +
FLOAT128 +
+Must be defined if the TestFloat programs are to support the +128-bit quadruple-precision floating-point format. +
+
+Following the usual custom for C, the content of a macro's +definition is irrelevant; +what matters is a macro's effect on #ifdef directives. +

+ +

+It is recommended that any definition of macro LITTLEENDIAN be +made in a build target's platform.h header file, because +endianness is expected to be determined inflexibly by the target machine. +On the other hand, the EXTFLOAT80 and FLOAT128 macros +are not dictated by the target and hence might be better located in the +target's Makefile (or its equivalent). +

+ + +

6.4. Specializing the testfloat Program

+ +

+The supplied sources for the all-in-one testfloat program cause +testfloat to test the C compiler's float and +double types for C operations +, -, +*, /, etc. +The supplied version is also capable of testing C type long +double if the sources are compiled with one of these macros +defined: +

+
+
LONG_DOUBLE_IS_EXTFLOAT80 +
+Indicates that type long double is +80-bit double-extended-precision floating-point. +
LONG_DOUBLE_IS_FLOAT128 +
+Indicates that type long double is +128-bit quadruple-precision floating-point. +
+
+By default, testfloat assumes that only the IEEE Standard's +original four rounding modes (near_even, minMag, +min, and max) are supported by the floating-point +being tested. +If the fifth rounding mode, near_maxMag, is also supported, an +additional macro can be defined: +
+
+
SUBJFLOAT_ROUND_NEAR_MAXMAG +
+Indicates that the subject floating-point supports rounding mode +near_maxMag (nearest/away). +
+
+

+ +

+To test a new and/or different implementation of floating-point, +testfloat must normally be retargeted to invoke this other +floating-point instead of C's floating-point. +Two source files define the functions that testfloat uses to +invoke floating-point operations for testing: +

+     subjfloat_config.h
+     subjfloat.c
+
+For the default target of testing C's floating-point, these files are contained +in directory source/subj-C as discussed earlier. +For a different subject floating-point, it is recommended that appropriate +versions of subjfloat_config.h and subjfloat.c be +stored in a sibling subj-<target> directory, +where <target> names the particular target. +

+ +

+Header file subjfloat_config.h defines a macro of the form +SUBJ_* for each subject function supported. +For example, if function subj_f32_add exists to perform +32-bit floating-point addition, then +subjfloat_config.h should have a definition for macro +SUBJ_F32_ADD. +The actual function subj_f32_add is expected to be defined in +subjfloat.c, along with all other subject functions. +A common header file, subjfloat.h, (not target-specific) provides +prototype declarations for all possible subject functions that +testfloat may be compiled to test, whether actually existing or +not. +(There is no penalty for the header to declare prototypes of nonexistent +functions that are never called.) +For a specific build of testfloat, the -list option +will list all subject functions that the testfloat program is able +to invoke and thus test. +

+ +

+In the source code as supplied, macros LONG_DOUBLE_IS_EXTFLOAT80 +and LONG_DOUBLE_IS_FLOAT128 affect only the target-specific source +files in source/subj-C, so these macros can be +ignored for any other subject floating-point that does not depend on them. +On the other hand, macro SUBJFLOAT_ROUND_NEAR_MAXMAG always +determines whether the testfloat program attempts to test rounding +mode near_maxMag, regardless of the subject floating-point. +

+ + +

6.5. Improving the Random Number Functions

+ +

+If you are serious about using TestFloat for testing floating-point, you should +consider replacing the random number functions in random.c. +The supplied random number functions are built on top of the standard C +rand function. +Because function rand is rather poor on some systems, the +functions in random.c assume very little about the quality of +rand. +As a result, rand is called more frequently than it might need to +be, shortening the time before random number sequences repeat, and possibly +wasting time as well. +If rand is better on a given target platform, or if another, +better random number generator is available (such as rand48 on +most UNIX-derived systems), TestFloat can be improved by overriding the given +random.c with a target-specific one. +

+ +

+Rather than modifying the supplied file random.c, it is +recommended instead that a new, alternate file be created and the target's +Makefile be modified to refer to that alternate file in place of +random.c. +

+ + +

7. Contact Information

+ +

+At the time of this writing, the most up-to-date information about TestFloat +and the latest release can be found at the Web page +http://www.jhauser.us/arithmetic/TestFloat.html. +

+ + + + diff --git a/doc/testfloat.html b/doc/testfloat.html new file mode 100644 index 0000000..7779214 --- /dev/null +++ b/doc/testfloat.html @@ -0,0 +1,259 @@ + + + + +testfloat + + + + +

Berkeley TestFloat Release 3: testfloat

+ +

+John R. Hauser
+2014 ______
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +
+*** REPLACE APOSTROPHES. +
+*** REPLACE EM DASH. +

+ + +

Overview

+ +

+The testfloat program tests an implementation of floating-point +arithmetic for conformity to the IEEE Standard for Binary Floating-Point +Arithmetic. +testfloat is part of the Berkeley TestFloat package, a small +collection of programs for performing such tests. +For general information about TestFloat, see file +TestFloat-general.html. +

+ +

+The testfloat program is an all-in-one tool for testing +floating-point arithmetic. +It generates test operand values, invokes a floating-point operation with the +generated operands, and examines the corresponding computed results, reporting +unexpected results as likely errors. +While the processes of generating inputs and examining results are generic, a +particular build of testfloat is limited to testing only the one +implementation of floating-point it has been compiled to invoke. +For example, while one instance of testfloat might be compiled to +execute a computer's hardware instruction for floating-point addition, a +different version might be compiled to call a subroutine called +myAddFloat that is linked into the testfloat program. +To test a new implementation of floating-point (a new set of machine +instructions or a new set of subroutines), a new testfloat must be +compiled containing the code needed to invoke the new floating-point. +

+ +

+The default build of testfloat assumes that C types +float and double are 32-bit and +64-bit binary floating-point types conforming to the IEEE +Standard, and tests the C operations of +, -, +*, /, type conversions, etc. +This tests the floating-point arithmetic seen by C programs. +Depending on the compiler and the options selected during compilation, this may +or may not be the same as the computer's floating-point hardware, if any. +

+ +

+The testfloat program will ordinarily test an operation for all +rounding modes defined by the IEEE Floating-Point Standard, one after the +other. +If the rounding mode is not supposed to have any affect on the results--for +instance, some operations do not require rounding--only the nearest/even +rounding mode is checked. +For double-extended-precision operations affected by rounding precision +control, testfloat also tests all three rounding precision modes, +one after the other. +Testing can be limited to a single rounding mode and/or rounding precision with +appropriate command-line options. +

+ +

+For more about the operation of testfloat and how to interpret its +output, refer to +TestFloat-general.html. +

+ + +

Command Syntax

+ +

+The testfloat program is executed as a command with this syntax: +

+     testfloat [<option>...] <function>
+
+Square brackets ([ ]) denote optional arguments, +<option> is a supported option, and +<function> is the name of either a testable operation or a +function set. +The available options and function sets are documented below. +The -list option can be used to obtain a list of all testable +operations for a given build of testfloat. +If testfloat is executed without any arguments, a summary of usage +is written. +

+ + +

Options

+ +

+The testfloat program accepts several command options. +If mutually contradictory options are given, the last one has priority. +

+ +

-help

+ +

+The -help option causes a summary of program usage to be written, +after which the program exits. +

+ +

-list

+ +

+The -list option causes a list of testable operations to be +written, after which the program exits. +The set of testable operations is just the set of operations that this build of +testfloat has some way to invoke for testing. +

+ +

-level <num>

+ +

+The -level option sets the level of testing. +The argument to -level can be either 1 or 2. +The default is level 1. +Level 2 performs many more tests than level 1 and thus can reveal +bugs not found by level 1. +

+ +

-errors <num>

+ +

+The -errors option instructs testfloat to report no +more than the specified number of errors for any combination of operation, +rounding mode, etc. +The argument to -errors must be a nonnegative decimal integer. +Once the specified number of error reports has been generated, +testfloat ends the current test and begins the next one, if any. +The default is -errors 20. +

+ +

+Against intuition, -errors 0 causes +testfloat to report every error it finds. +

+ +

-errorstop

+ +

+The -errorstop option causes the program to exit after the first +operation for which any errors are reported. +

+ +

-forever

+ +

+The -forever option causes a single operation to be repeatedly +tested. +Only one rounding mode and/or rounding precision can be tested in a single +execution. +If not specified, the rounding mode defaults to nearest/even. +For 80-bit double-extended-precision operations, the rounding +precision defaults to full double-extended precision. +The testing level is set to 2 by this option. +

+ +

-checkNaNs

+ +

+The -checkNaNs option causes testfloat to verify the +bitwise correctness of NaN results. +In order for this option to be sensible, testfloat must have been +compiled so that its internal reference implementation of floating-point +(SoftFloat) generates the proper NaN results for the system being tested. +

+ +

-precision32, -precision64, -precision80

+ +

+For 80-bit double-extended-precision operations affected by +rounding precision control, the -precision32 option restricts +testing to only the cases in which the rounding precision is +32 bits, equivalent to 32-bit single-precision. +The other rounding precision choices are not tested. +Likewise, -precision64 fixes the rounding precision to +64 bits, equivalent to 64-bit double-precision, and +-precision80 fixes the rounding precision to the full +80 bits of the double-extended-precision format. +All these options are ignored for operations not affected by rounding precision +control. +

+ +

+The precision-control options may not be accepted at all if no +double-extended-precision operations are testable. +

+ +

-rnear_even, -rnear_maxMag, -rminMag, -rmin, -rmax

+ +

+The -rnear_even option restricts testing to only the cases in +which the rounding mode is nearest/even. +The other rounding mode choices are not tested. +Likewise, -rnear_maxMag forces rounding to nearest/maximum +magnitude (nearest-away), -rminMag forces rounding to minimum +magnitude (toward zero), -rmin forces rounding to minimum (down, +toward negative infinity), and -rmax forces rounding to maximum +(up, toward positive infinity). +These options are ignored for operations that are exact and thus do not round. +

+ +

-tininessbefore, -tininessafter

+ +

+The -tininessbefore option indicates that the floating-point +implementation being tested detects tininess on underflow before rounding. +The -tininessafter option indicates that tininess is detected +after rounding. +The testfloat program alters its expectations accordingly. +These options override the default selected when testfloat was +compiled. +Choosing the wrong one of these two options should cause error reports for some +(but not all) operations. +

+ + +

Function Sets

+ +

+Just as testfloat can test an operation for all five rounding +modes in sequence, multiple operations can be tested with a single execution of +testfloat. +Two sets are recognized: -all1 and -all2. +The set -all1 comprises all one-operand operations, while +-all2 is all two-operand operations. +A function set is used in place of an operation name in the +testfloat command line, such as +

+     testfloat [<option>...] -all1
+
+

+ + + + diff --git a/doc/testfloat_gen.html b/doc/testfloat_gen.html new file mode 100644 index 0000000..43e6d20 --- /dev/null +++ b/doc/testfloat_gen.html @@ -0,0 +1,341 @@ + + + + +testfloat_gen + + + + +

Berkeley TestFloat Release 3: testfloat_gen

+ +

+John R. Hauser
+2014 ______
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +
+*** REPLACE APOSTROPHES. +
+*** REPLACE EM DASH. +

+ + +

Overview

+ +

+The testfloat_gen program generates test cases for testing that an +implementation of floating-point arithmetic conforms to the IEEE Standard for +Binary Floating-Point Arithmetic. +testfloat_gen is part of the Berkeley TestFloat package, a small +collection of programs for performing such tests. +For general information about TestFloat, see file +TestFloat-general.html. +

+ +

+A single execution of testfloat_gen generates test cases for only +a single floating-point operation and associated options. +The testfloat_gen program must be repeatedly executed to generate +test cases for each operation to be tested. +

+ +

+testfloat_gen writes the test cases it generates to standard +output. +This output can either be captured in a file through redirection, or be piped +to another program that exercises a floating-point operation using the test +cases as they are supplied. +Depending on use, the total output from testfloat_gen can be +large, so piping to another program may be the best choice to avoid consuming +inordinate file space. +The format of testfloat_gen's output is raw hexadecimal text, +described in the section below titled Output Format. +

+ + +

Command Syntax

+ +

+The testfloat_gen program is executed as a command in one of these +forms: +

+     testfloat_gen [<option>...] <type>
+     testfloat_gen [<option>...] <function>
+
+Square brackets ([ ]) denote optional arguments, and +<option> is a supported option, documented below. +A testfloat_gen command expects either a <type> +specifying the type and number of output or a <function> +naming a floating-point operation. +If testfloat_gen is executed without any arguments, a summary of +usage is written. +

+ +

+A <type> can be one of the following: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ui32unsigned 32-bit integers
ui64unsigned 64-bit integers
i32signed 32-bit integers
i64signed 64-bit integers
f32 [<num>]one or more 32-bit single-precision floating-point values
f64 [<num>]one or more 64-bit double-precision floating-point values
extF80 [<num>]   one or more 80-bit double-extended-precision floating-point +values
f128 [<num>]one or more 128-bit quadruple-precision floating-point +values
+
+Optional <num> is one of 1, 2, or 3. +If a <type> is given without <num> (such +as ui32 or f64), testfloat_gen outputs a +list of values of the specified type, one value per line, appropriate for +testing a floating-point operation with exactly one operand of the given type. +If a floating-point type and number are given (such as +f32 2 or +extF80 1), testfloat_gen +outputs the specified number of values per line, appropriate for testing a +floating-point operation with that number of operands. +Although the exact operation being tested is not specified, the test cases +output by testfloat_gen cover all standard floating-point +operations, to the degree explained in +TestFloat-general.html. +

+ +

+If a <function> operation name is given, then each line of +output from testfloat_gen contains not only the operands for that +operation (as would be generated by an appropriate <type> +argument) but also the expected results as determined by +testfloat_gen's internal floating-point emulation (SoftFloat). +The available operation names are listed in +TestFloat-general.html. +In all cases, floating-point operations have two results: +first, a value, which may be floating-point, integer, or Boolean, and, second, +the floating-point exception flags raised by the operation. +If the output from a tested floating-point operation does not match the +expected output specified by testfloat_gen, this may or may not +indicate an error in the floating-point operation. +For further explanation, see +TestFloat-general.html, +especially the section titled Variations Allowed by the IEEE Floating-Point +Standard. +

+ + +

Options

+ +

+The testfloat_gen program accepts several command options. +If mutually contradictory options are given, the last one has priority. +

+ +

-help

+ +

+The -help option causes a summary of program usage to be written, +after which the program exits. +

+ +

-prefix <text>

+ +

+The -prefix option causes testfloat_gen to write the +supplied text argument verbatim as the first line of output before any test +cases. +This can be used, for example, to indicate to a downstream program what kind of +test to perform for the test cases that follow. +

+ +

-level <num>

+ +

+The -level option sets the level of testing. +The argument to -level can be either 1 or 2. +The default is level 1. +Level 2 causes many more test cases to be generated, with better +coverage, than level 1. +

+ +

-n <num>

+ +

+Option -n specifies the number of test cases to generate. +For each <type> or <function> and each +testing level (set by -level), there is a minimum value that +testfloat_gen will accept for <num>. +If no -n option is given, the number of test cases generated by +testfloat_gen equals the minimum value acceptable for the +-n argument. +Option -n cannot be used to reduce this number, but can increase +it, without changing the testing level. +

+ +

-forever

+ +

+The -forever option causes test cases to be generated +indefinitely, without limit (until the program is terminated by some external +cause). +The testing level is set to 2 by this option. +

+ +

-precision32, -precision64, -precision80

+ +

+When a <function> is specified that is an +80-bit double-extended-precision operation affected by rounding +precision control, the -precision32 option sets the rounding +precision to 32 bits, equivalent to 32-bit +single-precision. +Likewise, -precision64 sets the rounding precision to +64 bits, equivalent to 64-bit double-precision, and +-precision80 sets the rounding precision to the full +80 bits of the double-extended-precision format. +All these options are ignored for operations not affected by rounding precision +control. +When rounding precision is applicable but not specified, the default is the +full 80 bits, same as -precision80. +

+ +

-rnear_even, -rnear_maxMag, -rminMag, -rmin, -rmax

+ +

+When a <function> is specified that requires rounding, the +-rnear_even option sets the rounding mode to nearest/even; +-rnear_maxMag sets rounding to nearest/maximum magnitude +(nearest-away); +-rminMag sets rounding to minimum magnitude (toward zero); +-rmin sets rounding to minimum (down, toward negative infinity); +and -rmax sets rounding to maximum (up, toward positive infinity). +These options are ignored for operations that are exact and thus do not round. +When rounding mode is relevant but not specified, the default is to round to +nearest/even, same as -rnear_even. +

+ +

-tininessbefore, -tininessafter

+ +

+When a <function> is specified that requires rounding, the +-tininessbefore option indicates that tininess on underflow will +be detected before rounding, while -tininessafter indicates that +tininess on underflow will be detected after rounding. +These options are ignored for operations that are exact and thus do not round. +When the method of tininess detection matters but is not specified, the default +is to detect tininess on underflow before rounding, same as +-tininessbefore. +

+ +

-notexact, -exact

+ +

+When a <function> is specified that rounds to an integer +(either conversion to an integer type or a roundToInt operation), +the -notexact option indicates that the inexact exception +flag is never raised, while -exact indicates that the +inexact exception flag is to be raised if the result is inexact. +For other operations, these options are ignored. +If neither option is specified, the default is not to raise the inexact +exception flag when rounding to an integer, same as -notexact. +

+ + +

Output Format

+ +

+For each test case generated, testfloat_gen writes a single line +of text to standard output. +When the testfloat_gen command is given a +<type> argument, each test case consists of either one +integer value or one, two, or three floating-point values. +Each value is written to output as a raw hexadecimal number. +When there is more than one value per line, they are separated by spaces. +For example, output from executing +

+     testfloat_gen f64 2
+
+might look like this: +
+     3F90EB5825D6851E C3E0080080000000
+     41E3C00000000000 C182024F8AE474A8
+     7FD80FFFFFFFFFFF 7FEFFFFFFFFFFF80
+     3FFFED6A25C534BE 3CA1000000020000
+     ...
+
+with each hexadecimal number being one 64-bit floating-point +value. +Note that, for floating-point values, the sign and exponent are at the +most-significant end of the number. +Thus, for the first number on the first line above, the leading hexadecimal +digits 3F9 are the sign and encoded exponent of the +64-bit floating-point value, and the remaining digits are the +encoded significand. +

+ +

+When testfloat_gen is given a <function> +operation name, each line of output has not only the operands for the operation +but also the expected output, consisting of a result value and the exception +flags that are raised. +For example, the output from +

+     testfloat_gen f64_add
+
+could include these lines: +
+     3F90EB5825D6851E C3E0080080000000 C3E0080080000000 01
+     41E3C00000000000 C182024F8AE474A8 41E377F6C1D46E2D 01
+     7FD80FFFFFFFFFFF 7FEFFFFFFFFFFF80 7FF0000000000000 05
+     3FFFED6A25C534BE 3CA1000000020000 3FFFED6A25C534BF 01
+     ...
+
+On each line, the first two numbers are the operands for the floating-point +addition, and the third and fourth numbers are the expected floating-point +result (the sum) and the exception flags raised. +Exception flags are encoded with one bit per flag as follows: +
+ + + + + + +
bit 0   inexact exception
bit 1 underflow exception
bit 2 overflow exception
bit 3 infinite exception ("divide by zero")
bit 4 invalid exception
+
+

+ + + + diff --git a/doc/testfloat_ver.html b/doc/testfloat_ver.html new file mode 100644 index 0000000..4d1540e --- /dev/null +++ b/doc/testfloat_ver.html @@ -0,0 +1,250 @@ + + + + +testfloat_ver + + + + +

Berkeley TestFloat Release 3: testfloat_ver

+ +

+John R. Hauser
+2014 ______
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +
+*** REPLACE APOSTROPHES. +
+*** REPLACE EM DASH. +

+ + +

Overview

+ +

+The testfloat_ver program takes test-case results obtained from +exercising an implementation of floating-point arithmetic and verifies that +those results conform to the IEEE Standard for Binary Floating-Point +Arithmetic. +testfloat_ver is part of the Berkeley TestFloat package, a small +collection of programs for performing such tests. +For general information about TestFloat, see file +TestFloat-general.html. +

+ +

+A single execution of testfloat_ver verifies results for only a +single floating-point operation and associated options. +The testfloat_ver program must be repeatedly executed to verify +results for each operation to be tested. +

+ +

+The test cases to be verified are read by testfloat_ver from +standard input. +This input will typically be piped from another program that, for each test +case, invokes the floating-point operation and writes out the results. +The format of testfloat_ver's input is raw hexadecimal text, +described in the section below titled Input Format. +

+ +

+For each test case given to it, testfloat_ver examines the +computed results and reports any unexpected results as likely errors. + +For more about the operation of testfloat_ver and how to interpret +its output, refer to +TestFloat-general.html. +

+ + +

Command Syntax

+ +

+The testfloat_ver program is executed as a command with this +syntax: +

+     testfloat_ver [<option>...] <function>
+
+Square brackets ([ ]) denote optional arguments, +<option> is a supported option, and +<function> is the name of a testable operation. +The available options are documented below. +The testable operation names are listed in +TestFloat-general.html. +If testfloat_ver is executed without any arguments, a summary of +usage is written. +

+ + +

Options

+ +

+The testfloat_ver program accepts several command options. +If mutually contradictory options are given, the last one has priority. +

+ +

-help

+ +

+The -help option causes a summary of program usage to be written, +after which the program exits. +

+ +

-errors <num>

+ +

+The -errors option instructs testfloat_ver to report +no more than the specified number of errors. +The argument to -errors must be a nonnegative decimal integer. +Once the specified number of error reports has been generated, the program +exits. +The default is -errors 20. +

+ +

+Against intuition, -errors 0 causes +testfloat_ver to continue for any number of errors. +

+ +

-checkNaNs

+ +

+The -checkNaNs option causes testfloat_ver to verify +the bitwise correctness of NaN results. +In order for this option to be sensible, testfloat_ver must have +been compiled so that its internal reference implementation of floating-point +(SoftFloat) generates the proper NaN results for the system being tested. +

+ +

-precision32, -precision64, -precision80

+ +

+When <function> is an 80-bit +double-extended-precision operation affected by rounding precision control, the +-precision32 option indicates that the rounding precision should +be 32 bits, equivalent to 32-bit single-precision. +Likewise, -precision64 indicates that the rounding precision +should be 64 bits, equivalent to 64-bit +double-precision, and -precision80 indicates that the rounding +precision should be the full 80 bits of the +double-extended-precision format. +All these options are ignored for operations not affected by rounding precision +control. +When rounding precision is applicable but not specified, the default assumption +is the full 80 bits, same as -precision80. +

+ +

-rnear_even, -rnear_maxMag, -rminMag, -rmin, -rmax

+ +

+When <function> is an operation that requires rounding, the +-rnear_even option indicates that rounding should be to +nearest/even, -rnear_maxMag indicates rounding to nearest/maximum +magnitude (nearest-away), -rminMag indicates rounding to minimum +magnitude (toward zero), -rmin indicates rounding to minimum +(down, toward negative infinity), and -rmax indicates rounding to +maximum (up, toward positive infinity). +These options are ignored for operations that are exact and thus do not round. +When rounding mode is relevant but not specified, the default assumption is +rounding to nearest/even, same as -rnear_even. +

+ +

-tininessbefore, -tininessafter

+ +

+When <function> is an operation that requires rounding, the +-tininessbefore option indicates that tininess on underflow should +be detected before rounding, while -tininessafter indicates that +tininess on underflow should be detected after rounding. +These options are ignored for operations that are exact and thus do not round. +When the method of tininess detection matters but is not specified, the default +assumption is that tininess should be detected before rounding, same as +-tininessbefore. +

+ +

-notexact, -exact

+ +

+When <function> is an operation that rounds to an integer +(either conversion to an integer type or a roundToInt operation), +the -notexact option indicates that the inexact exception +flag should never be raised, while -exact indicates that the +inexact exception flag should be raised when the result is inexact. +For other operations, these options are ignored. +If neither option is specified, the default assumption is that the +inexact exception flag should not be raised when rounding to an integer, +same as -notexact. +

+ + +

Input Format

+ +

+For a given <function> argument, the input format expected +by testfloat_ver is the same as the output generated by program +testfloat_gen for +the same argument. +

+ +

+Input to testfloat_ver is expected to be text, with each line +containing the data for one test case. +The number of input lines thus equals the number of test cases. +A single test case is organized as follows: first are the operands for the +operation, next is the result value obtained, and last is a number indicating +the exception flags that were raised. +These values are all expected to be provided as raw hexadecimal numbers +separated on the line by spaces. +For example, for the command +

+     testfloat_ver f64_add
+
+valid input could include these lines: +
+     3F90EB5825D6851E C3E0080080000000 C3E0080080000000 01
+     41E3C00000000000 C182024F8AE474A8 41E377F6C1D46E2D 01
+     7FD80FFFFFFFFFFF 7FEFFFFFFFFFFF80 7FF0000000000000 05
+     3FFFED6A25C534BE 3CA1000000020000 3FFFED6A25C534BF 01
+     ...
+
+On each line above, the first two hexadecimal numbers represent the +64-bit floating-point operands, the third hexadecimal number is +the 64-bit floating-point result of the operation (the sum), and +the last hexadecimal number gives the exception flags that were raised by the +operation. +

+ +

+Note that, for floating-point values, the sign and exponent are at the +most-significant end of the number. +Thus, for the first number on the first line above, the leading hexadecimal +digits 3F9 are the sign and encoded exponent of the +64-bit floating-point value, and the remaining digits are the +encoded significand. +

+ +

+Exception flags are encoded with one bit per flag as follows: +

+ + + + + + +
bit 0   inexact exception
bit 1 underflow exception
bit 2 overflow exception
bit 3 infinite exception ("divide by zero")
bit 4 invalid exception
+
+

+ + + + diff --git a/doc/testsoftfloat.html b/doc/testsoftfloat.html new file mode 100644 index 0000000..49215de --- /dev/null +++ b/doc/testsoftfloat.html @@ -0,0 +1,229 @@ + + + + +testsoftfloat + + + + +

Berkeley TestFloat Release 3: testsoftfloat

+ +

+John R. Hauser
+2014 ______
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +
+*** REPLACE APOSTROPHES. +
+*** REPLACE EM DASH. +

+ + +

Overview

+ +

+The testsoftfloat program tests that a build of the Berkeley +SoftFloat library conforms to the IEEE Standard for Binary Floating-Point +Arithmetic as expected. +Program testsoftfloat is part of the Berkeley TestFloat package, a +small collection of programs for performing such tests. +For general information about TestFloat, as well as for basics about the +operation of testsoftfloat and how to interpret its output, see +file +TestFloat-general.html. +

+ +

+Note that, even if there are no bugs in the source code for SoftFloat (not +guaranteed), a build of SoftFloat might still fail due to an issue with the +build process, such as an incompatible compiler option or a compiler bug. +

+ +

+The testsoftfloat program will ordinarily test a function for all +rounding modes defined by the IEEE Floating-Point Standard, one after the +other. +If an operation is not supposed to require rounding, it will by default be +tested only with the rounding mode set to near_even +(nearest/even). +In the same way, if an operation is affected by the way in which underflow +tininess is detected, testsoftfloat tests the function with +tininess detected both before rounding and after rounding. +For 80-bit double-extended-precision operations affected by +rounding precision control, testsoftfloat also tests the function +for all three rounding precision modes, one after the other. +Testing can be limited to a single rounding mode, a single tininess mode, +and/or a single rounding precision with appropriate command-line options. +

+ + +

Command Syntax

+ +

+The testsoftfloat program is executed as a command with this +syntax: +

+     testsoftfloat [<option>...] <function>
+
+Square brackets ([ ]) denote optional arguments, +<option> is a supported option, and +<function> is the name of either a testable function or a +function set. +The available options and function sets are documented below. +If testsoftfloat is executed without any arguments, a summary of +usage is written. +

+ + +

Options

+ +

+The testsoftfloat program accepts several command options. +If mutually contradictory options are given, the last one has priority. +

+ +

-help

+ +

+The -help option causes a summary of program usage to be written, +after which the program exits. +

+ +

-level <num>

+ +

+The -level option sets the level of testing. +The argument to -level can be either 1 or 2. +The default is level 1. +Level 2 performs many more tests than level 1 and thus can reveal +bugs not found by level 1. +

+ +

-errors <num>

+ +

+The -errors option instructs testsoftfloat to report +no more than the specified number of errors for any combination of function, +rounding mode, etc. +The argument to -errors must be a nonnegative decimal integer. +Once the specified number of error reports has been generated, +testsoftfloat ends the current test and begins the next one, if +any. +The default is -errors 20. +

+ +

+Against intuition, -errors 0 causes +testsoftfloat to report every error it finds. +

+ +

-errorstop

+ +

+The -errorstop option causes the program to exit after the first +function for which any errors are reported. +

+ +

-forever

+ +

+The -forever option causes a single function to be repeatedly +tested. +Only one rounding mode and/or rounding precision can be tested in a single +execution. +If not specified, the rounding mode defaults to nearest/even. +For 80-bit double-extended-precision functions, the rounding +precision defaults to full double-extended precision. +The testing level is set to 2 by this option. +

+ +

-precision32, -precision64, -precision80

+ +

+For 80-bit double-extended-precision funcions affected by +rounding precision control, the -precision32 option restricts +testing to only the cases in which the rounding precision is +32 bits, equivalent to 32-bit single-precision. +The other rounding precision choices are not tested. +Likewise, -precision64 fixes the rounding precision to +64 bits, equivalent to 64-bit double-precision; +and -precision80 fixes the rounding precision to the full +80 bits of the double-extended-precision format. +All these options are ignored for operations not affected by rounding precision +control. +

+ +

-rnear_even, -rnear_maxMag, -rminMag, -rmin, -rmax

+ +

+The -rnear_even option restricts testing to only the cases in +which the rounding mode is nearest/even. +The other rounding mode choices are not tested. +Likewise, -rnear_maxMag forces rounding to nearest/maximum +magnitude (nearest-away), -rminMag forces rounding to minimum +magnitude (toward zero), -rmin forces rounding to minimum (down, +toward negative infinity), and -rmax forces rounding to maximum +(up, toward positive infinity). +These options are ignored for operations that are exact and thus do not round. +

+ +

-tininessbefore, -tininessafter

+ +

+The -tininessbefore option restricts testing to only the cases in +which tininess on underflow is detected before rounding. +Likewise, -tininessafter restricts testing to only the cases in +which tininess on underflow is detected after rounding. +

+ +

-notexact, -exact

+ +

+For functions that round to an integer (conversions to integer types and the +roundToInt functions), the -notexact option restricts +testing to only the cases for which the exact operand +(specifying whether the inexact exception flag may be raised) is +false. +Likewise, the -exact option restricts testing to only the cases +for which the exact operand is true. +

+ + +

Function Sets

+ +

+Just as testsoftfloat can test a function for all five rounding +modes in sequence, multiple functions can be tested with a single execution of +testsoftfloat. +Two sets are recognized: -all1 and -all2. +The set -all1 comprises all one-operand operations, while +-all2 is all two-operand operations. +A function set is used in place of a function name in the +testsoftfloat command line, such as +

+     testsoftfloat [<option>...] -all1
+
+

+ +

+For the purpose of deciding the number of operands of an operation, any +roundingMode and exact arguments are +ignored. +(Such arguments specify the rounding mode and whether the inexact +exception flag may be raised, respectively.) +Thus, functions that convert to integer type and the roundToInt +functions are included in the set of one-operand operations tested by +-all1. +

+ + + + diff --git a/doc/timesoftfloat.html b/doc/timesoftfloat.html new file mode 100644 index 0000000..b214611 --- /dev/null +++ b/doc/timesoftfloat.html @@ -0,0 +1,202 @@ + + + + +timesoftfloat + + + + +

Berkeley TestFloat Release 3: timesoftfloat

+ +

+John R. Hauser
+2014 ______
+

+ +

+*** CONTENT DONE. +

+ +

+*** REPLACE QUOTATION MARKS. +
+*** REPLACE APOSTROPHES. +
+*** REPLACE EM DASH. +

+ + +

Overview

+ +

+The timesoftfloat program provides a simple way to evaluate the +speed of the floating-point operations of the Berkeley SoftFloat library. +Program timesoftfloat is included with the Berkeley TestFloat +package, a small collection of programs for testing that an implementation of +floating-point conforms to the IEEE Standard for Binary Floating-Point +Arithmetic. +Although timesoftfloat does not test floating-point correctness +like other TestFloat programs, nevertheless timesoftfloat is a +partner to TestFloat's testsoftfloat program. +For more about TestFloat generally and testsoftfloat specifically, +see file +TestFloat-general.html. +

+ +

+Ordinarily, timesoftfloat will measure a function's speed +separately for each rounding mode defined by the IEEE Floating-Point Standard, +one after the other. +If an operation is not supposed to require rounding, it will by default be +timed only with the rounding mode set to near_even (nearest/even). +In the same way, if an operation is affected by the way in which underflow +tininess is detected, timesoftfloat times the function with +tininess detected both before rounding and after rounding. +For 80-bit double-extended-precision operations affected by +rounding precision control, timesoftfloat also times the function +for each of the three rounding precision modes, one after the other. +Evaluation of a function can be limited to a single rounding mode, a single +tininess mode, and/or a single rounding precision with appropriate command-line +options. +

+ +

+For each function and mode evaluated, timesoftfloat reports the +measured speed of the function in Mops/s, or ``millions of operations per +second''. +The speeds reported by timesoftfloat may be affected somewhat by +other software executing at the same time as timesoftfloat. +Be aware also that the exact execution time of any SoftFloat function depends +partly on the values of arguments and the state of the processor's caches at +the time the function is called. +Your actual experience with SoftFloat may differ from the speeds reported by +timesoftfloat for all these reasons. +

+ +

+Note that the remainder operations (f32_rem, f64_rem, +extF80_rem, and f128_rem) will be markedly slower +than other operations, particularly for double-extended-precision +(extF80_rem) and quadruple precision (f128_rem). +This is inherent to the remainder operation itself and is not a failing of the +SoftFloat implementation. +

+ + +

Command Syntax

+ +

+The timesoftfloat program is executed as a command with this +syntax: +

+     timesoftfloat [<option>...] <function>
+
+Square brackets ([ ]) denote optional arguments, +<option> is a supported option, and +<function> is the name of either a testable function or a +function set. +The available options and function sets are documented below. +If timesoftfloat is executed without any arguments, a summary of +usage is written. +

+ + +

Options

+ +

+The timesoftfloat program accepts several command options. +If mutually contradictory options are given, the last one has priority. +

+ +

-help

+ +

+The -help option causes a summary of program usage to be written, +after which the program exits. +

+ +

-precision32, -precision64, -precision80

+ +

+For 80-bit double-extended-precision funcions affected by +rounding precision control, the -precision32 option restricts +timing of an operation to only the cases in which the rounding precision is +32 bits, equivalent to 32-bit single-precision. +Other rounding precision choices are not timed. +Likewise, -precision64 fixes the rounding precision to +64 bits, equivalent to 64-bit double-precision; +and -precision80 fixes the rounding precision to the full +80 bits of the double-extended-precision format. +All these options are ignored for operations not affected by rounding precision +control. +

+ +

-rnear_even, -rnear_maxMag, -rminMag, -rmin, -rmax

+ +

+The -rnear_even option restricts timing of an operation to only +the cases in which the rounding mode is nearest/even. +Other rounding mode choices are not timed. +Likewise, -rnear_maxMag forces rounding to nearest/maximum +magnitude (nearest-away), -rminMag forces rounding to minimum +magnitude (toward zero), -rmin forces rounding to minimum (down, +toward negative infinity), and -rmax forces rounding to maximum +(up, toward positive infinity). +These options are ignored for operations that are exact and thus do not round. +

+ +

-tininessbefore, -tininessafter

+ +

+The -tininessbefore option restricts timing of an operation to +only the cases in which tininess on underflow is detected before rounding. +Likewise, -tininessafter restricts measurement to only the cases +in which tininess on underflow is detected after rounding. +

+ +

-notexact, -exact

+ +

+For functions that round to an integer (conversions to integer types and the +roundToInt functions), the -notexact option restricts +timing of an operation to only the cases for which the +exact operand (specifying whether the inexact +exception flag may be raised) is false. +Likewise, the -exact option restricts measurement to only the +cases for which the exact operand is true. +

+ + +

Function Sets

+ +

+Just as timesoftfloat can time a function for all five rounding +modes in sequence, multiple functions can be timed with a single execution of +timesoftfloat. +Three sets are recognized: +-all1, -all2, and -all. +The set -all1 comprises all one-operand operations, +-all2 is all two-operand operations, and -all is +obviously all operations. +A function set is used in place of a function name in the +timesoftfloat command line, such as +

+     timesoftfloat [<option>...] -all1
+
+

+ +

+For the purpose of deciding the number of operands of an operation, any +roundingMode and exact arguments are +ignored. +(Such arguments specify the rounding mode and whether the inexact +exception flag may be raised, respectively.) +Thus, functions that convert to integer type and the roundToInt +functions are included in the set of one-operand operations timed by +-all1. +

+ + + + diff --git a/source/fail.c b/source/fail.c new file mode 100644 index 0000000..80685ef --- /dev/null +++ b/source/fail.c @@ -0,0 +1,56 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include +#include "platform.h" +#include "fail.h" + +char *fail_programName = ""; + +void fail( const char *messagePtr, ... ) +{ + va_list varArgs; + + fflush( 0 ); + fprintf( stderr, "%s: ", fail_programName ); + va_start( varArgs, messagePtr ); + vfprintf( stderr, messagePtr, varArgs ); + va_end( varArgs ); + fputs( ".\n", stderr ); + exit( EXIT_FAILURE ); + +} + diff --git a/source/fail.h b/source/fail.h new file mode 100644 index 0000000..50e50e5 --- /dev/null +++ b/source/fail.h @@ -0,0 +1,38 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +extern char *fail_programName; + +void fail( const char *, ... ); + diff --git a/source/functionInfos.c b/source/functionInfos.c new file mode 100644 index 0000000..1a3c54f --- /dev/null +++ b/source/functionInfos.c @@ -0,0 +1,212 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "functions.h" + +#define ARG_1 FUNC_ARG_UNARY +#define ARG_2 FUNC_ARG_BINARY +#define ARG_R FUNC_ARG_ROUNDINGMODE +#define ARG_E FUNC_ARG_EXACT +#define EFF_P FUNC_EFF_ROUNDINGPRECISION +#define EFF_R FUNC_EFF_ROUNDINGMODE +#define EFF_T FUNC_EFF_TININESSMODE +#define EFF_T_REDP FUNC_EFF_TININESSMODE_REDUCEDPREC + +/*---------------------------------------------------------------------------- +| Warning: This array must match the functions names defined in +| "functions.h". +*----------------------------------------------------------------------------*/ +const struct functionInfo functionInfos[NUM_FUNCTIONS] = { + { 0, 0 }, + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + { "ui32_to_f32", ARG_1 | EFF_R }, + { "ui32_to_f64", ARG_1 }, +#ifdef EXTFLOAT80 + { "ui32_to_extF80", ARG_1 }, +#endif +#ifdef FLOAT128 + { "ui32_to_f128", ARG_1 }, +#endif + { "ui64_to_f32", ARG_1 | EFF_R }, + { "ui64_to_f64", ARG_1 | EFF_R }, +#ifdef EXTFLOAT80 + { "ui64_to_extF80", ARG_1 }, +#endif +#ifdef FLOAT128 + { "ui64_to_f128", ARG_1 }, +#endif + { "i32_to_f32", ARG_1 | EFF_R }, + { "i32_to_f64", ARG_1 }, +#ifdef EXTFLOAT80 + { "i32_to_extF80", ARG_1 }, +#endif +#ifdef FLOAT128 + { "i32_to_f128", ARG_1 }, +#endif + { "i64_to_f32", ARG_1 | EFF_R }, + { "i64_to_f64", ARG_1 | EFF_R }, +#ifdef EXTFLOAT80 + { "i64_to_extF80", ARG_1 }, +#endif +#ifdef FLOAT128 + { "i64_to_f128", ARG_1 }, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + { "f32_to_ui32", ARG_1 | ARG_R | ARG_E }, + { "f32_to_ui64", ARG_1 | ARG_R | ARG_E }, + { "f32_to_i32", ARG_1 | ARG_R | ARG_E }, + { "f32_to_i64", ARG_1 | ARG_R | ARG_E }, + { "f32_to_ui32_r_minMag", ARG_1 | ARG_E }, + { "f32_to_ui64_r_minMag", ARG_1 | ARG_E }, + { "f32_to_i32_r_minMag", ARG_1 | ARG_E }, + { "f32_to_i64_r_minMag", ARG_1 | ARG_E }, + { "f32_to_f64", ARG_1 }, +#ifdef EXTFLOAT80 + { "f32_to_extF80", ARG_1 }, +#endif +#ifdef FLOAT128 + { "f32_to_f128", ARG_1 }, +#endif + { "f32_roundToInt", ARG_1 | ARG_R | ARG_E }, + { "f32_add", ARG_2 | EFF_R }, + { "f32_sub", ARG_2 | EFF_R }, + { "f32_mul", ARG_2 | EFF_R | EFF_T }, + { "f32_mulAdd", EFF_R | EFF_T }, + { "f32_div", ARG_2 | EFF_R }, + { "f32_rem", ARG_2 }, + { "f32_sqrt", ARG_1 | EFF_R }, + { "f32_eq", ARG_2 }, + { "f32_le", ARG_2 }, + { "f32_lt", ARG_2 }, + { "f32_eq_signaling", ARG_2 }, + { "f32_le_quiet", ARG_2 }, + { "f32_lt_quiet", ARG_2 }, + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + { "f64_to_ui32", ARG_1 | ARG_R | ARG_E }, + { "f64_to_ui64", ARG_1 | ARG_R | ARG_E }, + { "f64_to_i32", ARG_1 | ARG_R | ARG_E }, + { "f64_to_i64", ARG_1 | ARG_R | ARG_E }, + { "f64_to_ui32_r_minMag", ARG_1 | ARG_E }, + { "f64_to_ui64_r_minMag", ARG_1 | ARG_E }, + { "f64_to_i32_r_minMag", ARG_1 | ARG_E }, + { "f64_to_i64_r_minMag", ARG_1 | ARG_E }, + { "f64_to_f32", ARG_1 | EFF_R | EFF_T }, +#ifdef EXTFLOAT80 + { "f64_to_extF80", ARG_1 }, +#endif +#ifdef FLOAT128 + { "f64_to_f128", ARG_1 }, +#endif + { "f64_roundToInt", ARG_1 | ARG_R | ARG_E }, + { "f64_add", ARG_2 | EFF_R }, + { "f64_sub", ARG_2 | EFF_R }, + { "f64_mul", ARG_2 | EFF_R | EFF_T }, + { "f64_mulAdd", EFF_R | EFF_T }, + { "f64_div", ARG_2 | EFF_R }, + { "f64_rem", ARG_2 }, + { "f64_sqrt", ARG_1 | EFF_R }, + { "f64_eq", ARG_2 }, + { "f64_le", ARG_2 }, + { "f64_lt", ARG_2 }, + { "f64_eq_signaling", ARG_2 }, + { "f64_le_quiet", ARG_2 }, + { "f64_lt_quiet", ARG_2 }, + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef EXTFLOAT80 + { "extF80_to_ui32", ARG_1 | ARG_R | ARG_E }, + { "extF80_to_ui64", ARG_1 | ARG_R | ARG_E }, + { "extF80_to_i32", ARG_1 | ARG_R | ARG_E }, + { "extF80_to_i64", ARG_1 | ARG_R | ARG_E }, + { "extF80_to_ui32_r_minMag", ARG_1 | ARG_E }, + { "extF80_to_ui64_r_minMag", ARG_1 | ARG_E }, + { "extF80_to_i32_r_minMag", ARG_1 | ARG_E }, + { "extF80_to_i64_r_minMag", ARG_1 | ARG_E }, + { "extF80_to_f32", ARG_1 | EFF_R | EFF_T }, + { "extF80_to_f64", ARG_1 | EFF_R | EFF_T }, +#ifdef FLOAT128 + { "extF80_to_f128", ARG_1 }, +#endif + { "extF80_roundToInt", ARG_1 | ARG_R | ARG_E }, + { "extF80_add", ARG_2 | EFF_P | EFF_R | EFF_T_REDP }, + { "extF80_sub", ARG_2 | EFF_P | EFF_R | EFF_T_REDP }, + { "extF80_mul", ARG_2 | EFF_P | EFF_R | EFF_T | EFF_T_REDP }, + { "extF80_div", ARG_2 | EFF_P | EFF_R | EFF_T_REDP }, + { "extF80_rem", ARG_2 }, + { "extF80_sqrt", ARG_1 | EFF_P | EFF_R }, + { "extF80_eq", ARG_2 }, + { "extF80_le", ARG_2 }, + { "extF80_lt", ARG_2 }, + { "extF80_eq_signaling", ARG_2 }, + { "extF80_le_quiet", ARG_2 }, + { "extF80_lt_quiet", ARG_2 }, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef FLOAT128 + { "f128_to_ui32", ARG_1 | ARG_R | ARG_E }, + { "f128_to_ui64", ARG_1 | ARG_R | ARG_E }, + { "f128_to_i32", ARG_1 | ARG_R | ARG_E }, + { "f128_to_i64", ARG_1 | ARG_R | ARG_E }, + { "f128_to_ui32_r_minMag", ARG_1 | ARG_E }, + { "f128_to_ui64_r_minMag", ARG_1 | ARG_E }, + { "f128_to_i32_r_minMag", ARG_1 | ARG_E }, + { "f128_to_i64_r_minMag", ARG_1 | ARG_E }, + { "f128_to_f32", ARG_1 | EFF_R | EFF_T }, + { "f128_to_f64", ARG_1 | EFF_R | EFF_T }, +#ifdef EXTFLOAT80 + { "f128_to_extF80", ARG_1 | EFF_R | EFF_T }, +#endif + { "f128_roundToInt", ARG_1 | ARG_R | ARG_E }, + { "f128_add", ARG_2 | EFF_R }, + { "f128_sub", ARG_2 | EFF_R }, + { "f128_mul", ARG_2 | EFF_R | EFF_T }, + { "f128_mulAdd", EFF_R | EFF_T }, + { "f128_div", ARG_2 | EFF_R }, + { "f128_rem", ARG_2 }, + { "f128_sqrt", ARG_1 | EFF_R }, + { "f128_eq", ARG_2 }, + { "f128_le", ARG_2 }, + { "f128_lt", ARG_2 }, + { "f128_eq_signaling", ARG_2 }, + { "f128_le_quiet", ARG_2 }, + { "f128_lt_quiet", ARG_2 }, +#endif +}; + diff --git a/source/functions.h b/source/functions.h new file mode 100644 index 0000000..0f5e55f --- /dev/null +++ b/source/functions.h @@ -0,0 +1,230 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include + +/*---------------------------------------------------------------------------- +| Warning: This list must match the contents of "functionInfos.c". +*----------------------------------------------------------------------------*/ +enum { + UI32_TO_F32 = 1, + UI32_TO_F64, +#ifdef EXTFLOAT80 + UI32_TO_EXTF80, +#endif +#ifdef FLOAT128 + UI32_TO_F128, +#endif + UI64_TO_F32, + UI64_TO_F64, +#ifdef EXTFLOAT80 + UI64_TO_EXTF80, +#endif +#ifdef FLOAT128 + UI64_TO_F128, +#endif + I32_TO_F32, + I32_TO_F64, +#ifdef EXTFLOAT80 + I32_TO_EXTF80, +#endif +#ifdef FLOAT128 + I32_TO_F128, +#endif + I64_TO_F32, + I64_TO_F64, +#ifdef EXTFLOAT80 + I64_TO_EXTF80, +#endif +#ifdef FLOAT128 + I64_TO_F128, +#endif + F32_TO_UI32, + F32_TO_UI64, + F32_TO_I32, + F32_TO_I64, + F32_TO_UI32_R_MINMAG, + F32_TO_UI64_R_MINMAG, + F32_TO_I32_R_MINMAG, + F32_TO_I64_R_MINMAG, + F32_TO_F64, +#ifdef EXTFLOAT80 + F32_TO_EXTF80, +#endif +#ifdef FLOAT128 + F32_TO_F128, +#endif + F32_ROUNDTOINT, + F32_ADD, + F32_SUB, + F32_MUL, + F32_MULADD, + F32_DIV, + F32_REM, + F32_SQRT, + F32_EQ, + F32_LE, + F32_LT, + F32_EQ_SIGNALING, + F32_LE_QUIET, + F32_LT_QUIET, + F64_TO_UI32, + F64_TO_UI64, + F64_TO_I32, + F64_TO_I64, + F64_TO_UI32_R_MINMAG, + F64_TO_UI64_R_MINMAG, + F64_TO_I32_R_MINMAG, + F64_TO_I64_R_MINMAG, + F64_TO_F32, +#ifdef EXTFLOAT80 + F64_TO_EXTF80, +#endif +#ifdef FLOAT128 + F64_TO_F128, +#endif + F64_ROUNDTOINT, + F64_ADD, + F64_SUB, + F64_MUL, + F64_MULADD, + F64_DIV, + F64_REM, + F64_SQRT, + F64_EQ, + F64_LE, + F64_LT, + F64_EQ_SIGNALING, + F64_LE_QUIET, + F64_LT_QUIET, +#ifdef EXTFLOAT80 + EXTF80_TO_UI32, + EXTF80_TO_UI64, + EXTF80_TO_I32, + EXTF80_TO_I64, + EXTF80_TO_UI32_R_MINMAG, + EXTF80_TO_UI64_R_MINMAG, + EXTF80_TO_I32_R_MINMAG, + EXTF80_TO_I64_R_MINMAG, + EXTF80_TO_F32, + EXTF80_TO_F64, +#ifdef FLOAT128 + EXTF80_TO_F128, +#endif + EXTF80_ROUNDTOINT, + EXTF80_ADD, + EXTF80_SUB, + EXTF80_MUL, + EXTF80_DIV, + EXTF80_REM, + EXTF80_SQRT, + EXTF80_EQ, + EXTF80_LE, + EXTF80_LT, + EXTF80_EQ_SIGNALING, + EXTF80_LE_QUIET, + EXTF80_LT_QUIET, +#endif +#ifdef FLOAT128 + F128_TO_UI32, + F128_TO_UI64, + F128_TO_I32, + F128_TO_I64, + F128_TO_UI32_R_MINMAG, + F128_TO_UI64_R_MINMAG, + F128_TO_I32_R_MINMAG, + F128_TO_I64_R_MINMAG, + F128_TO_F32, + F128_TO_F64, +#ifdef EXTFLOAT80 + F128_TO_EXTF80, +#endif + F128_ROUNDTOINT, + F128_ADD, + F128_SUB, + F128_MUL, + F128_MULADD, + F128_DIV, + F128_REM, + F128_SQRT, + F128_EQ, + F128_LE, + F128_LT, + F128_EQ_SIGNALING, + F128_LE_QUIET, + F128_LT_QUIET, +#endif + NUM_FUNCTIONS +}; + +enum { + ROUND_NEAR_EVEN = 1, + ROUND_MINMAG, + ROUND_MIN, + ROUND_MAX, + ROUND_NEAR_MAXMAG, + NUM_ROUNDINGMODES +}; +enum { + TININESS_BEFORE_ROUNDING = 1, + TININESS_AFTER_ROUNDING, + NUM_TININESSMODES +}; + +extern const uint_fast8_t roundingModes[NUM_ROUNDINGMODES]; +extern const uint_fast8_t tininessModes[NUM_TININESSMODES]; + +enum { + FUNC_ARG_UNARY = 0x01, + FUNC_ARG_BINARY = 0x02, + FUNC_ARG_ROUNDINGMODE = 0x04, + FUNC_ARG_EXACT = 0x08, + FUNC_EFF_ROUNDINGPRECISION = 0x10, + FUNC_EFF_ROUNDINGMODE = 0x20, + FUNC_EFF_TININESSMODE = 0x40, + FUNC_EFF_TININESSMODE_REDUCEDPREC = 0x80 +}; +struct functionInfo { + const char *namePtr; + unsigned char attribs; +}; +extern const struct functionInfo functionInfos[NUM_FUNCTIONS]; + +struct standardFunctionInfo { + const char *namePtr; + unsigned char functionCode; + char roundingCode, exact; +}; +extern const struct standardFunctionInfo standardFunctionInfos[]; + diff --git a/source/functions_common.c b/source/functions_common.c new file mode 100644 index 0000000..ca6caeb --- /dev/null +++ b/source/functions_common.c @@ -0,0 +1,54 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "functions.h" + +const uint_fast8_t roundingModes[NUM_ROUNDINGMODES] = { + 0, + softfloat_round_near_even, + softfloat_round_minMag, + softfloat_round_min, + softfloat_round_max, + softfloat_round_near_maxMag +}; + +const uint_fast8_t tininessModes[NUM_TININESSMODES] = { + 0, + softfloat_tininess_beforeRounding, + softfloat_tininess_afterRounding +}; + diff --git a/source/genCases.h b/source/genCases.h new file mode 100644 index 0000000..d186592 --- /dev/null +++ b/source/genCases.h @@ -0,0 +1,99 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "softfloat.h" + +extern int genCases_level; + +void genCases_setLevel( int ); + +extern uint_fast64_t genCases_total; +extern bool genCases_done; + +void genCases_ui32_a_init( void ); +void genCases_ui32_a_next( void ); +extern uint_fast32_t genCases_ui32_a; + +void genCases_ui64_a_init( void ); +void genCases_ui64_a_next( void ); +extern uint_fast64_t genCases_ui64_a; + +void genCases_i32_a_init( void ); +void genCases_i32_a_next( void ); +extern int_fast32_t genCases_i32_a; + +void genCases_i64_a_init( void ); +void genCases_i64_a_next( void ); +extern int_fast64_t genCases_i64_a; + +void genCases_f32_a_init( void ); +void genCases_f32_a_next( void ); +void genCases_f32_ab_init( void ); +void genCases_f32_ab_next( void ); +void genCases_f32_abc_init( void ); +void genCases_f32_abc_next( void ); +extern float32_t genCases_f32_a, genCases_f32_b, genCases_f32_c; + +void genCases_f64_a_init( void ); +void genCases_f64_a_next( void ); +void genCases_f64_ab_init( void ); +void genCases_f64_ab_next( void ); +void genCases_f64_abc_init( void ); +void genCases_f64_abc_next( void ); +extern float64_t genCases_f64_a, genCases_f64_b, genCases_f64_c; + +#ifdef EXTFLOAT80 +void genCases_extF80_a_init( void ); +void genCases_extF80_a_next( void ); +void genCases_extF80_ab_init( void ); +void genCases_extF80_ab_next( void ); +void genCases_extF80_abc_init( void ); +void genCases_extF80_abc_next( void ); +extern extFloat80_t genCases_extF80_a, genCases_extF80_b, genCases_extF80_c; +#endif + +#ifdef FLOAT128 +void genCases_f128_a_init( void ); +void genCases_f128_a_next( void ); +void genCases_f128_ab_init( void ); +void genCases_f128_ab_next( void ); +void genCases_f128_abc_init( void ); +void genCases_f128_abc_next( void ); +extern float128_t genCases_f128_a, genCases_f128_b, genCases_f128_c; +#endif + +void genCases_writeTestsTotal( bool ); + diff --git a/source/genCases_common.c b/source/genCases_common.c new file mode 100644 index 0000000..d0fe0bf --- /dev/null +++ b/source/genCases_common.c @@ -0,0 +1,55 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "fail.h" +#include "genCases.h" + +int genCases_level = 0; + +void genCases_setLevel( int newLevel ) +{ + + if ( (newLevel < 1) || (2 < newLevel) ) { + fail( "Invalid testing level %d", newLevel ); + } + genCases_level = newLevel; + +} + +uint_fast64_t genCases_total; +bool genCases_done; + diff --git a/source/genCases_extF80.c b/source/genCases_extF80.c new file mode 100644 index 0000000..0cfc468 --- /dev/null +++ b/source/genCases_extF80.c @@ -0,0 +1,917 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" +#include "softfloat.h" +#include "genCases.h" + +#ifdef EXTFLOAT80 + +struct sequence { + int expNum, term1Num, term2Num; + bool done; +}; + +enum { + extF80NumQIn = 22, + extF80NumQOut = 76, + extF80NumP1 = 4, + extF80NumP2 = 248 +}; +static const uint16_t extF80QIn[extF80NumQIn] = { + 0x0000, /* positive, subnormal */ + 0x0001, /* positive, -16382 */ + 0x3FBF, /* positive, -64 */ + 0x3FFD, /* positive, -2 */ + 0x3FFE, /* positive, -1 */ + 0x3FFF, /* positive, 0 */ + 0x4000, /* positive, 1 */ + 0x4001, /* positive, 2 */ + 0x403F, /* positive, 64 */ + 0x7FFE, /* positive, 16383 */ + 0x7FFF, /* positive, infinity or NaN */ + 0x8000, /* negative, subnormal */ + 0x8001, /* negative, -16382 */ + 0xBFBF, /* negative, -64 */ + 0xBFFD, /* negative, -2 */ + 0xBFFE, /* negative, -1 */ + 0xBFFF, /* negative, 0 */ + 0xC000, /* negative, 1 */ + 0xC001, /* negative, 2 */ + 0xC03F, /* negative, 64 */ + 0xFFFE, /* negative, 16383 */ + 0xFFFF /* negative, infinity or NaN */ +}; +static const uint16_t extF80QOut[extF80NumQOut] = { + 0x0000, /* positive, subnormal */ + 0x0001, /* positive, -16382 */ + 0x0002, /* positive, -16381 */ + 0x3BFE, /* positive, -1025 */ + 0x3BFF, /* positive, -1024 */ + 0x3C00, /* positive, -1023 */ + 0x3C01, /* positive, -1022 */ + 0x3F7E, /* positive, -129 */ + 0x3F7F, /* positive, -128 */ + 0x3F80, /* positive, -127 */ + 0x3F81, /* positive, -126 */ + 0x3FBF, /* positive, -64 */ + 0x3FFB, /* positive, -4 */ + 0x3FFC, /* positive, -3 */ + 0x3FFD, /* positive, -2 */ + 0x3FFE, /* positive, -1 */ + 0x3FFF, /* positive, 0 */ + 0x4000, /* positive, 1 */ + 0x4001, /* positive, 2 */ + 0x4002, /* positive, 3 */ + 0x4003, /* positive, 4 */ + 0x401C, /* positive, 29 */ + 0x401D, /* positive, 30 */ + 0x401E, /* positive, 31 */ + 0x401F, /* positive, 32 */ + 0x403C, /* positive, 61 */ + 0x403D, /* positive, 62 */ + 0x403E, /* positive, 63 */ + 0x403F, /* positive, 64 */ + 0x407E, /* positive, 127 */ + 0x407F, /* positive, 128 */ + 0x4080, /* positive, 129 */ + 0x43FE, /* positive, 1023 */ + 0x43FF, /* positive, 1024 */ + 0x4400, /* positive, 1025 */ + 0x7FFD, /* positive, 16382 */ + 0x7FFE, /* positive, 16383 */ + 0x7FFF, /* positive, infinity or NaN */ + 0x8000, /* negative, subnormal */ + 0x8001, /* negative, -16382 */ + 0x8002, /* negative, -16381 */ + 0xBBFE, /* negative, -1025 */ + 0xBBFF, /* negative, -1024 */ + 0xBC00, /* negative, -1023 */ + 0xBC01, /* negative, -1022 */ + 0xBF7E, /* negative, -129 */ + 0xBF7F, /* negative, -128 */ + 0xBF80, /* negative, -127 */ + 0xBF81, /* negative, -126 */ + 0xBFBF, /* negative, -64 */ + 0xBFFB, /* negative, -4 */ + 0xBFFC, /* negative, -3 */ + 0xBFFD, /* negative, -2 */ + 0xBFFE, /* negative, -1 */ + 0xBFFF, /* negative, 0 */ + 0xC000, /* negative, 1 */ + 0xC001, /* negative, 2 */ + 0xC002, /* negative, 3 */ + 0xC003, /* negative, 4 */ + 0xC01C, /* negative, 29 */ + 0xC01D, /* negative, 30 */ + 0xC01E, /* negative, 31 */ + 0xC01F, /* negative, 32 */ + 0xC03C, /* negative, 61 */ + 0xC03D, /* negative, 62 */ + 0xC03E, /* negative, 63 */ + 0xC03F, /* negative, 64 */ + 0xC07E, /* negative, 127 */ + 0xC07F, /* negative, 128 */ + 0xC080, /* negative, 129 */ + 0xC3FE, /* negative, 1023 */ + 0xC3FF, /* negative, 1024 */ + 0xC400, /* negative, 1025 */ + 0xFFFD, /* negative, 16382 */ + 0xFFFE, /* negative, 16383 */ + 0xFFFF /* negative, infinity or NaN */ +}; +static const uint64_t extF80P1[extF80NumP1] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000001 ), + UINT64_C( 0x7FFFFFFFFFFFFFFF ), + UINT64_C( 0x7FFFFFFFFFFFFFFE ) +}; +static const uint64_t extF80P2[extF80NumP2] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000001 ), + UINT64_C( 0x0000000000000002 ), + UINT64_C( 0x0000000000000004 ), + UINT64_C( 0x0000000000000008 ), + UINT64_C( 0x0000000000000010 ), + UINT64_C( 0x0000000000000020 ), + UINT64_C( 0x0000000000000040 ), + UINT64_C( 0x0000000000000080 ), + UINT64_C( 0x0000000000000100 ), + UINT64_C( 0x0000000000000200 ), + UINT64_C( 0x0000000000000400 ), + UINT64_C( 0x0000000000000800 ), + UINT64_C( 0x0000000000001000 ), + UINT64_C( 0x0000000000002000 ), + UINT64_C( 0x0000000000004000 ), + UINT64_C( 0x0000000000008000 ), + UINT64_C( 0x0000000000010000 ), + UINT64_C( 0x0000000000020000 ), + UINT64_C( 0x0000000000040000 ), + UINT64_C( 0x0000000000080000 ), + UINT64_C( 0x0000000000100000 ), + UINT64_C( 0x0000000000200000 ), + UINT64_C( 0x0000000000400000 ), + UINT64_C( 0x0000000000800000 ), + UINT64_C( 0x0000000001000000 ), + UINT64_C( 0x0000000002000000 ), + UINT64_C( 0x0000000004000000 ), + UINT64_C( 0x0000000008000000 ), + UINT64_C( 0x0000000010000000 ), + UINT64_C( 0x0000000020000000 ), + UINT64_C( 0x0000000040000000 ), + UINT64_C( 0x0000000080000000 ), + UINT64_C( 0x0000000100000000 ), + UINT64_C( 0x0000000200000000 ), + UINT64_C( 0x0000000400000000 ), + UINT64_C( 0x0000000800000000 ), + UINT64_C( 0x0000001000000000 ), + UINT64_C( 0x0000002000000000 ), + UINT64_C( 0x0000004000000000 ), + UINT64_C( 0x0000008000000000 ), + UINT64_C( 0x0000010000000000 ), + UINT64_C( 0x0000020000000000 ), + UINT64_C( 0x0000040000000000 ), + UINT64_C( 0x0000080000000000 ), + UINT64_C( 0x0000100000000000 ), + UINT64_C( 0x0000200000000000 ), + UINT64_C( 0x0000400000000000 ), + UINT64_C( 0x0000800000000000 ), + UINT64_C( 0x0001000000000000 ), + UINT64_C( 0x0002000000000000 ), + UINT64_C( 0x0004000000000000 ), + UINT64_C( 0x0008000000000000 ), + UINT64_C( 0x0010000000000000 ), + UINT64_C( 0x0020000000000000 ), + UINT64_C( 0x0040000000000000 ), + UINT64_C( 0x0080000000000000 ), + UINT64_C( 0x0100000000000000 ), + UINT64_C( 0x0200000000000000 ), + UINT64_C( 0x0400000000000000 ), + UINT64_C( 0x0800000000000000 ), + UINT64_C( 0x1000000000000000 ), + UINT64_C( 0x2000000000000000 ), + UINT64_C( 0x4000000000000000 ), + UINT64_C( 0x6000000000000000 ), + UINT64_C( 0x7000000000000000 ), + UINT64_C( 0x7800000000000000 ), + UINT64_C( 0x7C00000000000000 ), + UINT64_C( 0x7E00000000000000 ), + UINT64_C( 0x7F00000000000000 ), + UINT64_C( 0x7F80000000000000 ), + UINT64_C( 0x7FC0000000000000 ), + UINT64_C( 0x7FE0000000000000 ), + UINT64_C( 0x7FF0000000000000 ), + UINT64_C( 0x7FF8000000000000 ), + UINT64_C( 0x7FFC000000000000 ), + UINT64_C( 0x7FFE000000000000 ), + UINT64_C( 0x7FFF000000000000 ), + UINT64_C( 0x7FFF800000000000 ), + UINT64_C( 0x7FFFC00000000000 ), + UINT64_C( 0x7FFFE00000000000 ), + UINT64_C( 0x7FFFF00000000000 ), + UINT64_C( 0x7FFFF80000000000 ), + UINT64_C( 0x7FFFFC0000000000 ), + UINT64_C( 0x7FFFFE0000000000 ), + UINT64_C( 0x7FFFFF0000000000 ), + UINT64_C( 0x7FFFFF8000000000 ), + UINT64_C( 0x7FFFFFC000000000 ), + UINT64_C( 0x7FFFFFE000000000 ), + UINT64_C( 0x7FFFFFF000000000 ), + UINT64_C( 0x7FFFFFF800000000 ), + UINT64_C( 0x7FFFFFFC00000000 ), + UINT64_C( 0x7FFFFFFE00000000 ), + UINT64_C( 0x7FFFFFFF00000000 ), + UINT64_C( 0x7FFFFFFF80000000 ), + UINT64_C( 0x7FFFFFFFC0000000 ), + UINT64_C( 0x7FFFFFFFE0000000 ), + UINT64_C( 0x7FFFFFFFF0000000 ), + UINT64_C( 0x7FFFFFFFF8000000 ), + UINT64_C( 0x7FFFFFFFFC000000 ), + UINT64_C( 0x7FFFFFFFFE000000 ), + UINT64_C( 0x7FFFFFFFFF000000 ), + UINT64_C( 0x7FFFFFFFFF800000 ), + UINT64_C( 0x7FFFFFFFFFC00000 ), + UINT64_C( 0x7FFFFFFFFFE00000 ), + UINT64_C( 0x7FFFFFFFFFF00000 ), + UINT64_C( 0x7FFFFFFFFFF80000 ), + UINT64_C( 0x7FFFFFFFFFFC0000 ), + UINT64_C( 0x7FFFFFFFFFFE0000 ), + UINT64_C( 0x7FFFFFFFFFFF0000 ), + UINT64_C( 0x7FFFFFFFFFFF8000 ), + UINT64_C( 0x7FFFFFFFFFFFC000 ), + UINT64_C( 0x7FFFFFFFFFFFE000 ), + UINT64_C( 0x7FFFFFFFFFFFF000 ), + UINT64_C( 0x7FFFFFFFFFFFF800 ), + UINT64_C( 0x7FFFFFFFFFFFFC00 ), + UINT64_C( 0x7FFFFFFFFFFFFE00 ), + UINT64_C( 0x7FFFFFFFFFFFFF00 ), + UINT64_C( 0x7FFFFFFFFFFFFF80 ), + UINT64_C( 0x7FFFFFFFFFFFFFC0 ), + UINT64_C( 0x7FFFFFFFFFFFFFE0 ), + UINT64_C( 0x7FFFFFFFFFFFFFF0 ), + UINT64_C( 0x7FFFFFFFFFFFFFF8 ), + UINT64_C( 0x7FFFFFFFFFFFFFFC ), + UINT64_C( 0x7FFFFFFFFFFFFFFE ), + UINT64_C( 0x7FFFFFFFFFFFFFFF ), + UINT64_C( 0x7FFFFFFFFFFFFFFD ), + UINT64_C( 0x7FFFFFFFFFFFFFFB ), + UINT64_C( 0x7FFFFFFFFFFFFFF7 ), + UINT64_C( 0x7FFFFFFFFFFFFFEF ), + UINT64_C( 0x7FFFFFFFFFFFFFDF ), + UINT64_C( 0x7FFFFFFFFFFFFFBF ), + UINT64_C( 0x7FFFFFFFFFFFFF7F ), + UINT64_C( 0x7FFFFFFFFFFFFEFF ), + UINT64_C( 0x7FFFFFFFFFFFFDFF ), + UINT64_C( 0x7FFFFFFFFFFFFBFF ), + UINT64_C( 0x7FFFFFFFFFFFF7FF ), + UINT64_C( 0x7FFFFFFFFFFFEFFF ), + UINT64_C( 0x7FFFFFFFFFFFDFFF ), + UINT64_C( 0x7FFFFFFFFFFFBFFF ), + UINT64_C( 0x7FFFFFFFFFFF7FFF ), + UINT64_C( 0x7FFFFFFFFFFEFFFF ), + UINT64_C( 0x7FFFFFFFFFFDFFFF ), + UINT64_C( 0x7FFFFFFFFFFBFFFF ), + UINT64_C( 0x7FFFFFFFFFF7FFFF ), + UINT64_C( 0x7FFFFFFFFFEFFFFF ), + UINT64_C( 0x7FFFFFFFFFDFFFFF ), + UINT64_C( 0x7FFFFFFFFFBFFFFF ), + UINT64_C( 0x7FFFFFFFFF7FFFFF ), + UINT64_C( 0x7FFFFFFFFEFFFFFF ), + UINT64_C( 0x7FFFFFFFFDFFFFFF ), + UINT64_C( 0x7FFFFFFFFBFFFFFF ), + UINT64_C( 0x7FFFFFFFF7FFFFFF ), + UINT64_C( 0x7FFFFFFFEFFFFFFF ), + UINT64_C( 0x7FFFFFFFDFFFFFFF ), + UINT64_C( 0x7FFFFFFFBFFFFFFF ), + UINT64_C( 0x7FFFFFFF7FFFFFFF ), + UINT64_C( 0x7FFFFFFEFFFFFFFF ), + UINT64_C( 0x7FFFFFFDFFFFFFFF ), + UINT64_C( 0x7FFFFFFBFFFFFFFF ), + UINT64_C( 0x7FFFFFF7FFFFFFFF ), + UINT64_C( 0x7FFFFFEFFFFFFFFF ), + UINT64_C( 0x7FFFFFDFFFFFFFFF ), + UINT64_C( 0x7FFFFFBFFFFFFFFF ), + UINT64_C( 0x7FFFFF7FFFFFFFFF ), + UINT64_C( 0x7FFFFEFFFFFFFFFF ), + UINT64_C( 0x7FFFFDFFFFFFFFFF ), + UINT64_C( 0x7FFFFBFFFFFFFFFF ), + UINT64_C( 0x7FFFF7FFFFFFFFFF ), + UINT64_C( 0x7FFFEFFFFFFFFFFF ), + UINT64_C( 0x7FFFDFFFFFFFFFFF ), + UINT64_C( 0x7FFFBFFFFFFFFFFF ), + UINT64_C( 0x7FFF7FFFFFFFFFFF ), + UINT64_C( 0x7FFEFFFFFFFFFFFF ), + UINT64_C( 0x7FFDFFFFFFFFFFFF ), + UINT64_C( 0x7FFBFFFFFFFFFFFF ), + UINT64_C( 0x7FF7FFFFFFFFFFFF ), + UINT64_C( 0x7FEFFFFFFFFFFFFF ), + UINT64_C( 0x7FDFFFFFFFFFFFFF ), + UINT64_C( 0x7FBFFFFFFFFFFFFF ), + UINT64_C( 0x7F7FFFFFFFFFFFFF ), + UINT64_C( 0x7EFFFFFFFFFFFFFF ), + UINT64_C( 0x7DFFFFFFFFFFFFFF ), + UINT64_C( 0x7BFFFFFFFFFFFFFF ), + UINT64_C( 0x77FFFFFFFFFFFFFF ), + UINT64_C( 0x6FFFFFFFFFFFFFFF ), + UINT64_C( 0x5FFFFFFFFFFFFFFF ), + UINT64_C( 0x3FFFFFFFFFFFFFFF ), + UINT64_C( 0x1FFFFFFFFFFFFFFF ), + UINT64_C( 0x0FFFFFFFFFFFFFFF ), + UINT64_C( 0x07FFFFFFFFFFFFFF ), + UINT64_C( 0x03FFFFFFFFFFFFFF ), + UINT64_C( 0x01FFFFFFFFFFFFFF ), + UINT64_C( 0x00FFFFFFFFFFFFFF ), + UINT64_C( 0x007FFFFFFFFFFFFF ), + UINT64_C( 0x003FFFFFFFFFFFFF ), + UINT64_C( 0x001FFFFFFFFFFFFF ), + UINT64_C( 0x000FFFFFFFFFFFFF ), + UINT64_C( 0x0007FFFFFFFFFFFF ), + UINT64_C( 0x0003FFFFFFFFFFFF ), + UINT64_C( 0x0001FFFFFFFFFFFF ), + UINT64_C( 0x0000FFFFFFFFFFFF ), + UINT64_C( 0x00007FFFFFFFFFFF ), + UINT64_C( 0x00003FFFFFFFFFFF ), + UINT64_C( 0x00001FFFFFFFFFFF ), + UINT64_C( 0x00000FFFFFFFFFFF ), + UINT64_C( 0x000007FFFFFFFFFF ), + UINT64_C( 0x000003FFFFFFFFFF ), + UINT64_C( 0x000001FFFFFFFFFF ), + UINT64_C( 0x000000FFFFFFFFFF ), + UINT64_C( 0x0000007FFFFFFFFF ), + UINT64_C( 0x0000003FFFFFFFFF ), + UINT64_C( 0x0000001FFFFFFFFF ), + UINT64_C( 0x0000000FFFFFFFFF ), + UINT64_C( 0x00000007FFFFFFFF ), + UINT64_C( 0x00000003FFFFFFFF ), + UINT64_C( 0x00000001FFFFFFFF ), + UINT64_C( 0x00000000FFFFFFFF ), + UINT64_C( 0x000000007FFFFFFF ), + UINT64_C( 0x000000003FFFFFFF ), + UINT64_C( 0x000000001FFFFFFF ), + UINT64_C( 0x000000000FFFFFFF ), + UINT64_C( 0x0000000007FFFFFF ), + UINT64_C( 0x0000000003FFFFFF ), + UINT64_C( 0x0000000001FFFFFF ), + UINT64_C( 0x0000000000FFFFFF ), + UINT64_C( 0x00000000007FFFFF ), + UINT64_C( 0x00000000003FFFFF ), + UINT64_C( 0x00000000001FFFFF ), + UINT64_C( 0x00000000000FFFFF ), + UINT64_C( 0x000000000007FFFF ), + UINT64_C( 0x000000000003FFFF ), + UINT64_C( 0x000000000001FFFF ), + UINT64_C( 0x000000000000FFFF ), + UINT64_C( 0x0000000000007FFF ), + UINT64_C( 0x0000000000003FFF ), + UINT64_C( 0x0000000000001FFF ), + UINT64_C( 0x0000000000000FFF ), + UINT64_C( 0x00000000000007FF ), + UINT64_C( 0x00000000000003FF ), + UINT64_C( 0x00000000000001FF ), + UINT64_C( 0x00000000000000FF ), + UINT64_C( 0x000000000000007F ), + UINT64_C( 0x000000000000003F ), + UINT64_C( 0x000000000000001F ), + UINT64_C( 0x000000000000000F ), + UINT64_C( 0x0000000000000007 ), + UINT64_C( 0x0000000000000003 ) +}; + +static const uint_fast32_t extF80NumQInP1 = extF80NumQIn * extF80NumP1; +static const uint_fast32_t extF80NumQOutP1 = extF80NumQOut * extF80NumP1; + +static void extF80NextQInP1( struct sequence *sequencePtr, extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + int expNum, sigNum; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZ64 = extF80QIn[expNum]; + uiZ0 = extF80P1[sigNum]; + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + ++sigNum; + if ( extF80NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( extF80NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static + void extF80NextQOutP1( struct sequence *sequencePtr, extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + int expNum, sigNum; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZ64 = extF80QOut[expNum]; + uiZ0 = extF80P1[sigNum]; + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + ++sigNum; + if ( extF80NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( extF80NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static const uint_fast32_t extF80NumQInP2 = extF80NumQIn * extF80NumP2; +static const uint_fast32_t extF80NumQOutP2 = extF80NumQOut * extF80NumP2; + +static void extF80NextQInP2( struct sequence *sequencePtr, extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + int expNum, sigNum; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZ64 = extF80QIn[expNum]; + uiZ0 = extF80P2[sigNum]; + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + ++sigNum; + if ( extF80NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( extF80NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static + void extF80NextQOutP2( struct sequence *sequencePtr, extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + int expNum, sigNum; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZ64 = extF80QOut[expNum]; + uiZ0 = extF80P2[sigNum]; + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + ++sigNum; + if ( extF80NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( extF80NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static void extF80RandomQOutP3( extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + uiZ64 = extF80QOut[randomN_ui8( extF80NumQOut )]; + uiZ0 = + (extF80P2[randomN_ui8( extF80NumP2 )] + + extF80P2[randomN_ui8( extF80NumP2 )]) + & UINT64_C( 0x7FFFFFFFFFFFFFFF ); + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + +} + +static void extF80RandomQOutPInf( extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + uiZ64 = extF80QOut[randomN_ui8( extF80NumQOut )]; + uiZ0 = random_ui64() & UINT64_C( 0x7FFFFFFFFFFFFFFF ); + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + +} + +enum { extF80NumQInfWeightMasks = 14 }; +static const uint16_t extF80QInfWeightMasks[extF80NumQInfWeightMasks] = { + 0xFFFF, + 0xFFFF, + 0xBFFF, + 0x9FFF, + 0x87FF, + 0x87FF, + 0x83FF, + 0x81FF, + 0x80FF, + 0x807F, + 0x803F, + 0x801F, + 0x800F, + 0x8007 +}; +static const uint16_t extF80QInfWeightOffsets[extF80NumQInfWeightMasks] = { + 0x0000, + 0x0000, + 0x2000, + 0x3000, + 0x3800, + 0x3C00, + 0x3E00, + 0x3F00, + 0x3F80, + 0x3FC0, + 0x3FE0, + 0x3FF0, + 0x3FF8, + 0x3FFC +}; + +static void extF80RandomQInfP3( extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + int weightMaskNum; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + weightMaskNum = randomN_ui8( extF80NumQInfWeightMasks ); + uiZ64 = + (random_ui16() & extF80QInfWeightMasks[weightMaskNum]) + + extF80QInfWeightOffsets[weightMaskNum]; + uiZ0 = + (extF80P2[randomN_ui8( extF80NumP2 )] + + extF80P2[randomN_ui8( extF80NumP2 )]) + & UINT64_C( 0x7FFFFFFFFFFFFFFF ); + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + +} + +static void extF80RandomQInfPInf( extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + int weightMaskNum; + uint_fast16_t uiZ64; + uint_fast64_t uiZ0; + + zSPtr = (struct extFloat80M *) zPtr; + weightMaskNum = randomN_ui8( extF80NumQInfWeightMasks ); + uiZ64 = + (random_ui16() & extF80QInfWeightMasks[weightMaskNum]) + + extF80QInfWeightOffsets[weightMaskNum]; + uiZ0 = random_ui64() & UINT64_C( 0x7FFFFFFFFFFFFFFF ); + if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 ); + zSPtr->signExp = uiZ64; + zSPtr->signif = uiZ0; + +} + +static void extF80Random( extFloat80_t *zPtr ) +{ + + switch ( random_ui8() & 7 ) { + case 0: + case 1: + case 2: + extF80RandomQOutP3( zPtr ); + break; + case 3: + extF80RandomQOutPInf( zPtr ); + break; + case 4: + case 5: + case 6: + extF80RandomQInfP3( zPtr ); + break; + case 7: + extF80RandomQInfPInf( zPtr ); + break; + } + +} + +static struct sequence sequenceA, sequenceB, sequenceC; +static extFloat80_t currentA, currentB, currentC; +static int subcase; + +extFloat80_t genCases_extF80_a, genCases_extF80_b, genCases_extF80_c; + +void genCases_extF80_a_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = + (genCases_level == 1) ? 3 * extF80NumQOutP1 : 2 * extF80NumQOutP2; + genCases_done = false; + +} + +void genCases_extF80_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + case 1: + extF80Random( &genCases_extF80_a ); + break; + case 2: + extF80NextQOutP1( &sequenceA, &genCases_extF80_a ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + extF80Random( &genCases_extF80_a ); + break; + case 1: + extF80NextQOutP2( &sequenceA, &genCases_extF80_a ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_extF80_ab_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 6 * extF80NumQInP1 * extF80NumQInP1; + extF80NextQInP1( &sequenceA, ¤tA ); + } else { + genCases_total = 2 * extF80NumQInP2 * extF80NumQInP2; + extF80NextQInP2( &sequenceA, ¤tA ); + } + genCases_done = false; + +} + +void genCases_extF80_ab_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceB.done ) { + sequenceB.done = false; + extF80NextQInP1( &sequenceA, ¤tA ); + } + extF80NextQInP1( &sequenceB, ¤tB ); + case 2: + case 4: + extF80Random( &genCases_extF80_a ); + extF80Random( &genCases_extF80_b ); + break; + case 1: + genCases_extF80_a = currentA; + extF80Random( &genCases_extF80_b ); + break; + case 3: + extF80Random( &genCases_extF80_a ); + genCases_extF80_b = currentB; + break; + case 5: + genCases_extF80_a = currentA; + genCases_extF80_b = currentB; + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + extF80Random( &genCases_extF80_a ); + extF80Random( &genCases_extF80_b ); + break; + case 1: + if ( sequenceB.done ) { + sequenceB.done = false; + extF80NextQInP2( &sequenceA, ¤tA ); + } + genCases_extF80_a = currentA; + extF80NextQInP2( &sequenceB, &genCases_extF80_b ); + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_extF80_abc_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + sequenceC.expNum = 0; + sequenceC.term1Num = 0; + sequenceC.term2Num = 0; + sequenceC.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 9 * extF80NumQInP1 * extF80NumQInP1 * extF80NumQInP1; + extF80NextQInP1( &sequenceA, ¤tA ); + extF80NextQInP1( &sequenceB, ¤tB ); + } else { + genCases_total = 2 * extF80NumQInP2 * extF80NumQInP2 * extF80NumQInP2; + extF80NextQInP2( &sequenceA, ¤tA ); + extF80NextQInP2( &sequenceB, ¤tB ); + } + genCases_done = false; + +} + +void genCases_extF80_abc_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + extF80NextQInP1( &sequenceA, ¤tA ); + } + extF80NextQInP1( &sequenceB, ¤tB ); + } + extF80NextQInP1( &sequenceC, ¤tC ); + extF80Random( &genCases_extF80_a ); + extF80Random( &genCases_extF80_b ); + genCases_extF80_c = currentC; + break; + case 1: + genCases_extF80_a = currentA; + genCases_extF80_b = currentB; + extF80Random( &genCases_extF80_c ); + break; + case 2: + extF80Random( &genCases_extF80_a ); + extF80Random( &genCases_extF80_b ); + extF80Random( &genCases_extF80_c ); + break; + case 3: + extF80Random( &genCases_extF80_a ); + genCases_extF80_b = currentB; + genCases_extF80_c = currentC; + break; + case 4: + genCases_extF80_a = currentA; + extF80Random( &genCases_extF80_b ); + extF80Random( &genCases_extF80_c ); + break; + case 5: + extF80Random( &genCases_extF80_a ); + genCases_extF80_b = currentB; + extF80Random( &genCases_extF80_c ); + break; + case 6: + genCases_extF80_a = currentA; + extF80Random( &genCases_extF80_b ); + genCases_extF80_c = currentC; + break; + case 7: + extF80Random( &genCases_extF80_a ); + extF80Random( &genCases_extF80_b ); + extF80Random( &genCases_extF80_c ); + break; + case 8: + genCases_extF80_a = currentA; + genCases_extF80_b = currentB; + genCases_extF80_c = currentC; + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + extF80Random( &genCases_extF80_a ); + extF80Random( &genCases_extF80_b ); + extF80Random( &genCases_extF80_c ); + break; + case 1: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + extF80NextQInP2( &sequenceA, ¤tA ); + } + extF80NextQInP2( &sequenceB, ¤tB ); + } + genCases_extF80_a = currentA; + genCases_extF80_b = currentB; + extF80NextQInP2( &sequenceC, &genCases_extF80_c ); + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +#endif + diff --git a/source/genCases_f128.c b/source/genCases_f128.c new file mode 100644 index 0000000..0a516d3 --- /dev/null +++ b/source/genCases_f128.c @@ -0,0 +1,1087 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "uint128.h" +#include "random.h" +#include "softfloat.h" +#include "genCases.h" + +#ifdef FLOAT128 + +struct sequence { + int expNum, term1Num, term2Num; + bool done; +}; + +enum { + f128NumQIn = 22, + f128NumQOut = 78, + f128NumP1 = 4, + f128NumP2 = 443 +}; +static const uint64_t f128QIn[f128NumQIn] = { + UINT64_C( 0x0000000000000000 ), /* positive, subnormal */ + UINT64_C( 0x0001000000000000 ), /* positive, -16382 */ + UINT64_C( 0x3F8E000000000000 ), /* positive, -113 */ + UINT64_C( 0x3FFD000000000000 ), /* positive, -2 */ + UINT64_C( 0x3FFE000000000000 ), /* positive, -1 */ + UINT64_C( 0x3FFF000000000000 ), /* positive, 0 */ + UINT64_C( 0x4000000000000000 ), /* positive, 1 */ + UINT64_C( 0x4001000000000000 ), /* positive, 2 */ + UINT64_C( 0x4070000000000000 ), /* positive, 113 */ + UINT64_C( 0x7FFE000000000000 ), /* positive, 16383 */ + UINT64_C( 0x7FFF000000000000 ), /* positive, infinity or NaN */ + UINT64_C( 0x8000000000000000 ), /* negative, subnormal */ + UINT64_C( 0x8001000000000000 ), /* negative, -16382 */ + UINT64_C( 0xBF8E000000000000 ), /* negative, -113 */ + UINT64_C( 0xBFFD000000000000 ), /* negative, -2 */ + UINT64_C( 0xBFFE000000000000 ), /* negative, -1 */ + UINT64_C( 0xBFFF000000000000 ), /* negative, 0 */ + UINT64_C( 0xC000000000000000 ), /* negative, 1 */ + UINT64_C( 0xC001000000000000 ), /* negative, 2 */ + UINT64_C( 0xC070000000000000 ), /* negative, 113 */ + UINT64_C( 0xFFFE000000000000 ), /* negative, 16383 */ + UINT64_C( 0xFFFF000000000000 ) /* negative, infinity or NaN */ +}; +static const uint64_t f128QOut[f128NumQOut] = { + UINT64_C( 0x0000000000000000 ), /* positive, subnormal */ + UINT64_C( 0x0001000000000000 ), /* positive, -16382 */ + UINT64_C( 0x0002000000000000 ), /* positive, -16381 */ + UINT64_C( 0x3BFE000000000000 ), /* positive, -1025 */ + UINT64_C( 0x3BFF000000000000 ), /* positive, -1024 */ + UINT64_C( 0x3C00000000000000 ), /* positive, -1023 */ + UINT64_C( 0x3C01000000000000 ), /* positive, -1022 */ + UINT64_C( 0x3F7E000000000000 ), /* positive, -129 */ + UINT64_C( 0x3F7F000000000000 ), /* positive, -128 */ + UINT64_C( 0x3F80000000000000 ), /* positive, -127 */ + UINT64_C( 0x3F81000000000000 ), /* positive, -126 */ + UINT64_C( 0x3F8E000000000000 ), /* positive, -113 */ + UINT64_C( 0x3FFB000000000000 ), /* positive, -4 */ + UINT64_C( 0x3FFC000000000000 ), /* positive, -3 */ + UINT64_C( 0x3FFD000000000000 ), /* positive, -2 */ + UINT64_C( 0x3FFE000000000000 ), /* positive, -1 */ + UINT64_C( 0x3FFF000000000000 ), /* positive, 0 */ + UINT64_C( 0x4000000000000000 ), /* positive, 1 */ + UINT64_C( 0x4001000000000000 ), /* positive, 2 */ + UINT64_C( 0x4002000000000000 ), /* positive, 3 */ + UINT64_C( 0x4003000000000000 ), /* positive, 4 */ + UINT64_C( 0x401C000000000000 ), /* positive, 29 */ + UINT64_C( 0x401D000000000000 ), /* positive, 30 */ + UINT64_C( 0x401E000000000000 ), /* positive, 31 */ + UINT64_C( 0x401F000000000000 ), /* positive, 32 */ + UINT64_C( 0x403C000000000000 ), /* positive, 61 */ + UINT64_C( 0x403D000000000000 ), /* positive, 62 */ + UINT64_C( 0x403E000000000000 ), /* positive, 63 */ + UINT64_C( 0x403F000000000000 ), /* positive, 64 */ + UINT64_C( 0x4070000000000000 ), /* positive, 113 */ + UINT64_C( 0x407E000000000000 ), /* positive, 127 */ + UINT64_C( 0x407F000000000000 ), /* positive, 128 */ + UINT64_C( 0x4080000000000000 ), /* positive, 129 */ + UINT64_C( 0x43FE000000000000 ), /* positive, 1023 */ + UINT64_C( 0x43FF000000000000 ), /* positive, 1024 */ + UINT64_C( 0x4400000000000000 ), /* positive, 1025 */ + UINT64_C( 0x7FFD000000000000 ), /* positive, 16382 */ + UINT64_C( 0x7FFE000000000000 ), /* positive, 16383 */ + UINT64_C( 0x7FFF000000000000 ), /* positive, infinity or NaN */ + UINT64_C( 0x8000000000000000 ), /* negative, subnormal */ + UINT64_C( 0x8001000000000000 ), /* negative, -16382 */ + UINT64_C( 0x8002000000000000 ), /* negative, -16381 */ + UINT64_C( 0xBBFE000000000000 ), /* negative, -1025 */ + UINT64_C( 0xBBFF000000000000 ), /* negative, -1024 */ + UINT64_C( 0xBC00000000000000 ), /* negative, -1023 */ + UINT64_C( 0xBC01000000000000 ), /* negative, -1022 */ + UINT64_C( 0xBF7E000000000000 ), /* negative, -129 */ + UINT64_C( 0xBF7F000000000000 ), /* negative, -128 */ + UINT64_C( 0xBF80000000000000 ), /* negative, -127 */ + UINT64_C( 0xBF81000000000000 ), /* negative, -126 */ + UINT64_C( 0xBF8E000000000000 ), /* negative, -113 */ + UINT64_C( 0xBFFB000000000000 ), /* negative, -4 */ + UINT64_C( 0xBFFC000000000000 ), /* negative, -3 */ + UINT64_C( 0xBFFD000000000000 ), /* negative, -2 */ + UINT64_C( 0xBFFE000000000000 ), /* negative, -1 */ + UINT64_C( 0xBFFF000000000000 ), /* negative, 0 */ + UINT64_C( 0xC000000000000000 ), /* negative, 1 */ + UINT64_C( 0xC001000000000000 ), /* negative, 2 */ + UINT64_C( 0xC002000000000000 ), /* negative, 3 */ + UINT64_C( 0xC003000000000000 ), /* negative, 4 */ + UINT64_C( 0xC01C000000000000 ), /* negative, 29 */ + UINT64_C( 0xC01D000000000000 ), /* negative, 30 */ + UINT64_C( 0xC01E000000000000 ), /* negative, 31 */ + UINT64_C( 0xC01F000000000000 ), /* negative, 32 */ + UINT64_C( 0xC03C000000000000 ), /* negative, 61 */ + UINT64_C( 0xC03D000000000000 ), /* negative, 62 */ + UINT64_C( 0xC03E000000000000 ), /* negative, 63 */ + UINT64_C( 0xC03F000000000000 ), /* negative, 64 */ + UINT64_C( 0xC070000000000000 ), /* negative, 113 */ + UINT64_C( 0xC07E000000000000 ), /* negative, 127 */ + UINT64_C( 0xC07F000000000000 ), /* negative, 128 */ + UINT64_C( 0xC080000000000000 ), /* negative, 129 */ + UINT64_C( 0xC3FE000000000000 ), /* negative, 1023 */ + UINT64_C( 0xC3FF000000000000 ), /* negative, 1024 */ + UINT64_C( 0xC400000000000000 ), /* negative, 1025 */ + UINT64_C( 0xFFFD000000000000 ), /* negative, 16382 */ + UINT64_C( 0xFFFE000000000000 ), /* negative, 16383 */ + UINT64_C( 0xFFFF000000000000 ) /* negative, infinity or NaN */ +}; +static const struct { uint64_t v64, v0; } f128P1[f128NumP1] = { + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000001 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFE ) } +}; +static const struct { uint64_t v64, v0; } f128P2[f128NumP2] = { + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000001 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000002 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000004 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000008 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000010 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000020 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000040 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000080 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000100 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000200 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000400 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000800 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000001000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000002000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000004000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000008000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000010000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000020000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000040000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000080000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000100000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000200000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000400000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000800000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000001000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000002000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000004000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000008000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000010000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000020000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000040000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000080000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000100000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000200000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000400000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000800000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000001000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000002000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000004000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000008000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000010000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000020000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000040000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000080000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000100000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000200000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000400000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000800000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0001000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0002000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0004000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0008000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0010000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0020000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0040000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0080000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0100000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0200000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0400000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0800000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x1000000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x2000000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x4000000000000000 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x8000000000000000 ) }, + { UINT64_C( 0x0000000000000001 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000002 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000004 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000008 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000010 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000020 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000040 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000080 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000100 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000200 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000400 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000000800 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000001000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000002000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000004000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000008000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000010000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000020000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000040000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000080000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000100000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000200000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000400000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000000800000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000001000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000002000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000004000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000008000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000010000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000020000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000040000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000080000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000100000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000200000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000400000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000000800000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000001000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000002000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000004000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000008000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000010000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000020000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000040000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000080000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000100000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000200000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000400000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000800000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000C00000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000E00000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000F00000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000F80000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FC0000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FE0000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FF0000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FF8000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFC000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFE000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFF000000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFF800000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFC00000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFE00000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFF00000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFF80000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFC0000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFE0000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFF0000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFF8000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFC000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFE000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFF000000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFF800000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFC00000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFE00000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFF00000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFF80000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFC0000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFE0000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFF0000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFF8000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFC000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFE000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFF000 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFF800 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFC00 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFE00 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFF00 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFF80 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFC0 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFE0 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFF0 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFF8 ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFC ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFE ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0x0000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0x8000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xC000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xE000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xF000000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xF800000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFC00000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFE00000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFF00000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFF80000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFC0000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFE0000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFF0000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFF8000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFC000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFE000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFF000000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFF800000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFC00000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFE00000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFF00000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFF80000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFC0000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFE0000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFF0000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFF8000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFC000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFE000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFF000000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFF800000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFC00000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFE00000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFF00000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFF80000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFC0000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFE0000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFF0000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFF8000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFC000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFE000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFF000000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFF800000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFC00000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFE00000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFF00000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFF80000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFC0000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFE0000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFF0000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFF8000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFC000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFE000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFF000 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFF800 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFC00 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFE00 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFF00 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFF80 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFC0 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFE0 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFF0 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFF8 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFC ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFE ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFD ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFB ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFF7 ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFEF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFDF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFBF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFF7F ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFEFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFDFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFBFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFF7FF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFEFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFDFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFBFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFF7FFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFEFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFDFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFBFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFF7FFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFEFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFDFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFBFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFF7FFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFEFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFDFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFBFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFF7FFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFEFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFDFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFBFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFF7FFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFEFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFDFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFBFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFF7FFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFEFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFDFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFFBFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFF7FFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFEFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFDFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFFBFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFF7FFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFEFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFDFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFFBFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFF7FFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFEFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFDFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFFBFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFF7FFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFEFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFDFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFFBFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFF7FFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFEFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFDFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xFBFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xF7FFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xEFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xDFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0xBFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFF ), UINT64_C( 0x7FFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFD ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFFB ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFF7 ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFEF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFDF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFFBF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFF7F ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFEFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFDFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFFBFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFF7FF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFEFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFDFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFFBFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFF7FFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFEFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFDFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFFBFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFF7FFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFEFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFDFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFFBFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFF7FFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFEFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFDFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFFBFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFF7FFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFEFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFDFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFFBFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFF7FFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFEFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFDFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFFBFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFF7FFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFEFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFDFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FFBFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FF7FFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FEFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FDFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000FBFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000F7FFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000EFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000DFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000BFFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00007FFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00003FFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00001FFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000FFFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000007FFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000003FFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000001FFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000FFFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000007FFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000003FFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000001FFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000FFFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000007FFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000003FFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000001FFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000FFFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000007FFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000003FFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000001FFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000FFFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000007FFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000003FFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000001FFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000FFFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000007FFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000003FFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000001FFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000000FFFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000007FFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000003FFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000001FFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000000FFFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000007FFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000003FFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000001FFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000FFF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000000007FF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000000003FF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000000001FF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x00000000000000FF ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000000007F ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000000003F ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000000001F ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x000000000000000F ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000007 ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000003 ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000001 ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0xFFFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x7FFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x3FFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x1FFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0FFFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x07FFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x03FFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x01FFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00FFFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x007FFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x003FFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x001FFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000FFFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0007FFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0003FFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0001FFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000FFFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00007FFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00003FFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00001FFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000FFFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000007FFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000003FFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000001FFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000FFFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000007FFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000003FFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000001FFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000FFFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000007FFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000003FFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000001FFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000FFFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000007FFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000003FFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000001FFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000FFFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000007FFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000003FFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000001FFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000FFFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000007FFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000003FFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000001FFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000000FFFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000007FFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000003FFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000001FFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000000FFFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000007FFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000003FFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000001FFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000FFF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000000007FF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000000003FF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000000001FF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x00000000000000FF ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000000007F ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000000003F ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000000001F ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x000000000000000F ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000007 ) }, + { UINT64_C( 0x0000000000000000 ), UINT64_C( 0x0000000000000003 ) } +}; + +static const uint_fast64_t f128NumQInP1 = f128NumQIn * f128NumP1; +static const uint_fast64_t f128NumQOutP1 = f128NumQOut * f128NumP1; + +static void f128NextQInP1( struct sequence *sequencePtr, float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + int expNum, sigNum; + + uiZPtr = (struct uint128 *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZPtr->v64 = f128QIn[expNum] | f128P1[sigNum].v64; + uiZPtr->v0 = f128P1[sigNum].v0; + ++sigNum; + if ( f128NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f128NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static void f128NextQOutP1( struct sequence *sequencePtr, float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + int expNum, sigNum; + + uiZPtr = (struct uint128 *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZPtr->v64 = f128QOut[expNum] | f128P1[sigNum].v64; + uiZPtr->v0 = f128P1[sigNum].v0; + ++sigNum; + if ( f128NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f128NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static const uint_fast64_t f128NumQInP2 = f128NumQIn * f128NumP2; +static const uint_fast64_t f128NumQOutP2 = f128NumQOut * f128NumP2; + +static void f128NextQInP2( struct sequence *sequencePtr, float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + int expNum, sigNum; + + uiZPtr = (struct uint128 *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZPtr->v64 = f128QIn[expNum] | f128P2[sigNum].v64; + uiZPtr->v0 = f128P2[sigNum].v0; + ++sigNum; + if ( f128NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f128NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static void f128NextQOutP2( struct sequence *sequencePtr, float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + int expNum, sigNum; + + uiZPtr = (struct uint128 *) zPtr; + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uiZPtr->v64 = f128QOut[expNum] | f128P2[sigNum].v64; + uiZPtr->v0 = f128P2[sigNum].v0; + ++sigNum; + if ( f128NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f128NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + +} + +static void f128RandomQOutP3( float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + int sigNum1, sigNum2; + uint_fast64_t sig1_0; + + uiZPtr = (struct uint128 *) zPtr; + sigNum1 = randomN_ui16( f128NumP2 ); + sigNum2 = randomN_ui16( f128NumP2 ); + sig1_0 = f128P2[sigNum1].v0; + uiZPtr->v0 = sig1_0 + f128P2[sigNum2].v0; + uiZPtr->v64 = + f128QOut[randomN_ui8( f128NumQOut )] + | ((f128P2[sigNum1].v64 + f128P2[sigNum2].v64 + (uiZPtr->v0 < sig1_0)) + & UINT64_C( 0x0000FFFFFFFFFFFF )); + +} + +static void f128RandomQOutPInf( float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + + uiZPtr = (struct uint128 *) zPtr; + uiZPtr->v64 = + f128QOut[randomN_ui8( f128NumQOut )] + | (random_ui64() & UINT64_C( 0x0000FFFFFFFFFFFF )); + uiZPtr->v0 = random_ui64(); + +} + +enum { f128NumQInfWeightMasks = 14 }; +static const uint64_t f128QInfWeightMasks[f128NumQInfWeightMasks] = { + UINT64_C( 0xFFFF000000000000 ), + UINT64_C( 0xFFFF000000000000 ), + UINT64_C( 0xBFFF000000000000 ), + UINT64_C( 0x9FFF000000000000 ), + UINT64_C( 0x87FF000000000000 ), + UINT64_C( 0x87FF000000000000 ), + UINT64_C( 0x83FF000000000000 ), + UINT64_C( 0x81FF000000000000 ), + UINT64_C( 0x80FF000000000000 ), + UINT64_C( 0x807F000000000000 ), + UINT64_C( 0x803F000000000000 ), + UINT64_C( 0x801F000000000000 ), + UINT64_C( 0x800F000000000000 ), + UINT64_C( 0x8007000000000000 ) +}; +static const uint64_t f128QInfWeightOffsets[f128NumQInfWeightMasks] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x2000000000000000 ), + UINT64_C( 0x3000000000000000 ), + UINT64_C( 0x3800000000000000 ), + UINT64_C( 0x3C00000000000000 ), + UINT64_C( 0x3E00000000000000 ), + UINT64_C( 0x3F00000000000000 ), + UINT64_C( 0x3F80000000000000 ), + UINT64_C( 0x3FC0000000000000 ), + UINT64_C( 0x3FE0000000000000 ), + UINT64_C( 0x3FF0000000000000 ), + UINT64_C( 0x3FF8000000000000 ), + UINT64_C( 0x3FFC000000000000 ) +}; + +static void f128RandomQInfP3( float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + int sigNum1, sigNum2; + uint_fast64_t sig1_0; + int weightMaskNum; + + uiZPtr = (struct uint128 *) zPtr; + sigNum1 = randomN_ui16( f128NumP2 ); + sigNum2 = randomN_ui16( f128NumP2 ); + sig1_0 = f128P2[sigNum1].v0; + uiZPtr->v0 = sig1_0 + f128P2[sigNum2].v0; + weightMaskNum = randomN_ui8( f128NumQInfWeightMasks ); + uiZPtr->v64 = + (((uint_fast64_t) random_ui16()<<48 + & f128QInfWeightMasks[weightMaskNum]) + + f128QInfWeightOffsets[weightMaskNum]) + | ((f128P2[sigNum1].v64 + f128P2[sigNum2].v64 + (uiZPtr->v0 < sig1_0)) + & UINT64_C( 0x0000FFFFFFFFFFFF )); + +} + +static void f128RandomQInfPInf( float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + int weightMaskNum; + + uiZPtr = (struct uint128 *) zPtr; + weightMaskNum = randomN_ui8( f128NumQInfWeightMasks ); + uiZPtr->v64 = + (random_ui64() + & (f128QInfWeightMasks[weightMaskNum] + | UINT64_C( 0x0000FFFFFFFFFFFF ))) + + f128QInfWeightOffsets[weightMaskNum]; + uiZPtr->v0 = random_ui64(); + +} + +static void f128Random( float128_t *zPtr ) +{ + + switch ( random_ui8() & 7 ) { + case 0: + case 1: + case 2: + f128RandomQOutP3( zPtr ); + break; + case 3: + f128RandomQOutPInf( zPtr ); + break; + case 4: + case 5: + case 6: + f128RandomQInfP3( zPtr ); + break; + case 7: + f128RandomQInfPInf( zPtr ); + break; + } + +} + +static struct sequence sequenceA, sequenceB, sequenceC; +static float128_t currentA, currentB, currentC; +static int subcase; + +float128_t genCases_f128_a, genCases_f128_b, genCases_f128_c; + +void genCases_f128_a_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = + (genCases_level == 1) ? 3 * f128NumQOutP1 : 2 * f128NumQOutP2; + genCases_done = false; + +} + +void genCases_f128_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + case 1: + f128Random( &genCases_f128_a ); + break; + case 2: + f128NextQOutP1( &sequenceA, &genCases_f128_a ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + f128Random( &genCases_f128_a ); + break; + case 1: + f128NextQOutP2( &sequenceA, &genCases_f128_a ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f128_ab_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 6 * f128NumQInP1 * f128NumQInP1; + f128NextQInP1( &sequenceA, ¤tA ); + } else { + genCases_total = 2 * f128NumQInP2 * f128NumQInP2; + f128NextQInP2( &sequenceA, ¤tA ); + } + genCases_done = false; + +} + +void genCases_f128_ab_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceB.done ) { + sequenceB.done = false; + f128NextQInP1( &sequenceA, ¤tA ); + } + f128NextQInP1( &sequenceB, ¤tB ); + case 2: + case 4: + f128Random( &genCases_f128_a ); + f128Random( &genCases_f128_b ); + break; + case 1: + genCases_f128_a = currentA; + f128Random( &genCases_f128_b ); + break; + case 3: + f128Random( &genCases_f128_a ); + genCases_f128_b = currentB; + break; + case 5: + genCases_f128_a = currentA; + genCases_f128_b = currentB; + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + f128Random( &genCases_f128_a ); + f128Random( &genCases_f128_b ); + break; + case 1: + if ( sequenceB.done ) { + sequenceB.done = false; + f128NextQInP2( &sequenceA, ¤tA ); + } + genCases_f128_a = currentA; + f128NextQInP2( &sequenceB, &genCases_f128_b ); + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f128_abc_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + sequenceC.expNum = 0; + sequenceC.term1Num = 0; + sequenceC.term2Num = 0; + sequenceC.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 9 * f128NumQInP1 * f128NumQInP1 * f128NumQInP1; + f128NextQInP1( &sequenceA, ¤tA ); + f128NextQInP1( &sequenceB, ¤tB ); + } else { + genCases_total = 2 * f128NumQInP2 * f128NumQInP2 * f128NumQInP2; + f128NextQInP2( &sequenceA, ¤tA ); + f128NextQInP2( &sequenceB, ¤tB ); + } + genCases_done = false; + +} + +void genCases_f128_abc_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + f128NextQInP1( &sequenceA, ¤tA ); + } + f128NextQInP1( &sequenceB, ¤tB ); + } + f128NextQInP1( &sequenceC, ¤tC ); + f128Random( &genCases_f128_a ); + f128Random( &genCases_f128_b ); + genCases_f128_c = currentC; + break; + case 1: + genCases_f128_a = currentA; + genCases_f128_b = currentB; + f128Random( &genCases_f128_c ); + break; + case 2: + f128Random( &genCases_f128_a ); + f128Random( &genCases_f128_b ); + f128Random( &genCases_f128_c ); + break; + case 3: + f128Random( &genCases_f128_a ); + genCases_f128_b = currentB; + genCases_f128_c = currentC; + break; + case 4: + genCases_f128_a = currentA; + f128Random( &genCases_f128_b ); + f128Random( &genCases_f128_c ); + break; + case 5: + f128Random( &genCases_f128_a ); + genCases_f128_b = currentB; + f128Random( &genCases_f128_c ); + break; + case 6: + genCases_f128_a = currentA; + f128Random( &genCases_f128_b ); + genCases_f128_c = currentC; + break; + case 7: + f128Random( &genCases_f128_a ); + f128Random( &genCases_f128_b ); + f128Random( &genCases_f128_c ); + break; + case 8: + genCases_f128_a = currentA; + genCases_f128_b = currentB; + genCases_f128_c = currentC; + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + f128Random( &genCases_f128_a ); + f128Random( &genCases_f128_b ); + f128Random( &genCases_f128_c ); + break; + case 1: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + f128NextQInP2( &sequenceA, ¤tA ); + } + f128NextQInP2( &sequenceB, ¤tB ); + } + genCases_f128_a = currentA; + genCases_f128_b = currentB; + f128NextQInP2( &sequenceC, &genCases_f128_c ); + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +#endif + diff --git a/source/genCases_f32.c b/source/genCases_f32.c new file mode 100644 index 0000000..e81dd89 --- /dev/null +++ b/source/genCases_f32.c @@ -0,0 +1,661 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" +#include "softfloat.h" +#include "genCases.h" + +struct sequence { + int expNum, term1Num, term2Num; + bool done; +}; + +union ui32_f32 { uint32_t ui; float32_t f; }; + +enum { + f32NumQIn = 22, + f32NumQOut = 50, + f32NumP1 = 4, + f32NumP2 = 88 +}; +static const uint32_t f32QIn[f32NumQIn] = { + 0x00000000, /* positive, subnormal */ + 0x00800000, /* positive, -126 */ + 0x33800000, /* positive, -24 */ + 0x3E800000, /* positive, -2 */ + 0x3F000000, /* positive, -1 */ + 0x3F800000, /* positive, 0 */ + 0x40000000, /* positive, 1 */ + 0x40800000, /* positive, 2 */ + 0x4B800000, /* positive, 24 */ + 0x7F000000, /* positive, 127 */ + 0x7F800000, /* positive, infinity or NaN */ + 0x80000000, /* negative, subnormal */ + 0x80800000, /* negative, -126 */ + 0xB3800000, /* negative, -24 */ + 0xBE800000, /* negative, -2 */ + 0xBF000000, /* negative, -1 */ + 0xBF800000, /* negative, 0 */ + 0xC0000000, /* negative, 1 */ + 0xC0800000, /* negative, 2 */ + 0xCB800000, /* negative, 24 */ + 0xFE800000, /* negative, 126 */ + 0xFF800000 /* negative, infinity or NaN */ +}; +static const uint32_t f32QOut[f32NumQOut] = { + 0x00000000, /* positive, subnormal */ + 0x00800000, /* positive, -126 */ + 0x01000000, /* positive, -125 */ + 0x33800000, /* positive, -24 */ + 0x3D800000, /* positive, -4 */ + 0x3E000000, /* positive, -3 */ + 0x3E800000, /* positive, -2 */ + 0x3F000000, /* positive, -1 */ + 0x3F800000, /* positive, 0 */ + 0x40000000, /* positive, 1 */ + 0x40800000, /* positive, 2 */ + 0x41000000, /* positive, 3 */ + 0x41800000, /* positive, 4 */ + 0x4B800000, /* positive, 24 */ + 0x4E000000, /* positive, 29 */ + 0x4E800000, /* positive, 30 */ + 0x4F000000, /* positive, 31 */ + 0x4F800000, /* positive, 32 */ + 0x5E000000, /* positive, 61 */ + 0x5E800000, /* positive, 62 */ + 0x5F000000, /* positive, 63 */ + 0x5F800000, /* positive, 64 */ + 0x7E800000, /* positive, 126 */ + 0x7F000000, /* positive, 127 */ + 0x7F800000, /* positive, infinity or NaN */ + 0x80000000, /* negative, subnormal */ + 0x80800000, /* negative, -126 */ + 0x81000000, /* negative, -125 */ + 0xB3800000, /* negative, -24 */ + 0xBD800000, /* negative, -4 */ + 0xBE000000, /* negative, -3 */ + 0xBE800000, /* negative, -2 */ + 0xBF000000, /* negative, -1 */ + 0xBF800000, /* negative, 0 */ + 0xC0000000, /* negative, 1 */ + 0xC0800000, /* negative, 2 */ + 0xC1000000, /* negative, 3 */ + 0xC1800000, /* negative, 4 */ + 0xCB800000, /* negative, 24 */ + 0xCE000000, /* negative, 29 */ + 0xCE800000, /* negative, 30 */ + 0xCF000000, /* negative, 31 */ + 0xCF800000, /* negative, 32 */ + 0xDE000000, /* negative, 61 */ + 0xDE800000, /* negative, 62 */ + 0xDF000000, /* negative, 63 */ + 0xDF800000, /* negative, 64 */ + 0xFE800000, /* negative, 126 */ + 0xFF000000, /* negative, 127 */ + 0xFF800000 /* negative, infinity or NaN */ +}; +static const uint32_t f32P1[f32NumP1] = { + 0x00000000, + 0x00000001, + 0x007FFFFF, + 0x007FFFFE +}; +static const uint32_t f32P2[f32NumP2] = { + 0x00000000, + 0x00000001, + 0x00000002, + 0x00000004, + 0x00000008, + 0x00000010, + 0x00000020, + 0x00000040, + 0x00000080, + 0x00000100, + 0x00000200, + 0x00000400, + 0x00000800, + 0x00001000, + 0x00002000, + 0x00004000, + 0x00008000, + 0x00010000, + 0x00020000, + 0x00040000, + 0x00080000, + 0x00100000, + 0x00200000, + 0x00400000, + 0x00600000, + 0x00700000, + 0x00780000, + 0x007C0000, + 0x007E0000, + 0x007F0000, + 0x007F8000, + 0x007FC000, + 0x007FE000, + 0x007FF000, + 0x007FF800, + 0x007FFC00, + 0x007FFE00, + 0x007FFF00, + 0x007FFF80, + 0x007FFFC0, + 0x007FFFE0, + 0x007FFFF0, + 0x007FFFF8, + 0x007FFFFC, + 0x007FFFFE, + 0x007FFFFF, + 0x007FFFFD, + 0x007FFFFB, + 0x007FFFF7, + 0x007FFFEF, + 0x007FFFDF, + 0x007FFFBF, + 0x007FFF7F, + 0x007FFEFF, + 0x007FFDFF, + 0x007FFBFF, + 0x007FF7FF, + 0x007FEFFF, + 0x007FDFFF, + 0x007FBFFF, + 0x007F7FFF, + 0x007EFFFF, + 0x007DFFFF, + 0x007BFFFF, + 0x0077FFFF, + 0x006FFFFF, + 0x005FFFFF, + 0x003FFFFF, + 0x001FFFFF, + 0x000FFFFF, + 0x0007FFFF, + 0x0003FFFF, + 0x0001FFFF, + 0x0000FFFF, + 0x00007FFF, + 0x00003FFF, + 0x00001FFF, + 0x00000FFF, + 0x000007FF, + 0x000003FF, + 0x000001FF, + 0x000000FF, + 0x0000007F, + 0x0000003F, + 0x0000001F, + 0x0000000F, + 0x00000007, + 0x00000003 +}; + +static const uint_fast64_t f32NumQInP1 = f32NumQIn * f32NumP1; +static const uint_fast64_t f32NumQOutP1 = f32NumQOut * f32NumP1; + +static float32_t f32NextQInP1( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui32_f32 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f32QIn[expNum] | f32P1[sigNum]; + ++sigNum; + if ( f32NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f32NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float32_t f32NextQOutP1( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui32_f32 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f32QOut[expNum] | f32P1[sigNum]; + ++sigNum; + if ( f32NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f32NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static const uint_fast64_t f32NumQInP2 = f32NumQIn * f32NumP2; +static const uint_fast64_t f32NumQOutP2 = f32NumQOut * f32NumP2; + +static float32_t f32NextQInP2( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui32_f32 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f32QIn[expNum] | f32P2[sigNum]; + ++sigNum; + if ( f32NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f32NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float32_t f32NextQOutP2( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui32_f32 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f32QOut[expNum] | f32P2[sigNum]; + ++sigNum; + if ( f32NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f32NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float32_t f32RandomQOutP3( void ) +{ + union ui32_f32 uZ; + + uZ.ui = + f32QOut[randomN_ui8( f32NumQOut )] + | ((f32P2[randomN_ui8( f32NumP2 )] + f32P2[randomN_ui8( f32NumP2 )]) + & 0x007FFFFF); + return uZ.f; + +} + +static float32_t f32RandomQOutPInf( void ) +{ + union ui32_f32 uZ; + + uZ.ui = f32QOut[randomN_ui8( f32NumQOut )] | (random_ui32() & 0x007FFFFF); + return uZ.f; + +} + +enum { f32NumQInfWeightMasks = 7 }; +static const uint32_t f32QInfWeightMasks[f32NumQInfWeightMasks] = { + 0xFF800000, + 0xFF800000, + 0xBF800000, + 0x9F800000, + 0x8F800000, + 0x87800000, + 0x83800000 +}; +static const uint32_t f32QInfWeightOffsets[f32NumQInfWeightMasks] = { + 0x00000000, + 0x00000000, + 0x20000000, + 0x30000000, + 0x38000000, + 0x3C000000, + 0x3E000000 +}; + +static float32_t f32RandomQInfP3( void ) +{ + int weightMaskNum; + union ui32_f32 uZ; + + weightMaskNum = randomN_ui8( f32NumQInfWeightMasks ); + uZ.ui = + (((uint_fast32_t) random_ui16()<<16 + & f32QInfWeightMasks[weightMaskNum]) + + f32QInfWeightOffsets[weightMaskNum]) + | ((f32P2[randomN_ui8( f32NumP2 )] + f32P2[randomN_ui8( f32NumP2 )]) + & 0x007FFFFF); + return uZ.f; + +} + +static float32_t f32RandomQInfPInf( void ) +{ + int weightMaskNum; + union ui32_f32 uZ; + + weightMaskNum = randomN_ui8( f32NumQInfWeightMasks ); + uZ.ui = + (random_ui32() & (f32QInfWeightMasks[weightMaskNum] | 0x007FFFFF)) + + f32QInfWeightOffsets[weightMaskNum]; + return uZ.f; + +} + +static float32_t f32Random( void ) +{ + + switch ( random_ui8() & 7 ) { + case 0: + case 1: + case 2: + return f32RandomQOutP3(); + case 3: + return f32RandomQOutPInf(); + case 4: + case 5: + case 6: + return f32RandomQInfP3(); + case 7: + return f32RandomQInfPInf(); + } + +} + +static struct sequence sequenceA, sequenceB, sequenceC; +static float32_t currentA, currentB, currentC; +static int subcase; + +float32_t genCases_f32_a, genCases_f32_b, genCases_f32_c; + +void genCases_f32_a_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = + (genCases_level == 1) ? 3 * f32NumQOutP1 : 2 * f32NumQOutP2; + genCases_done = false; + +} + +void genCases_f32_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + case 1: + genCases_f32_a = f32Random(); + break; + case 2: + genCases_f32_a = f32NextQOutP1( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f32_a = f32Random(); + break; + case 1: + genCases_f32_a = f32NextQOutP2( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f32_ab_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 6 * f32NumQInP1 * f32NumQInP1; + currentA = f32NextQInP1( &sequenceA ); + } else { + genCases_total = 2 * f32NumQInP2 * f32NumQInP2; + currentA = f32NextQInP2( &sequenceA ); + } + genCases_done = false; + +} + +void genCases_f32_ab_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f32NextQInP1( &sequenceA ); + } + currentB = f32NextQInP1( &sequenceB ); + case 2: + case 4: + genCases_f32_a = f32Random(); + genCases_f32_b = f32Random(); + break; + case 1: + genCases_f32_a = currentA; + genCases_f32_b = f32Random(); + break; + case 3: + genCases_f32_a = f32Random(); + genCases_f32_b = currentB; + break; + case 5: + genCases_f32_a = currentA; + genCases_f32_b = currentB; + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f32_a = f32Random(); + genCases_f32_b = f32Random(); + break; + case 1: + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f32NextQInP2( &sequenceA ); + } + genCases_f32_a = currentA; + genCases_f32_b = f32NextQInP2( &sequenceB ); + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f32_abc_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + sequenceC.expNum = 0; + sequenceC.term1Num = 0; + sequenceC.term2Num = 0; + sequenceC.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 9 * f32NumQInP1 * f32NumQInP1 * f32NumQInP1; + currentA = f32NextQInP1( &sequenceA ); + currentB = f32NextQInP1( &sequenceB ); + } else { + genCases_total = 2 * f32NumQInP2 * f32NumQInP2 * f32NumQInP2; + currentA = f32NextQInP2( &sequenceA ); + currentB = f32NextQInP2( &sequenceB ); + } + genCases_done = false; + +} + +void genCases_f32_abc_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f32NextQInP1( &sequenceA ); + } + currentB = f32NextQInP1( &sequenceB ); + } + currentC = f32NextQInP1( &sequenceC ); + genCases_f32_a = f32Random(); + genCases_f32_b = f32Random(); + genCases_f32_c = currentC; + break; + case 1: + genCases_f32_a = currentA; + genCases_f32_b = currentB; + genCases_f32_c = f32Random(); + break; + case 2: + genCases_f32_a = f32Random(); + genCases_f32_b = f32Random(); + genCases_f32_c = f32Random(); + break; + case 3: + genCases_f32_a = f32Random(); + genCases_f32_b = currentB; + genCases_f32_c = currentC; + break; + case 4: + genCases_f32_a = currentA; + genCases_f32_b = f32Random(); + genCases_f32_c = f32Random(); + break; + case 5: + genCases_f32_a = f32Random(); + genCases_f32_b = currentB; + genCases_f32_c = f32Random(); + break; + case 6: + genCases_f32_a = currentA; + genCases_f32_b = f32Random(); + genCases_f32_c = currentC; + break; + case 7: + genCases_f32_a = f32Random(); + genCases_f32_b = f32Random(); + genCases_f32_c = f32Random(); + break; + case 8: + genCases_f32_a = currentA; + genCases_f32_b = currentB; + genCases_f32_c = currentC; + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f32_a = f32Random(); + genCases_f32_b = f32Random(); + genCases_f32_c = f32Random(); + break; + case 1: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f32NextQInP2( &sequenceA ); + } + currentB = f32NextQInP2( &sequenceB ); + } + genCases_f32_a = currentA; + genCases_f32_b = currentB; + genCases_f32_c = f32NextQInP2( &sequenceC ); + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } + ++subcase; + +} + diff --git a/source/genCases_f64.c b/source/genCases_f64.c new file mode 100644 index 0000000..cc91fb4 --- /dev/null +++ b/source/genCases_f64.c @@ -0,0 +1,801 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" +#include "softfloat.h" +#include "genCases.h" + +struct sequence { + int expNum, term1Num, term2Num; + bool done; +}; + +union ui64_f64 { uint64_t ui; float64_t f; }; + +enum { + f64NumQIn = 22, + f64NumQOut = 64, + f64NumP1 = 4, + f64NumP2 = 204 +}; +static const uint64_t f64QIn[f64NumQIn] = { + UINT64_C( 0x0000000000000000 ), /* positive, subnormal */ + UINT64_C( 0x0010000000000000 ), /* positive, -1022 */ + UINT64_C( 0x3CA0000000000000 ), /* positive, -53 */ + UINT64_C( 0x3FD0000000000000 ), /* positive, -2 */ + UINT64_C( 0x3FE0000000000000 ), /* positive, -1 */ + UINT64_C( 0x3FF0000000000000 ), /* positive, 0 */ + UINT64_C( 0x4000000000000000 ), /* positive, 1 */ + UINT64_C( 0x4010000000000000 ), /* positive, 2 */ + UINT64_C( 0x4340000000000000 ), /* positive, 53 */ + UINT64_C( 0x7FE0000000000000 ), /* positive, 1023 */ + UINT64_C( 0x7FF0000000000000 ), /* positive, infinity or NaN */ + UINT64_C( 0x8000000000000000 ), /* negative, subnormal */ + UINT64_C( 0x8010000000000000 ), /* negative, -1022 */ + UINT64_C( 0xBCA0000000000000 ), /* negative, -53 */ + UINT64_C( 0xBFD0000000000000 ), /* negative, -2 */ + UINT64_C( 0xBFE0000000000000 ), /* negative, -1 */ + UINT64_C( 0xBFF0000000000000 ), /* negative, 0 */ + UINT64_C( 0xC000000000000000 ), /* negative, 1 */ + UINT64_C( 0xC010000000000000 ), /* negative, 2 */ + UINT64_C( 0xC340000000000000 ), /* negative, 53 */ + UINT64_C( 0xFFE0000000000000 ), /* negative, 1023 */ + UINT64_C( 0xFFF0000000000000 ) /* negative, infinity or NaN */ +}; +static const uint64_t f64QOut[f64NumQOut] = { + UINT64_C( 0x0000000000000000 ), /* positive, subnormal */ + UINT64_C( 0x0010000000000000 ), /* positive, -1022 */ + UINT64_C( 0x0020000000000000 ), /* positive, -1021 */ + UINT64_C( 0x37E0000000000000 ), /* positive, -129 */ + UINT64_C( 0x37F0000000000000 ), /* positive, -128 */ + UINT64_C( 0x3800000000000000 ), /* positive, -127 */ + UINT64_C( 0x3810000000000000 ), /* positive, -126 */ + UINT64_C( 0x3CA0000000000000 ), /* positive, -53 */ + UINT64_C( 0x3FB0000000000000 ), /* positive, -4 */ + UINT64_C( 0x3FC0000000000000 ), /* positive, -3 */ + UINT64_C( 0x3FD0000000000000 ), /* positive, -2 */ + UINT64_C( 0x3FE0000000000000 ), /* positive, -1 */ + UINT64_C( 0x3FF0000000000000 ), /* positive, 0 */ + UINT64_C( 0x4000000000000000 ), /* positive, 1 */ + UINT64_C( 0x4010000000000000 ), /* positive, 2 */ + UINT64_C( 0x4020000000000000 ), /* positive, 3 */ + UINT64_C( 0x4030000000000000 ), /* positive, 4 */ + UINT64_C( 0x41C0000000000000 ), /* positive, 29 */ + UINT64_C( 0x41D0000000000000 ), /* positive, 30 */ + UINT64_C( 0x41E0000000000000 ), /* positive, 31 */ + UINT64_C( 0x41F0000000000000 ), /* positive, 32 */ + UINT64_C( 0x4340000000000000 ), /* positive, 53 */ + UINT64_C( 0x43C0000000000000 ), /* positive, 61 */ + UINT64_C( 0x43D0000000000000 ), /* positive, 62 */ + UINT64_C( 0x43E0000000000000 ), /* positive, 63 */ + UINT64_C( 0x43F0000000000000 ), /* positive, 64 */ + UINT64_C( 0x47E0000000000000 ), /* positive, 127 */ + UINT64_C( 0x47F0000000000000 ), /* positive, 128 */ + UINT64_C( 0x4800000000000000 ), /* positive, 129 */ + UINT64_C( 0x7FD0000000000000 ), /* positive, 1022 */ + UINT64_C( 0x7FE0000000000000 ), /* positive, 1023 */ + UINT64_C( 0x7FF0000000000000 ), /* positive, infinity or NaN */ + UINT64_C( 0x8000000000000000 ), /* negative, subnormal */ + UINT64_C( 0x8010000000000000 ), /* negative, -1022 */ + UINT64_C( 0x8020000000000000 ), /* negative, -1021 */ + UINT64_C( 0xB7E0000000000000 ), /* negative, -129 */ + UINT64_C( 0xB7F0000000000000 ), /* negative, -128 */ + UINT64_C( 0xB800000000000000 ), /* negative, -127 */ + UINT64_C( 0xB810000000000000 ), /* negative, -126 */ + UINT64_C( 0xBCA0000000000000 ), /* negative, -53 */ + UINT64_C( 0xBFB0000000000000 ), /* negative, -4 */ + UINT64_C( 0xBFC0000000000000 ), /* negative, -3 */ + UINT64_C( 0xBFD0000000000000 ), /* negative, -2 */ + UINT64_C( 0xBFE0000000000000 ), /* negative, -1 */ + UINT64_C( 0xBFF0000000000000 ), /* negative, 0 */ + UINT64_C( 0xC000000000000000 ), /* negative, 1 */ + UINT64_C( 0xC010000000000000 ), /* negative, 2 */ + UINT64_C( 0xC020000000000000 ), /* negative, 3 */ + UINT64_C( 0xC030000000000000 ), /* negative, 4 */ + UINT64_C( 0xC1C0000000000000 ), /* negative, 29 */ + UINT64_C( 0xC1D0000000000000 ), /* negative, 30 */ + UINT64_C( 0xC1E0000000000000 ), /* negative, 31 */ + UINT64_C( 0xC1F0000000000000 ), /* negative, 32 */ + UINT64_C( 0xC340000000000000 ), /* negative, 53 */ + UINT64_C( 0xC3C0000000000000 ), /* negative, 61 */ + UINT64_C( 0xC3D0000000000000 ), /* negative, 62 */ + UINT64_C( 0xC3E0000000000000 ), /* negative, 63 */ + UINT64_C( 0xC3F0000000000000 ), /* negative, 64 */ + UINT64_C( 0xC7E0000000000000 ), /* negative, 127 */ + UINT64_C( 0xC7F0000000000000 ), /* negative, 128 */ + UINT64_C( 0xC800000000000000 ), /* negative, 129 */ + UINT64_C( 0xFFD0000000000000 ), /* negative, 1022 */ + UINT64_C( 0xFFE0000000000000 ), /* negative, 1023 */ + UINT64_C( 0xFFF0000000000000 ) /* negative, infinity or NaN */ +}; +static const uint64_t f64P1[f64NumP1] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000001 ), + UINT64_C( 0x000FFFFFFFFFFFFF ), + UINT64_C( 0x000FFFFFFFFFFFFE ) +}; +static const uint64_t f64P2[f64NumP2] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000001 ), + UINT64_C( 0x0000000000000002 ), + UINT64_C( 0x0000000000000004 ), + UINT64_C( 0x0000000000000008 ), + UINT64_C( 0x0000000000000010 ), + UINT64_C( 0x0000000000000020 ), + UINT64_C( 0x0000000000000040 ), + UINT64_C( 0x0000000000000080 ), + UINT64_C( 0x0000000000000100 ), + UINT64_C( 0x0000000000000200 ), + UINT64_C( 0x0000000000000400 ), + UINT64_C( 0x0000000000000800 ), + UINT64_C( 0x0000000000001000 ), + UINT64_C( 0x0000000000002000 ), + UINT64_C( 0x0000000000004000 ), + UINT64_C( 0x0000000000008000 ), + UINT64_C( 0x0000000000010000 ), + UINT64_C( 0x0000000000020000 ), + UINT64_C( 0x0000000000040000 ), + UINT64_C( 0x0000000000080000 ), + UINT64_C( 0x0000000000100000 ), + UINT64_C( 0x0000000000200000 ), + UINT64_C( 0x0000000000400000 ), + UINT64_C( 0x0000000000800000 ), + UINT64_C( 0x0000000001000000 ), + UINT64_C( 0x0000000002000000 ), + UINT64_C( 0x0000000004000000 ), + UINT64_C( 0x0000000008000000 ), + UINT64_C( 0x0000000010000000 ), + UINT64_C( 0x0000000020000000 ), + UINT64_C( 0x0000000040000000 ), + UINT64_C( 0x0000000080000000 ), + UINT64_C( 0x0000000100000000 ), + UINT64_C( 0x0000000200000000 ), + UINT64_C( 0x0000000400000000 ), + UINT64_C( 0x0000000800000000 ), + UINT64_C( 0x0000001000000000 ), + UINT64_C( 0x0000002000000000 ), + UINT64_C( 0x0000004000000000 ), + UINT64_C( 0x0000008000000000 ), + UINT64_C( 0x0000010000000000 ), + UINT64_C( 0x0000020000000000 ), + UINT64_C( 0x0000040000000000 ), + UINT64_C( 0x0000080000000000 ), + UINT64_C( 0x0000100000000000 ), + UINT64_C( 0x0000200000000000 ), + UINT64_C( 0x0000400000000000 ), + UINT64_C( 0x0000800000000000 ), + UINT64_C( 0x0001000000000000 ), + UINT64_C( 0x0002000000000000 ), + UINT64_C( 0x0004000000000000 ), + UINT64_C( 0x0008000000000000 ), + UINT64_C( 0x000C000000000000 ), + UINT64_C( 0x000E000000000000 ), + UINT64_C( 0x000F000000000000 ), + UINT64_C( 0x000F800000000000 ), + UINT64_C( 0x000FC00000000000 ), + UINT64_C( 0x000FE00000000000 ), + UINT64_C( 0x000FF00000000000 ), + UINT64_C( 0x000FF80000000000 ), + UINT64_C( 0x000FFC0000000000 ), + UINT64_C( 0x000FFE0000000000 ), + UINT64_C( 0x000FFF0000000000 ), + UINT64_C( 0x000FFF8000000000 ), + UINT64_C( 0x000FFFC000000000 ), + UINT64_C( 0x000FFFE000000000 ), + UINT64_C( 0x000FFFF000000000 ), + UINT64_C( 0x000FFFF800000000 ), + UINT64_C( 0x000FFFFC00000000 ), + UINT64_C( 0x000FFFFE00000000 ), + UINT64_C( 0x000FFFFF00000000 ), + UINT64_C( 0x000FFFFF80000000 ), + UINT64_C( 0x000FFFFFC0000000 ), + UINT64_C( 0x000FFFFFE0000000 ), + UINT64_C( 0x000FFFFFF0000000 ), + UINT64_C( 0x000FFFFFF8000000 ), + UINT64_C( 0x000FFFFFFC000000 ), + UINT64_C( 0x000FFFFFFE000000 ), + UINT64_C( 0x000FFFFFFF000000 ), + UINT64_C( 0x000FFFFFFF800000 ), + UINT64_C( 0x000FFFFFFFC00000 ), + UINT64_C( 0x000FFFFFFFE00000 ), + UINT64_C( 0x000FFFFFFFF00000 ), + UINT64_C( 0x000FFFFFFFF80000 ), + UINT64_C( 0x000FFFFFFFFC0000 ), + UINT64_C( 0x000FFFFFFFFE0000 ), + UINT64_C( 0x000FFFFFFFFF0000 ), + UINT64_C( 0x000FFFFFFFFF8000 ), + UINT64_C( 0x000FFFFFFFFFC000 ), + UINT64_C( 0x000FFFFFFFFFE000 ), + UINT64_C( 0x000FFFFFFFFFF000 ), + UINT64_C( 0x000FFFFFFFFFF800 ), + UINT64_C( 0x000FFFFFFFFFFC00 ), + UINT64_C( 0x000FFFFFFFFFFE00 ), + UINT64_C( 0x000FFFFFFFFFFF00 ), + UINT64_C( 0x000FFFFFFFFFFF80 ), + UINT64_C( 0x000FFFFFFFFFFFC0 ), + UINT64_C( 0x000FFFFFFFFFFFE0 ), + UINT64_C( 0x000FFFFFFFFFFFF0 ), + UINT64_C( 0x000FFFFFFFFFFFF8 ), + UINT64_C( 0x000FFFFFFFFFFFFC ), + UINT64_C( 0x000FFFFFFFFFFFFE ), + UINT64_C( 0x000FFFFFFFFFFFFF ), + UINT64_C( 0x000FFFFFFFFFFFFD ), + UINT64_C( 0x000FFFFFFFFFFFFB ), + UINT64_C( 0x000FFFFFFFFFFFF7 ), + UINT64_C( 0x000FFFFFFFFFFFEF ), + UINT64_C( 0x000FFFFFFFFFFFDF ), + UINT64_C( 0x000FFFFFFFFFFFBF ), + UINT64_C( 0x000FFFFFFFFFFF7F ), + UINT64_C( 0x000FFFFFFFFFFEFF ), + UINT64_C( 0x000FFFFFFFFFFDFF ), + UINT64_C( 0x000FFFFFFFFFFBFF ), + UINT64_C( 0x000FFFFFFFFFF7FF ), + UINT64_C( 0x000FFFFFFFFFEFFF ), + UINT64_C( 0x000FFFFFFFFFDFFF ), + UINT64_C( 0x000FFFFFFFFFBFFF ), + UINT64_C( 0x000FFFFFFFFF7FFF ), + UINT64_C( 0x000FFFFFFFFEFFFF ), + UINT64_C( 0x000FFFFFFFFDFFFF ), + UINT64_C( 0x000FFFFFFFFBFFFF ), + UINT64_C( 0x000FFFFFFFF7FFFF ), + UINT64_C( 0x000FFFFFFFEFFFFF ), + UINT64_C( 0x000FFFFFFFDFFFFF ), + UINT64_C( 0x000FFFFFFFBFFFFF ), + UINT64_C( 0x000FFFFFFF7FFFFF ), + UINT64_C( 0x000FFFFFFEFFFFFF ), + UINT64_C( 0x000FFFFFFDFFFFFF ), + UINT64_C( 0x000FFFFFFBFFFFFF ), + UINT64_C( 0x000FFFFFF7FFFFFF ), + UINT64_C( 0x000FFFFFEFFFFFFF ), + UINT64_C( 0x000FFFFFDFFFFFFF ), + UINT64_C( 0x000FFFFFBFFFFFFF ), + UINT64_C( 0x000FFFFF7FFFFFFF ), + UINT64_C( 0x000FFFFEFFFFFFFF ), + UINT64_C( 0x000FFFFDFFFFFFFF ), + UINT64_C( 0x000FFFFBFFFFFFFF ), + UINT64_C( 0x000FFFF7FFFFFFFF ), + UINT64_C( 0x000FFFEFFFFFFFFF ), + UINT64_C( 0x000FFFDFFFFFFFFF ), + UINT64_C( 0x000FFFBFFFFFFFFF ), + UINT64_C( 0x000FFF7FFFFFFFFF ), + UINT64_C( 0x000FFEFFFFFFFFFF ), + UINT64_C( 0x000FFDFFFFFFFFFF ), + UINT64_C( 0x000FFBFFFFFFFFFF ), + UINT64_C( 0x000FF7FFFFFFFFFF ), + UINT64_C( 0x000FEFFFFFFFFFFF ), + UINT64_C( 0x000FDFFFFFFFFFFF ), + UINT64_C( 0x000FBFFFFFFFFFFF ), + UINT64_C( 0x000F7FFFFFFFFFFF ), + UINT64_C( 0x000EFFFFFFFFFFFF ), + UINT64_C( 0x000DFFFFFFFFFFFF ), + UINT64_C( 0x000BFFFFFFFFFFFF ), + UINT64_C( 0x0007FFFFFFFFFFFF ), + UINT64_C( 0x0003FFFFFFFFFFFF ), + UINT64_C( 0x0001FFFFFFFFFFFF ), + UINT64_C( 0x0000FFFFFFFFFFFF ), + UINT64_C( 0x00007FFFFFFFFFFF ), + UINT64_C( 0x00003FFFFFFFFFFF ), + UINT64_C( 0x00001FFFFFFFFFFF ), + UINT64_C( 0x00000FFFFFFFFFFF ), + UINT64_C( 0x000007FFFFFFFFFF ), + UINT64_C( 0x000003FFFFFFFFFF ), + UINT64_C( 0x000001FFFFFFFFFF ), + UINT64_C( 0x000000FFFFFFFFFF ), + UINT64_C( 0x0000007FFFFFFFFF ), + UINT64_C( 0x0000003FFFFFFFFF ), + UINT64_C( 0x0000001FFFFFFFFF ), + UINT64_C( 0x0000000FFFFFFFFF ), + UINT64_C( 0x00000007FFFFFFFF ), + UINT64_C( 0x00000003FFFFFFFF ), + UINT64_C( 0x00000001FFFFFFFF ), + UINT64_C( 0x00000000FFFFFFFF ), + UINT64_C( 0x000000007FFFFFFF ), + UINT64_C( 0x000000003FFFFFFF ), + UINT64_C( 0x000000001FFFFFFF ), + UINT64_C( 0x000000000FFFFFFF ), + UINT64_C( 0x0000000007FFFFFF ), + UINT64_C( 0x0000000003FFFFFF ), + UINT64_C( 0x0000000001FFFFFF ), + UINT64_C( 0x0000000000FFFFFF ), + UINT64_C( 0x00000000007FFFFF ), + UINT64_C( 0x00000000003FFFFF ), + UINT64_C( 0x00000000001FFFFF ), + UINT64_C( 0x00000000000FFFFF ), + UINT64_C( 0x000000000007FFFF ), + UINT64_C( 0x000000000003FFFF ), + UINT64_C( 0x000000000001FFFF ), + UINT64_C( 0x000000000000FFFF ), + UINT64_C( 0x0000000000007FFF ), + UINT64_C( 0x0000000000003FFF ), + UINT64_C( 0x0000000000001FFF ), + UINT64_C( 0x0000000000000FFF ), + UINT64_C( 0x00000000000007FF ), + UINT64_C( 0x00000000000003FF ), + UINT64_C( 0x00000000000001FF ), + UINT64_C( 0x00000000000000FF ), + UINT64_C( 0x000000000000007F ), + UINT64_C( 0x000000000000003F ), + UINT64_C( 0x000000000000001F ), + UINT64_C( 0x000000000000000F ), + UINT64_C( 0x0000000000000007 ), + UINT64_C( 0x0000000000000003 ) +}; + +static const uint_fast64_t f64NumQInP1 = f64NumQIn * f64NumP1; +static const uint_fast64_t f64NumQOutP1 = f64NumQOut * f64NumP1; + +static float64_t f64NextQInP1( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui64_f64 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f64QIn[expNum] | f64P1[sigNum]; + ++sigNum; + if ( f64NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f64NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float64_t f64NextQOutP1( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui64_f64 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f64QOut[expNum] | f64P1[sigNum]; + ++sigNum; + if ( f64NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f64NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static const uint_fast64_t f64NumQInP2 = f64NumQIn * f64NumP2; +static const uint_fast64_t f64NumQOutP2 = f64NumQOut * f64NumP2; + +static float64_t f64NextQInP2( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui64_f64 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f64QIn[expNum] | f64P2[sigNum]; + ++sigNum; + if ( f64NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f64NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float64_t f64NextQOutP2( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui64_f64 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f64QOut[expNum] | f64P2[sigNum]; + ++sigNum; + if ( f64NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f64NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float64_t f64RandomQOutP3( void ) +{ + union ui64_f64 uZ; + + uZ.ui = + f64QOut[randomN_ui8( f64NumQOut )] + | ((f64P2[randomN_ui8( f64NumP2 )] + f64P2[randomN_ui8( f64NumP2 )]) + & UINT64_C( 0x000FFFFFFFFFFFFF )); + return uZ.f; + +} + +static float64_t f64RandomQOutPInf( void ) +{ + union ui64_f64 uZ; + + uZ.ui = + f64QOut[randomN_ui8( f64NumQOut )] + | (random_ui64() & UINT64_C( 0x000FFFFFFFFFFFFF )); + return uZ.f; + +} + +enum { f64NumQInfWeightMasks = 10 }; +static const uint64_t f64QInfWeightMasks[f64NumQInfWeightMasks] = { + UINT64_C( 0xFFF0000000000000 ), + UINT64_C( 0xFFF0000000000000 ), + UINT64_C( 0xBFF0000000000000 ), + UINT64_C( 0x9FF0000000000000 ), + UINT64_C( 0x8FF0000000000000 ), + UINT64_C( 0x87F0000000000000 ), + UINT64_C( 0x83F0000000000000 ), + UINT64_C( 0x81F0000000000000 ), + UINT64_C( 0x80F0000000000000 ), + UINT64_C( 0x8070000000000000 ) +}; +static const uint64_t f64QInfWeightOffsets[f64NumQInfWeightMasks] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x2000000000000000 ), + UINT64_C( 0x3000000000000000 ), + UINT64_C( 0x3800000000000000 ), + UINT64_C( 0x3C00000000000000 ), + UINT64_C( 0x3E00000000000000 ), + UINT64_C( 0x3F00000000000000 ), + UINT64_C( 0x3F80000000000000 ), + UINT64_C( 0x3FC0000000000000 ) +}; + +static float64_t f64RandomQInfP3( void ) +{ + int weightMaskNum; + union ui64_f64 uZ; + + weightMaskNum = randomN_ui8( f64NumQInfWeightMasks ); + uZ.ui = + (((uint_fast64_t) random_ui16()<<48 + & f64QInfWeightMasks[weightMaskNum]) + + f64QInfWeightOffsets[weightMaskNum]) + | ((f64P2[randomN_ui8( f64NumP2 )] + f64P2[randomN_ui8( f64NumP2 )]) + & UINT64_C( 0x000FFFFFFFFFFFFF )); + return uZ.f; + +} + +static float64_t f64RandomQInfPInf( void ) +{ + int weightMaskNum; + union ui64_f64 uZ; + + weightMaskNum = randomN_ui8( f64NumQInfWeightMasks ); + uZ.ui = + (random_ui64() + & (f64QInfWeightMasks[weightMaskNum] + | UINT64_C( 0x000FFFFFFFFFFFFF ))) + + f64QInfWeightOffsets[weightMaskNum]; + return uZ.f; + +} + +static float64_t f64Random( void ) +{ + + switch ( random_ui8() & 7 ) { + case 0: + case 1: + case 2: + return f64RandomQOutP3(); + case 3: + return f64RandomQOutPInf(); + case 4: + case 5: + case 6: + return f64RandomQInfP3(); + case 7: + return f64RandomQInfPInf(); + } + +} + +static struct sequence sequenceA, sequenceB, sequenceC; +static float64_t currentA, currentB, currentC; +static int subcase; + +float64_t genCases_f64_a, genCases_f64_b, genCases_f64_c; + +void genCases_f64_a_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = + (genCases_level == 1) ? 3 * f64NumQOutP1 : 2 * f64NumQOutP2; + genCases_done = false; + +} + +void genCases_f64_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + case 1: + genCases_f64_a = f64Random(); + break; + case 2: + genCases_f64_a = f64NextQOutP1( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f64_a = f64Random(); + break; + case 1: + genCases_f64_a = f64NextQOutP2( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f64_ab_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 6 * f64NumQInP1 * f64NumQInP1; + currentA = f64NextQInP1( &sequenceA ); + } else { + genCases_total = 2 * f64NumQInP2 * f64NumQInP2; + currentA = f64NextQInP2( &sequenceA ); + } + genCases_done = false; + +} + +void genCases_f64_ab_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f64NextQInP1( &sequenceA ); + } + currentB = f64NextQInP1( &sequenceB ); + case 2: + case 4: + genCases_f64_a = f64Random(); + genCases_f64_b = f64Random(); + break; + case 1: + genCases_f64_a = currentA; + genCases_f64_b = f64Random(); + break; + case 3: + genCases_f64_a = f64Random(); + genCases_f64_b = currentB; + break; + case 5: + genCases_f64_a = currentA; + genCases_f64_b = currentB; + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f64_a = f64Random(); + genCases_f64_b = f64Random(); + break; + case 1: + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f64NextQInP2( &sequenceA ); + } + genCases_f64_a = currentA; + genCases_f64_b = f64NextQInP2( &sequenceB ); + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f64_abc_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + sequenceC.expNum = 0; + sequenceC.term1Num = 0; + sequenceC.term2Num = 0; + sequenceC.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 9 * f64NumQInP1 * f64NumQInP1 * f64NumQInP1; + currentA = f64NextQInP1( &sequenceA ); + currentB = f64NextQInP1( &sequenceB ); + } else { + genCases_total = 2 * f64NumQInP2 * f64NumQInP2 * f64NumQInP2; + currentA = f64NextQInP2( &sequenceA ); + currentB = f64NextQInP2( &sequenceB ); + } + genCases_done = false; + +} + +void genCases_f64_abc_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f64NextQInP1( &sequenceA ); + } + currentB = f64NextQInP1( &sequenceB ); + } + currentC = f64NextQInP1( &sequenceC ); + genCases_f64_a = f64Random(); + genCases_f64_b = f64Random(); + genCases_f64_c = currentC; + break; + case 1: + genCases_f64_a = currentA; + genCases_f64_b = currentB; + genCases_f64_c = f64Random(); + break; + case 2: + genCases_f64_a = f64Random(); + genCases_f64_b = f64Random(); + genCases_f64_c = f64Random(); + break; + case 3: + genCases_f64_a = f64Random(); + genCases_f64_b = currentB; + genCases_f64_c = currentC; + break; + case 4: + genCases_f64_a = currentA; + genCases_f64_b = f64Random(); + genCases_f64_c = f64Random(); + break; + case 5: + genCases_f64_a = f64Random(); + genCases_f64_b = currentB; + genCases_f64_c = f64Random(); + break; + case 6: + genCases_f64_a = currentA; + genCases_f64_b = f64Random(); + genCases_f64_c = currentC; + break; + case 7: + genCases_f64_a = f64Random(); + genCases_f64_b = f64Random(); + genCases_f64_c = f64Random(); + break; + case 8: + genCases_f64_a = currentA; + genCases_f64_b = currentB; + genCases_f64_c = currentC; + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done;; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f64_a = f64Random(); + genCases_f64_b = f64Random(); + genCases_f64_c = f64Random(); + break; + case 1: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f64NextQInP2( &sequenceA ); + } + currentB = f64NextQInP2( &sequenceB ); + } + genCases_f64_a = currentA; + genCases_f64_b = currentB; + genCases_f64_c = f64NextQInP2( &sequenceC ); + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done;; + subcase = -1; + break; + } + } + ++subcase; + +} + diff --git a/source/genCases_i32.c b/source/genCases_i32.c new file mode 100644 index 0000000..bc3287a --- /dev/null +++ b/source/genCases_i32.c @@ -0,0 +1,359 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" +#include "genCases.h" + +struct sequence { + int term1Num, term2Num; + bool done; +}; + +union ui32_i32 { uint32_t ui; int32_t i; }; + +enum { i32NumP1 = 124 }; +static const uint32_t i32P1[i32NumP1] = { + 0x00000000, + 0x00000001, + 0x00000002, + 0x00000004, + 0x00000008, + 0x00000010, + 0x00000020, + 0x00000040, + 0x00000080, + 0x00000100, + 0x00000200, + 0x00000400, + 0x00000800, + 0x00001000, + 0x00002000, + 0x00004000, + 0x00008000, + 0x00010000, + 0x00020000, + 0x00040000, + 0x00080000, + 0x00100000, + 0x00200000, + 0x00400000, + 0x00800000, + 0x01000000, + 0x02000000, + 0x04000000, + 0x08000000, + 0x10000000, + 0x20000000, + 0x40000000, + 0x80000000, + 0xC0000000, + 0xE0000000, + 0xF0000000, + 0xF8000000, + 0xFC000000, + 0xFE000000, + 0xFF000000, + 0xFF800000, + 0xFFC00000, + 0xFFE00000, + 0xFFF00000, + 0xFFF80000, + 0xFFFC0000, + 0xFFFE0000, + 0xFFFF0000, + 0xFFFF8000, + 0xFFFFC000, + 0xFFFFE000, + 0xFFFFF000, + 0xFFFFF800, + 0xFFFFFC00, + 0xFFFFFE00, + 0xFFFFFF00, + 0xFFFFFF80, + 0xFFFFFFC0, + 0xFFFFFFE0, + 0xFFFFFFF0, + 0xFFFFFFF8, + 0xFFFFFFFC, + 0xFFFFFFFE, + 0xFFFFFFFF, + 0xFFFFFFFD, + 0xFFFFFFFB, + 0xFFFFFFF7, + 0xFFFFFFEF, + 0xFFFFFFDF, + 0xFFFFFFBF, + 0xFFFFFF7F, + 0xFFFFFEFF, + 0xFFFFFDFF, + 0xFFFFFBFF, + 0xFFFFF7FF, + 0xFFFFEFFF, + 0xFFFFDFFF, + 0xFFFFBFFF, + 0xFFFF7FFF, + 0xFFFEFFFF, + 0xFFFDFFFF, + 0xFFFBFFFF, + 0xFFF7FFFF, + 0xFFEFFFFF, + 0xFFDFFFFF, + 0xFFBFFFFF, + 0xFF7FFFFF, + 0xFEFFFFFF, + 0xFDFFFFFF, + 0xFBFFFFFF, + 0xF7FFFFFF, + 0xEFFFFFFF, + 0xDFFFFFFF, + 0xBFFFFFFF, + 0x7FFFFFFF, + 0x3FFFFFFF, + 0x1FFFFFFF, + 0x0FFFFFFF, + 0x07FFFFFF, + 0x03FFFFFF, + 0x01FFFFFF, + 0x00FFFFFF, + 0x007FFFFF, + 0x003FFFFF, + 0x001FFFFF, + 0x000FFFFF, + 0x0007FFFF, + 0x0003FFFF, + 0x0001FFFF, + 0x0000FFFF, + 0x00007FFF, + 0x00003FFF, + 0x00001FFF, + 0x00000FFF, + 0x000007FF, + 0x000003FF, + 0x000001FF, + 0x000000FF, + 0x0000007F, + 0x0000003F, + 0x0000001F, + 0x0000000F, + 0x00000007, + 0x00000003 +}; + +static int_fast32_t i32NextP1( struct sequence *sequencePtr ) +{ + int termNum; + union ui32_i32 uZ; + + termNum = sequencePtr->term1Num; + uZ.ui = i32P1[termNum]; + ++termNum; + if ( i32NumP1 <= termNum ) { + termNum = 0; + sequencePtr->done = true; + } + sequencePtr->term1Num = termNum; + return uZ.i; + +} + +static const int_fast32_t i32NumP2 = (i32NumP1 * i32NumP1 + i32NumP1) / 2; + +static int_fast32_t i32NextP2( struct sequence *sequencePtr ) +{ + int term1Num, term2Num; + union ui32_i32 uZ; + + term2Num = sequencePtr->term2Num; + term1Num = sequencePtr->term1Num; + uZ.ui = i32P1[term1Num] + i32P1[term2Num]; + ++term2Num; + if ( i32NumP1 <= term2Num ) { + ++term1Num; + if ( i32NumP1 <= term1Num ) { + term1Num = 0; + sequencePtr->done = true; + } + term2Num = term1Num; + sequencePtr->term1Num = term1Num; + } + sequencePtr->term2Num = term2Num; + return uZ.i; + +} + +static int_fast32_t i32RandomP3( void ) +{ + union ui32_i32 uZ; + + uZ.ui = + i32P1[randomN_ui8( i32NumP1 )] + i32P1[randomN_ui8( i32NumP1 )] + + i32P1[randomN_ui8( i32NumP1 )]; + return uZ.i; + +} + +enum { i32NumPInfWeightMasks = 29 }; +static const uint32_t i32PInfWeightMasks[i32NumPInfWeightMasks] = { + 0xFFFFFFFF, + 0x7FFFFFFF, + 0x3FFFFFFF, + 0x1FFFFFFF, + 0x0FFFFFFF, + 0x07FFFFFF, + 0x03FFFFFF, + 0x01FFFFFF, + 0x00FFFFFF, + 0x007FFFFF, + 0x003FFFFF, + 0x001FFFFF, + 0x000FFFFF, + 0x0007FFFF, + 0x0003FFFF, + 0x0001FFFF, + 0x0000FFFF, + 0x00007FFF, + 0x00003FFF, + 0x00001FFF, + 0x00000FFF, + 0x000007FF, + 0x000003FF, + 0x000001FF, + 0x000000FF, + 0x0000007F, + 0x0000003F, + 0x0000001F, + 0x0000000F +}; +static const uint32_t i32PInfWeightOffsets[i32NumPInfWeightMasks] = { + 0x00000000, + 0xC0000000, + 0xE0000000, + 0xF0000000, + 0xF8000000, + 0xFC000000, + 0xFE000000, + 0xFF000000, + 0xFF800000, + 0xFFC00000, + 0xFFE00000, + 0xFFF00000, + 0xFFF80000, + 0xFFFC0000, + 0xFFFE0000, + 0xFFFF0000, + 0xFFFF8000, + 0xFFFFC000, + 0xFFFFE000, + 0xFFFFF000, + 0xFFFFF800, + 0xFFFFFC00, + 0xFFFFFE00, + 0xFFFFFF00, + 0xFFFFFF80, + 0xFFFFFFC0, + 0xFFFFFFE0, + 0xFFFFFFF0, + 0xFFFFFFF8 +}; + +static int_fast32_t i32RandomPInf( void ) +{ + int weightMaskNum; + union ui32_i32 uZ; + + weightMaskNum = randomN_ui8( i32NumPInfWeightMasks ); + uZ.ui = + (random_ui32() & i32PInfWeightMasks[weightMaskNum]) + + i32PInfWeightOffsets[weightMaskNum]; + return uZ.i; + +} + +static struct sequence sequenceA; +static int subcase; + +int_fast32_t genCases_i32_a; + +void genCases_i32_a_init( void ) +{ + + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = (genCases_level == 1) ? 3 * i32NumP1 : 2 * i32NumP2; + genCases_done = false; + +} + +void genCases_i32_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + genCases_i32_a = i32RandomP3(); + break; + case 1: + genCases_i32_a = i32RandomPInf(); + break; + case 2: + genCases_i32_a = i32NextP1( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_i32_a = i32RandomP3(); + break; + case 2: + genCases_i32_a = i32RandomPInf(); + break; + case 3: + subcase = -1; + case 1: + genCases_i32_a = i32NextP2( &sequenceA ); + genCases_done = sequenceA.done; + break; + } + } + ++subcase; + +} + diff --git a/source/genCases_i64.c b/source/genCases_i64.c new file mode 100644 index 0000000..b98df8d --- /dev/null +++ b/source/genCases_i64.c @@ -0,0 +1,551 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" +#include "genCases.h" + +struct sequence { + int term1Num, term2Num; + bool done; +}; + +union ui64_i64 { uint64_t ui; int64_t i; }; + +enum { i64NumP1 = 252 }; +static const uint64_t i64P1[i64NumP1] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000001 ), + UINT64_C( 0x0000000000000002 ), + UINT64_C( 0x0000000000000004 ), + UINT64_C( 0x0000000000000008 ), + UINT64_C( 0x0000000000000010 ), + UINT64_C( 0x0000000000000020 ), + UINT64_C( 0x0000000000000040 ), + UINT64_C( 0x0000000000000080 ), + UINT64_C( 0x0000000000000100 ), + UINT64_C( 0x0000000000000200 ), + UINT64_C( 0x0000000000000400 ), + UINT64_C( 0x0000000000000800 ), + UINT64_C( 0x0000000000001000 ), + UINT64_C( 0x0000000000002000 ), + UINT64_C( 0x0000000000004000 ), + UINT64_C( 0x0000000000008000 ), + UINT64_C( 0x0000000000010000 ), + UINT64_C( 0x0000000000020000 ), + UINT64_C( 0x0000000000040000 ), + UINT64_C( 0x0000000000080000 ), + UINT64_C( 0x0000000000100000 ), + UINT64_C( 0x0000000000200000 ), + UINT64_C( 0x0000000000400000 ), + UINT64_C( 0x0000000000800000 ), + UINT64_C( 0x0000000001000000 ), + UINT64_C( 0x0000000002000000 ), + UINT64_C( 0x0000000004000000 ), + UINT64_C( 0x0000000008000000 ), + UINT64_C( 0x0000000010000000 ), + UINT64_C( 0x0000000020000000 ), + UINT64_C( 0x0000000040000000 ), + UINT64_C( 0x0000000080000000 ), + UINT64_C( 0x0000000100000000 ), + UINT64_C( 0x0000000200000000 ), + UINT64_C( 0x0000000400000000 ), + UINT64_C( 0x0000000800000000 ), + UINT64_C( 0x0000001000000000 ), + UINT64_C( 0x0000002000000000 ), + UINT64_C( 0x0000004000000000 ), + UINT64_C( 0x0000008000000000 ), + UINT64_C( 0x0000010000000000 ), + UINT64_C( 0x0000020000000000 ), + UINT64_C( 0x0000040000000000 ), + UINT64_C( 0x0000080000000000 ), + UINT64_C( 0x0000100000000000 ), + UINT64_C( 0x0000200000000000 ), + UINT64_C( 0x0000400000000000 ), + UINT64_C( 0x0000800000000000 ), + UINT64_C( 0x0001000000000000 ), + UINT64_C( 0x0002000000000000 ), + UINT64_C( 0x0004000000000000 ), + UINT64_C( 0x0008000000000000 ), + UINT64_C( 0x0010000000000000 ), + UINT64_C( 0x0020000000000000 ), + UINT64_C( 0x0040000000000000 ), + UINT64_C( 0x0080000000000000 ), + UINT64_C( 0x0100000000000000 ), + UINT64_C( 0x0200000000000000 ), + UINT64_C( 0x0400000000000000 ), + UINT64_C( 0x0800000000000000 ), + UINT64_C( 0x1000000000000000 ), + UINT64_C( 0x2000000000000000 ), + UINT64_C( 0x4000000000000000 ), + UINT64_C( 0x8000000000000000 ), + UINT64_C( 0xC000000000000000 ), + UINT64_C( 0xE000000000000000 ), + UINT64_C( 0xF000000000000000 ), + UINT64_C( 0xF800000000000000 ), + UINT64_C( 0xFC00000000000000 ), + UINT64_C( 0xFE00000000000000 ), + UINT64_C( 0xFF00000000000000 ), + UINT64_C( 0xFF80000000000000 ), + UINT64_C( 0xFFC0000000000000 ), + UINT64_C( 0xFFE0000000000000 ), + UINT64_C( 0xFFF0000000000000 ), + UINT64_C( 0xFFF8000000000000 ), + UINT64_C( 0xFFFC000000000000 ), + UINT64_C( 0xFFFE000000000000 ), + UINT64_C( 0xFFFF000000000000 ), + UINT64_C( 0xFFFF800000000000 ), + UINT64_C( 0xFFFFC00000000000 ), + UINT64_C( 0xFFFFE00000000000 ), + UINT64_C( 0xFFFFF00000000000 ), + UINT64_C( 0xFFFFF80000000000 ), + UINT64_C( 0xFFFFFC0000000000 ), + UINT64_C( 0xFFFFFE0000000000 ), + UINT64_C( 0xFFFFFF0000000000 ), + UINT64_C( 0xFFFFFF8000000000 ), + UINT64_C( 0xFFFFFFC000000000 ), + UINT64_C( 0xFFFFFFE000000000 ), + UINT64_C( 0xFFFFFFF000000000 ), + UINT64_C( 0xFFFFFFF800000000 ), + UINT64_C( 0xFFFFFFFC00000000 ), + UINT64_C( 0xFFFFFFFE00000000 ), + UINT64_C( 0xFFFFFFFF00000000 ), + UINT64_C( 0xFFFFFFFF80000000 ), + UINT64_C( 0xFFFFFFFFC0000000 ), + UINT64_C( 0xFFFFFFFFE0000000 ), + UINT64_C( 0xFFFFFFFFF0000000 ), + UINT64_C( 0xFFFFFFFFF8000000 ), + UINT64_C( 0xFFFFFFFFFC000000 ), + UINT64_C( 0xFFFFFFFFFE000000 ), + UINT64_C( 0xFFFFFFFFFF000000 ), + UINT64_C( 0xFFFFFFFFFF800000 ), + UINT64_C( 0xFFFFFFFFFFC00000 ), + UINT64_C( 0xFFFFFFFFFFE00000 ), + UINT64_C( 0xFFFFFFFFFFF00000 ), + UINT64_C( 0xFFFFFFFFFFF80000 ), + UINT64_C( 0xFFFFFFFFFFFC0000 ), + UINT64_C( 0xFFFFFFFFFFFE0000 ), + UINT64_C( 0xFFFFFFFFFFFF0000 ), + UINT64_C( 0xFFFFFFFFFFFF8000 ), + UINT64_C( 0xFFFFFFFFFFFFC000 ), + UINT64_C( 0xFFFFFFFFFFFFE000 ), + UINT64_C( 0xFFFFFFFFFFFFF000 ), + UINT64_C( 0xFFFFFFFFFFFFF800 ), + UINT64_C( 0xFFFFFFFFFFFFFC00 ), + UINT64_C( 0xFFFFFFFFFFFFFE00 ), + UINT64_C( 0xFFFFFFFFFFFFFF00 ), + UINT64_C( 0xFFFFFFFFFFFFFF80 ), + UINT64_C( 0xFFFFFFFFFFFFFFC0 ), + UINT64_C( 0xFFFFFFFFFFFFFFE0 ), + UINT64_C( 0xFFFFFFFFFFFFFFF0 ), + UINT64_C( 0xFFFFFFFFFFFFFFF8 ), + UINT64_C( 0xFFFFFFFFFFFFFFFC ), + UINT64_C( 0xFFFFFFFFFFFFFFFE ), + UINT64_C( 0xFFFFFFFFFFFFFFFF ), + UINT64_C( 0xFFFFFFFFFFFFFFFD ), + UINT64_C( 0xFFFFFFFFFFFFFFFB ), + UINT64_C( 0xFFFFFFFFFFFFFFF7 ), + UINT64_C( 0xFFFFFFFFFFFFFFEF ), + UINT64_C( 0xFFFFFFFFFFFFFFDF ), + UINT64_C( 0xFFFFFFFFFFFFFFBF ), + UINT64_C( 0xFFFFFFFFFFFFFF7F ), + UINT64_C( 0xFFFFFFFFFFFFFEFF ), + UINT64_C( 0xFFFFFFFFFFFFFDFF ), + UINT64_C( 0xFFFFFFFFFFFFFBFF ), + UINT64_C( 0xFFFFFFFFFFFFF7FF ), + UINT64_C( 0xFFFFFFFFFFFFEFFF ), + UINT64_C( 0xFFFFFFFFFFFFDFFF ), + UINT64_C( 0xFFFFFFFFFFFFBFFF ), + UINT64_C( 0xFFFFFFFFFFFF7FFF ), + UINT64_C( 0xFFFFFFFFFFFEFFFF ), + UINT64_C( 0xFFFFFFFFFFFDFFFF ), + UINT64_C( 0xFFFFFFFFFFFBFFFF ), + UINT64_C( 0xFFFFFFFFFFF7FFFF ), + UINT64_C( 0xFFFFFFFFFFEFFFFF ), + UINT64_C( 0xFFFFFFFFFFDFFFFF ), + UINT64_C( 0xFFFFFFFFFFBFFFFF ), + UINT64_C( 0xFFFFFFFFFF7FFFFF ), + UINT64_C( 0xFFFFFFFFFEFFFFFF ), + UINT64_C( 0xFFFFFFFFFDFFFFFF ), + UINT64_C( 0xFFFFFFFFFBFFFFFF ), + UINT64_C( 0xFFFFFFFFF7FFFFFF ), + UINT64_C( 0xFFFFFFFFEFFFFFFF ), + UINT64_C( 0xFFFFFFFFDFFFFFFF ), + UINT64_C( 0xFFFFFFFFBFFFFFFF ), + UINT64_C( 0xFFFFFFFF7FFFFFFF ), + UINT64_C( 0xFFFFFFFEFFFFFFFF ), + UINT64_C( 0xFFFFFFFDFFFFFFFF ), + UINT64_C( 0xFFFFFFFBFFFFFFFF ), + UINT64_C( 0xFFFFFFF7FFFFFFFF ), + UINT64_C( 0xFFFFFFEFFFFFFFFF ), + UINT64_C( 0xFFFFFFDFFFFFFFFF ), + UINT64_C( 0xFFFFFFBFFFFFFFFF ), + UINT64_C( 0xFFFFFF7FFFFFFFFF ), + UINT64_C( 0xFFFFFEFFFFFFFFFF ), + UINT64_C( 0xFFFFFDFFFFFFFFFF ), + UINT64_C( 0xFFFFFBFFFFFFFFFF ), + UINT64_C( 0xFFFFF7FFFFFFFFFF ), + UINT64_C( 0xFFFFEFFFFFFFFFFF ), + UINT64_C( 0xFFFFDFFFFFFFFFFF ), + UINT64_C( 0xFFFFBFFFFFFFFFFF ), + UINT64_C( 0xFFFF7FFFFFFFFFFF ), + UINT64_C( 0xFFFEFFFFFFFFFFFF ), + UINT64_C( 0xFFFDFFFFFFFFFFFF ), + UINT64_C( 0xFFFBFFFFFFFFFFFF ), + UINT64_C( 0xFFF7FFFFFFFFFFFF ), + UINT64_C( 0xFFEFFFFFFFFFFFFF ), + UINT64_C( 0xFFDFFFFFFFFFFFFF ), + UINT64_C( 0xFFBFFFFFFFFFFFFF ), + UINT64_C( 0xFF7FFFFFFFFFFFFF ), + UINT64_C( 0xFEFFFFFFFFFFFFFF ), + UINT64_C( 0xFDFFFFFFFFFFFFFF ), + UINT64_C( 0xFBFFFFFFFFFFFFFF ), + UINT64_C( 0xF7FFFFFFFFFFFFFF ), + UINT64_C( 0xEFFFFFFFFFFFFFFF ), + UINT64_C( 0xDFFFFFFFFFFFFFFF ), + UINT64_C( 0xBFFFFFFFFFFFFFFF ), + UINT64_C( 0x7FFFFFFFFFFFFFFF ), + UINT64_C( 0x3FFFFFFFFFFFFFFF ), + UINT64_C( 0x1FFFFFFFFFFFFFFF ), + UINT64_C( 0x0FFFFFFFFFFFFFFF ), + UINT64_C( 0x07FFFFFFFFFFFFFF ), + UINT64_C( 0x03FFFFFFFFFFFFFF ), + UINT64_C( 0x01FFFFFFFFFFFFFF ), + UINT64_C( 0x00FFFFFFFFFFFFFF ), + UINT64_C( 0x007FFFFFFFFFFFFF ), + UINT64_C( 0x003FFFFFFFFFFFFF ), + UINT64_C( 0x001FFFFFFFFFFFFF ), + UINT64_C( 0x000FFFFFFFFFFFFF ), + UINT64_C( 0x0007FFFFFFFFFFFF ), + UINT64_C( 0x0003FFFFFFFFFFFF ), + UINT64_C( 0x0001FFFFFFFFFFFF ), + UINT64_C( 0x0000FFFFFFFFFFFF ), + UINT64_C( 0x00007FFFFFFFFFFF ), + UINT64_C( 0x00003FFFFFFFFFFF ), + UINT64_C( 0x00001FFFFFFFFFFF ), + UINT64_C( 0x00000FFFFFFFFFFF ), + UINT64_C( 0x000007FFFFFFFFFF ), + UINT64_C( 0x000003FFFFFFFFFF ), + UINT64_C( 0x000001FFFFFFFFFF ), + UINT64_C( 0x000000FFFFFFFFFF ), + UINT64_C( 0x0000007FFFFFFFFF ), + UINT64_C( 0x0000003FFFFFFFFF ), + UINT64_C( 0x0000001FFFFFFFFF ), + UINT64_C( 0x0000000FFFFFFFFF ), + UINT64_C( 0x00000007FFFFFFFF ), + UINT64_C( 0x00000003FFFFFFFF ), + UINT64_C( 0x00000001FFFFFFFF ), + UINT64_C( 0x00000000FFFFFFFF ), + UINT64_C( 0x000000007FFFFFFF ), + UINT64_C( 0x000000003FFFFFFF ), + UINT64_C( 0x000000001FFFFFFF ), + UINT64_C( 0x000000000FFFFFFF ), + UINT64_C( 0x0000000007FFFFFF ), + UINT64_C( 0x0000000003FFFFFF ), + UINT64_C( 0x0000000001FFFFFF ), + UINT64_C( 0x0000000000FFFFFF ), + UINT64_C( 0x00000000007FFFFF ), + UINT64_C( 0x00000000003FFFFF ), + UINT64_C( 0x00000000001FFFFF ), + UINT64_C( 0x00000000000FFFFF ), + UINT64_C( 0x000000000007FFFF ), + UINT64_C( 0x000000000003FFFF ), + UINT64_C( 0x000000000001FFFF ), + UINT64_C( 0x000000000000FFFF ), + UINT64_C( 0x0000000000007FFF ), + UINT64_C( 0x0000000000003FFF ), + UINT64_C( 0x0000000000001FFF ), + UINT64_C( 0x0000000000000FFF ), + UINT64_C( 0x00000000000007FF ), + UINT64_C( 0x00000000000003FF ), + UINT64_C( 0x00000000000001FF ), + UINT64_C( 0x00000000000000FF ), + UINT64_C( 0x000000000000007F ), + UINT64_C( 0x000000000000003F ), + UINT64_C( 0x000000000000001F ), + UINT64_C( 0x000000000000000F ), + UINT64_C( 0x0000000000000007 ), + UINT64_C( 0x0000000000000003 ) +}; + +static int_fast64_t i64NextP1( struct sequence *sequencePtr ) +{ + int termNum; + union ui64_i64 uZ; + + termNum = sequencePtr->term1Num; + uZ.ui = i64P1[termNum]; + ++termNum; + if ( i64NumP1 <= termNum ) { + termNum = 0; + sequencePtr->done = true; + } + sequencePtr->term1Num = termNum; + return uZ.i; + +} + +static const int_fast64_t i64NumP2 = (i64NumP1 * i64NumP1 + i64NumP1) / 2; + +static int_fast64_t i64NextP2( struct sequence *sequencePtr ) +{ + int term1Num, term2Num; + union ui64_i64 uZ; + + term2Num = sequencePtr->term2Num; + term1Num = sequencePtr->term1Num; + uZ.ui = i64P1[term1Num] + i64P1[term2Num]; + ++term2Num; + if ( i64NumP1 <= term2Num ) { + ++term1Num; + if ( i64NumP1 <= term1Num ) { + term1Num = 0; + sequencePtr->done = true; + } + term2Num = term1Num; + sequencePtr->term1Num = term1Num; + } + sequencePtr->term2Num = term2Num; + return uZ.i; + +} + +static int_fast64_t i64RandomP3( void ) +{ + union ui64_i64 uZ; + + uZ.ui = + i64P1[randomN_ui8( i64NumP1 )] + i64P1[randomN_ui8( i64NumP1 )] + + i64P1[randomN_ui8( i64NumP1 )]; + return uZ.i; + +} + +enum { i64NumPInfWeightMasks = 61 }; +static const uint64_t i64PInfWeightMasks[i64NumPInfWeightMasks] = { + UINT64_C( 0xFFFFFFFFFFFFFFFF ), + UINT64_C( 0x7FFFFFFFFFFFFFFF ), + UINT64_C( 0x3FFFFFFFFFFFFFFF ), + UINT64_C( 0x1FFFFFFFFFFFFFFF ), + UINT64_C( 0x0FFFFFFFFFFFFFFF ), + UINT64_C( 0x07FFFFFFFFFFFFFF ), + UINT64_C( 0x03FFFFFFFFFFFFFF ), + UINT64_C( 0x01FFFFFFFFFFFFFF ), + UINT64_C( 0x00FFFFFFFFFFFFFF ), + UINT64_C( 0x007FFFFFFFFFFFFF ), + UINT64_C( 0x003FFFFFFFFFFFFF ), + UINT64_C( 0x001FFFFFFFFFFFFF ), + UINT64_C( 0x000FFFFFFFFFFFFF ), + UINT64_C( 0x0007FFFFFFFFFFFF ), + UINT64_C( 0x0003FFFFFFFFFFFF ), + UINT64_C( 0x0001FFFFFFFFFFFF ), + UINT64_C( 0x0000FFFFFFFFFFFF ), + UINT64_C( 0x00007FFFFFFFFFFF ), + UINT64_C( 0x00003FFFFFFFFFFF ), + UINT64_C( 0x00001FFFFFFFFFFF ), + UINT64_C( 0x00000FFFFFFFFFFF ), + UINT64_C( 0x000007FFFFFFFFFF ), + UINT64_C( 0x000003FFFFFFFFFF ), + UINT64_C( 0x000001FFFFFFFFFF ), + UINT64_C( 0x000000FFFFFFFFFF ), + UINT64_C( 0x0000007FFFFFFFFF ), + UINT64_C( 0x0000003FFFFFFFFF ), + UINT64_C( 0x0000001FFFFFFFFF ), + UINT64_C( 0x0000000FFFFFFFFF ), + UINT64_C( 0x00000007FFFFFFFF ), + UINT64_C( 0x00000003FFFFFFFF ), + UINT64_C( 0x00000001FFFFFFFF ), + UINT64_C( 0x00000000FFFFFFFF ), + UINT64_C( 0x000000007FFFFFFF ), + UINT64_C( 0x000000003FFFFFFF ), + UINT64_C( 0x000000001FFFFFFF ), + UINT64_C( 0x000000000FFFFFFF ), + UINT64_C( 0x0000000007FFFFFF ), + UINT64_C( 0x0000000003FFFFFF ), + UINT64_C( 0x0000000001FFFFFF ), + UINT64_C( 0x0000000000FFFFFF ), + UINT64_C( 0x00000000007FFFFF ), + UINT64_C( 0x00000000003FFFFF ), + UINT64_C( 0x00000000001FFFFF ), + UINT64_C( 0x00000000000FFFFF ), + UINT64_C( 0x000000000007FFFF ), + UINT64_C( 0x000000000003FFFF ), + UINT64_C( 0x000000000001FFFF ), + UINT64_C( 0x000000000000FFFF ), + UINT64_C( 0x0000000000007FFF ), + UINT64_C( 0x0000000000003FFF ), + UINT64_C( 0x0000000000001FFF ), + UINT64_C( 0x0000000000000FFF ), + UINT64_C( 0x00000000000007FF ), + UINT64_C( 0x00000000000003FF ), + UINT64_C( 0x00000000000001FF ), + UINT64_C( 0x00000000000000FF ), + UINT64_C( 0x000000000000007F ), + UINT64_C( 0x000000000000003F ), + UINT64_C( 0x000000000000001F ), + UINT64_C( 0x000000000000000F ) +}; +static const uint64_t i64PInfWeightOffsets[i64NumPInfWeightMasks] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0xC000000000000000 ), + UINT64_C( 0xE000000000000000 ), + UINT64_C( 0xF000000000000000 ), + UINT64_C( 0xF800000000000000 ), + UINT64_C( 0xFC00000000000000 ), + UINT64_C( 0xFE00000000000000 ), + UINT64_C( 0xFF00000000000000 ), + UINT64_C( 0xFF80000000000000 ), + UINT64_C( 0xFFC0000000000000 ), + UINT64_C( 0xFFE0000000000000 ), + UINT64_C( 0xFFF0000000000000 ), + UINT64_C( 0xFFF8000000000000 ), + UINT64_C( 0xFFFC000000000000 ), + UINT64_C( 0xFFFE000000000000 ), + UINT64_C( 0xFFFF000000000000 ), + UINT64_C( 0xFFFF800000000000 ), + UINT64_C( 0xFFFFC00000000000 ), + UINT64_C( 0xFFFFE00000000000 ), + UINT64_C( 0xFFFFF00000000000 ), + UINT64_C( 0xFFFFF80000000000 ), + UINT64_C( 0xFFFFFC0000000000 ), + UINT64_C( 0xFFFFFE0000000000 ), + UINT64_C( 0xFFFFFF0000000000 ), + UINT64_C( 0xFFFFFF8000000000 ), + UINT64_C( 0xFFFFFFC000000000 ), + UINT64_C( 0xFFFFFFE000000000 ), + UINT64_C( 0xFFFFFFF000000000 ), + UINT64_C( 0xFFFFFFF800000000 ), + UINT64_C( 0xFFFFFFFC00000000 ), + UINT64_C( 0xFFFFFFFE00000000 ), + UINT64_C( 0xFFFFFFFF00000000 ), + UINT64_C( 0xFFFFFFFF80000000 ), + UINT64_C( 0xFFFFFFFFC0000000 ), + UINT64_C( 0xFFFFFFFFE0000000 ), + UINT64_C( 0xFFFFFFFFF0000000 ), + UINT64_C( 0xFFFFFFFFF8000000 ), + UINT64_C( 0xFFFFFFFFFC000000 ), + UINT64_C( 0xFFFFFFFFFE000000 ), + UINT64_C( 0xFFFFFFFFFF000000 ), + UINT64_C( 0xFFFFFFFFFF800000 ), + UINT64_C( 0xFFFFFFFFFFC00000 ), + UINT64_C( 0xFFFFFFFFFFE00000 ), + UINT64_C( 0xFFFFFFFFFFF00000 ), + UINT64_C( 0xFFFFFFFFFFF80000 ), + UINT64_C( 0xFFFFFFFFFFFC0000 ), + UINT64_C( 0xFFFFFFFFFFFE0000 ), + UINT64_C( 0xFFFFFFFFFFFF0000 ), + UINT64_C( 0xFFFFFFFFFFFF8000 ), + UINT64_C( 0xFFFFFFFFFFFFC000 ), + UINT64_C( 0xFFFFFFFFFFFFE000 ), + UINT64_C( 0xFFFFFFFFFFFFF000 ), + UINT64_C( 0xFFFFFFFFFFFFF800 ), + UINT64_C( 0xFFFFFFFFFFFFFC00 ), + UINT64_C( 0xFFFFFFFFFFFFFE00 ), + UINT64_C( 0xFFFFFFFFFFFFFF00 ), + UINT64_C( 0xFFFFFFFFFFFFFF80 ), + UINT64_C( 0xFFFFFFFFFFFFFFC0 ), + UINT64_C( 0xFFFFFFFFFFFFFFE0 ), + UINT64_C( 0xFFFFFFFFFFFFFFF0 ), + UINT64_C( 0xFFFFFFFFFFFFFFF8 ) +}; + +static int_fast64_t i64RandomPInf( void ) +{ + int weightMaskNum; + union ui64_i64 uZ; + + weightMaskNum = randomN_ui8( i64NumPInfWeightMasks ); + uZ.ui = + (random_ui64() & i64PInfWeightMasks[weightMaskNum]) + + i64PInfWeightOffsets[weightMaskNum]; + return uZ.i; + +} + +static struct sequence sequenceA; +static int subcase; + +int_fast64_t genCases_i64_a; + +void genCases_i64_a_init( void ) +{ + + sequenceA.term2Num = 0; + sequenceA.term1Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = (genCases_level == 1) ? 3 * i64NumP1 : 2 * i64NumP2; + genCases_done = false; + +} + +void genCases_i64_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + genCases_i64_a = i64RandomP3(); + break; + case 1: + genCases_i64_a = i64RandomPInf(); + break; + case 2: + genCases_i64_a = i64NextP1( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_i64_a = i64RandomP3(); + break; + case 2: + genCases_i64_a = i64RandomPInf(); + break; + case 3: + subcase = -1; + case 1: + genCases_i64_a = i64NextP2( &sequenceA ); + genCases_done = sequenceA.done; + break; + } + } + ++subcase; + +} + diff --git a/source/genCases_ui32.c b/source/genCases_ui32.c new file mode 100644 index 0000000..3b890cb --- /dev/null +++ b/source/genCases_ui32.c @@ -0,0 +1,320 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" +#include "genCases.h" + +struct sequence { + int term1Num, term2Num; + bool done; +}; + +enum { ui32NumP1 = 124 }; +static const uint32_t ui32P1[ui32NumP1] = { + 0x00000000, + 0x00000001, + 0x00000002, + 0x00000004, + 0x00000008, + 0x00000010, + 0x00000020, + 0x00000040, + 0x00000080, + 0x00000100, + 0x00000200, + 0x00000400, + 0x00000800, + 0x00001000, + 0x00002000, + 0x00004000, + 0x00008000, + 0x00010000, + 0x00020000, + 0x00040000, + 0x00080000, + 0x00100000, + 0x00200000, + 0x00400000, + 0x00800000, + 0x01000000, + 0x02000000, + 0x04000000, + 0x08000000, + 0x10000000, + 0x20000000, + 0x40000000, + 0x80000000, + 0xC0000000, + 0xE0000000, + 0xF0000000, + 0xF8000000, + 0xFC000000, + 0xFE000000, + 0xFF000000, + 0xFF800000, + 0xFFC00000, + 0xFFE00000, + 0xFFF00000, + 0xFFF80000, + 0xFFFC0000, + 0xFFFE0000, + 0xFFFF0000, + 0xFFFF8000, + 0xFFFFC000, + 0xFFFFE000, + 0xFFFFF000, + 0xFFFFF800, + 0xFFFFFC00, + 0xFFFFFE00, + 0xFFFFFF00, + 0xFFFFFF80, + 0xFFFFFFC0, + 0xFFFFFFE0, + 0xFFFFFFF0, + 0xFFFFFFF8, + 0xFFFFFFFC, + 0xFFFFFFFE, + 0xFFFFFFFF, + 0xFFFFFFFD, + 0xFFFFFFFB, + 0xFFFFFFF7, + 0xFFFFFFEF, + 0xFFFFFFDF, + 0xFFFFFFBF, + 0xFFFFFF7F, + 0xFFFFFEFF, + 0xFFFFFDFF, + 0xFFFFFBFF, + 0xFFFFF7FF, + 0xFFFFEFFF, + 0xFFFFDFFF, + 0xFFFFBFFF, + 0xFFFF7FFF, + 0xFFFEFFFF, + 0xFFFDFFFF, + 0xFFFBFFFF, + 0xFFF7FFFF, + 0xFFEFFFFF, + 0xFFDFFFFF, + 0xFFBFFFFF, + 0xFF7FFFFF, + 0xFEFFFFFF, + 0xFDFFFFFF, + 0xFBFFFFFF, + 0xF7FFFFFF, + 0xEFFFFFFF, + 0xDFFFFFFF, + 0xBFFFFFFF, + 0x7FFFFFFF, + 0x3FFFFFFF, + 0x1FFFFFFF, + 0x0FFFFFFF, + 0x07FFFFFF, + 0x03FFFFFF, + 0x01FFFFFF, + 0x00FFFFFF, + 0x007FFFFF, + 0x003FFFFF, + 0x001FFFFF, + 0x000FFFFF, + 0x0007FFFF, + 0x0003FFFF, + 0x0001FFFF, + 0x0000FFFF, + 0x00007FFF, + 0x00003FFF, + 0x00001FFF, + 0x00000FFF, + 0x000007FF, + 0x000003FF, + 0x000001FF, + 0x000000FF, + 0x0000007F, + 0x0000003F, + 0x0000001F, + 0x0000000F, + 0x00000007, + 0x00000003 +}; + +static uint_fast32_t ui32NextP1( struct sequence *sequencePtr ) +{ + int termNum; + uint_fast32_t z; + + termNum = sequencePtr->term1Num; + z = ui32P1[termNum]; + ++termNum; + if ( ui32NumP1 <= termNum ) { + termNum = 0; + sequencePtr->done = true; + } + sequencePtr->term1Num = termNum; + return z; + +} + +static const uint_fast32_t ui32NumP2 = (ui32NumP1 * ui32NumP1 + ui32NumP1) / 2; + +static uint_fast32_t ui32NextP2( struct sequence *sequencePtr ) +{ + int term1Num, term2Num; + uint_fast32_t z; + + term2Num = sequencePtr->term2Num; + term1Num = sequencePtr->term1Num; + z = ui32P1[term1Num] + ui32P1[term2Num]; + ++term2Num; + if ( ui32NumP1 <= term2Num ) { + ++term1Num; + if ( ui32NumP1 <= term1Num ) { + term1Num = 0; + sequencePtr->done = true; + } + term2Num = term1Num; + sequencePtr->term1Num = term1Num; + } + sequencePtr->term2Num = term2Num; + return z; + +} + +static uint_fast32_t ui32RandomP3( void ) +{ + + return + ui32P1[randomN_ui8( ui32NumP1 )] + ui32P1[randomN_ui8( ui32NumP1 )] + + ui32P1[randomN_ui8( ui32NumP1 )]; + +} + +enum { ui32NumPInfWeightMasks = 29 }; +static const uint32_t ui32PInfWeightMasks[ui32NumPInfWeightMasks] = { + 0xFFFFFFFF, + 0x7FFFFFFF, + 0x3FFFFFFF, + 0x1FFFFFFF, + 0x0FFFFFFF, + 0x07FFFFFF, + 0x03FFFFFF, + 0x01FFFFFF, + 0x00FFFFFF, + 0x007FFFFF, + 0x003FFFFF, + 0x001FFFFF, + 0x000FFFFF, + 0x0007FFFF, + 0x0003FFFF, + 0x0001FFFF, + 0x0000FFFF, + 0x00007FFF, + 0x00003FFF, + 0x00001FFF, + 0x00000FFF, + 0x000007FF, + 0x000003FF, + 0x000001FF, + 0x000000FF, + 0x0000007F, + 0x0000003F, + 0x0000001F, + 0x0000000F +}; + +static uint_fast32_t ui32RandomPInf( void ) +{ + int weightMaskNum; + + weightMaskNum = randomN_ui8( ui32NumPInfWeightMasks ); + return random_ui32() & ui32PInfWeightMasks[weightMaskNum]; + +} + +static struct sequence sequenceA; +static int subcase; + +uint_fast32_t genCases_ui32_a; + +void genCases_ui32_a_init( void ) +{ + + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = (genCases_level == 1) ? 3 * ui32NumP1 : 2 * ui32NumP2; + genCases_done = false; + +} + +void genCases_ui32_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + genCases_ui32_a = ui32RandomP3(); + break; + case 1: + genCases_ui32_a = ui32RandomPInf(); + break; + case 2: + genCases_ui32_a = ui32NextP1( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_ui32_a = ui32RandomP3(); + break; + case 2: + genCases_ui32_a = ui32RandomPInf(); + break; + case 3: + subcase = -1; + case 1: + genCases_ui32_a = ui32NextP2( &sequenceA ); + genCases_done = sequenceA.done; + break; + } + } + ++subcase; + +} + diff --git a/source/genCases_ui64.c b/source/genCases_ui64.c new file mode 100644 index 0000000..51dc428 --- /dev/null +++ b/source/genCases_ui64.c @@ -0,0 +1,480 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" +#include "genCases.h" + +struct sequence { + int term1Num, term2Num; + bool done; +}; + +enum { ui64NumP1 = 252 }; +static const uint64_t ui64P1[ui64NumP1] = { + UINT64_C( 0x0000000000000000 ), + UINT64_C( 0x0000000000000001 ), + UINT64_C( 0x0000000000000002 ), + UINT64_C( 0x0000000000000004 ), + UINT64_C( 0x0000000000000008 ), + UINT64_C( 0x0000000000000010 ), + UINT64_C( 0x0000000000000020 ), + UINT64_C( 0x0000000000000040 ), + UINT64_C( 0x0000000000000080 ), + UINT64_C( 0x0000000000000100 ), + UINT64_C( 0x0000000000000200 ), + UINT64_C( 0x0000000000000400 ), + UINT64_C( 0x0000000000000800 ), + UINT64_C( 0x0000000000001000 ), + UINT64_C( 0x0000000000002000 ), + UINT64_C( 0x0000000000004000 ), + UINT64_C( 0x0000000000008000 ), + UINT64_C( 0x0000000000010000 ), + UINT64_C( 0x0000000000020000 ), + UINT64_C( 0x0000000000040000 ), + UINT64_C( 0x0000000000080000 ), + UINT64_C( 0x0000000000100000 ), + UINT64_C( 0x0000000000200000 ), + UINT64_C( 0x0000000000400000 ), + UINT64_C( 0x0000000000800000 ), + UINT64_C( 0x0000000001000000 ), + UINT64_C( 0x0000000002000000 ), + UINT64_C( 0x0000000004000000 ), + UINT64_C( 0x0000000008000000 ), + UINT64_C( 0x0000000010000000 ), + UINT64_C( 0x0000000020000000 ), + UINT64_C( 0x0000000040000000 ), + UINT64_C( 0x0000000080000000 ), + UINT64_C( 0x0000000100000000 ), + UINT64_C( 0x0000000200000000 ), + UINT64_C( 0x0000000400000000 ), + UINT64_C( 0x0000000800000000 ), + UINT64_C( 0x0000001000000000 ), + UINT64_C( 0x0000002000000000 ), + UINT64_C( 0x0000004000000000 ), + UINT64_C( 0x0000008000000000 ), + UINT64_C( 0x0000010000000000 ), + UINT64_C( 0x0000020000000000 ), + UINT64_C( 0x0000040000000000 ), + UINT64_C( 0x0000080000000000 ), + UINT64_C( 0x0000100000000000 ), + UINT64_C( 0x0000200000000000 ), + UINT64_C( 0x0000400000000000 ), + UINT64_C( 0x0000800000000000 ), + UINT64_C( 0x0001000000000000 ), + UINT64_C( 0x0002000000000000 ), + UINT64_C( 0x0004000000000000 ), + UINT64_C( 0x0008000000000000 ), + UINT64_C( 0x0010000000000000 ), + UINT64_C( 0x0020000000000000 ), + UINT64_C( 0x0040000000000000 ), + UINT64_C( 0x0080000000000000 ), + UINT64_C( 0x0100000000000000 ), + UINT64_C( 0x0200000000000000 ), + UINT64_C( 0x0400000000000000 ), + UINT64_C( 0x0800000000000000 ), + UINT64_C( 0x1000000000000000 ), + UINT64_C( 0x2000000000000000 ), + UINT64_C( 0x4000000000000000 ), + UINT64_C( 0x8000000000000000 ), + UINT64_C( 0xC000000000000000 ), + UINT64_C( 0xE000000000000000 ), + UINT64_C( 0xF000000000000000 ), + UINT64_C( 0xF800000000000000 ), + UINT64_C( 0xFC00000000000000 ), + UINT64_C( 0xFE00000000000000 ), + UINT64_C( 0xFF00000000000000 ), + UINT64_C( 0xFF80000000000000 ), + UINT64_C( 0xFFC0000000000000 ), + UINT64_C( 0xFFE0000000000000 ), + UINT64_C( 0xFFF0000000000000 ), + UINT64_C( 0xFFF8000000000000 ), + UINT64_C( 0xFFFC000000000000 ), + UINT64_C( 0xFFFE000000000000 ), + UINT64_C( 0xFFFF000000000000 ), + UINT64_C( 0xFFFF800000000000 ), + UINT64_C( 0xFFFFC00000000000 ), + UINT64_C( 0xFFFFE00000000000 ), + UINT64_C( 0xFFFFF00000000000 ), + UINT64_C( 0xFFFFF80000000000 ), + UINT64_C( 0xFFFFFC0000000000 ), + UINT64_C( 0xFFFFFE0000000000 ), + UINT64_C( 0xFFFFFF0000000000 ), + UINT64_C( 0xFFFFFF8000000000 ), + UINT64_C( 0xFFFFFFC000000000 ), + UINT64_C( 0xFFFFFFE000000000 ), + UINT64_C( 0xFFFFFFF000000000 ), + UINT64_C( 0xFFFFFFF800000000 ), + UINT64_C( 0xFFFFFFFC00000000 ), + UINT64_C( 0xFFFFFFFE00000000 ), + UINT64_C( 0xFFFFFFFF00000000 ), + UINT64_C( 0xFFFFFFFF80000000 ), + UINT64_C( 0xFFFFFFFFC0000000 ), + UINT64_C( 0xFFFFFFFFE0000000 ), + UINT64_C( 0xFFFFFFFFF0000000 ), + UINT64_C( 0xFFFFFFFFF8000000 ), + UINT64_C( 0xFFFFFFFFFC000000 ), + UINT64_C( 0xFFFFFFFFFE000000 ), + UINT64_C( 0xFFFFFFFFFF000000 ), + UINT64_C( 0xFFFFFFFFFF800000 ), + UINT64_C( 0xFFFFFFFFFFC00000 ), + UINT64_C( 0xFFFFFFFFFFE00000 ), + UINT64_C( 0xFFFFFFFFFFF00000 ), + UINT64_C( 0xFFFFFFFFFFF80000 ), + UINT64_C( 0xFFFFFFFFFFFC0000 ), + UINT64_C( 0xFFFFFFFFFFFE0000 ), + UINT64_C( 0xFFFFFFFFFFFF0000 ), + UINT64_C( 0xFFFFFFFFFFFF8000 ), + UINT64_C( 0xFFFFFFFFFFFFC000 ), + UINT64_C( 0xFFFFFFFFFFFFE000 ), + UINT64_C( 0xFFFFFFFFFFFFF000 ), + UINT64_C( 0xFFFFFFFFFFFFF800 ), + UINT64_C( 0xFFFFFFFFFFFFFC00 ), + UINT64_C( 0xFFFFFFFFFFFFFE00 ), + UINT64_C( 0xFFFFFFFFFFFFFF00 ), + UINT64_C( 0xFFFFFFFFFFFFFF80 ), + UINT64_C( 0xFFFFFFFFFFFFFFC0 ), + UINT64_C( 0xFFFFFFFFFFFFFFE0 ), + UINT64_C( 0xFFFFFFFFFFFFFFF0 ), + UINT64_C( 0xFFFFFFFFFFFFFFF8 ), + UINT64_C( 0xFFFFFFFFFFFFFFFC ), + UINT64_C( 0xFFFFFFFFFFFFFFFE ), + UINT64_C( 0xFFFFFFFFFFFFFFFF ), + UINT64_C( 0xFFFFFFFFFFFFFFFD ), + UINT64_C( 0xFFFFFFFFFFFFFFFB ), + UINT64_C( 0xFFFFFFFFFFFFFFF7 ), + UINT64_C( 0xFFFFFFFFFFFFFFEF ), + UINT64_C( 0xFFFFFFFFFFFFFFDF ), + UINT64_C( 0xFFFFFFFFFFFFFFBF ), + UINT64_C( 0xFFFFFFFFFFFFFF7F ), + UINT64_C( 0xFFFFFFFFFFFFFEFF ), + UINT64_C( 0xFFFFFFFFFFFFFDFF ), + UINT64_C( 0xFFFFFFFFFFFFFBFF ), + UINT64_C( 0xFFFFFFFFFFFFF7FF ), + UINT64_C( 0xFFFFFFFFFFFFEFFF ), + UINT64_C( 0xFFFFFFFFFFFFDFFF ), + UINT64_C( 0xFFFFFFFFFFFFBFFF ), + UINT64_C( 0xFFFFFFFFFFFF7FFF ), + UINT64_C( 0xFFFFFFFFFFFEFFFF ), + UINT64_C( 0xFFFFFFFFFFFDFFFF ), + UINT64_C( 0xFFFFFFFFFFFBFFFF ), + UINT64_C( 0xFFFFFFFFFFF7FFFF ), + UINT64_C( 0xFFFFFFFFFFEFFFFF ), + UINT64_C( 0xFFFFFFFFFFDFFFFF ), + UINT64_C( 0xFFFFFFFFFFBFFFFF ), + UINT64_C( 0xFFFFFFFFFF7FFFFF ), + UINT64_C( 0xFFFFFFFFFEFFFFFF ), + UINT64_C( 0xFFFFFFFFFDFFFFFF ), + UINT64_C( 0xFFFFFFFFFBFFFFFF ), + UINT64_C( 0xFFFFFFFFF7FFFFFF ), + UINT64_C( 0xFFFFFFFFEFFFFFFF ), + UINT64_C( 0xFFFFFFFFDFFFFFFF ), + UINT64_C( 0xFFFFFFFFBFFFFFFF ), + UINT64_C( 0xFFFFFFFF7FFFFFFF ), + UINT64_C( 0xFFFFFFFEFFFFFFFF ), + UINT64_C( 0xFFFFFFFDFFFFFFFF ), + UINT64_C( 0xFFFFFFFBFFFFFFFF ), + UINT64_C( 0xFFFFFFF7FFFFFFFF ), + UINT64_C( 0xFFFFFFEFFFFFFFFF ), + UINT64_C( 0xFFFFFFDFFFFFFFFF ), + UINT64_C( 0xFFFFFFBFFFFFFFFF ), + UINT64_C( 0xFFFFFF7FFFFFFFFF ), + UINT64_C( 0xFFFFFEFFFFFFFFFF ), + UINT64_C( 0xFFFFFDFFFFFFFFFF ), + UINT64_C( 0xFFFFFBFFFFFFFFFF ), + UINT64_C( 0xFFFFF7FFFFFFFFFF ), + UINT64_C( 0xFFFFEFFFFFFFFFFF ), + UINT64_C( 0xFFFFDFFFFFFFFFFF ), + UINT64_C( 0xFFFFBFFFFFFFFFFF ), + UINT64_C( 0xFFFF7FFFFFFFFFFF ), + UINT64_C( 0xFFFEFFFFFFFFFFFF ), + UINT64_C( 0xFFFDFFFFFFFFFFFF ), + UINT64_C( 0xFFFBFFFFFFFFFFFF ), + UINT64_C( 0xFFF7FFFFFFFFFFFF ), + UINT64_C( 0xFFEFFFFFFFFFFFFF ), + UINT64_C( 0xFFDFFFFFFFFFFFFF ), + UINT64_C( 0xFFBFFFFFFFFFFFFF ), + UINT64_C( 0xFF7FFFFFFFFFFFFF ), + UINT64_C( 0xFEFFFFFFFFFFFFFF ), + UINT64_C( 0xFDFFFFFFFFFFFFFF ), + UINT64_C( 0xFBFFFFFFFFFFFFFF ), + UINT64_C( 0xF7FFFFFFFFFFFFFF ), + UINT64_C( 0xEFFFFFFFFFFFFFFF ), + UINT64_C( 0xDFFFFFFFFFFFFFFF ), + UINT64_C( 0xBFFFFFFFFFFFFFFF ), + UINT64_C( 0x7FFFFFFFFFFFFFFF ), + UINT64_C( 0x3FFFFFFFFFFFFFFF ), + UINT64_C( 0x1FFFFFFFFFFFFFFF ), + UINT64_C( 0x0FFFFFFFFFFFFFFF ), + UINT64_C( 0x07FFFFFFFFFFFFFF ), + UINT64_C( 0x03FFFFFFFFFFFFFF ), + UINT64_C( 0x01FFFFFFFFFFFFFF ), + UINT64_C( 0x00FFFFFFFFFFFFFF ), + UINT64_C( 0x007FFFFFFFFFFFFF ), + UINT64_C( 0x003FFFFFFFFFFFFF ), + UINT64_C( 0x001FFFFFFFFFFFFF ), + UINT64_C( 0x000FFFFFFFFFFFFF ), + UINT64_C( 0x0007FFFFFFFFFFFF ), + UINT64_C( 0x0003FFFFFFFFFFFF ), + UINT64_C( 0x0001FFFFFFFFFFFF ), + UINT64_C( 0x0000FFFFFFFFFFFF ), + UINT64_C( 0x00007FFFFFFFFFFF ), + UINT64_C( 0x00003FFFFFFFFFFF ), + UINT64_C( 0x00001FFFFFFFFFFF ), + UINT64_C( 0x00000FFFFFFFFFFF ), + UINT64_C( 0x000007FFFFFFFFFF ), + UINT64_C( 0x000003FFFFFFFFFF ), + UINT64_C( 0x000001FFFFFFFFFF ), + UINT64_C( 0x000000FFFFFFFFFF ), + UINT64_C( 0x0000007FFFFFFFFF ), + UINT64_C( 0x0000003FFFFFFFFF ), + UINT64_C( 0x0000001FFFFFFFFF ), + UINT64_C( 0x0000000FFFFFFFFF ), + UINT64_C( 0x00000007FFFFFFFF ), + UINT64_C( 0x00000003FFFFFFFF ), + UINT64_C( 0x00000001FFFFFFFF ), + UINT64_C( 0x00000000FFFFFFFF ), + UINT64_C( 0x000000007FFFFFFF ), + UINT64_C( 0x000000003FFFFFFF ), + UINT64_C( 0x000000001FFFFFFF ), + UINT64_C( 0x000000000FFFFFFF ), + UINT64_C( 0x0000000007FFFFFF ), + UINT64_C( 0x0000000003FFFFFF ), + UINT64_C( 0x0000000001FFFFFF ), + UINT64_C( 0x0000000000FFFFFF ), + UINT64_C( 0x00000000007FFFFF ), + UINT64_C( 0x00000000003FFFFF ), + UINT64_C( 0x00000000001FFFFF ), + UINT64_C( 0x00000000000FFFFF ), + UINT64_C( 0x000000000007FFFF ), + UINT64_C( 0x000000000003FFFF ), + UINT64_C( 0x000000000001FFFF ), + UINT64_C( 0x000000000000FFFF ), + UINT64_C( 0x0000000000007FFF ), + UINT64_C( 0x0000000000003FFF ), + UINT64_C( 0x0000000000001FFF ), + UINT64_C( 0x0000000000000FFF ), + UINT64_C( 0x00000000000007FF ), + UINT64_C( 0x00000000000003FF ), + UINT64_C( 0x00000000000001FF ), + UINT64_C( 0x00000000000000FF ), + UINT64_C( 0x000000000000007F ), + UINT64_C( 0x000000000000003F ), + UINT64_C( 0x000000000000001F ), + UINT64_C( 0x000000000000000F ), + UINT64_C( 0x0000000000000007 ), + UINT64_C( 0x0000000000000003 ) +}; + +static uint_fast64_t ui64NextP1( struct sequence *sequencePtr ) +{ + int termNum; + uint_fast64_t z; + + termNum = sequencePtr->term1Num; + z = ui64P1[termNum]; + ++termNum; + if ( ui64NumP1 <= termNum ) { + termNum = 0; + sequencePtr->done = true; + } + sequencePtr->term1Num = termNum; + return z; + +} + +static const uint_fast64_t ui64NumP2 = (ui64NumP1 * ui64NumP1 + ui64NumP1) / 2; + +static uint_fast64_t ui64NextP2( struct sequence *sequencePtr ) +{ + int term1Num, term2Num; + uint_fast64_t z; + + term2Num = sequencePtr->term2Num; + term1Num = sequencePtr->term1Num; + z = ui64P1[term1Num] + ui64P1[term2Num]; + ++term2Num; + if ( ui64NumP1 <= term2Num ) { + ++term1Num; + if ( ui64NumP1 <= term1Num ) { + term1Num = 0; + sequencePtr->done = true; + } + term2Num = term1Num; + sequencePtr->term1Num = term1Num; + } + sequencePtr->term2Num = term2Num; + return z; + +} + +static uint_fast64_t ui64RandomP3( void ) +{ + + return + ui64P1[randomN_ui8( ui64NumP1 )] + ui64P1[randomN_ui8( ui64NumP1 )] + + ui64P1[randomN_ui8( ui64NumP1 )]; + +} + +enum { ui64NumPInfWeightMasks = 61 }; +static const uint64_t ui64PInfWeightMasks[ui64NumPInfWeightMasks] = { + UINT64_C( 0xFFFFFFFFFFFFFFFF ), + UINT64_C( 0x7FFFFFFFFFFFFFFF ), + UINT64_C( 0x3FFFFFFFFFFFFFFF ), + UINT64_C( 0x1FFFFFFFFFFFFFFF ), + UINT64_C( 0x0FFFFFFFFFFFFFFF ), + UINT64_C( 0x07FFFFFFFFFFFFFF ), + UINT64_C( 0x03FFFFFFFFFFFFFF ), + UINT64_C( 0x01FFFFFFFFFFFFFF ), + UINT64_C( 0x00FFFFFFFFFFFFFF ), + UINT64_C( 0x007FFFFFFFFFFFFF ), + UINT64_C( 0x003FFFFFFFFFFFFF ), + UINT64_C( 0x001FFFFFFFFFFFFF ), + UINT64_C( 0x000FFFFFFFFFFFFF ), + UINT64_C( 0x0007FFFFFFFFFFFF ), + UINT64_C( 0x0003FFFFFFFFFFFF ), + UINT64_C( 0x0001FFFFFFFFFFFF ), + UINT64_C( 0x0000FFFFFFFFFFFF ), + UINT64_C( 0x00007FFFFFFFFFFF ), + UINT64_C( 0x00003FFFFFFFFFFF ), + UINT64_C( 0x00001FFFFFFFFFFF ), + UINT64_C( 0x00000FFFFFFFFFFF ), + UINT64_C( 0x000007FFFFFFFFFF ), + UINT64_C( 0x000003FFFFFFFFFF ), + UINT64_C( 0x000001FFFFFFFFFF ), + UINT64_C( 0x000000FFFFFFFFFF ), + UINT64_C( 0x0000007FFFFFFFFF ), + UINT64_C( 0x0000003FFFFFFFFF ), + UINT64_C( 0x0000001FFFFFFFFF ), + UINT64_C( 0x0000000FFFFFFFFF ), + UINT64_C( 0x00000007FFFFFFFF ), + UINT64_C( 0x00000003FFFFFFFF ), + UINT64_C( 0x00000001FFFFFFFF ), + UINT64_C( 0x00000000FFFFFFFF ), + UINT64_C( 0x000000007FFFFFFF ), + UINT64_C( 0x000000003FFFFFFF ), + UINT64_C( 0x000000001FFFFFFF ), + UINT64_C( 0x000000000FFFFFFF ), + UINT64_C( 0x0000000007FFFFFF ), + UINT64_C( 0x0000000003FFFFFF ), + UINT64_C( 0x0000000001FFFFFF ), + UINT64_C( 0x0000000000FFFFFF ), + UINT64_C( 0x00000000007FFFFF ), + UINT64_C( 0x00000000003FFFFF ), + UINT64_C( 0x00000000001FFFFF ), + UINT64_C( 0x00000000000FFFFF ), + UINT64_C( 0x000000000007FFFF ), + UINT64_C( 0x000000000003FFFF ), + UINT64_C( 0x000000000001FFFF ), + UINT64_C( 0x000000000000FFFF ), + UINT64_C( 0x0000000000007FFF ), + UINT64_C( 0x0000000000003FFF ), + UINT64_C( 0x0000000000001FFF ), + UINT64_C( 0x0000000000000FFF ), + UINT64_C( 0x00000000000007FF ), + UINT64_C( 0x00000000000003FF ), + UINT64_C( 0x00000000000001FF ), + UINT64_C( 0x00000000000000FF ), + UINT64_C( 0x000000000000007F ), + UINT64_C( 0x000000000000003F ), + UINT64_C( 0x000000000000001F ), + UINT64_C( 0x000000000000000F ) +}; + +static uint_fast64_t ui64RandomPInf( void ) +{ + int weightMaskNum; + + weightMaskNum = randomN_ui8( ui64NumPInfWeightMasks ); + return random_ui64() & ui64PInfWeightMasks[weightMaskNum]; + +} + +static struct sequence sequenceA; +static int subcase; + +uint_fast64_t genCases_ui64_a; + +void genCases_ui64_a_init( void ) +{ + + sequenceA.term2Num = 0; + sequenceA.term1Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = (genCases_level == 1) ? 3 * ui64NumP1 : 2 * ui64NumP2; + genCases_done = false; + +} + +void genCases_ui64_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + genCases_ui64_a = ui64RandomP3(); + break; + case 1: + genCases_ui64_a = ui64RandomPInf(); + break; + case 2: + genCases_ui64_a = ui64NextP1( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_ui64_a = ui64RandomP3(); + break; + case 2: + genCases_ui64_a = ui64RandomPInf(); + break; + case 3: + subcase = -1; + case 1: + genCases_ui64_a = ui64NextP2( &sequenceA ); + genCases_done = sequenceA.done; + break; + } + } + ++subcase; + +} + diff --git a/source/genCases_writeTestsTotal.c b/source/genCases_writeTestsTotal.c new file mode 100644 index 0000000..64eda6d --- /dev/null +++ b/source/genCases_writeTestsTotal.c @@ -0,0 +1,60 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "genCases.h" + +void genCases_writeTestsTotal( bool forever ) +{ + + if ( forever ) { + fputs( "Unbounded tests.\n", stderr ); + } else { + if ( 2000000000 <= genCases_total ) { + fprintf( + stderr, + "\r%lu%09lu tests total.\n", + (long unsigned) (genCases_total / 1000000000), + (long unsigned) (genCases_total % 1000000000) + ); + } else { + fprintf( + stderr, "\r%lu tests total.\n", (long unsigned) genCases_total + ); + } + } + +} + diff --git a/source/genLoops.c b/source/genLoops.c new file mode 100644 index 0000000..893c344 --- /dev/null +++ b/source/genLoops.c @@ -0,0 +1,2224 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include +#include "platform.h" +#include "uint128.h" +#include "fail.h" +#include "softfloat.h" +#include "genCases.h" +#include "writeHex.h" +#include "genLoops.h" + +volatile bool genLoops_stop = false; + +bool genLoops_forever; +bool genLoops_givenCount; +uint_fast64_t genLoops_count; +uint_fast8_t *genLoops_trueFlagsPtr; + +union ui32_f32 { uint32_t ui; float32_t f; }; +union ui64_f64 { uint64_t ui; float64_t f; }; + +static void checkEnoughCases( void ) +{ + + if ( genLoops_givenCount && (genLoops_count < genCases_total) ) { + if ( 2000000000 <= genCases_total ) { + fail( + "Too few cases; minimum is %lu%09lu", + (unsigned long) (genCases_total / 1000000000), + (unsigned long) (genCases_total % 1000000000) + ); + } else { + fail( + "Too few cases; minimum is %lu", (unsigned long) genCases_total + ); + } + } + +} + +static void writeGenOutput_flags( uint_fast8_t flags ) +{ + uint_fast8_t commonFlags; + + commonFlags = 0; + if ( flags & softfloat_flag_invalid ) commonFlags |= 0x10; + if ( flags & softfloat_flag_infinite ) commonFlags |= 0x08; + if ( flags & softfloat_flag_overflow ) commonFlags |= 0x04; + if ( flags & softfloat_flag_underflow ) commonFlags |= 0x02; + if ( flags & softfloat_flag_inexact ) commonFlags |= 0x01; + writeHex_ui8( commonFlags, '\n' ); + +} + +static bool writeGenOutputs_bool( bool z, uint_fast8_t flags ) +{ + + writeHex_bool( z, ' ' ); + writeGenOutput_flags( flags ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) return true; + } + return false; + +} + +static bool writeGenOutputs_ui32( uint_fast32_t z, uint_fast8_t flags ) +{ + + writeHex_ui32( z, ' ' ); + writeGenOutput_flags( flags ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) return true; + } + return false; + +} + +static bool writeGenOutputs_ui64( uint_fast64_t z, uint_fast8_t flags ) +{ + + writeHex_ui64( z, ' ' ); + writeGenOutput_flags( flags ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) return true; + } + return false; + +} + +#ifdef EXTFLOAT80 + +static void writeHex_uiExtF80M( const extFloat80_t *aPtr, char sepChar ) +{ + const struct extFloat80M *aSPtr; + + aSPtr = (const struct extFloat80M *) aPtr; + writeHex_ui16( aSPtr->signExp, 0 ); + writeHex_ui64( aSPtr->signif, sepChar ); + +} + +static + bool writeGenOutputs_extF80M( const extFloat80_t *aPtr, uint_fast8_t flags ) +{ + + writeHex_uiExtF80M( aPtr, ' ' ); + writeGenOutput_flags( flags ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) return true; + } + return false; + +} + +#endif + +#ifdef FLOAT128 + +static void writeHex_uiF128M( const float128_t *aPtr, char sepChar ) +{ + const struct uint128 *uiAPtr; + + uiAPtr = (const struct uint128 *) aPtr; + writeHex_ui64( uiAPtr->v64, 0 ); + writeHex_ui64( uiAPtr->v0, sepChar ); + +} + +static bool writeGenOutputs_f128M( const float128_t *aPtr, uint_fast8_t flags ) +{ + + writeHex_uiF128M( aPtr, ' ' ); + writeGenOutput_flags( flags ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) return true; + } + return false; + +} + +#endif + +void gen_a_ui32( void ) +{ + + genCases_ui32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui32_a_next(); + writeHex_ui32( genCases_ui32_a, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_a_ui64( void ) +{ + + genCases_ui64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui64_a_next(); + writeHex_ui64( genCases_ui64_a, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_a_i32( void ) +{ + + genCases_i32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i32_a_next(); + writeHex_ui32( genCases_i32_a, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_a_i64( void ) +{ + + genCases_i64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i64_a_next(); + writeHex_ui64( genCases_i64_a, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_a_f32( void ) +{ + union ui32_f32 uA; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_ab_f32( void ) +{ + union ui32_f32 u; + + genCases_f32_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_ab_next(); + u.f = genCases_f32_a; + writeHex_ui32( u.ui, ' ' ); + u.f = genCases_f32_b; + writeHex_ui32( u.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_abc_f32( void ) +{ + union ui32_f32 u; + + genCases_f32_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_abc_next(); + u.f = genCases_f32_a; + writeHex_ui32( u.ui, ' ' ); + u.f = genCases_f32_b; + writeHex_ui32( u.ui, ' ' ); + u.f = genCases_f32_c; + writeHex_ui32( u.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_a_f64( void ) +{ + union ui64_f64 uA; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_ab_f64( void ) +{ + union ui64_f64 u; + + genCases_f64_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_ab_next(); + u.f = genCases_f64_a; + writeHex_ui64( u.ui, ' ' ); + u.f = genCases_f64_b; + writeHex_ui64( u.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_abc_f64( void ) +{ + union ui64_f64 u; + + genCases_f64_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_abc_next(); + u.f = genCases_f64_a; + writeHex_ui64( u.ui, ' ' ); + u.f = genCases_f64_b; + writeHex_ui64( u.ui, ' ' ); + u.f = genCases_f64_c; + writeHex_ui64( u.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_extF80( void ) +{ + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_ab_extF80( void ) +{ + + genCases_extF80_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_ab_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + writeHex_uiExtF80M( &genCases_extF80_b, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_abc_extF80( void ) +{ + + genCases_extF80_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_abc_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + writeHex_uiExtF80M( &genCases_extF80_b, ' ' ); + writeHex_uiExtF80M( &genCases_extF80_c, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_f128( void ) +{ + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_ab_f128( void ) +{ + + genCases_f128_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_ab_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + writeHex_uiF128M( &genCases_f128_b, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_abc_f128( void ) +{ + + genCases_f128_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_abc_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + writeHex_uiF128M( &genCases_f128_b, ' ' ); + writeHex_uiF128M( &genCases_f128_c, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +#endif + +void gen_a_ui32_z_f32( float32_t trueFunction( uint_fast32_t ) ) +{ + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_ui32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui32_a_next(); + writeHex_ui32( genCases_ui32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_ui32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +void gen_a_ui32_z_f64( float64_t trueFunction( uint_fast32_t ) ) +{ + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_ui32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui32_a_next(); + writeHex_ui32( genCases_ui32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_ui32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_ui32_z_extF80( void trueFunction( uint_fast32_t, extFloat80_t * ) ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_ui32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui32_a_next(); + writeHex_ui32( genCases_ui32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui32_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_ui32_z_f128( void trueFunction( uint_fast32_t, float128_t * ) ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_ui32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui32_a_next(); + writeHex_ui32( genCases_ui32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui32_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_a_ui64_z_f32( float32_t trueFunction( uint_fast64_t ) ) +{ + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_ui64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui64_a_next(); + writeHex_ui64( genCases_ui64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_ui64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +void gen_a_ui64_z_f64( float64_t trueFunction( uint_fast64_t ) ) +{ + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_ui64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui64_a_next(); + writeHex_ui64( genCases_ui64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_ui64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_ui64_z_extF80( void trueFunction( uint_fast64_t, extFloat80_t * ) ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_ui64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui64_a_next(); + writeHex_ui64( genCases_ui64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui64_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_ui64_z_f128( void trueFunction( uint_fast64_t, float128_t * ) ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_ui64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui64_a_next(); + writeHex_ui64( genCases_ui64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui64_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_a_i32_z_f32( float32_t trueFunction( int_fast32_t ) ) +{ + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_i32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i32_a_next(); + writeHex_ui32( genCases_i32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_i32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +void gen_a_i32_z_f64( float64_t trueFunction( int_fast32_t ) ) +{ + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_i32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i32_a_next(); + writeHex_ui32( genCases_i32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_i32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_i32_z_extF80( void trueFunction( int_fast32_t, extFloat80_t * ) ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_i32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i32_a_next(); + writeHex_ui32( genCases_i32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_i32_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_i32_z_f128( void trueFunction( int_fast32_t, float128_t * ) ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_i32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i32_a_next(); + writeHex_ui32( genCases_i32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_i32_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_a_i64_z_f32( float32_t trueFunction( int_fast64_t ) ) +{ + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_i64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i64_a_next(); + writeHex_ui64( genCases_i64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_i64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +void gen_a_i64_z_f64( float64_t trueFunction( int_fast64_t ) ) +{ + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_i64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i64_a_next(); + writeHex_ui64( genCases_i64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_i64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_i64_z_extF80( void trueFunction( int_fast64_t, extFloat80_t * ) ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_i64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i64_a_next(); + writeHex_ui64( genCases_i64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_i64_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_i64_z_f128( void trueFunction( int_fast64_t, float128_t * ) ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_i64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i64_a_next(); + writeHex_ui64( genCases_i64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_i64_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void + gen_a_f32_z_ui32_rx( + uint_fast32_t trueFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui32_f32 uA; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f32_z_ui64_rx( + uint_fast64_t trueFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui32_f32 uA; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f32_z_i32_rx( + int_fast32_t trueFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui32_f32 uA; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f32_z_i64_rx( + int_fast64_t trueFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui32_f32 uA; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f32_z_ui32_x( + uint_fast32_t trueFunction( float32_t, bool ), bool exact ) +{ + union ui32_f32 uA; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f32_z_ui64_x( + uint_fast64_t trueFunction( float32_t, bool ), bool exact ) +{ + union ui32_f32 uA; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f32_z_i32_x( int_fast32_t trueFunction( float32_t, bool ), bool exact ) +{ + union ui32_f32 uA; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f32_z_i64_x( int_fast64_t trueFunction( float32_t, bool ), bool exact ) +{ + union ui32_f32 uA; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void gen_a_f32_z_f64( float64_t trueFunction( float32_t ) ) +{ + union ui32_f32 uA; + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_f32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_f32_z_extF80( void trueFunction( float32_t, extFloat80_t * ) ) +{ + union ui32_f32 uA; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_f32_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_f32_z_f128( void trueFunction( float32_t, float128_t * ) ) +{ + union ui32_f32 uA; + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_f32_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_az_f32( float32_t trueFunction( float32_t ) ) +{ + union ui32_f32 u; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + u.f = genCases_f32_a; + writeHex_ui32( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( u.ui, trueFlags ) ) break; + } + +} + +void + gen_az_f32_rx( + float32_t trueFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui32_f32 u; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + u.f = genCases_f32_a; + writeHex_ui32( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( u.ui, trueFlags ) ) break; + } + +} + +void gen_abz_f32( float32_t trueFunction( float32_t, float32_t ) ) +{ + union ui32_f32 u; + uint_fast8_t trueFlags; + + genCases_f32_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_ab_next(); + u.f = genCases_f32_a; + writeHex_ui32( u.ui, ' ' ); + u.f = genCases_f32_b; + writeHex_ui32( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f32_a, genCases_f32_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( u.ui, trueFlags ) ) break; + } + +} + +void gen_abcz_f32( float32_t trueFunction( float32_t, float32_t, float32_t ) ) +{ + union ui32_f32 u; + uint_fast8_t trueFlags; + + genCases_f32_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_abc_next(); + u.f = genCases_f32_a; + writeHex_ui32( u.ui, ' ' ); + u.f = genCases_f32_b; + writeHex_ui32( u.ui, ' ' ); + u.f = genCases_f32_c; + writeHex_ui32( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f32_a, genCases_f32_b, genCases_f32_c ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( u.ui, trueFlags ) ) break; + } + +} + +void gen_ab_f32_z_bool( bool trueFunction( float32_t, float32_t ) ) +{ + union ui32_f32 u; + bool trueZ; + uint_fast8_t trueFlags; + + genCases_f32_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_ab_next(); + u.f = genCases_f32_a; + writeHex_ui32( u.ui, ' ' ); + u.f = genCases_f32_b; + writeHex_ui32( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, genCases_f32_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_bool( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_ui32_rx( + uint_fast32_t trueFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui64_f64 uA; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_ui64_rx( + uint_fast64_t trueFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui64_f64 uA; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_i32_rx( + int_fast32_t trueFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui64_f64 uA; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_i64_rx( + int_fast64_t trueFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui64_f64 uA; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_ui32_x( + uint_fast32_t trueFunction( float64_t, bool ), bool exact ) +{ + union ui64_f64 uA; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_ui64_x( + uint_fast64_t trueFunction( float64_t, bool ), bool exact ) +{ + union ui64_f64 uA; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_i32_x( int_fast32_t trueFunction( float64_t, bool ), bool exact ) +{ + union ui64_f64 uA; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f64_z_i64_x( int_fast64_t trueFunction( float64_t, bool ), bool exact ) +{ + union ui64_f64 uA; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void gen_a_f64_z_f32( float32_t trueFunction( float64_t ) ) +{ + union ui64_f64 uA; + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_f64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_f64_z_extF80( void trueFunction( float64_t, extFloat80_t * ) ) +{ + union ui64_f64 uA; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_f64_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_f64_z_f128( void trueFunction( float64_t, float128_t * ) ) +{ + union ui64_f64 uA; + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_f64_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_az_f64( float64_t trueFunction( float64_t ) ) +{ + union ui64_f64 u; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + u.f = genCases_f64_a; + writeHex_ui64( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( u.ui, trueFlags ) ) break; + } + +} + +void + gen_az_f64_rx( + float64_t trueFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui64_f64 u; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + u.f = genCases_f64_a; + writeHex_ui64( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( u.ui, trueFlags ) ) break; + } + +} + +void gen_abz_f64( float64_t trueFunction( float64_t, float64_t ) ) +{ + union ui64_f64 u; + uint_fast8_t trueFlags; + + genCases_f64_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_ab_next(); + u.f = genCases_f64_a; + writeHex_ui64( u.ui, ' ' ); + u.f = genCases_f64_b; + writeHex_ui64( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f64_a, genCases_f64_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( u.ui, trueFlags ) ) break; + } + +} + +void gen_abcz_f64( float64_t trueFunction( float64_t, float64_t, float64_t ) ) +{ + union ui64_f64 u; + uint_fast8_t trueFlags; + + genCases_f64_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_abc_next(); + u.f = genCases_f64_a; + writeHex_ui64( u.ui, ' ' ); + u.f = genCases_f64_b; + writeHex_ui64( u.ui, ' ' ); + u.f = genCases_f64_c; + writeHex_ui64( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f64_a, genCases_f64_b, genCases_f64_c ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( u.ui, trueFlags ) ) break; + } + +} + +void gen_ab_f64_z_bool( bool trueFunction( float64_t, float64_t ) ) +{ + union ui64_f64 u; + bool trueZ; + uint_fast8_t trueFlags; + + genCases_f64_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_ab_next(); + u.f = genCases_f64_a; + writeHex_ui64( u.ui, ' ' ); + u.f = genCases_f64_b; + writeHex_ui64( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, genCases_f64_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_bool( trueZ, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void + gen_a_extF80_z_ui32_rx( + uint_fast32_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_extF80_z_ui64_rx( + uint_fast64_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_extF80_z_i32_rx( + int_fast32_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_extF80_z_i64_rx( + int_fast64_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_extF80_z_ui32_x( + uint_fast32_t trueFunction( const extFloat80_t *, bool ), bool exact ) +{ + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_extF80_z_ui64_x( + uint_fast64_t trueFunction( const extFloat80_t *, bool ), bool exact ) +{ + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_extF80_z_i32_x( + int_fast32_t trueFunction( const extFloat80_t *, bool ), bool exact ) +{ + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_extF80_z_i64_x( + int_fast64_t trueFunction( const extFloat80_t *, bool ), bool exact ) +{ + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void gen_a_extF80_z_f32( float32_t trueFunction( const extFloat80_t * ) ) +{ + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( &genCases_extF80_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +void gen_a_extF80_z_f64( float64_t trueFunction( const extFloat80_t * ) ) +{ + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( &genCases_extF80_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef FLOAT128 + +void + gen_a_extF80_z_f128( void trueFunction( const extFloat80_t *, float128_t * ) ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_az_extF80( void trueFunction( const extFloat80_t *, extFloat80_t * ) ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_az_extF80_rx( + void + trueFunction( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), + uint_fast8_t roundingMode, + bool exact + ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, roundingMode, exact, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_abz_extF80( + void + trueFunction( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ) + ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_ab_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + writeHex_uiExtF80M( &genCases_extF80_b, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, &genCases_extF80_b, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_abcz_extF80( + void + trueFunction( + const extFloat80_t *, + const extFloat80_t *, + const extFloat80_t *, + extFloat80_t * + ) + ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_abc_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + writeHex_uiExtF80M( &genCases_extF80_b, ' ' ); + writeHex_uiExtF80M( &genCases_extF80_c, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( + &genCases_extF80_a, &genCases_extF80_b, &genCases_extF80_c, &trueZ + ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_ab_extF80_z_bool( + bool trueFunction( const extFloat80_t *, const extFloat80_t * ) ) +{ + bool trueZ; + uint_fast8_t trueFlags; + + genCases_extF80_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_ab_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + writeHex_uiExtF80M( &genCases_extF80_b, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, &genCases_extF80_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_bool( trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void + gen_a_f128_z_ui32_rx( + uint_fast32_t trueFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f128_z_ui64_rx( + uint_fast64_t trueFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f128_z_i32_rx( + int_fast32_t trueFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f128_z_i64_rx( + int_fast64_t trueFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f128_z_ui32_x( + uint_fast32_t trueFunction( const float128_t *, bool ), bool exact ) +{ + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f128_z_ui64_x( + uint_fast64_t trueFunction( const float128_t *, bool ), bool exact ) +{ + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f128_z_i32_x( + int_fast32_t trueFunction( const float128_t *, bool ), bool exact ) +{ + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f128_z_i64_x( + int_fast64_t trueFunction( const float128_t *, bool ), bool exact ) +{ + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void gen_a_f128_z_f32( float32_t trueFunction( const float128_t * ) ) +{ + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( &genCases_f128_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +void gen_a_f128_z_f64( float64_t trueFunction( const float128_t * ) ) +{ + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( &genCases_f128_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void + gen_a_f128_z_extF80( void trueFunction( const float128_t *, extFloat80_t * ) ) +{ + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_az_f128( void trueFunction( const float128_t *, float128_t * ) ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_az_f128_rx( + void trueFunction( const float128_t *, uint_fast8_t, bool, float128_t * ), + uint_fast8_t roundingMode, + bool exact + ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, roundingMode, exact, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_abz_f128( + void trueFunction( const float128_t *, const float128_t *, float128_t * ) + ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_ab_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + writeHex_uiF128M( &genCases_f128_b, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, &genCases_f128_b, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_abcz_f128( + void + trueFunction( + const float128_t *, + const float128_t *, + const float128_t *, + float128_t * + ) + ) +{ + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_f128_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_abc_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + writeHex_uiF128M( &genCases_f128_b, ' ' ); + writeHex_uiF128M( &genCases_f128_c, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( + &genCases_f128_a, &genCases_f128_b, &genCases_f128_c, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +void + gen_ab_f128_z_bool( + bool trueFunction( const float128_t *, const float128_t * ) ) +{ + bool trueZ; + uint_fast8_t trueFlags; + + genCases_f128_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_ab_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + writeHex_uiF128M( &genCases_f128_b, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, &genCases_f128_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_bool( trueZ, trueFlags ) ) break; + } + +} + +#endif + diff --git a/source/genLoops.h b/source/genLoops.h new file mode 100644 index 0000000..74ac42e --- /dev/null +++ b/source/genLoops.h @@ -0,0 +1,277 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "softfloat.h" + +extern volatile bool genLoops_stop; + +extern bool genLoops_forever; +extern bool genLoops_givenCount; +extern uint_fast64_t genLoops_count; +extern uint_fast8_t *genLoops_trueFlagsPtr; + +void gen_a_ui32( void ); +void gen_a_ui64( void ); +void gen_a_i32( void ); +void gen_a_i64( void ); +void gen_a_f32( void ); +void gen_ab_f32( void ); +void gen_abc_f32( void ); +void gen_a_f64( void ); +void gen_ab_f64( void ); +void gen_abc_f64( void ); +#ifdef EXTFLOAT80 +void gen_a_extF80( void ); +void gen_ab_extF80( void ); +void gen_abc_extF80( void ); +#endif +#ifdef FLOAT128 +void gen_a_f128( void ); +void gen_ab_f128( void ); +void gen_abc_f128( void ); +#endif + +void gen_a_ui32_z_f32( float32_t ( uint_fast32_t ) ); +void gen_a_ui32_z_f64( float64_t ( uint_fast32_t ) ); +#ifdef EXTFLOAT80 +void gen_a_ui32_z_extF80( void ( uint_fast32_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void gen_a_ui32_z_f128( void ( uint_fast32_t, float128_t * ) ); +#endif +void gen_a_ui64_z_f32( float32_t ( uint_fast64_t ) ); +void gen_a_ui64_z_f64( float64_t ( uint_fast64_t ) ); +#ifdef EXTFLOAT80 +void gen_a_ui64_z_extF80( void ( uint_fast64_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void gen_a_ui64_z_f128( void ( uint_fast64_t, float128_t * ) ); +#endif +void gen_a_i32_z_f32( float32_t ( int_fast32_t ) ); +void gen_a_i32_z_f64( float64_t ( int_fast32_t ) ); +#ifdef EXTFLOAT80 +void gen_a_i32_z_extF80( void ( int_fast32_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void gen_a_i32_z_f128( void ( int_fast32_t, float128_t * ) ); +#endif +void gen_a_i64_z_f32( float32_t ( int_fast64_t ) ); +void gen_a_i64_z_f64( float64_t ( int_fast64_t ) ); +#ifdef EXTFLOAT80 +void gen_a_i64_z_extF80( void ( int_fast64_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void gen_a_i64_z_f128( void ( int_fast64_t, float128_t * ) ); +#endif + +void + gen_a_f32_z_ui32_rx( + uint_fast32_t ( float32_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f32_z_ui64_rx( + uint_fast64_t ( float32_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f32_z_i32_rx( + int_fast32_t ( float32_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f32_z_i64_rx( + int_fast64_t ( float32_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void gen_a_f32_z_ui32_x( uint_fast32_t ( float32_t, bool ), bool ); +void gen_a_f32_z_ui64_x( uint_fast64_t ( float32_t, bool ), bool ); +void gen_a_f32_z_i32_x( int_fast32_t ( float32_t, bool ), bool ); +void gen_a_f32_z_i64_x( int_fast64_t ( float32_t, bool ), bool ); +void gen_a_f32_z_f64( float64_t ( float32_t ) ); +#ifdef EXTFLOAT80 +void gen_a_f32_z_extF80( void ( float32_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void gen_a_f32_z_f128( void ( float32_t, float128_t * ) ); +#endif +void gen_az_f32( float32_t ( float32_t ) ); +void + gen_az_f32_rx( + float32_t ( float32_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void gen_abz_f32( float32_t ( float32_t, float32_t ) ); +void gen_abcz_f32( float32_t ( float32_t, float32_t, float32_t ) ); +void gen_ab_f32_z_bool( bool ( float32_t, float32_t ) ); + +void + gen_a_f64_z_ui32_rx( + uint_fast32_t ( float64_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f64_z_ui64_rx( + uint_fast64_t ( float64_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f64_z_i32_rx( + int_fast32_t ( float64_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f64_z_i64_rx( + int_fast64_t ( float64_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void gen_a_f64_z_ui32_x( uint_fast32_t ( float64_t, bool ), bool ); +void gen_a_f64_z_ui64_x( uint_fast64_t ( float64_t, bool ), bool ); +void gen_a_f64_z_i32_x( int_fast32_t ( float64_t, bool ), bool ); +void gen_a_f64_z_i64_x( int_fast64_t ( float64_t, bool ), bool ); +void gen_a_f64_z_f32( float32_t ( float64_t ) ); +#ifdef EXTFLOAT80 +void gen_a_f64_z_extF80( void ( float64_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void gen_a_f64_z_f128( void ( float64_t, float128_t * ) ); +#endif +void gen_az_f64( float64_t ( float64_t ) ); +void + gen_az_f64_rx( + float64_t ( float64_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void gen_abz_f64( float64_t ( float64_t, float64_t ) ); +void gen_abcz_f64( float64_t ( float64_t, float64_t, float64_t ) ); +void gen_ab_f64_z_bool( bool ( float64_t, float64_t ) ); + +#ifdef EXTFLOAT80 +void + gen_a_extF80_z_ui32_rx( + uint_fast32_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + gen_a_extF80_z_ui64_rx( + uint_fast64_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + gen_a_extF80_z_i32_rx( + int_fast32_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + gen_a_extF80_z_i64_rx( + int_fast64_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + gen_a_extF80_z_ui32_x( uint_fast32_t ( const extFloat80_t *, bool ), bool ); +void + gen_a_extF80_z_ui64_x( uint_fast64_t ( const extFloat80_t *, bool ), bool ); +void gen_a_extF80_z_i32_x( int_fast32_t ( const extFloat80_t *, bool ), bool ); +void gen_a_extF80_z_i64_x( int_fast64_t ( const extFloat80_t *, bool ), bool ); +void gen_a_extF80_z_f32( float32_t ( const extFloat80_t * ) ); +void gen_a_extF80_z_f64( float64_t ( const extFloat80_t * ) ); +#ifdef FLOAT128 +void gen_a_extF80_z_f128( void ( const extFloat80_t *, float128_t * ) ); +#endif +void gen_az_extF80( void ( const extFloat80_t *, extFloat80_t * ) ); +void + gen_az_extF80_rx( + void ( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), + uint_fast8_t, + bool + ); +void + gen_abz_extF80( + void ( const extFloat80_t *, const extFloat80_t *, extFloat80_t * ) ); +void + gen_abcz_extF80( + void + ( + const extFloat80_t *, + const extFloat80_t *, + const extFloat80_t *, + extFloat80_t * + ) + ); +void + gen_ab_extF80_z_bool( bool ( const extFloat80_t *, const extFloat80_t * ) ); +#endif + +#ifdef FLOAT128 +void + gen_a_f128_z_ui32_rx( + uint_fast32_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + gen_a_f128_z_ui64_rx( + uint_fast64_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + gen_a_f128_z_i32_rx( + int_fast32_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + gen_a_f128_z_i64_rx( + int_fast64_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void gen_a_f128_z_ui32_x( uint_fast32_t ( const float128_t *, bool ), bool ); +void gen_a_f128_z_ui64_x( uint_fast64_t ( const float128_t *, bool ), bool ); +void gen_a_f128_z_i32_x( int_fast32_t ( const float128_t *, bool ), bool ); +void gen_a_f128_z_i64_x( int_fast64_t ( const float128_t *, bool ), bool ); +void gen_a_f128_z_f32( float32_t ( const float128_t * ) ); +void gen_a_f128_z_f64( float64_t ( const float128_t * ) ); +#ifdef EXTFLOAT80 +void gen_a_f128_z_extF80( void ( const float128_t *, extFloat80_t * ) ); +#endif +void gen_az_f128( void ( const float128_t *, float128_t * ) ); +void + gen_az_f128_rx( + void ( const float128_t *, uint_fast8_t, bool, float128_t * ), + uint_fast8_t, + bool + ); +void + gen_abz_f128( void ( const float128_t *, const float128_t *, float128_t * ) ); +void + gen_abcz_f128( + void + ( + const float128_t *, + const float128_t *, + const float128_t *, + float128_t * + ) + ); +void gen_ab_f128_z_bool( bool ( const float128_t *, const float128_t * ) ); +#endif + diff --git a/source/random.c b/source/random.c new file mode 100644 index 0000000..fbf3408 --- /dev/null +++ b/source/random.c @@ -0,0 +1,135 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "random.h" + +uint_fast8_t random_ui8( void ) +{ + + return rand()>>4 & 0xFF; + +} + +uint_fast16_t random_ui16( void ) +{ + + return (rand() & 0x0FF0)<<4 | (rand()>>4 & 0xFF); + +} + +uint_fast32_t random_ui32( void ) +{ + + return + (uint_fast32_t) (rand() & 0x0FF0)<<20 + | (uint_fast32_t) (rand() & 0x0FF0)<<12 + | (rand() & 0x0FF0)<<4 + | (rand()>>4 & 0xFF); + +} + +uint_fast64_t random_ui64( void ) +{ + + return (uint_fast64_t) random_ui32()<<32 | random_ui32(); + +} + +uint_fast8_t randomN_ui8( uint_fast8_t N ) +{ + uint_fast8_t scale, z; + + scale = 0; + while ( N < 0x80 ) { + ++scale; + N <<= 1; + } + do { + z = random_ui8(); + } while ( N <= z ); + return z>>scale; + +} + +uint_fast16_t randomN_ui16( uint_fast16_t N ) +{ + uint_fast16_t scale, z; + + scale = 0; + while ( N < 0x8000 ) { + ++scale; + N <<= 1; + } + do { + z = random_ui16(); + } while ( N <= z ); + return z>>scale; + +} + +uint_fast32_t randomN_ui32( uint_fast32_t N ) +{ + uint_fast32_t scale, z; + + scale = 0; + while ( N < 0x8000 ) { + ++scale; + N <<= 1; + } + do { + z = random_ui32(); + } while ( N <= z ); + return z>>scale; + +} + +uint_fast64_t randomN_ui64( uint_fast64_t N ) +{ + uint_fast64_t scale, z; + + scale = 0; + while ( N < 0x8000 ) { + ++scale; + N <<= 1; + } + do { + z = random_ui64(); + } while ( N <= z ); + return z>>scale; + +} + diff --git a/source/random.h b/source/random.h new file mode 100644 index 0000000..47864c9 --- /dev/null +++ b/source/random.h @@ -0,0 +1,46 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include + +uint_fast8_t random_ui8( void ); +uint_fast16_t random_ui16( void ); +uint_fast32_t random_ui32( void ); +uint_fast64_t random_ui64( void ); + +uint_fast8_t randomN_ui8( uint_fast8_t ); +uint_fast16_t randomN_ui16( uint_fast16_t ); +uint_fast32_t randomN_ui32( uint_fast32_t ); +uint_fast64_t randomN_ui64( uint_fast64_t ); + diff --git a/source/readHex.c b/source/readHex.c new file mode 100644 index 0000000..5d313ba --- /dev/null +++ b/source/readHex.c @@ -0,0 +1,187 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include +#include "platform.h" +#include "readHex.h" + +bool readHex_bool( bool *aPtr, char sepChar ) +{ + int i; + bool a; + + i = fgetc( stdin ); + if ( (i == EOF) || (i < '0') || ('1' < i) ) return false; + a = i - '0'; + if ( sepChar ) { + i = fgetc( stdin ); + if ( (sepChar != '\n') || (i != '\r') ) { + if ( i != sepChar ) return false; + } + } + *aPtr = a; + return true; + +} + +bool readHex_ui8( uint_least8_t *aPtr, char sepChar ) +{ + int i; + uint_fast8_t a; + + i = fgetc( stdin ); + if ( i == EOF ) return false; + if ( ('0' <= i) && (i <= '9') ) { + i -= '0'; + } else if ( ('A' <= i) && (i <= 'F') ) { + i -= 'A' - 10; + } else if ( ('a' <= i) && (i <= 'f') ) { + i -= 'a' - 10; + } else { + return false; + } + a = i<<4; + i = fgetc( stdin ); + if ( i == EOF ) return false; + if ( ('0' <= i) && (i <= '9') ) { + i -= '0'; + } else if ( ('A' <= i) && (i <= 'F') ) { + i -= 'A' - 10; + } else if ( ('a' <= i) && (i <= 'f') ) { + i -= 'a' - 10; + } else { + return false; + } + a |= i; + if ( sepChar ) { + i = fgetc( stdin ); + if ( (sepChar != '\n') || (i != '\r') ) { + if ( i != sepChar ) return false; + } + } + *aPtr = a; + return true; + +} + +bool readHex_ui16( uint16_t *aPtr, char sepChar ) +{ + int i; + uint_fast16_t a; + + i = fgetc( stdin ); + if ( i == EOF ) return false; + if ( ('0' <= i) && (i <= '9') ) { + i -= '0'; + } else if ( ('A' <= i) && (i <= 'F') ) { + i -= 'A' - 10; + } else if ( ('a' <= i) && (i <= 'f') ) { + i -= 'a' - 10; + } else { + return false; + } + a = (uint_fast16_t) i<<12; + i = fgetc( stdin ); + if ( i == EOF ) return false; + if ( ('0' <= i) && (i <= '9') ) { + i -= '0'; + } else if ( ('A' <= i) && (i <= 'F') ) { + i -= 'A' - 10; + } else if ( ('a' <= i) && (i <= 'f') ) { + i -= 'a' - 10; + } else { + return false; + } + a |= (uint_fast16_t) i<<8; + i = fgetc( stdin ); + if ( i == EOF ) return false; + if ( ('0' <= i) && (i <= '9') ) { + i -= '0'; + } else if ( ('A' <= i) && (i <= 'F') ) { + i -= 'A' - 10; + } else if ( ('a' <= i) && (i <= 'f') ) { + i -= 'a' - 10; + } else { + return false; + } + a |= (uint_fast16_t) i<<4; + i = fgetc( stdin ); + if ( i == EOF ) return false; + if ( ('0' <= i) && (i <= '9') ) { + i -= '0'; + } else if ( ('A' <= i) && (i <= 'F') ) { + i -= 'A' - 10; + } else if ( ('a' <= i) && (i <= 'f') ) { + i -= 'a' - 10; + } else { + return false; + } + a |= i; + if ( sepChar ) { + i = fgetc( stdin ); + if ( (sepChar != '\n') || (i != '\r') ) { + if ( i != sepChar ) return false; + } + } + *aPtr = a; + return true; + +} + +bool readHex_ui32( uint32_t *aPtr, char sepChar ) +{ + uint16_t v16, v0; + + if ( ! readHex_ui16( &v16, 0 ) || ! readHex_ui16( &v0, sepChar ) ) { + return false; + } + *aPtr = (uint_fast32_t) v16<<16 | v0; + return true; + +} + +bool readHex_ui64( uint64_t *aPtr, char sepChar ) +{ + uint32_t v32, v0; + + if ( ! readHex_ui32( &v32, 0 ) || ! readHex_ui32( &v0, sepChar ) ) { + return false; + } + *aPtr = (uint_fast64_t) v32<<32 | v0; + return true; + +} + diff --git a/source/readHex.h b/source/readHex.h new file mode 100644 index 0000000..56c8eeb --- /dev/null +++ b/source/readHex.h @@ -0,0 +1,43 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include + +bool readHex_bool( bool *, char ); +bool readHex_ui8( uint_least8_t *, char ); +bool readHex_ui16( uint16_t *, char ); +bool readHex_ui32( uint32_t *, char ); +bool readHex_ui64( uint64_t *, char ); + diff --git a/source/slowfloat.c b/source/slowfloat.c new file mode 100644 index 0000000..ac54bb5 --- /dev/null +++ b/source/slowfloat.c @@ -0,0 +1,3098 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "uint128.h" +#include "softfloat.h" +#include "slowfloat.h" + +uint_fast8_t slowfloat_roundingMode; +uint_fast8_t slowfloat_detectTininess; +uint_fast8_t slowfloat_exceptionFlags; +#ifdef EXTFLOAT80 +uint_fast8_t slow_extF80_roundingPrecision; +#endif + +union ui32_f32 { uint32_t ui; float32_t f; }; +union ui64_f64 { uint64_t ui; float64_t f; }; + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +struct floatX { + bool isNaN; + bool isInf; + bool isZero; + bool sign; + int_fast32_t exp; + struct uint128 sig; +}; + +static const struct floatX floatXNaN = + { true, false, false, false, 0, { 0, 0 } }; +static const struct floatX floatXPositiveZero = + { false, false, true, false, 0, { 0, 0 } }; +static const struct floatX floatXNegativeZero = + { false, false, true, true, 0, { 0, 0 } }; + +static + void + roundFloatXTo24( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast64_t sigX64; + uint_fast32_t roundBits; + + sigX64 = xPtr->sig.v64 | (xPtr->sig.v0 != 0); + roundBits = (uint32_t) sigX64; + sigX64 -= roundBits; + if ( roundBits ) { + if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; + if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; + switch ( roundingMode ) { + case softfloat_round_near_even: + if ( roundBits < 0x80000000 ) goto noIncrement; + if ( + (roundBits == 0x80000000) + && ! (sigX64 & UINT64_C( 0x100000000 )) + ) { + goto noIncrement; + } + break; + case softfloat_round_minMag: + goto noIncrement; + case softfloat_round_min: + if ( ! xPtr->sign ) goto noIncrement; + break; + case softfloat_round_max: + if ( xPtr->sign ) goto noIncrement; + break; + case softfloat_round_near_maxMag: + if ( roundBits < 0x80000000 ) goto noIncrement; + break; + } + sigX64 += UINT64_C( 0x100000000 ); + if ( sigX64 == UINT64_C( 0x0100000000000000 ) ) { + ++xPtr->exp; + sigX64 = UINT64_C( 0x0080000000000000 ); + } + } + noIncrement: + xPtr->sig.v64 = sigX64; + xPtr->sig.v0 = 0; + +} + +static + void + roundFloatXTo53( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast64_t sigX64; + uint_fast8_t roundBits; + + sigX64 = xPtr->sig.v64 | (xPtr->sig.v0 != 0); + roundBits = sigX64 & 7; + sigX64 -= roundBits; + if ( roundBits ) { + if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; + if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; + switch ( roundingMode ) { + case softfloat_round_near_even: + if ( roundBits < 4 ) goto noIncrement; + if ( (roundBits == 4) && ! (sigX64 & 8) ) goto noIncrement; + break; + case softfloat_round_minMag: + goto noIncrement; + case softfloat_round_min: + if ( ! xPtr->sign ) goto noIncrement; + break; + case softfloat_round_max: + if ( xPtr->sign ) goto noIncrement; + break; + case softfloat_round_near_maxMag: + if ( roundBits < 4 ) goto noIncrement; + break; + } + sigX64 += 8; + if ( sigX64 == UINT64_C( 0x0100000000000000 ) ) { + ++xPtr->exp; + sigX64 = UINT64_C( 0x0080000000000000 ); + } + } + noIncrement: + xPtr->sig.v64 = sigX64; + xPtr->sig.v0 = 0; + +} + +static + void + roundFloatXTo64( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast64_t sigX0; + int_fast64_t roundBits; + uint_fast64_t sigX64; + + sigX0 = xPtr->sig.v0; + roundBits = sigX0 & UINT64_C( 0x00FFFFFFFFFFFFFF ); + sigX0 -= roundBits; + if ( roundBits ) { + if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; + if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; + switch ( roundingMode ) { + case softfloat_round_near_even: + if ( roundBits < UINT64_C( 0x0080000000000000 ) ) goto noIncrement; + if ( + (roundBits == UINT64_C( 0x0080000000000000 )) + && ! (sigX0 & UINT64_C( 0x0100000000000000 )) + ) { + goto noIncrement; + } + break; + case softfloat_round_minMag: + goto noIncrement; + case softfloat_round_min: + if ( ! xPtr->sign ) goto noIncrement; + break; + case softfloat_round_max: + if ( xPtr->sign ) goto noIncrement; + break; + case softfloat_round_near_maxMag: + if ( roundBits < UINT64_C( 0x0080000000000000 ) ) goto noIncrement; + break; + } + sigX0 += UINT64_C( 0x0100000000000000 ); + sigX64 = xPtr->sig.v64 + ! sigX0; + if ( sigX64 == UINT64_C( 0x0100000000000000 ) ) { + ++xPtr->exp; + sigX64 = UINT64_C( 0x0080000000000000 ); + } + xPtr->sig.v64 = sigX64; + } + noIncrement: + xPtr->sig.v0 = sigX0; + +} + +static + void + roundFloatXTo113( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast64_t sigX0; + int_fast64_t roundBits; + uint_fast64_t sigX64; + + sigX0 = xPtr->sig.v0; + roundBits = sigX0 & 0x7F; + sigX0 -= roundBits; + if ( roundBits ) { + if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; + if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; + switch ( roundingMode ) { + case softfloat_round_near_even: + if ( roundBits < 0x40 ) goto noIncrement; + if ( (roundBits == 0x40) && ! (sigX0 & 0x80) ) goto noIncrement; + break; + case softfloat_round_minMag: + goto noIncrement; + case softfloat_round_min: + if ( ! xPtr->sign ) goto noIncrement; + break; + case softfloat_round_max: + if ( xPtr->sign ) goto noIncrement; + break; + case softfloat_round_near_maxMag: + if ( roundBits < 0x40 ) goto noIncrement; + break; + } + sigX0 += 0x80; + sigX64 = xPtr->sig.v64 + ! sigX0; + if ( sigX64 == UINT64_C( 0x0100000000000000 ) ) { + ++xPtr->exp; + sigX64 = UINT64_C( 0x0080000000000000 ); + } + xPtr->sig.v64 = sigX64; + } + noIncrement: + xPtr->sig.v0 = sigX0; + +} + +static void ui32ToFloatX( uint_fast32_t a, struct floatX *xPtr ) +{ + uint_fast64_t sig64; + int_fast32_t exp; + + xPtr->isNaN = false; + xPtr->isInf = false; + xPtr->sign = false; + sig64 = a; + if ( a ) { + xPtr->isZero = false; + exp = 31; + sig64 <<= 24; + while ( sig64 < UINT64_C( 0x0080000000000000 ) ) { + --exp; + sig64 <<= 1; + } + xPtr->exp = exp; + } else { + xPtr->isZero = true; + } + xPtr->sig.v64 = sig64; + xPtr->sig.v0 = 0; + +} + +static + uint_fast32_t + floatXToUI32( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast8_t savedExceptionFlags; + struct floatX x; + int_fast32_t shiftCount; + uint_fast32_t z; + + if ( xPtr->isInf || xPtr->isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + return 0xFFFFFFFF; + } + if ( xPtr->isZero ) return 0; + savedExceptionFlags = slowfloat_exceptionFlags; + x = *xPtr; + shiftCount = 52 - x.exp; + if ( 56 < shiftCount ) { + x.sig.v64 = 0; + x.sig.v0 = 1; + } else { + while ( 0 < shiftCount ) { + x.sig = shortShiftRightJam128( x.sig, 1 ); + --shiftCount; + } + } + roundFloatXTo53( false, &x, roundingMode, exact ); + x.sig = shortShiftRightJam128( x.sig, 3 ); + z = x.sig.v64; + if ( (shiftCount < 0) || x.sig.v64>>32 || (x.sign && z) ) { + slowfloat_exceptionFlags = + savedExceptionFlags | softfloat_flag_invalid; + return 0xFFFFFFFF; + } + return z; + +} + +static void ui64ToFloatX( uint_fast64_t a, struct floatX *xPtr ) +{ + struct uint128 sig; + int_fast32_t exp; + + xPtr->isNaN = false; + xPtr->isInf = false; + xPtr->sign = false; + sig.v64 = 0; + sig.v0 = a; + if ( a ) { + xPtr->isZero = false; + exp = 63; + sig = shortShiftLeft128( sig, 56 ); + while ( sig.v64 < UINT64_C( 0x0080000000000000 ) ) { + --exp; + sig = shortShiftLeft128( sig, 1 ); + } + xPtr->exp = exp; + } else { + xPtr->isZero = true; + } + xPtr->sig = sig; + +} + +static + uint_fast64_t + floatXToUI64( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast8_t savedExceptionFlags; + struct floatX x; + int_fast32_t shiftCount; + uint_fast64_t z; + + if ( xPtr->isInf || xPtr->isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + return UINT64_C( 0xFFFFFFFFFFFFFFFF ); + } + if ( xPtr->isZero ) return 0; + savedExceptionFlags = slowfloat_exceptionFlags; + x = *xPtr; + shiftCount = 112 - x.exp; + if ( 116 < shiftCount ) { + x.sig.v64 = 0; + x.sig.v0 = 1; + } else { + while ( 0 < shiftCount ) { + x.sig = shortShiftRightJam128( x.sig, 1 ); + --shiftCount; + } + } + roundFloatXTo113( false, &x, roundingMode, exact ); + x.sig = shortShiftRightJam128( x.sig, 7 ); + z = x.sig.v0; + if ( (shiftCount < 0) || x.sig.v64 || (x.sign && z) ) { + slowfloat_exceptionFlags = + savedExceptionFlags | softfloat_flag_invalid; + return UINT64_C( 0xFFFFFFFFFFFFFFFF ); + } + return z; + +} + +static void i32ToFloatX( int_fast32_t a, struct floatX *xPtr ) +{ + bool sign; + uint_fast64_t sig64; + int_fast32_t exp; + + xPtr->isNaN = false; + xPtr->isInf = false; + sign = (a < 0); + xPtr->sign = sign; + sig64 = sign ? -(uint64_t) a : a; + if ( a ) { + xPtr->isZero = false; + exp = 31; + sig64 <<= 24; + while ( sig64 < UINT64_C( 0x0080000000000000 ) ) { + --exp; + sig64 <<= 1; + } + xPtr->exp = exp; + } else { + xPtr->isZero = true; + } + xPtr->sig.v64 = sig64; + xPtr->sig.v0 = 0; + +} + +static + int_fast32_t + floatXToI32( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast8_t savedExceptionFlags; + struct floatX x; + int_fast32_t shiftCount; + union { uint32_t ui; int32_t i; } uZ; + + if ( xPtr->isInf || xPtr->isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + return (xPtr->isInf & xPtr->sign) ? -0x7FFFFFFF - 1 : 0x7FFFFFFF; + } + if ( xPtr->isZero ) return 0; + savedExceptionFlags = slowfloat_exceptionFlags; + x = *xPtr; + shiftCount = 52 - x.exp; + if ( 56 < shiftCount ) { + x.sig.v64 = 0; + x.sig.v0 = 1; + } else { + while ( 0 < shiftCount ) { + x.sig = shortShiftRightJam128( x.sig, 1 ); + --shiftCount; + } + } + roundFloatXTo53( false, &x, roundingMode, exact ); + x.sig = shortShiftRightJam128( x.sig, 3 ); + uZ.ui = x.sig.v64; + if ( x.sign ) uZ.ui = -uZ.ui; + if ( + (shiftCount < 0) || x.sig.v64>>32 + || ((uZ.i != 0) && (x.sign != (uZ.i < 0))) + ) { + slowfloat_exceptionFlags = + savedExceptionFlags | softfloat_flag_invalid; + return x.sign ? -0x7FFFFFFF - 1 : 0x7FFFFFFF; + } + return uZ.i; + +} + +static void i64ToFloatX( int_fast64_t a, struct floatX *xPtr ) +{ + bool sign; + struct uint128 sig; + int_fast32_t exp; + + xPtr->isNaN = false; + xPtr->isInf = false; + sign = (a < 0); + xPtr->sign = sign; + sig.v64 = 0; + sig.v0 = sign ? -(uint_fast64_t) a : a; + if ( a ) { + xPtr->isZero = false; + exp = 63; + sig = shortShiftLeft128( sig, 56 ); + while ( sig.v64 < UINT64_C( 0x0080000000000000 ) ) { + --exp; + sig = shortShiftLeft128( sig, 1 ); + } + xPtr->exp = exp; + } else { + xPtr->isZero = true; + } + xPtr->sig = sig; + +} + +static + int_fast64_t + floatXToI64( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast8_t savedExceptionFlags; + struct floatX x; + int_fast32_t shiftCount; + union { uint64_t ui; int64_t i; } uZ; + + if ( xPtr->isInf || xPtr->isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + return + (xPtr->isInf & xPtr->sign) ? -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1 + : INT64_C( 0x7FFFFFFFFFFFFFFF ); + } + if ( xPtr->isZero ) return 0; + savedExceptionFlags = slowfloat_exceptionFlags; + x = *xPtr; + shiftCount = 112 - x.exp; + if ( 116 < shiftCount ) { + x.sig.v64 = 0; + x.sig.v0 = 1; + } else { + while ( 0 < shiftCount ) { + x.sig = shortShiftRightJam128( x.sig, 1 ); + --shiftCount; + } + } + roundFloatXTo113( false, &x, roundingMode, exact ); + x.sig = shortShiftRightJam128( x.sig, 7 ); + uZ.ui = x.sig.v0; + if ( x.sign ) uZ.ui = -uZ.ui; + if ( + (shiftCount < 0) || x.sig.v64 + || ((uZ.i != 0) && (x.sign != (uZ.i < 0))) + ) { + slowfloat_exceptionFlags = + savedExceptionFlags | softfloat_flag_invalid; + return + x.sign ? -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1 + : INT64_C( 0x7FFFFFFFFFFFFFFF ); + } + return uZ.i; + +} + +static void f32ToFloatX( float32_t a, struct floatX *xPtr ) +{ + union ui32_f32 uA; + uint_fast32_t uiA; + int_fast16_t exp; + uint_fast64_t sig64; + + uA.f = a; + uiA = uA.ui; + xPtr->isNaN = false; + xPtr->isInf = false; + xPtr->isZero = false; + xPtr->sign = ((uiA & 0x80000000) != 0); + exp = uiA>>23 & 0xFF; + sig64 = uiA & 0x007FFFFF; + sig64 <<= 32; + if ( exp == 0xFF ) { + if ( sig64 ) { + xPtr->isNaN = true; + } else { + xPtr->isInf = true; + } + } else if ( ! exp ) { + if ( ! sig64 ) { + xPtr->isZero = true; + } else { + exp = 1 - 0x7F; + do { + --exp; + sig64 <<= 1; + } while ( sig64 < UINT64_C( 0x0080000000000000 ) ); + xPtr->exp = exp; + } + } else { + xPtr->exp = exp - 0x7F; + sig64 |= UINT64_C( 0x0080000000000000 ); + } + xPtr->sig.v64 = sig64; + xPtr->sig.v0 = 0; + +} + +static float32_t floatXToF32( const struct floatX *xPtr ) +{ + uint_fast32_t uiZ; + struct floatX x, savedX; + bool isTiny; + int_fast32_t exp; + union ui32_f32 uZ; + + if ( xPtr->isNaN ) { + uiZ = 0xFFFFFFFF; + goto uiZ; + } + if ( xPtr->isInf ) { + uiZ = xPtr->sign ? 0xFF800000 : 0x7F800000; + goto uiZ; + } + if ( xPtr->isZero ) { + uiZ = xPtr->sign ? 0x80000000 : 0; + goto uiZ; + } + x = *xPtr; + while ( UINT64_C( 0x0100000000000000 ) <= x.sig.v64 ) { + ++x.exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + while ( x.sig.v64 < UINT64_C( 0x0080000000000000 ) ) { + --x.exp; + x.sig = shortShiftLeft128( x.sig, 1 ); + } + savedX = x; + isTiny = + (slowfloat_detectTininess == softfloat_tininess_beforeRounding) + && (x.exp + 0x7F <= 0); + roundFloatXTo24( isTiny, &x, slowfloat_roundingMode, true ); + exp = x.exp + 0x7F; + if ( 0xFF <= exp ) { + slowfloat_exceptionFlags |= + softfloat_flag_overflow | softfloat_flag_inexact; + if ( x.sign ) { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_min: + case softfloat_round_near_maxMag: + uiZ = 0xFF800000; + break; + case softfloat_round_minMag: + case softfloat_round_max: + uiZ = 0xFF7FFFFF; + break; + } + } else { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_max: + case softfloat_round_near_maxMag: + uiZ = 0x7F800000; + break; + case softfloat_round_minMag: + case softfloat_round_min: + uiZ = 0x7F7FFFFF; + break; + } + } + goto uiZ; + } + if ( exp <= 0 ) { + isTiny = true; + x = savedX; + exp = x.exp + 0x7F; + if ( exp < -27 ) { + x.sig.v0 = (x.sig.v64 != 0) || (x.sig.v0 != 0); + x.sig.v64 = 0; + } else { + while ( exp <= 0 ) { + ++exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + } + roundFloatXTo24( isTiny, &x, slowfloat_roundingMode, true ); + exp = (UINT64_C( 0x0080000000000000 ) <= x.sig.v64) ? 1 : 0; + } + uiZ = (uint_fast32_t) exp<<23; + if ( x.sign ) uiZ |= 0x80000000; + uiZ |= x.sig.v64>>32 & 0x007FFFFF; + uiZ: + uZ.ui = uiZ; + return uZ.f; + +} + +static void f64ToFloatX( float64_t a, struct floatX *xPtr ) +{ + union ui64_f64 uA; + uint_fast64_t uiA; + int_fast16_t exp; + uint_fast64_t sig64; + + uA.f = a; + uiA = uA.ui; + xPtr->isNaN = false; + xPtr->isInf = false; + xPtr->isZero = false; + xPtr->sign = ((uiA & UINT64_C( 0x8000000000000000 )) != 0); + exp = uiA>>52 & 0x7FF; + sig64 = uiA & UINT64_C( 0x000FFFFFFFFFFFFF ); + if ( exp == 0x7FF ) { + if ( sig64 ) { + xPtr->isNaN = true; + } else { + xPtr->isInf = true; + } + } else if ( ! exp ) { + if ( ! sig64 ) { + xPtr->isZero = true; + } else { + exp = 1 - 0x3FF; + do { + --exp; + sig64 <<= 1; + } while ( sig64 < UINT64_C( 0x0010000000000000 ) ); + xPtr->exp = exp; + } + } else { + xPtr->exp = exp - 0x3FF; + sig64 |= UINT64_C( 0x0010000000000000 ); + } + xPtr->sig.v64 = sig64<<3; + xPtr->sig.v0 = 0; + +} + +static float64_t floatXToF64( const struct floatX *xPtr ) +{ + uint_fast64_t uiZ; + struct floatX x, savedX; + bool isTiny; + int_fast32_t exp; + union ui64_f64 uZ; + + if ( xPtr->isNaN ) { + uiZ = UINT64_C( 0xFFFFFFFFFFFFFFFF ); + goto uiZ; + } + if ( xPtr->isInf ) { + uiZ = + xPtr->sign ? UINT64_C( 0xFFF0000000000000 ) + : UINT64_C( 0x7FF0000000000000 ); + goto uiZ; + } + if ( xPtr->isZero ) { + uiZ = xPtr->sign ? UINT64_C( 0x8000000000000000 ) : 0; + goto uiZ; + } + x = *xPtr; + while ( UINT64_C( 0x0100000000000000 ) <= x.sig.v64 ) { + ++x.exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + while ( x.sig.v64 < UINT64_C( 0x0080000000000000 ) ) { + --x.exp; + x.sig = shortShiftLeft128( x.sig, 1 ); + } + savedX = x; + isTiny = + (slowfloat_detectTininess == softfloat_tininess_beforeRounding) + && (x.exp + 0x3FF <= 0); + roundFloatXTo53( isTiny, &x, slowfloat_roundingMode, true ); + exp = x.exp + 0x3FF; + if ( 0x7FF <= exp ) { + slowfloat_exceptionFlags |= + softfloat_flag_overflow | softfloat_flag_inexact; + if ( x.sign ) { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_min: + case softfloat_round_near_maxMag: + uiZ = UINT64_C( 0xFFF0000000000000 ); + break; + case softfloat_round_minMag: + case softfloat_round_max: + uiZ = UINT64_C( 0xFFEFFFFFFFFFFFFF ); + break; + } + } else { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_max: + case softfloat_round_near_maxMag: + uiZ = UINT64_C( 0x7FF0000000000000 ); + break; + case softfloat_round_minMag: + case softfloat_round_min: + uiZ = UINT64_C( 0x7FEFFFFFFFFFFFFF ); + break; + } + } + goto uiZ; + } + if ( exp <= 0 ) { + isTiny = true; + x = savedX; + exp = x.exp + 0x3FF; + if ( exp < -56 ) { + x.sig.v0 = (x.sig.v64 != 0) || (x.sig.v0 != 0); + x.sig.v64 = 0; + } else { + while ( exp <= 0 ) { + ++exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + } + roundFloatXTo53( isTiny, &x, slowfloat_roundingMode, true ); + exp = (UINT64_C( 0x0080000000000000 ) <= x.sig.v64) ? 1 : 0; + } + uiZ = (uint_fast64_t) exp<<52; + if ( x.sign ) uiZ |= UINT64_C( 0x8000000000000000 ); + uiZ |= x.sig.v64>>3 & UINT64_C( 0x000FFFFFFFFFFFFF ); + uiZ: + uZ.ui = uiZ; + return uZ.f; + +} + +#ifdef EXTFLOAT80 + +static void extF80MToFloatX( const extFloat80_t *aPtr, struct floatX *xPtr ) +{ + const struct extFloat80M *aSPtr; + uint_fast16_t uiA64; + int_fast32_t exp; + struct uint128 sig; + + aSPtr = (const struct extFloat80M *) aPtr; + xPtr->isNaN = false; + xPtr->isInf = false; + xPtr->isZero = false; + uiA64 = aSPtr->signExp; + xPtr->sign = ((uiA64 & 0x8000) != 0); + exp = uiA64 & 0x7FFF; + sig.v64 = 0; + sig.v0 = aSPtr->signif; + if ( exp == 0x7FFF ) { + if ( sig.v0 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) { + xPtr->isNaN = true; + } else { + xPtr->isInf = true; + } + } else { + if ( ! exp ) ++exp; + exp -= 0x3FFF; + if ( ! (sig.v0 & UINT64_C( 0x8000000000000000 )) ) { + if ( ! sig.v0 ) { + xPtr->isZero = true; + } else { + do { + --exp; + sig.v0 <<= 1; + } while ( sig.v0 < UINT64_C( 0x8000000000000000 ) ); + } + } + xPtr->exp = exp; + } + xPtr->sig = shortShiftLeft128( sig, 56 ); + +} + +static void floatXToExtF80M( const struct floatX *xPtr, extFloat80_t *zPtr ) +{ + struct extFloat80M *zSPtr; + struct floatX x, savedX; + bool isTiny; + int_fast32_t exp; + uint_fast64_t uiZ0; + uint_fast16_t uiZ64; + + zSPtr = (struct extFloat80M *) zPtr; + if ( xPtr->isNaN ) { + zSPtr->signExp = 0xFFFF; + zSPtr->signif = UINT64_C( 0xFFFFFFFFFFFFFFFF ); + return; + } + if ( xPtr->isInf ) { + zSPtr->signExp = xPtr->sign ? 0xFFFF : 0x7FFF; + zSPtr->signif = UINT64_C( 0x8000000000000000 ); + return; + } + if ( xPtr->isZero ) { + zSPtr->signExp = xPtr->sign ? 0x8000 : 0; + zSPtr->signif = 0; + return; + } + x = *xPtr; + while ( UINT64_C( 0x0100000000000000 ) <= x.sig.v64 ) { + ++x.exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + while ( x.sig.v64 < UINT64_C( 0x0080000000000000 ) ) { + --x.exp; + x.sig = shortShiftLeft128( x.sig, 1 ); + } + savedX = x; + isTiny = + (slowfloat_detectTininess == softfloat_tininess_beforeRounding) + && (x.exp + 0x3FFF <= 0); + switch ( slow_extF80_roundingPrecision ) { + case 32: + roundFloatXTo24( isTiny, &x, slowfloat_roundingMode, true ); + break; + case 64: + roundFloatXTo53( isTiny, &x, slowfloat_roundingMode, true ); + break; + default: + roundFloatXTo64( isTiny, &x, slowfloat_roundingMode, true ); + break; + } + exp = x.exp + 0x3FFF; + if ( 0x7FFF <= exp ) { + slowfloat_exceptionFlags |= + softfloat_flag_overflow | softfloat_flag_inexact; + if ( x.sign ) { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_min: + case softfloat_round_near_maxMag: + zSPtr->signExp = 0xFFFF; + zSPtr->signif = UINT64_C( 0x8000000000000000 ); + break; + case softfloat_round_minMag: + case softfloat_round_max: + switch ( slow_extF80_roundingPrecision ) { + case 32: + uiZ0 = UINT64_C( 0xFFFFFF0000000000 ); + break; + case 64: + uiZ0 = UINT64_C( 0xFFFFFFFFFFFFF800 ); + break; + default: + uiZ0 = UINT64_C( 0xFFFFFFFFFFFFFFFF ); + break; + } + zSPtr->signExp = 0xFFFE; + zSPtr->signif = uiZ0; + break; + } + } else { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_max: + case softfloat_round_near_maxMag: + zSPtr->signExp = 0x7FFF; + zSPtr->signif = UINT64_C( 0x8000000000000000 ); + break; + case softfloat_round_minMag: + case softfloat_round_min: + switch ( slow_extF80_roundingPrecision ) { + case 32: + uiZ0 = UINT64_C( 0xFFFFFF0000000000 ); + break; + case 64: + uiZ0 = UINT64_C( 0xFFFFFFFFFFFFF800 ); + break; + default: + uiZ0 = UINT64_C( 0xFFFFFFFFFFFFFFFF ); + break; + } + zSPtr->signExp = 0x7FFE; + zSPtr->signif = uiZ0; + break; + } + } + return; + } + if ( exp <= 0 ) { + isTiny = true; + x = savedX; + exp = x.exp + 0x3FFF; + if ( exp < -70 ) { + x.sig.v0 = (x.sig.v64 != 0) || (x.sig.v0 != 0); + x.sig.v64 = 0; + } else { + while ( exp <= 0 ) { + ++exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + } + switch ( slow_extF80_roundingPrecision ) { + case 32: + roundFloatXTo24( isTiny, &x, slowfloat_roundingMode, true ); + break; + case 64: + roundFloatXTo53( isTiny, &x, slowfloat_roundingMode, true ); + break; + default: + roundFloatXTo64( isTiny, &x, slowfloat_roundingMode, true ); + break; + } + exp = (UINT64_C( 0x0080000000000000 ) <= x.sig.v64) ? 1 : 0; + } + uiZ64 = exp; + if ( x.sign ) uiZ64 |= 0x8000; + zSPtr->signExp = uiZ64; + zSPtr->signif = shortShiftRightJam128( x.sig, 56 ).v0; + +} + +#endif + +#ifdef FLOAT128 + +static void f128MToFloatX( const float128_t *aPtr, struct floatX *xPtr ) +{ + const struct uint128 *uiAPtr; + uint_fast64_t uiA64; + int_fast32_t exp; + struct uint128 sig; + + uiAPtr = (const struct uint128 *) aPtr; + xPtr->isNaN = false; + xPtr->isInf = false; + xPtr->isZero = false; + uiA64 = uiAPtr->v64; + xPtr->sign = ((uiA64 & UINT64_C( 0x8000000000000000 )) != 0); + exp = uiA64>>48 & 0x7FFF; + sig.v64 = uiA64 & UINT64_C( 0x0000FFFFFFFFFFFF ); + sig.v0 = uiAPtr->v0; + if ( exp == 0x7FFF ) { + if ( sig.v64 || sig.v0 ) { + xPtr->isNaN = true; + } else { + xPtr->isInf = true; + } + } else if ( ! exp ) { + if ( ! sig.v64 && ! sig.v0 ) { + xPtr->isZero = true; + } else { + exp = 1 - 0x3FFF; + do { + --exp; + sig = shortShiftLeft128( sig, 1 ); + } while ( sig.v64 < UINT64_C( 0x0001000000000000 ) ); + xPtr->exp = exp; + } + } else { + xPtr->exp = exp - 0x3FFF; + sig.v64 |= UINT64_C( 0x0001000000000000 ); + } + xPtr->sig = shortShiftLeft128( sig, 7 ); + +} + +static void floatXToF128M( const struct floatX *xPtr, float128_t *zPtr ) +{ + struct uint128 *uiZPtr; + struct floatX x, savedX; + bool isTiny; + int_fast32_t exp; + uint_fast64_t uiZ64; + + uiZPtr = (struct uint128 *) zPtr; + if ( xPtr->isNaN ) { + uiZPtr->v64 = uiZPtr->v0 = UINT64_C( 0xFFFFFFFFFFFFFFFF ); + return; + } + if ( xPtr->isInf ) { + uiZPtr->v64 = + xPtr->sign ? UINT64_C( 0xFFFF000000000000 ) + : UINT64_C( 0x7FFF000000000000 ); + uiZPtr->v0 = 0; + return; + } + if ( xPtr->isZero ) { + uiZPtr->v64 = xPtr->sign ? UINT64_C( 0x8000000000000000 ) : 0; + uiZPtr->v0 = 0; + return; + } + x = *xPtr; + while ( UINT64_C( 0x0100000000000000 ) <= x.sig.v64 ) { + ++x.exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + while ( x.sig.v64 < UINT64_C( 0x0080000000000000 ) ) { + --x.exp; + x.sig = shortShiftLeft128( x.sig, 1 ); + } + savedX = x; + isTiny = + (slowfloat_detectTininess == softfloat_tininess_beforeRounding) + && (x.exp + 0x3FFF <= 0); + roundFloatXTo113( isTiny, &x, slowfloat_roundingMode, true ); + exp = x.exp + 0x3FFF; + if ( 0x7FFF <= exp ) { + slowfloat_exceptionFlags |= + softfloat_flag_overflow | softfloat_flag_inexact; + if ( x.sign ) { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_min: + case softfloat_round_near_maxMag: + uiZPtr->v64 = UINT64_C( 0xFFFF000000000000 ); + uiZPtr->v0 = 0; + break; + case softfloat_round_minMag: + case softfloat_round_max: + uiZPtr->v64 = UINT64_C( 0xFFFEFFFFFFFFFFFF ); + uiZPtr->v0 = UINT64_C( 0xFFFFFFFFFFFFFFFF ); + break; + } + } else { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_max: + case softfloat_round_near_maxMag: + uiZPtr->v64 = UINT64_C( 0x7FFF000000000000 ); + uiZPtr->v0 = 0; + break; + case softfloat_round_minMag: + case softfloat_round_min: + uiZPtr->v64 = UINT64_C( 0x7FFEFFFFFFFFFFFF ); + uiZPtr->v0 = UINT64_C( 0xFFFFFFFFFFFFFFFF ); + break; + } + } + return; + } + if ( exp <= 0 ) { + isTiny = true; + x = savedX; + exp = x.exp + 0x3FFF; + if ( exp < -120 ) { + x.sig.v0 = (x.sig.v64 != 0) || (x.sig.v0 != 0); + x.sig.v64 = 0; + } else { + while ( exp <= 0 ) { + ++exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + } + roundFloatXTo113( isTiny, &x, slowfloat_roundingMode, true ); + exp = (UINT64_C( 0x0080000000000000 ) <= x.sig.v64) ? 1 : 0; + } + uiZ64 = (uint_fast64_t) exp<<48; + if ( x.sign ) uiZ64 |= UINT64_C( 0x8000000000000000 ); + x.sig = shortShiftRightJam128( x.sig, 7 ); + uiZPtr->v64 = uiZ64 | x.sig.v64 & UINT64_C( 0x0000FFFFFFFFFFFF ); + uiZPtr->v0 = x.sig.v0; + +} + +#endif + +static void floatXInvalid( struct floatX *xPtr ) +{ + + slowfloat_exceptionFlags |= softfloat_flag_invalid; + *xPtr = floatXNaN; + +} + +static + void + floatXRoundToInt( + struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + int_fast32_t exp, shiftCount; + struct uint128 sig; + + if ( xPtr->isNaN || xPtr->isInf ) return; + exp = xPtr->exp; + shiftCount = 112 - exp; + if ( shiftCount <= 0 ) return; + if ( 119 < shiftCount ) { + xPtr->exp = 112; + xPtr->sig.v64 = 0; + xPtr->sig.v0 = ! xPtr->isZero; + } else { + sig = xPtr->sig; + while ( 0 < shiftCount ) { + ++exp; + sig = shortShiftRightJam128( sig, 1 ); + --shiftCount; + } + xPtr->exp = exp; + xPtr->sig = sig; + } + roundFloatXTo113( false, xPtr, roundingMode, exact ); + if ( ! xPtr->sig.v64 && ! xPtr->sig.v0 ) xPtr->isZero = true; + +} + +static void floatXAdd( struct floatX *xPtr, const struct floatX *yPtr ) +{ + int_fast32_t expX, expY, expDiff; + struct uint128 sigY; + + if ( xPtr->isNaN ) return; + if ( yPtr->isNaN ) goto copyY; + if ( xPtr->isInf && yPtr->isInf ) { + if ( xPtr->sign != yPtr->sign ) floatXInvalid( xPtr ); + return; + } + if ( xPtr->isInf ) return; + if ( yPtr->isInf ) goto copyY; + if ( xPtr->isZero && yPtr->isZero ) { + if ( xPtr->sign == yPtr->sign ) return; + goto completeCancellation; + } + expX = xPtr->exp; + expY = yPtr->exp; + if ( + (xPtr->sign != yPtr->sign) && (expX == expY) + && eq128( xPtr->sig, yPtr->sig ) + ) { + completeCancellation: + if (slowfloat_roundingMode == softfloat_round_min) { + *xPtr = floatXNegativeZero; + } else { + *xPtr = floatXPositiveZero; + } + return; + } + if ( xPtr->isZero ) goto copyY; + if ( yPtr->isZero ) return; + expDiff = expX - expY; + if ( expDiff < 0 ) { + xPtr->exp = expY; + if ( expDiff < -120 ) { + xPtr->sig.v64 = 0; + xPtr->sig.v0 = 1; + } else { + while ( expDiff < 0 ) { + ++expDiff; + xPtr->sig = shortShiftRightJam128( xPtr->sig, 1 ); + } + } + if ( xPtr->sign != yPtr->sign ) xPtr->sig = neg128( xPtr->sig ); + xPtr->sign = yPtr->sign; + xPtr->sig = add128( xPtr->sig, yPtr->sig ); + } else { + sigY = yPtr->sig; + if ( 120 < expDiff ) { + sigY.v64 = 0; + sigY.v0 = 1; + } else { + while ( 0 < expDiff ) { + --expDiff; + sigY = shortShiftRightJam128( sigY, 1 ); + } + } + if ( xPtr->sign != yPtr->sign ) sigY = neg128( sigY ); + xPtr->sig = add128( xPtr->sig, sigY ); + } + if ( xPtr->sig.v64 & UINT64_C( 0x8000000000000000 ) ) { + xPtr->sign = ! xPtr->sign; + xPtr->sig = neg128( xPtr->sig ); + } + return; + copyY: + *xPtr = *yPtr; + +} + +static void floatXMul( struct floatX *xPtr, const struct floatX *yPtr ) +{ + struct uint128 sig; + int bitNum; + + if ( xPtr->isNaN ) return; + if ( yPtr->isNaN ) { + xPtr->isNaN = true; + xPtr->isInf = false; + xPtr->isZero = false; + xPtr->sign = yPtr->sign; + return; + } + if ( yPtr->sign ) xPtr->sign = ! xPtr->sign; + if ( xPtr->isInf ) { + if ( yPtr->isZero ) floatXInvalid( xPtr ); + return; + } + if ( yPtr->isInf ) { + if ( xPtr->isZero ) { + floatXInvalid( xPtr ); + return; + } + xPtr->isInf = true; + return; + } + if ( xPtr->isZero || yPtr->isZero ) { + if ( xPtr->sign ) { + *xPtr = floatXNegativeZero; + } else { + *xPtr = floatXPositiveZero; + } + return; + } + xPtr->exp += yPtr->exp; + sig.v64 = 0; + sig.v0 = 0; + for ( bitNum = 0; bitNum < 120; ++bitNum ) { + sig = shortShiftRightJam128( sig, 1 ); + if ( xPtr->sig.v0 & 1 ) sig = add128( sig, yPtr->sig ); + xPtr->sig = shortShiftRight128( xPtr->sig, 1 ); + } + if ( UINT64_C( 0x0100000000000000 ) <= sig.v64 ) { + ++xPtr->exp; + sig = shortShiftRightJam128( sig, 1 ); + } + xPtr->sig = sig; + +} + +static void floatXDiv( struct floatX *xPtr, const struct floatX *yPtr ) +{ + struct uint128 sig, negSigY; + int bitNum; + + if ( xPtr->isNaN ) return; + if ( yPtr->isNaN ) { + xPtr->isNaN = true; + xPtr->isInf = false; + xPtr->isZero = false; + xPtr->sign = yPtr->sign; + return; + } + if ( yPtr->sign ) xPtr->sign = ! xPtr->sign; + if ( xPtr->isInf ) { + if ( yPtr->isInf ) floatXInvalid( xPtr ); + return; + } + if ( yPtr->isZero ) { + if ( xPtr->isZero ) { + floatXInvalid( xPtr ); + return; + } + slowfloat_exceptionFlags |= softfloat_flag_infinite; + xPtr->isInf = true; + return; + } + if ( xPtr->isZero || yPtr->isInf ) { + if ( xPtr->sign ) { + *xPtr = floatXNegativeZero; + } else { + *xPtr = floatXPositiveZero; + } + return; + } + xPtr->exp -= yPtr->exp + 1; + sig.v64 = 0; + sig.v0 = 0; + negSigY = neg128( yPtr->sig ); + for ( bitNum = 0; bitNum < 120; ++bitNum ) { + if ( le128( yPtr->sig, xPtr->sig ) ) { + sig.v0 |= 1; + xPtr->sig = add128( xPtr->sig, negSigY ); + } + xPtr->sig = shortShiftLeft128( xPtr->sig, 1 ); + sig = shortShiftLeft128( sig, 1 ); + } + if ( xPtr->sig.v64 || xPtr->sig.v0 ) sig.v0 |= 1; + xPtr->sig = sig; + +} + +static void floatXRem( struct floatX *xPtr, const struct floatX *yPtr ) +{ + int_fast32_t expX, expY; + struct uint128 sigY, negSigY; + bool lastQuotientBit; + struct uint128 savedSigX; + + if ( xPtr->isNaN ) return; + if ( yPtr->isNaN ) { + xPtr->isNaN = true; + xPtr->isInf = false; + xPtr->isZero = false; + xPtr->sign = yPtr->sign; + return; + } + if ( xPtr->isInf || yPtr->isZero ) { + floatXInvalid( xPtr ); + return; + } + if ( xPtr->isZero || yPtr->isInf ) return; + expX = xPtr->exp; + expY = yPtr->exp - 1; + if ( expX < expY ) return; + sigY = shortShiftLeft128( yPtr->sig, 1 ); + negSigY = neg128( sigY ); + while ( expY < expX ) { + --expX; + if ( le128( sigY, xPtr->sig ) ) { + xPtr->sig = add128( xPtr->sig, negSigY ); + } + xPtr->sig = shortShiftLeft128( xPtr->sig, 1 ); + } + xPtr->exp = expX; + lastQuotientBit = le128( sigY, xPtr->sig ); + if ( lastQuotientBit ) xPtr->sig = add128( xPtr->sig, negSigY ); + savedSigX = xPtr->sig; + xPtr->sig = neg128( add128( xPtr->sig, negSigY ) ); + if ( lt128( xPtr->sig, savedSigX ) ) { + xPtr->sign = ! xPtr->sign; + } else if ( lt128( savedSigX, xPtr->sig ) ) { + goto restoreSavedSigX; + } else { + if ( lastQuotientBit ) { + xPtr->sign = ! xPtr->sign; + } else { + restoreSavedSigX: + xPtr->sig = savedSigX; + } + } + if ( ! xPtr->sig.v64 && ! xPtr->sig.v0 ) xPtr->isZero = true; + +} + +static void floatXSqrt( struct floatX *xPtr ) +{ + struct uint128 sig, bitSig; + int bitNum; + struct uint128 savedSigX; + + if ( xPtr->isNaN || xPtr->isZero ) return; + if ( xPtr->sign ) { + floatXInvalid( xPtr ); + return; + } + if ( xPtr->isInf ) return; + if ( ! (xPtr->exp & 1) ) xPtr->sig = shortShiftRightJam128( xPtr->sig, 1 ); + xPtr->exp >>= 1; + sig.v64 = 0; + sig.v0 = 0; + bitSig.v64 = UINT64_C( 0x0080000000000000 ); + bitSig.v0 = 0; + for ( bitNum = 0; bitNum < 120; ++bitNum ) { + savedSigX = xPtr->sig; + xPtr->sig = add128( xPtr->sig, neg128( sig ) ); + xPtr->sig = shortShiftLeft128( xPtr->sig, 1 ); + xPtr->sig = add128( xPtr->sig, neg128( bitSig ) ); + if ( xPtr->sig.v64 & UINT64_C( 0x8000000000000000 ) ) { + xPtr->sig = shortShiftLeft128( savedSigX, 1 ); + } else { + sig.v64 |= bitSig.v64; + sig.v0 |= bitSig.v0; + } + bitSig = shortShiftRightJam128( bitSig, 1 ); + } + if ( xPtr->sig.v64 || xPtr->sig.v0 ) sig.v0 |= 1; + xPtr->sig = sig; + +} + +static bool floatXEq( const struct floatX *xPtr, const struct floatX *yPtr ) +{ + + if ( xPtr->isNaN || yPtr->isNaN ) return false; + if ( xPtr->isZero && yPtr->isZero ) return true; + if ( xPtr->sign != yPtr->sign ) return false; + if ( xPtr->isInf || yPtr->isInf ) return xPtr->isInf && yPtr->isInf; + return ( xPtr->exp == yPtr->exp ) && eq128( xPtr->sig, yPtr->sig ); + +} + +static bool floatXLe( const struct floatX *xPtr, const struct floatX *yPtr ) +{ + + if ( xPtr->isNaN || yPtr->isNaN ) return false; + if ( xPtr->isZero && yPtr->isZero ) return true; + if ( xPtr->sign != yPtr->sign ) return xPtr->sign; + if ( xPtr->sign ) { + if ( xPtr->isInf || yPtr->isZero ) return true; + if ( yPtr->isInf || xPtr->isZero ) return false; + if ( yPtr->exp < xPtr->exp ) return true; + if ( xPtr->exp < yPtr->exp ) return false; + return le128( yPtr->sig, xPtr->sig ); + } else { + if ( yPtr->isInf || xPtr->isZero ) return true; + if ( xPtr->isInf || yPtr->isZero ) return false; + if ( xPtr->exp < yPtr->exp ) return true; + if ( yPtr->exp < xPtr->exp ) return false; + return le128( xPtr->sig, yPtr->sig ); + } + +} + +static bool floatXLt( const struct floatX *xPtr, const struct floatX *yPtr ) +{ + + if ( xPtr->isNaN || yPtr->isNaN ) return false; + if ( xPtr->isZero && yPtr->isZero ) return false; + if ( xPtr->sign != yPtr->sign ) return xPtr->sign; + if ( xPtr->isInf && yPtr->isInf ) return false; + if ( xPtr->sign ) { + if ( xPtr->isInf || yPtr->isZero ) return true; + if ( yPtr->isInf || xPtr->isZero ) return false; + if ( yPtr->exp < xPtr->exp ) return true; + if ( xPtr->exp < yPtr->exp ) return false; + return lt128( yPtr->sig, xPtr->sig ); + } else { + if ( yPtr->isInf || xPtr->isZero ) return true; + if ( xPtr->isInf || yPtr->isZero ) return false; + if ( xPtr->exp < yPtr->exp ) return true; + if ( yPtr->exp < xPtr->exp ) return false; + return lt128( xPtr->sig, yPtr->sig ); + } + +} + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +#if defined EXTFLOAT80 || defined FLOAT128 + +#ifdef LITTLEENDIAN +struct uint256 { uint64_t v0, v64, v128, v192; }; +#else +struct uint256 { uint64_t v192, v128 v64, v0; }; +#endif + +static bool eq256M( const struct uint256 *aPtr, const struct uint256 *bPtr ) +{ + + return + (aPtr->v192 == bPtr->v192) && (aPtr->v128 == bPtr->v128) + && (aPtr->v64 == bPtr->v64) && (aPtr->v0 == bPtr->v0); + +} + +static void shiftLeft1256M( struct uint256 *ptr ) +{ + uint64_t dword1, dword2; + + dword1 = ptr->v128; + ptr->v192 = ptr->v192<<1 | dword1>>63; + dword2 = ptr->v64; + ptr->v128 = dword1<<1 | dword2>>63; + dword1 = ptr->v0; + ptr->v64 = dword2<<1 | dword1>>63; + ptr->v0 = dword1<<1; + +} + +static void shiftRight1256M( struct uint256 *ptr ) +{ + uint64_t dword1, dword2; + + dword1 = ptr->v64; + ptr->v0 = dword1<<63 | ptr->v0>>1; + dword2 = ptr->v128; + ptr->v64 = dword2<<63 | dword1>>1; + dword1 = ptr->v192; + ptr->v128 = dword1<<63 | dword2>>1; + ptr->v192 = dword1>>1; + +} + +static void shiftRight1Jam256M( struct uint256 *ptr ) +{ + int extra; + + extra = ptr->v0 & 1; + shiftRight1256M( ptr ); + ptr->v0 |= extra; + +} + +static void neg256M( struct uint256 *ptr ) +{ + uint64_t v64, v0, v128; + + v64 = ptr->v64; + v0 = ptr->v0; + if ( v64 | v0 ) { + ptr->v192 = ~ptr->v192; + ptr->v128 = ~ptr->v128; + if ( v0 ) { + ptr->v64 = ~v64; + ptr->v0 = -v0; + } else { + ptr->v64 = -v64; + } + } else { + v128 = ptr->v128; + if ( v128 ) { + ptr->v192 = ~ptr->v192; + ptr->v128 = -v128; + } else { + ptr->v192 = -ptr->v192; + } + } + +} + +static void add256M( struct uint256 *aPtr, const struct uint256 *bPtr ) +{ + uint64_t dwordA, dwordZ; + unsigned int carry1, carry2; + + dwordA = aPtr->v0; + dwordZ = dwordA + bPtr->v0; + carry1 = (dwordZ < dwordA); + aPtr->v0 = dwordZ; + dwordA = aPtr->v64; + dwordZ = dwordA + bPtr->v64; + carry2 = (dwordZ < dwordA); + dwordZ += carry1; + carry2 += (dwordZ < carry1); + aPtr->v64 = dwordZ; + dwordA = aPtr->v128; + dwordZ = dwordA + bPtr->v128; + carry1 = (dwordZ < dwordA); + dwordZ += carry2; + carry1 += (dwordZ < carry2); + aPtr->v128 = dwordZ; + aPtr->v192 = aPtr->v192 + bPtr->v192 + carry1; + +} + +struct floatX256 { + bool isNaN; + bool isInf; + bool isZero; + bool sign; + int_fast32_t exp; + struct uint256 sig; +}; + +static const struct floatX256 floatX256NaN = + { true, false, false, false, 0, { 0, 0, 0, 0 } }; +static const struct floatX256 floatX256PositiveZero = + { false, false, true, false, 0, { 0, 0, 0, 0 } }; +static const struct floatX256 floatX256NegativeZero = + { false, false, true, true, 0, { 0, 0, 0, 0 } }; + +#ifdef FLOAT128 + +static void f128MToFloatX256( const float128_t *aPtr, struct floatX256 *xPtr ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + xPtr->isNaN = x.isNaN; + xPtr->isInf = x.isInf; + xPtr->isZero = x.isZero; + xPtr->sign = x.sign; + xPtr->exp = x.exp; + xPtr->sig.v192 = x.sig.v64; + xPtr->sig.v128 = x.sig.v0; + xPtr->sig.v64 = 0; + xPtr->sig.v0 = 0; + +} + +static void floatX256ToF128M( const struct floatX256 *xPtr, float128_t *zPtr ) +{ + struct floatX x; + int_fast32_t expZ; + struct uint256 sig; + + x.isNaN = xPtr->isNaN; + x.isInf = xPtr->isInf; + x.isZero = xPtr->isZero; + x.sign = xPtr->sign; + if ( ! (x.isNaN | x.isInf | x.isZero) ) { + expZ = xPtr->exp; + sig = xPtr->sig; + while ( ! sig.v192 ) { + expZ -= 64; + sig.v192 = sig.v128; + sig.v128 = sig.v64; + sig.v64 = sig.v0; + sig.v0 = 0; + } + while ( sig.v192 < UINT64_C( 0x0100000000000000 ) ) { + --expZ; + shiftLeft1256M( &sig ); + } + x.exp = expZ; + x.sig.v64 = sig.v192; + x.sig.v0 = sig.v128 | ((sig.v64 | sig.v0) != 0); + } + floatXToF128M( &x, zPtr ); + +} + +#endif + +static void floatX256Invalid( struct floatX256 *xPtr ) +{ + + slowfloat_exceptionFlags |= softfloat_flag_invalid; + *xPtr = floatX256NaN; + +} + +static + void floatX256Add( struct floatX256 *xPtr, const struct floatX256 *yPtr ) +{ + int_fast32_t expX, expY, expDiff; + struct uint256 sigY; + + if ( xPtr->isNaN ) return; + if ( yPtr->isNaN ) goto copyY; + if ( xPtr->isInf && yPtr->isInf ) { + if ( xPtr->sign != yPtr->sign ) floatX256Invalid( xPtr ); + return; + } + if ( xPtr->isInf ) return; + if ( yPtr->isInf ) goto copyY; + if ( xPtr->isZero && yPtr->isZero ) { + if ( xPtr->sign == yPtr->sign ) return; + goto completeCancellation; + } + expX = xPtr->exp; + expY = yPtr->exp; + if ( + (xPtr->sign != yPtr->sign) && (expX == expY) + && eq256M( &xPtr->sig, &yPtr->sig ) + ) { + completeCancellation: + if (slowfloat_roundingMode == softfloat_round_min) { + *xPtr = floatX256NegativeZero; + } else { + *xPtr = floatX256PositiveZero; + } + return; + } + if ( xPtr->isZero ) goto copyY; + if ( yPtr->isZero ) return; + expDiff = expX - expY; + if ( expDiff < 0 ) { + xPtr->exp = expY; + if ( expDiff < -248 ) { + xPtr->sig.v192 = 0; + xPtr->sig.v128 = 0; + xPtr->sig.v64 = 0; + xPtr->sig.v0 = 1; + } else { + while ( expDiff < 0 ) { + ++expDiff; + shiftRight1Jam256M( &xPtr->sig ); + } + } + if ( xPtr->sign != yPtr->sign ) neg256M( &xPtr->sig ); + xPtr->sign = yPtr->sign; + add256M( &xPtr->sig, &yPtr->sig ); + } else { + sigY = yPtr->sig; + if ( 248 < expDiff ) { + sigY.v192 = 0; + sigY.v128 = 0; + sigY.v64 = 0; + sigY.v0 = 1; + } else { + while ( 0 < expDiff ) { + --expDiff; + shiftRight1Jam256M( &sigY ); + } + } + if ( xPtr->sign != yPtr->sign ) neg256M( &sigY ); + add256M( &xPtr->sig, &sigY ); + } + if ( xPtr->sig.v192 & UINT64_C( 0x8000000000000000 ) ) { + xPtr->sign = ! xPtr->sign; + neg256M( &xPtr->sig ); + } + return; + copyY: + *xPtr = *yPtr; + +} + +static + void floatX256Mul( struct floatX256 *xPtr, const struct floatX256 *yPtr ) +{ + struct uint256 sig; + int bitNum; + + if ( xPtr->isNaN ) return; + if ( yPtr->isNaN ) { + xPtr->isNaN = true; + xPtr->isInf = false; + xPtr->isZero = false; + xPtr->sign = yPtr->sign; + return; + } + if ( yPtr->sign ) xPtr->sign = ! xPtr->sign; + if ( xPtr->isInf ) { + if ( yPtr->isZero ) floatX256Invalid( xPtr ); + return; + } + if ( yPtr->isInf ) { + if ( xPtr->isZero ) { + floatX256Invalid( xPtr ); + return; + } + xPtr->isInf = true; + return; + } + if ( xPtr->isZero || yPtr->isZero ) { + if ( xPtr->sign ) { + *xPtr = floatX256NegativeZero; + } else { + *xPtr = floatX256PositiveZero; + } + return; + } + xPtr->exp += yPtr->exp; + sig.v192 = 0; + sig.v128 = 0; + sig.v64 = 0; + sig.v0 = 0; + for ( bitNum = 0; bitNum < 248; ++bitNum ) { + shiftRight1Jam256M( &sig ); + if ( xPtr->sig.v0 & 1 ) add256M( &sig, &yPtr->sig ); + shiftRight1256M( &xPtr->sig ); + } + if ( UINT64_C( 0x0100000000000000 ) <= sig.v192 ) { + ++xPtr->exp; + shiftRight1Jam256M( &sig ); + } + xPtr->sig = sig; + +} + +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +float32_t slow_ui32_to_f32( uint32_t a ) +{ + struct floatX x; + + ui32ToFloatX( a, &x ); + return floatXToF32( &x ); + +} + +float64_t slow_ui32_to_f64( uint32_t a ) +{ + struct floatX x; + + ui32ToFloatX( a, &x ); + return floatXToF64( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr ) +{ + struct floatX x; + + ui32ToFloatX( a, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +void slow_ui32_to_f128M( uint32_t a, float128_t *zPtr ) +{ + struct floatX x; + + ui32ToFloatX( a, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +float32_t slow_ui64_to_f32( uint64_t a ) +{ + struct floatX x; + + ui64ToFloatX( a, &x ); + return floatXToF32( &x ); + +} + +float64_t slow_ui64_to_f64( uint64_t a ) +{ + struct floatX x; + + ui64ToFloatX( a, &x ); + return floatXToF64( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr ) +{ + struct floatX x; + + ui64ToFloatX( a, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +void slow_ui64_to_f128M( uint64_t a, float128_t *zPtr ) +{ + struct floatX x; + + ui64ToFloatX( a, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +float32_t slow_i32_to_f32( int32_t a ) +{ + struct floatX x; + + i32ToFloatX( a, &x ); + return floatXToF32( &x ); + +} + +float64_t slow_i32_to_f64( int32_t a ) +{ + struct floatX x; + + i32ToFloatX( a, &x ); + return floatXToF64( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_i32_to_extF80M( int32_t a, extFloat80_t *zPtr ) +{ + struct floatX x; + + i32ToFloatX( a, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +void slow_i32_to_f128M( int32_t a, float128_t *zPtr ) +{ + struct floatX x; + + i32ToFloatX( a, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +float32_t slow_i64_to_f32( int64_t a ) +{ + struct floatX x; + + i64ToFloatX( a, &x ); + return floatXToF32( &x ); + +} + +float64_t slow_i64_to_f64( int64_t a ) +{ + struct floatX x; + + i64ToFloatX( a, &x ); + return floatXToF64( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_i64_to_extF80M( int64_t a, extFloat80_t *zPtr ) +{ + struct floatX x; + + i64ToFloatX( a, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +void slow_i64_to_f128M( int64_t a, float128_t *zPtr ) +{ + struct floatX x; + + i64ToFloatX( a, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +uint_fast32_t + slow_f32_to_ui32( float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToUI32( &x, roundingMode, exact ); + +} + +uint_fast64_t + slow_f32_to_ui64( float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToUI64( &x, roundingMode, exact ); + +} + +int_fast32_t + slow_f32_to_i32( float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToI32( &x, roundingMode, exact ); + +} + +int_fast64_t + slow_f32_to_i64( float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToI64( &x, roundingMode, exact ); + +} + +uint_fast32_t slow_f32_to_ui32_r_minMag( float32_t a, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToUI32( &x, softfloat_round_minMag, exact ); + +} + +uint_fast64_t slow_f32_to_ui64_r_minMag( float32_t a, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToUI64( &x, softfloat_round_minMag, exact ); + +} + +int_fast32_t slow_f32_to_i32_r_minMag( float32_t a, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToI32( &x, softfloat_round_minMag, exact ); + +} + +int_fast64_t slow_f32_to_i64_r_minMag( float32_t a, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToI64( &x, softfloat_round_minMag, exact ); + +} + +float64_t slow_f32_to_f64( float32_t a ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToF64( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_f32_to_extF80M( float32_t a, extFloat80_t *zPtr ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +void slow_f32_to_f128M( float32_t a, float128_t *zPtr ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +float32_t + slow_f32_roundToInt( float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + floatXRoundToInt( &x, roundingMode, exact ); + return floatXToF32( &x ); + +} + +float32_t slow_f32_add( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + floatXAdd( &x, &y ); + return floatXToF32( &x ); + +} + +float32_t slow_f32_sub( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + y.sign = ! y.sign; + floatXAdd( &x, &y ); + return floatXToF32( &x ); + + +} + +float32_t slow_f32_mul( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + floatXMul( &x, &y ); + return floatXToF32( &x ); + +} + +float32_t slow_f32_mulAdd( float32_t a, float32_t b, float32_t c ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + floatXMul( &x, &y ); + f32ToFloatX( c, &y ); + floatXAdd( &x, &y ); + return floatXToF32( &x ); + +} + +float32_t slow_f32_div( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + floatXDiv( &x, &y ); + return floatXToF32( &x ); + +} + +float32_t slow_f32_rem( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + floatXRem( &x, &y ); + return floatXToF32( &x ); + +} + +float32_t slow_f32_sqrt( float32_t a ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + floatXSqrt( &x ); + return floatXToF32( &x ); + +} + +bool slow_f32_eq( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + return floatXEq( &x, &y ); + +} + +bool slow_f32_le( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLe( &x, &y ); + +} + +bool slow_f32_lt( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLt( &x, &y ); + +} + +bool slow_f32_eq_signaling( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXEq( &x, &y ); + +} + +bool slow_f32_le_quiet( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + return floatXLe( &x, &y ); + +} + +bool slow_f32_lt_quiet( float32_t a, float32_t b ) +{ + struct floatX x, y; + + f32ToFloatX( a, &x ); + f32ToFloatX( b, &y ); + return floatXLt( &x, &y ); + +} + +uint_fast32_t + slow_f64_to_ui32( float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToUI32( &x, roundingMode, exact ); + +} + +uint_fast64_t + slow_f64_to_ui64( float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToUI64( &x, roundingMode, exact ); + +} + +int_fast32_t + slow_f64_to_i32( float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToI32( &x, roundingMode, exact ); + +} + +int_fast64_t + slow_f64_to_i64( float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToI64( &x, roundingMode, exact ); + +} + +uint_fast32_t slow_f64_to_ui32_r_minMag( float64_t a, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToUI32( &x, softfloat_round_minMag, exact ); + +} + +uint_fast64_t slow_f64_to_ui64_r_minMag( float64_t a, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToUI64( &x, softfloat_round_minMag, exact ); + +} + +int_fast32_t slow_f64_to_i32_r_minMag( float64_t a, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToI32( &x, softfloat_round_minMag, exact ); + +} + +int_fast64_t slow_f64_to_i64_r_minMag( float64_t a, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToI64( &x, softfloat_round_minMag, exact ); + +} + +float32_t slow_f64_to_f32( float64_t a ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToF32( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_f64_to_extF80M( float64_t a, extFloat80_t *zPtr ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +void slow_f64_to_f128M( float64_t a, float128_t *zPtr ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +float64_t + slow_f64_roundToInt( float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + floatXRoundToInt( &x, roundingMode, exact ); + return floatXToF64( &x ); + +} + +float64_t slow_f64_add( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + floatXAdd( &x, &y ); + return floatXToF64( &x ); + +} + +float64_t slow_f64_sub( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + y.sign = ! y.sign; + floatXAdd( &x, &y ); + return floatXToF64( &x ); + +} + +float64_t slow_f64_mul( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + floatXMul( &x, &y ); + return floatXToF64( &x ); + +} + +float64_t slow_f64_mulAdd( float64_t a, float64_t b, float64_t c ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + floatXMul( &x, &y ); + f64ToFloatX( c, &y ); + floatXAdd( &x, &y ); + return floatXToF64( &x ); + +} + +float64_t slow_f64_div( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + floatXDiv( &x, &y ); + return floatXToF64( &x ); + +} + +float64_t slow_f64_rem( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + floatXRem( &x, &y ); + return floatXToF64( &x ); + +} + +float64_t slow_f64_sqrt( float64_t a ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + floatXSqrt( &x ); + return floatXToF64( &x ); + +} + +bool slow_f64_eq( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + return floatXEq( &x, &y ); + +} + +bool slow_f64_le( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLe( &x, &y ); + +} + +bool slow_f64_lt( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLt( &x, &y ); + +} + +bool slow_f64_eq_signaling( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXEq( &x, &y ); + +} + +bool slow_f64_le_quiet( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + return floatXLe( &x, &y ); + +} + +bool slow_f64_lt_quiet( float64_t a, float64_t b ) +{ + struct floatX x, y; + + f64ToFloatX( a, &x ); + f64ToFloatX( b, &y ); + return floatXLt( &x, &y ); + +} + +#ifdef EXTFLOAT80 + +uint_fast32_t + slow_extF80M_to_ui32( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToUI32( &x, roundingMode, exact ); + +} + +uint_fast64_t + slow_extF80M_to_ui64( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToUI64( &x, roundingMode, exact ); + +} + +int_fast32_t + slow_extF80M_to_i32( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToI32( &x, roundingMode, exact ); + +} + +int_fast64_t + slow_extF80M_to_i64( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToI64( &x, roundingMode, exact ); + +} + +uint_fast32_t + slow_extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToUI32( &x, softfloat_round_minMag, exact ); + +} + +uint_fast64_t + slow_extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToUI64( &x, softfloat_round_minMag, exact ); + +} + +int_fast32_t + slow_extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToI32( &x, softfloat_round_minMag, exact ); + +} + +int_fast64_t + slow_extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToI64( &x, softfloat_round_minMag, exact ); + +} + +float32_t slow_extF80M_to_f32( const extFloat80_t *aPtr ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToF32( &x ); + +} + +float64_t slow_extF80M_to_f64( const extFloat80_t *aPtr ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToF64( &x ); + +} + +#ifdef FLOAT128 + +void slow_extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +void + slow_extF80M_roundToInt( + const extFloat80_t *aPtr, + uint_fast8_t roundingMode, + bool exact, + extFloat80_t *zPtr + ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + floatXRoundToInt( &x, roundingMode, exact ); + floatXToExtF80M( &x, zPtr ); + +} + +void + slow_extF80M_add( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + floatXAdd( &x, &y ); + floatXToExtF80M( &x, zPtr ); + +} + +void + slow_extF80M_sub( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + y.sign = ! y.sign; + floatXAdd( &x, &y ); + floatXToExtF80M( &x, zPtr ); + +} + +void + slow_extF80M_mul( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + floatXMul( &x, &y ); + floatXToExtF80M( &x, zPtr ); + +} + +void + slow_extF80M_div( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + floatXDiv( &x, &y ); + floatXToExtF80M( &x, zPtr ); + +} + +void + slow_extF80M_rem( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + floatXRem( &x, &y ); + floatXToExtF80M( &x, zPtr ); + +} + +void slow_extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + floatXSqrt( &x ); + floatXToExtF80M( &x, zPtr ); + +} + +bool slow_extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + return floatXEq( &x, &y ); + +} + +bool slow_extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLe( &x, &y ); + +} + +bool slow_extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLt( &x, &y ); + +} + +bool + slow_extF80M_eq_signaling( + const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXEq( &x, &y ); + +} + +bool slow_extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + return floatXLe( &x, &y ); + +} + +bool slow_extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + struct floatX x, y; + + extF80MToFloatX( aPtr, &x ); + extF80MToFloatX( bPtr, &y ); + return floatXLt( &x, &y ); + +} + +#endif + +#ifdef FLOAT128 + +uint_fast32_t + slow_f128M_to_ui32( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToUI32( &x, roundingMode, exact ); + +} + +uint_fast64_t + slow_f128M_to_ui64( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToUI64( &x, roundingMode, exact ); + +} + +int_fast32_t + slow_f128M_to_i32( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToI32( &x, roundingMode, exact ); + +} + +int_fast64_t + slow_f128M_to_i64( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToI64( &x, roundingMode, exact ); + +} + +uint_fast32_t slow_f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToUI32( &x, softfloat_round_minMag, exact ); + +} + +uint_fast64_t slow_f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToUI64( &x, softfloat_round_minMag, exact ); + +} + +int_fast32_t slow_f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToI32( &x, softfloat_round_minMag, exact ); + +} + +int_fast64_t slow_f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToI64( &x, softfloat_round_minMag, exact ); + +} + +float32_t slow_f128M_to_f32( const float128_t *aPtr ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToF32( &x ); + +} + +float64_t slow_f128M_to_f64( const float128_t *aPtr ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToF64( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +void + slow_f128M_roundToInt( + const float128_t *aPtr, + uint_fast8_t roundingMode, + bool exact, + float128_t *zPtr + ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + floatXRoundToInt( &x, roundingMode, exact ); + floatXToF128M( &x, zPtr ); + +} + +void + slow_f128M_add( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + floatXAdd( &x, &y ); + floatXToF128M( &x, zPtr ); + +} + +void + slow_f128M_sub( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + y.sign = ! y.sign; + floatXAdd( &x, &y ); + floatXToF128M( &x, zPtr ); + +} + +void + slow_f128M_mul( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + floatXMul( &x, &y ); + floatXToF128M( &x, zPtr ); + +} + +void + slow_f128M_mulAdd( + const float128_t *aPtr, + const float128_t *bPtr, + const float128_t *cPtr, + float128_t *zPtr + ) +{ + struct floatX256 x, y; + + f128MToFloatX256( aPtr, &x ); + f128MToFloatX256( bPtr, &y ); + floatX256Mul( &x, &y ); + f128MToFloatX256( cPtr, &y ); + floatX256Add( &x, &y ); + floatX256ToF128M( &x, zPtr ); + +} + +void + slow_f128M_div( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + floatXDiv( &x, &y ); + floatXToF128M( &x, zPtr ); + +} + +void + slow_f128M_rem( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + floatXRem( &x, &y ); + floatXToF128M( &x, zPtr ); + +} + +void slow_f128M_sqrt( const float128_t *aPtr, float128_t *zPtr ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + floatXSqrt( &x ); + floatXToF128M( &x, zPtr ); + +} + +bool slow_f128M_eq( const float128_t *aPtr, const float128_t *bPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + return floatXEq( &x, &y ); + +} + +bool slow_f128M_le( const float128_t *aPtr, const float128_t *bPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLe( &x, &y ); + +} + +bool slow_f128M_lt( const float128_t *aPtr, const float128_t *bPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLt( &x, &y ); + +} + +bool slow_f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXEq( &x, &y ); + +} + +bool slow_f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + return floatXLe( &x, &y ); + +} + +bool slow_f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr ) +{ + struct floatX x, y; + + f128MToFloatX( aPtr, &x ); + f128MToFloatX( bPtr, &y ); + return floatXLt( &x, &y ); + +} + +#endif + diff --git a/source/slowfloat.h b/source/slowfloat.h new file mode 100644 index 0000000..b2d8cb8 --- /dev/null +++ b/source/slowfloat.h @@ -0,0 +1,220 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "softfloat.h" + +extern uint_fast8_t slowfloat_roundingMode; +extern uint_fast8_t slowfloat_detectTininess; +extern uint_fast8_t slowfloat_exceptionFlags; +#ifdef EXTFLOAT80 +extern uint_fast8_t slow_extF80_roundingPrecision; +#endif + +float32_t slow_ui32_to_f32( uint32_t ); +float64_t slow_ui32_to_f64( uint32_t ); +#ifdef EXTFLOAT80 +void slow_ui32_to_extF80M( uint32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void slow_ui32_to_f128M( uint32_t, float128_t * ); +#endif +float32_t slow_ui64_to_f32( uint64_t ); +float64_t slow_ui64_to_f64( uint64_t ); +#ifdef EXTFLOAT80 +void slow_ui64_to_extF80M( uint64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void slow_ui64_to_f128M( uint64_t, float128_t * ); +#endif +float32_t slow_i32_to_f32( int32_t ); +float64_t slow_i32_to_f64( int32_t ); +#ifdef EXTFLOAT80 +void slow_i32_to_extF80M( int32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void slow_i32_to_f128M( int32_t, float128_t * ); +#endif +float32_t slow_i64_to_f32( int64_t ); +float64_t slow_i64_to_f64( int64_t ); +#ifdef EXTFLOAT80 +void slow_i64_to_extF80M( int64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void slow_i64_to_f128M( int64_t, float128_t * ); +#endif + +uint_fast32_t slow_f32_to_ui32( float32_t, uint_fast8_t, bool ); +uint_fast64_t slow_f32_to_ui64( float32_t, uint_fast8_t, bool ); +int_fast32_t slow_f32_to_i32( float32_t, uint_fast8_t, bool ); +int_fast64_t slow_f32_to_i64( float32_t, uint_fast8_t, bool ); +uint_fast32_t slow_f32_to_ui32_r_minMag( float32_t, bool ); +uint_fast64_t slow_f32_to_ui64_r_minMag( float32_t, bool ); +int_fast32_t slow_f32_to_i32_r_minMag( float32_t, bool ); +int_fast64_t slow_f32_to_i64_r_minMag( float32_t, bool ); +float64_t slow_f32_to_f64( float32_t ); +#ifdef EXTFLOAT80 +void slow_f32_to_extF80M( float32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void slow_f32_to_f128M( float32_t, float128_t * ); +#endif +float32_t slow_f32_roundToInt( float32_t, uint_fast8_t, bool ); +float32_t slow_f32_add( float32_t, float32_t ); +float32_t slow_f32_sub( float32_t, float32_t ); +float32_t slow_f32_mul( float32_t, float32_t ); +float32_t slow_f32_mulAdd( float32_t, float32_t, float32_t ); +float32_t slow_f32_div( float32_t, float32_t ); +float32_t slow_f32_rem( float32_t, float32_t ); +float32_t slow_f32_sqrt( float32_t ); +bool slow_f32_eq( float32_t, float32_t ); +bool slow_f32_le( float32_t, float32_t ); +bool slow_f32_lt( float32_t, float32_t ); +bool slow_f32_eq_signaling( float32_t, float32_t ); +bool slow_f32_le_quiet( float32_t, float32_t ); +bool slow_f32_lt_quiet( float32_t, float32_t ); + +uint_fast32_t slow_f64_to_ui32( float64_t, uint_fast8_t, bool ); +uint_fast64_t slow_f64_to_ui64( float64_t, uint_fast8_t, bool ); +int_fast32_t slow_f64_to_i32( float64_t, uint_fast8_t, bool ); +int_fast64_t slow_f64_to_i64( float64_t, uint_fast8_t, bool ); +uint_fast32_t slow_f64_to_ui32_r_minMag( float64_t, bool ); +uint_fast64_t slow_f64_to_ui64_r_minMag( float64_t, bool ); +int_fast32_t slow_f64_to_i32_r_minMag( float64_t, bool ); +int_fast64_t slow_f64_to_i64_r_minMag( float64_t, bool ); +float32_t slow_f64_to_f32( float64_t ); +#ifdef EXTFLOAT80 +void slow_f64_to_extF80M( float64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void slow_f64_to_f128M( float64_t, float128_t * ); +#endif +float64_t slow_f64_roundToInt( float64_t, uint_fast8_t, bool ); +float64_t slow_f64_add( float64_t, float64_t ); +float64_t slow_f64_sub( float64_t, float64_t ); +float64_t slow_f64_mul( float64_t, float64_t ); +float64_t slow_f64_mulAdd( float64_t, float64_t, float64_t ); +float64_t slow_f64_div( float64_t, float64_t ); +float64_t slow_f64_rem( float64_t, float64_t ); +float64_t slow_f64_sqrt( float64_t ); +bool slow_f64_eq( float64_t, float64_t ); +bool slow_f64_le( float64_t, float64_t ); +bool slow_f64_lt( float64_t, float64_t ); +bool slow_f64_eq_signaling( float64_t, float64_t ); +bool slow_f64_le_quiet( float64_t, float64_t ); +bool slow_f64_lt_quiet( float64_t, float64_t ); + +#ifdef EXTFLOAT80 +uint_fast32_t slow_extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool ); +uint_fast64_t slow_extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool ); +int_fast32_t slow_extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool ); +int_fast64_t slow_extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool ); +uint_fast32_t slow_extF80M_to_ui32_r_minMag( const extFloat80_t *, bool ); +uint_fast64_t slow_extF80M_to_ui64_r_minMag( const extFloat80_t *, bool ); +int_fast32_t slow_extF80M_to_i32_r_minMag( const extFloat80_t *, bool ); +int_fast64_t slow_extF80M_to_i64_r_minMag( const extFloat80_t *, bool ); +float32_t slow_extF80M_to_f32( const extFloat80_t * ); +float64_t slow_extF80M_to_f64( const extFloat80_t * ); +#ifdef FLOAT128 +void slow_extF80M_to_f128M( const extFloat80_t *, float128_t * ); +#endif +void + slow_extF80M_roundToInt( + const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ); +void + slow_extF80M_add( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + slow_extF80M_sub( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + slow_extF80M_mul( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + slow_extF80M_mulAdd( + const extFloat80_t *, + const extFloat80_t *, + const extFloat80_t *, + extFloat80_t * + ); +void + slow_extF80M_div( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + slow_extF80M_rem( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void slow_extF80M_sqrt( const extFloat80_t *, extFloat80_t * ); +bool slow_extF80M_eq( const extFloat80_t *, const extFloat80_t * ); +bool slow_extF80M_le( const extFloat80_t *, const extFloat80_t * ); +bool slow_extF80M_lt( const extFloat80_t *, const extFloat80_t * ); +bool slow_extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * ); +bool slow_extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * ); +bool slow_extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * ); +#endif + +#ifdef FLOAT128 +uint_fast32_t slow_f128M_to_ui32( const float128_t *, uint_fast8_t, bool ); +uint_fast64_t slow_f128M_to_ui64( const float128_t *, uint_fast8_t, bool ); +int_fast32_t slow_f128M_to_i32( const float128_t *, uint_fast8_t, bool ); +int_fast64_t slow_f128M_to_i64( const float128_t *, uint_fast8_t, bool ); +uint_fast32_t slow_f128M_to_ui32_r_minMag( const float128_t *, bool ); +uint_fast64_t slow_f128M_to_ui64_r_minMag( const float128_t *, bool ); +int_fast32_t slow_f128M_to_i32_r_minMag( const float128_t *, bool ); +int_fast64_t slow_f128M_to_i64_r_minMag( const float128_t *, bool ); +float32_t slow_f128M_to_f32( const float128_t * ); +float64_t slow_f128M_to_f64( const float128_t * ); +#ifdef EXTFLOAT80 +void slow_f128M_to_extF80M( const float128_t *, extFloat80_t * ); +#endif +void + slow_f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * ); +void slow_f128M_add( const float128_t *, const float128_t *, float128_t * ); +void slow_f128M_sub( const float128_t *, const float128_t *, float128_t * ); +void slow_f128M_mul( const float128_t *, const float128_t *, float128_t * ); +void + slow_f128M_mulAdd( + const float128_t *, const float128_t *, const float128_t *, float128_t * + ); +void slow_f128M_div( const float128_t *, const float128_t *, float128_t * ); +void slow_f128M_rem( const float128_t *, const float128_t *, float128_t * ); +void slow_f128M_sqrt( const float128_t *, float128_t * ); +bool slow_f128M_eq( const float128_t *, const float128_t * ); +bool slow_f128M_le( const float128_t *, const float128_t * ); +bool slow_f128M_lt( const float128_t *, const float128_t * ); +bool slow_f128M_eq_signaling( const float128_t *, const float128_t * ); +bool slow_f128M_le_quiet( const float128_t *, const float128_t * ); +bool slow_f128M_lt_quiet( const float128_t *, const float128_t * ); +#endif + diff --git a/source/standardFunctionInfos.c b/source/standardFunctionInfos.c new file mode 100644 index 0000000..68613eb --- /dev/null +++ b/source/standardFunctionInfos.c @@ -0,0 +1,355 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "functions.h" + +#define RNEVEN ROUND_NEAR_EVEN +#define RMINM ROUND_MINMAG +#define RMIN ROUND_MIN +#define RMAX ROUND_MAX +#define RNMAXM ROUND_NEAR_MAXMAG + +const struct standardFunctionInfo standardFunctionInfos[] = { + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + { "ui32_to_f32", UI32_TO_F32, 0, 0 }, + { "ui32_to_f64", UI32_TO_F64, 0, 0 }, +#ifdef EXTFLOAT80 + { "ui32_to_extF80", UI32_TO_EXTF80, 0, 0 }, +#endif +#ifdef FLOAT128 + { "ui32_to_f128", UI32_TO_F128, 0, 0 }, +#endif + { "ui64_to_f32", UI64_TO_F32, 0, 0 }, + { "ui64_to_f64", UI64_TO_F64, 0, 0 }, +#ifdef EXTFLOAT80 + { "ui64_to_extF80", UI64_TO_EXTF80, 0, 0 }, +#endif +#ifdef FLOAT128 + { "ui64_to_f128", UI64_TO_F128, 0, 0 }, +#endif + { "i32_to_f32", I32_TO_F32, 0, 0 }, + { "i32_to_f64", I32_TO_F64, 0, 0 }, +#ifdef EXTFLOAT80 + { "i32_to_extF80", I32_TO_EXTF80, 0, 0 }, +#endif +#ifdef FLOAT128 + { "i32_to_f128", I32_TO_F128, 0, 0 }, +#endif + { "i64_to_f32", I64_TO_F32, 0, 0 }, + { "i64_to_f64", I64_TO_F64, 0, 0 }, +#ifdef EXTFLOAT80 + { "i64_to_extF80", I64_TO_EXTF80, 0, 0 }, +#endif +#ifdef FLOAT128 + { "i64_to_f128", I64_TO_F128, 0, 0 }, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + { "f32_to_ui32_r_near_even", F32_TO_UI32, RNEVEN, false }, + { "f32_to_ui32_r_minMag", F32_TO_UI32, RMINM, false }, + { "f32_to_ui32_r_min", F32_TO_UI32, RMIN, false }, + { "f32_to_ui32_r_max", F32_TO_UI32, RMAX, false }, + { "f32_to_ui32_r_near_maxMag", F32_TO_UI32, RNMAXM, false }, + { "f32_to_ui64_r_near_even", F32_TO_UI64, RNEVEN, false }, + { "f32_to_ui64_r_minMag", F32_TO_UI64, RMINM, false }, + { "f32_to_ui64_r_min", F32_TO_UI64, RMIN, false }, + { "f32_to_ui64_r_max", F32_TO_UI64, RMAX, false }, + { "f32_to_ui64_r_near_maxMag", F32_TO_UI64, RNMAXM, false }, + { "f32_to_i32_r_near_even", F32_TO_I32, RNEVEN, false }, + { "f32_to_i32_r_minMag", F32_TO_I32, RMINM, false }, + { "f32_to_i32_r_min", F32_TO_I32, RMIN, false }, + { "f32_to_i32_r_max", F32_TO_I32, RMAX, false }, + { "f32_to_i32_r_near_maxMag", F32_TO_I32, RNMAXM, false }, + { "f32_to_i64_r_near_even", F32_TO_I64, RNEVEN, false }, + { "f32_to_i64_r_minMag", F32_TO_I64, RMINM, false }, + { "f32_to_i64_r_min", F32_TO_I64, RMIN, false }, + { "f32_to_i64_r_max", F32_TO_I64, RMAX, false }, + { "f32_to_i64_r_near_maxMag", F32_TO_I64, RNMAXM, false }, + { "f32_to_ui32_rx_near_even", F32_TO_UI32, RNEVEN, true }, + { "f32_to_ui32_rx_minMag", F32_TO_UI32, RMINM, true }, + { "f32_to_ui32_rx_min", F32_TO_UI32, RMIN, true }, + { "f32_to_ui32_rx_max", F32_TO_UI32, RMAX, true }, + { "f32_to_ui32_rx_near_maxMag", F32_TO_UI32, RNMAXM, true }, + { "f32_to_ui64_rx_near_even", F32_TO_UI64, RNEVEN, true }, + { "f32_to_ui64_rx_minMag", F32_TO_UI64, RMINM, true }, + { "f32_to_ui64_rx_min", F32_TO_UI64, RMIN, true }, + { "f32_to_ui64_rx_max", F32_TO_UI64, RMAX, true }, + { "f32_to_ui64_rx_near_maxMag", F32_TO_UI64, RNMAXM, true }, + { "f32_to_i32_rx_near_even", F32_TO_I32, RNEVEN, true }, + { "f32_to_i32_rx_minMag", F32_TO_I32, RMINM, true }, + { "f32_to_i32_rx_min", F32_TO_I32, RMIN, true }, + { "f32_to_i32_rx_max", F32_TO_I32, RMAX, true }, + { "f32_to_i32_rx_near_maxMag", F32_TO_I32, RNMAXM, true }, + { "f32_to_i64_rx_near_even", F32_TO_I64, RNEVEN, true }, + { "f32_to_i64_rx_minMag", F32_TO_I64, RMINM, true }, + { "f32_to_i64_rx_min", F32_TO_I64, RMIN, true }, + { "f32_to_i64_rx_max", F32_TO_I64, RMAX, true }, + { "f32_to_i64_rx_near_maxMag", F32_TO_I64, RNMAXM, true }, + { "f32_to_f64", F32_TO_F64, 0, 0 }, +#ifdef EXTFLOAT80 + { "f32_to_extF80", F32_TO_EXTF80, 0, 0 }, +#endif +#ifdef FLOAT128 + { "f32_to_f128", F32_TO_F128, 0, 0 }, +#endif + { "f32_roundToInt_r_near_even", F32_ROUNDTOINT, RNEVEN, false }, + { "f32_roundToInt_r_minMag", F32_ROUNDTOINT, RMINM, false }, + { "f32_roundToInt_r_min", F32_ROUNDTOINT, RMIN, false }, + { "f32_roundToInt_r_max", F32_ROUNDTOINT, RMAX, false }, + { "f32_roundToInt_r_near_maxMag", F32_ROUNDTOINT, RNMAXM, false }, + { "f32_roundToInt_x", F32_ROUNDTOINT, 0, true }, + { "f32_add", F32_ADD, 0, 0 }, + { "f32_sub", F32_SUB, 0, 0 }, + { "f32_mul", F32_MUL, 0, 0 }, + { "f32_mulAdd", F32_MULADD, 0, 0 }, + { "f32_div", F32_DIV, 0, 0 }, + { "f32_rem", F32_REM, 0, 0 }, + { "f32_sqrt", F32_SQRT, 0, 0 }, + { "f32_eq", F32_EQ, 0, 0 }, + { "f32_le", F32_LE, 0, 0 }, + { "f32_lt", F32_LT, 0, 0 }, + { "f32_eq_signaling", F32_EQ_SIGNALING, 0, 0 }, + { "f32_le_quiet", F32_LE_QUIET, 0, 0 }, + { "f32_lt_quiet", F32_LT_QUIET, 0, 0 }, + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + { "f64_to_ui32_r_near_even", F64_TO_UI32, RNEVEN, false }, + { "f64_to_ui32_r_minMag", F64_TO_UI32, RMINM, false }, + { "f64_to_ui32_r_min", F64_TO_UI32, RMIN, false }, + { "f64_to_ui32_r_max", F64_TO_UI32, RMAX, false }, + { "f64_to_ui32_r_near_maxMag", F64_TO_UI32, RNMAXM, false }, + { "f64_to_ui64_r_near_even", F64_TO_UI64, RNEVEN, false }, + { "f64_to_ui64_r_minMag", F64_TO_UI64, RMINM, false }, + { "f64_to_ui64_r_min", F64_TO_UI64, RMIN, false }, + { "f64_to_ui64_r_max", F64_TO_UI64, RMAX, false }, + { "f64_to_ui64_r_near_maxMag", F64_TO_UI64, RNMAXM, false }, + { "f64_to_i32_r_near_even", F64_TO_I32, RNEVEN, false }, + { "f64_to_i32_r_minMag", F64_TO_I32, RMINM, false }, + { "f64_to_i32_r_min", F64_TO_I32, RMIN, false }, + { "f64_to_i32_r_max", F64_TO_I32, RMAX, false }, + { "f64_to_i32_r_near_maxMag", F64_TO_I32, RNMAXM, false }, + { "f64_to_i64_r_near_even", F64_TO_I64, RNEVEN, false }, + { "f64_to_i64_r_minMag", F64_TO_I64, RMINM, false }, + { "f64_to_i64_r_min", F64_TO_I64, RMIN, false }, + { "f64_to_i64_r_max", F64_TO_I64, RMAX, false }, + { "f64_to_i64_r_near_maxMag", F64_TO_I64, RNMAXM, false }, + { "f64_to_ui32_rx_near_even", F64_TO_UI32, RNEVEN, true }, + { "f64_to_ui32_rx_minMag", F64_TO_UI32, RMINM, true }, + { "f64_to_ui32_rx_min", F64_TO_UI32, RMIN, true }, + { "f64_to_ui32_rx_max", F64_TO_UI32, RMAX, true }, + { "f64_to_ui32_rx_near_maxMag", F64_TO_UI32, RNMAXM, true }, + { "f64_to_ui64_rx_near_even", F64_TO_UI64, RNEVEN, true }, + { "f64_to_ui64_rx_minMag", F64_TO_UI64, RMINM, true }, + { "f64_to_ui64_rx_min", F64_TO_UI64, RMIN, true }, + { "f64_to_ui64_rx_max", F64_TO_UI64, RMAX, true }, + { "f64_to_ui64_rx_near_maxMag", F64_TO_UI64, RNMAXM, true }, + { "f64_to_i32_rx_near_even", F64_TO_I32, RNEVEN, true }, + { "f64_to_i32_rx_minMag", F64_TO_I32, RMINM, true }, + { "f64_to_i32_rx_min", F64_TO_I32, RMIN, true }, + { "f64_to_i32_rx_max", F64_TO_I32, RMAX, true }, + { "f64_to_i32_rx_near_maxMag", F64_TO_I32, RNMAXM, true }, + { "f64_to_i64_rx_near_even", F64_TO_I64, RNEVEN, true }, + { "f64_to_i64_rx_minMag", F64_TO_I64, RMINM, true }, + { "f64_to_i64_rx_min", F64_TO_I64, RMIN, true }, + { "f64_to_i64_rx_max", F64_TO_I64, RMAX, true }, + { "f64_to_i64_rx_near_maxMag", F64_TO_I64, RNMAXM, true }, + { "f64_to_f32", F64_TO_F32, 0, 0 }, +#ifdef EXTFLOAT80 + { "f64_to_extF80", F64_TO_EXTF80, 0, 0 }, +#endif +#ifdef FLOAT128 + { "f64_to_f128", F64_TO_F128, 0, 0 }, +#endif + { "f64_roundToInt_r_near_even", F64_ROUNDTOINT, RNEVEN, false }, + { "f64_roundToInt_r_minMag", F64_ROUNDTOINT, RMINM, false }, + { "f64_roundToInt_r_min", F64_ROUNDTOINT, RMIN, false }, + { "f64_roundToInt_r_max", F64_ROUNDTOINT, RMAX, false }, + { "f64_roundToInt_r_near_maxMag", F64_ROUNDTOINT, RNMAXM, false }, + { "f64_roundToInt_x", F64_ROUNDTOINT, 0, true }, + { "f64_add", F64_ADD, 0, 0 }, + { "f64_sub", F64_SUB, 0, 0 }, + { "f64_mul", F64_MUL, 0, 0 }, + { "f64_mulAdd", F64_MULADD, 0, 0 }, + { "f64_div", F64_DIV, 0, 0 }, + { "f64_rem", F64_REM, 0, 0 }, + { "f64_sqrt", F64_SQRT, 0, 0 }, + { "f64_eq", F64_EQ, 0, 0 }, + { "f64_le", F64_LE, 0, 0 }, + { "f64_lt", F64_LT, 0, 0 }, + { "f64_eq_signaling", F64_EQ_SIGNALING, 0, 0 }, + { "f64_le_quiet", F64_LE_QUIET, 0, 0 }, + { "f64_lt_quiet", F64_LT_QUIET, 0, 0 }, + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef EXTFLOAT80 + { "extF80_to_ui32_r_near_even", EXTF80_TO_UI32, RNEVEN, false }, + { "extF80_to_ui32_r_minMag", EXTF80_TO_UI32, RMINM, false }, + { "extF80_to_ui32_r_min", EXTF80_TO_UI32, RMIN, false }, + { "extF80_to_ui32_r_max", EXTF80_TO_UI32, RMAX, false }, + { "extF80_to_ui32_r_near_maxMag", EXTF80_TO_UI32, RNMAXM, false }, + { "extF80_to_ui64_r_near_even", EXTF80_TO_UI64, RNEVEN, false }, + { "extF80_to_ui64_r_minMag", EXTF80_TO_UI64, RMINM, false }, + { "extF80_to_ui64_r_min", EXTF80_TO_UI64, RMIN, false }, + { "extF80_to_ui64_r_max", EXTF80_TO_UI64, RMAX, false }, + { "extF80_to_ui64_r_near_maxMag", EXTF80_TO_UI64, RNMAXM, false }, + { "extF80_to_i32_r_near_even", EXTF80_TO_I32, RNEVEN, false }, + { "extF80_to_i32_r_minMag", EXTF80_TO_I32, RMINM, false }, + { "extF80_to_i32_r_min", EXTF80_TO_I32, RMIN, false }, + { "extF80_to_i32_r_max", EXTF80_TO_I32, RMAX, false }, + { "extF80_to_i32_r_near_maxMag", EXTF80_TO_I32, RNMAXM, false }, + { "extF80_to_i64_r_near_even", EXTF80_TO_I64, RNEVEN, false }, + { "extF80_to_i64_r_minMag", EXTF80_TO_I64, RMINM, false }, + { "extF80_to_i64_r_min", EXTF80_TO_I64, RMIN, false }, + { "extF80_to_i64_r_max", EXTF80_TO_I64, RMAX, false }, + { "extF80_to_i64_r_near_maxMag", EXTF80_TO_I64, RNMAXM, false }, + { "extF80_to_ui32_rx_near_even", EXTF80_TO_UI32, RNEVEN, true }, + { "extF80_to_ui32_rx_minMag", EXTF80_TO_UI32, RMINM, true }, + { "extF80_to_ui32_rx_min", EXTF80_TO_UI32, RMIN, true }, + { "extF80_to_ui32_rx_max", EXTF80_TO_UI32, RMAX, true }, + { "extF80_to_ui32_rx_near_maxMag", EXTF80_TO_UI32, RNMAXM, true }, + { "extF80_to_ui64_rx_near_even", EXTF80_TO_UI64, RNEVEN, true }, + { "extF80_to_ui64_rx_minMag", EXTF80_TO_UI64, RMINM, true }, + { "extF80_to_ui64_rx_min", EXTF80_TO_UI64, RMIN, true }, + { "extF80_to_ui64_rx_max", EXTF80_TO_UI64, RMAX, true }, + { "extF80_to_ui64_rx_near_maxMag", EXTF80_TO_UI64, RNMAXM, true }, + { "extF80_to_i32_rx_near_even", EXTF80_TO_I32, RNEVEN, true }, + { "extF80_to_i32_rx_minMag", EXTF80_TO_I32, RMINM, true }, + { "extF80_to_i32_rx_min", EXTF80_TO_I32, RMIN, true }, + { "extF80_to_i32_rx_max", EXTF80_TO_I32, RMAX, true }, + { "extF80_to_i32_rx_near_maxMag", EXTF80_TO_I32, RNMAXM, true }, + { "extF80_to_i64_rx_near_even", EXTF80_TO_I64, RNEVEN, true }, + { "extF80_to_i64_rx_minMag", EXTF80_TO_I64, RMINM, true }, + { "extF80_to_i64_rx_min", EXTF80_TO_I64, RMIN, true }, + { "extF80_to_i64_rx_max", EXTF80_TO_I64, RMAX, true }, + { "extF80_to_i64_rx_near_maxMag", EXTF80_TO_I64, RNMAXM, true }, + { "extF80_to_f32", EXTF80_TO_F32, 0, 0 }, + { "extF80_to_f64", EXTF80_TO_F64, 0, 0 }, +#ifdef FLOAT128 + { "extF80_to_f128", EXTF80_TO_F128, 0, 0 }, +#endif + { "extF80_roundToInt_r_near_even", EXTF80_ROUNDTOINT, RNEVEN, false }, + { "extF80_roundToInt_r_minMag", EXTF80_ROUNDTOINT, RMINM, false }, + { "extF80_roundToInt_r_min", EXTF80_ROUNDTOINT, RMIN, false }, + { "extF80_roundToInt_r_max", EXTF80_ROUNDTOINT, RMAX, false }, + { "extF80_roundToInt_r_near_maxMag", EXTF80_ROUNDTOINT, RNMAXM, false }, + { "extF80_roundToInt_x", EXTF80_ROUNDTOINT, 0, true }, + { "extF80_add", EXTF80_ADD, 0, 0 }, + { "extF80_sub", EXTF80_SUB, 0, 0 }, + { "extF80_mul", EXTF80_MUL, 0, 0 }, + { "extF80_div", EXTF80_DIV, 0, 0 }, + { "extF80_rem", EXTF80_REM, 0, 0 }, + { "extF80_sqrt", EXTF80_SQRT, 0, 0 }, + { "extF80_eq", EXTF80_EQ, 0, 0 }, + { "extF80_le", EXTF80_LE, 0, 0 }, + { "extF80_lt", EXTF80_LT, 0, 0 }, + { "extF80_eq_signaling", EXTF80_EQ_SIGNALING, 0, 0 }, + { "extF80_le_quiet", EXTF80_LE_QUIET, 0, 0 }, + { "extF80_lt_quiet", EXTF80_LT_QUIET, 0, 0 }, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef FLOAT128 + { "f128_to_ui32_r_near_even", F128_TO_UI32, RNEVEN, false }, + { "f128_to_ui32_r_minMag", F128_TO_UI32, RMINM, false }, + { "f128_to_ui32_r_min", F128_TO_UI32, RMIN, false }, + { "f128_to_ui32_r_max", F128_TO_UI32, RMAX, false }, + { "f128_to_ui32_r_near_maxMag", F128_TO_UI32, RNMAXM, false }, + { "f128_to_ui64_r_near_even", F128_TO_UI64, RNEVEN, false }, + { "f128_to_ui64_r_minMag", F128_TO_UI64, RMINM, false }, + { "f128_to_ui64_r_min", F128_TO_UI64, RMIN, false }, + { "f128_to_ui64_r_max", F128_TO_UI64, RMAX, false }, + { "f128_to_ui64_r_near_maxMag", F128_TO_UI64, RNMAXM, false }, + { "f128_to_i32_r_near_even", F128_TO_I32, RNEVEN, false }, + { "f128_to_i32_r_minMag", F128_TO_I32, RMINM, false }, + { "f128_to_i32_r_min", F128_TO_I32, RMIN, false }, + { "f128_to_i32_r_max", F128_TO_I32, RMAX, false }, + { "f128_to_i32_r_near_maxMag", F128_TO_I32, RNMAXM, false }, + { "f128_to_i64_r_near_even", F128_TO_I64, RNEVEN, false }, + { "f128_to_i64_r_minMag", F128_TO_I64, RMINM, false }, + { "f128_to_i64_r_min", F128_TO_I64, RMIN, false }, + { "f128_to_i64_r_max", F128_TO_I64, RMAX, false }, + { "f128_to_i64_r_near_maxMag", F128_TO_I64, RNMAXM, false }, + { "f128_to_ui32_rx_near_even", F128_TO_UI32, RNEVEN, true }, + { "f128_to_ui32_rx_minMag", F128_TO_UI32, RMINM, true }, + { "f128_to_ui32_rx_min", F128_TO_UI32, RMIN, true }, + { "f128_to_ui32_rx_max", F128_TO_UI32, RMAX, true }, + { "f128_to_ui32_rx_near_maxMag", F128_TO_UI32, RNMAXM, true }, + { "f128_to_ui64_rx_near_even", F128_TO_UI64, RNEVEN, true }, + { "f128_to_ui64_rx_minMag", F128_TO_UI64, RMINM, true }, + { "f128_to_ui64_rx_min", F128_TO_UI64, RMIN, true }, + { "f128_to_ui64_rx_max", F128_TO_UI64, RMAX, true }, + { "f128_to_ui64_rx_near_maxMag", F128_TO_UI64, RNMAXM, true }, + { "f128_to_i32_rx_near_even", F128_TO_I32, RNEVEN, true }, + { "f128_to_i32_rx_minMag", F128_TO_I32, RMINM, true }, + { "f128_to_i32_rx_min", F128_TO_I32, RMIN, true }, + { "f128_to_i32_rx_max", F128_TO_I32, RMAX, true }, + { "f128_to_i32_rx_near_maxMag", F128_TO_I32, RNMAXM, true }, + { "f128_to_i64_rx_near_even", F128_TO_I64, RNEVEN, true }, + { "f128_to_i64_rx_minMag", F128_TO_I64, RMINM, true }, + { "f128_to_i64_rx_min", F128_TO_I64, RMIN, true }, + { "f128_to_i64_rx_max", F128_TO_I64, RMAX, true }, + { "f128_to_i64_rx_near_maxMag", F128_TO_I64, RNMAXM, true }, + { "f128_to_f32", F128_TO_F32, 0, 0 }, + { "f128_to_f64", F128_TO_F64, 0, 0 }, +#ifdef EXTFLOAT80 + { "f128_to_extF80", F128_TO_EXTF80, 0, 0 }, +#endif + { "f128_roundToInt_r_near_even", F128_ROUNDTOINT, RNEVEN, false }, + { "f128_roundToInt_r_minMag", F128_ROUNDTOINT, RMINM, false }, + { "f128_roundToInt_r_min", F128_ROUNDTOINT, RMIN, false }, + { "f128_roundToInt_r_max", F128_ROUNDTOINT, RMAX, false }, + { "f128_roundToInt_r_near_maxMag", F128_ROUNDTOINT, RNMAXM, false }, + { "f128_roundToInt_x", F128_ROUNDTOINT, 0, true }, + { "f128_add", F128_ADD, 0, 0 }, + { "f128_sub", F128_SUB, 0, 0 }, + { "f128_mul", F128_MUL, 0, 0 }, + { "f128_mulAdd", F128_MULADD, 0, 0 }, + { "f128_div", F128_DIV, 0, 0 }, + { "f128_rem", F128_REM, 0, 0 }, + { "f128_sqrt", F128_SQRT, 0, 0 }, + { "f128_eq", F128_EQ, 0, 0 }, + { "f128_le", F128_LE, 0, 0 }, + { "f128_lt", F128_LT, 0, 0 }, + { "f128_eq_signaling", F128_EQ_SIGNALING, 0, 0 }, + { "f128_le_quiet", F128_LE_QUIET, 0, 0 }, + { "f128_lt_quiet", F128_LT_QUIET, 0, 0 }, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + { 0, 0, 0, 0 } +}; + diff --git a/source/subj-C/subjfloat.c b/source/subj-C/subjfloat.c new file mode 100644 index 0000000..4d1a0d6 --- /dev/null +++ b/source/subj-C/subjfloat.c @@ -0,0 +1,734 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "subjfloat_config.h" +#include "subjfloat.h" + +#pragma STDC FENV_ACCESS ON + +void subjfloat_setRoundingMode( uint_fast8_t roundingMode ) +{ + + fesetround( + (roundingMode == softfloat_round_near_even) ? FE_TONEAREST + : (roundingMode == softfloat_round_minMag) ? FE_TOWARDZERO + : (roundingMode == softfloat_round_min) ? FE_DOWNWARD + : FE_UPWARD + ); + +} + +void subjfloat_setExtF80RoundingPrecision( uint_fast8_t roundingPrecision ) +{ + +} + +uint_fast8_t subjfloat_clearExceptionFlags( void ) +{ + int subjExceptionFlags; + uint_fast8_t exceptionFlags; + + subjExceptionFlags = + fetestexcept( + FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT + ); + feclearexcept( + FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT ); + exceptionFlags = 0; + if ( subjExceptionFlags & FE_INVALID ) { + exceptionFlags |= softfloat_flag_invalid; + } + if ( subjExceptionFlags & FE_DIVBYZERO ) { + exceptionFlags |= softfloat_flag_infinite; + } + if ( subjExceptionFlags & FE_OVERFLOW ) { + exceptionFlags |= softfloat_flag_overflow; + } + if ( subjExceptionFlags & FE_UNDERFLOW ) { + exceptionFlags |= softfloat_flag_underflow; + } + if ( subjExceptionFlags & FE_INEXACT ) { + exceptionFlags |= softfloat_flag_inexact; + } + return exceptionFlags; + +} + +union f32_f { float32_t f32; float f; }; +union f64_d { float64_t f64; double d; }; + +float32_t subj_ui32_to_f32( uint_fast32_t a ) +{ + union f32_f uZ; + + uZ.f = a; + return uZ.f32; + +} + +float64_t subj_ui32_to_f64( uint_fast32_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +float32_t subj_ui64_to_f32( uint_fast64_t a ) +{ + union f32_f uZ; + + uZ.f = a; + return uZ.f32; + +} + +float64_t subj_ui64_to_f64( uint_fast64_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +float32_t subj_i32_to_f32( int_fast32_t a ) +{ + union f32_f uZ; + + uZ.f = a; + return uZ.f32; + +} + +float64_t subj_i32_to_f64( int_fast32_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +float32_t subj_i64_to_f32( int_fast64_t a ) +{ + union f32_f uZ; + + uZ.f = a; + return uZ.f32; + +} + +float64_t subj_i64_to_f64( int_fast64_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +uint_fast32_t subj_f32_to_ui32_rx_minMag( float32_t a ) +{ + union f32_f uA; + + uA.f32 = a; + return (uint32_t) uA.f; + +} + +uint_fast64_t subj_f32_to_ui64_rx_minMag( float32_t a ) +{ + union f32_f uA; + + uA.f32 = a; + return (uint64_t) uA.f; + +} + +int_fast32_t subj_f32_to_i32_rx_minMag( float32_t a ) +{ + union f32_f uA; + + uA.f32 = a; + return (int32_t) uA.f; + +} + +int_fast64_t subj_f32_to_i64_rx_minMag( float32_t a ) +{ + union f32_f uA; + + uA.f32 = a; + return (int64_t) uA.f; + +} + +float64_t subj_f32_to_f64( float32_t a ) +{ + union f32_f uA; + union f64_d uZ; + + uA.f32 = a; + uZ.d = uA.f; + return uZ.f64; + +} + +float32_t subj_f32_add( float32_t a, float32_t b ) +{ + union f32_f uA, uB, uZ; + + uA.f32 = a; + uB.f32 = b; + uZ.f = uA.f + uB.f; + return uZ.f32; + +} + +float32_t subj_f32_sub( float32_t a, float32_t b ) +{ + union f32_f uA, uB, uZ; + + uA.f32 = a; + uB.f32 = b; + uZ.f = uA.f - uB.f; + return uZ.f32; + +} + +float32_t subj_f32_mul( float32_t a, float32_t b ) +{ + union f32_f uA, uB, uZ; + + uA.f32 = a; + uB.f32 = b; + uZ.f = uA.f * uB.f; + return uZ.f32; + +} + +float32_t subj_f32_div( float32_t a, float32_t b ) +{ + union f32_f uA, uB, uZ; + + uA.f32 = a; + uB.f32 = b; + uZ.f = uA.f / uB.f; + return uZ.f32; + +} + +bool subj_f32_eq( float32_t a, float32_t b ) +{ + union f32_f uA, uB; + + uA.f32 = a; + uB.f32 = b; + return (uA.f == uB.f); + +} + +bool subj_f32_le( float32_t a, float32_t b ) +{ + union f32_f uA, uB; + + uA.f32 = a; + uB.f32 = b; + return (uA.f <= uB.f); + +} + +bool subj_f32_lt( float32_t a, float32_t b ) +{ + union f32_f uA, uB; + + uA.f32 = a; + uB.f32 = b; + return (uA.f < uB.f); + +} + +uint_fast32_t subj_f64_to_ui32_rx_minMag( float64_t a ) +{ + union f64_d uA; + + uA.f64 = a; + return (uint32_t) uA.d; + +} + +uint_fast64_t subj_f64_to_ui64_rx_minMag( float64_t a ) +{ + union f64_d uA; + + uA.f64 = a; + return (uint64_t) uA.d; + +} + +int_fast32_t subj_f64_to_i32_rx_minMag( float64_t a ) +{ + union f64_d uA; + + uA.f64 = a; + return (int32_t) uA.d; + +} + +int_fast64_t subj_f64_to_i64_rx_minMag( float64_t a ) +{ + union f64_d uA; + + uA.f64 = a; + return (int64_t) uA.d; + +} + +float32_t subj_f64_to_f32( float64_t a ) +{ + union f64_d uA; + union f32_f uZ; + + uA.f64 = a; + uZ.f = uA.d; + return uZ.f32; + +} + +float64_t subj_f64_add( float64_t a, float64_t b ) +{ + union f64_d uA, uB, uZ; + + uA.f64 = a; + uB.f64 = b; + uZ.d = uA.d + uB.d; + return uZ.f64; + +} + +float64_t subj_f64_sub( float64_t a, float64_t b ) +{ + union f64_d uA, uB, uZ; + + uA.f64 = a; + uB.f64 = b; + uZ.d = uA.d - uB.d; + return uZ.f64; + +} + +float64_t subj_f64_mul( float64_t a, float64_t b ) +{ + union f64_d uA, uB, uZ; + + uA.f64 = a; + uB.f64 = b; + uZ.d = uA.d * uB.d; + return uZ.f64; + +} + +float64_t subj_f64_div( float64_t a, float64_t b ) +{ + union f64_d uA, uB, uZ; + + uA.f64 = a; + uB.f64 = b; + uZ.d = uA.d / uB.d; + return uZ.f64; + +} + +float64_t subj_f64_sqrt( float64_t a ) +{ + union f64_d uA, uZ; + + uA.f64 = a; + uZ.d = sqrt( uA.d ); + return uZ.f64; + +} + +bool subj_f64_eq( float64_t a, float64_t b ) +{ + union f64_d uA, uB; + + uA.f64 = a; + uB.f64 = b; + return (uA.d == uB.d); + +} + +bool subj_f64_le( float64_t a, float64_t b ) +{ + union f64_d uA, uB; + + uA.f64 = a; + uB.f64 = b; + return (uA.d <= uB.d); + +} + +bool subj_f64_lt( float64_t a, float64_t b ) +{ + union f64_d uA, uB; + + uA.f64 = a; + uB.f64 = b; + return (uA.d < uB.d); + +} + +#if defined EXTFLOAT80 && defined LONG_DOUBLE_IS_EXTFLOAT80 + +void subj_ui32_to_extF80M( uint_fast32_t a, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_ui64_to_extF80M( uint_fast64_t a, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_i32_to_extF80M( int_fast32_t a, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_i64_to_extF80M( int_fast64_t a, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_f32_to_extF80M( float32_t a, extFloat80_t *zPtr ) +{ + union f32_f uA; + + uA.f32 = a; + *((long double *) zPtr) = uA.f; + +} + +void subj_f64_to_extF80M( float64_t a, extFloat80_t *zPtr ) +{ + union f64_d uA; + + uA.f64 = a; + *((long double *) zPtr) = uA.d; + +} + +uint_fast32_t subj_extF80M_to_ui32_rx_minMag( const extFloat80_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +uint_fast64_t subj_extF80M_to_ui64_rx_minMag( const extFloat80_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +int_fast32_t subj_extF80M_to_i32_rx_minMag( const extFloat80_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +int_fast64_t subj_extF80M_to_i64_rx_minMag( const extFloat80_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +float32_t subj_extF80M_to_f32( const extFloat80_t *aPtr ) +{ + union f32_f uZ; + + uZ.f = *((const long double *) aPtr); + return uZ.f32; + +} + +float64_t subj_extF80M_to_f64( const extFloat80_t *aPtr ) +{ + union f64_d uZ; + + uZ.d = *((const long double *) aPtr); + return uZ.f64; + +} + +void + subj_extF80M_add( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) + *((const long double *) bPtr); + +} + +void + subj_extF80M_sub( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) - *((const long double *) bPtr); + +} + +void + subj_extF80M_mul( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) * *((const long double *) bPtr); + +} + +void + subj_extF80M_div( + const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) / *((const long double *) bPtr); + +} + +bool subj_extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + + return (*((const long double *) aPtr) == *((const long double *) bPtr)); + +} + +bool subj_extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + + return (*((const long double *) aPtr) <= *((const long double *) bPtr)); + +} + +bool subj_extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + + return (*((const long double *) aPtr) < *((const long double *) bPtr)); + +} + +#endif + +#if defined FLOAT128 && defined LONG_DOUBLE_IS_FLOAT128 + +void subj_ui32_to_f128M( uint_fast32_t a, float128_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_ui64_to_f128M( uint_fast64_t a, float128_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_i32_to_f128M( int_fast32_t a, float128_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_i64_to_f128M( int_fast64_t a, float128_t *zPtr ) +{ + + *((long double *) zPtr) = a; + +} + +void subj_f32_to_f128M( float32_t a, float128_t *zPtr ) +{ + union f32_f uA; + + uA.f32 = a; + *((long double *) zPtr) = uA.f; + +} + +void subj_f64_to_f128M( float64_t a, float128_t *zPtr ) +{ + union f64_d uA; + + uA.f64 = a; + *((long double *) zPtr) = uA.d; + +} + +uint_fast32_t subj_f128M_to_ui32_rx_minMag( const float128_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +uint_fast64_t subj_f128M_to_ui64_rx_minMag( const float128_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +int_fast32_t subj_f128M_to_i32_rx_minMag( const float128_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +int_fast64_t subj_f128M_to_i64_rx_minMag( const float128_t *aPtr ) +{ + + return *((const long double *) aPtr); + +} + +float32_t subj_f128M_to_f32( const float128_t *aPtr ) +{ + union f32_f uZ; + + uZ.f = *((const long double *) aPtr); + return uZ.f32; + +} + +float64_t subj_f128M_to_f64( const float128_t *aPtr ) +{ + union f64_d uZ; + + uZ.d = *((const long double *) aPtr); + return uZ.f64; + +} + +void + subj_f128M_add( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) + *((const long double *) bPtr); + +} + +void + subj_f128M_sub( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) - *((const long double *) bPtr); + +} + +void + subj_f128M_mul( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) * *((const long double *) bPtr); + +} + +void + subj_f128M_div( + const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) +{ + + *((long double *) zPtr) = + *((const long double *) aPtr) / *((const long double *) bPtr); + +} + +bool subj_f128M_eq( const float128_t *aPtr, const float128_t *bPtr ) +{ + + return (*((const long double *) aPtr) == *((const long double *) bPtr)); + +} + +bool subj_f128M_le( const float128_t *aPtr, const float128_t *bPtr ) +{ + + return (*((const long double *) aPtr) <= *((const long double *) bPtr)); + +} + +bool subj_f128M_lt( const float128_t *aPtr, const float128_t *bPtr ) +{ + + return (*((const long double *) aPtr) < *((const long double *) bPtr)); + +} + +#endif + diff --git a/source/subj-C/subjfloat_config.h b/source/subj-C/subjfloat_config.h new file mode 100644 index 0000000..74ef090 --- /dev/null +++ b/source/subj-C/subjfloat_config.h @@ -0,0 +1,94 @@ + +/*---------------------------------------------------------------------------- +| The following macros are defined to indicate all the subject functions that +| exist. +*----------------------------------------------------------------------------*/ + +#define SUBJ_UI32_TO_F32 +#define SUBJ_UI32_TO_F64 +#define SUBJ_UI64_TO_F32 +#define SUBJ_UI64_TO_F64 +#define SUBJ_I32_TO_F32 +#define SUBJ_I32_TO_F64 +#define SUBJ_I64_TO_F32 +#define SUBJ_I64_TO_F64 + +#define SUBJ_F32_TO_UI32_RX_MINMAG +#define SUBJ_F32_TO_UI64_RX_MINMAG +#define SUBJ_F32_TO_I32_RX_MINMAG +#define SUBJ_F32_TO_I64_RX_MINMAG +#define SUBJ_F32_TO_F64 +#define SUBJ_F32_ADD +#define SUBJ_F32_SUB +#define SUBJ_F32_MUL +#define SUBJ_F32_DIV +#define SUBJ_F32_EQ +#define SUBJ_F32_LE +#define SUBJ_F32_LT + +#define SUBJ_F64_TO_UI32_RX_MINMAG +#define SUBJ_F64_TO_UI64_RX_MINMAG +#define SUBJ_F64_TO_I32_RX_MINMAG +#define SUBJ_F64_TO_I64_RX_MINMAG +#define SUBJ_F64_TO_F32 +#define SUBJ_F64_ADD +#define SUBJ_F64_SUB +#define SUBJ_F64_MUL +#define SUBJ_F64_DIV +#define SUBJ_F64_SQRT +#define SUBJ_F64_EQ +#define SUBJ_F64_LE +#define SUBJ_F64_LT + +#if defined EXTFLOAT80 && defined LONG_DOUBLE_IS_EXTFLOAT80 + +#define SUBJ_UI32_TO_EXTF80 +#define SUBJ_UI64_TO_EXTF80 +#define SUBJ_I32_TO_EXTF80 +#define SUBJ_I64_TO_EXTF80 + +#define SUBJ_F32_TO_EXTF80 +#define SUBJ_F64_TO_EXTF80 + +#define SUBJ_EXTF80_TO_UI32_RX_MINMAG +#define SUBJ_EXTF80_TO_UI64_RX_MINMAG +#define SUBJ_EXTF80_TO_I32_RX_MINMAG +#define SUBJ_EXTF80_TO_I64_RX_MINMAG +#define SUBJ_EXTF80_TO_F32 +#define SUBJ_EXTF80_TO_F64 +#define SUBJ_EXTF80_ADD +#define SUBJ_EXTF80_SUB +#define SUBJ_EXTF80_MUL +#define SUBJ_EXTF80_DIV +#define SUBJ_EXTF80_EQ +#define SUBJ_EXTF80_LE +#define SUBJ_EXTF80_LT + +#endif + +#if defined FLOAT128 && defined LONG_DOUBLE_IS_FLOAT128 + +#define SUBJ_UI32_TO_F128 +#define SUBJ_UI64_TO_F128 +#define SUBJ_I32_TO_F128 +#define SUBJ_I64_TO_F128 + +#define SUBJ_F32_TO_F128 +#define SUBJ_F64_TO_F128 + +#define SUBJ_F128_TO_UI32_RX_MINMAG +#define SUBJ_F128_TO_UI64_RX_MINMAG +#define SUBJ_F128_TO_I32_RX_MINMAG +#define SUBJ_F128_TO_I64_RX_MINMAG +#define SUBJ_F128_TO_F32 +#define SUBJ_F128_TO_F64 +#define SUBJ_F128_ADD +#define SUBJ_F128_SUB +#define SUBJ_F128_MUL +#define SUBJ_F128_DIV +#define SUBJ_F128_EQ +#define SUBJ_F128_LE +#define SUBJ_F128_LT + +#endif + diff --git a/source/subjfloat.h b/source/subjfloat.h new file mode 100644 index 0000000..4423944 --- /dev/null +++ b/source/subjfloat.h @@ -0,0 +1,392 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "softfloat.h" + +extern void (*const subjfloat_functions[])(); + +void subjfloat_setRoundingMode( uint_fast8_t ); +void subjfloat_setExtF80RoundingPrecision( uint_fast8_t ); +uint_fast8_t subjfloat_clearExceptionFlags( void ); + +/*---------------------------------------------------------------------------- +| Subject function declarations. (Many of these functions may not exist.) +| WARNING: +| This file should not normally be modified. Use "subjfloat_config.h" to +| specify which of these functions actually exist. +*----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +float32_t subj_ui32_to_f32( uint_fast32_t ); +float64_t subj_ui32_to_f64( uint_fast32_t ); +#ifdef EXTFLOAT80 +void subj_ui32_to_extF80M( uint_fast32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void subj_ui32_to_f128M( uint_fast32_t, float128_t * ); +#endif +float32_t subj_ui64_to_f32( uint_fast64_t ); +float64_t subj_ui64_to_f64( uint_fast64_t ); +#ifdef EXTFLOAT80 +void subj_ui64_to_extF80M( uint_fast64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void subj_ui64_to_f128M( uint_fast64_t, float128_t * ); +#endif +float32_t subj_i32_to_f32( int_fast32_t ); +float64_t subj_i32_to_f64( int_fast32_t ); +#ifdef EXTFLOAT80 +void subj_i32_to_extF80M( int_fast32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void subj_i32_to_f128M( int_fast32_t, float128_t * ); +#endif +float32_t subj_i64_to_f32( int_fast64_t ); +float64_t subj_i64_to_f64( int_fast64_t ); +#ifdef EXTFLOAT80 +void subj_i64_to_extF80M( int_fast64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void subj_i64_to_f128M( int_fast64_t, float128_t * ); +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +uint_fast32_t subj_f32_to_ui32_r_near_even( float32_t ); +uint_fast32_t subj_f32_to_ui32_r_minMag( float32_t ); +uint_fast32_t subj_f32_to_ui32_r_min( float32_t ); +uint_fast32_t subj_f32_to_ui32_r_max( float32_t ); +uint_fast32_t subj_f32_to_ui32_r_near_maxMag( float32_t ); +uint_fast64_t subj_f32_to_ui64_r_near_even( float32_t ); +uint_fast64_t subj_f32_to_ui64_r_minMag( float32_t ); +uint_fast64_t subj_f32_to_ui64_r_min( float32_t ); +uint_fast64_t subj_f32_to_ui64_r_max( float32_t ); +uint_fast64_t subj_f32_to_ui64_r_near_maxMag( float32_t ); +int_fast32_t subj_f32_to_i32_r_near_even( float32_t ); +int_fast32_t subj_f32_to_i32_r_minMag( float32_t ); +int_fast32_t subj_f32_to_i32_r_min( float32_t ); +int_fast32_t subj_f32_to_i32_r_max( float32_t ); +int_fast32_t subj_f32_to_i32_r_near_maxMag( float32_t ); +int_fast64_t subj_f32_to_i64_r_near_even( float32_t ); +int_fast64_t subj_f32_to_i64_r_minMag( float32_t ); +int_fast64_t subj_f32_to_i64_r_min( float32_t ); +int_fast64_t subj_f32_to_i64_r_max( float32_t ); +int_fast64_t subj_f32_to_i64_r_near_maxMag( float32_t ); + +uint_fast32_t subj_f32_to_ui32_rx_near_even( float32_t ); +uint_fast32_t subj_f32_to_ui32_rx_minMag( float32_t ); +uint_fast32_t subj_f32_to_ui32_rx_min( float32_t ); +uint_fast32_t subj_f32_to_ui32_rx_max( float32_t ); +uint_fast32_t subj_f32_to_ui32_rx_near_maxMag( float32_t ); +uint_fast64_t subj_f32_to_ui64_rx_near_even( float32_t ); +uint_fast64_t subj_f32_to_ui64_rx_minMag( float32_t ); +uint_fast64_t subj_f32_to_ui64_rx_min( float32_t ); +uint_fast64_t subj_f32_to_ui64_rx_max( float32_t ); +uint_fast64_t subj_f32_to_ui64_rx_near_maxMag( float32_t ); +int_fast32_t subj_f32_to_i32_rx_near_even( float32_t ); +int_fast32_t subj_f32_to_i32_rx_minMag( float32_t ); +int_fast32_t subj_f32_to_i32_rx_min( float32_t ); +int_fast32_t subj_f32_to_i32_rx_max( float32_t ); +int_fast32_t subj_f32_to_i32_rx_near_maxMag( float32_t ); +int_fast64_t subj_f32_to_i64_rx_near_even( float32_t ); +int_fast64_t subj_f32_to_i64_rx_minMag( float32_t ); +int_fast64_t subj_f32_to_i64_rx_min( float32_t ); +int_fast64_t subj_f32_to_i64_rx_max( float32_t ); +int_fast64_t subj_f32_to_i64_rx_near_maxMag( float32_t ); + +float64_t subj_f32_to_f64( float32_t ); +#ifdef EXTFLOAT80 +void subj_f32_to_extF80M( float32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void subj_f32_to_f128M( float32_t, float128_t * ); +#endif + +float32_t subj_f32_roundToInt_r_near_even( float32_t ); +float32_t subj_f32_roundToInt_r_minMag( float32_t ); +float32_t subj_f32_roundToInt_r_min( float32_t ); +float32_t subj_f32_roundToInt_r_max( float32_t ); +float32_t subj_f32_roundToInt_r_near_maxMag( float32_t ); +float32_t subj_f32_roundToInt_x( float32_t ); +float32_t subj_f32_add( float32_t, float32_t ); +float32_t subj_f32_sub( float32_t, float32_t ); +float32_t subj_f32_mul( float32_t, float32_t ); +float32_t subj_f32_mulAdd( float32_t, float32_t, float32_t ); +float32_t subj_f32_div( float32_t, float32_t ); +float32_t subj_f32_rem( float32_t, float32_t ); +float32_t subj_f32_sqrt( float32_t ); +bool subj_f32_eq( float32_t, float32_t ); +bool subj_f32_le( float32_t, float32_t ); +bool subj_f32_lt( float32_t, float32_t ); +bool subj_f32_eq_signaling( float32_t, float32_t ); +bool subj_f32_le_quiet( float32_t, float32_t ); +bool subj_f32_lt_quiet( float32_t, float32_t ); + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +uint_fast32_t subj_f64_to_ui32_r_near_even( float64_t ); +uint_fast32_t subj_f64_to_ui32_r_minMag( float64_t ); +uint_fast32_t subj_f64_to_ui32_r_min( float64_t ); +uint_fast32_t subj_f64_to_ui32_r_max( float64_t ); +uint_fast32_t subj_f64_to_ui32_r_near_maxMag( float64_t ); +uint_fast64_t subj_f64_to_ui64_r_near_even( float64_t ); +uint_fast64_t subj_f64_to_ui64_r_minMag( float64_t ); +uint_fast64_t subj_f64_to_ui64_r_min( float64_t ); +uint_fast64_t subj_f64_to_ui64_r_max( float64_t ); +uint_fast64_t subj_f64_to_ui64_r_near_maxMag( float64_t ); +int_fast32_t subj_f64_to_i32_r_near_even( float64_t ); +int_fast32_t subj_f64_to_i32_r_minMag( float64_t ); +int_fast32_t subj_f64_to_i32_r_min( float64_t ); +int_fast32_t subj_f64_to_i32_r_max( float64_t ); +int_fast32_t subj_f64_to_i32_r_near_maxMag( float64_t ); +int_fast64_t subj_f64_to_i64_r_near_even( float64_t ); +int_fast64_t subj_f64_to_i64_r_minMag( float64_t ); +int_fast64_t subj_f64_to_i64_r_min( float64_t ); +int_fast64_t subj_f64_to_i64_r_max( float64_t ); +int_fast64_t subj_f64_to_i64_r_near_maxMag( float64_t ); + +uint_fast32_t subj_f64_to_ui32_rx_near_even( float64_t ); +uint_fast32_t subj_f64_to_ui32_rx_minMag( float64_t ); +uint_fast32_t subj_f64_to_ui32_rx_min( float64_t ); +uint_fast32_t subj_f64_to_ui32_rx_max( float64_t ); +uint_fast32_t subj_f64_to_ui32_rx_near_maxMag( float64_t ); +uint_fast64_t subj_f64_to_ui64_rx_near_even( float64_t ); +uint_fast64_t subj_f64_to_ui64_rx_minMag( float64_t ); +uint_fast64_t subj_f64_to_ui64_rx_min( float64_t ); +uint_fast64_t subj_f64_to_ui64_rx_max( float64_t ); +uint_fast64_t subj_f64_to_ui64_rx_near_maxMag( float64_t ); +int_fast32_t subj_f64_to_i32_rx_near_even( float64_t ); +int_fast32_t subj_f64_to_i32_rx_minMag( float64_t ); +int_fast32_t subj_f64_to_i32_rx_min( float64_t ); +int_fast32_t subj_f64_to_i32_rx_max( float64_t ); +int_fast32_t subj_f64_to_i32_rx_near_maxMag( float64_t ); +int_fast64_t subj_f64_to_i64_rx_near_even( float64_t ); +int_fast64_t subj_f64_to_i64_rx_minMag( float64_t ); +int_fast64_t subj_f64_to_i64_rx_min( float64_t ); +int_fast64_t subj_f64_to_i64_rx_max( float64_t ); +int_fast64_t subj_f64_to_i64_rx_near_maxMag( float64_t ); + +float32_t subj_f64_to_f32( float64_t ); +#ifdef EXTFLOAT80 +void subj_f64_to_extF80M( float64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void subj_f64_to_f128M( float64_t, float128_t * ); +#endif + +float64_t subj_f64_roundToInt_r_near_even( float64_t ); +float64_t subj_f64_roundToInt_r_minMag( float64_t ); +float64_t subj_f64_roundToInt_r_min( float64_t ); +float64_t subj_f64_roundToInt_r_max( float64_t ); +float64_t subj_f64_roundToInt_r_near_maxMag( float64_t ); +float64_t subj_f64_roundToInt_x( float64_t ); +float64_t subj_f64_add( float64_t, float64_t ); +float64_t subj_f64_sub( float64_t, float64_t ); +float64_t subj_f64_mul( float64_t, float64_t ); +float64_t subj_f64_mulAdd( float64_t, float64_t, float64_t ); +float64_t subj_f64_div( float64_t, float64_t ); +float64_t subj_f64_rem( float64_t, float64_t ); +float64_t subj_f64_sqrt( float64_t ); +bool subj_f64_eq( float64_t, float64_t ); +bool subj_f64_le( float64_t, float64_t ); +bool subj_f64_lt( float64_t, float64_t ); +bool subj_f64_eq_signaling( float64_t, float64_t ); +bool subj_f64_le_quiet( float64_t, float64_t ); +bool subj_f64_lt_quiet( float64_t, float64_t ); + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +#ifdef EXTFLOAT80 + +uint_fast32_t subj_extF80M_to_ui32_r_near_even( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_r_minMag( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_r_min( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_r_max( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_r_near_maxMag( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_r_near_even( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_r_minMag( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_r_min( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_r_max( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_r_near_maxMag( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_r_near_even( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_r_minMag( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_r_min( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_r_max( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_r_near_maxMag( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_r_near_even( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_r_minMag( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_r_min( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_r_max( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_r_near_maxMag( const extFloat80_t * ); + +uint_fast32_t subj_extF80M_to_ui32_rx_near_even( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_rx_minMag( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_rx_min( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_rx_max( const extFloat80_t * ); +uint_fast32_t subj_extF80M_to_ui32_rx_near_maxMag( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_rx_near_even( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_rx_minMag( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_rx_min( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_rx_max( const extFloat80_t * ); +uint_fast64_t subj_extF80M_to_ui64_rx_near_maxMag( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_rx_near_even( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_rx_minMag( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_rx_min( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_rx_max( const extFloat80_t * ); +int_fast32_t subj_extF80M_to_i32_rx_near_maxMag( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_rx_near_even( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_rx_minMag( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_rx_min( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_rx_max( const extFloat80_t * ); +int_fast64_t subj_extF80M_to_i64_rx_near_maxMag( const extFloat80_t * ); + +float32_t subj_extF80M_to_f32( const extFloat80_t * ); +float64_t subj_extF80M_to_f64( const extFloat80_t * ); +#ifdef EXTFLOAT80 +void subj_extF80M_to_f128M( const extFloat80_t *, float128_t * ); +#endif + +void + subj_extF80M_roundToInt_r_near_even( const extFloat80_t *, extFloat80_t * ); +void subj_extF80M_roundToInt_r_minMag( const extFloat80_t *, extFloat80_t * ); +void subj_extF80M_roundToInt_r_min( const extFloat80_t *, extFloat80_t * ); +void subj_extF80M_roundToInt_r_max( const extFloat80_t *, extFloat80_t * ); +void + subj_extF80M_roundToInt_r_near_maxMag( const extFloat80_t *, extFloat80_t * ); +void subj_extF80M_roundToInt_x( const extFloat80_t *, extFloat80_t * ); +void + subj_extF80M_add( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + subj_extF80M_sub( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + subj_extF80M_mul( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + subj_extF80M_div( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void + subj_extF80M_rem( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +void subj_extF80M_sqrt( const extFloat80_t *, extFloat80_t * ); +bool subj_extF80M_eq( const extFloat80_t *, const extFloat80_t * ); +bool subj_extF80M_le( const extFloat80_t *, const extFloat80_t * ); +bool subj_extF80M_lt( const extFloat80_t *, const extFloat80_t * ); +bool subj_extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * ); +bool subj_extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * ); +bool subj_extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * ); + +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +#ifdef FLOAT128 + +uint_fast32_t subj_f128M_to_ui32_r_near_even( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_r_minMag( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_r_min( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_r_max( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_r_near_maxMag( extFloat80_t * ); +uint_fast64_t subj_f128M_to_ui64_r_near_even( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_r_minMag( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_r_min( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_r_max( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_r_near_maxMag( extFloat80_t * ); +int_fast32_t subj_f128M_to_i32_r_near_even( const float128_t * ); +int_fast32_t subj_f128M_to_i32_r_minMag( const float128_t * ); +int_fast32_t subj_f128M_to_i32_r_min( const float128_t * ); +int_fast32_t subj_f128M_to_i32_r_max( const float128_t * ); +int_fast32_t subj_f128M_to_i32_r_near_maxMag( extFloat80_t * ); +int_fast64_t subj_f128M_to_i64_r_near_even( const float128_t * ); +int_fast64_t subj_f128M_to_i64_r_minMag( const float128_t * ); +int_fast64_t subj_f128M_to_i64_r_min( const float128_t * ); +int_fast64_t subj_f128M_to_i64_r_max( const float128_t * ); +int_fast64_t subj_f128M_to_i64_r_near_maxMag( extFloat80_t * ); + +uint_fast32_t subj_f128M_to_ui32_rx_near_even( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_rx_minMag( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_rx_min( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_rx_max( const float128_t * ); +uint_fast32_t subj_f128M_to_ui32_rx_near_maxMag( extFloat80_t * ); +uint_fast64_t subj_f128M_to_ui64_rx_near_even( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_rx_minMag( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_rx_min( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_rx_max( const float128_t * ); +uint_fast64_t subj_f128M_to_ui64_rx_near_maxMag( extFloat80_t * ); +int_fast32_t subj_f128M_to_i32_rx_near_even( const float128_t * ); +int_fast32_t subj_f128M_to_i32_rx_minMag( const float128_t * ); +int_fast32_t subj_f128M_to_i32_rx_min( const float128_t * ); +int_fast32_t subj_f128M_to_i32_rx_max( const float128_t * ); +int_fast32_t subj_f128M_to_i32_rx_near_maxMag( extFloat80_t * ); +int_fast64_t subj_f128M_to_i64_rx_near_even( const float128_t * ); +int_fast64_t subj_f128M_to_i64_rx_minMag( const float128_t * ); +int_fast64_t subj_f128M_to_i64_rx_min( const float128_t * ); +int_fast64_t subj_f128M_to_i64_rx_max( const float128_t * ); +int_fast64_t subj_f128M_to_i64_rx_near_maxMag( extFloat80_t * ); + +float32_t subj_f128M_to_f32( const float128_t * ); +float64_t subj_f128M_to_f64( const float128_t * ); +#ifdef FLOAT128 +void subj_f128M_to_extF80M( const float128_t *, extFloat80_t * ); +#endif + +void subj_f128M_roundToInt_r_near_even( const float128_t, float128_t * ); +void subj_f128M_roundToInt_r_minMag( const float128_t, float128_t * ); +void subj_f128M_roundToInt_r_min( const float128_t, float128_t * ); +void subj_f128M_roundToInt_r_max( const float128_t, float128_t * ); +void subj_f128M_roundToInt_r_near_maxMag( const float128_t, float128_t * ); +void subj_f128M_roundToInt_x( const float128_t, float128_t * ); +void subj_f128M_add( const float128_t *, const float128_t *, float128_t * ); +void subj_f128M_sub( const float128_t *, const float128_t *, float128_t * ); +void subj_f128M_mul( const float128_t *, const float128_t *, float128_t * ); +void + subj_f128M_mulAdd( + const float128_t *, const float128_t *, const float128_t *, float128_t * + ); +void subj_f128M_div( const float128_t *, const float128_t *, float128_t * ); +void subj_f128M_rem( const float128_t *, const float128_t *, float128_t * ); +void subj_f128M_sqrt( const float128_t *, float128_t * ); +bool subj_f128M_eq( const float128_t *, const float128_t * ); +bool subj_f128M_le( const float128_t *, const float128_t * ); +bool subj_f128M_lt( const float128_t *, const float128_t * ); +bool subj_f128M_eq_signaling( const float128_t *, const float128_t * ); +bool subj_f128M_le_quiet( const float128_t *, const float128_t * ); +bool subj_f128M_lt_quiet( const float128_t *, const float128_t * ); + +#endif + diff --git a/source/subjfloat_functions.c b/source/subjfloat_functions.c new file mode 100644 index 0000000..392ffef --- /dev/null +++ b/source/subjfloat_functions.c @@ -0,0 +1,1410 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "subjfloat_config.h" +#include "subjfloat.h" +#include "functions.h" + +typedef void genericFuncType(); + +/*---------------------------------------------------------------------------- +| WARNING: +| This file should not normally be modified. See "subjfloat_config.h" +| instead. +| The order of these array entries must match the order in the array +| `standardFunctionInfos'. Be careful about making changes. +*----------------------------------------------------------------------------*/ + +genericFuncType *const subjfloat_functions[] = { + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef SUBJ_UI32_TO_F32 + (genericFuncType *) subj_ui32_to_f32, +#else + 0, +#endif +#ifdef SUBJ_UI32_TO_F64 + (genericFuncType *) subj_ui32_to_f64, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_UI32_TO_EXTF80 + (genericFuncType *) subj_ui32_to_extF80M, +#else + 0, +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_UI32_TO_F128 + (genericFuncType *) subj_ui32_to_f128M, +#else + 0, +#endif +#endif +#ifdef SUBJ_UI64_TO_F32 + (genericFuncType *) subj_ui64_to_f32, +#else + 0, +#endif +#ifdef SUBJ_UI64_TO_F64 + (genericFuncType *) subj_ui64_to_f64, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_UI64_TO_EXTF80 + (genericFuncType *) subj_ui64_to_extF80M, +#else + 0, +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_UI64_TO_F128 + (genericFuncType *) subj_ui64_to_f128M, +#else + 0, +#endif +#endif +#ifdef SUBJ_I32_TO_F32 + (genericFuncType *) subj_i32_to_f32, +#else + 0, +#endif +#ifdef SUBJ_I32_TO_F64 + (genericFuncType *) subj_i32_to_f64, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_I32_TO_EXTF80 + (genericFuncType *) subj_i32_to_extF80M, +#else + 0, +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_I32_TO_F128 + (genericFuncType *) subj_i32_to_f128M, +#else + 0, +#endif +#endif +#ifdef SUBJ_I64_TO_F32 + (genericFuncType *) subj_i64_to_f32, +#else + 0, +#endif +#ifdef SUBJ_I64_TO_F64 + (genericFuncType *) subj_i64_to_f64, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_I64_TO_EXTF80 + (genericFuncType *) subj_i64_to_extF80M, +#else + 0, +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_I64_TO_F128 + (genericFuncType *) subj_i64_to_f128M, +#else + 0, +#endif +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef SUBJ_F32_TO_UI32_R_NEAR_EVEN + (genericFuncType *) subj_f32_to_ui32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_R_MINMAG + (genericFuncType *) subj_f32_to_ui32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_R_MIN + (genericFuncType *) subj_f32_to_ui32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_R_MAX + (genericFuncType *) subj_f32_to_ui32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_R_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_ui32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_R_NEAR_EVEN + (genericFuncType *) subj_f32_to_ui64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_R_MINMAG + (genericFuncType *) subj_f32_to_ui64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_R_MIN + (genericFuncType *) subj_f32_to_ui64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_R_MAX + (genericFuncType *) subj_f32_to_ui64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_R_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_ui64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_R_NEAR_EVEN + (genericFuncType *) subj_f32_to_i32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_R_MINMAG + (genericFuncType *) subj_f32_to_i32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_R_MIN + (genericFuncType *) subj_f32_to_i32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_R_MAX + (genericFuncType *) subj_f32_to_i32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_R_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_i32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_R_NEAR_EVEN + (genericFuncType *) subj_f32_to_i64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_R_MINMAG + (genericFuncType *) subj_f32_to_i64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_R_MIN + (genericFuncType *) subj_f32_to_i64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_R_MAX + (genericFuncType *) subj_f32_to_i64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_R_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_i64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_RX_NEAR_EVEN + (genericFuncType *) subj_f32_to_ui32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_RX_MINMAG + (genericFuncType *) subj_f32_to_ui32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_RX_MIN + (genericFuncType *) subj_f32_to_ui32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_RX_MAX + (genericFuncType *) subj_f32_to_ui32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_ui32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_RX_NEAR_EVEN + (genericFuncType *) subj_f32_to_ui64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_RX_MINMAG + (genericFuncType *) subj_f32_to_ui64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_RX_MIN + (genericFuncType *) subj_f32_to_ui64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_RX_MAX + (genericFuncType *) subj_f32_to_ui64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_UI64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_ui64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_RX_NEAR_EVEN + (genericFuncType *) subj_f32_to_i32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_RX_MINMAG + (genericFuncType *) subj_f32_to_i32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_RX_MIN + (genericFuncType *) subj_f32_to_i32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_RX_MAX + (genericFuncType *) subj_f32_to_i32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_i32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_RX_NEAR_EVEN + (genericFuncType *) subj_f32_to_i64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_RX_MINMAG + (genericFuncType *) subj_f32_to_i64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_RX_MIN + (genericFuncType *) subj_f32_to_i64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_RX_MAX + (genericFuncType *) subj_f32_to_i64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_I64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f32_to_i64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_TO_F64 + (genericFuncType *) subj_f32_to_f64, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F32_TO_EXTF80 + (genericFuncType *) subj_f32_to_extF80M, +#else + 0, +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_F32_TO_F128 + (genericFuncType *) subj_f32_to_f128M, +#else + 0, +#endif +#endif +#ifdef SUBJ_F32_ROUNDTOINT_R_NEAR_EVEN + (genericFuncType *) subj_f32_roundToInt_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F32_ROUNDTOINT_R_MINMAG + (genericFuncType *) subj_f32_roundToInt_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F32_ROUNDTOINT_R_MIN + (genericFuncType *) subj_f32_roundToInt_r_min, +#else + 0, +#endif +#ifdef SUBJ_F32_ROUNDTOINT_R_MAX + (genericFuncType *) subj_f32_roundToInt_r_max, +#else + 0, +#endif +#ifdef SUBJ_F32_ROUNDTOINT_R_NEAR_MAXMAG + (genericFuncType *) subj_f32_roundToInt_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F32_ROUNDTOINT_X + (genericFuncType *) subj_f32_roundToInt_x, +#else + 0, +#endif +#ifdef SUBJ_F32_ADD + (genericFuncType *) subj_f32_add, +#else + 0, +#endif +#ifdef SUBJ_F32_SUB + (genericFuncType *) subj_f32_sub, +#else + 0, +#endif +#ifdef SUBJ_F32_MUL + (genericFuncType *) subj_f32_mul, +#else + 0, +#endif +#ifdef SUBJ_F32_MULADD + (genericFuncType *) subj_f32_mulAdd, +#else + 0, +#endif +#ifdef SUBJ_F32_DIV + (genericFuncType *) subj_f32_div, +#else + 0, +#endif +#ifdef SUBJ_F32_REM + (genericFuncType *) subj_f32_rem, +#else + 0, +#endif +#ifdef SUBJ_F32_SQRT + (genericFuncType *) subj_f32_sqrt, +#else + 0, +#endif +#ifdef SUBJ_F32_EQ + (genericFuncType *) subj_f32_eq, +#else + 0, +#endif +#ifdef SUBJ_F32_LE + (genericFuncType *) subj_f32_le, +#else + 0, +#endif +#ifdef SUBJ_F32_LT + (genericFuncType *) subj_f32_lt, +#else + 0, +#endif +#ifdef SUBJ_F32_EQ_SIGNALING + (genericFuncType *) subj_f32_eq_signaling, +#else + 0, +#endif +#ifdef SUBJ_F32_LE_QUIET + (genericFuncType *) subj_f32_le_quiet, +#else + 0, +#endif +#ifdef SUBJ_F32_LT_QUIET + (genericFuncType *) subj_f32_lt_quiet, +#else + 0, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef SUBJ_F64_TO_UI32_R_NEAR_EVEN + (genericFuncType *) subj_f64_to_ui32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_R_MINMAG + (genericFuncType *) subj_f64_to_ui32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_R_MIN + (genericFuncType *) subj_f64_to_ui32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_R_MAX + (genericFuncType *) subj_f64_to_ui32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_R_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_ui32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_R_NEAR_EVEN + (genericFuncType *) subj_f64_to_ui64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_R_MINMAG + (genericFuncType *) subj_f64_to_ui64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_R_MIN + (genericFuncType *) subj_f64_to_ui64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_R_MAX + (genericFuncType *) subj_f64_to_ui64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_R_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_ui64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_R_NEAR_EVEN + (genericFuncType *) subj_f64_to_i32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_R_MINMAG + (genericFuncType *) subj_f64_to_i32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_R_MIN + (genericFuncType *) subj_f64_to_i32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_R_MAX + (genericFuncType *) subj_f64_to_i32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_R_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_i32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_R_NEAR_EVEN + (genericFuncType *) subj_f64_to_i64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_R_MINMAG + (genericFuncType *) subj_f64_to_i64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_R_MIN + (genericFuncType *) subj_f64_to_i64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_R_MAX + (genericFuncType *) subj_f64_to_i64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_R_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_i64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_RX_NEAR_EVEN + (genericFuncType *) subj_f64_to_ui32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_RX_MINMAG + (genericFuncType *) subj_f64_to_ui32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_RX_MIN + (genericFuncType *) subj_f64_to_ui32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_RX_MAX + (genericFuncType *) subj_f64_to_ui32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_ui32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_RX_NEAR_EVEN + (genericFuncType *) subj_f64_to_ui64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_RX_MINMAG + (genericFuncType *) subj_f64_to_ui64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_RX_MIN + (genericFuncType *) subj_f64_to_ui64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_RX_MAX + (genericFuncType *) subj_f64_to_ui64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_UI64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_ui64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_RX_NEAR_EVEN + (genericFuncType *) subj_f64_to_i32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_RX_MINMAG + (genericFuncType *) subj_f64_to_i32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_RX_MIN + (genericFuncType *) subj_f64_to_i32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_RX_MAX + (genericFuncType *) subj_f64_to_i32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_i32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_RX_NEAR_EVEN + (genericFuncType *) subj_f64_to_i64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_RX_MINMAG + (genericFuncType *) subj_f64_to_i64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_RX_MIN + (genericFuncType *) subj_f64_to_i64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_RX_MAX + (genericFuncType *) subj_f64_to_i64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_I64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f64_to_i64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_TO_F32 + (genericFuncType *) subj_f64_to_f32, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F64_TO_EXTF80 + (genericFuncType *) subj_f64_to_extF80M, +#else + 0, +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_F64_TO_F128 + (genericFuncType *) subj_f64_to_f128M, +#else + 0, +#endif +#endif +#ifdef SUBJ_F64_ROUNDTOINT_R_NEAR_EVEN + (genericFuncType *) subj_f64_roundToInt_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F64_ROUNDTOINT_R_MINMAG + (genericFuncType *) subj_f64_roundToInt_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F64_ROUNDTOINT_R_MIN + (genericFuncType *) subj_f64_roundToInt_r_min, +#else + 0, +#endif +#ifdef SUBJ_F64_ROUNDTOINT_R_MAX + (genericFuncType *) subj_f64_roundToInt_r_max, +#else + 0, +#endif +#ifdef SUBJ_F64_ROUNDTOINT_R_NEAR_MAXMAG + (genericFuncType *) subj_f64_roundToInt_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F64_ROUNDTOINT_X + (genericFuncType *) subj_f64_roundToInt_x, +#else + 0, +#endif +#ifdef SUBJ_F64_ADD + (genericFuncType *) subj_f64_add, +#else + 0, +#endif +#ifdef SUBJ_F64_SUB + (genericFuncType *) subj_f64_sub, +#else + 0, +#endif +#ifdef SUBJ_F64_MUL + (genericFuncType *) subj_f64_mul, +#else + 0, +#endif +#ifdef SUBJ_F64_MULADD + (genericFuncType *) subj_f64_mulAdd, +#else + 0, +#endif +#ifdef SUBJ_F64_DIV + (genericFuncType *) subj_f64_div, +#else + 0, +#endif +#ifdef SUBJ_F64_REM + (genericFuncType *) subj_f64_rem, +#else + 0, +#endif +#ifdef SUBJ_F64_SQRT + (genericFuncType *) subj_f64_sqrt, +#else + 0, +#endif +#ifdef SUBJ_F64_EQ + (genericFuncType *) subj_f64_eq, +#else + 0, +#endif +#ifdef SUBJ_F64_LE + (genericFuncType *) subj_f64_le, +#else + 0, +#endif +#ifdef SUBJ_F64_LT + (genericFuncType *) subj_f64_lt, +#else + 0, +#endif +#ifdef SUBJ_F64_EQ_SIGNALING + (genericFuncType *) subj_f64_eq_signaling, +#else + 0, +#endif +#ifdef SUBJ_F64_LE_QUIET + (genericFuncType *) subj_f64_le_quiet, +#else + 0, +#endif +#ifdef SUBJ_F64_LT_QUIET + (genericFuncType *) subj_f64_lt_quiet, +#else + 0, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef EXTFLOAT80 +#ifdef SUBJ_EXTF80_TO_UI32_R_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_ui32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_R_MINMAG + (genericFuncType *) subj_extF80M_to_ui32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_R_MIN + (genericFuncType *) subj_extF80M_to_ui32_r_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_R_MAX + (genericFuncType *) subj_extF80M_to_ui32_r_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_R_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_ui32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_R_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_ui64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_R_MINMAG + (genericFuncType *) subj_extF80M_to_ui64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_R_MIN + (genericFuncType *) subj_extF80M_to_ui64_r_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_R_MAX + (genericFuncType *) subj_extF80M_to_ui64_r_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_R_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_ui64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_R_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_i32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_R_MINMAG + (genericFuncType *) subj_extF80M_to_i32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_R_MIN + (genericFuncType *) subj_extF80M_to_i32_r_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_R_MAX + (genericFuncType *) subj_extF80M_to_i32_r_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_R_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_i32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_R_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_i64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_R_MINMAG + (genericFuncType *) subj_extF80M_to_i64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_R_MIN + (genericFuncType *) subj_extF80M_to_i64_r_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_R_MAX + (genericFuncType *) subj_extF80M_to_i64_r_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_R_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_i64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_RX_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_ui32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_RX_MINMAG + (genericFuncType *) subj_extF80M_to_ui32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_RX_MIN + (genericFuncType *) subj_extF80M_to_ui32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_RX_MAX + (genericFuncType *) subj_extF80M_to_ui32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI32_RX_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_ui32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_RX_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_ui64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_RX_MINMAG + (genericFuncType *) subj_extF80M_to_ui64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_RX_MIN + (genericFuncType *) subj_extF80M_to_ui64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_RX_MAX + (genericFuncType *) subj_extF80M_to_ui64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_UI64_RX_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_ui64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_RX_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_i32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_RX_MINMAG + (genericFuncType *) subj_extF80M_to_i32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_RX_MIN + (genericFuncType *) subj_extF80M_to_i32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_RX_MAX + (genericFuncType *) subj_extF80M_to_i32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I32_RX_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_i32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_RX_NEAR_EVEN + (genericFuncType *) subj_extF80M_to_i64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_RX_MINMAG + (genericFuncType *) subj_extF80M_to_i64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_RX_MIN + (genericFuncType *) subj_extF80M_to_i64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_RX_MAX + (genericFuncType *) subj_extF80M_to_i64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_I64_RX_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_to_i64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_F32 + (genericFuncType *) subj_extF80M_to_f32, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_TO_F64 + (genericFuncType *) subj_extF80M_to_f64, +#else + 0, +#endif +#ifdef FLOAT128 +#ifdef SUBJ_EXTF80_TO_F128 + (genericFuncType *) subj_extF80M_to_f128M, +#else + 0, +#endif +#endif +#ifdef SUBJ_EXTF80_ROUNDTOINT_R_NEAR_EVEN + (genericFuncType *) subj_extF80M_roundToInt_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_ROUNDTOINT_R_MINMAG + (genericFuncType *) subj_extF80M_roundToInt_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_ROUNDTOINT_R_MIN + (genericFuncType *) subj_extF80M_roundToInt_r_min, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_ROUNDTOINT_R_MAX + (genericFuncType *) subj_extF80M_roundToInt_r_max, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_ROUNDTOINT_R_NEAR_MAXMAG + (genericFuncType *) subj_extF80M_roundToInt_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_ROUNDTOINT_X + (genericFuncType *) subj_extF80M_roundToInt_x, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_ADD + (genericFuncType *) subj_extF80M_add, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_SUB + (genericFuncType *) subj_extF80M_sub, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_MUL + (genericFuncType *) subj_extF80M_mul, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_DIV + (genericFuncType *) subj_extF80M_div, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_REM + (genericFuncType *) subj_extF80M_rem, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_SQRT + (genericFuncType *) subj_extF80M_sqrt, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_EQ + (genericFuncType *) subj_extF80M_eq, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_LE + (genericFuncType *) subj_extF80M_le, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_LT + (genericFuncType *) subj_extF80M_lt, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_EQ_SIGNALING + (genericFuncType *) subj_extF80M_eq_signaling, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_LE_QUIET + (genericFuncType *) subj_extF80M_le_quiet, +#else + 0, +#endif +#ifdef SUBJ_EXTF80_LT_QUIET + (genericFuncType *) subj_extF80M_lt_quiet, +#else + 0, +#endif +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef FLOAT128 +#ifdef SUBJ_F128_TO_UI32_R_NEAR_EVEN + (genericFuncType *) subj_f128M_to_ui32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_R_MINMAG + (genericFuncType *) subj_f128M_to_ui32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_R_MIN + (genericFuncType *) subj_f128M_to_ui32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_R_MAX + (genericFuncType *) subj_f128M_to_ui32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_R_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_ui32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_R_NEAR_EVEN + (genericFuncType *) subj_f128M_to_ui64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_R_MINMAG + (genericFuncType *) subj_f128M_to_ui64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_R_MIN + (genericFuncType *) subj_f128M_to_ui64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_R_MAX + (genericFuncType *) subj_f128M_to_ui64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_R_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_ui64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_R_NEAR_EVEN + (genericFuncType *) subj_f128M_to_i32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_R_MINMAG + (genericFuncType *) subj_f128M_to_i32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_R_MIN + (genericFuncType *) subj_f128M_to_i32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_R_MAX + (genericFuncType *) subj_f128M_to_i32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_R_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_i32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_R_NEAR_EVEN + (genericFuncType *) subj_f128M_to_i64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_R_MINMAG + (genericFuncType *) subj_f128M_to_i64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_R_MIN + (genericFuncType *) subj_f128M_to_i64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_R_MAX + (genericFuncType *) subj_f128M_to_i64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_R_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_i64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_RX_NEAR_EVEN + (genericFuncType *) subj_f128M_to_ui32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_RX_MINMAG + (genericFuncType *) subj_f128M_to_ui32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_RX_MIN + (genericFuncType *) subj_f128M_to_ui32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_RX_MAX + (genericFuncType *) subj_f128M_to_ui32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_ui32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_RX_NEAR_EVEN + (genericFuncType *) subj_f128M_to_ui64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_RX_MINMAG + (genericFuncType *) subj_f128M_to_ui64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_RX_MIN + (genericFuncType *) subj_f128M_to_ui64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_RX_MAX + (genericFuncType *) subj_f128M_to_ui64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_UI64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_ui64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_RX_NEAR_EVEN + (genericFuncType *) subj_f128M_to_i32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_RX_MINMAG + (genericFuncType *) subj_f128M_to_i32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_RX_MIN + (genericFuncType *) subj_f128M_to_i32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_RX_MAX + (genericFuncType *) subj_f128M_to_i32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_i32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_RX_NEAR_EVEN + (genericFuncType *) subj_f128M_to_i64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_RX_MINMAG + (genericFuncType *) subj_f128M_to_i64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_RX_MIN + (genericFuncType *) subj_f128M_to_i64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_RX_MAX + (genericFuncType *) subj_f128M_to_i64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_I64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f128M_to_i64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_F32 + (genericFuncType *) subj_f128M_to_f32, +#else + 0, +#endif +#ifdef SUBJ_F128_TO_F64 + (genericFuncType *) subj_f128M_to_f64, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F128_TO_EXTF80 + (genericFuncType *) subj_f128M_to_extF80M, +#else + 0, +#endif +#endif +#ifdef SUBJ_F128_ROUNDTOINT_R_NEAR_EVEN + (genericFuncType *) subj_f128M_roundToInt_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F128_ROUNDTOINT_R_MINMAG + (genericFuncType *) subj_f128M_roundToInt_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F128_ROUNDTOINT_R_MIN + (genericFuncType *) subj_f128M_roundToInt_r_min, +#else + 0, +#endif +#ifdef SUBJ_F128_ROUNDTOINT_R_MAX + (genericFuncType *) subj_f128M_roundToInt_r_max, +#else + 0, +#endif +#ifdef SUBJ_F128_ROUNDTOINT_R_NEAR_MAXMAG + (genericFuncType *) subj_f128M_roundToInt_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F128_ROUNDTOINT_X + (genericFuncType *) subj_f128M_roundToInt_x, +#else + 0, +#endif +#ifdef SUBJ_F128_ADD + (genericFuncType *) subj_f128M_add, +#else + 0, +#endif +#ifdef SUBJ_F128_SUB + (genericFuncType *) subj_f128M_sub, +#else + 0, +#endif +#ifdef SUBJ_F128_MUL + (genericFuncType *) subj_f128M_mul, +#else + 0, +#endif +#ifdef SUBJ_F128_MULADD + (genericFuncType *) subj_f128M_mulAdd, +#else + 0, +#endif +#ifdef SUBJ_F128_DIV + (genericFuncType *) subj_f128M_div, +#else + 0, +#endif +#ifdef SUBJ_F128_REM + (genericFuncType *) subj_f128M_rem, +#else + 0, +#endif +#ifdef SUBJ_F128_SQRT + (genericFuncType *) subj_f128M_sqrt, +#else + 0, +#endif +#ifdef SUBJ_F128_EQ + (genericFuncType *) subj_f128M_eq, +#else + 0, +#endif +#ifdef SUBJ_F128_LE + (genericFuncType *) subj_f128M_le, +#else + 0, +#endif +#ifdef SUBJ_F128_LT + (genericFuncType *) subj_f128M_lt, +#else + 0, +#endif +#ifdef SUBJ_F128_EQ_SIGNALING + (genericFuncType *) subj_f128M_eq_signaling, +#else + 0, +#endif +#ifdef SUBJ_F128_LE_QUIET + (genericFuncType *) subj_f128M_le_quiet, +#else + 0, +#endif +#ifdef SUBJ_F128_LT_QUIET + (genericFuncType *) subj_f128M_lt_quiet, +#else + 0, +#endif +#endif +}; + diff --git a/source/testLoops.h b/source/testLoops.h new file mode 100644 index 0000000..bed5df3 --- /dev/null +++ b/source/testLoops.h @@ -0,0 +1,466 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include +#include "softfloat.h" + +extern bool testLoops_forever; + +extern uint_fast8_t *testLoops_trueFlagsPtr; +extern uint_fast8_t (*testLoops_subjFlagsFunction)( void ); + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +void test_a_ui32_z_f32( float32_t ( uint32_t ), float32_t ( uint32_t ) ); +void test_a_ui32_z_f64( float64_t ( uint32_t ), float64_t ( uint32_t ) ); +#ifdef EXTFLOAT80 +void + test_a_ui32_z_extF80( + void ( uint32_t, extFloat80_t * ), void ( uint32_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void + test_a_ui32_z_f128( + void ( uint32_t, float128_t * ), void ( uint32_t, float128_t * ) + ); +#endif +void test_a_ui64_z_f32( float32_t ( uint64_t ), float32_t ( uint64_t ) ); +void test_a_ui64_z_f64( float64_t ( uint64_t ), float64_t ( uint64_t ) ); +#ifdef EXTFLOAT80 +void + test_a_ui64_z_extF80( + void ( uint64_t, extFloat80_t * ), void ( uint64_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void + test_a_ui64_z_f128( + void ( uint64_t, float128_t * ), void ( uint64_t, float128_t * ) ); +#endif +void test_a_i32_z_f32( float32_t ( int32_t ), float32_t ( int32_t ) ); +void test_a_i32_z_f64( float64_t ( int32_t ), float64_t ( int32_t ) ); +#ifdef EXTFLOAT80 +void + test_a_i32_z_extF80( + void ( int32_t, extFloat80_t * ), void ( int32_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void + test_a_i32_z_f128( + void ( int32_t, float128_t * ), void ( int32_t, float128_t * ) ); +#endif +void test_a_i64_z_f32( float32_t ( int64_t ), float32_t ( int64_t ) ); +void test_a_i64_z_f64( float64_t ( int64_t ), float64_t ( int64_t ) ); +#ifdef EXTFLOAT80 +void + test_a_i64_z_extF80( + void ( int64_t, extFloat80_t * ), void ( int64_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void + test_a_i64_z_f128( + void ( int64_t, float128_t * ), void ( int64_t, float128_t * ) ); +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +void + test_a_f32_z_ui32_rx( + uint_fast32_t ( float32_t, uint_fast8_t, bool ), + uint_fast32_t ( float32_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f32_z_ui64_rx( + uint_fast64_t ( float32_t, uint_fast8_t, bool ), + uint_fast64_t ( float32_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f32_z_i32_rx( + int_fast32_t ( float32_t, uint_fast8_t, bool ), + int_fast32_t ( float32_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f32_z_i64_rx( + int_fast64_t ( float32_t, uint_fast8_t, bool ), + int_fast64_t ( float32_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f32_z_ui32_x( + uint_fast32_t ( float32_t, bool ), uint_fast32_t ( float32_t, bool ), bool + ); +void + test_a_f32_z_ui64_x( + uint_fast64_t ( float32_t, bool ), uint_fast64_t ( float32_t, bool ), bool + ); +void + test_a_f32_z_i32_x( + int_fast32_t ( float32_t, bool ), int_fast32_t ( float32_t, bool ), bool + ); +void + test_a_f32_z_i64_x( + int_fast64_t ( float32_t, bool ), int_fast64_t ( float32_t, bool ), bool + ); +void test_a_f32_z_f64( float64_t ( float32_t ), float64_t ( float32_t ) ); +#ifdef EXTFLOAT80 +void + test_a_f32_z_extF80( + void ( float32_t, extFloat80_t * ), void ( float32_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void + test_a_f32_z_f128( + void ( float32_t, float128_t * ), void ( float32_t, float128_t * ) ); +#endif +void test_az_f32( float32_t ( float32_t ), float32_t ( float32_t ) ); +void + test_az_f32_rx( + float32_t ( float32_t, uint_fast8_t, bool ), + float32_t ( float32_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_abz_f32( + float32_t ( float32_t, float32_t ), float32_t ( float32_t, float32_t ) ); +void + test_abcz_f32( + float32_t ( float32_t, float32_t, float32_t ), + float32_t ( float32_t, float32_t, float32_t ) + ); +void + test_ab_f32_z_bool( + bool ( float32_t, float32_t ), bool ( float32_t, float32_t ) ); + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +void + test_a_f64_z_ui32_rx( + uint_fast32_t ( float64_t, uint_fast8_t, bool ), + uint_fast32_t ( float64_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f64_z_ui64_rx( + uint_fast64_t ( float64_t, uint_fast8_t, bool ), + uint_fast64_t ( float64_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f64_z_i32_rx( + int_fast32_t ( float64_t, uint_fast8_t, bool ), + int_fast32_t ( float64_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f64_z_i64_rx( + int_fast64_t ( float64_t, uint_fast8_t, bool ), + int_fast64_t ( float64_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f64_z_ui32_x( + uint_fast32_t ( float64_t, bool ), uint_fast32_t ( float64_t, bool ), bool + ); +void + test_a_f64_z_ui64_x( + uint_fast64_t ( float64_t, bool ), uint_fast64_t ( float64_t, bool ), bool + ); +void + test_a_f64_z_i32_x( + int_fast32_t ( float64_t, bool ), int_fast32_t ( float64_t, bool ), bool + ); +void + test_a_f64_z_i64_x( + int_fast64_t ( float64_t, bool ), int_fast64_t ( float64_t, bool ), bool + ); +void test_a_f64_z_f32( float32_t ( float64_t ), float32_t ( float64_t ) ); +#ifdef EXTFLOAT80 +void + test_a_f64_z_extF80( + void ( float64_t, extFloat80_t * ), void ( float64_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void + test_a_f64_z_f128( + void ( float64_t, float128_t * ), void ( float64_t, float128_t * ) ); +#endif +void test_az_f64( float64_t ( float64_t ), float64_t ( float64_t ) ); +void + test_az_f64_rx( + float64_t ( float64_t, uint_fast8_t, bool ), + float64_t ( float64_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_abz_f64( + float64_t ( float64_t, float64_t ), float64_t ( float64_t, float64_t ) ); +void + test_abcz_f64( + float64_t ( float64_t, float64_t, float64_t ), + float64_t ( float64_t, float64_t, float64_t ) + ); +void + test_ab_f64_z_bool( + bool ( float64_t, float64_t ), bool ( float64_t, float64_t ) ); + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +#ifdef EXTFLOAT80 +void + test_a_extF80_z_ui32_rx( + uint_fast32_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast32_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_extF80_z_ui64_rx( + uint_fast64_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast64_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_extF80_z_i32_rx( + int_fast32_t ( const extFloat80_t *, uint_fast8_t, bool ), + int_fast32_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_extF80_z_i64_rx( + int_fast64_t ( const extFloat80_t *, uint_fast8_t, bool ), + int_fast64_t ( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_extF80_z_ui32_x( + uint_fast32_t ( const extFloat80_t *, bool ), + uint_fast32_t ( const extFloat80_t *, bool ), + bool + ); +void + test_a_extF80_z_ui64_x( + uint_fast64_t ( const extFloat80_t *, bool ), + uint_fast64_t ( const extFloat80_t *, bool ), + bool + ); +void + test_a_extF80_z_i32_x( + int_fast32_t ( const extFloat80_t *, bool ), + int_fast32_t ( const extFloat80_t *, bool ), + bool + ); +void + test_a_extF80_z_i64_x( + int_fast64_t ( const extFloat80_t *, bool ), + int_fast64_t ( const extFloat80_t *, bool ), + bool + ); +void + test_a_extF80_z_f32( + float32_t ( const extFloat80_t * ), float32_t ( const extFloat80_t * ) ); +void + test_a_extF80_z_f64( + float64_t ( const extFloat80_t * ), float64_t ( const extFloat80_t * ) ); +#ifdef FLOAT128 +void + test_a_extF80_z_f128( + void ( const extFloat80_t *, float128_t * ), + void ( const extFloat80_t *, float128_t * ) + ); +#endif +void + test_az_extF80( + void ( const extFloat80_t *, extFloat80_t * ), + void ( const extFloat80_t *, extFloat80_t * ) + ); +void + test_az_extF80_rx( + void ( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), + void ( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), + uint_fast8_t, + bool + ); +void + test_abz_extF80( + void ( const extFloat80_t *, const extFloat80_t *, extFloat80_t * ), + void ( const extFloat80_t *, const extFloat80_t *, extFloat80_t * ) + ); +void + test_abcz_extF80( + void + ( + const extFloat80_t, + const extFloat80_t, + const extFloat80_t, + extFloat80_t * + ), + void + ( + const extFloat80_t, + const extFloat80_t, + const extFloat80_t, + extFloat80_t * + ) + ); +void + test_ab_extF80_z_bool( + bool ( const extFloat80_t *, const extFloat80_t * ), + bool ( const extFloat80_t *, const extFloat80_t * ) + ); +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ +#ifdef FLOAT128 +void + test_a_f128_z_ui32_rx( + uint_fast32_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast32_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f128_z_ui64_rx( + uint_fast64_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast64_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f128_z_i32_rx( + int_fast32_t ( const float128_t *, uint_fast8_t, bool ), + int_fast32_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f128_z_i64_rx( + int_fast64_t ( const float128_t *, uint_fast8_t, bool ), + int_fast64_t ( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f128_z_ui32_x( + uint_fast32_t ( const float128_t *, bool ), + uint_fast32_t ( const float128_t *, bool ), + bool + ); +void + test_a_f128_z_ui64_x( + uint_fast64_t ( const float128_t *, bool ), + uint_fast64_t ( const float128_t *, bool ), + bool + ); +void + test_a_f128_z_i32_x( + int_fast32_t ( const float128_t *, bool ), + int_fast32_t ( const float128_t *, bool ), + bool + ); +void + test_a_f128_z_i64_x( + int_fast64_t ( const float128_t *, bool ), + int_fast64_t ( const float128_t *, bool ), + bool + ); +void + test_a_f128_z_f32( + float32_t ( const float128_t * ), float32_t ( const float128_t * ) ); +void + test_a_f128_z_f64( + float64_t ( const float128_t * ), float64_t ( const float128_t * ) ); +#ifdef EXTFLOAT80 +void + test_a_f128_z_extF80( + void ( const float128_t *, extFloat80_t * ), + void ( const float128_t *, extFloat80_t * ) + ); +#endif +void + test_az_f128( + void ( const float128_t *, float128_t * ), + void ( const float128_t *, float128_t * ) + ); +void + test_az_f128_rx( + void ( const float128_t *, uint_fast8_t, bool, float128_t * ), + void ( const float128_t *, uint_fast8_t, bool, float128_t * ), + uint_fast8_t, + bool + ); +void + test_abz_f128( + void ( const float128_t *, const float128_t *, float128_t * ), + void ( const float128_t *, const float128_t *, float128_t * ) + ); +void + test_abcz_f128( + void + ( const float128_t *, + const float128_t *, + const float128_t *, + float128_t * + ), + void + ( const float128_t *, + const float128_t *, + const float128_t *, + float128_t * + ) + ); +void + test_ab_f128_z_bool( + bool ( const float128_t *, const float128_t * ), + bool ( const float128_t *, const float128_t * ) + ); +#endif + diff --git a/source/testLoops_common.c b/source/testLoops_common.c new file mode 100644 index 0000000..f8d4f27 --- /dev/null +++ b/source/testLoops_common.c @@ -0,0 +1,44 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "testLoops.h" + +bool testLoops_forever = false; + +uint_fast8_t *testLoops_trueFlagsPtr; +uint_fast8_t (*testLoops_subjFlagsFunction)( void ); + diff --git a/source/test_a_extF80_z_f128.c b/source/test_a_extF80_z_f128.c new file mode 100644 index 0000000..b71648b --- /dev/null +++ b/source/test_a_extF80_z_f128.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#if defined EXTFLOAT80 && defined FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_f128( + void trueFunction( const extFloat80_t *, float128_t * ), + void subjFunction( const extFloat80_t *, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_extF80_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_f32.c b/source/test_a_extF80_z_f32.c new file mode 100644 index 0000000..b10c48b --- /dev/null +++ b/source/test_a_extF80_z_f32.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_f32( + float32_t trueFunction( const extFloat80_t * ), + float32_t subjFunction( const extFloat80_t * ) + ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_f64.c b/source/test_a_extF80_z_f64.c new file mode 100644 index 0000000..3ad72da --- /dev/null +++ b/source/test_a_extF80_z_f64.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_f64( + float64_t trueFunction( const extFloat80_t * ), + float64_t subjFunction( const extFloat80_t * ) + ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_i32_rx.c b/source/test_a_extF80_z_i32_rx.c new file mode 100644 index 0000000..8d665bf --- /dev/null +++ b/source/test_a_extF80_z_i32_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_i32_rx( + int_fast32_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + int_fast32_t subjFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_i32_x.c b/source/test_a_extF80_z_i32_x.c new file mode 100644 index 0000000..0b98a01 --- /dev/null +++ b/source/test_a_extF80_z_i32_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_i32_x( + int_fast32_t trueFunction( const extFloat80_t *, bool ), + int_fast32_t subjFunction( const extFloat80_t *, bool ), + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_i64_rx.c b/source/test_a_extF80_z_i64_rx.c new file mode 100644 index 0000000..296fe4a --- /dev/null +++ b/source/test_a_extF80_z_i64_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_i64_rx( + int_fast64_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + int_fast64_t subjFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, "\n\t" ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_i64_x.c b/source/test_a_extF80_z_i64_x.c new file mode 100644 index 0000000..e9e9dd8 --- /dev/null +++ b/source/test_a_extF80_z_i64_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_i64_x( + int_fast64_t trueFunction( const extFloat80_t *, bool ), + int_fast64_t subjFunction( const extFloat80_t *, bool ), + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, "\n\t" ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_ui32_rx.c b/source/test_a_extF80_z_ui32_rx.c new file mode 100644 index 0000000..033caee --- /dev/null +++ b/source/test_a_extF80_z_ui32_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_ui32_rx( + uint_fast32_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast32_t subjFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_ui32_x.c b/source/test_a_extF80_z_ui32_x.c new file mode 100644 index 0000000..e2dd4ff --- /dev/null +++ b/source/test_a_extF80_z_ui32_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_ui32_x( + uint_fast32_t trueFunction( const extFloat80_t *, bool ), + uint_fast32_t subjFunction( const extFloat80_t *, bool ), + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_ui64_rx.c b/source/test_a_extF80_z_ui64_rx.c new file mode 100644 index 0000000..83dff24 --- /dev/null +++ b/source/test_a_extF80_z_ui64_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_ui64_rx( + uint_fast64_t trueFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast64_t subjFunction( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_ui64_x.c b/source/test_a_extF80_z_ui64_x.c new file mode 100644 index 0000000..8e1560a --- /dev/null +++ b/source/test_a_extF80_z_ui64_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_ui64_x( + uint_fast64_t trueFunction( const extFloat80_t *, bool ), + uint_fast64_t subjFunction( const extFloat80_t *, bool ), + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, "\n\t" ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_extF80.c b/source/test_a_f128_z_extF80.c new file mode 100644 index 0000000..7cec13f --- /dev/null +++ b/source/test_a_f128_z_extF80.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#if defined EXTFLOAT80 && defined FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_extF80( + void trueFunction( const float128_t *, extFloat80_t * ), + void subjFunction( const float128_t *, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_f128_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_f32.c b/source/test_a_f128_z_f32.c new file mode 100644 index 0000000..22fa4ef --- /dev/null +++ b/source/test_a_f128_z_f32.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_f32( + float32_t trueFunction( const float128_t * ), + float32_t subjFunction( const float128_t * ) + ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_f64.c b/source/test_a_f128_z_f64.c new file mode 100644 index 0000000..0ad5241 --- /dev/null +++ b/source/test_a_f128_z_f64.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_f64( + float64_t trueFunction( const float128_t * ), + float64_t subjFunction( const float128_t * ) + ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, "\n\t" ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_i32_rx.c b/source/test_a_f128_z_i32_rx.c new file mode 100644 index 0000000..8db9a4e --- /dev/null +++ b/source/test_a_f128_z_i32_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_i32_rx( + int_fast32_t trueFunction( const float128_t *, uint_fast8_t, bool ), + int_fast32_t subjFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_i32_x.c b/source/test_a_f128_z_i32_x.c new file mode 100644 index 0000000..3396e62 --- /dev/null +++ b/source/test_a_f128_z_i32_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_i32_x( + int_fast32_t trueFunction( const float128_t *, bool ), + int_fast32_t subjFunction( const float128_t *, bool ), + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_i64_rx.c b/source/test_a_f128_z_i64_rx.c new file mode 100644 index 0000000..7221618 --- /dev/null +++ b/source/test_a_f128_z_i64_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_i64_rx( + int_fast64_t trueFunction( const float128_t *, uint_fast8_t, bool ), + int_fast64_t subjFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, "\n\t" ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_i64_x.c b/source/test_a_f128_z_i64_x.c new file mode 100644 index 0000000..0a4e815 --- /dev/null +++ b/source/test_a_f128_z_i64_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_i64_x( + int_fast64_t trueFunction( const float128_t *, bool ), + int_fast64_t subjFunction( const float128_t *, bool ), + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, "\n\t" ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_ui32_rx.c b/source/test_a_f128_z_ui32_rx.c new file mode 100644 index 0000000..4b5e87e --- /dev/null +++ b/source/test_a_f128_z_ui32_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_ui32_rx( + uint_fast32_t trueFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast32_t subjFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_ui32_x.c b/source/test_a_f128_z_ui32_x.c new file mode 100644 index 0000000..633e3ad --- /dev/null +++ b/source/test_a_f128_z_ui32_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_ui32_x( + uint_fast32_t trueFunction( const float128_t *, bool ), + uint_fast32_t subjFunction( const float128_t *, bool ), + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_ui64_rx.c b/source/test_a_f128_z_ui64_rx.c new file mode 100644 index 0000000..096341c --- /dev/null +++ b/source/test_a_f128_z_ui64_rx.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_ui64_rx( + uint_fast64_t trueFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast64_t subjFunction( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, "\n\t" ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_ui64_x.c b/source/test_a_f128_z_ui64_x.c new file mode 100644 index 0000000..5cf0e0f --- /dev/null +++ b/source/test_a_f128_z_ui64_x.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_ui64_x( + uint_fast64_t trueFunction( const float128_t *, bool ), + uint_fast64_t subjFunction( const float128_t *, bool ), + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, "\n\t" ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f32_z_extF80.c b/source/test_a_f32_z_extF80.c new file mode 100644 index 0000000..8effe53 --- /dev/null +++ b/source/test_a_f32_z_extF80.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_extF80( + void trueFunction( float32_t, extFloat80_t * ), + void subjFunction( float32_t, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_f32_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_f32_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f32_z_f128.c b/source/test_a_f32_z_f128.c new file mode 100644 index 0000000..889c31d --- /dev/null +++ b/source/test_a_f32_z_f128.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_f128( + void trueFunction( float32_t, float128_t * ), + void subjFunction( float32_t, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_f32_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_f32_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f32_z_f64.c b/source/test_a_f32_z_f64.c new file mode 100644 index 0000000..c4e63d8 --- /dev/null +++ b/source/test_a_f32_z_f64.c @@ -0,0 +1,97 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_f64( + float64_t trueFunction( float32_t ), float64_t subjFunction( float32_t ) ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_i32_rx.c b/source/test_a_f32_z_i32_rx.c new file mode 100644 index 0000000..a61c31d --- /dev/null +++ b/source/test_a_f32_z_i32_rx.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_i32_rx( + int_fast32_t trueFunction( float32_t, uint_fast8_t, bool ), + int_fast32_t subjFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_i32_x.c b/source/test_a_f32_z_i32_x.c new file mode 100644 index 0000000..d2b5097 --- /dev/null +++ b/source/test_a_f32_z_i32_x.c @@ -0,0 +1,100 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_i32_x( + int_fast32_t trueFunction( float32_t, bool ), + int_fast32_t subjFunction( float32_t, bool ), + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_i64_rx.c b/source/test_a_f32_z_i64_rx.c new file mode 100644 index 0000000..56b4704 --- /dev/null +++ b/source/test_a_f32_z_i64_rx.c @@ -0,0 +1,102 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_i64_rx( + int_fast64_t trueFunction( float32_t, uint_fast8_t, bool ), + int_fast64_t subjFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_i64_x.c b/source/test_a_f32_z_i64_x.c new file mode 100644 index 0000000..fddf48f --- /dev/null +++ b/source/test_a_f32_z_i64_x.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_i64_x( + int_fast64_t trueFunction( float32_t, bool ), + int_fast64_t subjFunction( float32_t, bool ), + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_ui32_rx.c b/source/test_a_f32_z_ui32_rx.c new file mode 100644 index 0000000..9b478f2 --- /dev/null +++ b/source/test_a_f32_z_ui32_rx.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_ui32_rx( + uint_fast32_t trueFunction( float32_t, uint_fast8_t, bool ), + uint_fast32_t subjFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_ui32_x.c b/source/test_a_f32_z_ui32_x.c new file mode 100644 index 0000000..53283ed --- /dev/null +++ b/source/test_a_f32_z_ui32_x.c @@ -0,0 +1,100 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_ui32_x( + uint_fast32_t trueFunction( float32_t, bool ), + uint_fast32_t subjFunction( float32_t, bool ), + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_ui64_rx.c b/source/test_a_f32_z_ui64_rx.c new file mode 100644 index 0000000..c0f88ae --- /dev/null +++ b/source/test_a_f32_z_ui64_rx.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_ui64_rx( + uint_fast64_t trueFunction( float32_t, uint_fast8_t, bool ), + uint_fast64_t subjFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_ui64_x.c b/source/test_a_f32_z_ui64_x.c new file mode 100644 index 0000000..0237244 --- /dev/null +++ b/source/test_a_f32_z_ui64_x.c @@ -0,0 +1,100 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_ui64_x( + uint_fast64_t trueFunction( float32_t, bool ), + uint_fast64_t subjFunction( float32_t, bool ), + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_extF80.c b/source/test_a_f64_z_extF80.c new file mode 100644 index 0000000..7607b2c --- /dev/null +++ b/source/test_a_f64_z_extF80.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_extF80( + void trueFunction( float64_t, extFloat80_t * ), + void subjFunction( float64_t, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_f64_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_f64_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f64_z_f128.c b/source/test_a_f64_z_f128.c new file mode 100644 index 0000000..ce125a4 --- /dev/null +++ b/source/test_a_f64_z_f128.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_f128( + void trueFunction( float64_t, float128_t * ), + void subjFunction( float64_t, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_f64_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_f64_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f64_z_f32.c b/source/test_a_f64_z_f32.c new file mode 100644 index 0000000..42bb130 --- /dev/null +++ b/source/test_a_f64_z_f32.c @@ -0,0 +1,97 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_f32( + float32_t trueFunction( float64_t ), float32_t subjFunction( float64_t ) ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_i32_rx.c b/source/test_a_f64_z_i32_rx.c new file mode 100644 index 0000000..8a9cacf --- /dev/null +++ b/source/test_a_f64_z_i32_rx.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_i32_rx( + int_fast32_t trueFunction( float64_t, uint_fast8_t, bool ), + int_fast32_t subjFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_i32_x.c b/source/test_a_f64_z_i32_x.c new file mode 100644 index 0000000..a22e26f --- /dev/null +++ b/source/test_a_f64_z_i32_x.c @@ -0,0 +1,100 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_i32_x( + int_fast32_t trueFunction( float64_t, bool ), + int_fast32_t subjFunction( float64_t, bool ), + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_i64_rx.c b/source/test_a_f64_z_i64_rx.c new file mode 100644 index 0000000..9b67053 --- /dev/null +++ b/source/test_a_f64_z_i64_rx.c @@ -0,0 +1,102 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_i64_rx( + int_fast64_t trueFunction( float64_t, uint_fast8_t, bool ), + int_fast64_t subjFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_i64_x.c b/source/test_a_f64_z_i64_x.c new file mode 100644 index 0000000..d310ee2 --- /dev/null +++ b/source/test_a_f64_z_i64_x.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_i64_x( + int_fast64_t trueFunction( float64_t, bool ), + int_fast64_t subjFunction( float64_t, bool ), + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_ui32_rx.c b/source/test_a_f64_z_ui32_rx.c new file mode 100644 index 0000000..f4cda96 --- /dev/null +++ b/source/test_a_f64_z_ui32_rx.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_ui32_rx( + uint_fast32_t trueFunction( float64_t, uint_fast8_t, bool ), + uint_fast32_t subjFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_ui32_x.c b/source/test_a_f64_z_ui32_x.c new file mode 100644 index 0000000..0e73182 --- /dev/null +++ b/source/test_a_f64_z_ui32_x.c @@ -0,0 +1,100 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_ui32_x( + uint_fast32_t trueFunction( float64_t, bool ), + uint_fast32_t subjFunction( float64_t, bool ), + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_ui64_rx.c b/source/test_a_f64_z_ui64_rx.c new file mode 100644 index 0000000..1166604 --- /dev/null +++ b/source/test_a_f64_z_ui64_rx.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_ui64_rx( + uint_fast64_t trueFunction( float64_t, uint_fast8_t, bool ), + uint_fast64_t subjFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f64_z_ui64_x.c b/source/test_a_f64_z_ui64_x.c new file mode 100644 index 0000000..4ff2c8f --- /dev/null +++ b/source/test_a_f64_z_ui64_x.c @@ -0,0 +1,100 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_ui64_x( + uint_fast64_t trueFunction( float64_t, bool ), + uint_fast64_t subjFunction( float64_t, bool ), + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_i32_z_extF80.c b/source/test_a_i32_z_extF80.c new file mode 100644 index 0000000..ec96d56 --- /dev/null +++ b/source/test_a_i32_z_extF80.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_i32_z_extF80( + void trueFunction( int32_t, extFloat80_t * ), + void subjFunction( int32_t, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_i32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_i32_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_i32_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i32( genCases_i32_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_i32_z_f128.c b/source/test_a_i32_z_f128.c new file mode 100644 index 0000000..71d1d50 --- /dev/null +++ b/source/test_a_i32_z_f128.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_i32_z_f128( + void trueFunction( int32_t, float128_t * ), + void subjFunction( int32_t, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_i32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_i32_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_i32_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i32( genCases_i32_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_i32_z_f32.c b/source/test_a_i32_z_f32.c new file mode 100644 index 0000000..54fc995 --- /dev/null +++ b/source/test_a_i32_z_f32.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_i32_z_f32( + float32_t trueFunction( int32_t ), float32_t subjFunction( int32_t ) ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_i32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_i32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_i32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i32( genCases_i32_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_i32_z_f64.c b/source/test_a_i32_z_f64.c new file mode 100644 index 0000000..bd2196c --- /dev/null +++ b/source/test_a_i32_z_f64.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_i32_z_f64( + float64_t trueFunction( int32_t ), float64_t subjFunction( int32_t ) ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_i32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_i32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_i32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i32( genCases_i32_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_i64_z_extF80.c b/source/test_a_i64_z_extF80.c new file mode 100644 index 0000000..90ae68a --- /dev/null +++ b/source/test_a_i64_z_extF80.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_i64_z_extF80( + void trueFunction( int64_t, extFloat80_t * ), + void subjFunction( int64_t, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_i64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_i64_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_i64_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i64( genCases_i64_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_i64_z_f128.c b/source/test_a_i64_z_f128.c new file mode 100644 index 0000000..4752a5d --- /dev/null +++ b/source/test_a_i64_z_f128.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_i64_z_f128( + void trueFunction( int64_t, float128_t * ), + void subjFunction( int64_t, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_i64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_i64_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_i64_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i64( genCases_i64_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_i64_z_f32.c b/source/test_a_i64_z_f32.c new file mode 100644 index 0000000..e13812a --- /dev/null +++ b/source/test_a_i64_z_f32.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_i64_z_f32( + float32_t trueFunction( int64_t ), float32_t subjFunction( int64_t ) ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_i64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_i64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_i64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i64( genCases_i64_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_i64_z_f64.c b/source/test_a_i64_z_f64.c new file mode 100644 index 0000000..cf1afb9 --- /dev/null +++ b/source/test_a_i64_z_f64.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_i64_z_f64( + float64_t trueFunction( int64_t ), float64_t subjFunction( int64_t ) ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_i64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_i64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_i64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i64( genCases_i64_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_ui32_z_extF80.c b/source/test_a_ui32_z_extF80.c new file mode 100644 index 0000000..069b16a --- /dev/null +++ b/source/test_a_ui32_z_extF80.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui32_z_extF80( + void trueFunction( uint32_t, extFloat80_t * ), + void subjFunction( uint32_t, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui32_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_ui32_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui32( genCases_ui32_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_ui32_z_f128.c b/source/test_a_ui32_z_f128.c new file mode 100644 index 0000000..394f2d5 --- /dev/null +++ b/source/test_a_ui32_z_f128.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui32_z_f128( + void trueFunction( uint32_t, float128_t * ), + void subjFunction( uint32_t, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui32_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_ui32_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui32( genCases_ui32_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_ui32_z_f32.c b/source/test_a_ui32_z_f32.c new file mode 100644 index 0000000..8c79c7a --- /dev/null +++ b/source/test_a_ui32_z_f32.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui32_z_f32( + float32_t trueFunction( uint32_t ), float32_t subjFunction( uint32_t ) ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_ui32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_ui32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui32( genCases_ui32_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_ui32_z_f64.c b/source/test_a_ui32_z_f64.c new file mode 100644 index 0000000..c1ce51a --- /dev/null +++ b/source/test_a_ui32_z_f64.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui32_z_f64( + float64_t trueFunction( uint32_t ), float64_t subjFunction( uint32_t ) ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_ui32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_ui32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui32( genCases_ui32_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_ui64_z_extF80.c b/source/test_a_ui64_z_extF80.c new file mode 100644 index 0000000..aa541ba --- /dev/null +++ b/source/test_a_ui64_z_extF80.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui64_z_extF80( + void trueFunction( uint64_t, extFloat80_t * ), + void subjFunction( uint64_t, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui64_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_ui64_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui64( genCases_ui64_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_ui64_z_f128.c b/source/test_a_ui64_z_f128.c new file mode 100644 index 0000000..7d7f1f2 --- /dev/null +++ b/source/test_a_ui64_z_f128.c @@ -0,0 +1,98 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui64_z_f128( + void trueFunction( uint64_t, float128_t * ), + void subjFunction( uint64_t, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_ui64_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_ui64_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui64( genCases_ui64_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_ui64_z_f32.c b/source/test_a_ui64_z_f32.c new file mode 100644 index 0000000..d7ee290 --- /dev/null +++ b/source/test_a_ui64_z_f32.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui64_z_f32( + float32_t trueFunction( uint64_t ), float32_t subjFunction( uint64_t ) ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_ui64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_ui64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui64( genCases_ui64_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_ui64_z_f64.c b/source/test_a_ui64_z_f64.c new file mode 100644 index 0000000..0bd74c8 --- /dev/null +++ b/source/test_a_ui64_z_f64.c @@ -0,0 +1,92 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui64_z_f64( + float64_t trueFunction( uint64_t ), float64_t subjFunction( uint64_t ) ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_ui64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_ui64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui64( genCases_ui64_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_ab_extF80_z_bool.c b/source/test_ab_extF80_z_bool.c new file mode 100644 index 0000000..88d9e96 --- /dev/null +++ b/source/test_ab_extF80_z_bool.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_ab_extF80_z_bool( + bool trueFunction( const extFloat80_t *, const extFloat80_t * ), + bool subjFunction( const extFloat80_t *, const extFloat80_t * ) + ) +{ + int count; + bool trueZ; + uint_fast8_t trueFlags; + bool subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a, &genCases_extF80_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a, &genCases_extF80_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (extF80M_isSignalingNaN( &genCases_extF80_a ) + || extF80M_isSignalingNaN( &genCases_extF80_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_extF80M( + &genCases_extF80_a, &genCases_extF80_b, " " ); + writeCase_z_bool( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_ab_f128_z_bool.c b/source/test_ab_f128_z_bool.c new file mode 100644 index 0000000..fbbb5f4 --- /dev/null +++ b/source/test_ab_f128_z_bool.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_ab_f128_z_bool( + bool trueFunction( const float128_t *, const float128_t * ), + bool subjFunction( const float128_t *, const float128_t * ) + ) +{ + int count; + bool trueZ; + uint_fast8_t trueFlags; + bool subjZ; + uint_fast8_t subjFlags; + + genCases_f128_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a, &genCases_f128_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a, &genCases_f128_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f128M_isSignalingNaN( &genCases_f128_a ) + || f128M_isSignalingNaN( &genCases_f128_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f128M( + &genCases_f128_a, &genCases_f128_b, "\n\t" ); + writeCase_z_bool( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_ab_f32_z_bool.c b/source/test_ab_f32_z_bool.c new file mode 100644 index 0000000..8720ddd --- /dev/null +++ b/source/test_ab_f32_z_bool.c @@ -0,0 +1,96 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_ab_f32_z_bool( + bool trueFunction( float32_t, float32_t ), + bool subjFunction( float32_t, float32_t ) + ) +{ + int count; + bool trueZ; + uint_fast8_t trueFlags; + bool subjZ; + uint_fast8_t subjFlags; + + genCases_f32_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, genCases_f32_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, genCases_f32_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f32_isSignalingNaN( genCases_f32_a ) + || f32_isSignalingNaN( genCases_f32_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f32( genCases_f32_a, genCases_f32_b, " " ); + writeCase_z_bool( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_ab_f64_z_bool.c b/source/test_ab_f64_z_bool.c new file mode 100644 index 0000000..cd97c91 --- /dev/null +++ b/source/test_ab_f64_z_bool.c @@ -0,0 +1,96 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_ab_f64_z_bool( + bool trueFunction( float64_t, float64_t ), + bool subjFunction( float64_t, float64_t ) + ) +{ + int count; + bool trueZ; + uint_fast8_t trueFlags; + bool subjZ; + uint_fast8_t subjFlags; + + genCases_f64_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, genCases_f64_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, genCases_f64_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f64_isSignalingNaN( genCases_f64_a ) + || f64_isSignalingNaN( genCases_f64_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f64( genCases_f64_a, genCases_f64_b, " " ); + writeCase_z_bool( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_abcz_f128.c b/source/test_abcz_f128.c new file mode 100644 index 0000000..c4df9ba --- /dev/null +++ b/source/test_abcz_f128.c @@ -0,0 +1,126 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_abcz_f128( + void + trueFunction( + const float128_t *, + const float128_t *, + const float128_t *, + float128_t * + ), + void + subjFunction( + const float128_t *, + const float128_t *, + const float128_t *, + float128_t * + ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_abc_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_abc_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( + &genCases_f128_a, &genCases_f128_b, &genCases_f128_c, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( + &genCases_f128_a, &genCases_f128_b, &genCases_f128_c, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && ( f128M_isSignalingNaN( &genCases_f128_a ) + || f128M_isSignalingNaN( &genCases_f128_b ) + || f128M_isSignalingNaN( &genCases_f128_c ) + ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_abc_f128M( + &genCases_f128_a, + &genCases_f128_b, + &genCases_f128_c, + "\n\t" + ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_abcz_f32.c b/source/test_abcz_f32.c new file mode 100644 index 0000000..29048a5 --- /dev/null +++ b/source/test_abcz_f32.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_abcz_f32( + float32_t trueFunction( float32_t, float32_t, float32_t ), + float32_t subjFunction( float32_t, float32_t, float32_t ) + ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_abc_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_abc_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, genCases_f32_b, genCases_f32_c ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, genCases_f32_b, genCases_f32_c ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && ( f32_isSignalingNaN( genCases_f32_a ) + || f32_isSignalingNaN( genCases_f32_b ) + || f32_isSignalingNaN( genCases_f32_c ) + ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_abc_f32( + genCases_f32_a, genCases_f32_b, genCases_f32_c, "\n\t" ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_abcz_f64.c b/source/test_abcz_f64.c new file mode 100644 index 0000000..067617b --- /dev/null +++ b/source/test_abcz_f64.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_abcz_f64( + float64_t trueFunction( float64_t, float64_t, float64_t ), + float64_t subjFunction( float64_t, float64_t, float64_t ) + ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_abc_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_abc_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, genCases_f64_b, genCases_f64_c ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, genCases_f64_b, genCases_f64_c ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && ( f64_isSignalingNaN( genCases_f64_a ) + || f64_isSignalingNaN( genCases_f64_b ) + || f64_isSignalingNaN( genCases_f64_c ) + ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_abc_f64( + genCases_f64_a, genCases_f64_b, genCases_f64_c, "\n\t" ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_abz_extF80.c b/source/test_abz_extF80.c new file mode 100644 index 0000000..e6453d6 --- /dev/null +++ b/source/test_abz_extF80.c @@ -0,0 +1,110 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_abz_extF80( + void + trueFunction( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ), + void + subjFunction( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, &genCases_extF80_b, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_extF80_a, &genCases_extF80_b, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (extF80M_isSignalingNaN( &genCases_extF80_a ) + || extF80M_isSignalingNaN( &genCases_extF80_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_extF80M( + &genCases_extF80_a, &genCases_extF80_b, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_abz_f128.c b/source/test_abz_f128.c new file mode 100644 index 0000000..95656f4 --- /dev/null +++ b/source/test_abz_f128.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_abz_f128( + void trueFunction( const float128_t *, const float128_t *, float128_t * ), + void subjFunction( const float128_t *, const float128_t *, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, &genCases_f128_b, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_f128_a, &genCases_f128_b, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f128M_isSignalingNaN( &genCases_f128_a ) + || f128M_isSignalingNaN( &genCases_f128_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f128M( + &genCases_f128_a, &genCases_f128_b, "\n\t" ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_abz_f32.c b/source/test_abz_f32.c new file mode 100644 index 0000000..e224653 --- /dev/null +++ b/source/test_abz_f32.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_abz_f32( + float32_t trueFunction( float32_t, float32_t ), + float32_t subjFunction( float32_t, float32_t ) + ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, genCases_f32_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, genCases_f32_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f32_isSignalingNaN( genCases_f32_a ) + || f32_isSignalingNaN( genCases_f32_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f32( genCases_f32_a, genCases_f32_b, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_abz_f64.c b/source/test_abz_f64.c new file mode 100644 index 0000000..5b04e14 --- /dev/null +++ b/source/test_abz_f64.c @@ -0,0 +1,101 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_abz_f64( + float64_t trueFunction( float64_t, float64_t ), + float64_t subjFunction( float64_t, float64_t ) + ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, genCases_f64_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, genCases_f64_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f64_isSignalingNaN( genCases_f64_a ) + || f64_isSignalingNaN( genCases_f64_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f64( genCases_f64_a, genCases_f64_b, "\n\t" ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_az_extF80.c b/source/test_az_extF80.c new file mode 100644 index 0000000..bb6f319 --- /dev/null +++ b/source/test_az_extF80.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_az_extF80( + void trueFunction( const extFloat80_t *, extFloat80_t * ), + void subjFunction( const extFloat80_t *, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_extF80_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_az_extF80_rx.c b/source/test_az_extF80_rx.c new file mode 100644 index 0000000..e6559ae --- /dev/null +++ b/source/test_az_extF80_rx.c @@ -0,0 +1,109 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_az_extF80_rx( + void + trueFunction( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), + void + subjFunction( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_extF80_a, roundingMode, exact, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_extF80_a, roundingMode, exact, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_az_f128.c b/source/test_az_f128.c new file mode 100644 index 0000000..6237cf5 --- /dev/null +++ b/source/test_az_f128.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_az_f128( + void trueFunction( const float128_t *, float128_t * ), + void subjFunction( const float128_t *, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_f128_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_az_f128_rx.c b/source/test_az_f128_rx.c new file mode 100644 index 0000000..cf08cf1 --- /dev/null +++ b/source/test_az_f128_rx.c @@ -0,0 +1,107 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_az_f128_rx( + void trueFunction( const float128_t *, uint_fast8_t, bool, float128_t * ), + void subjFunction( const float128_t *, uint_fast8_t, bool, float128_t * ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( &genCases_f128_a, roundingMode, exact, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( &genCases_f128_a, roundingMode, exact, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_az_f32.c b/source/test_az_f32.c new file mode 100644 index 0000000..9cbf6d5 --- /dev/null +++ b/source/test_az_f32.c @@ -0,0 +1,97 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_az_f32( + float32_t trueFunction( float32_t ), float32_t subjFunction( float32_t ) ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_az_f32_rx.c b/source/test_az_f32_rx.c new file mode 100644 index 0000000..511669a --- /dev/null +++ b/source/test_az_f32_rx.c @@ -0,0 +1,102 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_az_f32_rx( + float32_t trueFunction( float32_t, uint_fast8_t, bool ), + float32_t subjFunction( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_az_f64.c b/source/test_az_f64.c new file mode 100644 index 0000000..17c7f2b --- /dev/null +++ b/source/test_az_f64.c @@ -0,0 +1,97 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_az_f64( + float64_t trueFunction( float64_t ), float64_t subjFunction( float64_t ) ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_az_f64_rx.c b/source/test_az_f64_rx.c new file mode 100644 index 0000000..a785378 --- /dev/null +++ b/source/test_az_f64_rx.c @@ -0,0 +1,102 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_az_f64_rx( + float64_t trueFunction( float64_t, uint_fast8_t, bool ), + float64_t subjFunction( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/testfloat.c b/source/testfloat.c new file mode 100644 index 0000000..73044f8 --- /dev/null +++ b/source/testfloat.c @@ -0,0 +1,1351 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California +(Regents). All Rights Reserved. Redistribution and use in source and binary +forms, with or without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions, and the following two paragraphs of disclaimer in the +documentation and/or other materials provided with the distribution. Neither +the name of the Regents nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING +OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED +HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE +MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +=============================================================================*/ + +#include +#include +#include +#include +#include +#include +#include "platform.h" +#include "fail.h" +#include "softfloat.h" +#include "subjfloat_config.h" +#include "subjfloat.h" +#include "functions.h" +#include "genCases.h" +#include "verCases.h" +#include "testLoops.h" + +static void catchSIGINT( int signalCode ) +{ + + if ( verCases_stop ) exit( EXIT_FAILURE ); + verCases_stop = true; + +} + +static void (*subjFunctionPtr)(); + +typedef float32_t funcType_a_ui32_z_f32( uint_fast32_t ); +typedef float64_t funcType_a_ui32_z_f64( uint_fast32_t ); +#ifdef EXTFLOAT80 +typedef void funcType_a_ui32_z_extF80( uint_fast32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +typedef void funcType_a_ui32_z_f128( uint_fast32_t, float128_t * ); +#endif +typedef float32_t funcType_a_ui64_z_f32( uint_fast64_t ); +typedef float64_t funcType_a_ui64_z_f64( uint_fast64_t ); +#ifdef EXTFLOAT80 +typedef void funcType_a_ui64_z_extF80( uint_fast64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +typedef void funcType_a_ui64_z_f128( uint_fast64_t, float128_t * ); +#endif +typedef float32_t funcType_a_i32_z_f32( int_fast32_t ); +typedef float64_t funcType_a_i32_z_f64( int_fast32_t ); +#ifdef EXTFLOAT80 +typedef void funcType_a_i32_z_extF80( int_fast32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +typedef void funcType_a_i32_z_f128( int_fast32_t, float128_t * ); +#endif +typedef float32_t funcType_a_i64_z_f32( int_fast64_t ); +typedef float64_t funcType_a_i64_z_f64( int_fast64_t ); +#ifdef EXTFLOAT80 +typedef void funcType_a_i64_z_extF80( int_fast64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +typedef void funcType_a_i64_z_f128( int_fast64_t, float128_t * ); +#endif + +typedef uint_fast32_t funcType_a_f32_z_ui32( float32_t ); +typedef uint_fast64_t funcType_a_f32_z_ui64( float32_t ); +typedef int_fast32_t funcType_a_f32_z_i32( float32_t ); +typedef int_fast64_t funcType_a_f32_z_i64( float32_t ); +typedef float64_t funcType_a_f32_z_f64( float32_t ); +#ifdef EXTFLOAT80 +typedef void funcType_a_f32_z_extF80( float32_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +typedef void funcType_a_f32_z_f128( float32_t, float128_t * ); +#endif +typedef float32_t funcType_az_f32( float32_t ); +typedef float32_t funcType_abz_f32( float32_t, float32_t ); +typedef float32_t funcType_abcz_f32( float32_t, float32_t, float32_t ); +typedef bool funcType_ab_f32_z_bool( float32_t, float32_t ); + +typedef uint_fast32_t funcType_a_f64_z_ui32( float64_t ); +typedef uint_fast64_t funcType_a_f64_z_ui64( float64_t ); +typedef int_fast32_t funcType_a_f64_z_i32( float64_t ); +typedef int_fast64_t funcType_a_f64_z_i64( float64_t ); +typedef float32_t funcType_a_f64_z_f32( float64_t ); +#ifdef EXTFLOAT80 +typedef void funcType_a_f64_z_extF80( float64_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +typedef void funcType_a_f64_z_f128( float64_t, float128_t * ); +#endif +typedef float64_t funcType_az_f64( float64_t ); +typedef float64_t funcType_abz_f64( float64_t, float64_t ); +typedef float64_t funcType_abcz_f64( float64_t, float64_t, float64_t ); +typedef bool funcType_ab_f64_z_bool( float64_t, float64_t ); + +#ifdef EXTFLOAT80 +typedef uint_fast32_t funcType_a_extF80_z_ui32( const extFloat80_t * ); +typedef uint_fast64_t funcType_a_extF80_z_ui64( const extFloat80_t * ); +typedef int_fast32_t funcType_a_extF80_z_i32( const extFloat80_t * ); +typedef int_fast64_t funcType_a_extF80_z_i64( const extFloat80_t * ); +typedef float32_t funcType_a_extF80_z_f32( const extFloat80_t * ); +typedef float64_t funcType_a_extF80_z_f64( const extFloat80_t * ); +#ifdef FLOAT128 +typedef void funcType_a_extF80_z_f128( const extFloat80_t *, float128_t * ); +#endif +typedef void funcType_az_extF80( const extFloat80_t *, extFloat80_t * ); +typedef + void + funcType_abz_extF80( + const extFloat80_t *, const extFloat80_t *, extFloat80_t * ); +typedef + bool funcType_ab_extF80_z_bool( const extFloat80_t *, const extFloat80_t * ); +#endif + +#ifdef FLOAT128 +typedef uint_fast32_t funcType_a_f128_z_ui32( const float128_t * ); +typedef uint_fast64_t funcType_a_f128_z_ui64( const float128_t * ); +typedef int_fast32_t funcType_a_f128_z_i32( const float128_t * ); +typedef int_fast64_t funcType_a_f128_z_i64( const float128_t * ); +typedef float32_t funcType_a_f128_z_f32( const float128_t * ); +typedef float64_t funcType_a_f128_z_f64( const float128_t * ); +#ifdef EXTFLOAT80 +typedef void funcType_a_f128_z_extF80( const float128_t *, extFloat80_t * ); +#endif +typedef void funcType_az_f128( const float128_t *, float128_t * ); +typedef + void + funcType_abz_f128( const float128_t *, const float128_t *, float128_t * ); +typedef + void + funcType_abcz_f128( + const float128_t *, const float128_t *, const float128_t *, float128_t * + ); +typedef bool funcType_ab_f128_z_bool( const float128_t *, const float128_t * ); +#endif + +static + uint_fast32_t + subjFunction_a_f32_z_ui32_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f32_z_ui32 *) subjFunctionPtr)( a ); + +} + +static + uint_fast64_t + subjFunction_a_f32_z_ui64_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f32_z_ui64 *) subjFunctionPtr)( a ); + +} + +static + int_fast32_t + subjFunction_a_f32_z_i32_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f32_z_i32 *) subjFunctionPtr)( a ); + +} + +static + int_fast64_t + subjFunction_a_f32_z_i64_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f32_z_i64 *) subjFunctionPtr)( a ); + +} + +static + float32_t + subjFunction_az_f32_rx( float32_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_az_f32 *) subjFunctionPtr)( a ); + +} + +static + uint_fast32_t + subjFunction_a_f64_z_ui32_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f64_z_ui32 *) subjFunctionPtr)( a ); + +} + +static + uint_fast64_t + subjFunction_a_f64_z_ui64_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f64_z_ui64 *) subjFunctionPtr)( a ); + +} + +static + int_fast32_t + subjFunction_a_f64_z_i32_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f64_z_i32 *) subjFunctionPtr)( a ); + +} + +static + int_fast64_t + subjFunction_a_f64_z_i64_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f64_z_i64 *) subjFunctionPtr)( a ); + +} + +static + float64_t + subjFunction_az_f64_rx( float64_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_az_f64 *) subjFunctionPtr)( a ); + +} + +#ifdef EXTFLOAT80 + +static + uint_fast32_t + subjFunction_a_extF80_z_ui32_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_extF80_z_ui32 *) subjFunctionPtr)( aPtr ); + +} + +static + uint_fast64_t + subjFunction_a_extF80_z_ui64_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_extF80_z_ui64 *) subjFunctionPtr)( aPtr ); + +} + +static + int_fast32_t + subjFunction_a_extF80_z_i32_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_extF80_z_i32 *) subjFunctionPtr)( aPtr ); + +} + +static + int_fast64_t + subjFunction_a_extF80_z_i64_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_extF80_z_i64 *) subjFunctionPtr)( aPtr ); + +} + +static + void + subjFunction_az_extF80_rx( + const extFloat80_t *aPtr, + uint_fast8_t roundingMode, + bool exact, + extFloat80_t *zPtr + ) +{ + + return ((funcType_az_extF80 *) subjFunctionPtr)( aPtr, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +static + uint_fast32_t + subjFunction_a_f128_z_ui32_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f128_z_ui32 *) subjFunctionPtr)( aPtr ); + +} + +static + uint_fast64_t + subjFunction_a_f128_z_ui64_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f128_z_ui64 *) subjFunctionPtr)( aPtr ); + +} + +static + int_fast32_t + subjFunction_a_f128_z_i32_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f128_z_i32 *) subjFunctionPtr)( aPtr ); + +} + +static + int_fast64_t + subjFunction_a_f128_z_i64_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f128_z_i64 *) subjFunctionPtr)( aPtr ); + +} + +static + void + subjFunction_az_f128_rx( + const float128_t *aPtr, + uint_fast8_t roundingMode, + bool exact, + float128_t *zPtr + ) +{ + + return ((funcType_az_f128 *) subjFunctionPtr)( aPtr, zPtr ); + +} + +#endif + +static + void + testFunctionInstance( + int functionCode, uint_fast8_t roundingMode, bool exact ) +{ + funcType_abz_f32 *trueFunction_abz_f32; + funcType_ab_f32_z_bool *trueFunction_ab_f32_z_bool; + funcType_abz_f64 *trueFunction_abz_f64; + funcType_ab_f64_z_bool *trueFunction_ab_f64_z_bool; + funcType_abz_extF80 *trueFunction_abz_extF80; + funcType_ab_extF80_z_bool *trueFunction_ab_extF80_z_bool; + funcType_abz_f128 *trueFunction_abz_f128; + funcType_ab_f128_z_bool *trueFunction_ab_f128_z_bool; + + fputs( "Testing ", stderr ); + verCases_writeFunctionName( stderr ); + fputs( ".\n", stderr ); + switch ( functionCode ) { + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ +#ifdef SUBJ_UI32_TO_F32 + case UI32_TO_F32: + test_a_ui32_z_f32( + ui32_to_f32, (funcType_a_ui32_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_UI32_TO_F64 + case UI32_TO_F64: + test_a_ui32_z_f64( + ui32_to_f64, (funcType_a_ui32_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_UI32_TO_EXTF80 + case UI32_TO_EXTF80: + test_a_ui32_z_extF80( + ui32_to_extF80M, (funcType_a_ui32_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_UI32_TO_F128 + case UI32_TO_F128: + test_a_ui32_z_f128( + ui32_to_f128M, (funcType_a_ui32_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef SUBJ_UI64_TO_F32 + case UI64_TO_F32: + test_a_ui64_z_f32( + ui64_to_f32, (funcType_a_ui64_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_UI64_TO_F64 + case UI64_TO_F64: + test_a_ui64_z_f64( + ui64_to_f64, (funcType_a_ui64_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_UI64_TO_EXTF80 + case UI64_TO_EXTF80: + test_a_ui64_z_extF80( + ui64_to_extF80M, (funcType_a_ui64_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_UI64_TO_F128 + case UI64_TO_F128: + test_a_ui64_z_f128( + ui64_to_f128M, (funcType_a_ui64_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef SUBJ_I32_TO_F32 + case I32_TO_F32: + test_a_i32_z_f32( + i32_to_f32, (funcType_a_i32_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_I32_TO_F64 + case I32_TO_F64: + test_a_i32_z_f64( + i32_to_f64, (funcType_a_i32_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_I32_TO_EXTF80 + case I32_TO_EXTF80: + test_a_i32_z_extF80( + i32_to_extF80M, (funcType_a_i32_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_I32_TO_F128 + case I32_TO_F128: + test_a_i32_z_f128( + i32_to_f128M, (funcType_a_i32_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef SUBJ_I64_TO_F32 + case I64_TO_F32: + test_a_i64_z_f32( + i64_to_f32, (funcType_a_i64_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_I64_TO_F64 + case I64_TO_F64: + test_a_i64_z_f64( + i64_to_f64, (funcType_a_i64_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_I64_TO_EXTF80 + case I64_TO_EXTF80: + test_a_i64_z_extF80( + i64_to_extF80M, (funcType_a_i64_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_I64_TO_F128 + case I64_TO_F128: + test_a_i64_z_f128( + i64_to_f128M, (funcType_a_i64_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ + case F32_TO_UI32: + test_a_f32_z_ui32_rx( + f32_to_ui32, subjFunction_a_f32_z_ui32_rx, roundingMode, exact ); + break; + case F32_TO_UI64: + test_a_f32_z_ui64_rx( + f32_to_ui64, subjFunction_a_f32_z_ui64_rx, roundingMode, exact ); + break; + case F32_TO_I32: + test_a_f32_z_i32_rx( + f32_to_i32, subjFunction_a_f32_z_i32_rx, roundingMode, exact ); + break; + case F32_TO_I64: + test_a_f32_z_i64_rx( + f32_to_i64, subjFunction_a_f32_z_i64_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F32_TO_F64 + case F32_TO_F64: + test_a_f32_z_f64( + f32_to_f64, (funcType_a_f32_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F32_TO_EXTF80 + case F32_TO_EXTF80: + test_a_f32_z_extF80( + f32_to_extF80M, (funcType_a_f32_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_F32_TO_F128 + case F32_TO_F128: + test_a_f32_z_f128( + f32_to_f128M, (funcType_a_f32_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif + case F32_ROUNDTOINT: + test_az_f32_rx( + f32_roundToInt, subjFunction_az_f32_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F32_ADD + case F32_ADD: + trueFunction_abz_f32 = f32_add; + goto test_abz_f32; +#endif +#ifdef SUBJ_F32_SUB + case F32_SUB: + trueFunction_abz_f32 = f32_sub; + goto test_abz_f32; +#endif +#ifdef SUBJ_F32_MUL + case F32_MUL: + trueFunction_abz_f32 = f32_mul; + goto test_abz_f32; +#endif +#ifdef SUBJ_F32_MULADD + case F32_MULADD: + test_abcz_f32( f32_mulAdd, (funcType_abcz_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F32_DIV + case F32_DIV: + trueFunction_abz_f32 = f32_div; + goto test_abz_f32; +#endif +#ifdef SUBJ_F32_REM + case F32_REM: + trueFunction_abz_f32 = f32_rem; + goto test_abz_f32; +#endif + test_abz_f32: + test_abz_f32( + trueFunction_abz_f32, (funcType_abz_f32 *) subjFunctionPtr ); + break; +#ifdef SUBJ_F32_SQRT + case F32_SQRT: + test_az_f32( f32_sqrt, (funcType_az_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F32_EQ + case F32_EQ: + trueFunction_ab_f32_z_bool = f32_eq; + goto test_ab_f32_z_bool; +#endif +#ifdef SUBJ_F32_LE + case F32_LE: + trueFunction_ab_f32_z_bool = f32_le; + goto test_ab_f32_z_bool; +#endif +#ifdef SUBJ_F32_LT + case F32_LT: + trueFunction_ab_f32_z_bool = f32_lt; + goto test_ab_f32_z_bool; +#endif +#ifdef SUBJ_F32_EQ_SIGNALING + case F32_EQ_SIGNALING: + trueFunction_ab_f32_z_bool = f32_eq_signaling; + goto test_ab_f32_z_bool; +#endif +#ifdef SUBJ_F32_LE_QUIET + case F32_LE_QUIET: + trueFunction_ab_f32_z_bool = f32_le_quiet; + goto test_ab_f32_z_bool; +#endif +#ifdef SUBJ_F32_LT_QUIET + case F32_LT_QUIET: + trueFunction_ab_f32_z_bool = f32_lt_quiet; + goto test_ab_f32_z_bool; +#endif + test_ab_f32_z_bool: + test_ab_f32_z_bool( + trueFunction_ab_f32_z_bool, + (funcType_ab_f32_z_bool *) subjFunctionPtr + ); + break; + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ + case F64_TO_UI32: + test_a_f64_z_ui32_rx( + f64_to_ui32, subjFunction_a_f64_z_ui32_rx, roundingMode, exact ); + break; + case F64_TO_UI64: + test_a_f64_z_ui64_rx( + f64_to_ui64, subjFunction_a_f64_z_ui64_rx, roundingMode, exact ); + break; + case F64_TO_I32: + test_a_f64_z_i32_rx( + f64_to_i32, subjFunction_a_f64_z_i32_rx, roundingMode, exact ); + break; + case F64_TO_I64: + test_a_f64_z_i64_rx( + f64_to_i64, subjFunction_a_f64_z_i64_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F64_TO_F32 + case F64_TO_F32: + test_a_f64_z_f32( + f64_to_f32, (funcType_a_f64_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F64_TO_EXTF80 + case F64_TO_EXTF80: + test_a_f64_z_extF80( + f64_to_extF80M, (funcType_a_f64_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_F64_TO_F128 + case F64_TO_F128: + test_a_f64_z_f128( + f64_to_f128M, (funcType_a_f64_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif + case F64_ROUNDTOINT: + test_az_f64_rx( + f64_roundToInt, subjFunction_az_f64_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F64_ADD + case F64_ADD: + trueFunction_abz_f64 = f64_add; + goto test_abz_f64; +#endif +#ifdef SUBJ_F64_SUB + case F64_SUB: + trueFunction_abz_f64 = f64_sub; + goto test_abz_f64; +#endif +#ifdef SUBJ_F64_MUL + case F64_MUL: + trueFunction_abz_f64 = f64_mul; + goto test_abz_f64; +#endif +#ifdef SUBJ_F64_MULADD + case F64_MULADD: + test_abcz_f64( f64_mulAdd, (funcType_abcz_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F64_DIV + case F64_DIV: + trueFunction_abz_f64 = f64_div; + goto test_abz_f64; +#endif +#ifdef SUBJ_F64_REM + case F64_REM: + trueFunction_abz_f64 = f64_rem; + goto test_abz_f64; +#endif + test_abz_f64: + test_abz_f64( + trueFunction_abz_f64, (funcType_abz_f64 *) subjFunctionPtr ); + break; +#ifdef SUBJ_F64_SQRT + case F64_SQRT: + test_az_f64( f64_sqrt, (funcType_az_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F64_EQ + case F64_EQ: + trueFunction_ab_f64_z_bool = f64_eq; + goto test_ab_f64_z_bool; +#endif +#ifdef SUBJ_F64_LE + case F64_LE: + trueFunction_ab_f64_z_bool = f64_le; + goto test_ab_f64_z_bool; +#endif +#ifdef SUBJ_F64_LT + case F64_LT: + trueFunction_ab_f64_z_bool = f64_lt; + goto test_ab_f64_z_bool; +#endif +#ifdef SUBJ_F64_EQ_SIGNALING + case F64_EQ_SIGNALING: + trueFunction_ab_f64_z_bool = f64_eq_signaling; + goto test_ab_f64_z_bool; +#endif +#ifdef SUBJ_F64_LE_QUIET + case F64_LE_QUIET: + trueFunction_ab_f64_z_bool = f64_le_quiet; + goto test_ab_f64_z_bool; +#endif +#ifdef SUBJ_F64_LT_QUIET + case F64_LT_QUIET: + trueFunction_ab_f64_z_bool = f64_lt_quiet; + goto test_ab_f64_z_bool; +#endif + test_ab_f64_z_bool: + test_ab_f64_z_bool( + trueFunction_ab_f64_z_bool, + (funcType_ab_f64_z_bool *) subjFunctionPtr + ); + break; + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ +#ifdef EXTFLOAT80 + case EXTF80_TO_UI32: + test_a_extF80_z_ui32_rx( + extF80M_to_ui32, + subjFunction_a_extF80_z_ui32_rx, + roundingMode, + exact + ); + break; + case EXTF80_TO_UI64: + test_a_extF80_z_ui64_rx( + extF80M_to_ui64, + subjFunction_a_extF80_z_ui64_rx, + roundingMode, + exact + ); + break; + case EXTF80_TO_I32: + test_a_extF80_z_i32_rx( + extF80M_to_i32, subjFunction_a_extF80_z_i32_rx, roundingMode, exact + ); + break; + case EXTF80_TO_I64: + test_a_extF80_z_i64_rx( + extF80M_to_i64, subjFunction_a_extF80_z_i64_rx, roundingMode, exact + ); + break; +#ifdef SUBJ_EXTF80_TO_F32 + case EXTF80_TO_F32: + test_a_extF80_z_f32( + extF80M_to_f32, (funcType_a_extF80_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_EXTF80_TO_F64 + case EXTF80_TO_F64: + test_a_extF80_z_f64( + extF80M_to_f64, (funcType_a_extF80_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef FLOAT128 +#ifdef SUBJ_EXTF80_TO_F128 + case EXTF80_TO_F128: + test_a_extF80_z_f128( + extF80M_to_f128M, (funcType_a_extF80_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif + case EXTF80_ROUNDTOINT: + test_az_extF80_rx( + extF80M_roundToInt, subjFunction_az_extF80_rx, roundingMode, exact + ); + break; +#ifdef SUBJ_EXTF80_ADD + case EXTF80_ADD: + trueFunction_abz_extF80 = extF80M_add; + goto test_abz_extF80; +#endif +#ifdef SUBJ_EXTF80_SUB + case EXTF80_SUB: + trueFunction_abz_extF80 = extF80M_sub; + goto test_abz_extF80; +#endif +#ifdef SUBJ_EXTF80_MUL + case EXTF80_MUL: + trueFunction_abz_extF80 = extF80M_mul; + goto test_abz_extF80; +#endif +#ifdef SUBJ_EXTF80_DIV + case EXTF80_DIV: + trueFunction_abz_extF80 = extF80M_div; + goto test_abz_extF80; +#endif +#ifdef SUBJ_EXTF80_REM + case EXTF80_REM: + trueFunction_abz_extF80 = extF80M_rem; + goto test_abz_extF80; +#endif + test_abz_extF80: + test_abz_extF80( + trueFunction_abz_extF80, (funcType_abz_extF80 *) subjFunctionPtr ); + break; +#ifdef SUBJ_EXTF80_SQRT + case EXTF80_SQRT: + test_az_extF80( extF80M_sqrt, (funcType_az_extF80 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_EXTF80_EQ + case EXTF80_EQ: + trueFunction_ab_extF80_z_bool = extF80M_eq; + goto test_ab_extF80_z_bool; +#endif +#ifdef SUBJ_EXTF80_LE + case EXTF80_LE: + trueFunction_ab_extF80_z_bool = extF80M_le; + goto test_ab_extF80_z_bool; +#endif +#ifdef SUBJ_EXTF80_LT + case EXTF80_LT: + trueFunction_ab_extF80_z_bool = extF80M_lt; + goto test_ab_extF80_z_bool; +#endif +#ifdef SUBJ_EXTF80_EQ_SIGNALING + case EXTF80_EQ_SIGNALING: + trueFunction_ab_extF80_z_bool = extF80M_eq_signaling; + goto test_ab_extF80_z_bool; +#endif +#ifdef SUBJ_EXTF80_LE_QUIET + case EXTF80_LE_QUIET: + trueFunction_ab_extF80_z_bool = extF80M_le_quiet; + goto test_ab_extF80_z_bool; +#endif +#ifdef SUBJ_EXTF80_LT_QUIET + case EXTF80_LT_QUIET: + trueFunction_ab_extF80_z_bool = extF80M_lt_quiet; + goto test_ab_extF80_z_bool; +#endif + test_ab_extF80_z_bool: + test_ab_extF80_z_bool( + trueFunction_ab_extF80_z_bool, + (funcType_ab_extF80_z_bool *) subjFunctionPtr + ); + break; +#endif + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ +#ifdef FLOAT128 + case F128_TO_UI32: + test_a_f128_z_ui32_rx( + f128M_to_ui32, subjFunction_a_f128_z_ui32_rx, roundingMode, exact + ); + break; + case F128_TO_UI64: + test_a_f128_z_ui64_rx( + f128M_to_ui64, subjFunction_a_f128_z_ui64_rx, roundingMode, exact + ); + break; + case F128_TO_I32: + test_a_f128_z_i32_rx( + f128M_to_i32, subjFunction_a_f128_z_i32_rx, roundingMode, exact ); + break; + case F128_TO_I64: + test_a_f128_z_i64_rx( + f128M_to_i64, subjFunction_a_f128_z_i64_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F128_TO_F32 + case F128_TO_F32: + test_a_f128_z_f32( + f128M_to_f32, (funcType_a_f128_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F128_TO_F64 + case F128_TO_F64: + test_a_f128_z_f64( + f128M_to_f64, (funcType_a_f128_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F128_TO_EXTF80 + case F128_TO_EXTF80: + test_a_f128_z_extF80( + f128M_to_extF80M, (funcType_a_f128_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif + case F128_ROUNDTOINT: + test_az_f128_rx( + f128M_roundToInt, subjFunction_az_f128_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F128_ADD + case F128_ADD: + trueFunction_abz_f128 = f128M_add; + goto test_abz_f128; +#endif +#ifdef SUBJ_F128_SUB + case F128_SUB: + trueFunction_abz_f128 = f128M_sub; + goto test_abz_f128; +#endif +#ifdef SUBJ_F128_MUL + case F128_MUL: + trueFunction_abz_f128 = f128M_mul; + goto test_abz_f128; +#endif +#ifdef SUBJ_F128_MULADD + case F128_MULADD: + test_abcz_f128( f128M_mulAdd, (funcType_abcz_f128 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F128_DIV + case F128_DIV: + trueFunction_abz_f128 = f128M_div; + goto test_abz_f128; +#endif +#ifdef SUBJ_F128_REM + case F128_REM: + trueFunction_abz_f128 = f128M_rem; + goto test_abz_f128; +#endif + test_abz_f128: + test_abz_f128( + trueFunction_abz_f128, (funcType_abz_f128 *) subjFunctionPtr ); + break; +#ifdef SUBJ_F128_SQRT + case F128_SQRT: + test_az_f128( f128M_sqrt, (funcType_az_f128 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F128_EQ + case F128_EQ: + trueFunction_ab_f128_z_bool = f128M_eq; + goto test_ab_f128_z_bool; +#endif +#ifdef SUBJ_F128_LE + case F128_LE: + trueFunction_ab_f128_z_bool = f128M_le; + goto test_ab_f128_z_bool; +#endif +#ifdef SUBJ_F128_LT + case F128_LT: + trueFunction_ab_f128_z_bool = f128M_lt; + goto test_ab_f128_z_bool; +#endif +#ifdef SUBJ_F128_EQ_SIGNALING + case F128_EQ_SIGNALING: + trueFunction_ab_f128_z_bool = f128M_eq_signaling; + goto test_ab_f128_z_bool; +#endif +#ifdef SUBJ_F128_LE_QUIET + case F128_LE_QUIET: + trueFunction_ab_f128_z_bool = f128M_le_quiet; + goto test_ab_f128_z_bool; +#endif +#ifdef SUBJ_F128_LT_QUIET + case F128_LT_QUIET: + trueFunction_ab_f128_z_bool = f128M_lt_quiet; + goto test_ab_f128_z_bool; +#endif + test_ab_f128_z_bool: + test_ab_f128_z_bool( + trueFunction_ab_f128_z_bool, + (funcType_ab_f128_z_bool *) subjFunctionPtr + ); + break; +#endif + } + if ( (verCases_errorStop && verCases_anyErrors) || verCases_stop ) { + verCases_exitWithStatus(); + } + +} + +static + void + testFunction( + const struct standardFunctionInfo *standardFunctionInfoPtr, + uint_fast8_t roundingPrecisionIn, + int roundingCodeIn + ) +{ + int functionCode, functionAttribs; + bool standardFunctionHasFixedRounding; + int roundingCode; + bool exact; + uint_fast8_t roundingPrecision, roundingMode; + + functionCode = standardFunctionInfoPtr->functionCode; + functionAttribs = functionInfos[functionCode].attribs; + standardFunctionHasFixedRounding = false; + if ( functionAttribs & FUNC_ARG_ROUNDINGMODE ) { + roundingCode = standardFunctionInfoPtr->roundingCode; + if ( roundingCode ) { + standardFunctionHasFixedRounding = true; + roundingCodeIn = roundingCode; + } + } + exact = standardFunctionInfoPtr->exact; + verCases_functionNamePtr = standardFunctionInfoPtr->namePtr; + roundingPrecision = 32; + for (;;) { + if ( ! (functionAttribs & FUNC_EFF_ROUNDINGPRECISION) ) { + roundingPrecision = 0; + } else if ( roundingPrecisionIn ) { + roundingPrecision = roundingPrecisionIn; + } +#ifdef EXTFLOAT80 + verCases_roundingPrecision = roundingPrecision; + if ( roundingPrecision ) { + extF80_roundingPrecision = roundingPrecision; + subjfloat_setExtF80RoundingPrecision( roundingPrecision ); + } +#endif + for ( + roundingCode = 1; roundingCode < NUM_ROUNDINGMODES; ++roundingCode + ) { +#ifndef SUBJFLOAT_ROUND_NEAR_MAXMAG + if ( roundingCode != ROUND_NEAR_MAXMAG ) { +#endif + if ( + ! (functionAttribs + & (FUNC_ARG_ROUNDINGMODE | FUNC_EFF_ROUNDINGMODE)) + ) { + roundingCode = 0; + } else if ( roundingCodeIn ) { + roundingCode = roundingCodeIn; + } + verCases_roundingCode = + standardFunctionHasFixedRounding ? 0 : roundingCode; + if ( roundingCode ) { + roundingMode = roundingModes[roundingCode]; + softfloat_roundingMode = roundingMode; + if ( ! standardFunctionHasFixedRounding ) { + subjfloat_setRoundingMode( roundingMode ); + } + } + testFunctionInstance( functionCode, roundingMode, exact ); + if ( roundingCodeIn || ! roundingCode ) break; +#ifndef SUBJFLOAT_ROUND_NEAR_MAXMAG + } +#endif + } + if ( roundingPrecisionIn || ! roundingPrecision ) break; + if ( roundingPrecision == 80 ) { + break; + } else if ( roundingPrecision == 64 ) { + roundingPrecision = 80; + } else if ( roundingPrecision == 32 ) { + roundingPrecision = 64; + } + } + +} + +int main( int argc, char *argv[] ) +{ + bool haveFunctionArg; + const struct standardFunctionInfo *standardFunctionInfoPtr; + int numOperands; + uint_fast8_t roundingPrecision; + int roundingCode; + const char *argPtr; + void (*const *subjFunctionPtrPtr)(); + const char *functionNamePtr; + long i; + + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ + fail_programName = "testfloat"; + if ( argc <= 1 ) goto writeHelpMessage; + genCases_setLevel( 1 ); + verCases_maxErrorCount = 20; + testLoops_trueFlagsPtr = &softfloat_exceptionFlags; + testLoops_subjFlagsFunction = subjfloat_clearExceptionFlags; + haveFunctionArg = false; + standardFunctionInfoPtr = 0; + numOperands = 0; + roundingPrecision = 0; + roundingCode = 0; + for (;;) { + --argc; + if ( ! argc ) break; + argPtr = *++argv; + if ( ! argPtr ) break; + if ( argPtr[0] == '-' ) ++argPtr; + if ( + ! strcmp( argPtr, "help" ) || ! strcmp( argPtr, "-help" ) + || ! strcmp( argPtr, "h" ) + ) { + writeHelpMessage: + fputs( +"testfloat [