Debian Codegraph @

mpn/loongarch/64/rshift.asm

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