xref: /linux/arch/sh/lib/lshrsi3.S (revision 0d3b051adbb72ed81956447d0d1e54d5943ee6f5)
1/* SPDX-License-Identifier: GPL-2.0+ WITH GCC-exception-2.0
2
3   Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4   2004, 2005, 2006
5   Free Software Foundation, Inc.
6*/
7
8!! libgcc routines for the Renesas / SuperH SH CPUs.
9!! Contributed by Steve Chamberlain.
10!! sac@cygnus.com
11
12!! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
13!! recoded in assembly by Toshiyasu Morita
14!! tm@netcom.com
15
16/* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
17   ELF local label prefixes by J"orn Rennecke
18   amylaar@cygnus.com  */
19
20!
21! __lshrsi3
22!
23! Entry:
24!
25! r4: Value to shift
26! r5: Shifts
27!
28! Exit:
29!
30! r0: Result
31!
32! Destroys:
33!
34! (none)
35!
36! __lshrsi3_r0
37!
38! Entry:
39!
40! r0: Value to shift
41! r5: Shifts
42!
43! Exit:
44!
45! r0: Result
46!
47! Destroys:
48!
49! (none)
50!
51	.global	__lshrsi3
52	.global	__lshrsi3_r0
53
54	.align	2
55__lshrsi3:
56	mov	r5,r0
57	.align	2
58__lshrsi3_r0:
59	and	#31,r0
60	mov.l	r4,@-r15
61	mov	r0,r4
62	mova	lshrsi3_table,r0
63	mov.b	@(r0,r4),r4
64	add	r4,r0
65	jmp	@r0
66	mov.l	@r15+,r0
67
68	.align	2
69lshrsi3_table:
70	.byte		lshrsi3_0-lshrsi3_table
71	.byte		lshrsi3_1-lshrsi3_table
72	.byte		lshrsi3_2-lshrsi3_table
73	.byte		lshrsi3_3-lshrsi3_table
74	.byte		lshrsi3_4-lshrsi3_table
75	.byte		lshrsi3_5-lshrsi3_table
76	.byte		lshrsi3_6-lshrsi3_table
77	.byte		lshrsi3_7-lshrsi3_table
78	.byte		lshrsi3_8-lshrsi3_table
79	.byte		lshrsi3_9-lshrsi3_table
80	.byte		lshrsi3_10-lshrsi3_table
81	.byte		lshrsi3_11-lshrsi3_table
82	.byte		lshrsi3_12-lshrsi3_table
83	.byte		lshrsi3_13-lshrsi3_table
84	.byte		lshrsi3_14-lshrsi3_table
85	.byte		lshrsi3_15-lshrsi3_table
86	.byte		lshrsi3_16-lshrsi3_table
87	.byte		lshrsi3_17-lshrsi3_table
88	.byte		lshrsi3_18-lshrsi3_table
89	.byte		lshrsi3_19-lshrsi3_table
90	.byte		lshrsi3_20-lshrsi3_table
91	.byte		lshrsi3_21-lshrsi3_table
92	.byte		lshrsi3_22-lshrsi3_table
93	.byte		lshrsi3_23-lshrsi3_table
94	.byte		lshrsi3_24-lshrsi3_table
95	.byte		lshrsi3_25-lshrsi3_table
96	.byte		lshrsi3_26-lshrsi3_table
97	.byte		lshrsi3_27-lshrsi3_table
98	.byte		lshrsi3_28-lshrsi3_table
99	.byte		lshrsi3_29-lshrsi3_table
100	.byte		lshrsi3_30-lshrsi3_table
101	.byte		lshrsi3_31-lshrsi3_table
102
103lshrsi3_6:
104	shlr2	r0
105lshrsi3_4:
106	shlr2	r0
107lshrsi3_2:
108	rts
109	shlr2	r0
110
111lshrsi3_7:
112	shlr2	r0
113lshrsi3_5:
114	shlr2	r0
115lshrsi3_3:
116	shlr2	r0
117lshrsi3_1:
118	rts
119	shlr	r0
120
121lshrsi3_14:
122	shlr2	r0
123lshrsi3_12:
124	shlr2	r0
125lshrsi3_10:
126	shlr2	r0
127lshrsi3_8:
128	rts
129	shlr8	r0
130
131lshrsi3_15:
132	shlr2	r0
133lshrsi3_13:
134	shlr2	r0
135lshrsi3_11:
136	shlr2	r0
137lshrsi3_9:
138	shlr8	r0
139	rts
140	shlr	r0
141
142lshrsi3_22:
143	shlr2	r0
144lshrsi3_20:
145	shlr2	r0
146lshrsi3_18:
147	shlr2	r0
148lshrsi3_16:
149	rts
150	shlr16	r0
151
152lshrsi3_23:
153	shlr2	r0
154lshrsi3_21:
155	shlr2	r0
156lshrsi3_19:
157	shlr2	r0
158lshrsi3_17:
159	shlr16	r0
160	rts
161	shlr	r0
162
163lshrsi3_30:
164	shlr2	r0
165lshrsi3_28:
166	shlr2	r0
167lshrsi3_26:
168	shlr2	r0
169lshrsi3_24:
170	shlr16	r0
171	rts
172	shlr8	r0
173
174lshrsi3_31:
175	shlr2	r0
176lshrsi3_29:
177	shlr2	r0
178lshrsi3_27:
179	shlr2	r0
180lshrsi3_25:
181	shlr16	r0
182	shlr8	r0
183	rts
184	shlr	r0
185
186lshrsi3_0:
187	rts
188	nop
189