xref: /openbmc/linux/arch/arm64/lib/tishift.S (revision 2d972b6a)
1/*
2 * Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/linkage.h>
18
19ENTRY(__ashlti3)
20	cbz	x2, 1f
21	mov	x3, #64
22	sub	x3, x3, x2
23	cmp	x3, #0
24	b.le	2f
25	lsl	x1, x1, x2
26	lsr	x3, x0, x3
27	lsl	x2, x0, x2
28	orr	x1, x1, x3
29	mov	x0, x2
301:
31	ret
322:
33	neg	w1, w3
34	mov	x2, #0
35	lsl	x1, x0, x1
36	mov	x0, x2
37	ret
38ENDPROC(__ashlti3)
39
40ENTRY(__ashrti3)
41	cbz	x2, 1f
42	mov	x3, #64
43	sub	x3, x3, x2
44	cmp	x3, #0
45	b.le	2f
46	lsr	x0, x0, x2
47	lsl	x3, x1, x3
48	asr	x2, x1, x2
49	orr	x0, x0, x3
50	mov	x1, x2
511:
52	ret
532:
54	neg	w0, w3
55	asr	x2, x1, #63
56	asr	x0, x1, x0
57	mov	x1, x2
58	ret
59ENDPROC(__ashrti3)
60
61ENTRY(__lshrti3)
62	cbz	x2, 1f
63	mov	x3, #64
64	sub	x3, x3, x2
65	cmp	x3, #0
66	b.le	2f
67	lsr	x0, x0, x2
68	lsl	x3, x1, x3
69	lsr	x2, x1, x2
70	orr	x0, x0, x3
71	mov	x1, x2
721:
73	ret
742:
75	neg	w0, w3
76	mov	x2, #0
77	lsr	x0, x1, x0
78	mov	x1, x2
79	ret
80ENDPROC(__lshrti3)
81