1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2018 Free Software Foundation, Inc.
4 */
5
6#include <linux/linkage.h>
7#include <asm-generic/export.h>
8
9SYM_FUNC_START(__lshrti3)
10	beqz	a2, .L1
11	li	a5,64
12	sub	a5,a5,a2
13	sext.w	a4,a5
14	blez	a5, .L2
15	sext.w	a2,a2
16	srl	a0,a0,a2
17	sll	a4,a1,a4
18	srl	a2,a1,a2
19	or	a0,a0,a4
20	mv	a1,a2
21.L1:
22	ret
23.L2:
24	negw	a0,a4
25	li	a2,0
26	srl	a0,a1,a0
27	mv	a1,a2
28	ret
29SYM_FUNC_END(__lshrti3)
30EXPORT_SYMBOL(__lshrti3)
31
32SYM_FUNC_START(__ashrti3)
33	beqz	a2, .L3
34	li	a5,64
35	sub	a5,a5,a2
36	sext.w	a4,a5
37	blez	a5, .L4
38	sext.w	a2,a2
39	srl	a0,a0,a2
40	sll	a4,a1,a4
41	sra	a2,a1,a2
42	or	a0,a0,a4
43	mv	a1,a2
44.L3:
45	ret
46.L4:
47	negw	a0,a4
48	srai	a2,a1,0x3f
49	sra	a0,a1,a0
50	mv	a1,a2
51	ret
52SYM_FUNC_END(__ashrti3)
53EXPORT_SYMBOL(__ashrti3)
54
55SYM_FUNC_START(__ashlti3)
56	beqz	a2, .L5
57	li	a5,64
58	sub	a5,a5,a2
59	sext.w	a4,a5
60	blez	a5, .L6
61	sext.w	a2,a2
62	sll	a1,a1,a2
63	srl	a4,a0,a4
64	sll	a2,a0,a2
65	or	a1,a1,a4
66	mv	a0,a2
67.L5:
68	ret
69.L6:
70	negw	a1,a4
71	li	a2,0
72	sll	a1,a0,a1
73	mv	a0,a2
74	ret
75SYM_FUNC_END(__ashlti3)
76EXPORT_SYMBOL(__ashlti3)
77