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