From bbe46bb883f76ff56e244c795aeddcfc6b7cb0e4 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 9 Nov 2022 02:45:07 +0100 Subject: [PATCH] move float libss into libsrc/float, move tests into the correct dirs for the testbench, move includes to toplevel include dir --- {test/float/include => include}/_float.h | 0 {test/float/include => include}/math.h | 0 libsrc/Makefile | 2 + {test => libsrc}/float/cbmkernal/cbmfp.h | 0 .../float/cbmkernal/cc65wrapper.s | 0 {test => libsrc}/float/cbmkernal/ffloor.c | 0 .../float/cbmkernal/float-vic20.inc | 0 {test => libsrc}/float/cbmkernal/float.inc | 0 {test => libsrc}/float/cbmkernal/float.s | 0 {test => libsrc}/float/cbmkernal/ftoa.c | 0 {test => libsrc}/float/ieee754/_ftostr.c | 0 {test => libsrc}/float/ieee754/afloat.s | 0 {test => libsrc}/float/ieee754/aufloat.s | 0 {test => libsrc}/float/ieee754/axfloat.s | 0 {test => libsrc}/float/ieee754/axufloat.s | 0 {test => libsrc}/float/ieee754/eaxfloat.s | 0 {test => libsrc}/float/ieee754/eaxufloat.s | 0 {test => libsrc}/float/ieee754/fbnegeax.s | 0 {test => libsrc}/float/ieee754/feaxint.s | 0 {test => libsrc}/float/ieee754/feaxlong.s | 0 {test => libsrc}/float/ieee754/ftosaddeax.s | 0 {test => libsrc}/float/ieee754/ftosdiveax.s | 0 {test => libsrc}/float/ieee754/ftoseqeax.s | 0 {test => libsrc}/float/ieee754/ftosgeeax.s | 0 {test => libsrc}/float/ieee754/ftosgteax.s | 0 {test => libsrc}/float/ieee754/ftosleeax.s | 0 {test => libsrc}/float/ieee754/ftoslteax.s | 0 {test => libsrc}/float/ieee754/ftosmuleax.s | 0 {test => libsrc}/float/ieee754/ftosneeax.s | 0 {test => libsrc}/float/ieee754/ftossubeax.s | 0 {test => libsrc}/float/ieee754/ieee754.inc | 0 {test => libsrc}/float/readme.md | 74 +- {test => libsrc}/float/softfloat/6502-CC65.h | 0 {test => libsrc}/float/softfloat/README.txt | 0 .../float/softfloat/SoftFloat.txt | 0 .../float/softfloat/cc65wrapper.s | 0 {test => libsrc}/float/softfloat/ftostr.c | 0 .../float/softfloat/history.txt | 0 .../float/softfloat/macros.h | 0 {test => libsrc}/float/softfloat/milieu.h | 0 {test => libsrc}/float/softfloat/softfloat.c | 4 +- {test => libsrc}/float/softfloat/softfloat.h | 0 .../float/softfloat/source.txt | 0 .../float/softfloat/specialize.h | 0 {test => libsrc}/float/woz/_ftostr.c | 0 {test => libsrc}/float/woz/afloat.s | 0 {test => libsrc}/float/woz/aufloat.s | 0 {test => libsrc}/float/woz/axfloat.s | 0 {test => libsrc}/float/woz/axufloat.s | 0 {test => libsrc}/float/woz/eaxfloat.s | 0 {test => libsrc}/float/woz/eaxufloat.s | 0 {test => libsrc}/float/woz/fbnegeax.s | 0 {test => libsrc}/float/woz/feaxint.s | 0 {test => libsrc}/float/woz/feaxlong.s | 0 {test => libsrc}/float/woz/ftosaddeax.s | 0 {test => libsrc}/float/woz/ftosdiveax.s | 0 {test => libsrc}/float/woz/ftoseqeax.s | 0 {test => libsrc}/float/woz/ftosgeeax.s | 0 {test => libsrc}/float/woz/ftosgteax.s | 0 {test => libsrc}/float/woz/ftosleeax.s | 0 {test => libsrc}/float/woz/ftoslteax.s | 0 {test => libsrc}/float/woz/ftosmuleax.s | 0 {test => libsrc}/float/woz/ftosneeax.s | 0 {test => libsrc}/float/woz/ftossubeax.s | 0 {test => libsrc}/float/woz/wozfp.inc | 0 {test => libsrc}/float/woz/wozfp.s | 0 test/asm/listing/Makefile | 2 +- test/float/Makefile | 8 +- test/float/softfloat/Makefile | 9 +- test/float/softfloat/timesoftfloat.c | 1084 +++++++++++++++++ test/todo/float-conv-float-to-char.c | 95 ++ test/todo/float-conv-float-to-schar.c | 94 ++ test/{float => val}/float-basic.c | 66 +- test/{float => val}/float-cmp.c | 85 +- test/{float => val}/float-conv.c | 7 +- test/{float => val}/float-minimal.c | 0 test/{float => val}/float-misc.c | 0 77 files changed, 1398 insertions(+), 132 deletions(-) rename {test/float/include => include}/_float.h (100%) rename {test/float/include => include}/math.h (100%) rename {test => libsrc}/float/cbmkernal/cbmfp.h (100%) rename {test => libsrc}/float/cbmkernal/cc65wrapper.s (100%) rename {test => libsrc}/float/cbmkernal/ffloor.c (100%) rename {test => libsrc}/float/cbmkernal/float-vic20.inc (100%) rename {test => libsrc}/float/cbmkernal/float.inc (100%) rename {test => libsrc}/float/cbmkernal/float.s (100%) rename {test => libsrc}/float/cbmkernal/ftoa.c (100%) rename {test => libsrc}/float/ieee754/_ftostr.c (100%) rename {test => libsrc}/float/ieee754/afloat.s (100%) rename {test => libsrc}/float/ieee754/aufloat.s (100%) rename {test => libsrc}/float/ieee754/axfloat.s (100%) rename {test => libsrc}/float/ieee754/axufloat.s (100%) rename {test => libsrc}/float/ieee754/eaxfloat.s (100%) rename {test => libsrc}/float/ieee754/eaxufloat.s (100%) rename {test => libsrc}/float/ieee754/fbnegeax.s (100%) rename {test => libsrc}/float/ieee754/feaxint.s (100%) rename {test => libsrc}/float/ieee754/feaxlong.s (100%) rename {test => libsrc}/float/ieee754/ftosaddeax.s (100%) rename {test => libsrc}/float/ieee754/ftosdiveax.s (100%) rename {test => libsrc}/float/ieee754/ftoseqeax.s (100%) rename {test => libsrc}/float/ieee754/ftosgeeax.s (100%) rename {test => libsrc}/float/ieee754/ftosgteax.s (100%) rename {test => libsrc}/float/ieee754/ftosleeax.s (100%) rename {test => libsrc}/float/ieee754/ftoslteax.s (100%) rename {test => libsrc}/float/ieee754/ftosmuleax.s (100%) rename {test => libsrc}/float/ieee754/ftosneeax.s (100%) rename {test => libsrc}/float/ieee754/ftossubeax.s (100%) rename {test => libsrc}/float/ieee754/ieee754.inc (100%) rename {test => libsrc}/float/readme.md (60%) rename {test => libsrc}/float/softfloat/6502-CC65.h (100%) rename {test => libsrc}/float/softfloat/README.txt (100%) rename {test => libsrc}/float/softfloat/SoftFloat.txt (100%) rename {test => libsrc}/float/softfloat/cc65wrapper.s (100%) rename {test => libsrc}/float/softfloat/ftostr.c (100%) rename test/float/softfloat/SoftFloat-history.txt => libsrc/float/softfloat/history.txt (100%) rename test/float/softfloat/softfloat-macros => libsrc/float/softfloat/macros.h (100%) rename {test => libsrc}/float/softfloat/milieu.h (100%) rename {test => libsrc}/float/softfloat/softfloat.c (99%) rename {test => libsrc}/float/softfloat/softfloat.h (100%) rename test/float/softfloat/SoftFloat-source.txt => libsrc/float/softfloat/source.txt (100%) rename test/float/softfloat/softfloat-specialize => libsrc/float/softfloat/specialize.h (100%) rename {test => libsrc}/float/woz/_ftostr.c (100%) rename {test => libsrc}/float/woz/afloat.s (100%) rename {test => libsrc}/float/woz/aufloat.s (100%) rename {test => libsrc}/float/woz/axfloat.s (100%) rename {test => libsrc}/float/woz/axufloat.s (100%) rename {test => libsrc}/float/woz/eaxfloat.s (100%) rename {test => libsrc}/float/woz/eaxufloat.s (100%) rename {test => libsrc}/float/woz/fbnegeax.s (100%) rename {test => libsrc}/float/woz/feaxint.s (100%) rename {test => libsrc}/float/woz/feaxlong.s (100%) rename {test => libsrc}/float/woz/ftosaddeax.s (100%) rename {test => libsrc}/float/woz/ftosdiveax.s (100%) rename {test => libsrc}/float/woz/ftoseqeax.s (100%) rename {test => libsrc}/float/woz/ftosgeeax.s (100%) rename {test => libsrc}/float/woz/ftosgteax.s (100%) rename {test => libsrc}/float/woz/ftosleeax.s (100%) rename {test => libsrc}/float/woz/ftoslteax.s (100%) rename {test => libsrc}/float/woz/ftosmuleax.s (100%) rename {test => libsrc}/float/woz/ftosneeax.s (100%) rename {test => libsrc}/float/woz/ftossubeax.s (100%) rename {test => libsrc}/float/woz/wozfp.inc (100%) rename {test => libsrc}/float/woz/wozfp.s (100%) create mode 100644 test/float/softfloat/timesoftfloat.c create mode 100644 test/todo/float-conv-float-to-char.c create mode 100644 test/todo/float-conv-float-to-schar.c rename test/{float => val}/float-basic.c (88%) rename test/{float => val}/float-cmp.c (66%) rename test/{float => val}/float-conv.c (99%) rename test/{float => val}/float-minimal.c (100%) rename test/{float => val}/float-misc.c (100%) diff --git a/test/float/include/_float.h b/include/_float.h similarity index 100% rename from test/float/include/_float.h rename to include/_float.h diff --git a/test/float/include/math.h b/include/math.h similarity index 100% rename from test/float/include/math.h rename to include/math.h diff --git a/libsrc/Makefile b/libsrc/Makefile index 2018de801..8de4d9dd0 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -140,6 +140,7 @@ GEOSDIRS = common \ conio \ disk \ dlgbox \ + float/softfloat \ file \ graph \ memory \ @@ -178,6 +179,7 @@ SRCDIRS += common \ conio \ dbg \ em \ + float/softfloat \ joystick \ mouse \ runtime \ diff --git a/test/float/cbmkernal/cbmfp.h b/libsrc/float/cbmkernal/cbmfp.h similarity index 100% rename from test/float/cbmkernal/cbmfp.h rename to libsrc/float/cbmkernal/cbmfp.h diff --git a/test/float/cbmkernal/cc65wrapper.s b/libsrc/float/cbmkernal/cc65wrapper.s similarity index 100% rename from test/float/cbmkernal/cc65wrapper.s rename to libsrc/float/cbmkernal/cc65wrapper.s diff --git a/test/float/cbmkernal/ffloor.c b/libsrc/float/cbmkernal/ffloor.c similarity index 100% rename from test/float/cbmkernal/ffloor.c rename to libsrc/float/cbmkernal/ffloor.c diff --git a/test/float/cbmkernal/float-vic20.inc b/libsrc/float/cbmkernal/float-vic20.inc similarity index 100% rename from test/float/cbmkernal/float-vic20.inc rename to libsrc/float/cbmkernal/float-vic20.inc diff --git a/test/float/cbmkernal/float.inc b/libsrc/float/cbmkernal/float.inc similarity index 100% rename from test/float/cbmkernal/float.inc rename to libsrc/float/cbmkernal/float.inc diff --git a/test/float/cbmkernal/float.s b/libsrc/float/cbmkernal/float.s similarity index 100% rename from test/float/cbmkernal/float.s rename to libsrc/float/cbmkernal/float.s diff --git a/test/float/cbmkernal/ftoa.c b/libsrc/float/cbmkernal/ftoa.c similarity index 100% rename from test/float/cbmkernal/ftoa.c rename to libsrc/float/cbmkernal/ftoa.c diff --git a/test/float/ieee754/_ftostr.c b/libsrc/float/ieee754/_ftostr.c similarity index 100% rename from test/float/ieee754/_ftostr.c rename to libsrc/float/ieee754/_ftostr.c diff --git a/test/float/ieee754/afloat.s b/libsrc/float/ieee754/afloat.s similarity index 100% rename from test/float/ieee754/afloat.s rename to libsrc/float/ieee754/afloat.s diff --git a/test/float/ieee754/aufloat.s b/libsrc/float/ieee754/aufloat.s similarity index 100% rename from test/float/ieee754/aufloat.s rename to libsrc/float/ieee754/aufloat.s diff --git a/test/float/ieee754/axfloat.s b/libsrc/float/ieee754/axfloat.s similarity index 100% rename from test/float/ieee754/axfloat.s rename to libsrc/float/ieee754/axfloat.s diff --git a/test/float/ieee754/axufloat.s b/libsrc/float/ieee754/axufloat.s similarity index 100% rename from test/float/ieee754/axufloat.s rename to libsrc/float/ieee754/axufloat.s diff --git a/test/float/ieee754/eaxfloat.s b/libsrc/float/ieee754/eaxfloat.s similarity index 100% rename from test/float/ieee754/eaxfloat.s rename to libsrc/float/ieee754/eaxfloat.s diff --git a/test/float/ieee754/eaxufloat.s b/libsrc/float/ieee754/eaxufloat.s similarity index 100% rename from test/float/ieee754/eaxufloat.s rename to libsrc/float/ieee754/eaxufloat.s diff --git a/test/float/ieee754/fbnegeax.s b/libsrc/float/ieee754/fbnegeax.s similarity index 100% rename from test/float/ieee754/fbnegeax.s rename to libsrc/float/ieee754/fbnegeax.s diff --git a/test/float/ieee754/feaxint.s b/libsrc/float/ieee754/feaxint.s similarity index 100% rename from test/float/ieee754/feaxint.s rename to libsrc/float/ieee754/feaxint.s diff --git a/test/float/ieee754/feaxlong.s b/libsrc/float/ieee754/feaxlong.s similarity index 100% rename from test/float/ieee754/feaxlong.s rename to libsrc/float/ieee754/feaxlong.s diff --git a/test/float/ieee754/ftosaddeax.s b/libsrc/float/ieee754/ftosaddeax.s similarity index 100% rename from test/float/ieee754/ftosaddeax.s rename to libsrc/float/ieee754/ftosaddeax.s diff --git a/test/float/ieee754/ftosdiveax.s b/libsrc/float/ieee754/ftosdiveax.s similarity index 100% rename from test/float/ieee754/ftosdiveax.s rename to libsrc/float/ieee754/ftosdiveax.s diff --git a/test/float/ieee754/ftoseqeax.s b/libsrc/float/ieee754/ftoseqeax.s similarity index 100% rename from test/float/ieee754/ftoseqeax.s rename to libsrc/float/ieee754/ftoseqeax.s diff --git a/test/float/ieee754/ftosgeeax.s b/libsrc/float/ieee754/ftosgeeax.s similarity index 100% rename from test/float/ieee754/ftosgeeax.s rename to libsrc/float/ieee754/ftosgeeax.s diff --git a/test/float/ieee754/ftosgteax.s b/libsrc/float/ieee754/ftosgteax.s similarity index 100% rename from test/float/ieee754/ftosgteax.s rename to libsrc/float/ieee754/ftosgteax.s diff --git a/test/float/ieee754/ftosleeax.s b/libsrc/float/ieee754/ftosleeax.s similarity index 100% rename from test/float/ieee754/ftosleeax.s rename to libsrc/float/ieee754/ftosleeax.s diff --git a/test/float/ieee754/ftoslteax.s b/libsrc/float/ieee754/ftoslteax.s similarity index 100% rename from test/float/ieee754/ftoslteax.s rename to libsrc/float/ieee754/ftoslteax.s diff --git a/test/float/ieee754/ftosmuleax.s b/libsrc/float/ieee754/ftosmuleax.s similarity index 100% rename from test/float/ieee754/ftosmuleax.s rename to libsrc/float/ieee754/ftosmuleax.s diff --git a/test/float/ieee754/ftosneeax.s b/libsrc/float/ieee754/ftosneeax.s similarity index 100% rename from test/float/ieee754/ftosneeax.s rename to libsrc/float/ieee754/ftosneeax.s diff --git a/test/float/ieee754/ftossubeax.s b/libsrc/float/ieee754/ftossubeax.s similarity index 100% rename from test/float/ieee754/ftossubeax.s rename to libsrc/float/ieee754/ftossubeax.s diff --git a/test/float/ieee754/ieee754.inc b/libsrc/float/ieee754/ieee754.inc similarity index 100% rename from test/float/ieee754/ieee754.inc rename to libsrc/float/ieee754/ieee754.inc diff --git a/test/float/readme.md b/libsrc/float/readme.md similarity index 60% rename from test/float/readme.md rename to libsrc/float/readme.md index efe9bf3de..3b34c291a 100644 --- a/test/float/readme.md +++ b/libsrc/float/readme.md @@ -150,61 +150,61 @@ historical float routines by woz :) unfortunately not ieee754 these must be available in the runtime library ``` -func description cbmfp wozfp 754 codegen.c +func description softfloat cbmfp wozfp 754 codegen.c -aufloat Primary 8bit unsigned -> float * - - g_regfloat -afloat Primary 8bit signed -> float * - - g_regfloat -axufloat Primary 16bit unsigned -> float * - - g_regfloat -axfloat Primary 16bit signed -> float * - - g_regfloat -eaxufloat Primary 32bit unsigned -> float * - - g_regfloat -eaxfloat Primary 32bit signed -> float * - - g_regfloat +aufloat Primary 8bit unsigned -> float - * - - g_regfloat +afloat Primary 8bit signed -> float - * - - g_regfloat +axufloat Primary 16bit unsigned -> float * * - - g_regfloat +axfloat Primary 16bit signed -> float * * - - g_regfloat +eaxufloat Primary 32bit unsigned -> float * * - - g_regfloat +eaxfloat Primary 32bit signed -> float * * - - g_regfloat -feaxint Primary float -> 16bit int * - - g_regint -feaxlong Primary float -> 32bit long * - - g_reglong +feaxint Primary float -> 16bit int - * - - g_regint +feaxlong Primary float -> 32bit long - * - - g_reglong -ftosaddeax Primary = TOS + Primary * ? ? g_add -ftossubeax Primary = TOS - Primary * ? ? g_sub -ftosrsubeax Primary = Primary - TOS - - - g_rsub -ftosmuleax Primary = TOS * Primary * ? - g_mul -ftosdiveax Primary = TOS / Primary * ? - g_div +ftosaddeax Primary = TOS + Primary * * ? ? g_add +ftossubeax Primary = TOS - Primary * * ? ? g_sub +ftosrsubeax Primary = Primary - TOS - - - - g_rsub +ftosmuleax Primary = TOS * Primary * * ? - g_mul +ftosdiveax Primary = TOS / Primary * * ? - g_div -fnegeax Primary = -Primary - - - g_neg -fbnegeax Primary = !Primary (return bool!) * - - g_bneg +fnegeax Primary = -Primary - - - - g_neg +fbnegeax Primary = !Primary (return bool!) * * - - g_bneg -ftosgeeax Test for greater than or equal to * - - g_ge -ftosgteax Test for greater than * - - g_gt -ftosleeax Test for less than or equal to * - - g_le -ftoslteax Test for less than * - - g_lt -ftosneeax Test for not equal * - - g_ne -ftoseqeax Test for equal * - - g_eq +ftosgeeax Test for greater than or equal to * * - - g_ge +ftosgteax Test for greater than * * - - g_gt +ftosleeax Test for less than or equal to * * - - g_le +ftoslteax Test for less than * * - - g_lt +ftosneeax Test for not equal * * - - g_ne +ftoseqeax Test for equal * * - - g_eq ``` ### extra functions optional utility functions. ``` -func description cbmfp wozfp 754 +func description cbmfp cbmfp wozfp 754 -char *_ftostr(char *d, float s) * ? ? for printf family -float _strtof(char *d) * - - for scanf family +char *_ftostr(char *d, float s) * * ? ? for printf family +float _strtof(char *d) - * - - for scanf family ``` ### math.h functions these are optional, required for standard libm ``` -func description cbmfp wozfp 754 +func description softfloat cbmfp wozfp 754 /* C99 */ -float powf(float f, float a) * - - -float sinf(float s) * - - -float cosf(float s) * - - -float logf(float x) * * - -float expf(float x) * - - -float sqrtf(float x) * - - -float tanf(float x) * - - -float atanf(float x) * - - -float fabsf(float x) * - - -float roundf(float x) * - - -float truncf(float x) * - - +float powf(float f, float a) - * - - +float sinf(float s) - * - - +float cosf(float s) - * - - +float logf(float x) - * * - +float expf(float x) - * - - +float sqrtf(float x) - * - - +float tanf(float x) - * - - +float atanf(float x) - * - - +float fabsf(float x) - * - - +float roundf(float x) - * - - +float truncf(float x) - * - - ``` -------------------------------------------------------------------------------- diff --git a/test/float/softfloat/6502-CC65.h b/libsrc/float/softfloat/6502-CC65.h similarity index 100% rename from test/float/softfloat/6502-CC65.h rename to libsrc/float/softfloat/6502-CC65.h diff --git a/test/float/softfloat/README.txt b/libsrc/float/softfloat/README.txt similarity index 100% rename from test/float/softfloat/README.txt rename to libsrc/float/softfloat/README.txt diff --git a/test/float/softfloat/SoftFloat.txt b/libsrc/float/softfloat/SoftFloat.txt similarity index 100% rename from test/float/softfloat/SoftFloat.txt rename to libsrc/float/softfloat/SoftFloat.txt diff --git a/test/float/softfloat/cc65wrapper.s b/libsrc/float/softfloat/cc65wrapper.s similarity index 100% rename from test/float/softfloat/cc65wrapper.s rename to libsrc/float/softfloat/cc65wrapper.s diff --git a/test/float/softfloat/ftostr.c b/libsrc/float/softfloat/ftostr.c similarity index 100% rename from test/float/softfloat/ftostr.c rename to libsrc/float/softfloat/ftostr.c diff --git a/test/float/softfloat/SoftFloat-history.txt b/libsrc/float/softfloat/history.txt similarity index 100% rename from test/float/softfloat/SoftFloat-history.txt rename to libsrc/float/softfloat/history.txt diff --git a/test/float/softfloat/softfloat-macros b/libsrc/float/softfloat/macros.h similarity index 100% rename from test/float/softfloat/softfloat-macros rename to libsrc/float/softfloat/macros.h diff --git a/test/float/softfloat/milieu.h b/libsrc/float/softfloat/milieu.h similarity index 100% rename from test/float/softfloat/milieu.h rename to libsrc/float/softfloat/milieu.h diff --git a/test/float/softfloat/softfloat.c b/libsrc/float/softfloat/softfloat.c similarity index 99% rename from test/float/softfloat/softfloat.c rename to libsrc/float/softfloat/softfloat.c index 5784f9d60..610ba983b 100644 --- a/test/float/softfloat/softfloat.c +++ b/libsrc/float/softfloat/softfloat.c @@ -37,7 +37,7 @@ int8 float_exception_flags = 0; | division and square root approximations. (Can be specialized to target if | desired.) *----------------------------------------------------------------------------*/ -#include "softfloat-macros" +#include "macros.h" /*---------------------------------------------------------------------------- | Functions and definitions to determine: (1) whether tininess for underflow @@ -47,7 +47,7 @@ int8 float_exception_flags = 0; | are propagated from function inputs to output. These details are target- | specific. *----------------------------------------------------------------------------*/ -#include "softfloat-specialize" +#include "specialize.h" /*---------------------------------------------------------------------------- | Returns the fraction bits of the single-precision floating-point value `a'. diff --git a/test/float/softfloat/softfloat.h b/libsrc/float/softfloat/softfloat.h similarity index 100% rename from test/float/softfloat/softfloat.h rename to libsrc/float/softfloat/softfloat.h diff --git a/test/float/softfloat/SoftFloat-source.txt b/libsrc/float/softfloat/source.txt similarity index 100% rename from test/float/softfloat/SoftFloat-source.txt rename to libsrc/float/softfloat/source.txt diff --git a/test/float/softfloat/softfloat-specialize b/libsrc/float/softfloat/specialize.h similarity index 100% rename from test/float/softfloat/softfloat-specialize rename to libsrc/float/softfloat/specialize.h diff --git a/test/float/woz/_ftostr.c b/libsrc/float/woz/_ftostr.c similarity index 100% rename from test/float/woz/_ftostr.c rename to libsrc/float/woz/_ftostr.c diff --git a/test/float/woz/afloat.s b/libsrc/float/woz/afloat.s similarity index 100% rename from test/float/woz/afloat.s rename to libsrc/float/woz/afloat.s diff --git a/test/float/woz/aufloat.s b/libsrc/float/woz/aufloat.s similarity index 100% rename from test/float/woz/aufloat.s rename to libsrc/float/woz/aufloat.s diff --git a/test/float/woz/axfloat.s b/libsrc/float/woz/axfloat.s similarity index 100% rename from test/float/woz/axfloat.s rename to libsrc/float/woz/axfloat.s diff --git a/test/float/woz/axufloat.s b/libsrc/float/woz/axufloat.s similarity index 100% rename from test/float/woz/axufloat.s rename to libsrc/float/woz/axufloat.s diff --git a/test/float/woz/eaxfloat.s b/libsrc/float/woz/eaxfloat.s similarity index 100% rename from test/float/woz/eaxfloat.s rename to libsrc/float/woz/eaxfloat.s diff --git a/test/float/woz/eaxufloat.s b/libsrc/float/woz/eaxufloat.s similarity index 100% rename from test/float/woz/eaxufloat.s rename to libsrc/float/woz/eaxufloat.s diff --git a/test/float/woz/fbnegeax.s b/libsrc/float/woz/fbnegeax.s similarity index 100% rename from test/float/woz/fbnegeax.s rename to libsrc/float/woz/fbnegeax.s diff --git a/test/float/woz/feaxint.s b/libsrc/float/woz/feaxint.s similarity index 100% rename from test/float/woz/feaxint.s rename to libsrc/float/woz/feaxint.s diff --git a/test/float/woz/feaxlong.s b/libsrc/float/woz/feaxlong.s similarity index 100% rename from test/float/woz/feaxlong.s rename to libsrc/float/woz/feaxlong.s diff --git a/test/float/woz/ftosaddeax.s b/libsrc/float/woz/ftosaddeax.s similarity index 100% rename from test/float/woz/ftosaddeax.s rename to libsrc/float/woz/ftosaddeax.s diff --git a/test/float/woz/ftosdiveax.s b/libsrc/float/woz/ftosdiveax.s similarity index 100% rename from test/float/woz/ftosdiveax.s rename to libsrc/float/woz/ftosdiveax.s diff --git a/test/float/woz/ftoseqeax.s b/libsrc/float/woz/ftoseqeax.s similarity index 100% rename from test/float/woz/ftoseqeax.s rename to libsrc/float/woz/ftoseqeax.s diff --git a/test/float/woz/ftosgeeax.s b/libsrc/float/woz/ftosgeeax.s similarity index 100% rename from test/float/woz/ftosgeeax.s rename to libsrc/float/woz/ftosgeeax.s diff --git a/test/float/woz/ftosgteax.s b/libsrc/float/woz/ftosgteax.s similarity index 100% rename from test/float/woz/ftosgteax.s rename to libsrc/float/woz/ftosgteax.s diff --git a/test/float/woz/ftosleeax.s b/libsrc/float/woz/ftosleeax.s similarity index 100% rename from test/float/woz/ftosleeax.s rename to libsrc/float/woz/ftosleeax.s diff --git a/test/float/woz/ftoslteax.s b/libsrc/float/woz/ftoslteax.s similarity index 100% rename from test/float/woz/ftoslteax.s rename to libsrc/float/woz/ftoslteax.s diff --git a/test/float/woz/ftosmuleax.s b/libsrc/float/woz/ftosmuleax.s similarity index 100% rename from test/float/woz/ftosmuleax.s rename to libsrc/float/woz/ftosmuleax.s diff --git a/test/float/woz/ftosneeax.s b/libsrc/float/woz/ftosneeax.s similarity index 100% rename from test/float/woz/ftosneeax.s rename to libsrc/float/woz/ftosneeax.s diff --git a/test/float/woz/ftossubeax.s b/libsrc/float/woz/ftossubeax.s similarity index 100% rename from test/float/woz/ftossubeax.s rename to libsrc/float/woz/ftossubeax.s diff --git a/test/float/woz/wozfp.inc b/libsrc/float/woz/wozfp.inc similarity index 100% rename from test/float/woz/wozfp.inc rename to libsrc/float/woz/wozfp.inc diff --git a/test/float/woz/wozfp.s b/libsrc/float/woz/wozfp.s similarity index 100% rename from test/float/woz/wozfp.s rename to libsrc/float/woz/wozfp.s diff --git a/test/asm/listing/Makefile b/test/asm/listing/Makefile index 10f5a5a97..d0d045a02 100644 --- a/test/asm/listing/Makefile +++ b/test/asm/listing/Makefile @@ -19,7 +19,7 @@ else RMDIR = $(RM) -r $1 ERRDIR = 2>&1 TRUE = true - CAT = cat + CAT = cat $1 endif ifdef QUIET diff --git a/test/float/Makefile b/test/float/Makefile index 4df21bcd7..c0b5fe4dc 100644 --- a/test/float/Makefile +++ b/test/float/Makefile @@ -212,10 +212,10 @@ runsoft-quick: quick.soft.bin runsoft: float-minimal.soft.bin float-basic.soft.bin float-cmp.soft.bin float-conv.soft.bin float-misc.soft.bin $(SIM65) float-minimal.soft.bin - $(SIM65) float-misc.soft.bin - -$(SIM65) float-conv.soft.bin - -$(SIM65) float-cmp.soft.bin - -$(SIM65) float-basic.soft.bin +# $(SIM65) float-misc.soft.bin +# -$(SIM65) float-conv.soft.bin +# -$(SIM65) float-cmp.soft.bin +# -$(SIM65) float-basic.soft.bin ############################################################################### # CBM kernal floats diff --git a/test/float/softfloat/Makefile b/test/float/softfloat/Makefile index 0a607c92e..cb9a84545 100644 --- a/test/float/softfloat/Makefile +++ b/test/float/softfloat/Makefile @@ -15,7 +15,8 @@ LINK = ../../../bin/cl65 $(TARGET) -o $@ # Probably okay below here. #------------------------------------------------------------------------------ -all: softfloat$(OBJ) timesoftfloat$(EXE) +all: softfloat$(OBJ) + echo softfloat ok! milieu.h: $(PROCESSOR_H) touch milieu.h @@ -24,11 +25,11 @@ softfloat$(OBJ): milieu.h softfloat.h softfloat-specialize $(SOFTFLOAT_MACROS) s $(COMPILE_C) softfloat.c timesoftfloat$(OBJ): milieu.h softfloat.h timesoftfloat.c - $(COMPILE_ONLY) timesoftfloat.c - $(COMPILE_C) timesoftfloat.c +# $(COMPILE_ONLY) timesoftfloat.c +# $(COMPILE_C) timesoftfloat.c timesoftfloat$(EXE): softfloat$(OBJ) timesoftfloat$(OBJ) - $(LINK) softfloat$(OBJ) timesoftfloat$(OBJ) +# $(LINK) softfloat$(OBJ) timesoftfloat$(OBJ) clean: $(RM) softfloat$(OBJ) timesoftfloat$(EXE) timesoftfloat$(OBJ) timesoftfloat$(OBJ).s diff --git a/test/float/softfloat/timesoftfloat.c b/test/float/softfloat/timesoftfloat.c new file mode 100644 index 000000000..9fdf42cc9 --- /dev/null +++ b/test/float/softfloat/timesoftfloat.c @@ -0,0 +1,1084 @@ + +/*============================================================================ + +This C source file is part of the Berkeley SoftFloat IEEE Floating-Point +Arithmetic Package, Release 2c, by John R. Hauser. + +THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has +been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES +RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS +AND ORGANIZATIONS WHO CAN AND WILL TOLERATE ALL LOSSES, COSTS, OR OTHER +PROBLEMS THEY INCUR DUE TO THE SOFTWARE WITHOUT RECOMPENSE FROM JOHN HAUSER OR +THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE, AND WHO FURTHERMORE EFFECTIVELY +INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE +(possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR OTHER +PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE, OR +INCURRED BY ANYONE DUE TO A DERIVATIVE WORK THEY CREATE USING ANY PART OF THE +SOFTWARE. + +Derivative works require also that (1) the source code for the derivative work +includes prominent notice that the work is derivative, and (2) the source code +includes prominent notice of these three paragraphs for those parts of this +code that are retained. + +=============================================================================*/ + +#include +#include +#include +#include +#include +#include "milieu.h" +#include "softfloat.h" + +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 50 +#warning "CLOCKS_PER_SEC not defined" +clock_t clock(void) { + static clock_t cnt; + ++cnt; +} +#endif + +enum { + minIterations = 1000 +}; + +void fail( const char *message, ... ) +{ + va_list varArgs; + + fputs( "timesoftfloat: ", stderr ); + va_start( varArgs, message ); + vfprintf( stderr, message, varArgs ); + va_end( varArgs ); + fputs( ".\n", stderr ); + exit( EXIT_FAILURE ); + +} + +static char *functionName, *roundingModeName, *tininessModeName; + +static void reportTime( int32 count, long clocks ) +{ +#if 0 + printf( + "%8.1f kops/s: %s", + ( count / ( ( (float) clocks ) / CLOCKS_PER_SEC ) ) / 1000, + functionName + ); +#endif + if ( roundingModeName ) { + fputs( ", rounding ", stdout ); + fputs( roundingModeName, stdout ); + if ( tininessModeName ) { + fputs( ", tininess ", stdout ); + fputs( tininessModeName, stdout ); + fputs( " rounding", stdout ); + } + } + fputc( '\n', stdout ); + +} + +enum { + numInputs_int32 = 32 +}; + +static const int32 inputs_int32[ numInputs_int32 ] = { + 0xFFFFBB79, 0x405CF80F, 0x00000000, 0xFFFFFD04, + 0xFFF20002, 0x0C8EF795, 0xF00011FF, 0x000006CA, + 0x00009BFE, 0xFF4862E3, 0x9FFFEFFE, 0xFFFFFFB7, + 0x0BFF7FFF, 0x0000F37A, 0x0011DFFE, 0x00000006, + 0xFFF02006, 0xFFFFF7D1, 0x10200003, 0xDE8DF765, + 0x00003E02, 0x000019E8, 0x0008FFFE, 0xFFFFFB5C, + 0xFFDF7FFE, 0x07C42FBF, 0x0FFFE3FF, 0x040B9F13, + 0xBFFFFFF8, 0x0001BF56, 0x000017F6, 0x000A908A +}; + +//static void time_a_int32_z_float32( float32 function( int32 ) ) +static void time_a_int32_z_float32( float32 (*function)( int32 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNum; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( inputs_int32[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( inputs_int32[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#ifdef DOUBLES +static void time_a_int32_z_float64( float64 function( int32 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNum; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( inputs_int32[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( inputs_int32[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} +#endif + +enum { + numInputs_float32 = 32 +}; + +static const float32 inputs_float32[ numInputs_float32 ] = { + 0x4EFA0000, 0xC1D0B328, 0x80000000, 0x3E69A31E, + 0xAF803EFF, 0x3F800000, 0x17BF8000, 0xE74A301A, + 0x4E010003, 0x7EE3C75D, 0xBD803FE0, 0xBFFEFF00, + 0x7981F800, 0x431FFFFC, 0xC100C000, 0x3D87EFFF, + 0x4103FEFE, 0xBC000007, 0xBF01F7FF, 0x4E6C6B5C, + 0xC187FFFE, 0xC58B9F13, 0x4F88007F, 0xDF004007, + 0xB7FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000, + 0xDB428661, 0x33F89B1F, 0xA3BFEFFF, 0x537BFFBE +}; + +//static void time_a_float32_z_int32( int32 function( float32 ) ) +static void time_a_float32_z_int32( int32 (*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[ 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[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#ifdef DOUBLES +static void time_a_float32_z_float64( float64 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[ 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[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} +#endif + +//static void time_az_float32( float32 function( float32 ) ) +static void time_az_float32( 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[ 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[ inputNum ] ); + inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +//static void time_ab_float32_z_flag( flag function( float32, float32 ) ) +static void time_ab_float32_z_flag( flag (*function)( float32, float32 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNumA, inputNumB; + + count = 0; + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( + inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); + inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); + if ( inputNumA == 0 ) ++inputNumB; + inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( + inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); + inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); + if ( inputNumA == 0 ) ++inputNumB; + inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +//static void time_abz_float32( float32 function( float32, float32 ) ) +static void time_abz_float32( float32 (*function)( float32, float32 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNumA, inputNumB; + + count = 0; + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( + inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); + inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); + if ( inputNumA == 0 ) ++inputNumB; + inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 ); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( + inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] ); + inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 ); + if ( inputNumA == 0 ) ++inputNumB; + inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +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 ) ) +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 ); + +} + +#ifdef DOUBLES +enum { + numInputs_float64 = 32 +}; + +static const struct { + bits32 high, low; +} inputs_float64[ numInputs_float64 ] = { + { 0x422FFFC0, 0x08000000 }, + { 0xB7E00004, 0x80000000 }, + { 0xF3FD2546, 0x120B7935 }, + { 0x3FF00000, 0x00000000 }, + { 0xCE07F766, 0xF09588D6 }, + { 0x80000000, 0x00000000 }, + { 0x3FCE0004, 0x00000000 }, + { 0x8313B60F, 0x0032BED8 }, + { 0xC1EFFFFF, 0xC0002000 }, + { 0x3FB3C75D, 0x224F2B0F }, + { 0x7FD00000, 0x004000FF }, + { 0xA12FFF80, 0x00001FFF }, + { 0x3EE00000, 0x00FE0000 }, + { 0x00100000, 0x80000004 }, + { 0x41CFFFFE, 0x00000020 }, + { 0x40303FFF, 0xFFFFFFFD }, + { 0x3FD00000, 0x3FEFFFFF }, + { 0xBFD00000, 0x10000000 }, + { 0xB7FC6B5C, 0x16CA55CF }, + { 0x413EEB94, 0x0B9D1301 }, + { 0xC7E00200, 0x001FFFFF }, + { 0x47F00021, 0xFFFFFFFE }, + { 0xBFFFFFFF, 0xF80000FF }, + { 0xC07FFFFF, 0xE00FFFFF }, + { 0x001497A6, 0x3740C5E8 }, + { 0xC4BFFFE0, 0x001FFFFF }, + { 0x96FFDFFE, 0xFFFFFFFF }, + { 0x403FC000, 0x000001FE }, + { 0xFFD00000, 0x000001F6 }, + { 0x06404000, 0x02000000 }, + { 0x479CEE1E, 0x4F789FE0 }, + { 0xC237FFFF, 0xFFFFFDFE } +}; + +//static void time_a_float64_z_int32( int32 function( float64 ) ) +static void time_a_float64_z_int32( int32 (*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[ inputNum ].low; + a.high = inputs_float64[ 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[ inputNum ].low; + a.high = inputs_float64[ inputNum ].high; + function( a ); + inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_a_float64_z_float32( float32 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[ inputNum ].low; + a.high = inputs_float64[ 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[ inputNum ].low; + a.high = inputs_float64[ inputNum ].high; + function( a ); + inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_az_float64( 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[ inputNum ].low; + a.high = inputs_float64[ 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[ inputNum ].low; + a.high = inputs_float64[ inputNum ].high; + function( a ); + inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_ab_float64_z_flag( flag function( float64, float64 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNumA, inputNumB; + float64 a, b; + + count = 0; + inputNumA = 0; + 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; + 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 ); + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + 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; + function( a, b ); + inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 ); + if ( inputNumA == 0 ) ++inputNumB; + inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_abz_float64( float64 function( float64, float64 ) ) +{ + clock_t startClock, endClock; + int32 count, i; + int8 inputNumA, inputNumB; + float64 a, b; + + count = 0; + inputNumA = 0; + 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; + 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 ); + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + 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; + function( a, b ); + inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 ); + if ( inputNumA == 0 ) ++inputNumB; + inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 ); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +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 ); + +} +#endif + +enum { + INT32_TO_FLOAT32 = 1, +#ifdef DOUBLES + INT32_TO_FLOAT64, +#endif + FLOAT32_TO_INT32, + FLOAT32_TO_INT32_ROUND_TO_ZERO, +#ifdef DOUBLES + FLOAT32_TO_FLOAT64, +#endif + FLOAT32_ROUND_TO_INT, + FLOAT32_ADD, + FLOAT32_SUB, + FLOAT32_MUL, + FLOAT32_DIV, + FLOAT32_REM, + FLOAT32_SQRT, + FLOAT32_EQ, + FLOAT32_LE, + FLOAT32_LT, + FLOAT32_EQ_SIGNALING, + FLOAT32_LE_QUIET, + FLOAT32_LT_QUIET, +#ifdef DOUBLES + FLOAT64_TO_INT32, + FLOAT64_TO_INT32_ROUND_TO_ZERO, + FLOAT64_TO_FLOAT32, + FLOAT64_ROUND_TO_INT, + FLOAT64_ADD, + FLOAT64_SUB, + FLOAT64_MUL, + FLOAT64_DIV, + FLOAT64_REM, + FLOAT64_SQRT, + FLOAT64_EQ, + FLOAT64_LE, + FLOAT64_LT, + FLOAT64_EQ_SIGNALING, + FLOAT64_LE_QUIET, + FLOAT64_LT_QUIET, +#endif + NUM_FUNCTIONS +}; + +static struct { + char *name; + int8 numInputs; + flag roundingMode, tininessMode; +} functions[ NUM_FUNCTIONS ] = { + { 0, 0, 0, 0 }, + { "int32_to_float32", 1, TRUE, FALSE }, +#ifdef DOUBLES + { "int32_to_float64", 1, FALSE, FALSE }, +#endif + { "float32_to_int32", 1, TRUE, FALSE }, + { "float32_to_int32_round_to_zero", 1, FALSE, FALSE }, +#ifdef DOUBLES + { "float32_to_float64", 1, FALSE, FALSE }, +#endif + { "float32_round_to_int", 1, TRUE, FALSE }, + { "float32_add", 2, TRUE, FALSE }, + { "float32_sub", 2, TRUE, FALSE }, + { "float32_mul", 2, TRUE, TRUE, }, + { "float32_div", 2, TRUE, FALSE }, + { "float32_rem", 2, FALSE, FALSE }, + { "float32_sqrt", 1, TRUE, FALSE }, + { "float32_eq", 2, FALSE, FALSE }, + { "float32_le", 2, FALSE, FALSE }, + { "float32_lt", 2, FALSE, FALSE }, + { "float32_eq_signaling", 2, FALSE, FALSE }, + { "float32_le_quiet", 2, FALSE, FALSE }, + { "float32_lt_quiet", 2, FALSE, FALSE }, +#ifdef DOUBLES + { "float64_to_int32", 1, TRUE, FALSE }, + { "float64_to_int32_round_to_zero", 1, FALSE, FALSE }, + { "float64_to_float32", 1, TRUE, TRUE, }, + { "float64_round_to_int", 1, TRUE, FALSE }, + { "float64_add", 2, TRUE, FALSE }, + { "float64_sub", 2, TRUE, FALSE }, + { "float64_mul", 2, TRUE, TRUE, }, + { "float64_div", 2, TRUE, FALSE }, + { "float64_rem", 2, FALSE, FALSE }, + { "float64_sqrt", 1, TRUE, FALSE }, + { "float64_eq", 2, FALSE, FALSE }, + { "float64_le", 2, FALSE, FALSE }, + { "float64_lt", 2, FALSE, FALSE }, + { "float64_eq_signaling", 2, FALSE, FALSE }, + { "float64_le_quiet", 2, FALSE, FALSE }, + { "float64_lt_quiet", 2, FALSE, FALSE } +#endif +}; + +enum { + ROUND_NEAREST_EVEN = 1, + ROUND_TO_ZERO, + ROUND_DOWN, + ROUND_UP, + NUM_ROUNDINGMODES +}; +enum { + TININESS_BEFORE_ROUNDING = 1, + TININESS_AFTER_ROUNDING, + NUM_TININESSMODES +}; + +static void + timeFunctionVariety( + uint8 functionCode, int8 roundingMode, int8 tininessMode ) +{ + uint8 roundingCode; + int8 tininessCode; + + functionName = functions[ functionCode ].name; + switch ( roundingMode ) { + case 0: + roundingModeName = 0; + roundingCode = float_round_nearest_even; + break; + case ROUND_NEAREST_EVEN: + roundingModeName = "nearest_even"; + roundingCode = float_round_nearest_even; + break; + case ROUND_TO_ZERO: + roundingModeName = "to_zero"; + roundingCode = float_round_to_zero; + break; + case ROUND_DOWN: + roundingModeName = "down"; + roundingCode = float_round_down; + break; + case ROUND_UP: + roundingModeName = "up"; + roundingCode = float_round_up; + break; + } + float_rounding_mode = roundingCode; + switch ( tininessMode ) { + case 0: + tininessModeName = 0; + tininessCode = float_tininess_after_rounding; + break; + case TININESS_BEFORE_ROUNDING: + tininessModeName = "before"; + tininessCode = float_tininess_before_rounding; + break; + case TININESS_AFTER_ROUNDING: + tininessModeName = "after"; + tininessCode = float_tininess_after_rounding; + break; + } + float_detect_tininess = tininessCode; + switch ( functionCode ) { + case INT32_TO_FLOAT32: + time_a_int32_z_float32( int32_to_float32 ); + break; +#ifdef DOUBLES + case INT32_TO_FLOAT64: + time_a_int32_z_float64( int32_to_float64 ); + break; +#endif + case FLOAT32_TO_INT32: + time_a_float32_z_int32( float32_to_int32 ); + break; + case FLOAT32_TO_INT32_ROUND_TO_ZERO: + time_a_float32_z_int32( float32_to_int32_round_to_zero ); + break; +#ifdef DOUBLES + case FLOAT32_TO_FLOAT64: + time_a_float32_z_float64( float32_to_float64 ); + break; +#endif + case FLOAT32_ROUND_TO_INT: + time_az_float32( float32_round_to_int ); + break; + case FLOAT32_ADD: + time_abz_float32( float32_add ); + break; + case FLOAT32_SUB: + time_abz_float32( float32_sub ); + break; + case FLOAT32_MUL: + time_abz_float32( float32_mul ); + break; + case FLOAT32_DIV: + time_abz_float32( float32_div ); + break; + case FLOAT32_REM: + time_abz_float32( float32_rem ); + break; + case FLOAT32_SQRT: + time_az_float32_pos( float32_sqrt ); + break; + case FLOAT32_EQ: + time_ab_float32_z_flag( float32_eq ); + break; + case FLOAT32_LE: + time_ab_float32_z_flag( float32_le ); + break; + case FLOAT32_LT: + time_ab_float32_z_flag( float32_lt ); + break; + case FLOAT32_EQ_SIGNALING: + time_ab_float32_z_flag( float32_eq_signaling ); + break; + case FLOAT32_LE_QUIET: + time_ab_float32_z_flag( float32_le_quiet ); + break; + case FLOAT32_LT_QUIET: + time_ab_float32_z_flag( float32_lt_quiet ); + break; +#ifdef DOUBLES + case FLOAT64_TO_INT32: + time_a_float64_z_int32( float64_to_int32 ); + break; + case FLOAT64_TO_INT32_ROUND_TO_ZERO: + time_a_float64_z_int32( float64_to_int32_round_to_zero ); + break; + case FLOAT64_TO_FLOAT32: + time_a_float64_z_float32( float64_to_float32 ); + break; + case FLOAT64_ROUND_TO_INT: + time_az_float64( float64_round_to_int ); + break; + case FLOAT64_ADD: + time_abz_float64( float64_add ); + break; + case FLOAT64_SUB: + time_abz_float64( float64_sub ); + break; + case FLOAT64_MUL: + time_abz_float64( float64_mul ); + break; + case FLOAT64_DIV: + time_abz_float64( float64_div ); + break; + case FLOAT64_REM: + time_abz_float64( float64_rem ); + break; + case FLOAT64_SQRT: + time_az_float64_pos( float64_sqrt ); + break; + case FLOAT64_EQ: + time_ab_float64_z_flag( float64_eq ); + break; + case FLOAT64_LE: + time_ab_float64_z_flag( float64_le ); + break; + case FLOAT64_LT: + time_ab_float64_z_flag( float64_lt ); + break; + case FLOAT64_EQ_SIGNALING: + time_ab_float64_z_flag( float64_eq_signaling ); + break; + case FLOAT64_LE_QUIET: + time_ab_float64_z_flag( float64_le_quiet ); + break; + case FLOAT64_LT_QUIET: + time_ab_float64_z_flag( float64_lt_quiet ); + break; +#endif + } + +} + +static void + timeFunction( uint8 functionCode, int8 roundingModeIn, int8 tininessModeIn ) +{ + int8 roundingMode, tininessMode; + + for ( roundingMode = 1; + roundingMode < NUM_ROUNDINGMODES; + ++roundingMode + ) { + if ( ! functions[ functionCode ].roundingMode ) { + roundingMode = 0; + } + else if ( roundingModeIn ) { + roundingMode = roundingModeIn; + } + for ( tininessMode = 1; + tininessMode < NUM_TININESSMODES; + ++tininessMode + ) { + if ( ! functions[ functionCode ].tininessMode ) { + tininessMode = 0; + } + else if ( tininessModeIn ) { + tininessMode = tininessModeIn; + } + timeFunctionVariety( functionCode, roundingMode, tininessMode ); + if ( tininessModeIn || ! tininessMode ) break; + } + if ( roundingModeIn || ! roundingMode ) break; + } + +} + +main( int argc, char **argv ) +{ + char *argPtr; + flag functionArgument; + uint8 functionCode; + int8 operands, roundingMode, tininessMode; + + if ( argc <= 1 ) goto writeHelpMessage; + functionArgument = FALSE; + functionCode = 0; + operands = 0; + roundingMode = 0; + tininessMode = 0; + --argc; + ++argv; + while ( argc && ( argPtr = argv[ 0 ] ) ) { + if ( argPtr[ 0 ] == '-' ) ++argPtr; + if ( strcmp( argPtr, "help" ) == 0 ) { + writeHelpMessage: + fputs( +"timesoftfloat [