xref: /openbmc/linux/arch/riscv/lib/tishift.S (revision 50acfb2b)
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
8ENTRY(__lshrti3)
9	beqz	a2, .L1
10	li	a5,64
11	sub	a5,a5,a2
12	addi	sp,sp,-16
13	sext.w	a4,a5
14	blez	a5, .L2
15	sext.w	a2,a2
16	sll	a4,a1,a4
17	srl	a0,a0,a2
18	srl	a1,a1,a2
19	or	a0,a0,a4
20	sd	a1,8(sp)
21	sd	a0,0(sp)
22	ld	a0,0(sp)
23	ld	a1,8(sp)
24	addi	sp,sp,16
25	ret
26.L1:
27	ret
28.L2:
29	negw	a4,a4
30	srl	a1,a1,a4
31	sd	a1,0(sp)
32	sd	zero,8(sp)
33	ld	a0,0(sp)
34	ld	a1,8(sp)
35	addi	sp,sp,16
36	ret
37ENDPROC(__lshrti3)
38