1;   Copyright (C) 2012-2021 Free Software Foundation, Inc.
2;   Contributed by Red Hat.
3;
4; This file is free software; you can redistribute it and/or modify it
5; under the terms of the GNU General Public License as published by the
6; Free Software Foundation; either version 3, or (at your option) any
7; later version.
8;
9; This file is distributed in the hope that it will be useful, but
10; WITHOUT ANY WARRANTY; without even the implied warranty of
11; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12; General Public License for more details.
13;
14; Under Section 7 of GPL version 3, you are granted additional
15; permissions described in the GCC Runtime Library Exception, version
16; 3.1, as published by the Free Software Foundation.
17;
18; You should have received a copy of the GNU General Public License and
19; a copy of the GCC Runtime Library Exception along with this program;
20; see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
21; <http://www.gnu.org/licenses/>.
22
23	.text
24
25/* Logical Left Shift - R12 -> R12.  */
26
27	.section	.text.__mspabi_slli_n
28	.macro	_slli n
29	.global __mspabi_slli_\n
30__mspabi_slli_\n:
31	ADD.W	R12,R12
32	.endm
33
34	_slli	15
35	_slli	14
36	_slli	13
37	_slli	12
38	_slli	11
39	_slli	10
40	_slli	9
41	_slli	8
42	_slli	7
43	_slli	6
44	_slli	5
45	_slli	4
46	_slli	3
47	_slli	2
48	_slli	1
49#ifdef __MSP430X_LARGE__
50	RETA
51#else
52	RET
53#endif
54
55	.section	.text.__mspabi_slli
561:	ADD.W	#-1,R13
57	ADD.W	R12,R12
58	.global	__mspabi_slli
59__mspabi_slli:
60	CMP	#0,R13
61	JNZ	1b
62#ifdef __MSP430X_LARGE__
63	RETA
64#else
65	RET
66#endif
67
68#ifdef __MSP430X__
69	.section	.text.__gnu_mspabi_sllp
701:	ADDA	#-1,R13
71	ADDA	R12,R12
72	.global	__gnu_mspabi_sllp
73__gnu_mspabi_sllp:
74	CMP	#0,R13
75	JNZ	1b
76#ifdef __MSP430X_LARGE__
77	RETA
78#else
79	RET
80#endif /* __MSP430X_LARGE__ */
81#endif /* __MSP430X__ */
82
83/* Logical Left Shift - R12:R13 -> R12:R13.  */
84
85	.section	.text.__mspabi_slll_n
86	.macro	_slll	n
87	.global	__mspabi_slll_\n
88__mspabi_slll_\n:
89	ADD.W	R12,R12
90	ADDC.W	R13,R13
91	.endm
92
93	_slll	15
94	_slll	14
95	_slll	13
96	_slll	12
97	_slll	11
98	_slll	10
99	_slll	9
100	_slll	8
101	_slll	7
102	_slll	6
103	_slll	5
104	_slll	4
105	_slll	3
106	_slll	2
107	_slll	1
108#ifdef __MSP430X_LARGE__
109	RETA
110#else
111	RET
112#endif
113
114	.section	.text.__mspabi_slll
1151:	ADD.W	#-1,R14
116	ADD.W	R12,R12
117	ADDC.W	R13,R13
118	.global	__mspabi_slll
119__mspabi_slll:
120	CMP	#0,R14
121	JNZ	1b
122#ifdef __MSP430X_LARGE__
123	RETA
124#else
125	RET
126#endif
127
128/* Logical Left Shift - R8:R11 -> R12:R15
129   A 64-bit argument would normally be passed in R12:R15, but __mspabi_sllll has
130   special conventions, so the 64-bit value to shift is passed in R8:R11.
131   According to the MSPABI, the shift amount is a 64-bit value in R12:R15, but
132   we only use the low word in R12.  */
133
134	.section	.text.__mspabi_sllll
135	.global __mspabi_sllll
136__mspabi_sllll:
137	MOV R11, R15 ; Free up R11 first
138	MOV R12, R11 ; Save the shift amount in R11
139	MOV R10, R14
140	MOV R9, R13
141	MOV R8, R12
142	CMP #0,R11
143	JNZ 1f
144#ifdef __MSP430X_LARGE__
145	RETA
146#else
147	RET
148#endif
1491:
150	RLA R12
151	RLC R13
152	RLC R14
153	RLC R15
154	ADD #-1,R11
155	JNZ 1b
156#ifdef __MSP430X_LARGE__
157	RETA
158#else
159	RET
160#endif
161