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.
This commit is contained in:
Anthony Green 2019-12-20 09:00:26 -05:00
parent 27202a1b14
commit b481c11e5a
2 changed files with 39 additions and 87 deletions

View File

@ -238,7 +238,7 @@ _BEGIN_STD_C
#endif
#ifdef __moxie__
#define _JBLEN 19
#define _JBLEN 10
#endif
#ifdef __CRX__

View File

@ -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