| 1 |
dnl Loongarch mpn_add_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_arg',`$r4') |
| 37 |
define(`ap', `$r5') |
| 38 |
define(`bp', `$r6') |
| 39 |
define(`n', `$r7') |
| 40 |
|
| 41 |
define(`rp', `$r8') |
| 42 |
|
| 43 |
ASM_START() |
| 44 |
PROLOGUE(mpn_add_n) |
| 45 |
alsl.d rp, n, rp_arg, 3 |
| 46 |
alsl.d ap, n, ap, 3 |
| 47 |
alsl.d bp, n, bp, 3 |
| 48 |
sub.d n, $r0, n |
| 49 |
slli.d n, n, 3 |
| 50 |
or $r4, $r0, $r0 |
| 51 |
|
| 52 |
L(top): ldx.d $r14, ap, n |
| 53 |
ldx.d $r13, bp, n |
| 54 |
add.d $r12, $r14, $r13 |
| 55 |
sltu $r15, $r12, $r13 C cy0 |
| 56 |
add.d $r14, $r12, $r4 |
| 57 |
sltu $r16, $r14, $r4 C cy1 set iff r4=1 & r12=111...1 |
| 58 |
stx.d $r14, rp, n |
| 59 |
addi.d n, n, 8 |
| 60 |
or $r4, $r15, $r16 |
| 61 |
bnez n, L(top) |
| 62 |
|
| 63 |
jr $r1 |
| 64 |
EPILOGUE() |