1/* Function to force register windows to the stack.
2   Copyright (C) 2005, 2007 Free Software Foundation, Inc.
3   This file is part of the GNU C Library.
4
5   The GNU C Library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9
10   The GNU C Library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public
16   License along with the GNU C Library; if not, see
17   <http://www.gnu.org/licenses/>.  */
18
19#include <bits/xtensa-config.h>
20
21#ifdef __XTENSA_WINDOWED_ABI__
22	.text
23	.align  4
24	.literal_position
25	.global __window_spill
26	.type   __window_spill, @function
27__window_spill:
28	entry	a1, 48
29        bbci.l  a0, 31, .L4		/* branch if called with call4 */
30        bbsi.l  a0, 30, .L12		/* branch if called with call12 */
31
32	/* Called with call8: touch register NUM_REGS-12 (4/20/52) */
33.L8:
34#if XCHAL_NUM_AREGS > 16
35	call12	1f
36	retw
37
38	.align	4
391:	_entry	a1, 48			/* touch NUM_REGS-24 (x/8/40) */
40
41#if XCHAL_NUM_AREGS == 32
42	mov	a8, a0
43	retw
44#else
45	mov	a12, a0
46	_entry	a1, 48			/* touch NUM_REGS-36 (x/x/28) */
47	mov	a12, a0
48	_entry	a1, 48			/* touch NUM_REGS-48 (x/x/16) */
49	mov	a12, a0
50	_entry	a1, 16			/* touch NUM_REGS-60 (x/x/4) */
51#endif
52#endif
53	mov	a4, a0
54	retw
55
56	/* Called with call4: touch register NUM_REGS-8 (8/24/56) */
57.L4:
58#if XCHAL_NUM_AREGS == 16
59	mov	a8, a0
60#else
61	call12	1f
62	retw
63
64	.align	4
651:	_entry	a1, 48			/* touch NUM_REGS-20 (x/12/44) */
66	mov	a12, a0
67#if XCHAL_NUM_AREGS > 32
68	_entry	a1, 48			/* touch NUM_REGS-32 (x/x/32) */
69	mov	a12, a0
70	_entry	a1, 48			/* touch NUM_REGS-44 (x/x/20) */
71	mov	a12, a0
72	_entry	a1, 48			/* touch NUM_REGS-56 (x/x/8) */
73	mov	a8, a0
74#endif
75#endif
76	retw
77
78	/* Called with call12: touch register NUM_REGS-16 (x/16/48) */
79.L12:
80#if XCHAL_NUM_AREGS > 16
81	call12	1f
82	retw
83
84	.align	4
851:	_entry	a1, 48			/* touch NUM_REGS-28 (x/4/36) */
86#if XCHAL_NUM_AREGS == 32
87	mov	a4, a0
88#else
89	mov	a12, a0
90	_entry	a1, 48			/* touch NUM_REGS-40 (x/x/24) */
91	mov	a12, a0
92	_entry	a1, 48			/* touch NUM_REGS-52 (x/x/12) */
93	mov	a12, a0
94#endif
95#endif
96	retw
97
98#endif
99