From 11da511c784eca003deb90c23570f0873954e0de Mon Sep 17 00:00:00 2001 From: Duncan Wilkie Date: Sat, 18 Nov 2023 06:11:09 -0600 Subject: Initial commit. --- gmp-6.3.0/mpn/riscv/64/aors_n.asm | 135 +++++++++++++++++++++++++++++ gmp-6.3.0/mpn/riscv/64/aorsmul_1.asm | 75 +++++++++++++++++ gmp-6.3.0/mpn/riscv/64/cnd_aors_n.asm | 97 +++++++++++++++++++++ gmp-6.3.0/mpn/riscv/64/copyd.asm | 87 +++++++++++++++++++ gmp-6.3.0/mpn/riscv/64/copyi.asm | 84 +++++++++++++++++++ gmp-6.3.0/mpn/riscv/64/lshift.asm | 121 ++++++++++++++++++++++++++ gmp-6.3.0/mpn/riscv/64/mul_1.asm | 58 +++++++++++++ gmp-6.3.0/mpn/riscv/64/rshift.asm | 119 ++++++++++++++++++++++++++ gmp-6.3.0/mpn/riscv/64/sec_tabselect.asm | 140 +++++++++++++++++++++++++++++++ 9 files changed, 916 insertions(+) create mode 100644 gmp-6.3.0/mpn/riscv/64/aors_n.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/aorsmul_1.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/cnd_aors_n.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/copyd.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/copyi.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/lshift.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/mul_1.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/rshift.asm create mode 100644 gmp-6.3.0/mpn/riscv/64/sec_tabselect.asm (limited to 'gmp-6.3.0/mpn/riscv') diff --git a/gmp-6.3.0/mpn/riscv/64/aors_n.asm b/gmp-6.3.0/mpn/riscv/64/aors_n.asm new file mode 100644 index 0000000..d267037 --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/aors_n.asm @@ -0,0 +1,135 @@ +dnl RISC-V/64 mpn_add_n and mpn_sub_n. + +dnl Copyright 2016 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp', `a0') +define(`ap', `a1') +define(`bp', `a2') +define(`n', `a3') + +define(`i', `a6') + +ifdef(`OPERATION_add_n',` + define(`ADDSUB', `add') + define(`CMPCY', `sltu $1, $2, $3') + define(`func', `mpn_add_n') +') +ifdef(`OPERATION_sub_n',` + define(`ADDSUB', `sub') + define(`CMPCY', `sltu $1, $3, $4') + define(`func', `mpn_sub_n') +') + +MULFUNC_PROLOGUE(mpn_add_n mpn_sub_n) + +ASM_START() +PROLOGUE(func) + li t6, 0 + srli i, n, 2 + + ld a4, 0(ap) + ld a5, 0(bp) + + andi t0, n, 1 + andi t1, n, 2 + bnez t0, L(bx1) +L(bx0): bnez t1, L(b10) +L(b00): addi rp, rp, -8 + addi i, i, -1 + j L(b0) +L(b10): addi bp, bp, -16 + addi ap, ap, -16 + addi rp, rp, -24 + j L(b2) +L(bx1): bnez t1, L(b11) +L(b01): beqz i, L(1) + addi bp, bp, 8 + addi ap, ap, 8 + addi i, i, -1 + j L(b1) +L(1): ADDSUB t0, a4, a5 + sd t0, 0(rp) + CMPCY( a0, t0, a4, a5) + ret +L(b11): addi bp, bp, -8 + addi ap, ap, -8 + addi rp, rp, -16 + j L(b3) + + ALIGN( 16) +L(top): addi bp, bp, 32 + addi ap, ap, 32 + addi rp, rp, 32 + addi i, i, -1 +L(b1): ADDSUB t0, a4, a5 + CMPCY( t2, t0, a4, a5) + ld a4, 0(ap) + ld a5, 0(bp) + ADDSUB t4, t0, t6 + CMPCY( t3, t4, t0, t6) + sd t4, 0(rp) + or t6, t2, t3 + +L(b0): ADDSUB t1, a4, a5 + CMPCY( t2, t1, a4, a5) + ld a4, 8(ap) + ld a5, 8(bp) + ADDSUB t4, t1, t6 + CMPCY( t3, t4, t1, t6) + sd t4, 8(rp) + or t6, t2, t3 +L(b3): ADDSUB t0, a4, a5 + CMPCY( t2, t0, a4, a5) + ld a4, 16(ap) + ld a5, 16(bp) + ADDSUB t4, t0, t6 + CMPCY( t3, t4, t0, t6) + sd t4, 16(rp) + or t6, t2, t3 +L(b2): ADDSUB t1, a4, a5 + CMPCY( t2, t1, a4, a5) + ld a4, 24(ap) + ld a5, 24(bp) + ADDSUB t4, t1, t6 + CMPCY( t3, t4, t1, t6) + sd t4, 24(rp) + or t6, t2, t3 + bne i, x0, L(top) + +L(end): ADDSUB t0, a4, a5 + CMPCY( t2, t0, a4, a5) + ADDSUB t4, t0, t6 + CMPCY( t3, t4, t0, t6) + sd t4, 32(rp) + or a0, t2, t3 + ret +EPILOGUE() diff --git a/gmp-6.3.0/mpn/riscv/64/aorsmul_1.asm b/gmp-6.3.0/mpn/riscv/64/aorsmul_1.asm new file mode 100644 index 0000000..1125a9f --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/aorsmul_1.asm @@ -0,0 +1,75 @@ +dnl RISC-V/64 mpn_addmul_1 and mpn_submul_1. + +dnl Copyright 2016 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp', `a0') +define(`up', `a1') +define(`n', `a2') +define(`v0', `a3') + +ifdef(`OPERATION_addmul_1',` + define(`ADDSUB', `add') + define(`CMPCY', `sltu $1, $2, $3') + define(`func', `mpn_addmul_1') +') +ifdef(`OPERATION_submul_1',` + define(`ADDSUB', `sub') + define(`CMPCY', `sltu $1, $3, $2') + define(`func', `mpn_submul_1') +') + +MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1) + +ASM_START() +PROLOGUE(func) + li a6, 0 + +L(top): ld a7, 0(up) + addi up, up, 8 C bookkeeping + ld a4, 0(rp) + addi rp, rp, 8 C bookkeeping + mul a5, a7, v0 + addi n, n, -1 C bookkeeping + mulhu a7, a7, v0 + ADDSUB a5, a4, a5 + ADDSUB a6, a5, a6 C cycle 0, 3, ... + CMPCY( a4, a5, a4) + add a4, a4, a7 + CMPCY( a5, a6, a5) C cycle 1, 4, ... + sd a6, -8(rp) + add a6, a4, a5 C cycle 2, 5, ... + bne n, x0, L(top) C bookkeeping + +L(end): mv a0, a6 + ret +EPILOGUE() +ASM_END() diff --git a/gmp-6.3.0/mpn/riscv/64/cnd_aors_n.asm b/gmp-6.3.0/mpn/riscv/64/cnd_aors_n.asm new file mode 100644 index 0000000..b3d5651 --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/cnd_aors_n.asm @@ -0,0 +1,97 @@ +dnl RISC-V/64 mpn_cnd_add_n and mpn_cnd_sub_n. + +dnl Copyright 2016, 2023 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`cnd', `a0') +define(`rp', `a1') +define(`up', `a2') +define(`vp', `a3') +define(`n', `a4') + +define(`mask', `t5') + +ifdef(`OPERATION_cnd_add_n',` + define(`ADDSUB', `add') + define(`CMPCY', `sltu $1, $2, $3') + define(`func', `mpn_cnd_add_n') +') +ifdef(`OPERATION_cnd_sub_n',` + define(`ADDSUB', `sub') + define(`CMPCY', `sltu $1, $3, $4') + define(`func', `mpn_cnd_sub_n') +') + +MULFUNC_PROLOGUE(mpn_cnd_add_n mpn_cnd_sub_n) + +ASM_START() +PROLOGUE(func) + li t6, 0 + + sltiu mask, cnd, 1 + addi mask, mask, -1 + + andi t0, n, 1 + beq t0, x0, L(top) + addi up, up, 8 + addi vp, vp, -8 + addi rp, rp, -8 + addi n, n, -1 + j L(mid) + +L(top): ld a0, 0(up) + ld a6, 0(vp) + addi n, n, -2 C bookkeeping + addi up, up, 16 C bookkeeping + and a6, a6, mask + ADDSUB t0, a0, a6 + CMPCY( t2, t0, a0, a6) + ADDSUB t4, t0, t6 C cycle 3, 9, ... + CMPCY( t3, t4, t0, t6) C cycle 4, 10, ... + sd t4, 0(rp) + add t6, t2, t3 C cycle 5, 11, ... +L(mid): ld a5, -8(up) + ld a7, 8(vp) + addi vp, vp, 16 C bookkeeping + addi rp, rp, 16 C bookkeeping + and a7, a7, mask + ADDSUB t1, a5, a7 + CMPCY( t2, t1, a5, a7) + ADDSUB t4, t1, t6 C cycle 0, 6, ... + CMPCY( t3, t4, t1, t6) C cycle 1, 7, ... + sd t4, -8(rp) + add t6, t2, t3 C cycle 2, 8, ... + bne n, x0, L(top) C bookkeeping + +L(end): mv a0, t6 + ret +EPILOGUE() +ASM_END() diff --git a/gmp-6.3.0/mpn/riscv/64/copyd.asm b/gmp-6.3.0/mpn/riscv/64/copyd.asm new file mode 100644 index 0000000..42557f8 --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/copyd.asm @@ -0,0 +1,87 @@ +dnl RISC-V/64 mpn_copyd + +dnl Copyright 2023 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp', `a0') +define(`ap', `a1') +define(`n', `a2') + +define(`i', `a6') + +ASM_START() +PROLOGUE(mpn_copyd) + slli t0, n, 3 + add ap, ap, t0 + add rp, rp, t0 + srli i, n, 2 + + andi t0, n, 1 + andi t1, n, 2 + bnez t0, L(bx1) +L(bx0): beqz n, L(ret) + ld t0, -8(ap) + bnez t1, L(b10) +L(b00): addi rp, rp, 8 + addi i, i, -1 + j L(b0) +L(b10): addi ap, ap, 16 + addi rp, rp, 24 + j L(b2) +L(bx1): ld t2, -8(ap) + bnez t1, L(b11) + beqz i, L(1) + addi ap, ap, -8 + addi i, i, -1 + j L(b1) +L(1): sd t2, -8(rp) + ret +L(b11): addi ap, ap, 8 + addi rp, rp, 16 + j L(b3) + + ALIGN( 16) +L(top): addi ap, ap, -32 + addi rp, rp, -32 + addi i, i, -1 +L(b1): ld t0, -8(ap) + sd t2, -8(rp) +L(b0): ld t2, -16(ap) + sd t0, -16(rp) +L(b3): ld t0, -24(ap) + sd t2, -24(rp) +L(b2): ld t2, -32(ap) + sd t0, -32(rp) + bnez i, L(top) + +L(end): sd t2, -40(rp) +L(ret): ret +EPILOGUE() diff --git a/gmp-6.3.0/mpn/riscv/64/copyi.asm b/gmp-6.3.0/mpn/riscv/64/copyi.asm new file mode 100644 index 0000000..7a0b7fa --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/copyi.asm @@ -0,0 +1,84 @@ +dnl RISC-V/64 mpn_copyi + +dnl Copyright 2023 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp', `a0') +define(`ap', `a1') +define(`n', `a2') + +define(`i', `a6') + +ASM_START() +PROLOGUE(mpn_copyi) + srli i, n, 2 + + andi t0, n, 1 + andi t1, n, 2 + bnez t0, L(bx1) +L(bx0): beqz n, L(ret) + ld t0, 0(ap) + bnez t1, L(b10) +L(b00): addi rp, rp, -8 + addi i, i, -1 + j L(b0) +L(b10): addi ap, ap, -16 + addi rp, rp, -24 + j L(b2) +L(bx1): ld t2, 0(ap) + bnez t1, L(b11) + beqz i, L(1) + addi ap, ap, 8 + addi i, i, -1 + j L(b1) +L(1): sd t2, 0(rp) + ret +L(b11): addi ap, ap, -8 + addi rp, rp, -16 + j L(b3) + + ALIGN( 16) +L(top): addi ap, ap, 32 + addi rp, rp, 32 + addi i, i, -1 +L(b1): ld t0, 0(ap) + sd t2, 0(rp) +L(b0): ld t2, 8(ap) + sd t0, 8(rp) +L(b3): ld t0, 16(ap) + sd t2, 16(rp) +L(b2): ld t2, 24(ap) + sd t0, 24(rp) + bnez i, L(top) + +L(end): sd t2, 32(rp) +L(ret): ret +EPILOGUE() diff --git a/gmp-6.3.0/mpn/riscv/64/lshift.asm b/gmp-6.3.0/mpn/riscv/64/lshift.asm new file mode 100644 index 0000000..413063f --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/lshift.asm @@ -0,0 +1,121 @@ +dnl RISC-V/64 mpn_lshift + +dnl Contributed to the GNU project by Torbjorn Granlund. + +dnl Copyright 2023 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp_arg',`a0') +define(`ap', `a1') +define(`n', `a2') +define(`cnt', `a3') + +define(`rp', `a4') +define(`tnc', `t5') +define(`i', `a7') + +ASM_START() +PROLOGUE(mpn_lshift) + slli t0, n, 3 + add ap, ap, t0 + add rp, rp_arg, t0 + sub tnc, x0, cnt + srli i, n, 2 + + ld t0, -8(ap) + srl a0, t0, tnc + + andi t6, n, 1 + andi a5, n, 2 + bnez t6, L(bx1) + + sll t3, t0, cnt + ld t0, -16(ap) + addi i, i, -1 + bnez a5, L(b10) + addi rp, rp, 16 + j L(b0) +L(b10): addi ap, ap, -16 + bge i, x0, L(b2) +L(eq2): srl t4, t0, tnc + sll t2, t0, cnt + or t4, t3, t4 + sd t4, -8(rp) + sd t2, -16(rp) + ret + +L(bx1): sll t2, t0, cnt + bnez a5, L(b11) + bnez i, L(gt1) + sd t2, -8(rp) + ret +L(gt1): ld t0, -16(ap) + addi ap, ap, -8 + addi rp, rp, 8 + addi i, i, -1 + j L(b1) +L(b11): ld t0, -16(ap) + addi ap, ap, 8 + addi rp, rp, 24 + j L(b3) + +L(top): addi ap, ap, -32 + addi rp, rp, -32 + addi i, i, -1 +L(b2): srl t4, t0, tnc + sll t2, t0, cnt + ld t0, -8(ap) + or t4, t3, t4 + sd t4, -8(rp) +L(b1): srl t4, t0, tnc + sll t3, t0, cnt + ld t0, -16(ap) + or t4, t2, t4 + sd t4, -16(rp) +L(b0): srl t4, t0, tnc + sll t2, t0, cnt + ld t0, -24(ap) + or t4, t3, t4 + sd t4, -24(rp) +L(b3): srl t4, t0, tnc + sll t3, t0, cnt + ld t0, -32(ap) + or t4, t2, t4 + sd t4, -32(rp) + bnez i, L(top) + +L(end): srl t4, t0, tnc + sll t2, t0, cnt + or t4, t3, t4 + sd t4, -40(rp) + sd t2, -48(rp) + ret +EPILOGUE() diff --git a/gmp-6.3.0/mpn/riscv/64/mul_1.asm b/gmp-6.3.0/mpn/riscv/64/mul_1.asm new file mode 100644 index 0000000..e35eaa9 --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/mul_1.asm @@ -0,0 +1,58 @@ +dnl RISC-V/64 mpn_mul_1. + +dnl Copyright 2016 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp', `a0') +define(`up', `a1') +define(`n', `a2') +define(`v0', `a3') + +ASM_START() +PROLOGUE(mpn_mul_1) + li a6, 0 + +L(top): ld a7, 0(up) + addi up, up, 8 C bookkeeping + addi rp, rp, 8 C bookkeeping + mul a5, a7, v0 + addi n, n, -1 C bookkeeping + mulhu a7, a7, v0 + add a6, a5, a6 C cycle 0, 3, ... + sltu a5, a6, a5 C cycle 1, 4, ... + sd a6, -8(rp) + add a6, a7, a5 C cycle 2, 5, ... + bne n, x0, L(top) C bookkeeping + +L(end): mv a0, a6 + ret +EPILOGUE() +ASM_END() diff --git a/gmp-6.3.0/mpn/riscv/64/rshift.asm b/gmp-6.3.0/mpn/riscv/64/rshift.asm new file mode 100644 index 0000000..0069765 --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/rshift.asm @@ -0,0 +1,119 @@ +dnl RISC-V/64 mpn_rshift + +dnl Contributed to the GNU project by Torbjorn Granlund. + +dnl Copyright 2023 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp_arg',`a0') +define(`ap', `a1') +define(`n', `a2') +define(`cnt', `a3') + +define(`rp', `a4') +define(`tnc', `t5') +define(`i', `a7') + +ASM_START() +PROLOGUE(mpn_rshift) + mv rp, rp_arg + sub tnc, x0, cnt + srli i, n, 2 + + ld t0, 0(ap) + sll a0, t0, tnc + + andi t6, n, 1 + andi a5, n, 2 + bnez t6, L(bx1) + + srl t3, t0, cnt + ld t0, 8(ap) + addi i, i, -1 + bnez a5, L(b10) + addi rp, rp, -16 + j L(b0) +L(b10): addi ap, ap, 16 + bge i, x0, L(b2) +L(eq2): sll t4, t0, tnc + srl t2, t0, cnt + or t4, t3, t4 + sd t4, (rp) + sd t2, 8(rp) + ret + +L(bx1): srl t2, t0, cnt + bnez a5, L(b11) + bnez i, L(gt1) + sd t2, (rp) + ret +L(gt1): ld t0, 8(ap) + addi ap, ap, 8 + addi rp, rp, -8 + addi i, i, -1 + j L(b1) +L(b11): ld t0, 8(ap) + addi ap, ap, -8 + addi rp, rp, -24 + j L(b3) + +L(top): addi ap, ap, 32 + addi rp, rp, 32 + addi i, i, -1 +L(b2): sll t4, t0, tnc + srl t2, t0, cnt + ld t0, 0(ap) + or t4, t3, t4 + sd t4, 0(rp) +L(b1): sll t4, t0, tnc + srl t3, t0, cnt + ld t0, 8(ap) + or t4, t2, t4 + sd t4, 8(rp) +L(b0): sll t4, t0, tnc + srl t2, t0, cnt + ld t0, 16(ap) + or t4, t3, t4 + sd t4, 16(rp) +L(b3): sll t4, t0, tnc + srl t3, t0, cnt + ld t0, 24(ap) + or t4, t2, t4 + sd t4, 24(rp) + bnez i, L(top) + +L(end): sll t4, t0, tnc + srl t2, t0, cnt + or t4, t3, t4 + sd t4, 32(rp) + sd t2, 40(rp) + ret +EPILOGUE() diff --git a/gmp-6.3.0/mpn/riscv/64/sec_tabselect.asm b/gmp-6.3.0/mpn/riscv/64/sec_tabselect.asm new file mode 100644 index 0000000..35211fd --- /dev/null +++ b/gmp-6.3.0/mpn/riscv/64/sec_tabselect.asm @@ -0,0 +1,140 @@ +dnl RISC-V/64 mpn_sec_tabselect + +dnl Copyright 2016 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C INPUT PARAMETERS +define(`rp', `a0') +define(`tp', `a1') +define(`n', `a2') +define(`nents', `a3') +define(`which', `a4') + +define(`i', `a6') +define(`j', `a7') +define(`mask', `s0') +define(`k', `nents') +define(`one', `s3') + +ASM_START() +PROLOGUE(mpn_sec_tabselect) + addi sp,sp,-32 + sd s0,24(sp) + sd s1,16(sp) + sd s2,8(sp) + sd s3,0(sp) + + addi j, n, -4 + slli n, n, 3 + li one, 1 + + sub k, which, nents + blt j, zero, L(outer_end) +L(outer_top): + mv s2, tp + li t0, 0 + li t1, 0 + li t2, 0 + li t3, 0 + addi j, j, -4 + mv i, which + + ALIGN(16) +L(top): ld t4, 0(tp) + ld t5, 8(tp) + sltu mask, i, one + addi i, i, -1 + neg mask, mask + ld t6, 16(tp) + ld a5, 24(tp) + and t4, mask, t4 + and t5, mask, t5 + or t0, t4, t0 + or t1, t5, t1 + and t6, mask, t6 + and a5, mask, a5 + or t2, t6, t2 + or t3, a5, t3 + add tp, tp, n + bne i, k, L(top) + + sd t0, 0(rp) + sd t1, 8(rp) + sd t2, 16(rp) + sd t3, 24(rp) + add tp, s2, 32 + add rp, rp, 32 + bge j, zero, L(outer_top) +L(outer_end): + andi t0, n, 2*8 + beq t0, zero, L(b0x) +L(b1x): mv s2, tp + li t0, 0 + li t1, 0 + mv i, which + ALIGN(16) +L(tp2): ld t4, 0(tp) + ld t5, 8(tp) + sltu mask, i, one + neg mask, mask + addi i, i, -1 + and t4, mask, t4 + and t5, mask, t5 + or t0, t4, t0 + or t1, t5, t1 + add tp, tp, n + bne i, k, L(tp2) + sd t0, 0(rp) + sd t1, 8(rp) + addi tp, s2, 16 + addi rp, rp, 16 + +L(b0x): andi t0, n, 1*8 + beq t0, zero, L(b00) +L(b01): li t0, 0 + mv i, which + ALIGN(16) +L(tp1): ld t4, 0(tp) + sltu mask, i, one + neg mask, mask + addi i, i, -1 + and t4, mask, t4 + or t0, t4, t0 + add tp, tp, n + bne i, k, L(tp1) + sd t0, 0(rp) + +L(b00): ld s0,24(sp) + ld s1,16(sp) + ld s2,8(sp) + ld s3,0(sp) + addi sp,sp,32 + jr ra +EPILOGUE() -- cgit v1.2.3