From b1683a1d6a4391ffef6ce12be9aa172d0f4f59bc Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 27 Feb 2014 23:18:42 -0500 Subject: [PATCH] add nofpu subarchs to the sh arch, and properly detect compiler's fpu config --- arch/sh/bits/fenv.h | 9 +++++++++ configure | 20 ++++++++++++++++++-- src/fenv/sh-nofpu/fenv.sub | 1 + src/fenv/sheb-nofpu/fenv.sub | 1 + src/setjmp/sh-nofpu/longjmp.s | 22 ++++++++++++++++++++++ src/setjmp/sh-nofpu/longjmp.sub | 1 + src/setjmp/sh-nofpu/setjmp.s | 21 +++++++++++++++++++++ src/setjmp/sh-nofpu/setjmp.sub | 1 + src/setjmp/sheb-nofpu/longjmp.sub | 1 + src/setjmp/sheb-nofpu/setjmp.sub | 1 + 10 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/fenv/sh-nofpu/fenv.sub create mode 100644 src/fenv/sheb-nofpu/fenv.sub create mode 100644 src/setjmp/sh-nofpu/longjmp.s create mode 100644 src/setjmp/sh-nofpu/longjmp.sub create mode 100644 src/setjmp/sh-nofpu/setjmp.s create mode 100644 src/setjmp/sh-nofpu/setjmp.sub create mode 100644 src/setjmp/sheb-nofpu/longjmp.sub create mode 100644 src/setjmp/sheb-nofpu/setjmp.sub diff --git a/arch/sh/bits/fenv.h b/arch/sh/bits/fenv.h index f454a15d..7f1b8b66 100644 --- a/arch/sh/bits/fenv.h +++ b/arch/sh/bits/fenv.h @@ -1,3 +1,10 @@ +#ifndef __SH_FPU_ANY__ + +#define FE_ALL_EXCEPT 0 +#define FE_TONEAREST 0 + +#else + #define FE_TONEAREST 0 #define FE_TOWARDZERO 1 @@ -8,6 +15,8 @@ #define FE_INVALID 0x40 #define FE_ALL_EXCEPT 0x7c +#endif + typedef unsigned long fexcept_t; typedef struct { diff --git a/configure b/configure index 1a092f52..572ea640 100755 --- a/configure +++ b/configure @@ -421,8 +421,24 @@ fi test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \ && SUBARCH=${SUBARCH}el -test "$ARCH" = "sh" && trycppif __BIG_ENDIAN__ "$t" \ -&& SUBARCH=${SUBARCH}eb +if test "$ARCH" = "sh" ; then +trycppif __BIG_ENDIAN__ "$t" && SUBARCH=${SUBARCH}eb +if trycppif __SH_FPU_ANY__ ; then +# Some sh configurations are broken and replace double with float +# rather than using softfloat when the fpu is present but only +# supports single precision. Reject them. +printf "checking whether compiler's double type is IEEE double... " +echo 'typedef char dblcheck[(int)sizeof(double)-5];' >> "$tmpc" +if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then +printf "yes\n" +else +printf "no\n" +fail "$0: error: compiler's floating point configuration is unsupported" +fi +else +SUBARCH=${SUBARCH}-nofpu +fi +fi test "$SUBARCH" \ && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH" diff --git a/src/fenv/sh-nofpu/fenv.sub b/src/fenv/sh-nofpu/fenv.sub new file mode 100644 index 00000000..9cafca5e --- /dev/null +++ b/src/fenv/sh-nofpu/fenv.sub @@ -0,0 +1 @@ +../fenv.c diff --git a/src/fenv/sheb-nofpu/fenv.sub b/src/fenv/sheb-nofpu/fenv.sub new file mode 100644 index 00000000..9cafca5e --- /dev/null +++ b/src/fenv/sheb-nofpu/fenv.sub @@ -0,0 +1 @@ +../fenv.c diff --git a/src/setjmp/sh-nofpu/longjmp.s b/src/setjmp/sh-nofpu/longjmp.s new file mode 100644 index 00000000..cda482c5 --- /dev/null +++ b/src/setjmp/sh-nofpu/longjmp.s @@ -0,0 +1,22 @@ +.global _longjmp +.global longjmp +.type _longjmp, @function +.type longjmp, @function +_longjmp: +longjmp: + mov.l @r4+, r8 + mov.l @r4+, r9 + mov.l @r4+, r10 + mov.l @r4+, r11 + mov.l @r4+, r12 + mov.l @r4+, r13 + mov.l @r4+, r14 + mov.l @r4+, r15 + lds.l @r4+, pr + + tst r5, r5 + movt r0 + add r5, r0 + + rts + nop diff --git a/src/setjmp/sh-nofpu/longjmp.sub b/src/setjmp/sh-nofpu/longjmp.sub new file mode 100644 index 00000000..e80331b6 --- /dev/null +++ b/src/setjmp/sh-nofpu/longjmp.sub @@ -0,0 +1 @@ +longjmp.s diff --git a/src/setjmp/sh-nofpu/setjmp.s b/src/setjmp/sh-nofpu/setjmp.s new file mode 100644 index 00000000..c6c7359a --- /dev/null +++ b/src/setjmp/sh-nofpu/setjmp.s @@ -0,0 +1,21 @@ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp, @function +.type _setjmp, @function +.type setjmp, @function +__setjmp: +_setjmp: +setjmp: + add #36, r4 + sts.l pr, @-r4 + mov.l r15 @-r4 + mov.l r14, @-r4 + mov.l r13, @-r4 + mov.l r12, @-r4 + mov.l r11, @-r4 + mov.l r10, @-r4 + mov.l r9, @-r4 + mov.l r8, @-r4 + rts + mov #0, r0 diff --git a/src/setjmp/sh-nofpu/setjmp.sub b/src/setjmp/sh-nofpu/setjmp.sub new file mode 100644 index 00000000..b7ad2210 --- /dev/null +++ b/src/setjmp/sh-nofpu/setjmp.sub @@ -0,0 +1 @@ +setjmp.s diff --git a/src/setjmp/sheb-nofpu/longjmp.sub b/src/setjmp/sheb-nofpu/longjmp.sub new file mode 100644 index 00000000..62fcd2b1 --- /dev/null +++ b/src/setjmp/sheb-nofpu/longjmp.sub @@ -0,0 +1 @@ +../sh-nofpu/longjmp.s diff --git a/src/setjmp/sheb-nofpu/setjmp.sub b/src/setjmp/sheb-nofpu/setjmp.sub new file mode 100644 index 00000000..a5bb294c --- /dev/null +++ b/src/setjmp/sheb-nofpu/setjmp.sub @@ -0,0 +1 @@ +../sh-nofpu/setjmp.s -- 2.25.1