From ff61ebfa2b5673d68172e6b7b1cbbfd3cab28237 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sun, 25 Jan 2009 21:31:58 +0000 Subject: [PATCH] Implemented several of the floating point intrinsics (using cgtest19 and the occam 2.1 manual) --- support/tock_intrinsics_float.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/support/tock_intrinsics_float.h b/support/tock_intrinsics_float.h index d467276..f01f2aa 100644 --- a/support/tock_intrinsics_float.h +++ b/support/tock_intrinsics_float.h @@ -1,6 +1,14 @@ static inline INT ADD_PREFIX(IEEECOMPARE) (REAL, REAL, const char*) occam_unused; static inline INT ADD_PREFIX(IEEECOMPARE) (REAL X, REAL Y, const char* pos) { - return 0; + if (isunordered(X,Y)) { + return 2; + } else if (isgreater(X,Y)) { + return 1; + } else if (isless(X,Y)) { + return -1; + } else { + return 0; + } } 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) { @@ -16,7 +24,7 @@ static inline BOOL SPLICE_SIZE(occam_REAL,EQ) (REAL X, REAL Y, const char* pos) } 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) { - return 0; + return isgreater(X,Y); } static inline REAL SPLICE_SIZE(occam_REAL,OP) (REAL, INT, REAL, const char*) occam_unused; static inline REAL SPLICE_SIZE(occam_REAL,OP) (REAL X, INT Op, REAL Y, const char* pos) { @@ -43,7 +51,7 @@ static inline REAL ADD_PREFIX(ABS) (REAL X, const char* pos) { } static inline REAL ADD_PREFIX(COPYSIGN) (REAL, REAL, const char*) occam_unused; static inline REAL ADD_PREFIX(COPYSIGN) (REAL X, REAL Y, const char* pos) { - return 0; + return F(copysign)(X,Y); } static inline REAL ADD_PREFIX(DIVBY2) (REAL, const char*) occam_unused; static inline REAL ADD_PREFIX(DIVBY2) (REAL X, const char* pos) { @@ -83,7 +91,7 @@ static inline BOOL ADD_PREFIX(NOTFINITE) (REAL X, const char* pos) { } static inline BOOL ADD_PREFIX(ORDERED) (REAL, REAL, const char*) occam_unused; static inline BOOL ADD_PREFIX(ORDERED) (REAL X, REAL Y, const char* pos) { - return 0; + return !(isunordered(X,Y)); } static inline REAL ADD_PREFIX(SCALEB) (REAL, INT, const char*) occam_unused; static inline REAL ADD_PREFIX(SCALEB) (REAL X, INT n, const char* pos) {