From d1e0ec07c418f2631f2c9c5b83a1db0b9353f29a Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 27 Jan 2009 12:21:18 +0000 Subject: [PATCH] Finished off the last of the floating point intrinsics (from appendices K and M) cgtest19 now passes all its tests --- support/tock_intrinsics_float.h | 25 +++++++++++++++++++++---- support/tock_support.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/support/tock_intrinsics_float.h b/support/tock_intrinsics_float.h index ef43c30..1781a31 100644 --- a/support/tock_intrinsics_float.h +++ b/support/tock_intrinsics_float.h @@ -12,15 +12,32 @@ static inline INT ADD_PREFIX(IEEECOMPARE) (REAL X, REAL Y, const char* pos) { } static inline BOOL SPLICE_SIZE(occam_IEEE,OP) (REAL, INT, INT, REAL, REAL*, const char*) occam_unused; static inline BOOL SPLICE_SIZE(occam_IEEE,OP) (REAL X, INT Rm, INT Op, REAL Y, REAL* result1, const char* pos) { - return 0; + REAL R; + int prevRm = fegetround(); + switch (Rm) { + case 0: fesetround(FE_TOWARDZERO); break; + case 1: fesetround(FE_TONEAREST); break; + case 2: fesetround(FE_UPWARD); break; + case 3: fesetround(FE_DOWNWARD); break; + } + switch (Op) { + case 0: R = X + Y; break; + case 1: R = X - Y; break; + case 2: R = X * Y; break; + case 3: R = X / Y; break; + } + fesetround(prevRm); + *result1 = R; + return (isnan(R)); } static inline BOOL SPLICE_SIZE(occam_IEEE,REM) (REAL, REAL, REAL*, const char*) occam_unused; static inline BOOL SPLICE_SIZE(occam_IEEE,REM) (REAL X, REAL Y, REAL* result1, const char* pos) { - return 0; + *result1 = F(remainder)(X,Y); + return isnan((*result1)); } static inline BOOL SPLICE_SIZE(occam_REAL,EQ) (REAL, REAL, const char*) occam_unused; static inline BOOL SPLICE_SIZE(occam_REAL,EQ) (REAL X, REAL Y, const char* pos) { - return 0; + return X==Y; } static inline BOOL SPLICE_SIZE(occam_REAL,GT) (REAL, REAL, const char*) occam_unused; static inline BOOL SPLICE_SIZE(occam_REAL,GT) (REAL X, REAL Y, const char* pos) { @@ -38,7 +55,7 @@ static inline REAL SPLICE_SIZE(occam_REAL,OP) (REAL X, INT Op, REAL Y, const cha } static inline REAL SPLICE_SIZE(occam_REAL,REM) (REAL, REAL, const char*) occam_unused; static inline REAL SPLICE_SIZE(occam_REAL,REM) (REAL X, REAL Y, const char* pos) { - return 0; + return F(remainder)(X,Y); } #if SPLICE_SIZE(4,1) == 4321 static inline BOOL occam_ARGUMENT_REDUCE (float, float, float, int32_t*, float*, const char*) occam_unused; diff --git a/support/tock_support.h b/support/tock_support.h index 5afb2ae..cf546bc 100644 --- a/support/tock_support.h +++ b/support/tock_support.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include