xref: /openbmc/linux/arch/arm64/lib/tishift.S (revision 6d99a79c)
1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 *
3 * Copyright (C) 2017-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4 */
5
6#include <linux/linkage.h>
7
8ENTRY(__ashlti3)
9	cbz	x2, 1f
10	mov	x3, #64
11	sub	x3, x3, x2
12	cmp	x3, #0
13	b.le	2f
14	lsl	x1, x1, x2
15	lsr	x3, x0, x3
16	lsl	x2, x0, x2
17	orr	x1, x1, x3
18	mov	x0, x2
191:
20	ret
212:
22	neg	w1, w3
23	mov	x2, #0
24	lsl	x1, x0, x1
25	mov	x0, x2
26	ret
27ENDPROC(__ashlti3)
28
29ENTRY(__ashrti3)
30	cbz	x2, 1f
31	mov	x3, #64
32	sub	x3, x3, x2
33	cmp	x3, #0
34	b.le	2f
35	lsr	x0, x0, x2
36	lsl	x3, x1, x3
37	asr	x2, x1, x2
38	orr	x0, x0, x3
39	mov	x1, x2
401:
41	ret
422:
43	neg	w0, w3
44	asr	x2, x1, #63
45	asr	x0, x1, x0
46	mov	x1, x2
47	ret
48ENDPROC(__ashrti3)
49
50ENTRY(__lshrti3)
51	cbz	x2, 1f
52	mov	x3, #64
53	sub	x3, x3, x2
54	cmp	x3, #0
55	b.le	2f
56	lsr	x0, x0, x2
57	lsl	x3, x1, x3
58	lsr	x2, x1, x2
59	orr	x0, x0, x3
60	mov	x1, x2
611:
62	ret
632:
64	neg	w0, w3
65	mov	x2, #0
66	lsr	x0, x1, x0
67	mov	x1, x2
68	ret
69ENDPROC(__lshrti3)
70