Only in libfloat: CVS Only in libfloat: Makefile Only in libfloat: fplib_glue.S Only in libfloat: libfloat.spec diff -uwbBpr libfloat/processors/386-gcc.h SoftFloat-2a/processors/386-gcc.h --- libfloat/processors/386-gcc.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/processors/386-gcc.h Mon Sep 20 11:46:44 1999 @@ -32,8 +32,8 @@ typedef int int16; typedef unsigned int uint32; typedef signed int int32; #ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; +typedef unsigned long long int uint64; +typedef signed long long int int64; #endif /* @@ -51,16 +51,16 @@ typedef signed short int sbits16; typedef unsigned int bits32; typedef signed int sbits32; #ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; +typedef unsigned long long int bits64; +typedef signed long long int sbits64; #endif #ifdef BITS64 /* ------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and if -necessary ``marks'' the literal as having a 64-bit integer type. For -example, the Gnu C Compiler (`gcc') requires that 64-bit literals be +The `LIT64' macro takes as its argument a textual integer literal and +if necessary ``marks'' the literal as having a 64-bit integer type. +For example, the GNU C Compiler (`gcc') requires that 64-bit literals be appended with the letters `LL' standing for `long long', which is `gcc's name for the 64-bit integer type. Some compilers may allow `LIT64' to be defined as the identity macro: `#define LIT64( a ) a'. Only in libfloat/processors: ARM-gcc.h Only in libfloat/processors: CVS diff -uwbBpr libfloat/processors/SPARC-gcc.h SoftFloat-2a/processors/SPARC-gcc.h --- libfloat/processors/SPARC-gcc.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/processors/SPARC-gcc.h Mon Sep 20 11:55:41 1999 @@ -32,8 +32,8 @@ typedef int int16; typedef unsigned int uint32; typedef signed int int32; #ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; +typedef unsigned long long int uint64; +typedef signed long long int int64; #endif /* @@ -51,16 +51,16 @@ typedef signed short int sbits16; typedef unsigned int bits32; typedef signed int sbits32; #ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; +typedef unsigned long long int bits64; +typedef signed long long int sbits64; #endif #ifdef BITS64 /* ------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and if -necessary ``marks'' the literal as having a 64-bit integer type. For -example, the Gnu C Compiler (`gcc') requires that 64-bit literals be +The `LIT64' macro takes as its argument a textual integer literal and +if necessary ``marks'' the literal as having a 64-bit integer type. +For example, the GNU C Compiler (`gcc') requires that 64-bit literals be appended with the letters `LL' standing for `long long', which is `gcc's name for the 64-bit integer type. Some compilers may allow `LIT64' to be defined as the identity macro: `#define LIT64( a ) a'. Only in libfloat/softfloat: CVS diff -uwbBpr libfloat/softfloat/README.txt SoftFloat-2a/softfloat/README.txt --- libfloat/softfloat/README.txt Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/README.txt Mon Sep 20 11:46:46 1999 @@ -1,25 +1,26 @@ -Package Overview for SoftFloat Release 2 +Package Overview for SoftFloat Release 2a John R. Hauser -1997 June 13 +1998 December 13 SoftFloat is a software implementation of floating-point that conforms to -the IEC/IEEE Standard for Binary Floating-point Arithmetic. SoftFloat is +the IEC/IEEE Standard for Binary Floating-Point Arithmetic. SoftFloat is distributed in the form of C source code. Compiling the SoftFloat sources generates two things: -- A SoftFloat object file (typically `softfloat.o') containing the complete set of IEC/IEEE floating-point routines. --- A `timesoftfloat' executable program for evaluating the speed of the - SoftFloat routines. (The SoftFloat module is linked into this program.) +-- A `timesoftfloat' program for evaluating the speed of the SoftFloat + routines. (The SoftFloat module is linked into this program.) -The SoftFloat package is documented in three text files: +The SoftFloat package is documented in four text files: softfloat.txt Documentation for using the SoftFloat functions. softfloat-source.txt Documentation for compiling SoftFloat. + softfloat-history.txt History of major changes to SoftFloat. timesoftfloat.txt Documentation for using `timesoftfloat'. Other files in the package comprise the source code for SoftFloat. @@ -33,5 +34,5 @@ You should not attempt to compile SoftFl At the time of this writing, the most up-to-date information about SoftFloat and the latest release can be found at the Web page `http:// -HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/softfloat.html'. +HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/SoftFloat.html'. Only in libfloat/softfloat/bits32/386-Win32-gcc: CVS diff -uwbBpr libfloat/softfloat/bits32/386-Win32-gcc/Makefile SoftFloat-2a/softfloat/bits32/386-Win32-gcc/Makefile --- libfloat/softfloat/bits32/386-Win32-gcc/Makefile Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/386-Win32-gcc/Makefile Mon Sep 20 11:46:58 1999 @@ -1,25 +1,24 @@ -PROCESSOR_DIR = ../../../processors -PROCESSOR_H = $(PROCESSOR_DIR)/386-gcc.h +PROCESSOR_H = ../../../processors/386-gcc.h SOFTFLOAT_MACROS = ../softfloat-macros -CC = gcc -CINCLUDES = -I. -I.. -I- -CFLAGS = -O2 -LINK = gcc -LFLAGS = -TIMESOFTFLOAT_EXE = timesoftfloat.exe -ALL: softfloat.o $(TIMESOFTFLOAT_EXE) +OBJ = .o +EXE = .exe +INCLUDES = -I. -I.. +COMPILE_C = gcc -c -o $@ $(INCLUDES) -I- -O2 +LINK = gcc -o $@ + +ALL: softfloat$(OBJ) timesoftfloat$(EXE) milieu.h: $(PROCESSOR_H) touch milieu.h -softfloat.o: milieu.h softfloat.h softfloat-specialize $(SOFTFLOAT_MACROS) ../softfloat.c - $(CC) $(CINCLUDES) $(CFLAGS) -c ../softfloat.c +softfloat$(OBJ): milieu.h softfloat.h softfloat-specialize $(SOFTFLOAT_MACROS) ../softfloat.c + $(COMPILE_C) ../softfloat.c -timesoftfloat.o: milieu.h softfloat.h ../timesoftfloat.c - $(CC) $(CINCLUDES) $(CFLAGS) -c ../timesoftfloat.c +timesoftfloat$(OBJ): milieu.h softfloat.h ../timesoftfloat.c + $(COMPILE_C) ../timesoftfloat.c -$(TIMESOFTFLOAT_EXE): softfloat.o timesoftfloat.o - $(LINK) $(LFLAGS) -o $(TIMESOFTFLOAT_EXE) softfloat.o timesoftfloat.o +timesoftfloat$(EXE): softfloat$(OBJ) timesoftfloat$(OBJ) + $(LINK) softfloat$(OBJ) timesoftfloat$(OBJ) diff -uwbBpr libfloat/softfloat/bits32/386-Win32-gcc/milieu.h SoftFloat-2a/softfloat/bits32/386-Win32-gcc/milieu.h --- libfloat/softfloat/bits32/386-Win32-gcc/milieu.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/386-Win32-gcc/milieu.h Mon Sep 20 11:46:59 1999 @@ -3,7 +3,7 @@ =============================================================================== This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -12,8 +12,8 @@ National Science Foundation under grant 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://http.cs.berkeley.edu/~jhauser/ -arithmetic/softfloat.html'. +is available through the Web page `http://HTTP.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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== diff -uwbBpr libfloat/softfloat/bits32/386-Win32-gcc/softfloat-specialize SoftFloat-2a/softfloat/bits32/386-Win32-gcc/softfloat-specialize --- libfloat/softfloat/bits32/386-Win32-gcc/softfloat-specialize Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/386-Win32-gcc/softfloat-specialize Mon Sep 20 11:47:00 1999 @@ -3,7 +3,7 @@ =============================================================================== This C source fragment is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -12,8 +12,8 @@ National Science Foundation under grant 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://http.cs.berkeley.edu/~jhauser/ -arithmetic/softfloat.html'. +is available through the Web page `http://HTTP.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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== @@ -40,8 +40,8 @@ int8 float_detect_tininess = float_tinin /* ------------------------------------------------------------------------------- Raises the exceptions specified by `flags'. Floating-point traps can be -defined here if desired. It is currently not possible for such a trap to -substitute a result value. If traps are not implemented, this routine +defined here if desired. It is currently not possible for such a trap +to substitute a result value. If traps are not implemented, this routine should be simply `float_exception_flags |= flags;'. ------------------------------------------------------------------------------- */ diff -uwbBpr libfloat/softfloat/bits32/386-Win32-gcc/softfloat.h SoftFloat-2a/softfloat/bits32/386-Win32-gcc/softfloat.h --- libfloat/softfloat/bits32/386-Win32-gcc/softfloat.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/386-Win32-gcc/softfloat.h Mon Sep 20 11:47:00 1999 @@ -3,7 +3,7 @@ =============================================================================== This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -12,8 +12,8 @@ National Science Foundation under grant 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://http.cs.berkeley.edu/~jhauser/ -arithmetic/softfloat.html'. +is available through the Web page `http://HTTP.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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== Only in libfloat/softfloat/bits32: ARM-gcc Only in libfloat/softfloat/bits32: CVS Only in SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc: .pure Only in libfloat/softfloat/bits32/SPARC-Solaris-gcc: CVS diff -uwbBpr libfloat/softfloat/bits32/SPARC-Solaris-gcc/Makefile SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/Makefile --- libfloat/softfloat/bits32/SPARC-Solaris-gcc/Makefile Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/Makefile Mon Sep 20 12:10:32 1999 @@ -1,25 +1,24 @@ -PROCESSOR_DIR = ../../../processors -PROCESSOR_H = $(PROCESSOR_DIR)/SPARC-gcc.h +PROCESSOR_H = ../../../processors/SPARC-gcc.h SOFTFLOAT_MACROS = ../softfloat-macros -CC = gcc -CINCLUDES = -I. -I.. -I- -CFLAGS = -O2 -LINK = gcc -LFLAGS = -TIMESOFTFLOAT_EXE = timesoftfloat -ALL: softfloat.o $(TIMESOFTFLOAT_EXE) +OBJ = .o +EXE = +INCLUDES = -I. -I.. +COMPILE_C = gcc -c -o $@ $(INCLUDES) -I- -O2 +LINK = gcc -o $@ + +ALL: softfloat$(OBJ) timesoftfloat$(EXE) milieu.h: $(PROCESSOR_H) touch milieu.h -softfloat.o: milieu.h softfloat.h softfloat-specialize $(SOFTFLOAT_MACROS) ../softfloat.c - $(CC) $(CINCLUDES) $(CFLAGS) -c ../softfloat.c +softfloat$(OBJ): milieu.h softfloat.h softfloat-specialize $(SOFTFLOAT_MACROS) ../softfloat.c + $(COMPILE_C) ../softfloat.c -timesoftfloat.o: milieu.h softfloat.h ../timesoftfloat.c - $(CC) $(CINCLUDES) $(CFLAGS) -c ../timesoftfloat.c +timesoftfloat$(OBJ): milieu.h softfloat.h ../timesoftfloat.c + $(COMPILE_C) ../timesoftfloat.c -$(TIMESOFTFLOAT_EXE): softfloat.o timesoftfloat.o - $(LINK) $(LFLAGS) -o $(TIMESOFTFLOAT_EXE) softfloat.o timesoftfloat.o +timesoftfloat$(EXE): softfloat$(OBJ) timesoftfloat$(OBJ) + $(LINK) softfloat$(OBJ) timesoftfloat$(OBJ) diff -uwbBpr libfloat/softfloat/bits32/SPARC-Solaris-gcc/milieu.h SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/milieu.h --- libfloat/softfloat/bits32/SPARC-Solaris-gcc/milieu.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/milieu.h Mon Sep 20 12:10:59 1999 @@ -3,7 +3,7 @@ =============================================================================== This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -12,8 +12,8 @@ National Science Foundation under grant 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://http.cs.berkeley.edu/~jhauser/ -arithmetic/softfloat.html'. +is available through the Web page `http://HTTP.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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== diff -uwbBpr libfloat/softfloat/bits32/SPARC-Solaris-gcc/softfloat-specialize SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/softfloat-specialize --- libfloat/softfloat/bits32/SPARC-Solaris-gcc/softfloat-specialize Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/softfloat-specialize Mon Sep 20 12:11:19 1999 @@ -3,7 +3,7 @@ =============================================================================== This C source fragment is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -12,8 +12,8 @@ National Science Foundation under grant 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://http.cs.berkeley.edu/~jhauser/ -arithmetic/softfloat.html'. +is available through the Web page `http://HTTP.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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== @@ -40,8 +40,8 @@ int8 float_detect_tininess = float_tinin /* ------------------------------------------------------------------------------- Raises the exceptions specified by `flags'. Floating-point traps can be -defined here if desired. It is currently not possible for such a trap to -substitute a result value. If traps are not implemented, this routine +defined here if desired. It is currently not possible for such a trap +to substitute a result value. If traps are not implemented, this routine should be simply `float_exception_flags |= flags;'. ------------------------------------------------------------------------------- */ diff -uwbBpr libfloat/softfloat/bits32/SPARC-Solaris-gcc/softfloat.h SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/softfloat.h --- libfloat/softfloat/bits32/SPARC-Solaris-gcc/softfloat.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/SPARC-Solaris-gcc/softfloat.h Mon Sep 20 12:11:27 1999 @@ -3,7 +3,7 @@ =============================================================================== This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -13,7 +13,7 @@ of this code was written as part of a pr 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://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/softfloat.html'. +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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== diff -uwbBpr libfloat/softfloat/bits32/softfloat-macros SoftFloat-2a/softfloat/bits32/softfloat-macros --- libfloat/softfloat/bits32/softfloat-macros Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/softfloat-macros Mon Sep 20 11:46:52 1999 @@ -3,7 +3,7 @@ =============================================================================== This C source fragment is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -12,8 +12,8 @@ National Science Foundation under grant 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://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/softfloat.html'. +is available through the Web page `http://HTTP.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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== @@ -225,9 +225,9 @@ INLINE void /* ------------------------------------------------------------------------------- -Shifts the 96-bit value formed by concatenating `a0', `a1', and `a2' left by -the number of bits given in `count'. Any bits shifted off are lost. The -value of `count' must be less than 32. The result is broken into three +Shifts the 96-bit value formed by concatenating `a0', `a1', and `a2' left +by the number of bits given in `count'. Any bits shifted off are lost. +The value of `count' must be less than 32. The result is broken into three 32-bit pieces which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'. ------------------------------------------------------------------------------- @@ -409,8 +409,8 @@ INLINE void mul32To64( bits32 a, bits32 /* ------------------------------------------------------------------------------- -Multiplies the 64-bit value formed by concatenating `a0' and `a1' by `b' to -obtain a 96-bit product. The product is broken into three 32-bit pieces +Multiplies the 64-bit value formed by concatenating `a0' and `a1' by `b' +to obtain a 96-bit product. The product is broken into three 32-bit pieces which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'. ------------------------------------------------------------------------------- @@ -477,10 +477,10 @@ INLINE void /* ------------------------------------------------------------------------------- Returns an approximation to the 32-bit integer quotient obtained by dividing -`b' into the 64-bit value formed by concatenating `a0' and `a1'. The divisor -`b' must be at least 2^31. If q is the exact quotient truncated toward -zero, the approximation returned lies between q and q + 2 inclusive. If -the exact quotient q is larger than 32 bits, the maximum positive 32-bit +`b' into the 64-bit value formed by concatenating `a0' and `a1'. The +divisor `b' must be at least 2^31. If q is the exact quotient truncated +toward zero, the approximation returned lies between q and q + 2 inclusive. +If the exact quotient q is larger than 32 bits, the maximum positive 32-bit unsigned integer is returned. ------------------------------------------------------------------------------- */ @@ -548,8 +548,8 @@ static bits32 estimateSqrt32( int16 aExp /* ------------------------------------------------------------------------------- -Returns the number of leading 0 bits before the most-significant 1 bit -of `a'. If `a' is zero, 32 is returned. +Returns the number of leading 0 bits before the most-significant 1 bit of +`a'. If `a' is zero, 32 is returned. ------------------------------------------------------------------------------- */ static int8 countLeadingZeros32( bits32 a ) @@ -590,8 +590,8 @@ static int8 countLeadingZeros32( bits32 /* ------------------------------------------------------------------------------- -Returns 1 if the 64-bit value formed by concatenating `a0' and `a1' is equal -to the 64-bit value formed by concatenating `b0' and `b1'. Otherwise, +Returns 1 if the 64-bit value formed by concatenating `a0' and `a1' is +equal to the 64-bit value formed by concatenating `b0' and `b1'. Otherwise, returns 0. ------------------------------------------------------------------------------- */ diff -uwbBpr libfloat/softfloat/bits32/softfloat.c SoftFloat-2a/softfloat/bits32/softfloat.c --- libfloat/softfloat/bits32/softfloat.c Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/softfloat.c Mon Sep 20 11:46:53 1999 @@ -2,8 +2,8 @@ /* =============================================================================== -This C source file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +This C source file is part of the SoftFloat IEC/IEEE Floating-Point +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -12,8 +12,8 @@ National Science Foundation under grant 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://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/softfloat.html'. +is available through the Web page `http://HTTP.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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== @@ -142,7 +142,7 @@ and significand `zSig', and returns the point value corresponding to the abstract input. Ordinarily, the abstract value is simply rounded and packed into the single-precision format, with the inexact exception raised if the abstract input cannot be represented -exactly. If the abstract value is too large, however, the overflow and +exactly. However, if the abstract value is too large, the overflow and inexact exceptions are raised and an infinity or maximal finite value is returned. If the abstract value is too small, the input value is rounded to a subnormal number, and the underflow and inexact exceptions are raised if @@ -155,7 +155,7 @@ significand must be normalized or smalle and it must not require rounding. In the usual case that `zSig' is normalized, `zExp' must be 1 less than the ``true'' floating-point exponent. The handling of underflow and overflow follows the IEC/IEEE Standard for -Binary Floating-point Arithmetic. +Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ static float32 roundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig ) @@ -215,9 +215,9 @@ static float32 roundAndPackFloat32( flag Takes an abstract floating-point value having sign `zSign', exponent `zExp', and significand `zSig', and returns the proper single-precision floating- point value corresponding to the abstract input. This routine is just like -`roundAndPackFloat32' except that `zSig' does not have to be normalized in -any way. In all cases, `zExp' must be 1 less than the ``true'' floating- -point exponent. +`roundAndPackFloat32' except that `zSig' does not have to be normalized. +Bit 31 of `zSig' must be zero, and `zExp' must be 1 less than the ``true'' +floating-point exponent. ------------------------------------------------------------------------------- */ static float32 @@ -353,8 +353,8 @@ and extended significand formed by the c and `zSig2', and returns the proper double-precision floating-point value corresponding to the abstract input. Ordinarily, the abstract value is simply rounded and packed into the double-precision format, with the inexact -exception raised if the abstract input cannot be represented exactly. If -the abstract value is too large, however, the overflow and inexact +exception raised if the abstract input cannot be represented exactly. +However, if the abstract value is too large, the overflow and inexact exceptions are raised and an infinity or maximal finite value is returned. If the abstract value is too small, the input value is rounded to a subnormal number, and the underflow and inexact exceptions are raised if the @@ -365,7 +365,7 @@ significand is not normalized, `zExp' mu returned is a subnormal number, and it must not require rounding. In the usual case that the input significand is normalized, `zExp' must be 1 less than the ``true'' floating-point exponent. The handling of underflow and -overflow follows the IEC/IEEE Standard for Binary Floating-point Arithmetic. +overflow follows the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ static float64 @@ -446,10 +446,10 @@ static float64 ------------------------------------------------------------------------------- Takes an abstract floating-point value having sign `zSign', exponent `zExp', and significand formed by the concatenation of `zSig0' and `zSig1', and -returns the proper double-precision floating-point value corresponding to -the abstract input. This routine is just like `roundAndPackFloat64' except -that the input significand has fewer bits and does not have to be normalized -in any way. In all cases, `zExp' must be 1 less than the ``true'' floating- +returns the proper double-precision floating-point value corresponding +to the abstract input. This routine is just like `roundAndPackFloat64' +except that the input significand has fewer bits and does not have to be +normalized. In all cases, `zExp' must be 1 less than the ``true'' floating- point exponent. ------------------------------------------------------------------------------- */ @@ -483,7 +483,7 @@ static float64 ------------------------------------------------------------------------------- Returns the result of converting the 32-bit two's complement integer `a' to the single-precision floating-point format. The conversion is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 int32_to_float32( int32 a ) @@ -491,7 +491,7 @@ float32 int32_to_float32( int32 a ) flag zSign; if ( a == 0 ) return 0; - if ( a == 0x80000000 ) return packFloat32( 1, 0x9E, 0 ); + if ( a == (sbits32) 0x80000000 ) return packFloat32( 1, 0x9E, 0 ); zSign = ( a < 0 ); return normalizeRoundAndPackFloat32( zSign, 0x9C, zSign ? - a : a ); @@ -501,7 +501,7 @@ float32 int32_to_float32( int32 a ) ------------------------------------------------------------------------------- Returns the result of converting the 32-bit two's complement integer `a' to the double-precision floating-point format. The conversion is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 int32_to_float64( int32 a ) @@ -530,7 +530,7 @@ float64 int32_to_float64( int32 a ) ------------------------------------------------------------------------------- Returns the result of converting the single-precision floating-point value `a' to the 32-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-point +performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic---which means in particular that the conversion is rounded according to the current rounding mode. If `a' is a NaN, the largest positive integer is returned. Otherwise, if the conversion overflows, the @@ -541,7 +541,7 @@ int32 float32_to_int32( float32 a ) { flag aSign; int16 aExp, shiftCount; - bits32 aSig, zExtra; + bits32 aSig, aSigExtra; int32 z; int8 roundingMode; @@ -551,41 +551,44 @@ int32 float32_to_int32( float32 a ) shiftCount = aExp - 0x96; if ( 0 <= shiftCount ) { if ( 0x9E <= aExp ) { - if ( a == 0xCF000000 ) return 0x80000000; + if ( a != 0xCF000000 ) { float_raise( float_flag_invalid ); - if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF; - return 0x80000000; + if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) { + return 0x7FFFFFFF; + } + } + return (sbits32) 0x80000000; } z = ( aSig | 0x00800000 )<>( - shiftCount ); } - if ( zExtra ) float_exception_flags |= float_flag_inexact; + if ( aSigExtra ) float_exception_flags |= float_flag_inexact; roundingMode = float_rounding_mode; if ( roundingMode == float_round_nearest_even ) { - if ( (sbits32) zExtra < 0 ) { + if ( (sbits32) aSigExtra < 0 ) { ++z; - if ( (bits32) ( zExtra<<1 ) == 0 ) z &= ~1; + if ( (bits32) ( aSigExtra<<1 ) == 0 ) z &= ~1; } if ( aSign ) z = - z; } else { - zExtra = ( zExtra != 0 ); + aSigExtra = ( aSigExtra != 0 ); if ( aSign ) { - z += ( roundingMode == float_round_down ) & zExtra; + z += ( roundingMode == float_round_down ) & aSigExtra; z = - z; } else { - z += ( roundingMode == float_round_up ) & zExtra; + z += ( roundingMode == float_round_up ) & aSigExtra; } } } @@ -597,10 +600,10 @@ int32 float32_to_int32( float32 a ) ------------------------------------------------------------------------------- Returns the result of converting the single-precision floating-point value `a' to the 32-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-point -Arithmetic, except that the conversion is always rounded toward zero. If -`a' is a NaN, the largest positive integer is returned. Otherwise, if the -conversion overflows, the largest integer with the same sign as `a' is +performed according to the IEC/IEEE Standard for Binary Floating-Point +Arithmetic, except that the conversion is always rounded toward zero. +If `a' is a NaN, the largest positive integer is returned. Otherwise, if +the conversion overflows, the largest integer with the same sign as `a' is returned. ------------------------------------------------------------------------------- */ @@ -616,10 +619,11 @@ int32 float32_to_int32_round_to_zero( fl aSign = extractFloat32Sign( a ); shiftCount = aExp - 0x9E; if ( 0 <= shiftCount ) { - if ( a == 0xCF000000 ) return 0x80000000; + if ( a != 0xCF000000 ) { float_raise( float_flag_invalid ); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF; - return 0x80000000; + } + return (sbits32) 0x80000000; } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) float_exception_flags |= float_flag_inexact; @@ -630,7 +634,8 @@ int32 float32_to_int32_round_to_zero( fl if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) { float_exception_flags |= float_flag_inexact; } - return aSign ? - z : z; + if ( aSign ) z = - z; + return z; } @@ -638,7 +643,7 @@ int32 float32_to_int32_round_to_zero( fl ------------------------------------------------------------------------------- Returns the result of converting the single-precision floating-point value `a' to the double-precision floating-point format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-point +performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ @@ -667,10 +672,10 @@ float64 float32_to_float64( float32 a ) /* ------------------------------------------------------------------------------- -Rounds the single-precision floating-point value `a' to an integer, and -returns the result as a single-precision floating-point value. The +Rounds the single-precision floating-point value `a' to an integer, +and returns the result as a single-precision floating-point value. The operation is performed according to the IEC/IEEE Standard for Binary -Floating-point Arithmetic. +Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 float32_round_to_int( float32 a ) @@ -728,10 +733,10 @@ float32 float32_round_to_int( float32 a /* ------------------------------------------------------------------------------- Returns the result of adding the absolute values of the single-precision -floating-point values `a' and `b'. If `zSign' is true, the sum is negated -before being returned. `zSign' is ignored if the result is a NaN. The -addition is performed according to the IEC/IEEE Standard for Binary -Floating-point Arithmetic. +floating-point values `a' and `b'. If `zSign' is 1, the sum is negated +before being returned. `zSign' is ignored if the result is a NaN. +The addition is performed according to the IEC/IEEE Standard for Binary +Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ static float32 addFloat32Sigs( float32 a, float32 b, flag zSign ) @@ -800,10 +805,10 @@ static float32 addFloat32Sigs( float32 a /* ------------------------------------------------------------------------------- Returns the result of subtracting the absolute values of the single- -precision floating-point values `a' and `b'. If `zSign' is true, the +precision floating-point values `a' and `b'. If `zSign' is 1, the difference is negated before being returned. `zSign' is ignored if the result is a NaN. The subtraction is performed according to the IEC/IEEE -Standard for Binary Floating-point Arithmetic. +Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ static float32 subFloat32Sigs( float32 a, float32 b, flag zSign ) @@ -877,7 +882,7 @@ static float32 subFloat32Sigs( float32 a ------------------------------------------------------------------------------- Returns the result of adding the single-precision floating-point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard for -Binary Floating-point Arithmetic. +Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 float32_add( float32 a, float32 b ) @@ -899,7 +904,7 @@ float32 float32_add( float32 a, float32 ------------------------------------------------------------------------------- Returns the result of subtracting the single-precision floating-point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-point Arithmetic. +for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 float32_sub( float32 a, float32 b ) @@ -921,7 +926,7 @@ float32 float32_sub( float32 a, float32 ------------------------------------------------------------------------------- Returns the result of multiplying the single-precision floating-point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-point Arithmetic. +for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 float32_mul( float32 a, float32 b ) @@ -979,17 +984,15 @@ float32 float32_mul( float32 a, float32 /* ------------------------------------------------------------------------------- Returns the result of dividing the single-precision floating-point value `a' -by the corresponding value `b'. The operation is performed according to -the IEC/IEEE Standard for Binary Floating-point Arithmetic. +by the corresponding value `b'. The operation is performed according to the +IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 float32_div( float32 a, float32 b ) { flag aSign, bSign, zSign; int16 aExp, bExp, zExp; - bits32 aSig, bSig, zSig; - bits32 rem0, rem1; - bits32 term0, term1; + bits32 aSig, bSig, zSig, rem0, rem1, term0, term1; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); @@ -1051,15 +1054,14 @@ float32 float32_div( float32 a, float32 ------------------------------------------------------------------------------- Returns the remainder of the single-precision floating-point value `a' with respect to the corresponding value `b'. The operation is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 float32_rem( float32 a, float32 b ) { flag aSign, bSign, zSign; int16 aExp, bExp, expDiff; - bits32 aSig, bSig; - bits32 q, allZero, alternateASig; + bits32 aSig, bSig, q, allZero, alternateASig; sbits32 sigMean; aSig = extractFloat32Frac( a ); @@ -1137,16 +1139,14 @@ float32 float32_rem( float32 a, float32 ------------------------------------------------------------------------------- Returns the square root of the single-precision floating-point value `a'. The operation is performed according to the IEC/IEEE Standard for Binary -Floating-point Arithmetic. +Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float32 float32_sqrt( float32 a ) { flag aSign; int16 aExp, zExp; - bits32 aSig, zSig; - bits32 rem0, rem1; - bits32 term0, term1; + bits32 aSig, zSig, rem0, rem1, term0, term1; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); @@ -1171,7 +1171,8 @@ float32 float32_sqrt( float32 a ) zSig = estimateSqrt32( aExp, aSig ) + 2; if ( ( zSig & 0x7F ) <= 5 ) { if ( zSig < 2 ) { - zSig = 0xFFFFFFFF; + zSig = 0x7FFFFFFF; + goto roundAndPack; } else { aSig >>= aExp & 1; @@ -1187,15 +1188,16 @@ float32 float32_sqrt( float32 a ) } } shift32RightJamming( zSig, 1, &zSig ); + roundAndPack: return roundAndPackFloat32( 0, zExp, zSig ); } /* ------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is equal to the -corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +Returns 1 if the single-precision floating-point value `a' is equal to +the corresponding value `b', and 0 otherwise. The comparison is performed +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float32_eq( float32 a, float32 b ) @@ -1215,9 +1217,9 @@ flag float32_eq( float32 a, float32 b ) /* ------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is less than or -equal to the corresponding value `b', and 0 otherwise. The comparison is -performed according to the IEC/IEEE Standard for Binary Floating-point +Returns 1 if the single-precision floating-point value `a' is less than +or equal to the corresponding value `b', and 0 otherwise. The comparison +is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ @@ -1242,7 +1244,7 @@ flag float32_le( float32 a, float32 b ) ------------------------------------------------------------------------------- Returns 1 if the single-precision floating-point value `a' is less than the corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float32_lt( float32 a, float32 b ) @@ -1264,10 +1266,10 @@ flag float32_lt( float32 a, float32 b ) /* ------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is equal to the -corresponding value `b', and 0 otherwise. The invalid exception is raised -if either operand is a NaN. Otherwise, the comparison is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +Returns 1 if the single-precision floating-point value `a' is equal to +the corresponding value `b', and 0 otherwise. The invalid exception is +raised if either operand is a NaN. Otherwise, the comparison is performed +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float32_eq_signaling( float32 a, float32 b ) @@ -1288,7 +1290,7 @@ flag float32_eq_signaling( float32 a, fl Returns 1 if the single-precision floating-point value `a' is less than or equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the -IEC/IEEE Standard for Binary Floating-point Arithmetic. +IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float32_le_quiet( float32 a, float32 b ) @@ -1316,7 +1318,7 @@ flag float32_le_quiet( float32 a, float3 Returns 1 if the single-precision floating-point value `a' is less than the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the IEC/IEEE -Standard for Binary Floating-point Arithmetic. +Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float32_lt_quiet( float32 a, float32 b ) @@ -1342,7 +1344,7 @@ flag float32_lt_quiet( float32 a, float3 ------------------------------------------------------------------------------- Returns the result of converting the double-precision floating-point value `a' to the 32-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-point +performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic---which means in particular that the conversion is rounded according to the current rounding mode. If `a' is a NaN, the largest positive integer is returned. Otherwise, if the conversion overflows, the @@ -1353,7 +1355,7 @@ int32 float64_to_int32( float64 a ) { flag aSign; int16 aExp, shiftCount; - bits32 aSig0, aSig1, absZ, zExtra; + bits32 aSig0, aSig1, absZ, aSigExtra; int32 z; int8 roundingMode; @@ -1363,50 +1365,50 @@ int32 float64_to_int32( float64 a ) aSign = extractFloat64Sign( a ); shiftCount = aExp - 0x413; if ( 0 <= shiftCount ) { - if ( 11 < shiftCount ) { + if ( 0x41E < aExp ) { if ( ( aExp == 0x7FF ) && ( aSig0 | aSig1 ) ) aSign = 0; - absZ = 0xC0000000; + goto invalid; } - else { shortShift64Left( - aSig0 | 0x00100000, aSig1, shiftCount, &absZ, &zExtra ); - if ( 0xC0000000 < absZ ) absZ = 0xC0000000; - } + aSig0 | 0x00100000, aSig1, shiftCount, &absZ, &aSigExtra ); + if ( 0x80000000 < absZ ) goto invalid; } else { aSig1 = ( aSig1 != 0 ); if ( aExp < 0x3FE ) { - zExtra = aExp | aSig0 | aSig1; + aSigExtra = aExp | aSig0 | aSig1; absZ = 0; } else { aSig0 |= 0x00100000; - zExtra = ( aSig0<<( shiftCount & 31 ) ) | aSig1; + aSigExtra = ( aSig0<<( shiftCount & 31 ) ) | aSig1; absZ = aSig0>>( - shiftCount ); } } roundingMode = float_rounding_mode; if ( roundingMode == float_round_nearest_even ) { - if ( (sbits32) zExtra < 0 ) { + if ( (sbits32) aSigExtra < 0 ) { ++absZ; - if ( (bits32) ( zExtra<<1 ) == 0 ) absZ &= ~1; + if ( (bits32) ( aSigExtra<<1 ) == 0 ) absZ &= ~1; } z = aSign ? - absZ : absZ; } else { - zExtra = ( zExtra != 0 ); + aSigExtra = ( aSigExtra != 0 ); if ( aSign ) { - z = - ( absZ + ( ( roundingMode == float_round_down ) & zExtra ) ); + z = - ( absZ + + ( ( roundingMode == float_round_down ) & aSigExtra ) ); } else { - z = absZ + ( ( roundingMode == float_round_up ) & zExtra ); + z = absZ + ( ( roundingMode == float_round_up ) & aSigExtra ); } } if ( ( aSign ^ ( z < 0 ) ) && z ) { + invalid: float_raise( float_flag_invalid ); - return aSign ? 0x80000000 : 0x7FFFFFFF; + return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF; } - if ( zExtra ) float_exception_flags |= float_flag_inexact; + if ( aSigExtra ) float_exception_flags |= float_flag_inexact; return z; } @@ -1415,10 +1417,10 @@ int32 float64_to_int32( float64 a ) ------------------------------------------------------------------------------- Returns the result of converting the double-precision floating-point value `a' to the 32-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-point -Arithmetic, except that the conversion is always rounded toward zero. If -`a' is a NaN, the largest positive integer is returned. Otherwise, if the -conversion overflows, the largest integer with the same sign as `a' is +performed according to the IEC/IEEE Standard for Binary Floating-Point +Arithmetic, except that the conversion is always rounded toward zero. +If `a' is a NaN, the largest positive integer is returned. Otherwise, if +the conversion overflows, the largest integer with the same sign as `a' is returned. ------------------------------------------------------------------------------- */ @@ -1426,9 +1428,8 @@ int32 float64_to_int32_round_to_zero( fl { flag aSign; int16 aExp, shiftCount; - bits32 aSig0, aSig1, absZ, zExtra; + bits32 aSig0, aSig1, absZ, aSigExtra; int32 z; - int8 roundingMode; aSig1 = extractFloat64Frac1( a ); aSig0 = extractFloat64Frac0( a ); @@ -1436,32 +1437,31 @@ int32 float64_to_int32_round_to_zero( fl aSign = extractFloat64Sign( a ); shiftCount = aExp - 0x413; if ( 0 <= shiftCount ) { - if ( 11 < shiftCount ) { + if ( 0x41E < aExp ) { if ( ( aExp == 0x7FF ) && ( aSig0 | aSig1 ) ) aSign = 0; - absZ = 0xC0000000; + goto invalid; } - else { shortShift64Left( - aSig0 | 0x00100000, aSig1, shiftCount, &absZ, &zExtra ); - } + aSig0 | 0x00100000, aSig1, shiftCount, &absZ, &aSigExtra ); } else { - if ( aExp < 0x3FE ) { - zExtra = aExp | aSig0 | aSig1; - absZ = 0; + if ( aExp < 0x3FF ) { + if ( aExp | aSig0 | aSig1 ) { + float_exception_flags |= float_flag_inexact; + } + return 0; } - else { aSig0 |= 0x00100000; - zExtra = ( aSig0<<( shiftCount & 31 ) ) | aSig1; + aSigExtra = ( aSig0<<( shiftCount & 31 ) ) | aSig1; absZ = aSig0>>( - shiftCount ); } - } z = aSign ? - absZ : absZ; if ( ( aSign ^ ( z < 0 ) ) && z ) { + invalid: float_raise( float_flag_invalid ); - return aSign ? 0x80000000 : 0x7FFFFFFF; + return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF; } - if ( zExtra ) float_exception_flags |= float_flag_inexact; + if ( aSigExtra ) float_exception_flags |= float_flag_inexact; return z; } @@ -1470,7 +1470,7 @@ int32 float64_to_int32_round_to_zero( fl ------------------------------------------------------------------------------- Returns the result of converting the double-precision floating-point value `a' to the single-precision floating-point format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-point +performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ @@ -1499,10 +1499,10 @@ float32 float64_to_float32( float64 a ) /* ------------------------------------------------------------------------------- -Rounds the double-precision floating-point value `a' to an integer, and -returns the result as a double-precision floating-point value. The +Rounds the double-precision floating-point value `a' to an integer, +and returns the result as a double-precision floating-point value. The operation is performed according to the IEC/IEEE Standard for Binary -Floating-point Arithmetic. +Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 float64_round_to_int( float64 a ) @@ -1602,10 +1602,10 @@ float64 float64_round_to_int( float64 a /* ------------------------------------------------------------------------------- Returns the result of adding the absolute values of the double-precision -floating-point values `a' and `b'. If `zSign' is true, the sum is negated -before being returned. `zSign' is ignored if the result is a NaN. The -addition is performed according to the IEC/IEEE Standard for Binary -Floating-point Arithmetic. +floating-point values `a' and `b'. If `zSign' is 1, the sum is negated +before being returned. `zSign' is ignored if the result is a NaN. +The addition is performed according to the IEC/IEEE Standard for Binary +Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ static float64 addFloat64Sigs( float64 a, float64 b, flag zSign ) @@ -1680,10 +1680,10 @@ static float64 addFloat64Sigs( float64 a /* ------------------------------------------------------------------------------- Returns the result of subtracting the absolute values of the double- -precision floating-point values `a' and `b'. If `zSign' is true, the +precision floating-point values `a' and `b'. If `zSign' is 1, the difference is negated before being returned. `zSign' is ignored if the result is a NaN. The subtraction is performed according to the IEC/IEEE -Standard for Binary Floating-point Arithmetic. +Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ static float64 subFloat64Sigs( float64 a, float64 b, flag zSign ) @@ -1766,7 +1766,7 @@ static float64 subFloat64Sigs( float64 a ------------------------------------------------------------------------------- Returns the result of adding the double-precision floating-point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard for -Binary Floating-point Arithmetic. +Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 float64_add( float64 a, float64 b ) @@ -1788,7 +1788,7 @@ float64 float64_add( float64 a, float64 ------------------------------------------------------------------------------- Returns the result of subtracting the double-precision floating-point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-point Arithmetic. +for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 float64_sub( float64 a, float64 b ) @@ -1810,7 +1810,7 @@ float64 float64_sub( float64 a, float64 ------------------------------------------------------------------------------- Returns the result of multiplying the double-precision floating-point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-point Arithmetic. +for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 float64_mul( float64 a, float64 b ) @@ -1874,8 +1874,8 @@ float64 float64_mul( float64 a, float64 /* ------------------------------------------------------------------------------- Returns the result of dividing the double-precision floating-point value `a' -by the corresponding value `b'. The operation is performed according to -the IEC/IEEE Standard for Binary Floating-point Arithmetic. +by the corresponding value `b'. The operation is performed according to the +IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 float64_div( float64 a, float64 b ) @@ -1958,16 +1958,15 @@ float64 float64_div( float64 a, float64 ------------------------------------------------------------------------------- Returns the remainder of the double-precision floating-point value `a' with respect to the corresponding value `b'. The operation is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 float64_rem( float64 a, float64 b ) { flag aSign, bSign, zSign; int16 aExp, bExp, expDiff; - bits32 aSig0, aSig1, bSig0, bSig1; - bits32 q, term0, term1, term2, allZero, alternateASig0, alternateASig1; - bits32 sigMean1; + bits32 aSig0, aSig1, bSig0, bSig1, q, term0, term1, term2; + bits32 allZero, alternateASig0, alternateASig1, sigMean1; sbits32 sigMean0; float64 z; @@ -2064,16 +2063,15 @@ float64 float64_rem( float64 a, float64 ------------------------------------------------------------------------------- Returns the square root of the double-precision floating-point value `a'. The operation is performed according to the IEC/IEEE Standard for Binary -Floating-point Arithmetic. +Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ float64 float64_sqrt( float64 a ) { flag aSign; int16 aExp, zExp; - bits32 aSig0, aSig1, zSig0, zSig1, zSig2; + bits32 aSig0, aSig1, zSig0, zSig1, zSig2, doubleZSig0; bits32 rem0, rem1, rem2, rem3, term0, term1, term2, term3; - bits32 shiftedRem0, shiftedRem1; float64 z; aSig1 = extractFloat64Frac1( a ); @@ -2098,46 +2096,45 @@ float64 float64_sqrt( float64 a ) normalizeFloat64Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 ); } zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE; - shortShift64Left( aSig0 | 0x00100000, aSig1, 11, &aSig0, &aSig1 ); - zSig0 = estimateSqrt32( aExp, aSig0 ) + 2; - if ( 0 <= (sbits32) zSig0 ) zSig0 = 0xFFFFFFFF; - if ( aExp & 1 ) shift64Right( aSig0, aSig1, 1, &aSig0, &aSig1 ); + aSig0 |= 0x00100000; + shortShift64Left( aSig0, aSig1, 11, &term0, &term1 ); + zSig0 = ( estimateSqrt32( aExp, term0 )>>1 ) + 1; + if ( zSig0 == 0 ) zSig0 = 0x7FFFFFFF; + doubleZSig0 = zSig0 + zSig0; + shortShift64Left( aSig0, aSig1, 9 - ( aExp & 1 ), &aSig0, &aSig1 ); mul32To64( zSig0, zSig0, &term0, &term1 ); sub64( aSig0, aSig1, term0, term1, &rem0, &rem1 ); while ( (sbits32) rem0 < 0 ) { --zSig0; - shortShift64Left( 0, zSig0, 1, &term0, &term1 ); - term1 |= 1; - add64( rem0, rem1, term0, term1, &rem0, &rem1 ); + doubleZSig0 -= 2; + add64( rem0, rem1, 0, doubleZSig0 | 1, &rem0, &rem1 ); } - shortShift64Left( rem0, rem1, 31, &shiftedRem0, &shiftedRem1 ); - zSig1 = estimateDiv64To32( shiftedRem0, shiftedRem1, zSig0 ); - if ( ( zSig1 & 0x3FF ) <= 5 ) { + zSig1 = estimateDiv64To32( rem1, 0, doubleZSig0 ); + if ( ( zSig1 & 0x1FF ) <= 5 ) { if ( zSig1 == 0 ) zSig1 = 1; - mul32To64( zSig0, zSig1, &term1, &term2 ); - shortShift64Left( term1, term2, 1, &term1, &term2 ); + mul32To64( doubleZSig0, zSig1, &term1, &term2 ); sub64( rem1, 0, term1, term2, &rem1, &rem2 ); mul32To64( zSig1, zSig1, &term2, &term3 ); sub96( rem1, rem2, 0, 0, term2, term3, &rem1, &rem2, &rem3 ); while ( (sbits32) rem1 < 0 ) { --zSig1; - shortShift96Left( 0, zSig0, zSig1, 1, &term1, &term2, &term3 ); + shortShift64Left( 0, zSig1, 1, &term2, &term3 ); term3 |= 1; - add96( - rem1, rem2, rem3, term1, term2, term3, &rem1, &rem2, &rem3 ); + term2 |= doubleZSig0; + add96( rem1, rem2, rem3, 0, term2, term3, &rem1, &rem2, &rem3 ); } zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 ); } - shift64ExtraRightJamming( zSig0, zSig1, 0, 11, &zSig0, &zSig1, &zSig2 ); + shift64ExtraRightJamming( zSig0, zSig1, 0, 10, &zSig0, &zSig1, &zSig2 ); return roundAndPackFloat64( 0, zExp, zSig0, zSig1, zSig2 ); } /* ------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is equal to the -corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +Returns 1 if the double-precision floating-point value `a' is equal to +the corresponding value `b', and 0 otherwise. The comparison is performed +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float64_eq( float64 a, float64 b ) @@ -2164,9 +2161,9 @@ flag float64_eq( float64 a, float64 b ) /* ------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is less than or -equal to the corresponding value `b', and 0 otherwise. The comparison is -performed according to the IEC/IEEE Standard for Binary Floating-point +Returns 1 if the double-precision floating-point value `a' is less than +or equal to the corresponding value `b', and 0 otherwise. The comparison +is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ @@ -2200,7 +2197,7 @@ flag float64_le( float64 a, float64 b ) ------------------------------------------------------------------------------- Returns 1 if the double-precision floating-point value `a' is less than the corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float64_lt( float64 a, float64 b ) @@ -2231,10 +2228,10 @@ flag float64_lt( float64 a, float64 b ) /* ------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is equal to the -corresponding value `b', and 0 otherwise. The invalid exception is raised -if either operand is a NaN. Otherwise, the comparison is performed -according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. +Returns 1 if the double-precision floating-point value `a' is equal to +the corresponding value `b', and 0 otherwise. The invalid exception is +raised if either operand is a NaN. Otherwise, the comparison is performed +according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float64_eq_signaling( float64 a, float64 b ) @@ -2262,7 +2259,7 @@ flag float64_eq_signaling( float64 a, fl Returns 1 if the double-precision floating-point value `a' is less than or equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the -IEC/IEEE Standard for Binary Floating-point Arithmetic. +IEC/IEEE Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float64_le_quiet( float64 a, float64 b ) @@ -2298,7 +2295,7 @@ flag float64_le_quiet( float64 a, float6 Returns 1 if the double-precision floating-point value `a' is less than the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the IEC/IEEE -Standard for Binary Floating-point Arithmetic. +Standard for Binary Floating-Point Arithmetic. ------------------------------------------------------------------------------- */ flag float64_lt_quiet( float64 a, float64 b ) Only in libfloat/softfloat/bits32/templates: CVS diff -uwbBpr libfloat/softfloat/bits32/templates/Makefile SoftFloat-2a/softfloat/bits32/templates/Makefile --- libfloat/softfloat/bits32/templates/Makefile Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/templates/Makefile Mon Sep 20 11:46:49 1999 @@ -1,25 +1,28 @@ -PROCESSOR_DIR = ../../../processors -PROCESSOR_H = $(PROCESSOR_DIR)/!!!processor.h #e.g., 386-gcc +PROCESSOR_H = ../../../processors/!!!processor.h SOFTFLOAT_MACROS = ../softfloat-macros -CC = gcc -CINCLUDES = -I. -I.. -I- -CFLAGS = -O2 -LINK = gcc -LFLAGS -TIMESOFTFLOAT_EXE = timesoftfloat -ALL: softfloat.o $(TIMESOFTFLOAT_EXE) +OBJ = .o +EXE = +INCLUDES = -I. -I.. +COMPILE_C = gcc -c -o $@ $(INCLUDES) -I- -O2 +LINK = gcc -o $@ + +#------------------------------------------------------------------------------ +# Probably O.K. below here. +#------------------------------------------------------------------------------ + +ALL: softfloat$(OBJ) timesoftfloat$(EXE) milieu.h: $(PROCESSOR_H) touch milieu.h -softfloat.o: milieu.h softfloat.h softfloat-specialize $(SOFTFLOAT_MACROS) ../softfloat.c - $(CC) $(CINCLUDES) $(CFLAGS) -c ../softfloat.c +softfloat$(OBJ): milieu.h softfloat.h softfloat-specialize $(SOFTFLOAT_MACROS) ../softfloat.c + $(COMPILE_C) ../softfloat.c -timesoftfloat.o: milieu.h softfloat.h ../timesoftfloat.c - $(CC) $(CINCLUDES) $(CFLAGS) -c ../timesoftfloat.c +timesoftfloat$(OBJ): milieu.h softfloat.h ../timesoftfloat.c + $(COMPILE_C) ../timesoftfloat.c -$(TIMESOFTFLOAT_EXE): softfloat.o timesoftfloat.o - $(LINK) $(LFLAGS) -o $(TIMESOFTFLOAT_EXE) softfloat.o timesoftfloat.o +timesoftfloat$(EXE): softfloat$(OBJ) timesoftfloat$(OBJ) + $(LINK) softfloat$(OBJ) timesoftfloat$(OBJ) diff -uwbBpr libfloat/softfloat/bits32/templates/milieu.h SoftFloat-2a/softfloat/bits32/templates/milieu.h --- libfloat/softfloat/bits32/templates/milieu.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/templates/milieu.h Mon Sep 20 11:46:49 1999 @@ -3,7 +3,7 @@ =============================================================================== This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -13,7 +13,7 @@ of this code was written as part of a pr 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://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/softfloat.html'. +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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== diff -uwbBpr libfloat/softfloat/bits32/templates/softfloat-specialize SoftFloat-2a/softfloat/bits32/templates/softfloat-specialize --- libfloat/softfloat/bits32/templates/softfloat-specialize Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/templates/softfloat-specialize Mon Sep 20 11:46:50 1999 @@ -3,7 +3,7 @@ =============================================================================== This C source fragment is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -13,7 +13,7 @@ of this code was written as part of a pr 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://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/softfloat.html'. +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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== @@ -40,8 +40,8 @@ int8 float_detect_tininess = float_tinin /* ------------------------------------------------------------------------------- Raises the exceptions specified by `flags'. Floating-point traps can be -defined here if desired. It is currently not possible for such a trap to -substitute a result value. If traps are not implemented, this routine +defined here if desired. It is currently not possible for such a trap +to substitute a result value. If traps are not implemented, this routine should be simply `float_exception_flags |= flags;'. ------------------------------------------------------------------------------- */ diff -uwbBpr libfloat/softfloat/bits32/templates/softfloat.h SoftFloat-2a/softfloat/bits32/templates/softfloat.h --- libfloat/softfloat/bits32/templates/softfloat.h Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/templates/softfloat.h Mon Sep 20 11:46:51 1999 @@ -3,7 +3,7 @@ =============================================================================== This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center @@ -13,7 +13,7 @@ of this code was written as part of a pr 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://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/softfloat.html'. +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 @@ -23,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== diff -uwbBpr libfloat/softfloat/bits32/timesoftfloat.c SoftFloat-2a/softfloat/bits32/timesoftfloat.c --- libfloat/softfloat/bits32/timesoftfloat.c Wed Sep 15 16:18:51 1999 +++ SoftFloat-2a/softfloat/bits32/timesoftfloat.c Mon Sep 20 11:46:48 1999 @@ -3,10 +3,17 @@ =============================================================================== This C source file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2. +Arithmetic Package, Release 2a. -Written by John R. Hauser. More information is available through the Web -page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/softfloat.html'. +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://HTTP.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 @@ -16,7 +23,7 @@ AND ALL LOSSES, COSTS, OR OTHER PROBLEMS Derivative works are acceptable, even for commercial purposes, so long as (1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these three paragraphs for those parts of +include prominent notice akin to these four paragraphs for those parts of this code that are retained. =============================================================================== @@ -24,30 +31,25 @@ this code that are retained. #include #include -#include #include #include +#include #include "milieu.h" #include "softfloat.h" -char *fail_programName = "timesoftfloat"; - -void writeFailureV( const char *message, va_list varArgs ) -{ - - fprintf( stderr, "%s: ", fail_programName ); - vfprintf( stderr, message, varArgs ); - fputs( ".\n", stderr ); - -} +enum { + minIterations = 1000 +}; void fail( const char *message, ... ) { va_list varArgs; + fputs( "timesoftfloat: ", stderr ); va_start( varArgs, message ); - writeFailureV( message, varArgs ); + vfprintf( stderr, message, varArgs ); va_end( varArgs ); + fputs( ".\n", stderr ); exit( EXIT_FAILURE ); } @@ -100,15 +102,16 @@ static void time_a_int32_z_float32( floa inputNum = 0; startClock = clock(); do { - (void) function( inputs_int32[ inputNum ] ); - ++count; + for ( i = minIterations; i; --i ) { + function( inputs_int32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { - (void) function( inputs_int32[ inputNum ] ); + for ( i = count; i; --i ) { + function( inputs_int32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); } endClock = clock(); @@ -126,15 +129,16 @@ static void time_a_int32_z_float64( floa inputNum = 0; startClock = clock(); do { - (void) function( inputs_int32[ inputNum ] ); - ++count; + for ( i = minIterations; i; --i ) { + function( inputs_int32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { - (void) function( inputs_int32[ inputNum ] ); + for ( i = count; i; --i ) { + function( inputs_int32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); } endClock = clock(); @@ -167,15 +171,16 @@ static void time_a_float32_z_int32( int3 inputNum = 0; startClock = clock(); do { - (void) function( inputs_float32[ inputNum ] ); - ++count; + for ( i = minIterations; i; --i ) { + function( inputs_float32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { - (void) function( inputs_float32[ inputNum ] ); + for ( i = count; i; --i ) { + function( inputs_float32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); } endClock = clock(); @@ -193,15 +198,16 @@ static void time_a_float32_z_float64( fl inputNum = 0; startClock = clock(); do { - (void) function( inputs_float32[ inputNum ] ); - ++count; + for ( i = minIterations; i; --i ) { + function( inputs_float32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { - (void) function( inputs_float32[ inputNum ] ); + for ( i = count; i; --i ) { + function( inputs_float32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); } endClock = clock(); @@ -219,15 +225,16 @@ static void time_az_float32( float32 fun inputNum = 0; startClock = clock(); do { - (void) function( inputs_float32[ inputNum ] ); - ++count; + for ( i = minIterations; i; --i ) { + function( inputs_float32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { - (void) function( inputs_float32[ inputNum ] ); + for ( i = count; i; --i ) { + function( inputs_float32[ inputNum ] ); inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); } endClock = clock(); @@ -246,20 +253,19 @@ static void time_ab_float32_z_flag( flag inputNumB = 0; startClock = clock(); do { - (void) + for ( i = minIterations; i; --i ) { function( inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); - ++count; inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); if ( inputNumA == 0 ) ++inputNumB; inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNumA = 0; inputNumB = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { - (void) + for ( i = count; i; --i ) { function( inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); @@ -282,20 +288,19 @@ static void time_abz_float32( float32 fu inputNumB = 0; startClock = clock(); do { - (void) + for ( i = minIterations; i; --i ) { function( inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); - ++count; inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); if ( inputNumA == 0 ) ++inputNumB; inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNumA = 0; inputNumB = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { - (void) + for ( i = count; i; --i ) { function( inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); @@ -307,6 +312,44 @@ static void time_abz_float32( float32 fu } +static const float32 inputs_float32_pos[ numInputs_float32 ] = { + 0x4EFA0000, 0x41D0B328, 0x00000000, 0x3E69A31E, + 0x2F803EFF, 0x3F800000, 0x17BF8000, 0x674A301A, + 0x4E010003, 0x7EE3C75D, 0x3D803FE0, 0x3FFEFF00, + 0x7981F800, 0x431FFFFC, 0x4100C000, 0x3D87EFFF, + 0x4103FEFE, 0x3C000007, 0x3F01F7FF, 0x4E6C6B5C, + 0x4187FFFE, 0x458B9F13, 0x4F88007F, 0x5F004007, + 0x37FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000, + 0x5B428661, 0x33F89B1F, 0x23BFEFFF, 0x537BFFBE +}; + +static void time_az_float32_pos( float32 function( float32 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNum; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( inputs_float32_pos[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( inputs_float32_pos[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + enum { numInputs_float64 = 32 }; @@ -359,19 +402,20 @@ static void time_a_float64_z_int32( int3 inputNum = 0; startClock = clock(); do { + for ( i = minIterations; i; --i ) { a.low = inputs_float64[ inputNum ].low; a.high = inputs_float64[ inputNum ].high; - (void) function( a ); - ++count; + function( a ); inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { + for ( i = count; i; --i ) { a.low = inputs_float64[ inputNum ].low; a.high = inputs_float64[ inputNum ].high; - (void) function( a ); + function( a ); inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); } endClock = clock(); @@ -391,19 +435,20 @@ static void time_a_float64_z_float32( fl inputNum = 0; startClock = clock(); do { + for ( i = minIterations; i; --i ) { a.low = inputs_float64[ inputNum ].low; a.high = inputs_float64[ inputNum ].high; - (void) function( a ); - ++count; + function( a ); inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { + for ( i = count; i; --i ) { a.low = inputs_float64[ inputNum ].low; a.high = inputs_float64[ inputNum ].high; - (void) function( a ); + function( a ); inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); } endClock = clock(); @@ -422,19 +467,20 @@ static void time_az_float64( float64 fun inputNum = 0; startClock = clock(); do { + for ( i = minIterations; i; --i ) { a.low = inputs_float64[ inputNum ].low; a.high = inputs_float64[ inputNum ].high; - (void) function( a ); - ++count; + function( a ); inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNum = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { + for ( i = count; i; --i ) { a.low = inputs_float64[ inputNum ].low; a.high = inputs_float64[ inputNum ].high; - (void) function( a ); + function( a ); inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); } endClock = clock(); @@ -454,26 +500,27 @@ static void time_ab_float64_z_flag( flag inputNumB = 0; startClock = clock(); do { + for ( i = minIterations; i; --i ) { a.low = inputs_float64[ inputNumA ].low; a.high = inputs_float64[ inputNumA ].high; b.low = inputs_float64[ inputNumB ].low; b.high = inputs_float64[ inputNumB ].high; - (void) function( a, b ); - ++count; + function( a, b ); inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 ); if ( inputNumA == 0 ) ++inputNumB; inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNumA = 0; inputNumB = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { + for ( i = count; i; --i ) { a.low = inputs_float64[ inputNumA ].low; a.high = inputs_float64[ inputNumA ].high; b.low = inputs_float64[ inputNumB ].low; b.high = inputs_float64[ inputNumB ].high; - (void) function( a, b ); + function( a, b ); inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 ); if ( inputNumA == 0 ) ++inputNumB; inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 ); @@ -495,26 +542,27 @@ static void time_abz_float64( float64 fu inputNumB = 0; startClock = clock(); do { + for ( i = minIterations; i; --i ) { a.low = inputs_float64[ inputNumA ].low; a.high = inputs_float64[ inputNumA ].high; b.low = inputs_float64[ inputNumB ].low; b.high = inputs_float64[ inputNumB ].high; - (void) function( a, b ); - ++count; + function( a, b ); inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 ); if ( inputNumA == 0 ) ++inputNumB; inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 ); + } + count += minIterations; } while ( clock() - startClock < CLOCKS_PER_SEC ); - count += count; inputNumA = 0; inputNumB = 0; startClock = clock(); - for ( i = count; 0 < i; --i ) { + for ( i = count; i; --i ) { a.low = inputs_float64[ inputNumA ].low; a.high = inputs_float64[ inputNumA ].high; b.low = inputs_float64[ inputNumB ].low; b.high = inputs_float64[ inputNumB ].high; - (void) function( a, b ); + function( a, b ); inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 ); if ( inputNumA == 0 ) ++inputNumB; inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 ); @@ -524,6 +572,75 @@ static void time_abz_float64( float64 fu } +static const struct { + bits32 high, low; +} inputs_float64_pos[ numInputs_float64 ] = { + { 0x422FFFC0, 0x08000000 }, + { 0x37E00004, 0x80000000 }, + { 0x73FD2546, 0x120B7935 }, + { 0x3FF00000, 0x00000000 }, + { 0x4E07F766, 0xF09588D6 }, + { 0x00000000, 0x00000000 }, + { 0x3FCE0004, 0x00000000 }, + { 0x0313B60F, 0x0032BED8 }, + { 0x41EFFFFF, 0xC0002000 }, + { 0x3FB3C75D, 0x224F2B0F }, + { 0x7FD00000, 0x004000FF }, + { 0x212FFF80, 0x00001FFF }, + { 0x3EE00000, 0x00FE0000 }, + { 0x00100000, 0x80000004 }, + { 0x41CFFFFE, 0x00000020 }, + { 0x40303FFF, 0xFFFFFFFD }, + { 0x3FD00000, 0x3FEFFFFF }, + { 0x3FD00000, 0x10000000 }, + { 0x37FC6B5C, 0x16CA55CF }, + { 0x413EEB94, 0x0B9D1301 }, + { 0x47E00200, 0x001FFFFF }, + { 0x47F00021, 0xFFFFFFFE }, + { 0x3FFFFFFF, 0xF80000FF }, + { 0x407FFFFF, 0xE00FFFFF }, + { 0x001497A6, 0x3740C5E8 }, + { 0x44BFFFE0, 0x001FFFFF }, + { 0x16FFDFFE, 0xFFFFFFFF }, + { 0x403FC000, 0x000001FE }, + { 0x7FD00000, 0x000001F6 }, + { 0x06404000, 0x02000000 }, + { 0x479CEE1E, 0x4F789FE0 }, + { 0x4237FFFF, 0xFFFFFDFE } +}; + +static void time_az_float64_pos( float64 function( float64 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNum; + float64 a; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + a.low = inputs_float64_pos[ inputNum ].low; + a.high = inputs_float64_pos[ inputNum ].high; + function( a ); + inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + a.low = inputs_float64_pos[ inputNum ].low; + a.high = inputs_float64_pos[ inputNum ].high; + function( a ); + inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + enum { INT32_TO_FLOAT32 = 1, INT32_TO_FLOAT64, @@ -698,7 +815,7 @@ static void time_abz_float32( float32_rem ); break; case FLOAT32_SQRT: - time_az_float32( float32_sqrt ); + time_az_float32_pos( float32_sqrt ); break; case FLOAT32_EQ: time_ab_float32_z_flag( float32_eq ); @@ -746,7 +863,7 @@ static void time_abz_float64( float64_rem ); break; case FLOAT64_SQRT: - time_az_float64( float64_sqrt ); + time_az_float64_pos( float64_sqrt ); break; case FLOAT64_EQ: time_ab_float64_z_flag( float64_eq ); @@ -823,7 +940,7 @@ main( int argc, char **argv ) if ( strcmp( argPtr, "help" ) == 0 ) { writeHelpMessage: fputs( -"usage: timesoftfloat [