summaryrefslogtreecommitdiff
path: root/patches/gcc/4.9.4/871-xtensa-reimplement-register-spilling.patch
blob: abc7a08e8d287de447adf8dbf25bb630c10b95be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 05154174b369505238b759cf80d595d8cfc8c731 Mon Sep 17 00:00:00 2001
From: Max Filippov <jcmvbkbc@gmail.com>
Date: Mon, 10 Aug 2015 21:35:20 +0300
Subject: [PATCH 1/3] xtensa: reimplement register spilling

Spilling windowed registers in userspace is much easier, more portable,
less error-prone and equally effective as in kernel. Now that register
spilling syscall is considered obsolete in the xtensa linux kernel
replace it with CALL12 followed by series of ENTRY in libgcc.

2015-08-18  Max Filippov  <jcmvbkbc@gmail.com>
libgcc/
	* config/xtensa/lib2funcs.S (__xtensa_libgcc_window_spill): Use
	CALL12 followed by series of ENTRY to spill windowed registers.
	(__xtensa_nonlocal_goto): Call __xtensa_libgcc_window_spill
	instead of making linux spill syscall.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
Backported from: r226962

 libgcc/config/xtensa/lib2funcs.S | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/libgcc/config/xtensa/lib2funcs.S b/libgcc/config/xtensa/lib2funcs.S
index 3ac8c1d..2e678af 100644
--- a/libgcc/config/xtensa/lib2funcs.S
+++ b/libgcc/config/xtensa/lib2funcs.S
@@ -33,10 +33,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 	.global	__xtensa_libgcc_window_spill
 	.type	__xtensa_libgcc_window_spill,@function
 __xtensa_libgcc_window_spill:
-	entry	sp, 32
-	movi	a2, 0
-	syscall
+	entry	sp, 48
+#if XCHAL_NUM_AREGS > 16
+	call12	1f
+	retw
+	.align	4
+1:
+	.rept	(XCHAL_NUM_AREGS - 24) / 12
+	_entry	sp, 48
+	mov	a12, a0
+	.endr
+	_entry	sp, 16
+#if XCHAL_NUM_AREGS % 12 == 0
+	mov	a4, a4
+#elif XCHAL_NUM_AREGS % 12 == 4
+	mov	a8, a8
+#elif XCHAL_NUM_AREGS % 12 == 8
+	mov	a12, a12
+#endif
+	retw
+#else
+	mov	a8, a8
 	retw
+#endif
 	.size	__xtensa_libgcc_window_spill, .-__xtensa_libgcc_window_spill
 
 
@@ -58,10 +77,7 @@ __xtensa_nonlocal_goto:
 	entry	sp, 32
 
 	/* Flush registers.  */
-	mov	a5, a2
-	movi	a2, 0
-	syscall
-	mov	a2, a5
+	call8	__xtensa_libgcc_window_spill
 
 	/* Because the save area for a0-a3 is stored one frame below
 	   the one identified by a2, the only way to restore those
-- 
1.8.1.4