| 1 |
dnl RISC-V/64 mpn_sec_tabselect |
| 2 |
|
| 3 |
dnl Copyright 2016 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(`tp', `a1') |
| 36 |
define(`n', `a2') |
| 37 |
define(`nents', `a3') |
| 38 |
define(`which', `a4') |
| 39 |
|
| 40 |
define(`i', `a6') |
| 41 |
define(`j', `a7') |
| 42 |
define(`mask', `s0') |
| 43 |
define(`k', `nents') |
| 44 |
define(`one', `s3') |
| 45 |
|
| 46 |
ASM_START() |
| 47 |
PROLOGUE(mpn_sec_tabselect) |
| 48 |
addi sp,sp,-32 |
| 49 |
sd s0,24(sp) |
| 50 |
sd s1,16(sp) |
| 51 |
sd s2,8(sp) |
| 52 |
sd s3,0(sp) |
| 53 |
|
| 54 |
addi j, n, -4 |
| 55 |
slli n, n, 3 |
| 56 |
li one, 1 |
| 57 |
|
| 58 |
sub k, which, nents |
| 59 |
blt j, zero, L(outer_end) |
| 60 |
L(outer_top): |
| 61 |
mv s2, tp |
| 62 |
li t0, 0 |
| 63 |
li t1, 0 |
| 64 |
li t2, 0 |
| 65 |
li t3, 0 |
| 66 |
addi j, j, -4 |
| 67 |
mv i, which |
| 68 |
|
| 69 |
ALIGN(16) |
| 70 |
L(top): ld t4, 0(tp) |
| 71 |
ld t5, 8(tp) |
| 72 |
sltu mask, i, one |
| 73 |
addi i, i, -1 |
| 74 |
neg mask, mask |
| 75 |
ld t6, 16(tp) |
| 76 |
ld a5, 24(tp) |
| 77 |
and t4, mask, t4 |
| 78 |
and t5, mask, t5 |
| 79 |
or t0, t4, t0 |
| 80 |
or t1, t5, t1 |
| 81 |
and t6, mask, t6 |
| 82 |
and a5, mask, a5 |
| 83 |
or t2, t6, t2 |
| 84 |
or t3, a5, t3 |
| 85 |
add tp, tp, n |
| 86 |
bne i, k, L(top) |
| 87 |
|
| 88 |
sd t0, 0(rp) |
| 89 |
sd t1, 8(rp) |
| 90 |
sd t2, 16(rp) |
| 91 |
sd t3, 24(rp) |
| 92 |
add tp, s2, 32 |
| 93 |
add rp, rp, 32 |
| 94 |
bge j, zero, L(outer_top) |
| 95 |
L(outer_end): |
| 96 |
andi t0, n, 2*8 |
| 97 |
beq t0, zero, L(b0x) |
| 98 |
L(b1x): mv s2, tp |
| 99 |
li t0, 0 |
| 100 |
li t1, 0 |
| 101 |
mv i, which |
| 102 |
ALIGN(16) |
| 103 |
L(tp2): ld t4, 0(tp) |
| 104 |
ld t5, 8(tp) |
| 105 |
sltu mask, i, one |
| 106 |
neg mask, mask |
| 107 |
addi i, i, -1 |
| 108 |
and t4, mask, t4 |
| 109 |
and t5, mask, t5 |
| 110 |
or t0, t4, t0 |
| 111 |
or t1, t5, t1 |
| 112 |
add tp, tp, n |
| 113 |
bne i, k, L(tp2) |
| 114 |
sd t0, 0(rp) |
| 115 |
sd t1, 8(rp) |
| 116 |
addi tp, s2, 16 |
| 117 |
addi rp, rp, 16 |
| 118 |
|
| 119 |
L(b0x): andi t0, n, 1*8 |
| 120 |
beq t0, zero, L(b00) |
| 121 |
L(b01): li t0, 0 |
| 122 |
mv i, which |
| 123 |
ALIGN(16) |
| 124 |
L(tp1): ld t4, 0(tp) |
| 125 |
sltu mask, i, one |
| 126 |
neg mask, mask |
| 127 |
addi i, i, -1 |
| 128 |
and t4, mask, t4 |
| 129 |
or t0, t4, t0 |
| 130 |
add tp, tp, n |
| 131 |
bne i, k, L(tp1) |
| 132 |
sd t0, 0(rp) |
| 133 |
|
| 134 |
L(b00): ld s0,24(sp) |
| 135 |
ld s1,16(sp) |
| 136 |
ld s2,8(sp) |
| 137 |
ld s3,0(sp) |
| 138 |
addi sp,sp,32 |
| 139 |
jr ra |
| 140 |
EPILOGUE() |