1 /* Copyright (c) 2006 Tensilica Inc.
2 
3    Permission is hereby granted, free of charge, to any person obtaining
4    a copy of this software and associated documentation files (the
5    "Software"), to deal in the Software without restriction, including
6    without limitation the rights to use, copy, modify, merge, publish,
7    distribute, sublicense, and/or sell copies of the Software, and to
8    permit persons to whom the Software is furnished to do so, subject to
9    the following conditions:
10 
11    The above copyright notice and this permission notice shall be included
12    in all copies or substantial portions of the Software.
13 
14    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
21 
22 /* Define macros for leaf function entry and return, supporting either the
23  * standard register windowed ABI or the non-windowed call0 ABI.  These
24  * macros do not allocate any extra stack space, so they only work for
25  * leaf functions that do not need to spill anything to the stack.  */
26 
27 #include <machine/core-isa.h>
28 
29 	.macro leaf_entry reg, size
30 #if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
31 	entry \reg, \size
32 #else
33 	/* do nothing */
34 #endif
35 	.endm
36 
37 	.macro leaf_return
38 #if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
39 	retw
40 #else
41 	ret
42 #endif
43 	.endm
44 
45 	.macro	src_b	r, w0, w1
46 #ifdef __XTENSA_EB__
47 	src	\r, \w0, \w1
48 #else
49 	src	\r, \w1, \w0
50 #endif
51 	.endm
52 
53 	.macro	ssa8	r
54 #ifdef __XTENSA_EB__
55 	ssa8b	\r
56 #else
57 	ssa8l	\r
58 #endif
59 	.endm
60 
61 #if XCHAL_HAVE_BE
62 #define	MASK0 0xff000000
63 #define	MASK1 0x00ff0000
64 #define	MASK2 0x0000ff00
65 #define	MASK3 0x000000ff
66 #else
67 #define	MASK0 0x000000ff
68 #define	MASK1 0x0000ff00
69 #define	MASK2 0x00ff0000
70 #define	MASK3 0xff000000
71 #endif
72 
73