Debian Codegraph @

mpn/riscv/64/rshift.asm

raw
1 dnl RISC-V/64 mpn_rshift
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_rshift)
47 mv rp, rp_arg
48 sub tnc, x0, cnt
49 srli i, n, 2
50
51 ld t0, 0(ap)
52 sll a0, t0, tnc
53
54 andi t6, n, 1
55 andi a5, n, 2
56 bnez t6, L(bx1)
57
58 srl t3, t0, cnt
59 ld t0, 8(ap)
60 addi i, i, -1
61 bnez a5, L(b10)
62 addi rp, rp, -16
63 j L(b0)
64 L(b10): addi ap, ap, 16
65 bge i, x0, L(b2)
66 L(eq2): sll t4, t0, tnc
67 srl t2, t0, cnt
68 or t4, t3, t4
69 sd t4, (rp)
70 sd t2, 8(rp)
71 ret
72
73 L(bx1): srl t2, t0, cnt
74 bnez a5, L(b11)
75 bnez i, L(gt1)
76 sd t2, (rp)
77 ret
78 L(gt1): ld t0, 8(ap)
79 addi ap, ap, 8
80 addi rp, rp, -8
81 addi i, i, -1
82 j L(b1)
83 L(b11): ld t0, 8(ap)
84 addi ap, ap, -8
85 addi rp, rp, -24
86 j L(b3)
87
88 L(top): addi ap, ap, 32
89 addi rp, rp, 32
90 addi i, i, -1
91 L(b2): sll t4, t0, tnc
92 srl t2, t0, cnt
93 ld t0, 0(ap)
94 or t4, t3, t4
95 sd t4, 0(rp)
96 L(b1): sll t4, t0, tnc
97 srl t3, t0, cnt
98 ld t0, 8(ap)
99 or t4, t2, t4
100 sd t4, 8(rp)
101 L(b0): sll t4, t0, tnc
102 srl t2, t0, cnt
103 ld t0, 16(ap)
104 or t4, t3, t4
105 sd t4, 16(rp)
106 L(b3): sll t4, t0, tnc
107 srl t3, t0, cnt
108 ld t0, 24(ap)
109 or t4, t2, t4
110 sd t4, 24(rp)
111 bnez i, L(top)
112
113 L(end): sll t4, t0, tnc
114 srl t2, t0, cnt
115 or t4, t3, t4
116 sd t4, 32(rp)
117 sd t2, 40(rp)
118 ret
119 EPILOGUE()