| 1 |
dnl Loongarch mpn_sub_n |
| 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', `$a0') |
| 37 |
define(`ap', `$a1') |
| 38 |
define(`bp', `$a2') |
| 39 |
define(`n', `$a3') |
| 40 |
|
| 41 |
define(`i', `$a7') |
| 42 |
|
| 43 |
ASM_START() |
| 44 |
PROLOGUE(mpn_sub_n) |
| 45 |
srli.d i, n, 2 |
| 46 |
move $t8, $zero |
| 47 |
|
| 48 |
andi $t0, n, 1 |
| 49 |
andi $t1, n, 2 |
| 50 |
bnez $t0, L(bx1) |
| 51 |
L(bx0): beqz $t1, L(b0) |
| 52 |
L(b10): addi.d bp, bp, -16 |
| 53 |
addi.d ap, ap, -16 |
| 54 |
addi.d rp, rp, -16 |
| 55 |
b L(b2) |
| 56 |
L(bx1): bnez $t1, L(b11) |
| 57 |
L(b01): addi.d bp, bp, -24 |
| 58 |
addi.d ap, ap, -24 |
| 59 |
addi.d rp, rp, -24 |
| 60 |
b L(b1) |
| 61 |
L(b11): addi.d bp, bp, -8 |
| 62 |
addi.d ap, ap, -8 |
| 63 |
addi.d rp, rp, -8 |
| 64 |
b L(b3) |
| 65 |
|
| 66 |
L(top): addi.d bp, bp, 32 |
| 67 |
addi.d ap, ap, 32 |
| 68 |
addi.d rp, rp, 32 |
| 69 |
L(b0): addi.d i, i, -1 |
| 70 |
ld.d $t4, bp, 0 |
| 71 |
ld.d $t0, ap, 0 |
| 72 |
sltu $a4, $t0, $t4 |
| 73 |
sub.d $t0, $t0, $t4 |
| 74 |
sltu $a5, $t0, $t8 C 0 |
| 75 |
sub.d $t0, $t0, $t8 C 0 |
| 76 |
or $t8, $a4, $a5 C 1 |
| 77 |
st.d $t0, rp, 0 |
| 78 |
L(b3): ld.d $t5, bp, 8 |
| 79 |
ld.d $t1, ap, 8 |
| 80 |
sltu $a4, $t1, $t5 |
| 81 |
sub.d $t1, $t1, $t5 |
| 82 |
sltu $a5, $t1, $t8 C 2 |
| 83 |
sub.d $t1, $t1, $t8 C 2 |
| 84 |
or $t8, $a4, $a5 C 3 |
| 85 |
st.d $t1, rp, 8 |
| 86 |
L(b2): ld.d $t4, bp, 16 |
| 87 |
ld.d $t0, ap, 16 |
| 88 |
sltu $a4, $t0, $t4 |
| 89 |
sub.d $t0, $t0, $t4 |
| 90 |
sltu $a5, $t0, $t8 C 4 |
| 91 |
sub.d $t0, $t0, $t8 C 4 |
| 92 |
or $t8, $a4, $a5 C 5 |
| 93 |
st.d $t0, rp, 16 |
| 94 |
L(b1): ld.d $t5, bp, 24 |
| 95 |
ld.d $t1, ap, 24 |
| 96 |
sltu $a4, $t1, $t5 |
| 97 |
sub.d $t1, $t1, $t5 |
| 98 |
sltu $a5, $t1, $t8 C 6 |
| 99 |
sub.d $t1, $t1, $t8 C 6 |
| 100 |
or $t8, $a4, $a5 C 7 |
| 101 |
st.d $t1, rp, 24 |
| 102 |
bnez i, L(top) |
| 103 |
|
| 104 |
move $a0, $t8 |
| 105 |
jr $r1 |
| 106 |
EPILOGUE() |