diff options
Diffstat (limited to 'src/setjmp')
| -rw-r--r-- | src/setjmp/aarch64/longjmp.s | 7 | ||||
| -rw-r--r-- | src/setjmp/arm/longjmp.S (renamed from src/setjmp/arm/longjmp.s) | 7 | ||||
| -rw-r--r-- | src/setjmp/arm/setjmp.S (renamed from src/setjmp/arm/setjmp.s) | 7 | ||||
| -rw-r--r-- | src/setjmp/i386/longjmp.s | 12 | ||||
| -rw-r--r-- | src/setjmp/loongarch64/longjmp.S | 32 | ||||
| -rw-r--r-- | src/setjmp/loongarch64/setjmp.S | 34 | ||||
| -rw-r--r-- | src/setjmp/mips/longjmp.S | 18 | ||||
| -rw-r--r-- | src/setjmp/mips/setjmp.S | 18 | ||||
| -rw-r--r-- | src/setjmp/powerpc/longjmp.S | 32 | ||||
| -rw-r--r-- | src/setjmp/powerpc/setjmp.S | 32 | ||||
| -rw-r--r-- | src/setjmp/riscv32/longjmp.S | 48 | ||||
| -rw-r--r-- | src/setjmp/riscv32/setjmp.S | 47 | ||||
| -rw-r--r-- | src/setjmp/riscv64/longjmp.S | 30 | ||||
| -rw-r--r-- | src/setjmp/riscv64/setjmp.S | 30 | ||||
| -rw-r--r-- | src/setjmp/x32/longjmp.s | 14 | ||||
| -rw-r--r-- | src/setjmp/x32/setjmp.s | 2 | ||||
| -rw-r--r-- | src/setjmp/x86_64/longjmp.s | 14 | ||||
| -rw-r--r-- | src/setjmp/x86_64/setjmp.s | 2 | 
18 files changed, 304 insertions, 82 deletions
diff --git a/src/setjmp/aarch64/longjmp.s b/src/setjmp/aarch64/longjmp.s index 7c4655fa..0af9c50e 100644 --- a/src/setjmp/aarch64/longjmp.s +++ b/src/setjmp/aarch64/longjmp.s @@ -18,7 +18,6 @@ longjmp:  	ldp d12, d13, [x0,#144]  	ldp d14, d15, [x0,#160] -	mov x0, x1 -	cbnz x1, 1f -	mov x0, #1 -1:	br x30 +	cmp w1, 0 +	csinc w0, w1, wzr, ne +	br x30 diff --git a/src/setjmp/arm/longjmp.s b/src/setjmp/arm/longjmp.S index 76cc2920..8df0b819 100644 --- a/src/setjmp/arm/longjmp.s +++ b/src/setjmp/arm/longjmp.S @@ -16,11 +16,14 @@ longjmp:  	ldr r2,1f  	ldr r1,[r1,r2] +#if __ARM_ARCH < 8  	tst r1,#0x260  	beq 3f +	// HWCAP_ARM_FPA  	tst r1,#0x20  	beq 2f  	ldc p2, cr4, [ip], #48 +#endif  2:	tst r1,#0x40  	beq 2f  	.fpu vfp @@ -28,6 +31,8 @@ longjmp:  	.fpu softvfp  	.eabi_attribute 10, 0  	.eabi_attribute 27, 0 +#if __ARM_ARCH < 8 +	// HWCAP_ARM_IWMMXT  2:	tst r1,#0x200  	beq 3f  	ldcl p1, cr10, [ip], #8 @@ -36,6 +41,8 @@ longjmp:  	ldcl p1, cr13, [ip], #8  	ldcl p1, cr14, [ip], #8  	ldcl p1, cr15, [ip], #8 +#endif +2:  3:	bx lr  .hidden __hwcap diff --git a/src/setjmp/arm/setjmp.s b/src/setjmp/arm/setjmp.S index 011315b7..45731d22 100644 --- a/src/setjmp/arm/setjmp.s +++ b/src/setjmp/arm/setjmp.S @@ -18,11 +18,14 @@ setjmp:  	ldr r2,1f  	ldr r1,[r1,r2] +#if __ARM_ARCH < 8  	tst r1,#0x260  	beq 3f +	// HWCAP_ARM_FPA  	tst r1,#0x20  	beq 2f  	stc p2, cr4, [ip], #48 +#endif  2:	tst r1,#0x40  	beq 2f  	.fpu vfp @@ -30,6 +33,8 @@ setjmp:  	.fpu softvfp  	.eabi_attribute 10, 0  	.eabi_attribute 27, 0 +#if __ARM_ARCH < 8 +	// HWCAP_ARM_IWMMXT  2:	tst r1,#0x200  	beq 3f  	stcl p1, cr10, [ip], #8 @@ -38,6 +43,8 @@ setjmp:  	stcl p1, cr13, [ip], #8  	stcl p1, cr14, [ip], #8  	stcl p1, cr15, [ip], #8 +#endif +2:  3:	bx lr  .hidden __hwcap diff --git a/src/setjmp/i386/longjmp.s b/src/setjmp/i386/longjmp.s index 772d28dd..8188f06b 100644 --- a/src/setjmp/i386/longjmp.s +++ b/src/setjmp/i386/longjmp.s @@ -6,15 +6,11 @@ _longjmp:  longjmp:  	mov  4(%esp),%edx  	mov  8(%esp),%eax -	test    %eax,%eax -	jnz 1f -	inc     %eax -1: +	cmp       $1,%eax +	adc       $0, %al  	mov   (%edx),%ebx  	mov  4(%edx),%esi  	mov  8(%edx),%edi  	mov 12(%edx),%ebp -	mov 16(%edx),%ecx -	mov     %ecx,%esp -	mov 20(%edx),%ecx -	jmp *%ecx +	mov 16(%edx),%esp +	jmp *20(%edx) diff --git a/src/setjmp/loongarch64/longjmp.S b/src/setjmp/loongarch64/longjmp.S new file mode 100644 index 00000000..896d2e26 --- /dev/null +++ b/src/setjmp/loongarch64/longjmp.S @@ -0,0 +1,32 @@ +.global _longjmp +.global longjmp +.type   _longjmp,@function +.type   longjmp,@function +_longjmp: +longjmp: +	ld.d    $ra, $a0, 0 +	ld.d    $sp, $a0, 8 +	ld.d    $r21,$a0, 16 +	ld.d    $fp, $a0, 24 +	ld.d    $s0, $a0, 32 +	ld.d    $s1, $a0, 40 +	ld.d    $s2, $a0, 48 +	ld.d    $s3, $a0, 56 +	ld.d    $s4, $a0, 64 +	ld.d    $s5, $a0, 72 +	ld.d    $s6, $a0, 80 +	ld.d    $s7, $a0, 88 +	ld.d    $s8, $a0, 96 +#ifndef __loongarch_soft_float +	fld.d   $fs0, $a0, 104 +	fld.d   $fs1, $a0, 112 +	fld.d   $fs2, $a0, 120 +	fld.d   $fs3, $a0, 128 +	fld.d   $fs4, $a0, 136 +	fld.d   $fs5, $a0, 144 +	fld.d   $fs6, $a0, 152 +	fld.d   $fs7, $a0, 160 +#endif +	sltui   $a0, $a1, 1 +	add.d   $a0, $a0, $a1 +	jr      $ra diff --git a/src/setjmp/loongarch64/setjmp.S b/src/setjmp/loongarch64/setjmp.S new file mode 100644 index 00000000..d158a3d2 --- /dev/null +++ b/src/setjmp/loongarch64/setjmp.S @@ -0,0 +1,34 @@ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +__setjmp: +_setjmp: +setjmp: +	st.d    $ra, $a0, 0 +	st.d    $sp, $a0, 8 +	st.d    $r21,$a0, 16 +	st.d    $fp, $a0, 24 +	st.d    $s0, $a0, 32 +	st.d    $s1, $a0, 40 +	st.d    $s2, $a0, 48 +	st.d    $s3, $a0, 56 +	st.d    $s4, $a0, 64 +	st.d    $s5, $a0, 72 +	st.d    $s6, $a0, 80 +	st.d    $s7, $a0, 88 +	st.d    $s8, $a0, 96 +#ifndef __loongarch_soft_float +	fst.d   $fs0, $a0, 104 +	fst.d   $fs1, $a0, 112 +	fst.d   $fs2, $a0, 120 +	fst.d   $fs3, $a0, 128 +	fst.d   $fs4, $a0, 136 +	fst.d   $fs5, $a0, 144 +	fst.d   $fs6, $a0, 152 +	fst.d   $fs7, $a0, 160 +#endif +	move    $a0, $zero +	jr      $ra diff --git a/src/setjmp/mips/longjmp.S b/src/setjmp/mips/longjmp.S index fdb6c95d..ecf40855 100644 --- a/src/setjmp/mips/longjmp.S +++ b/src/setjmp/mips/longjmp.S @@ -12,18 +12,12 @@ longjmp:  	addu    $2, $2, 1  1:  #ifndef __mips_soft_float -	lwc1    $20, 56($4) -	lwc1    $21, 60($4) -	lwc1    $22, 64($4) -	lwc1    $23, 68($4) -	lwc1    $24, 72($4) -	lwc1    $25, 76($4) -	lwc1    $26, 80($4) -	lwc1    $27, 84($4) -	lwc1    $28, 88($4) -	lwc1    $29, 92($4) -	lwc1    $30, 96($4) -	lwc1    $31, 100($4) +	l.d     $f20, 56($4) +	l.d     $f22, 64($4) +	l.d     $f24, 72($4) +	l.d     $f26, 80($4) +	l.d     $f28, 88($4) +	l.d     $f30, 96($4)  #endif  	lw      $ra,  0($4)  	lw      $sp,  4($4) diff --git a/src/setjmp/mips/setjmp.S b/src/setjmp/mips/setjmp.S index 501d5264..7ae8832d 100644 --- a/src/setjmp/mips/setjmp.S +++ b/src/setjmp/mips/setjmp.S @@ -22,18 +22,12 @@ setjmp:  	sw      $30, 40($4)  	sw      $28, 44($4)  #ifndef __mips_soft_float -	swc1    $20, 56($4) -	swc1    $21, 60($4) -	swc1    $22, 64($4) -	swc1    $23, 68($4) -	swc1    $24, 72($4) -	swc1    $25, 76($4) -	swc1    $26, 80($4) -	swc1    $27, 84($4) -	swc1    $28, 88($4) -	swc1    $29, 92($4) -	swc1    $30, 96($4) -	swc1    $31, 100($4) +	s.d     $f20, 56($4) +	s.d     $f22, 64($4) +	s.d     $f24, 72($4) +	s.d     $f26, 80($4) +	s.d     $f28, 88($4) +	s.d     $f30, 96($4)  #endif  	jr      $ra  	li      $2, 0 diff --git a/src/setjmp/powerpc/longjmp.S b/src/setjmp/powerpc/longjmp.S index e598bd05..465e4cd7 100644 --- a/src/setjmp/powerpc/longjmp.S +++ b/src/setjmp/powerpc/longjmp.S @@ -37,7 +37,37 @@ longjmp:  	lwz 29, 72(3)  	lwz 30, 76(3)  	lwz 31, 80(3) -#ifndef _SOFT_FLOAT +#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) +	mflr 0 +	bl 1f +	.hidden __hwcap +	.long __hwcap-. +1:	mflr 6 +	lwz 5, 0(6) +	lwzx 6, 6, 5 +	andis. 6, 6, 0x80 +	beq 1f +	.long 0x11c35b01 /* evldd 14,88(3) */ +	.long 0x11e36301 /* ... */ +	.long 0x12036b01 +	.long 0x12237301 +	.long 0x12437b01 +	.long 0x12638301 +	.long 0x12838b01 +	.long 0x12a39301 +	.long 0x12c39b01 +	.long 0x12e3a301 +	.long 0x1303ab01 +	.long 0x1323b301 +	.long 0x1343bb01 +	.long 0x1363c301 +	.long 0x1383cb01 +	.long 0x13a3d301 +	.long 0x13c3db01 +	.long 0x13e3e301 /* evldd 31,224(3) */ +	.long 0x11a3eb01 /* evldd 13,232(3) */ +1:	mtlr 0 +#else  	lfd 14,88(3)  	lfd 15,96(3)  	lfd 16,104(3) diff --git a/src/setjmp/powerpc/setjmp.S b/src/setjmp/powerpc/setjmp.S index cd91a207..f1fcce33 100644 --- a/src/setjmp/powerpc/setjmp.S +++ b/src/setjmp/powerpc/setjmp.S @@ -37,7 +37,37 @@ setjmp:  	stw 29, 72(3)  	stw 30, 76(3)  	stw 31, 80(3) -#ifndef _SOFT_FLOAT +#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) +	mflr 0 +	bl 1f +	.hidden __hwcap +	.long __hwcap-. +1:	mflr 4 +	lwz 5, 0(4) +	lwzx 4, 4, 5 +	andis. 4, 4, 0x80 +	beq 1f +	.long 0x11c35b21 /* evstdd 14,88(3) */ +	.long 0x11e36321 /* ... */ +	.long 0x12036b21 +	.long 0x12237321 +	.long 0x12437b21 +	.long 0x12638321 +	.long 0x12838b21 +	.long 0x12a39321 +	.long 0x12c39b21 +	.long 0x12e3a321 +	.long 0x1303ab21 +	.long 0x1323b321 +	.long 0x1343bb21 +	.long 0x1363c321 +	.long 0x1383cb21 +	.long 0x13a3d321 +	.long 0x13c3db21 +	.long 0x13e3e321 /* evstdd 31,224(3) */ +	.long 0x11a3eb21 /* evstdd 13,232(3) */ +1:	mtlr 0 +#else  	stfd 14,88(3)  	stfd 15,96(3)  	stfd 16,104(3) diff --git a/src/setjmp/riscv32/longjmp.S b/src/setjmp/riscv32/longjmp.S new file mode 100644 index 00000000..b4e5458d --- /dev/null +++ b/src/setjmp/riscv32/longjmp.S @@ -0,0 +1,48 @@ +.global __longjmp +.global _longjmp +.global longjmp +.type __longjmp, %function +.type _longjmp,  %function +.type longjmp,   %function +__longjmp: +_longjmp: +longjmp: +	lw s0,    0(a0) +	lw s1,    4(a0) +	lw s2,    8(a0) +	lw s3,    12(a0) +	lw s4,    16(a0) +	lw s5,    20(a0) +	lw s6,    24(a0) +	lw s7,    28(a0) +	lw s8,    32(a0) +	lw s9,    36(a0) +	lw s10,   40(a0) +	lw s11,   44(a0) +	lw sp,    48(a0) +	lw ra,    52(a0) + +#ifndef __riscv_float_abi_soft +#ifdef __riscv_float_abi_double +#define FLX fld +#else +#define FLX flw +#endif + +	FLX fs0,  56(a0) +	FLX fs1,  64(a0) +	FLX fs2,  72(a0) +	FLX fs3,  80(a0) +	FLX fs4,  88(a0) +	FLX fs5,  96(a0) +	FLX fs6,  104(a0) +	FLX fs7,  112(a0) +	FLX fs8,  120(a0) +	FLX fs9,  128(a0) +	FLX fs10, 136(a0) +	FLX fs11, 144(a0) +#endif + +	seqz a0, a1 +	add a0, a0, a1 +	ret diff --git a/src/setjmp/riscv32/setjmp.S b/src/setjmp/riscv32/setjmp.S new file mode 100644 index 00000000..5a1a41ef --- /dev/null +++ b/src/setjmp/riscv32/setjmp.S @@ -0,0 +1,47 @@ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp, %function +.type _setjmp,  %function +.type setjmp,   %function +__setjmp: +_setjmp: +setjmp: +	sw s0,    0(a0) +	sw s1,    4(a0) +	sw s2,    8(a0) +	sw s3,    12(a0) +	sw s4,    16(a0) +	sw s5,    20(a0) +	sw s6,    24(a0) +	sw s7,    28(a0) +	sw s8,    32(a0) +	sw s9,    36(a0) +	sw s10,   40(a0) +	sw s11,   44(a0) +	sw sp,    48(a0) +	sw ra,    52(a0) + +#ifndef __riscv_float_abi_soft +#ifdef __riscv_float_abi_double +#define FSX fsd +#else +#define FSX fsw +#endif + +	FSX fs0,  56(a0) +	FSX fs1,  64(a0) +	FSX fs2,  72(a0) +	FSX fs3,  80(a0) +	FSX fs4,  88(a0) +	FSX fs5,  96(a0) +	FSX fs6,  104(a0) +	FSX fs7,  112(a0) +	FSX fs8,  120(a0) +	FSX fs9,  128(a0) +	FSX fs10, 136(a0) +	FSX fs11, 144(a0) +#endif + +	li a0, 0 +	ret diff --git a/src/setjmp/riscv64/longjmp.S b/src/setjmp/riscv64/longjmp.S index 41e2d210..982475c7 100644 --- a/src/setjmp/riscv64/longjmp.S +++ b/src/setjmp/riscv64/longjmp.S @@ -23,18 +23,24 @@ longjmp:  	ld ra,    104(a0)  #ifndef __riscv_float_abi_soft -	fld fs0,  112(a0) -	fld fs1,  120(a0) -	fld fs2,  128(a0) -	fld fs3,  136(a0) -	fld fs4,  144(a0) -	fld fs5,  152(a0) -	fld fs6,  160(a0) -	fld fs7,  168(a0) -	fld fs8,  176(a0) -	fld fs9,  184(a0) -	fld fs10, 192(a0) -	fld fs11, 200(a0) +#ifdef __riscv_float_abi_double +#define FLX fld +#else +#define FLX flw +#endif + +	FLX fs0,  112(a0) +	FLX fs1,  120(a0) +	FLX fs2,  128(a0) +	FLX fs3,  136(a0) +	FLX fs4,  144(a0) +	FLX fs5,  152(a0) +	FLX fs6,  160(a0) +	FLX fs7,  168(a0) +	FLX fs8,  176(a0) +	FLX fs9,  184(a0) +	FLX fs10, 192(a0) +	FLX fs11, 200(a0)  #endif  	seqz a0, a1 diff --git a/src/setjmp/riscv64/setjmp.S b/src/setjmp/riscv64/setjmp.S index 51249672..0795bf7d 100644 --- a/src/setjmp/riscv64/setjmp.S +++ b/src/setjmp/riscv64/setjmp.S @@ -23,18 +23,24 @@ setjmp:  	sd ra,    104(a0)  #ifndef __riscv_float_abi_soft -	fsd fs0,  112(a0) -	fsd fs1,  120(a0) -	fsd fs2,  128(a0) -	fsd fs3,  136(a0) -	fsd fs4,  144(a0) -	fsd fs5,  152(a0) -	fsd fs6,  160(a0) -	fsd fs7,  168(a0) -	fsd fs8,  176(a0) -	fsd fs9,  184(a0) -	fsd fs10, 192(a0) -	fsd fs11, 200(a0) +#ifdef __riscv_float_abi_double +#define FSX fsd +#else +#define FSX fsw +#endif + +	FSX fs0,  112(a0) +	FSX fs1,  120(a0) +	FSX fs2,  128(a0) +	FSX fs3,  136(a0) +	FSX fs4,  144(a0) +	FSX fs5,  152(a0) +	FSX fs6,  160(a0) +	FSX fs7,  168(a0) +	FSX fs8,  176(a0) +	FSX fs9,  184(a0) +	FSX fs10, 192(a0) +	FSX fs11, 200(a0)  #endif  	li a0, 0 diff --git a/src/setjmp/x32/longjmp.s b/src/setjmp/x32/longjmp.s index e175a4b9..1b2661c3 100644 --- a/src/setjmp/x32/longjmp.s +++ b/src/setjmp/x32/longjmp.s @@ -5,18 +5,14 @@  .type longjmp,@function  _longjmp:  longjmp: -	mov %rsi,%rax           /* val will be longjmp return */ -	test %rax,%rax -	jnz 1f -	inc %rax                /* if val==0, val=1 per longjmp semantics */ -1: +	xor %eax,%eax +	cmp $1,%esi             /* CF = val ? 0 : 1 */ +	adc %esi,%eax           /* eax = val + !val */  	mov (%rdi),%rbx         /* rdi is the jmp_buf, restore regs from it */  	mov 8(%rdi),%rbp  	mov 16(%rdi),%r12  	mov 24(%rdi),%r13  	mov 32(%rdi),%r14  	mov 40(%rdi),%r15 -	mov 48(%rdi),%rdx       /* this ends up being the stack pointer */ -	mov %rdx,%rsp -	mov 56(%rdi),%rdx       /* this is the instruction pointer */ -	jmp *%rdx               /* goto saved address without altering rsp */ +	mov 48(%rdi),%rsp +	jmp *56(%rdi)           /* goto saved address without altering rsp */ diff --git a/src/setjmp/x32/setjmp.s b/src/setjmp/x32/setjmp.s index 98f58b8d..d95e4853 100644 --- a/src/setjmp/x32/setjmp.s +++ b/src/setjmp/x32/setjmp.s @@ -18,5 +18,5 @@ setjmp:  	mov %rdx,48(%rdi)  	mov (%rsp),%rdx         /* save return addr ptr for new rip */  	mov %rdx,56(%rdi) -	xor %rax,%rax           /* always return 0 */ +	xor %eax,%eax           /* always return 0 */  	ret diff --git a/src/setjmp/x86_64/longjmp.s b/src/setjmp/x86_64/longjmp.s index e175a4b9..1b2661c3 100644 --- a/src/setjmp/x86_64/longjmp.s +++ b/src/setjmp/x86_64/longjmp.s @@ -5,18 +5,14 @@  .type longjmp,@function  _longjmp:  longjmp: -	mov %rsi,%rax           /* val will be longjmp return */ -	test %rax,%rax -	jnz 1f -	inc %rax                /* if val==0, val=1 per longjmp semantics */ -1: +	xor %eax,%eax +	cmp $1,%esi             /* CF = val ? 0 : 1 */ +	adc %esi,%eax           /* eax = val + !val */  	mov (%rdi),%rbx         /* rdi is the jmp_buf, restore regs from it */  	mov 8(%rdi),%rbp  	mov 16(%rdi),%r12  	mov 24(%rdi),%r13  	mov 32(%rdi),%r14  	mov 40(%rdi),%r15 -	mov 48(%rdi),%rdx       /* this ends up being the stack pointer */ -	mov %rdx,%rsp -	mov 56(%rdi),%rdx       /* this is the instruction pointer */ -	jmp *%rdx               /* goto saved address without altering rsp */ +	mov 48(%rdi),%rsp +	jmp *56(%rdi)           /* goto saved address without altering rsp */ diff --git a/src/setjmp/x86_64/setjmp.s b/src/setjmp/x86_64/setjmp.s index 98f58b8d..d95e4853 100644 --- a/src/setjmp/x86_64/setjmp.s +++ b/src/setjmp/x86_64/setjmp.s @@ -18,5 +18,5 @@ setjmp:  	mov %rdx,48(%rdi)  	mov (%rsp),%rdx         /* save return addr ptr for new rip */  	mov %rdx,56(%rdi) -	xor %rax,%rax           /* always return 0 */ +	xor %eax,%eax           /* always return 0 */  	ret  | 
