| 1 |
dnl RISC-V/64 mpn_copyi |
| 2 |
|
| 3 |
dnl Copyright 2023 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
dnl This file is part of the GNU MP Library. |
| 6 |
dnl |
| 7 |
dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 8 |
dnl it under the terms of either: |
| 9 |
dnl |
| 10 |
dnl * the GNU Lesser General Public License as published by the Free |
| 11 |
dnl Software Foundation; either version 3 of the License, or (at your |
| 12 |
dnl option) any later version. |
| 13 |
dnl |
| 14 |
dnl or |
| 15 |
dnl |
| 16 |
dnl * the GNU General Public License as published by the Free Software |
| 17 |
dnl Foundation; either version 2 of the License, or (at your option) any |
| 18 |
dnl later version. |
| 19 |
dnl |
| 20 |
dnl or both in parallel, as here. |
| 21 |
dnl |
| 22 |
dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 23 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 24 |
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 25 |
dnl for more details. |
| 26 |
dnl |
| 27 |
dnl You should have received copies of the GNU General Public License and the |
| 28 |
dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 29 |
dnl see https://www.gnu.org/licenses/. |
| 30 |
|
| 31 |
include(`../config.m4') |
| 32 |
|
| 33 |
C INPUT PARAMETERS |
| 34 |
define(`rp', `a0') |
| 35 |
define(`ap', `a1') |
| 36 |
define(`n', `a2') |
| 37 |
|
| 38 |
define(`i', `a6') |
| 39 |
|
| 40 |
ASM_START() |
| 41 |
PROLOGUE(mpn_copyi) |
| 42 |
srli i, n, 2 |
| 43 |
|
| 44 |
andi t0, n, 1 |
| 45 |
andi t1, n, 2 |
| 46 |
bnez t0, L(bx1) |
| 47 |
L(bx0): beqz n, L(ret) |
| 48 |
ld t0, 0(ap) |
| 49 |
bnez t1, L(b10) |
| 50 |
L(b00): addi rp, rp, -8 |
| 51 |
addi i, i, -1 |
| 52 |
j L(b0) |
| 53 |
L(b10): addi ap, ap, -16 |
| 54 |
addi rp, rp, -24 |
| 55 |
j L(b2) |
| 56 |
L(bx1): ld t2, 0(ap) |
| 57 |
bnez t1, L(b11) |
| 58 |
beqz i, L(1) |
| 59 |
addi ap, ap, 8 |
| 60 |
addi i, i, -1 |
| 61 |
j L(b1) |
| 62 |
L(1): sd t2, 0(rp) |
| 63 |
ret |
| 64 |
L(b11): addi ap, ap, -8 |
| 65 |
addi rp, rp, -16 |
| 66 |
j L(b3) |
| 67 |
|
| 68 |
ALIGN( 16) |
| 69 |
L(top): addi ap, ap, 32 |
| 70 |
addi rp, rp, 32 |
| 71 |
addi i, i, -1 |
| 72 |
L(b1): ld t0, 0(ap) |
| 73 |
sd t2, 0(rp) |
| 74 |
L(b0): ld t2, 8(ap) |
| 75 |
sd t0, 8(rp) |
| 76 |
L(b3): ld t0, 16(ap) |
| 77 |
sd t2, 16(rp) |
| 78 |
L(b2): ld t2, 24(ap) |
| 79 |
sd t0, 24(rp) |
| 80 |
bnez i, L(top) |
| 81 |
|
| 82 |
L(end): sd t2, 32(rp) |
| 83 |
L(ret): ret |
| 84 |
EPILOGUE() |