diff options
Diffstat (limited to 'support/regression/tests')
-rw-r--r-- | support/regression/tests/bitintfromfloat.c.in | 35 | ||||
-rw-r--r-- | support/regression/tests/bitinttofloat.c.in (renamed from support/regression/tests/bitintfloat.c.in) | 5 | ||||
-rw-r--r-- | support/regression/tests/coremark.c.in | 2 | ||||
-rw-r--r-- | support/regression/tests/muldiv.c.in | 7 |
4 files changed, 43 insertions, 6 deletions
diff --git a/support/regression/tests/bitintfromfloat.c.in b/support/regression/tests/bitintfromfloat.c.in new file mode 100644 index 000000000..bf7ef9530 --- /dev/null +++ b/support/regression/tests/bitintfromfloat.c.in @@ -0,0 +1,35 @@ +/** casts between bit-precise integers and float + + width: 2, 4, 6, 7, 8, 9, 15, 16, 17, 24, 32, 33, 40, 48, 63, 64, 65 + sign: unsigned, signed +*/ + +#include <testfwk.h> + +#include <float.h> + +// clang 11 supports bit-precise types, but deviates a bit from C23. +#if __clang_major__ == 11 +#define __SDCC_BITINT_MAXWIDTH 128 +#define _BitInt _ExtInt +#endif + +#if __SDCC_BITINT_MAXWIDTH >= {width} && (32 >= {width} || !defined(__SDCC_pdk14)) // Lack of memory on pdk14 for wider types. Maybe some future optimization will help here. +typedef {sign} _BitInt({width}) bitinttype; + +bitinttype from_float(float f) +{ + return(f); +} +#endif + +void testCast (void) +{ +#if __SDCC_BITINT_MAXWIDTH >= {width} && (32 >= {width} || !defined(__SDCC_pdk14)) // Lack of memory on pdk14 for wider types. Maybe some future optimization will help here. + float f; + + f = 1; + ASSERT (from_float (f) == (bitinttype)f); +#endif +} + diff --git a/support/regression/tests/bitintfloat.c.in b/support/regression/tests/bitinttofloat.c.in index 77d5ae986..1645c5b3f 100644 --- a/support/regression/tests/bitintfloat.c.in +++ b/support/regression/tests/bitinttofloat.c.in @@ -22,11 +22,6 @@ float to_float(bitinttype b) { return(b); } - -/*bitinttype from_float(float f) -{ - return(f); -}*/ #endif void testCast (void) diff --git a/support/regression/tests/coremark.c.in b/support/regression/tests/coremark.c.in index 35eaa4125..4944f9ad5 100644 --- a/support/regression/tests/coremark.c.in +++ b/support/regression/tests/coremark.c.in @@ -21,7 +21,7 @@ #define LACK_OF_MEMORY #endif -#if !defined(LACK_OF_MEMORY) && !defined(__SDCC_z80) && !defined(__SDCC_z180) && !defined(__SDCC_ds390) /* z80, z180, ds390: fails, possibly a bug in codegen */ +#if !defined(LACK_OF_MEMORY) && !defined(__SDCC_ds390) /* ds390: fails, possibly a bug in codegen */ // coremark.h content below. diff --git a/support/regression/tests/muldiv.c.in b/support/regression/tests/muldiv.c.in index 1df52656f..bd7dd71c9 100644 --- a/support/regression/tests/muldiv.c.in +++ b/support/regression/tests/muldiv.c.in @@ -109,6 +109,12 @@ test16to32(void) {attr} {storage} int i, j; {attr} {storage} unsigned int ui, uj; + i = 123; + j = 0xaa; + ASSERT((long)i * (long)j == 123l * (long)0xaa); + i = -i; + ASSERT((long)i * (long)j == -123l * (long)0xaa); + i = 42; j = 42; ASSERT((long)i * (long)j == 42l * 42l); @@ -164,3 +170,4 @@ testMod(void) ASSERT(i%4 == -1); #endif } + |