1dnl ARM mpn_submul_1. 2 3dnl Copyright 2012, 2013 Free Software Foundation, Inc. 4 5dnl This file is part of the GNU MP Library. 6dnl 7dnl The GNU MP Library is free software; you can redistribute it and/or modify 8dnl it under the terms of either: 9dnl 10dnl * the GNU Lesser General Public License as published by the Free 11dnl Software Foundation; either version 3 of the License, or (at your 12dnl option) any later version. 13dnl 14dnl or 15dnl 16dnl * the GNU General Public License as published by the Free Software 17dnl Foundation; either version 2 of the License, or (at your option) any 18dnl later version. 19dnl 20dnl or both in parallel, as here. 21dnl 22dnl The GNU MP Library is distributed in the hope that it will be useful, but 23dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 24dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25dnl for more details. 26dnl 27dnl You should have received copies of the GNU General Public License and the 28dnl GNU Lesser General Public License along with the GNU MP Library. If not, 29dnl see https://www.gnu.org/licenses/. 30 31include(`../config.m4') 32 33C cycles/limb 34C StrongARM: - 35C XScale - 36C Cortex-A7 ? 37C Cortex-A8 ? 38C Cortex-A9 3.75 39C Cortex-A15 4.0 40 41C This loop complements U on the fly, 42C U' = B^n - 1 - U 43C and then uses that 44C R - U*v = R + U'*v + v - B^n v 45 46C TODO 47C * Micro-optimise feed-in code. 48C * Optimise for n=1,2 by delaying register saving. 49C * Try using ldm/stm. 50 51define(`rp',`r0') 52define(`up',`r1') 53define(`n', `r2') 54define(`v0',`r3') 55 56ASM_START() 57PROLOGUE(mpn_submul_1) 58 stmfd sp!, { r4, r5, r6, r7 } 59 60 ands r6, n, #3 61 mov r12, v0 62 beq L(fi0) 63 cmp r6, #2 64 bcc L(fi1) 65 beq L(fi2) 66 67L(fi3): ldr r4, [up], #12 68 mvn r4, r4 69 ldr r6, [rp, #0] 70 ldr r5, [up, #-8] 71 b L(lo3) 72 73L(fi0): ldr r5, [up], #16 74 mvn r5, r5 75 ldr r7, [rp], #4 76 ldr r4, [up, #-12] 77 b L(lo0) 78 79L(fi1): ldr r4, [up], #4 80 mvn r4, r4 81 ldr r6, [rp], #8 82 subs n, n, #1 83 beq L(1) 84 ldr r5, [up] 85 b L(lo1) 86 87L(fi2): ldr r5, [up], #8 88 mvn r5, r5 89 ldr r7, [rp], #12 90 ldr r4, [up, #-4] 91 b L(lo2) 92 93 ALIGN(16) 94L(top): ldr r6, [rp, #-8] 95 ldr r5, [up] 96 str r7, [rp, #-12] 97L(lo1): umaal r6, r12, r4, v0 98 add up, up, #16 99 mvn r5, r5 100 ldr r7, [rp, #-4] 101 ldr r4, [up, #-12] 102 str r6, [rp, #-8] 103L(lo0): umaal r7, r12, r5, v0 104 mvn r4, r4 105 ldr r6, [rp, #0] 106 ldr r5, [up, #-8] 107 str r7, [rp, #-4] 108L(lo3): umaal r6, r12, r4, v0 109 mvn r5, r5 110 ldr r7, [rp, #4] 111 ldr r4, [up, #-4] 112 str r6, [rp], #16 113L(lo2): umaal r7, r12, r5, v0 114 mvn r4, r4 115 subs n, n, #4 116 bhi L(top) 117 118 ldr r6, [rp, #-8] 119 str r7, [rp, #-12] 120L(1): umaal r6, r12, r4, v0 121 str r6, [rp, #-8] 122 sub r0, v0, r12 123 ldmfd sp!, { r4, r5, r6, r7 } 124 bx lr 125EPILOGUE() 126