xref: /freebsd/lib/libc/softfloat/softfloat-source.txt (revision c36abe0dcf91e964fbb194f3f8589dc8f05cd146)
1*c36abe0dSDavid Schultz$NetBSD: softfloat-source.txt,v 1.2 2006/11/24 19:46:58 christos Exp $
215144b0fSOlivier Houchard$FreeBSD$
315144b0fSOlivier Houchard
415144b0fSOlivier HouchardSoftFloat Release 2a Source Documentation
515144b0fSOlivier Houchard
615144b0fSOlivier HouchardJohn R. Hauser
715144b0fSOlivier Houchard1998 December 14
815144b0fSOlivier Houchard
915144b0fSOlivier Houchard
1015144b0fSOlivier Houchard-------------------------------------------------------------------------------
1115144b0fSOlivier HouchardIntroduction
1215144b0fSOlivier Houchard
1315144b0fSOlivier HouchardSoftFloat is a software implementation of floating-point that conforms to
1415144b0fSOlivier Houchardthe IEC/IEEE Standard for Binary Floating-Point Arithmetic.  SoftFloat can
1515144b0fSOlivier Houchardsupport four floating-point formats:  single precision, double precision,
1615144b0fSOlivier Houchardextended double precision, and quadruple precision.  All operations required
1715144b0fSOlivier Houchardby the IEEE Standard are implemented, except for conversions to and from
1815144b0fSOlivier Houcharddecimal.  SoftFloat is distributed in the form of C source code, so a
1915144b0fSOlivier HouchardC compiler is needed to compile the code.  Support for the extended double-
2015144b0fSOlivier Houchardprecision and quadruple-precision formats is dependent on the C compiler
2115144b0fSOlivier Houchardimplementing a 64-bit integer type.
2215144b0fSOlivier Houchard
2315144b0fSOlivier HouchardThis document gives information needed for compiling and/or porting
2415144b0fSOlivier HouchardSoftFloat.
2515144b0fSOlivier Houchard
2615144b0fSOlivier HouchardThe source code for SoftFloat is intended to be relatively machine-
2715144b0fSOlivier Houchardindependent and should be compilable using any ISO/ANSI C compiler.  At the
2815144b0fSOlivier Houchardtime of this writing, SoftFloat has been successfully compiled with the GNU
2915144b0fSOlivier HouchardC Compiler (`gcc') for several platforms.
3015144b0fSOlivier Houchard
3115144b0fSOlivier Houchard
3215144b0fSOlivier Houchard-------------------------------------------------------------------------------
3315144b0fSOlivier HouchardLimitations
3415144b0fSOlivier Houchard
3515144b0fSOlivier HouchardSoftFloat as written requires an ISO/ANSI-style C compiler.  No attempt has
36*c36abe0dSDavid Schultzbeen made to accommodate compilers that are not ISO-conformant.  Older ``K&R-
3715144b0fSOlivier Houchardstyle'' compilers are not adequate for compiling SoftFloat.  All testing I
3815144b0fSOlivier Houchardhave done so far has been with the GNU C Compiler.  Compilation with other
3915144b0fSOlivier Houchardcompilers should be possible but has not been tested.
4015144b0fSOlivier Houchard
4115144b0fSOlivier HouchardThe SoftFloat sources assume that source code file names can be longer than
4215144b0fSOlivier Houchard8 characters.  In order to compile under an MS-DOS-type system, many of the
4315144b0fSOlivier Houchardsource files will need to be renamed, and the source and makefiles edited
4415144b0fSOlivier Houchardappropriately.  Once compiled, the SoftFloat binary does not depend on the
4515144b0fSOlivier Houchardexistence of long file names.
4615144b0fSOlivier Houchard
4715144b0fSOlivier HouchardThe underlying machine is assumed to be binary with a word size that is a
4815144b0fSOlivier Houchardpower of 2.  Bytes are 8 bits.  Support for the extended double-precision
4915144b0fSOlivier Houchardand quadruple-precision formats depends on the C compiler implementing
5015144b0fSOlivier Houcharda 64-bit integer type.  If the largest integer type supported by the
5115144b0fSOlivier HouchardC compiler is 32 bits, SoftFloat is limited to the single- and double-
5215144b0fSOlivier Houchardprecision formats.
5315144b0fSOlivier Houchard
5415144b0fSOlivier Houchard
5515144b0fSOlivier Houchard-------------------------------------------------------------------------------
5615144b0fSOlivier HouchardContents
5715144b0fSOlivier Houchard
5815144b0fSOlivier Houchard    Introduction
5915144b0fSOlivier Houchard    Limitations
6015144b0fSOlivier Houchard    Contents
6115144b0fSOlivier Houchard    Legal Notice
6215144b0fSOlivier Houchard    SoftFloat Source Directory Structure
6315144b0fSOlivier Houchard    SoftFloat Source Files
6415144b0fSOlivier Houchard        processors/*.h
6515144b0fSOlivier Houchard        softfloat/bits*/*/softfloat.h
6615144b0fSOlivier Houchard        softfloat/bits*/*/milieu.h
6715144b0fSOlivier Houchard        softfloat/bits*/*/softfloat-specialize
6815144b0fSOlivier Houchard        softfloat/bits*/softfloat-macros
6915144b0fSOlivier Houchard        softfloat/bits*/softfloat.c
7015144b0fSOlivier Houchard    Steps to Creating a `softfloat.o'
7115144b0fSOlivier Houchard    Making `softfloat.o' a Library
7215144b0fSOlivier Houchard    Testing SoftFloat
7315144b0fSOlivier Houchard    Timing SoftFloat
7415144b0fSOlivier Houchard    Compiler Options and Efficiency
7515144b0fSOlivier Houchard    Processor-Specific Optimization of `softfloat.c' Using `softfloat-macros'
7615144b0fSOlivier Houchard    Contact Information
7715144b0fSOlivier Houchard
7815144b0fSOlivier Houchard
7915144b0fSOlivier Houchard
8015144b0fSOlivier Houchard-------------------------------------------------------------------------------
8115144b0fSOlivier HouchardLegal Notice
8215144b0fSOlivier Houchard
8315144b0fSOlivier HouchardSoftFloat was written by John R. Hauser.  This work was made possible in
8415144b0fSOlivier Houchardpart by the International Computer Science Institute, located at Suite 600,
8515144b0fSOlivier Houchard1947 Center Street, Berkeley, California 94704.  Funding was partially
8615144b0fSOlivier Houchardprovided by the National Science Foundation under grant MIP-9311980.  The
8715144b0fSOlivier Houchardoriginal version of this code was written as part of a project to build
8815144b0fSOlivier Houcharda fixed-point vector processor in collaboration with the University of
8915144b0fSOlivier HouchardCalifornia at Berkeley, overseen by Profs. Nelson Morgan and John Wawrzynek.
9015144b0fSOlivier Houchard
9115144b0fSOlivier HouchardTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
9215144b0fSOlivier Houchardhas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
9315144b0fSOlivier HouchardTIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
9415144b0fSOlivier HouchardPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
9515144b0fSOlivier HouchardAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
9615144b0fSOlivier Houchard
9715144b0fSOlivier Houchard
9815144b0fSOlivier Houchard-------------------------------------------------------------------------------
9915144b0fSOlivier HouchardSoftFloat Source Directory Structure
10015144b0fSOlivier Houchard
10115144b0fSOlivier HouchardBecause SoftFloat is targeted to multiple platforms, its source code
10215144b0fSOlivier Houchardis slightly scattered between target-specific and target-independent
10315144b0fSOlivier Houcharddirectories and files.  The directory structure is as follows:
10415144b0fSOlivier Houchard
10515144b0fSOlivier Houchard    processors
10615144b0fSOlivier Houchard    softfloat
10715144b0fSOlivier Houchard        bits64
10815144b0fSOlivier Houchard            templates
10915144b0fSOlivier Houchard            386-Win32-gcc
11015144b0fSOlivier Houchard            SPARC-Solaris-gcc
11115144b0fSOlivier Houchard        bits32
11215144b0fSOlivier Houchard            templates
11315144b0fSOlivier Houchard            386-Win32-gcc
11415144b0fSOlivier Houchard            SPARC-Solaris-gcc
11515144b0fSOlivier Houchard
11615144b0fSOlivier HouchardThe two topmost directories and their contents are:
11715144b0fSOlivier Houchard
11815144b0fSOlivier Houchard    softfloat    - Most of the source code needed for SoftFloat.
11915144b0fSOlivier Houchard    processors   - Target-specific header files that are not specific to
12015144b0fSOlivier Houchard                       SoftFloat.
12115144b0fSOlivier Houchard
12215144b0fSOlivier HouchardThe `softfloat' directory is further split into two parts:
12315144b0fSOlivier Houchard
12415144b0fSOlivier Houchard    bits64       - SoftFloat implementation using 64-bit integers.
12515144b0fSOlivier Houchard    bits32       - SoftFloat implementation using only 32-bit integers.
12615144b0fSOlivier Houchard
12715144b0fSOlivier HouchardWithin these directories are subdirectories for each of the targeted
12815144b0fSOlivier Houchardplatforms.  The SoftFloat source code is distributed with targets
12915144b0fSOlivier Houchard`386-Win32-gcc' and `SPARC-Solaris-gcc' (and perhaps others) already
13015144b0fSOlivier Houchardprepared for both the 32-bit and 64-bit implementations.  Source files that
13115144b0fSOlivier Houchardare not within these target-specific subdirectories are intended to be
13215144b0fSOlivier Houchardtarget-independent.
13315144b0fSOlivier Houchard
13415144b0fSOlivier HouchardThe naming convention used for the target-specific directories is
13515144b0fSOlivier Houchard`<processor>-<executable-type>-<compiler>'.  The names of the supplied
13615144b0fSOlivier Houchardtarget directories should be interpreted as follows:
13715144b0fSOlivier Houchard
13815144b0fSOlivier Houchard  <processor>:
13915144b0fSOlivier Houchard    386          - Intel 386-compatible processor.
14015144b0fSOlivier Houchard    SPARC        - SPARC processor (as used by Sun machines).
14115144b0fSOlivier Houchard  <executable-type>:
14215144b0fSOlivier Houchard    Win32        - Microsoft Win32 executable.
14315144b0fSOlivier Houchard    Solaris      - Sun Solaris executable.
14415144b0fSOlivier Houchard  <compiler>:
14515144b0fSOlivier Houchard    gcc          - GNU C Compiler.
14615144b0fSOlivier Houchard
14715144b0fSOlivier HouchardYou do not need to maintain this convention if you do not want to.
14815144b0fSOlivier Houchard
14915144b0fSOlivier HouchardAlongside the supplied target-specific directories is a `templates'
15015144b0fSOlivier Houcharddirectory containing a set of ``generic'' target-specific source files.  A
15115144b0fSOlivier Houchardnew target directory can be created by copying the `templates' directory and
15215144b0fSOlivier Houchardediting the files inside.  (Complete instructions for porting SoftFloat to a
15315144b0fSOlivier Houchardnew target are in the section _Steps_to_Creating_a_`softfloat.o'_.)  Note
15415144b0fSOlivier Houchardthat the `templates' directory will not work as a target directory without
15515144b0fSOlivier Houchardsome editing.  To avoid confusion, it would be wise to refrain from editing
15615144b0fSOlivier Houchardthe files inside `templates' directly.
15715144b0fSOlivier Houchard
15815144b0fSOlivier Houchard
15915144b0fSOlivier Houchard-------------------------------------------------------------------------------
16015144b0fSOlivier HouchardSoftFloat Source Files
16115144b0fSOlivier Houchard
16215144b0fSOlivier HouchardThe purpose of each source file is described below.  In the following,
16315144b0fSOlivier Houchardthe `*' symbol is used in place of the name of a specific target, such as
16415144b0fSOlivier Houchard`386-Win32-gcc' or `SPARC-Solaris-gcc', or in place of some other text, as
16515144b0fSOlivier Houchardin `bits*' for either `bits32' or `bits64'.
16615144b0fSOlivier Houchard
16715144b0fSOlivier Houchard- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16815144b0fSOlivier Houchardprocessors/*.h
16915144b0fSOlivier Houchard
17015144b0fSOlivier HouchardThe target-specific `processors' header file defines integer types
17115144b0fSOlivier Houchardof various sizes, and also defines certain C preprocessor macros that
17215144b0fSOlivier Houchardcharacterize the target.  The two examples supplied are `386-gcc.h' and
17315144b0fSOlivier Houchard`SPARC-gcc.h'.  The naming convention used for processor header files is
17415144b0fSOlivier Houchard`<processor>-<compiler>.h'.
17515144b0fSOlivier Houchard
17615144b0fSOlivier HouchardIf 64-bit integers are supported by the compiler, the macro name `BITS64'
17715144b0fSOlivier Houchardshould be defined here along with the corresponding 64-bit integer
17815144b0fSOlivier Houchardtypes.  In addition, the function-like macro `LIT64' must be defined for
17915144b0fSOlivier Houchardconstructing 64-bit integer literals (constants).  The `LIT64' macro is used
18015144b0fSOlivier Houchardconsistently in the SoftFloat code to annotate 64-bit literals.
18115144b0fSOlivier Houchard
18215144b0fSOlivier HouchardIf `BITS64' is not defined, only the 32-bit version of SoftFloat can be
18315144b0fSOlivier Houchardcompiled.  If `BITS64' _is_ defined, either can be compiled.
18415144b0fSOlivier Houchard
18515144b0fSOlivier HouchardIf an inlining attribute (such as an `inline' keyword) is provided by the
18615144b0fSOlivier Houchardcompiler, the macro `INLINE' should be defined to the appropriate keyword.
18715144b0fSOlivier HouchardIf not, `INLINE' can be set to the keyword `static'.  The `INLINE' macro
18815144b0fSOlivier Houchardappears in the SoftFloat source code before every function that should
18915144b0fSOlivier Houchardbe inlined by the compiler.  SoftFloat depends on inlining to obtain
19015144b0fSOlivier Houchardgood speed.  Even if inlining cannot be forced with a language keyword,
19115144b0fSOlivier Houchardthe compiler may still be able to perform inlining on its own as an
19215144b0fSOlivier Houchardoptimization.  If a command-line option is needed to convince the compiler
19315144b0fSOlivier Houchardto perform this optimization, this should be assured in the makefile.  (See
19415144b0fSOlivier Houchardthe section _Compiler_Options_and_Efficiency_ below.)
19515144b0fSOlivier Houchard
19615144b0fSOlivier Houchard- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
19715144b0fSOlivier Houchardsoftfloat/bits*/*/softfloat.h
19815144b0fSOlivier Houchard
19915144b0fSOlivier HouchardThe target-specific `softfloat.h' header file defines the SoftFloat
20015144b0fSOlivier Houchardinterface as seen by clients.
20115144b0fSOlivier Houchard
20215144b0fSOlivier HouchardUnlike the actual function definitions in `softfloat.c', the declarations
20315144b0fSOlivier Houchardin `softfloat.h' do not use any of the types defined by the `processors'
20415144b0fSOlivier Houchardheader file.  This is done so that clients will not have to include the
20515144b0fSOlivier Houchard`processors' header file in order to use SoftFloat.  Nevertheless, the
20615144b0fSOlivier Houchardtarget-specific declarations in `softfloat.h' must match what `softfloat.c'
20715144b0fSOlivier Houchardexpects.  For example, if `int32' is defined as `int' in the `processors'
20815144b0fSOlivier Houchardheader file, then in `softfloat.h' the output of `float32_to_int32' should
20915144b0fSOlivier Houchardbe stated as `int', although in `softfloat.c' it is given in target-
21015144b0fSOlivier Houchardindependent form as `int32'.
21115144b0fSOlivier Houchard
21215144b0fSOlivier HouchardFor the `bits64' implementation of SoftFloat, the macro names `FLOATX80' and
21315144b0fSOlivier Houchard`FLOAT128' must be defined in order for the extended double-precision and
21415144b0fSOlivier Houchardquadruple-precision formats to be enabled in the code.  Conversely, either
21515144b0fSOlivier Houchardor both of the extended formats can be disabled by simply removing the
21615144b0fSOlivier Houchard`#define' of the respective macro.  When an extended format is not enabled,
21715144b0fSOlivier Houchardnone of the functions that either input or output the format are defined,
21815144b0fSOlivier Houchardand no space is taken up in `softfloat.o' by such functions.  There is no
21915144b0fSOlivier Houchardprovision for disabling the usual single- and double-precision formats.
22015144b0fSOlivier Houchard
22115144b0fSOlivier Houchard- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22215144b0fSOlivier Houchardsoftfloat/bits*/*/milieu.h
22315144b0fSOlivier Houchard
22415144b0fSOlivier HouchardThe target-specific `milieu.h' header file provides declarations that are
22515144b0fSOlivier Houchardneeded to compile SoftFloat.  In addition, deviations from ISO/ANSI C by
22615144b0fSOlivier Houchardthe compiler (such as names not properly declared in system header files)
22715144b0fSOlivier Houchardare corrected in this header if possible.
22815144b0fSOlivier Houchard
22915144b0fSOlivier Houchard- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23015144b0fSOlivier Houchardsoftfloat/bits*/*/softfloat-specialize
23115144b0fSOlivier Houchard
23215144b0fSOlivier HouchardThis target-specific C source fragment defines:
23315144b0fSOlivier Houchard
23415144b0fSOlivier Houchard-- whether tininess for underflow is detected before or after rounding by
23515144b0fSOlivier Houchard       default;
23615144b0fSOlivier Houchard-- what (if anything) special happens when exceptions are raised;
23715144b0fSOlivier Houchard-- how signaling NaNs are distinguished from quiet NaNs;
23815144b0fSOlivier Houchard-- the default generated quiet NaNs; and
23915144b0fSOlivier Houchard-- how NaNs are propagated from function inputs to output.
24015144b0fSOlivier Houchard
24115144b0fSOlivier HouchardThese details are not decided by the IEC/IEEE Standard.  This fragment is
24215144b0fSOlivier Houchardincluded verbatim within `softfloat.c' when SoftFloat is compiled.
24315144b0fSOlivier Houchard
24415144b0fSOlivier Houchard- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24515144b0fSOlivier Houchardsoftfloat/bits*/softfloat-macros
24615144b0fSOlivier Houchard
24715144b0fSOlivier HouchardThis target-independent C source fragment defines a number of arithmetic
24815144b0fSOlivier Houchardfunctions used as primitives within the `softfloat.c' source.  Most of the
24915144b0fSOlivier Houchardfunctions defined here are intended to be inlined for efficiency.  This
25015144b0fSOlivier Houchardfragment is included verbatim within `softfloat.c' when SoftFloat is
25115144b0fSOlivier Houchardcompiled.
25215144b0fSOlivier Houchard
25315144b0fSOlivier HouchardTarget-specific variations on this file are possible.  See the section
25415144b0fSOlivier Houchard_Processor-Specific_Optimization_of_`softfloat.c'_Using_`softfloat-macros'_
25515144b0fSOlivier Houchardbelow.
25615144b0fSOlivier Houchard
25715144b0fSOlivier Houchard- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25815144b0fSOlivier Houchardsoftfloat/bits*/softfloat.c
25915144b0fSOlivier Houchard
26015144b0fSOlivier HouchardThe target-independent `softfloat.c' source file contains the body of the
26115144b0fSOlivier HouchardSoftFloat implementation.
26215144b0fSOlivier Houchard
26315144b0fSOlivier Houchard- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26415144b0fSOlivier Houchard
26515144b0fSOlivier HouchardThe inclusion of the files above within each other (using `#include') can be
26615144b0fSOlivier Houchardshown graphically as follows:
26715144b0fSOlivier Houchard
26815144b0fSOlivier Houchard    softfloat/bits*/softfloat.c
26915144b0fSOlivier Houchard        softfloat/bits*/*/milieu.h
27015144b0fSOlivier Houchard            processors/*.h
27115144b0fSOlivier Houchard        softfloat/bits*/*/softfloat.h
27215144b0fSOlivier Houchard        softfloat/bits*/*/softfloat-specialize
27315144b0fSOlivier Houchard        softfloat/bits*/softfloat-macros
27415144b0fSOlivier Houchard
27515144b0fSOlivier HouchardNote in particular that `softfloat.c' does not include the `processors'
27615144b0fSOlivier Houchardheader file directly.  Rather, `softfloat.c' includes the target-specific
27715144b0fSOlivier Houchard`milieu.h' header file, which in turn includes the processor header file.
27815144b0fSOlivier Houchard
27915144b0fSOlivier Houchard
28015144b0fSOlivier Houchard-------------------------------------------------------------------------------
28115144b0fSOlivier HouchardSteps to Creating a `softfloat.o'
28215144b0fSOlivier Houchard
28315144b0fSOlivier HouchardPorting and/or compiling SoftFloat involves the following steps:
28415144b0fSOlivier Houchard
28515144b0fSOlivier Houchard1. If one does not already exist, create an appropriate `.h' file in the
28615144b0fSOlivier Houchard   `processors' directory.
28715144b0fSOlivier Houchard
28815144b0fSOlivier Houchard2. If `BITS64' is defined in the `processors' header file, choose whether
28915144b0fSOlivier Houchard   to compile the 32-bit or 64-bit implementation of SoftFloat.  If
29015144b0fSOlivier Houchard   `BITS64' is not defined, your only choice is the 32-bit implementation.
29115144b0fSOlivier Houchard   The remaining steps occur within either the `bits32' or `bits64'
29215144b0fSOlivier Houchard   subdirectories.
29315144b0fSOlivier Houchard
29415144b0fSOlivier Houchard3. If one does not already exist, create an appropriate target-specific
29515144b0fSOlivier Houchard   subdirectory by copying the given `templates' directory.
29615144b0fSOlivier Houchard
29715144b0fSOlivier Houchard4. In the target-specific subdirectory, edit the files `softfloat-specialize'
29815144b0fSOlivier Houchard   and `softfloat.h' to define the desired exception handling functions
29915144b0fSOlivier Houchard   and mode control values.  In the `softfloat.h' header file, ensure also
30015144b0fSOlivier Houchard   that all declarations give the proper target-specific type (such as
30115144b0fSOlivier Houchard   `int' or `long') corresponding to the target-independent type used in
30215144b0fSOlivier Houchard   `softfloat.c' (such as `int32').  None of the type names declared in the
30315144b0fSOlivier Houchard   `processors' header file should appear in `softfloat.h'.
30415144b0fSOlivier Houchard
30515144b0fSOlivier Houchard5. In the target-specific subdirectory, edit the files `milieu.h' and
30615144b0fSOlivier Houchard   `Makefile' to reflect the current environment.
30715144b0fSOlivier Houchard
30815144b0fSOlivier Houchard6. In the target-specific subdirectory, execute `make'.
30915144b0fSOlivier Houchard
31015144b0fSOlivier HouchardFor the targets that are supplied, if the expected compiler is available
31115144b0fSOlivier Houchard(usually `gcc'), it should only be necessary to execute `make' in the
31215144b0fSOlivier Houchardtarget-specific subdirectory.
31315144b0fSOlivier Houchard
31415144b0fSOlivier Houchard
31515144b0fSOlivier Houchard-------------------------------------------------------------------------------
31615144b0fSOlivier HouchardMaking `softfloat.o' a Library
31715144b0fSOlivier Houchard
31815144b0fSOlivier HouchardSoftFloat is not made into a software library by the supplied makefile.
31915144b0fSOlivier HouchardIf desired, `softfloat.o' can easily be put into its own library (in Unix,
32015144b0fSOlivier Houchard`softfloat.a') using the usual system tool (in Unix, `ar').
32115144b0fSOlivier Houchard
32215144b0fSOlivier Houchard
32315144b0fSOlivier Houchard-------------------------------------------------------------------------------
32415144b0fSOlivier HouchardTesting SoftFloat
32515144b0fSOlivier Houchard
32615144b0fSOlivier HouchardSoftFloat can be tested using the `testsoftfloat' program by the same
32715144b0fSOlivier Houchardauthor.  The `testsoftfloat' program is part of the TestFloat package
32815144b0fSOlivier Houchardavailable at the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/
32915144b0fSOlivier HouchardTestFloat.html'.
33015144b0fSOlivier Houchard
33115144b0fSOlivier Houchard
33215144b0fSOlivier Houchard-------------------------------------------------------------------------------
33315144b0fSOlivier HouchardTiming SoftFloat
33415144b0fSOlivier Houchard
33515144b0fSOlivier HouchardA program called `timesoftfloat' for timing the SoftFloat functions is
33615144b0fSOlivier Houchardincluded with the SoftFloat source code.  Compiling `timesoftfloat' should
33715144b0fSOlivier Houchardpose no difficulties once `softfloat.o' exists.  The supplied makefile
33815144b0fSOlivier Houchardwill create a `timesoftfloat' executable by default after generating
33915144b0fSOlivier Houchard`softfloat.o'.  See `timesoftfloat.txt' for documentation about using
34015144b0fSOlivier Houchard`timesoftfloat'.
34115144b0fSOlivier Houchard
34215144b0fSOlivier Houchard
34315144b0fSOlivier Houchard-------------------------------------------------------------------------------
34415144b0fSOlivier HouchardCompiler Options and Efficiency
34515144b0fSOlivier Houchard
34615144b0fSOlivier HouchardIn order to get good speed with SoftFloat, it is important that the compiler
34715144b0fSOlivier Houchardinline the routines that have been marked `INLINE' in the code.  Even if
34815144b0fSOlivier Houchardinlining cannot be forced by an appropriate definition of the `INLINE'
34915144b0fSOlivier Houchardmacro, the compiler may still be able to perform inlining on its own as
35015144b0fSOlivier Houchardan optimization.  In that case, the makefile should be edited to give the
35115144b0fSOlivier Houchardcompiler whatever option is required to cause it to inline small functions.
35215144b0fSOlivier Houchard
35315144b0fSOlivier HouchardThe ability of the processor to do fast shifts has been assumed.  Efficiency
35415144b0fSOlivier Houchardwill not be as good on processors for which this is not the case (such as
35515144b0fSOlivier Houchardthe original Motorola 68000 or Intel 8086 processors).
35615144b0fSOlivier Houchard
35715144b0fSOlivier Houchard
35815144b0fSOlivier Houchard-------------------------------------------------------------------------------
35915144b0fSOlivier HouchardProcessor-Specific Optimization of `softfloat.c' Using `softfloat-macros'
36015144b0fSOlivier Houchard
36115144b0fSOlivier HouchardThe `softfloat-macros' source fragment defines arithmetic functions used
36215144b0fSOlivier Houchardas primitives by `softfloat.c'.  This file has been written in a target-
36315144b0fSOlivier Houchardindependent form.  For a given target, it may be possible to improve on
36415144b0fSOlivier Houchardthese functions using target-specific and/or non-ISO-C features (such
36515144b0fSOlivier Houchardas `asm' statements).  For example, one of the ``macro'' functions takes
36615144b0fSOlivier Houchardtwo word-size integers and returns their full product in two words.
36715144b0fSOlivier HouchardThis operation can be done directly in hardware on many processors; but
36815144b0fSOlivier Houchardbecause it is not available through standard C, the function defined in
36915144b0fSOlivier Houchard`softfloat-macros' uses four multiplies to achieve the same result.
37015144b0fSOlivier Houchard
37115144b0fSOlivier HouchardTo address these shortcomings, a customized version of `softfloat-macros'
37215144b0fSOlivier Houchardcan be created in any of the target-specific subdirectories.  A simple
37315144b0fSOlivier Houchardmodification to the target's makefile should be sufficient to ensure that
37415144b0fSOlivier Houchardthe custom version is used instead of the generic one.
37515144b0fSOlivier Houchard
37615144b0fSOlivier Houchard
37715144b0fSOlivier Houchard-------------------------------------------------------------------------------
37815144b0fSOlivier HouchardContact Information
37915144b0fSOlivier Houchard
38015144b0fSOlivier HouchardAt the time of this writing, the most up-to-date information about
38115144b0fSOlivier HouchardSoftFloat and the latest release can be found at the Web page `http://
38215144b0fSOlivier HouchardHTTP.CS.Berkeley.EDU/~jhauser/arithmetic/SoftFloat.html'.
38315144b0fSOlivier Houchard
38415144b0fSOlivier Houchard
385