This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [SH][PATCH] SH4 NOFPU support
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Tue, 03 Feb 2009 14:05:56 +0000
- Subject: Re: [SH][PATCH] SH4 NOFPU support
- References: <4981C25D.70502@codesourcery.com> <20090131.082004.211656735.kkojima@rr.iij4u.or.jp> <20090203.115036.217984769.kkojima@rr.iij4u.or.jp>
Kaz Kojima wrote:
are bad for sh3. You can change sysdeps/sh/sh4/dl-trampoline.S
like as
How about this version? I've discovered the __SH_FPU_ANY__ macro, set by
the compiler. This is presumably more future proof than using
!__SH4_NOFPU__ in any case.
Andrew
2009-02-03 Andrew Stubbs <ams@codesourcery.com>
glibc/
* sysdeps/sh/dl-trampoline.S: HAVE_FPU -> !__SH4_NOFPU__
* sysdeps/sh/sh4/setjmp.S: Support SH4-NOFPU.
* sysdeps/sh/sh4/__longjmp.S: Likewise.
* sysdeps/unix/sysv/linux/sh/sh4/getcontext.S: Likewise.
* sysdeps/unix/sysv/linux/sh/sh4/setcontext.S: Likewise.
* sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S: Likewise.
* sysdeps/unix/sysv/linux/sh/sh4/register-dump.h: Likewise.
---
src/glibc-mainline/sysdeps/sh/dl-trampoline.S | 4 ++++
src/glibc-mainline/sysdeps/sh/sh4/__longjmp.S | 5 +++++
src/glibc-mainline/sysdeps/sh/sh4/setjmp.S | 2 ++
src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S | 2 ++
src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h | 2 ++
src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S | 2 ++
src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S | 4 ++++
7 files changed, 21 insertions(+)
Index: src/glibc-mainline/sysdeps/sh/dl-trampoline.S
===================================================================
--- src/glibc-mainline/sysdeps/sh/dl-trampoline.S.orig
+++ src/glibc-mainline/sysdeps/sh/dl-trampoline.S
@@ -19,6 +19,10 @@
#include <sysdep.h>
+#ifndef __SH_FPU_ANY__
+# undef HAVE_FPU
+#endif
+
.text
.globl _dl_runtime_resolve
.type _dl_runtime_resolve, @function
Index: src/glibc-mainline/sysdeps/sh/sh4/__longjmp.S
===================================================================
--- src/glibc-mainline/sysdeps/sh/sh4/__longjmp.S.orig
+++ src/glibc-mainline/sysdeps/sh/sh4/__longjmp.S
@@ -52,6 +52,7 @@ ENTRY (__longjmp)
mov.l @r4+, r15
lds.l @r4+, pr
#endif
+#ifdef __SH_FPU_ANY__
ldc.l @r4+, gbr
lds.l @r4+, fpscr
fmov.s @r4+, fr12
@@ -59,4 +60,8 @@ ENTRY (__longjmp)
fmov.s @r4+, fr14
rts
fmov.s @r4+, fr15
+#else
+ rts
+ ldc.l @r4+, gbr
+#endif /* !__SH_FPU_ANY__ */
END (__longjmp)
Index: src/glibc-mainline/sysdeps/sh/sh4/setjmp.S
===================================================================
--- src/glibc-mainline/sysdeps/sh/sh4/setjmp.S.orig
+++ src/glibc-mainline/sysdeps/sh/sh4/setjmp.S
@@ -23,11 +23,13 @@
ENTRY (__sigsetjmp)
/* Save registers */
add #JB_SIZE, r4
+#ifdef __SH_FPU_ANY__
fmov.s fr15, @-r4
fmov.s fr14, @-r4
fmov.s fr13, @-r4
fmov.s fr12, @-r4
sts.l fpscr, @-r4
+#endif /* __SH_FPU_ANY__ */
stc.l gbr, @-r4
#ifdef PTR_MANGLE
sts pr, r2
Index: src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S
===================================================================
--- src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S.orig
+++ src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S
@@ -61,6 +61,7 @@ ENTRY(__getcontext)
mov.l r9, @-r0
mov.l r8, @-r0
+#ifdef __SH_FPU_ANY__
mov r4, r0
/* We need 2 add instruction because oFPUL+4 > 127. */
add #124,r0
@@ -101,6 +102,7 @@ ENTRY(__getcontext)
fmov.s fr2, @-r0
fmov.s fr1, @-r0
fmov.s fr0, @-r0
+#endif /* __SH_FPU_ANY__ */
/* sigprocmask (SIG_BLOCK, NULL, &uc->uc_sigmask). */
mov r4, r6
Index: src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h
===================================================================
--- src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h.orig
+++ src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h
@@ -144,6 +144,7 @@ register_dump (int fd, struct sigcontext
ADD_STRING ("\n");
+#ifdef __SH_FPU_ANY__
if (ctx->sc_ownedfp != NULL)
{
hexvalue (ctx->sc_fpregs[0], fpregs[0], 8);
@@ -253,6 +254,7 @@ register_dump (int fd, struct sigcontext
ADD_STRING ("\n");
}
+#endif /* __SH_FPU_ANY__ */
/* Write the stuff out. */
writev (fd, iov, nr);
Index: src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S
===================================================================
--- src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S.orig
+++ src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S
@@ -50,6 +50,7 @@ ENTRY(__setcontext)
nop
.Lsetcontext_restore:
+#ifdef __SH_FPU_ANY__
mov r8, r0
add #(oFR0),r0
fmov.s @r0+, fr0
@@ -88,6 +89,7 @@ ENTRY(__setcontext)
frchg
lds.l @r0+, fpscr
lds.l @r0+, fpul
+#endif /* __SH_FPU_ANY__ */
mov r8, r0
add #(oPC), r0
Index: src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S
===================================================================
--- src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S.orig
+++ src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S
@@ -61,6 +61,7 @@ ENTRY(__swapcontext)
mov.l r9, @-r0
mov.l r8, @-r0
+#ifdef __SH_FPU_ANY__
mov r4, r0
/* We need 2 add instruction because oFPUL+4 >= 127. */
add #124,r0
@@ -101,6 +102,7 @@ ENTRY(__swapcontext)
fmov.s fr2, @-r0
fmov.s fr1, @-r0
fmov.s fr0, @-r0
+#endif /* __SH_FPU_ANY__ */
mov r5, r8
@@ -125,6 +127,7 @@ ENTRY(__swapcontext)
rts
nop
.Lswapcontext_restore:
+#ifdef __SH_FPU_ANY__
mov r8, r0
add #(oFR0),r0
fmov.s @r0+, fr0
@@ -163,6 +166,7 @@ ENTRY(__swapcontext)
frchg
lds.l @r0+, fpscr
lds.l @r0+, fpul
+#endif /* __SH_FPU_ANY__ */
mov r8, r0
add #(oPC), r0