xref: /openbmc/linux/arch/arm64/lib/tishift.S (revision e2ad626f)
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
8#include <asm/assembler.h>
9
10SYM_FUNC_START(__ashlti3)
11	cbz	x2, 1f
12	mov	x3, #64
13	sub	x3, x3, x2
14	cmp	x3, #0
15	b.le	2f
16	lsl	x1, x1, x2
17	lsr	x3, x0, x3
18	lsl	x2, x0, x2
19	orr	x1, x1, x3
20	mov	x0, x2
211:
22	ret
232:
24	neg	w1, w3
25	mov	x2, #0
26	lsl	x1, x0, x1
27	mov	x0, x2
28	ret
29SYM_FUNC_END(__ashlti3)
30EXPORT_SYMBOL(__ashlti3)
31
32SYM_FUNC_START(__ashrti3)
33	cbz	x2, 1f
34	mov	x3, #64
35	sub	x3, x3, x2
36	cmp	x3, #0
37	b.le	2f
38	lsr	x0, x0, x2
39	lsl	x3, x1, x3
40	asr	x2, x1, x2
41	orr	x0, x0, x3
42	mov	x1, x2
431:
44	ret
452:
46	neg	w0, w3
47	asr	x2, x1, #63
48	asr	x0, x1, x0
49	mov	x1, x2
50	ret
51SYM_FUNC_END(__ashrti3)
52EXPORT_SYMBOL(__ashrti3)
53
54SYM_FUNC_START(__lshrti3)
55	cbz	x2, 1f
56	mov	x3, #64
57	sub	x3, x3, x2
58	cmp	x3, #0
59	b.le	2f
60	lsr	x0, x0, x2
61	lsl	x3, x1, x3
62	lsr	x2, x1, x2
63	orr	x0, x0, x3
64	mov	x1, x2
651:
66	ret
672:
68	neg	w0, w3
69	mov	x2, #0
70	lsr	x0, x1, x0
71	mov	x1, x2
72	ret
73SYM_FUNC_END(__lshrti3)
74EXPORT_SYMBOL(__lshrti3)
75