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