| 1 |
dnl Loongarch mpn_addlshC_n/mpn_sublshC_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 |
|
| 36 |
define(`rp',`$a0') |
| 37 |
define(`ap',`$a1') |
| 38 |
define(`bp',`$a2') |
| 39 |
define(`n', `$a3') |
| 40 |
|
| 41 |
define(`i', `$a4') |
| 42 |
|
| 43 |
|
| 44 |
ASM_START() |
| 45 |
PROLOGUE(func) |
| 46 |
srli.d i, n, 2 |
| 47 |
move $a5, $zero |
| 48 |
move $t7, $zero |
| 49 |
|
| 50 |
andi $t0, n, 1 |
| 51 |
andi $t1, n, 2 |
| 52 |
bnez $t0, L(bx1) |
| 53 |
L(bx0): beqz $t1, L(b0) |
| 54 |
L(b10): addi.d bp, bp, -16 |
| 55 |
addi.d ap, ap, -16 |
| 56 |
addi.d rp, rp, -16 |
| 57 |
b L(b2) |
| 58 |
L(bx1): bnez $t1, L(b11) |
| 59 |
L(b01): addi.d bp, bp, -24 |
| 60 |
addi.d ap, ap, -24 |
| 61 |
addi.d rp, rp, -24 |
| 62 |
b L(b1) |
| 63 |
L(b11): addi.d bp, bp, -8 |
| 64 |
addi.d ap, ap, -8 |
| 65 |
addi.d rp, rp, -8 |
| 66 |
b L(b3) |
| 67 |
|
| 68 |
L(top): addi.d bp, bp, 32 |
| 69 |
addi.d ap, ap, 32 |
| 70 |
addi.d rp, rp, 32 |
| 71 |
L(b0): addi.d i, i, -1 |
| 72 |
ld.d $t0, bp, 0 |
| 73 |
alsl.d $t6, $t0, $t7, LSH |
| 74 |
ld.d $t2, ap, 0 |
| 75 |
ADDSUB $t4, $t2, $t6 |
| 76 |
CARRY( $a6, $t4, $t2, $t6) |
| 77 |
srli.d $t7, $t0, RSH |
| 78 |
ADDSUB $t5, $t4, $a5 |
| 79 |
CARRY( $a5, $t5, $t4, $a5) |
| 80 |
st.d $t5, rp, 0 |
| 81 |
or $a5, $a5, $a6 |
| 82 |
L(b3): ld.d $t0, bp, 8 |
| 83 |
alsl.d $t6, $t0, $t7, LSH |
| 84 |
ld.d $t2, ap, 8 |
| 85 |
ADDSUB $t4, $t2, $t6 |
| 86 |
CARRY( $a6, $t4, $t2, $t6) |
| 87 |
srli.d $t7, $t0, RSH |
| 88 |
ADDSUB $t5, $t4, $a5 |
| 89 |
CARRY( $a5, $t5, $t4, $a5) |
| 90 |
st.d $t5, rp, 8 |
| 91 |
or $a5, $a5, $a6 |
| 92 |
L(b2): ld.d $t0, bp, 16 |
| 93 |
alsl.d $t6, $t0, $t7, LSH |
| 94 |
ld.d $t2, ap, 16 |
| 95 |
ADDSUB $t4, $t2, $t6 |
| 96 |
CARRY( $a6, $t4, $t2, $t6) |
| 97 |
srli.d $t7, $t0, RSH |
| 98 |
ADDSUB $t5, $t4, $a5 |
| 99 |
CARRY( $a5, $t5, $t4, $a5) |
| 100 |
st.d $t5, rp, 16 |
| 101 |
or $a5, $a5, $a6 |
| 102 |
L(b1): ld.d $t0, bp, 24 |
| 103 |
alsl.d $t6, $t0, $t7, LSH |
| 104 |
ld.d $t2, ap, 24 |
| 105 |
ADDSUB $t4, $t2, $t6 |
| 106 |
CARRY( $a6, $t4, $t2, $t6) |
| 107 |
srli.d $t7, $t0, RSH |
| 108 |
ADDSUB $t5, $t4, $a5 |
| 109 |
CARRY( $a5, $t5, $t4, $a5) |
| 110 |
st.d $t5, rp, 24 |
| 111 |
or $a5, $a5, $a6 |
| 112 |
bnez i, L(top) |
| 113 |
|
| 114 |
L(end): add.d $a0, $a5, $t7 |
| 115 |
jr $r1 |
| 116 |
EPILOGUE() |