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