From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15665 invoked by alias); 20 Dec 2019 14:01:18 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 15623 invoked by uid 302); 20 Dec 2019 14:01:18 -0000 Date: Fri, 20 Dec 2019 14:01:00 -0000 Message-ID: <20191220140118.15621.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Anthony Green To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Optimize setjmp/longjmp for moxie. X-Act-Checkin: newlib-cygwin X-Git-Author: Anthony Green X-Git-Refname: refs/heads/master X-Git-Oldrev: 27202a1b143d19ceadfac2584f208392e4e0859a X-Git-Newrev: b481c11e5a7eb409c76f56873d6378e7ff1e3e05 X-SW-Source: 2019-q4/txt/msg00031.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b481c11e5a7eb409c76f56873d6378e7ff1e3e05 commit b481c11e5a7eb409c76f56873d6378e7ff1e3e05 Author: Anthony Green Date: Fri Dec 20 09:00:26 2019 -0500 Optimize setjmp/longjmp for moxie. We don't need to save/restore every register -- just those we don't expect to be trashed by function calls. Diff: --- newlib/libc/include/machine/setjmp.h | 2 +- newlib/libc/machine/moxie/setjmp.S | 124 +++++++++++------------------------ 2 files changed, 39 insertions(+), 87 deletions(-) diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h index 78a81b5..55152b0 100644 --- a/newlib/libc/include/machine/setjmp.h +++ b/newlib/libc/include/machine/setjmp.h @@ -238,7 +238,7 @@ _BEGIN_STD_C #endif #ifdef __moxie__ -#define _JBLEN 19 +#define _JBLEN 10 #endif #ifdef __CRX__ diff --git a/newlib/libc/machine/moxie/setjmp.S b/newlib/libc/machine/moxie/setjmp.S index ed261d5..014368d 100644 --- a/newlib/libc/machine/moxie/setjmp.S +++ b/newlib/libc/machine/moxie/setjmp.S @@ -14,53 +14,34 @@ # setjmp/longjmp for moxie. The jmpbuf looks like this: # # Register jmpbuf offset -# $r0 0x00 -# $r1 0x04 -# $r2 0x08 -# $r3 0x0c -# $r4 0x10 -# $r5 0x14 -# $r6 0x18 -# $r7 0x1c -# $r8 0x20 -# $r9 0x24 -# $r10 0x28 -# $r11 0x2c -# $r12 0x30 -# $r13 0x34 -# $fp 0x38 -# $sp 0x3c -# stack frame fp 0x40 -# stack frame ra 0x44 -# stack frame sc 0x48 +# $r6 0x00 +# $r7 0x04 +# $r8 0x08 +# $r9 0x0c +# $r10 0x10 +# $fp 0x14 +# $sp 0x18 +# stack frame fp 0x1c +# stack frame ra 0x20 +# stack frame sc 0x25 .text .global setjmp .type setjmp,@function setjmp: - st.l ($r0), $r0 - sto.l 0x04($r0), $r1 - sto.l 0x08($r0), $r2 - sto.l 0x0c($r0), $r3 - sto.l 0x10($r0), $r4 - sto.l 0x14($r0), $r5 - sto.l 0x18($r0), $r6 - sto.l 0x1c($r0), $r7 - sto.l 0x20($r0), $r8 - sto.l 0x24($r0), $r9 - sto.l 0x28($r0), $r10 - sto.l 0x2c($r0), $r11 - sto.l 0x30($r0), $r12 - sto.l 0x34($r0), $r13 - sto.l 0x38($r0), $sp - sto.l 0x3c($r0), $fp - ldo.l $r1, 0x0($fp) - sto.l 0x40($r0), $r1 + st.l ($r0), $r6 + sto.l 0x04($r0), $r7 + sto.l 0x08($r0), $r8 + sto.l 0x0c($r0), $r9 + sto.l 0x10($r0), $r10 + sto.l 0x14($r0), $sp + sto.l 0x18($r0), $fp + ldo.l $r1, 0x00($fp) + sto.l 0x1c($r0), $r1 ldo.l $r1, 0x04($fp) - sto.l 0x44($r0), $r1 + sto.l 0x20($r0), $r1 ldo.l $r1, 0x08($fp) - sto.l 0x48($r0), $r1 - ldo.l $r1, 0x04($r0) + sto.l 0x24($r0), $r1 xor $r0, $r0 ret .Lend1: @@ -69,56 +50,27 @@ setjmp: .global longjmp .type longjmp,@function longjmp: - ldi.l $r2, 0x00 - cmp $r1, $r2 - beq .Lreturn1 + ldo.l $r6, 0x00($r0) + ldo.l $r7, 0x04($r0) + ldo.l $r8, 0x08($r0) + ldo.l $r9, 0x0c($r0) + ldo.l $r10, 0x10($r0) + ldo.l $sp, 0x14($r0) + ldo.l $fp, 0x18($r0) + ldo.l $r2, 0x1c($r0) + sto.l 0x0($fp), $r2 + ldo.l $r2, 0x20($r0) + sto.l 0x4($fp), $r2 + ldo.l $r2, 0x24($r0) + sto.l 0x8($fp), $r2 ldo.l $r2, 0x08($r0) - ldo.l $r3, 0x0c($r0) - ldo.l $r4, 0x10($r0) - ldo.l $r5, 0x14($r0) - ldo.l $r6, 0x18($r0) - ldo.l $r7, 0x1c($r0) - ldo.l $r8, 0x20($r0) - ldo.l $r9, 0x24($r0) - ldo.l $r10, 0x28($r0) - ldo.l $r11, 0x2c($r0) - ldo.l $r12, 0x30($r0) - ldo.l $r13, 0x34($r0) - ldo.l $sp, 0x38($r0) - ldo.l $fp, 0x3c($r0) - ldo.l $r1, 0x40($r0) - sto.l 0x0($fp), $r1 - ldo.l $r1, 0x44($r0) - sto.l 0x4($fp), $r1 - ldo.l $r1, 0x48($r0) - sto.l 0x8($fp), $r1 - ldo.l $r1, 0x04($r0) mov $r0, $r1 + xor $r2, $r2 + cmp $r0, $r2 + beq .Lreturn1 ret .Lreturn1: - ldo.l $r1, 0x04($r0) - ldo.l $r2, 0x08($r0) - ldo.l $r3, 0x0c($r0) - ldo.l $r4, 0x10($r0) - ldo.l $r5, 0x14($r0) - ldo.l $r6, 0x18($r0) - ldo.l $r7, 0x1c($r0) - ldo.l $r8, 0x20($r0) - ldo.l $r9, 0x24($r0) - ldo.l $r10, 0x28($r0) - ldo.l $r11, 0x2c($r0) - ldo.l $r12, 0x30($r0) - ldo.l $r13, 0x34($r0) - ldo.l $sp, 0x38($r0) - ldo.l $fp, 0x3c($r0) - ldo.l $r1, 0x40($r0) - sto.l 0x0($fp), $r1 - ldo.l $r1, 0x44($r0) - sto.l 0x4($fp), $r1 - ldo.l $r1, 0x48($r0) - sto.l 0x8($fp), $r1 - ldo.l $r1, 0x04($r0) - ldi.l $r0, 0x01 + inc $r0, 1 ret .Lend2: .size longjmp,.Lend2-longjmp