From 640220faf25659eb4c15b78cf8869251dbadbd16 Mon Sep 17 00:00:00 2001 From: Giuseppe Cavallaro Date: Mon, 13 Dec 2010 11:39:36 +0100 Subject: sh: fix memcpy saving/restoring FR12-FR15 registers This patch fixes a bug in the memcpy that doesn't save/restore the FR12-FR15 registers (callee save registers in ST40 ABI) while copying many cache lines with FPU in single paired precision mode and by using all FPU registers (DR and XD). Signed-off-by: Giuseppe Cavallaro Reviewed-by: Carmelo Amoroso Signed-off-by: Carmelo Amoroso --- libc/string/sh/sh4/memcpy.S | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'libc/string') diff --git a/libc/string/sh/sh4/memcpy.S b/libc/string/sh/sh4/memcpy.S index 5be770a59..6a229a06c 100644 --- a/libc/string/sh/sh4/memcpy.S +++ b/libc/string/sh/sh4/memcpy.S @@ -497,6 +497,12 @@ ENTRY(memcpy) mov r5, r6 add #-0x80, r6 ! prefetch head + ! store FPU (in single precision mode, do not check R15 align). + fmov fr12, @-r15 + fmov fr13, @-r15 + fmov fr14, @-r15 + fmov fr15, @-r15 + FPU_SET_PAIRED_PREC mov #4, r0 @@ -553,16 +559,22 @@ ENTRY(memcpy) bt/s 67b pref @r6 + RESTORE_FPSCR + + ! Restore FPU callee save registers + fmov @r15+, fr15 + fmov @r15+, fr14 + fmov @r15+, fr13 + fmov @r15+, fr12 + ! Other cache lines could be copied: so use the FPU in single paired ! precision without prefetching. No check for alignment is necessary. mov #1, r0 cmp/ge r0, r3 - bt/s 4f + bt/s 3f add #0x60, r5 - RESTORE_FPSCR - bra 5f nop -- cgit v1.2.3