summaryrefslogtreecommitdiffstats
path: root/arch/riscv/lib/tishift.S
diff options
context:
space:
mode:
authorAlex Guo <xfguo@jlsemi.com>2018-07-29 01:14:47 +0000
committerPalmer Dabbelt <palmer@sifive.com>2018-08-13 08:31:30 -0700
commita89757daf25cfe5320a5f40773271d86e2456c10 (patch)
treef9b2fde77d6093253ae8b73be93530486e6c8781 /arch/riscv/lib/tishift.S
parent4938c79bd0f5f3650c8c2cd4cdc972f0a6962ce4 (diff)
downloadlinux-stable-a89757daf25cfe5320a5f40773271d86e2456c10.tar.gz
linux-stable-a89757daf25cfe5320a5f40773271d86e2456c10.tar.bz2
linux-stable-a89757daf25cfe5320a5f40773271d86e2456c10.zip
RISC-V: implement __lshrti3.
Signed-off-by: Alex Guo <xfguo@jlsemi.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Diffstat (limited to 'arch/riscv/lib/tishift.S')
-rw-r--r--arch/riscv/lib/tishift.S42
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/riscv/lib/tishift.S b/arch/riscv/lib/tishift.S
new file mode 100644
index 000000000000..69abb1277234
--- /dev/null
+++ b/arch/riscv/lib/tishift.S
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+ .globl __lshrti3
+__lshrti3:
+ beqz a2, .L1
+ li a5,64
+ sub a5,a5,a2
+ addi sp,sp,-16
+ sext.w a4,a5
+ blez a5, .L2
+ sext.w a2,a2
+ sll a4,a1,a4
+ srl a0,a0,a2
+ srl a1,a1,a2
+ or a0,a0,a4
+ sd a1,8(sp)
+ sd a0,0(sp)
+ ld a0,0(sp)
+ ld a1,8(sp)
+ addi sp,sp,16
+ ret
+.L1:
+ ret
+.L2:
+ negw a4,a4
+ srl a1,a1,a4
+ sd a1,0(sp)
+ sd zero,8(sp)
+ ld a0,0(sp)
+ ld a1,8(sp)
+ addi sp,sp,16
+ ret