xref: /openbmc/linux/arch/riscv/lib/tishift.S (revision 25763b3c)
1/*
2 * Copyright (C) 2018 Free Software Foundation, Inc.
3 *
4 *   This program is free software; you can redistribute it and/or
5 *   modify it under the terms of the GNU General Public License
6 *   as published by the Free Software Foundation, version 2.
7 *
8 *   This program is distributed in the hope that it will be useful,
9 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *   GNU General Public License for more details.
12 */
13
14#include <linux/linkage.h>
15
16ENTRY(__lshrti3)
17	beqz	a2, .L1
18	li	a5,64
19	sub	a5,a5,a2
20	addi	sp,sp,-16
21	sext.w	a4,a5
22	blez	a5, .L2
23	sext.w	a2,a2
24	sll	a4,a1,a4
25	srl	a0,a0,a2
26	srl	a1,a1,a2
27	or	a0,a0,a4
28	sd	a1,8(sp)
29	sd	a0,0(sp)
30	ld	a0,0(sp)
31	ld	a1,8(sp)
32	addi	sp,sp,16
33	ret
34.L1:
35	ret
36.L2:
37	negw	a4,a4
38	srl	a1,a1,a4
39	sd	a1,0(sp)
40	sd	zero,8(sp)
41	ld	a0,0(sp)
42	ld	a1,8(sp)
43	addi	sp,sp,16
44	ret
45ENDPROC(__lshrti3)
46