1*2fe8fb19SBen Gras$NetBSD: softfloat-source.txt,v 1.2 2006/11/24 19:46:58 christos Exp $ 2*2fe8fb19SBen Gras 3*2fe8fb19SBen GrasSoftFloat Release 2a Source Documentation 4*2fe8fb19SBen Gras 5*2fe8fb19SBen GrasJohn R. Hauser 6*2fe8fb19SBen Gras1998 December 14 7*2fe8fb19SBen Gras 8*2fe8fb19SBen Gras 9*2fe8fb19SBen Gras------------------------------------------------------------------------------- 10*2fe8fb19SBen GrasIntroduction 11*2fe8fb19SBen Gras 12*2fe8fb19SBen GrasSoftFloat is a software implementation of floating-point that conforms to 13*2fe8fb19SBen Grasthe IEC/IEEE Standard for Binary Floating-Point Arithmetic. SoftFloat can 14*2fe8fb19SBen Grassupport four floating-point formats: single precision, double precision, 15*2fe8fb19SBen Grasextended double precision, and quadruple precision. All operations required 16*2fe8fb19SBen Grasby the IEEE Standard are implemented, except for conversions to and from 17*2fe8fb19SBen Grasdecimal. SoftFloat is distributed in the form of C source code, so a 18*2fe8fb19SBen GrasC compiler is needed to compile the code. Support for the extended double- 19*2fe8fb19SBen Grasprecision and quadruple-precision formats is dependent on the C compiler 20*2fe8fb19SBen Grasimplementing a 64-bit integer type. 21*2fe8fb19SBen Gras 22*2fe8fb19SBen GrasThis document gives information needed for compiling and/or porting 23*2fe8fb19SBen GrasSoftFloat. 24*2fe8fb19SBen Gras 25*2fe8fb19SBen GrasThe source code for SoftFloat is intended to be relatively machine- 26*2fe8fb19SBen Grasindependent and should be compilable using any ISO/ANSI C compiler. At the 27*2fe8fb19SBen Grastime of this writing, SoftFloat has been successfully compiled with the GNU 28*2fe8fb19SBen GrasC Compiler (`gcc') for several platforms. 29*2fe8fb19SBen Gras 30*2fe8fb19SBen Gras 31*2fe8fb19SBen Gras------------------------------------------------------------------------------- 32*2fe8fb19SBen GrasLimitations 33*2fe8fb19SBen Gras 34*2fe8fb19SBen GrasSoftFloat as written requires an ISO/ANSI-style C compiler. No attempt has 35*2fe8fb19SBen Grasbeen made to accommodate compilers that are not ISO-conformant. Older ``K&R- 36*2fe8fb19SBen Grasstyle'' compilers are not adequate for compiling SoftFloat. All testing I 37*2fe8fb19SBen Grashave done so far has been with the GNU C Compiler. Compilation with other 38*2fe8fb19SBen Grascompilers should be possible but has not been tested. 39*2fe8fb19SBen Gras 40*2fe8fb19SBen GrasThe SoftFloat sources assume that source code file names can be longer than 41*2fe8fb19SBen Gras8 characters. In order to compile under an MS-DOS-type system, many of the 42*2fe8fb19SBen Grassource files will need to be renamed, and the source and makefiles edited 43*2fe8fb19SBen Grasappropriately. Once compiled, the SoftFloat binary does not depend on the 44*2fe8fb19SBen Grasexistence of long file names. 45*2fe8fb19SBen Gras 46*2fe8fb19SBen GrasThe underlying machine is assumed to be binary with a word size that is a 47*2fe8fb19SBen Graspower of 2. Bytes are 8 bits. Support for the extended double-precision 48*2fe8fb19SBen Grasand quadruple-precision formats depends on the C compiler implementing 49*2fe8fb19SBen Grasa 64-bit integer type. If the largest integer type supported by the 50*2fe8fb19SBen GrasC compiler is 32 bits, SoftFloat is limited to the single- and double- 51*2fe8fb19SBen Grasprecision formats. 52*2fe8fb19SBen Gras 53*2fe8fb19SBen Gras 54*2fe8fb19SBen Gras------------------------------------------------------------------------------- 55*2fe8fb19SBen GrasContents 56*2fe8fb19SBen Gras 57*2fe8fb19SBen Gras Introduction 58*2fe8fb19SBen Gras Limitations 59*2fe8fb19SBen Gras Contents 60*2fe8fb19SBen Gras Legal Notice 61*2fe8fb19SBen Gras SoftFloat Source Directory Structure 62*2fe8fb19SBen Gras SoftFloat Source Files 63*2fe8fb19SBen Gras processors/*.h 64*2fe8fb19SBen Gras softfloat/bits*/*/softfloat.h 65*2fe8fb19SBen Gras softfloat/bits*/*/milieu.h 66*2fe8fb19SBen Gras softfloat/bits*/*/softfloat-specialize 67*2fe8fb19SBen Gras softfloat/bits*/softfloat-macros 68*2fe8fb19SBen Gras softfloat/bits*/softfloat.c 69*2fe8fb19SBen Gras Steps to Creating a `softfloat.o' 70*2fe8fb19SBen Gras Making `softfloat.o' a Library 71*2fe8fb19SBen Gras Testing SoftFloat 72*2fe8fb19SBen Gras Timing SoftFloat 73*2fe8fb19SBen Gras Compiler Options and Efficiency 74*2fe8fb19SBen Gras Processor-Specific Optimization of `softfloat.c' Using `softfloat-macros' 75*2fe8fb19SBen Gras Contact Information 76*2fe8fb19SBen Gras 77*2fe8fb19SBen Gras 78*2fe8fb19SBen Gras 79*2fe8fb19SBen Gras------------------------------------------------------------------------------- 80*2fe8fb19SBen GrasLegal Notice 81*2fe8fb19SBen Gras 82*2fe8fb19SBen GrasSoftFloat was written by John R. Hauser. This work was made possible in 83*2fe8fb19SBen Graspart by the International Computer Science Institute, located at Suite 600, 84*2fe8fb19SBen Gras1947 Center Street, Berkeley, California 94704. Funding was partially 85*2fe8fb19SBen Grasprovided by the National Science Foundation under grant MIP-9311980. The 86*2fe8fb19SBen Grasoriginal version of this code was written as part of a project to build 87*2fe8fb19SBen Grasa fixed-point vector processor in collaboration with the University of 88*2fe8fb19SBen GrasCalifornia at Berkeley, overseen by Profs. Nelson Morgan and John Wawrzynek. 89*2fe8fb19SBen Gras 90*2fe8fb19SBen GrasTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 91*2fe8fb19SBen Grashas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 92*2fe8fb19SBen GrasTIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 93*2fe8fb19SBen GrasPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 94*2fe8fb19SBen GrasAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 95*2fe8fb19SBen Gras 96*2fe8fb19SBen Gras 97*2fe8fb19SBen Gras------------------------------------------------------------------------------- 98*2fe8fb19SBen GrasSoftFloat Source Directory Structure 99*2fe8fb19SBen Gras 100*2fe8fb19SBen GrasBecause SoftFloat is targeted to multiple platforms, its source code 101*2fe8fb19SBen Grasis slightly scattered between target-specific and target-independent 102*2fe8fb19SBen Grasdirectories and files. The directory structure is as follows: 103*2fe8fb19SBen Gras 104*2fe8fb19SBen Gras processors 105*2fe8fb19SBen Gras softfloat 106*2fe8fb19SBen Gras bits64 107*2fe8fb19SBen Gras templates 108*2fe8fb19SBen Gras 386-Win32-gcc 109*2fe8fb19SBen Gras SPARC-Solaris-gcc 110*2fe8fb19SBen Gras bits32 111*2fe8fb19SBen Gras templates 112*2fe8fb19SBen Gras 386-Win32-gcc 113*2fe8fb19SBen Gras SPARC-Solaris-gcc 114*2fe8fb19SBen Gras 115*2fe8fb19SBen GrasThe two topmost directories and their contents are: 116*2fe8fb19SBen Gras 117*2fe8fb19SBen Gras softfloat - Most of the source code needed for SoftFloat. 118*2fe8fb19SBen Gras processors - Target-specific header files that are not specific to 119*2fe8fb19SBen Gras SoftFloat. 120*2fe8fb19SBen Gras 121*2fe8fb19SBen GrasThe `softfloat' directory is further split into two parts: 122*2fe8fb19SBen Gras 123*2fe8fb19SBen Gras bits64 - SoftFloat implementation using 64-bit integers. 124*2fe8fb19SBen Gras bits32 - SoftFloat implementation using only 32-bit integers. 125*2fe8fb19SBen Gras 126*2fe8fb19SBen GrasWithin these directories are subdirectories for each of the targeted 127*2fe8fb19SBen Grasplatforms. The SoftFloat source code is distributed with targets 128*2fe8fb19SBen Gras`386-Win32-gcc' and `SPARC-Solaris-gcc' (and perhaps others) already 129*2fe8fb19SBen Grasprepared for both the 32-bit and 64-bit implementations. Source files that 130*2fe8fb19SBen Grasare not within these target-specific subdirectories are intended to be 131*2fe8fb19SBen Grastarget-independent. 132*2fe8fb19SBen Gras 133*2fe8fb19SBen GrasThe naming convention used for the target-specific directories is 134*2fe8fb19SBen Gras`<processor>-<executable-type>-<compiler>'. The names of the supplied 135*2fe8fb19SBen Grastarget directories should be interpreted as follows: 136*2fe8fb19SBen Gras 137*2fe8fb19SBen Gras <processor>: 138*2fe8fb19SBen Gras 386 - Intel 386-compatible processor. 139*2fe8fb19SBen Gras SPARC - SPARC processor (as used by Sun machines). 140*2fe8fb19SBen Gras <executable-type>: 141*2fe8fb19SBen Gras Win32 - Microsoft Win32 executable. 142*2fe8fb19SBen Gras Solaris - Sun Solaris executable. 143*2fe8fb19SBen Gras <compiler>: 144*2fe8fb19SBen Gras gcc - GNU C Compiler. 145*2fe8fb19SBen Gras 146*2fe8fb19SBen GrasYou do not need to maintain this convention if you do not want to. 147*2fe8fb19SBen Gras 148*2fe8fb19SBen GrasAlongside the supplied target-specific directories is a `templates' 149*2fe8fb19SBen Grasdirectory containing a set of ``generic'' target-specific source files. A 150*2fe8fb19SBen Grasnew target directory can be created by copying the `templates' directory and 151*2fe8fb19SBen Grasediting the files inside. (Complete instructions for porting SoftFloat to a 152*2fe8fb19SBen Grasnew target are in the section _Steps_to_Creating_a_`softfloat.o'_.) Note 153*2fe8fb19SBen Grasthat the `templates' directory will not work as a target directory without 154*2fe8fb19SBen Grassome editing. To avoid confusion, it would be wise to refrain from editing 155*2fe8fb19SBen Grasthe files inside `templates' directly. 156*2fe8fb19SBen Gras 157*2fe8fb19SBen Gras 158*2fe8fb19SBen Gras------------------------------------------------------------------------------- 159*2fe8fb19SBen GrasSoftFloat Source Files 160*2fe8fb19SBen Gras 161*2fe8fb19SBen GrasThe purpose of each source file is described below. In the following, 162*2fe8fb19SBen Grasthe `*' symbol is used in place of the name of a specific target, such as 163*2fe8fb19SBen Gras`386-Win32-gcc' or `SPARC-Solaris-gcc', or in place of some other text, as 164*2fe8fb19SBen Grasin `bits*' for either `bits32' or `bits64'. 165*2fe8fb19SBen Gras 166*2fe8fb19SBen Gras- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 167*2fe8fb19SBen Grasprocessors/*.h 168*2fe8fb19SBen Gras 169*2fe8fb19SBen GrasThe target-specific `processors' header file defines integer types 170*2fe8fb19SBen Grasof various sizes, and also defines certain C preprocessor macros that 171*2fe8fb19SBen Grascharacterize the target. The two examples supplied are `386-gcc.h' and 172*2fe8fb19SBen Gras`SPARC-gcc.h'. The naming convention used for processor header files is 173*2fe8fb19SBen Gras`<processor>-<compiler>.h'. 174*2fe8fb19SBen Gras 175*2fe8fb19SBen GrasIf 64-bit integers are supported by the compiler, the macro name `BITS64' 176*2fe8fb19SBen Grasshould be defined here along with the corresponding 64-bit integer 177*2fe8fb19SBen Grastypes. In addition, the function-like macro `LIT64' must be defined for 178*2fe8fb19SBen Grasconstructing 64-bit integer literals (constants). The `LIT64' macro is used 179*2fe8fb19SBen Grasconsistently in the SoftFloat code to annotate 64-bit literals. 180*2fe8fb19SBen Gras 181*2fe8fb19SBen GrasIf `BITS64' is not defined, only the 32-bit version of SoftFloat can be 182*2fe8fb19SBen Grascompiled. If `BITS64' _is_ defined, either can be compiled. 183*2fe8fb19SBen Gras 184*2fe8fb19SBen GrasIf an inlining attribute (such as an `inline' keyword) is provided by the 185*2fe8fb19SBen Grascompiler, the macro `INLINE' should be defined to the appropriate keyword. 186*2fe8fb19SBen GrasIf not, `INLINE' can be set to the keyword `static'. The `INLINE' macro 187*2fe8fb19SBen Grasappears in the SoftFloat source code before every function that should 188*2fe8fb19SBen Grasbe inlined by the compiler. SoftFloat depends on inlining to obtain 189*2fe8fb19SBen Grasgood speed. Even if inlining cannot be forced with a language keyword, 190*2fe8fb19SBen Grasthe compiler may still be able to perform inlining on its own as an 191*2fe8fb19SBen Grasoptimization. If a command-line option is needed to convince the compiler 192*2fe8fb19SBen Grasto perform this optimization, this should be assured in the makefile. (See 193*2fe8fb19SBen Grasthe section _Compiler_Options_and_Efficiency_ below.) 194*2fe8fb19SBen Gras 195*2fe8fb19SBen Gras- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196*2fe8fb19SBen Grassoftfloat/bits*/*/softfloat.h 197*2fe8fb19SBen Gras 198*2fe8fb19SBen GrasThe target-specific `softfloat.h' header file defines the SoftFloat 199*2fe8fb19SBen Grasinterface as seen by clients. 200*2fe8fb19SBen Gras 201*2fe8fb19SBen GrasUnlike the actual function definitions in `softfloat.c', the declarations 202*2fe8fb19SBen Grasin `softfloat.h' do not use any of the types defined by the `processors' 203*2fe8fb19SBen Grasheader file. This is done so that clients will not have to include the 204*2fe8fb19SBen Gras`processors' header file in order to use SoftFloat. Nevertheless, the 205*2fe8fb19SBen Grastarget-specific declarations in `softfloat.h' must match what `softfloat.c' 206*2fe8fb19SBen Grasexpects. For example, if `int32' is defined as `int' in the `processors' 207*2fe8fb19SBen Grasheader file, then in `softfloat.h' the output of `float32_to_int32' should 208*2fe8fb19SBen Grasbe stated as `int', although in `softfloat.c' it is given in target- 209*2fe8fb19SBen Grasindependent form as `int32'. 210*2fe8fb19SBen Gras 211*2fe8fb19SBen GrasFor the `bits64' implementation of SoftFloat, the macro names `FLOATX80' and 212*2fe8fb19SBen Gras`FLOAT128' must be defined in order for the extended double-precision and 213*2fe8fb19SBen Grasquadruple-precision formats to be enabled in the code. Conversely, either 214*2fe8fb19SBen Grasor both of the extended formats can be disabled by simply removing the 215*2fe8fb19SBen Gras`#define' of the respective macro. When an extended format is not enabled, 216*2fe8fb19SBen Grasnone of the functions that either input or output the format are defined, 217*2fe8fb19SBen Grasand no space is taken up in `softfloat.o' by such functions. There is no 218*2fe8fb19SBen Grasprovision for disabling the usual single- and double-precision formats. 219*2fe8fb19SBen Gras 220*2fe8fb19SBen Gras- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 221*2fe8fb19SBen Grassoftfloat/bits*/*/milieu.h 222*2fe8fb19SBen Gras 223*2fe8fb19SBen GrasThe target-specific `milieu.h' header file provides declarations that are 224*2fe8fb19SBen Grasneeded to compile SoftFloat. In addition, deviations from ISO/ANSI C by 225*2fe8fb19SBen Grasthe compiler (such as names not properly declared in system header files) 226*2fe8fb19SBen Grasare corrected in this header if possible. 227*2fe8fb19SBen Gras 228*2fe8fb19SBen Gras- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 229*2fe8fb19SBen Grassoftfloat/bits*/*/softfloat-specialize 230*2fe8fb19SBen Gras 231*2fe8fb19SBen GrasThis target-specific C source fragment defines: 232*2fe8fb19SBen Gras 233*2fe8fb19SBen Gras-- whether tininess for underflow is detected before or after rounding by 234*2fe8fb19SBen Gras default; 235*2fe8fb19SBen Gras-- what (if anything) special happens when exceptions are raised; 236*2fe8fb19SBen Gras-- how signaling NaNs are distinguished from quiet NaNs; 237*2fe8fb19SBen Gras-- the default generated quiet NaNs; and 238*2fe8fb19SBen Gras-- how NaNs are propagated from function inputs to output. 239*2fe8fb19SBen Gras 240*2fe8fb19SBen GrasThese details are not decided by the IEC/IEEE Standard. This fragment is 241*2fe8fb19SBen Grasincluded verbatim within `softfloat.c' when SoftFloat is compiled. 242*2fe8fb19SBen Gras 243*2fe8fb19SBen Gras- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 244*2fe8fb19SBen Grassoftfloat/bits*/softfloat-macros 245*2fe8fb19SBen Gras 246*2fe8fb19SBen GrasThis target-independent C source fragment defines a number of arithmetic 247*2fe8fb19SBen Grasfunctions used as primitives within the `softfloat.c' source. Most of the 248*2fe8fb19SBen Grasfunctions defined here are intended to be inlined for efficiency. This 249*2fe8fb19SBen Grasfragment is included verbatim within `softfloat.c' when SoftFloat is 250*2fe8fb19SBen Grascompiled. 251*2fe8fb19SBen Gras 252*2fe8fb19SBen GrasTarget-specific variations on this file are possible. See the section 253*2fe8fb19SBen Gras_Processor-Specific_Optimization_of_`softfloat.c'_Using_`softfloat-macros'_ 254*2fe8fb19SBen Grasbelow. 255*2fe8fb19SBen Gras 256*2fe8fb19SBen Gras- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 257*2fe8fb19SBen Grassoftfloat/bits*/softfloat.c 258*2fe8fb19SBen Gras 259*2fe8fb19SBen GrasThe target-independent `softfloat.c' source file contains the body of the 260*2fe8fb19SBen GrasSoftFloat implementation. 261*2fe8fb19SBen Gras 262*2fe8fb19SBen Gras- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 263*2fe8fb19SBen Gras 264*2fe8fb19SBen GrasThe inclusion of the files above within each other (using `#include') can be 265*2fe8fb19SBen Grasshown graphically as follows: 266*2fe8fb19SBen Gras 267*2fe8fb19SBen Gras softfloat/bits*/softfloat.c 268*2fe8fb19SBen Gras softfloat/bits*/*/milieu.h 269*2fe8fb19SBen Gras processors/*.h 270*2fe8fb19SBen Gras softfloat/bits*/*/softfloat.h 271*2fe8fb19SBen Gras softfloat/bits*/*/softfloat-specialize 272*2fe8fb19SBen Gras softfloat/bits*/softfloat-macros 273*2fe8fb19SBen Gras 274*2fe8fb19SBen GrasNote in particular that `softfloat.c' does not include the `processors' 275*2fe8fb19SBen Grasheader file directly. Rather, `softfloat.c' includes the target-specific 276*2fe8fb19SBen Gras`milieu.h' header file, which in turn includes the processor header file. 277*2fe8fb19SBen Gras 278*2fe8fb19SBen Gras 279*2fe8fb19SBen Gras------------------------------------------------------------------------------- 280*2fe8fb19SBen GrasSteps to Creating a `softfloat.o' 281*2fe8fb19SBen Gras 282*2fe8fb19SBen GrasPorting and/or compiling SoftFloat involves the following steps: 283*2fe8fb19SBen Gras 284*2fe8fb19SBen Gras1. If one does not already exist, create an appropriate `.h' file in the 285*2fe8fb19SBen Gras `processors' directory. 286*2fe8fb19SBen Gras 287*2fe8fb19SBen Gras2. If `BITS64' is defined in the `processors' header file, choose whether 288*2fe8fb19SBen Gras to compile the 32-bit or 64-bit implementation of SoftFloat. If 289*2fe8fb19SBen Gras `BITS64' is not defined, your only choice is the 32-bit implementation. 290*2fe8fb19SBen Gras The remaining steps occur within either the `bits32' or `bits64' 291*2fe8fb19SBen Gras subdirectories. 292*2fe8fb19SBen Gras 293*2fe8fb19SBen Gras3. If one does not already exist, create an appropriate target-specific 294*2fe8fb19SBen Gras subdirectory by copying the given `templates' directory. 295*2fe8fb19SBen Gras 296*2fe8fb19SBen Gras4. In the target-specific subdirectory, edit the files `softfloat-specialize' 297*2fe8fb19SBen Gras and `softfloat.h' to define the desired exception handling functions 298*2fe8fb19SBen Gras and mode control values. In the `softfloat.h' header file, ensure also 299*2fe8fb19SBen Gras that all declarations give the proper target-specific type (such as 300*2fe8fb19SBen Gras `int' or `long') corresponding to the target-independent type used in 301*2fe8fb19SBen Gras `softfloat.c' (such as `int32'). None of the type names declared in the 302*2fe8fb19SBen Gras `processors' header file should appear in `softfloat.h'. 303*2fe8fb19SBen Gras 304*2fe8fb19SBen Gras5. In the target-specific subdirectory, edit the files `milieu.h' and 305*2fe8fb19SBen Gras `Makefile' to reflect the current environment. 306*2fe8fb19SBen Gras 307*2fe8fb19SBen Gras6. In the target-specific subdirectory, execute `make'. 308*2fe8fb19SBen Gras 309*2fe8fb19SBen GrasFor the targets that are supplied, if the expected compiler is available 310*2fe8fb19SBen Gras(usually `gcc'), it should only be necessary to execute `make' in the 311*2fe8fb19SBen Grastarget-specific subdirectory. 312*2fe8fb19SBen Gras 313*2fe8fb19SBen Gras 314*2fe8fb19SBen Gras------------------------------------------------------------------------------- 315*2fe8fb19SBen GrasMaking `softfloat.o' a Library 316*2fe8fb19SBen Gras 317*2fe8fb19SBen GrasSoftFloat is not made into a software library by the supplied makefile. 318*2fe8fb19SBen GrasIf desired, `softfloat.o' can easily be put into its own library (in Unix, 319*2fe8fb19SBen Gras`softfloat.a') using the usual system tool (in Unix, `ar'). 320*2fe8fb19SBen Gras 321*2fe8fb19SBen Gras 322*2fe8fb19SBen Gras------------------------------------------------------------------------------- 323*2fe8fb19SBen GrasTesting SoftFloat 324*2fe8fb19SBen Gras 325*2fe8fb19SBen GrasSoftFloat can be tested using the `testsoftfloat' program by the same 326*2fe8fb19SBen Grasauthor. The `testsoftfloat' program is part of the TestFloat package 327*2fe8fb19SBen Grasavailable at the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/ 328*2fe8fb19SBen GrasTestFloat.html'. 329*2fe8fb19SBen Gras 330*2fe8fb19SBen Gras 331*2fe8fb19SBen Gras------------------------------------------------------------------------------- 332*2fe8fb19SBen GrasTiming SoftFloat 333*2fe8fb19SBen Gras 334*2fe8fb19SBen GrasA program called `timesoftfloat' for timing the SoftFloat functions is 335*2fe8fb19SBen Grasincluded with the SoftFloat source code. Compiling `timesoftfloat' should 336*2fe8fb19SBen Graspose no difficulties once `softfloat.o' exists. The supplied makefile 337*2fe8fb19SBen Graswill create a `timesoftfloat' executable by default after generating 338*2fe8fb19SBen Gras`softfloat.o'. See `timesoftfloat.txt' for documentation about using 339*2fe8fb19SBen Gras`timesoftfloat'. 340*2fe8fb19SBen Gras 341*2fe8fb19SBen Gras 342*2fe8fb19SBen Gras------------------------------------------------------------------------------- 343*2fe8fb19SBen GrasCompiler Options and Efficiency 344*2fe8fb19SBen Gras 345*2fe8fb19SBen GrasIn order to get good speed with SoftFloat, it is important that the compiler 346*2fe8fb19SBen Grasinline the routines that have been marked `INLINE' in the code. Even if 347*2fe8fb19SBen Grasinlining cannot be forced by an appropriate definition of the `INLINE' 348*2fe8fb19SBen Grasmacro, the compiler may still be able to perform inlining on its own as 349*2fe8fb19SBen Grasan optimization. In that case, the makefile should be edited to give the 350*2fe8fb19SBen Grascompiler whatever option is required to cause it to inline small functions. 351*2fe8fb19SBen Gras 352*2fe8fb19SBen GrasThe ability of the processor to do fast shifts has been assumed. Efficiency 353*2fe8fb19SBen Graswill not be as good on processors for which this is not the case (such as 354*2fe8fb19SBen Grasthe original Motorola 68000 or Intel 8086 processors). 355*2fe8fb19SBen Gras 356*2fe8fb19SBen Gras 357*2fe8fb19SBen Gras------------------------------------------------------------------------------- 358*2fe8fb19SBen GrasProcessor-Specific Optimization of `softfloat.c' Using `softfloat-macros' 359*2fe8fb19SBen Gras 360*2fe8fb19SBen GrasThe `softfloat-macros' source fragment defines arithmetic functions used 361*2fe8fb19SBen Grasas primitives by `softfloat.c'. This file has been written in a target- 362*2fe8fb19SBen Grasindependent form. For a given target, it may be possible to improve on 363*2fe8fb19SBen Grasthese functions using target-specific and/or non-ISO-C features (such 364*2fe8fb19SBen Grasas `asm' statements). For example, one of the ``macro'' functions takes 365*2fe8fb19SBen Grastwo word-size integers and returns their full product in two words. 366*2fe8fb19SBen GrasThis operation can be done directly in hardware on many processors; but 367*2fe8fb19SBen Grasbecause it is not available through standard C, the function defined in 368*2fe8fb19SBen Gras`softfloat-macros' uses four multiplies to achieve the same result. 369*2fe8fb19SBen Gras 370*2fe8fb19SBen GrasTo address these shortcomings, a customized version of `softfloat-macros' 371*2fe8fb19SBen Grascan be created in any of the target-specific subdirectories. A simple 372*2fe8fb19SBen Grasmodification to the target's makefile should be sufficient to ensure that 373*2fe8fb19SBen Grasthe custom version is used instead of the generic one. 374*2fe8fb19SBen Gras 375*2fe8fb19SBen Gras 376*2fe8fb19SBen Gras------------------------------------------------------------------------------- 377*2fe8fb19SBen GrasContact Information 378*2fe8fb19SBen Gras 379*2fe8fb19SBen GrasAt the time of this writing, the most up-to-date information about 380*2fe8fb19SBen GrasSoftFloat and the latest release can be found at the Web page `http:// 381*2fe8fb19SBen GrasHTTP.CS.Berkeley.EDU/~jhauser/arithmetic/SoftFloat.html'. 382*2fe8fb19SBen Gras 383*2fe8fb19SBen Gras 384