public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Optimize setjmp/longjmp for moxie.
@ 2019-12-20 14:01 Anthony Green
0 siblings, 0 replies; only message in thread
From: Anthony Green @ 2019-12-20 14:01 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b481c11e5a7eb409c76f56873d6378e7ff1e3e05
commit b481c11e5a7eb409c76f56873d6378e7ff1e3e05
Author: Anthony Green <green@moxielogic.com>
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-20 14:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 14:01 [newlib-cygwin] Optimize setjmp/longjmp for moxie Anthony Green
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).