Debian Codegraph @

mpn/riscv/64/lshift.asm

raw
1 dnl RISC-V/64 mpn_lshift
2
3 dnl Contributed to the GNU project by Torbjorn Granlund.
4
5 dnl Copyright 2023 Free Software Foundation, Inc.
6
7 dnl This file is part of the GNU MP Library.
8 dnl
9 dnl The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl it under the terms of either:
11 dnl
12 dnl * the GNU Lesser General Public License as published by the Free
13 dnl Software Foundation; either version 3 of the License, or (at your
14 dnl option) any later version.
15 dnl
16 dnl or
17 dnl
18 dnl * the GNU General Public License as published by the Free Software
19 dnl Foundation; either version 2 of the License, or (at your option) any
20 dnl later version.
21 dnl
22 dnl or both in parallel, as here.
23 dnl
24 dnl The GNU MP Library is distributed in the hope that it will be useful, but
25 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 dnl for more details.
28 dnl
29 dnl You should have received copies of the GNU General Public License and the
30 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
31 dnl see https://www.gnu.org/licenses/.
32
33 include(`../config.m4')
34
35 C INPUT PARAMETERS
36 define(`rp_arg',`a0')
37 define(`ap', `a1')
38 define(`n', `a2')
39 define(`cnt', `a3')
40
41 define(`rp', `a4')
42 define(`tnc', `t5')
43 define(`i', `a7')
44
45 ASM_START()
46 PROLOGUE(mpn_lshift)
47 slli t0, n, 3
48 add ap, ap, t0
49 add rp, rp_arg, t0
50 sub tnc, x0, cnt
51 srli i, n, 2
52
53 ld t0, -8(ap)
54 srl a0, t0, tnc
55
56 andi t6, n, 1
57 andi a5, n, 2
58 bnez t6, L(bx1)
59
60 sll t3, t0, cnt
61 ld t0, -16(ap)
62 addi i, i, -1
63 bnez a5, L(b10)
64 addi rp, rp, 16
65 j L(b0)
66 L(b10): addi ap, ap, -16
67 bge i, x0, L(b2)
68 L(eq2): srl t4, t0, tnc
69 sll t2, t0, cnt
70 or t4, t3, t4
71 sd t4, -8(rp)
72 sd t2, -16(rp)
73 ret
74
75 L(bx1): sll t2, t0, cnt
76 bnez a5, L(b11)
77 bnez i, L(gt1)
78 sd t2, -8(rp)
79 ret
80 L(gt1): ld t0, -16(ap)
81 addi ap, ap, -8
82 addi rp, rp, 8
83 addi i, i, -1
84 j L(b1)
85 L(b11): ld t0, -16(ap)
86 addi ap, ap, 8
87 addi rp, rp, 24
88 j L(b3)
89
90 L(top): addi ap, ap, -32
91 addi rp, rp, -32
92 addi i, i, -1
93 L(b2): srl t4, t0, tnc
94 sll t2, t0, cnt
95 ld t0, -8(ap)
96 or t4, t3, t4
97 sd t4, -8(rp)
98 L(b1): srl t4, t0, tnc
99 sll t3, t0, cnt
100 ld t0, -16(ap)
101 or t4, t2, t4
102 sd t4, -16(rp)
103 L(b0): srl t4, t0, tnc
104 sll t2, t0, cnt
105 ld t0, -24(ap)
106 or t4, t3, t4
107 sd t4, -24(rp)
108 L(b3): srl t4, t0, tnc
109 sll t3, t0, cnt
110 ld t0, -32(ap)
111 or t4, t2, t4
112 sd t4, -32(rp)
113 bnez i, L(top)
114
115 L(end): srl t4, t0, tnc
116 sll t2, t0, cnt
117 or t4, t3, t4
118 sd t4, -40(rp)
119 sd t2, -48(rp)
120 ret
121 EPILOGUE()