1 dnl ARM64 mpn_mul_1 2 3 dnl Contributed to the GNU project by Torbjrn Granlund. 4 5 dnl Copyright 2013, 2015, 2017 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 cycles/limb 36 C Cortex-A53 7.5-8 37 C Cortex-A57 7 38 C Cortex-A72 39 C X-Gene 4 40 41 C TODO 42 C * Start first multiply earlier. 43 44 changecom(blah) 45 46 define(`rp', `x0') 47 define(`up', `x1') 48 define(`n', `x2') 49 define(`v0', `x3') 50 51 52 PROLOGUE(mpn_mul_1c) 53 adds xzr, xzr, xzr C clear cy flag 54 b L(com) 55 EPILOGUE() 56 57 PROLOGUE(mpn_mul_1) 58 adds x4, xzr, xzr C clear register and cy flag 59 L(com): lsr x18, n, #2 60 tbnz n, #0, L(bx1) 61 62 L(bx0): mov x11, x4 63 tbz n, #1, L(b00) 64 65 L(b10): ldp x4, x5, [up] 66 mul x8, x4, v0 67 umulh x10, x4, v0 68 cbz x18, L(2) 69 ldp x6, x7, [up,#16]! 70 mul x9, x5, v0 71 b L(mid)-8 72 73 L(2): mul x9, x5, v0 74 b L(2e) 75 76 L(bx1): ldr x7, [up],#8 77 mul x9, x7, v0 78 umulh x11, x7, v0 79 adds x9, x9, x4 80 str x9, [rp],#8 81 tbnz n, #1, L(b10) 82 83 L(b01): cbz x18, L(1) 84 85 L(b00): ldp x6, x7, [up] 86 mul x8, x6, v0 87 umulh x10, x6, v0 88 ldp x4, x5, [up,#16] 89 mul x9, x7, v0 90 adcs x12, x8, x11 91 umulh x11, x7, v0 92 add rp, rp, #16 93 sub x18, x18, #1 94 cbz x18, L(end) 95 96 ALIGN(16) 97 L(top): mul x8, x4, v0 98 ldp x6, x7, [up,#32]! 99 adcs x13, x9, x10 100 umulh x10, x4, v0 101 mul x9, x5, v0 102 stp x12, x13, [rp,#-16] 103 adcs x12, x8, x11 104 umulh x11, x5, v0 105 L(mid): mul x8, x6, v0 106 ldp x4, x5, [up,#16] 107 adcs x13, x9, x10 108 umulh x10, x6, v0 109 mul x9, x7, v0 110 stp x12, x13, [rp],#32 111 adcs x12, x8, x11 112 umulh x11, x7, v0 113 sub x18, x18, #1 114 cbnz x18, L(top) 115 116 L(end): mul x8, x4, v0 117 adcs x13, x9, x10 118 umulh x10, x4, v0 119 mul x9, x5, v0 120 stp x12, x13, [rp,#-16] 121 L(2e): adcs x12, x8, x11 122 umulh x11, x5, v0 123 adcs x13, x9, x10 124 stp x12, x13, [rp] 125 L(1): adc x0, x11, xzr 126 ret 127 EPILOGUE() 128