Skip to content

Commit

Permalink
Enable floating point unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterymath committed Dec 3, 2023
1 parent 204a638 commit bc6af28
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 45 deletions.
2 changes: 1 addition & 1 deletion SingleSource/Regression/C/2003-05-21-UnionBitfields.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int target_isinf(double x) {
union {
double d;
struct {
unsigned mantissa2;
unsigned long mantissa2;
unsigned long mantissa1 : 20;
unsigned exponent : 11;
unsigned sign : 1;
Expand Down
2 changes: 1 addition & 1 deletion SingleSource/Regression/C/2003-05-21-UnionTest.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>

int __signbit (double __x) {
union { double __d; int __i[3]; } __u = { __d: __x };
union { double __d; long __i[3]; } __u = { __d: __x };
return __u.__i[1] < 0;
}

Expand Down
4 changes: 2 additions & 2 deletions SingleSource/Regression/C/2003-10-12-GlobalVarInitializers.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <stdio.h>

union { unsigned __l; float __d; } GlobalUnion = { 0x70c00000U };
union { unsigned long __l; float __d; } GlobalUnion = { 0x70c00000U };

int main() {
union { unsigned __l; float __d; } LocalUnion = { 0x7fc00000U };
union { unsigned long __l; float __d; } LocalUnion = { 0x7fc00000U };

printf("%f %f\n", GlobalUnion.__d, LocalUnion.__d);

Expand Down
39 changes: 26 additions & 13 deletions SingleSource/Regression/C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

if(ARCH MATCHES "x86" OR ARCH MATCHES "riscv" OR
ARCH MATCHES "SystemZ" OR ARCH MATCHES "Mips" OR
ARCH MATCHES "AArch64" OR ARCH MATCHES "ARM" OR
Expand All @@ -9,31 +8,37 @@ endif()
if (ARCH STREQUAL "MOS")
file(GLOB Source RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c)
list(REMOVE_ITEM Source
# Permanently disabled tests.
# ---------------------------

# Requires large stack.
test_indvars.c

# Too slow
bigstack.c

# Temporarily disabled tests.
# ---------------------------

# Requires indirect branch.
2004-03-15-IndirectGoto.c

# Requires floating point.
2003-05-21-UnionBitfields.c
2003-05-21-UnionTest.c
2003-10-12-GlobalVarInitializers.c
2008-01-07-LongDouble.c
bigstack.c
callargs.c
casts.c
matrixTranspose.c
test_indvars.c
uint64_to_float.c

# Requires fprintf.
PR491.c

# Requires atoi.
badidx.c
sumarraymalloc.c

# Requires atof.
casts.c

# Requires fenv.h.
uint64_to_float.c

# Requires large whole number float printf
2003-10-12-GlobalVarInitializers.c

# Requires argc/argv.
2005-05-06-LongLongSignedShift.c
)
Expand All @@ -42,3 +47,11 @@ endif()
list(APPEND LDFLAGS -lm)
list(APPEND CFLAGS -Wno-implicit-int)
llvm_singlesource(PREFIX "Regression-C-")

if(ARCH STREQUAL "MOS")
target_link_libraries(Regression-C-2003-05-21-UnionBitfields PRIVATE printf_flt)
target_link_libraries(Regression-C-2003-05-21-UnionTest PRIVATE printf_flt)
target_link_libraries(Regression-C-2008-01-07-LongDouble PRIVATE printf_flt)
target_link_libraries(Regression-C-callargs PRIVATE printf_flt)
target_link_libraries(Regression-C-matrixTranspose PRIVATE printf_flt)
endif()
2 changes: 1 addition & 1 deletion SingleSource/UnitTests/2002-05-02-ManyArguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ void printfn(int a, short b, double C, float D, signed char E, char F, void *G,
}

int main() {
printfn(12, 2, 123.234, 1231.12312f, -12, 23, (void*)123456, 0, 1234567, 123124124124LL);
printfn(12, 2, 123.234, 1231.12312f, -12, 23, (void*)12345, 0, 12345, 123124124124LL);
return 0;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
12, 2, 123.234000, 1231.123169, -12
23, 123456, 0, 1234567, 123124124124
23, 12345, 0, 12345, 123124124124
exit 0
4 changes: 2 additions & 2 deletions SingleSource/UnitTests/2003-08-05-CastFPToUint.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ main(int argc, char** argv) {
double DI = getDI();
unsigned char uc = (unsigned char ) DC;
unsigned short us = (unsigned short) DS;
unsigned int ui = (unsigned int ) DI;
unsigned long ui = (unsigned long ) DI;
printf("DC = %lf, DS = %lf, DI = %lf\n", DC, DS, DI);
printf("uc = %u, us = %u, ui = %u\n", uc, us, ui);
printf("uc = %u, us = %u, ui = %lu\n", uc, us, ui);
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions SingleSource/UnitTests/2005-07-17-INT-To-FP.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Test the various SINT-TO-FP and UINT-TO-FP conversions.
#include <stdio.h>

int tests[] = {
long tests[] = {
0x80000000,
-123456792,
-10,
Expand Down Expand Up @@ -33,12 +33,12 @@ int main() {
(double)(unsigned long long)((unsigned long long)i << 58ULL)); // i64
}
// edge case tests
for (i = 0; i < (sizeof(tests) / sizeof(int)); i++) {
for (i = 0; i < (sizeof(tests) / sizeof(long)); i++) {
printf("%d %f, %f, %f, %f\n", i,
(double)(unsigned)tests[i],
(double)( signed)tests[i],
(double)(unsigned long)tests[i],
(double)( signed long)tests[i],
(float) tests[i],
(float) ( signed)tests[i]);
(float) ( signed long)tests[i]);
}
return 0;
}
4 changes: 2 additions & 2 deletions SingleSource/UnitTests/2007-01-04-KNR-Args.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
p1 (c, f1, s, d1, i, f2, l, d2)
char c; float f1; short s; double d1; int i; float f2; long l; double d2;
{
printf("%c %f %d %f %d %f %d %f\n", c, f1, s, d1,i, f2, l, d2);
printf("%c %f %d %f %d %f %ld %f\n", c, f1, s, d1,i, f2, l, d2);
}

void p2 (char c, float f1, short s, double d1, int i, float f2, long l, double d2)
{
printf("%c %f %d %f %d %f %d %f\n", c, f1, s, d1,i, f2, l, d2);
printf("%c %f %d %f %d %f %ld %f\n", c, f1, s, d1,i, f2, l, d2);
}

int main(int argc, const char *argv[]) {
Expand Down
35 changes: 18 additions & 17 deletions SingleSource/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,9 @@ if(ARCH STREQUAL "MOS")
# Temporarily disabled tests.
# ---------------------------

# Requires floating point.
2002-05-02-ArgumentTest.c
2002-05-02-ManyArguments.c
2002-10-12-StructureArgs.c
2002-10-12-StructureArgsSimple.c
2003-05-07-VarArgs.c
2003-08-05-CastFPToUint.c
2003-08-11-VaListArg.c
2004-02-02-NegativeZero.c
# Requires printing large floating point whole numbers
2005-05-12-Int64ToFP.c
2005-07-17-INT-To-FP.c
2006-12-01-float_varg.c
2007-01-04-KNR-Args.c
2009-04-16-BitfieldInitialization.c
2009-12-07-StructReturn.c
FloatPrecision.c
StructModifyTest.c
byval-alignment.c

# Requires scanf.
2004-11-28-GlobalBoolLayout.c
Expand All @@ -123,7 +108,23 @@ endif()

llvm_singlesource()

if(NOT ARCH STREQUAL "MOS")
if(ARCH STREQUAL "MOS")
target_link_libraries(2002-05-02-ArgumentTest PRIVATE printf_flt)
target_link_libraries(2002-05-02-ManyArguments PRIVATE printf_flt)
target_link_libraries(2002-10-12-StructureArgs PRIVATE printf_flt)
target_link_libraries(2002-10-12-StructureArgsSimple PRIVATE printf_flt)
target_link_libraries(2003-05-07-VarArgs PRIVATE printf_flt)
target_link_libraries(2003-08-05-CastFPToUint PRIVATE printf_flt)
target_link_libraries(2003-08-11-VaListArg PRIVATE printf_flt)
target_link_libraries(2004-02-02-NegativeZero PRIVATE printf_flt)
target_link_libraries(2006-12-01-float_varg PRIVATE printf_flt)
target_link_libraries(2007-01-04-KNR-Args PRIVATE printf_flt)
target_link_libraries(2009-04-16-BitfieldInitialization PRIVATE printf_flt)
target_link_libraries(2009-12-07-StructReturn PRIVATE printf_flt)
target_link_libraries(FloatPrecision PRIVATE printf_flt)
target_link_libraries(StructModifyTest PRIVATE printf_flt)
target_link_libraries(byval-alignment PRIVATE printf_flt)
else()
if (COMPILER_HAS_MATRIX_FLAG)
set_property(TARGET matrix-types-spec PROPERTY LINK_OPTIONS -fenable-matrix)
endif()
Expand Down

0 comments on commit bc6af28

Please sign in to comment.