1dnl ARM mpn_mod_1_1p 2 3dnl Contributed to the GNU project by Torbj��rn Granlund. 4 5dnl Copyright 2012 Free Software Foundation, Inc. 6 7dnl This file is part of the GNU MP Library. 8dnl 9dnl The GNU MP Library is free software; you can redistribute it and/or modify 10dnl it under the terms of either: 11dnl 12dnl * the GNU Lesser General Public License as published by the Free 13dnl Software Foundation; either version 3 of the License, or (at your 14dnl option) any later version. 15dnl 16dnl or 17dnl 18dnl * the GNU General Public License as published by the Free Software 19dnl Foundation; either version 2 of the License, or (at your option) any 20dnl later version. 21dnl 22dnl or both in parallel, as here. 23dnl 24dnl The GNU MP Library is distributed in the hope that it will be useful, but 25dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 26dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27dnl for more details. 28dnl 29dnl You should have received copies of the GNU General Public License and the 30dnl GNU Lesser General Public License along with the GNU MP Library. If not, 31dnl see https://www.gnu.org/licenses/. 32 33include(`../config.m4') 34 35C cycles/limb 36C StrongARM - 37C XScale ? 38C Cortex-A7 ? 39C Cortex-A8 ? 40C Cortex-A9 7 41C Cortex-A15 6 42 43define(`ap', `r0') 44define(`n', `r1') 45define(`d', `r2') 46define(`cps',`r3') 47 48ASM_START() 49PROLOGUE(mpn_mod_1_1p) 50 push {r4-r10} 51 add r0, r0, r1, asl #2 52 ldr r5, [r0, #-4]! 53 ldr r12, [r0, #-4]! 54 subs r1, r1, #2 55 ble L(4) 56 ldr r8, [r3, #12] 57 mov r4, r12 58 mov r10, r5 59 umull r7, r5, r10, r8 60 sub r1, r1, #1 61 b L(mid) 62 63L(top): adds r12, r6, r7 64 adcs r10, r4, r5 65 sub r1, r1, #1 66 mov r6, #0 67 movcs r6, r8 68 umull r7, r5, r10, r8 69 adds r4, r12, r6 70 subcs r4, r4, r2 71L(mid): ldr r6, [r0, #-4]! 72 teq r1, #0 73 bne L(top) 74 75 adds r12, r6, r7 76 adcs r5, r4, r5 77 subcs r5, r5, r2 78L(4): ldr r1, [r3, #4] 79 cmp r1, #0 80 beq L(7) 81 ldr r4, [r3, #8] 82 umull r0, r6, r5, r4 83 adds r12, r0, r12 84 addcs r6, r6, #1 85 rsb r0, r1, #32 86 mov r0, r12, lsr r0 87 orr r5, r0, r6, asl r1 88 mov r12, r12, asl r1 89 b L(8) 90L(7): cmp r5, r2 91 subcs r5, r5, r2 92L(8): ldr r0, [r3, #0] 93 umull r4, r3, r5, r0 94 add r5, r5, #1 95 adds r0, r4, r12 96 adc r5, r3, r5 97 mul r5, r2, r5 98 sub r12, r12, r5 99 cmp r12, r0 100 addhi r12, r12, r2 101 cmp r2, r12 102 subls r12, r12, r2 103 mov r0, r12, lsr r1 104 pop {r4-r10} 105 bx r14 106EPILOGUE() 107 108PROLOGUE(mpn_mod_1_1p_cps) 109 stmfd sp!, {r4, r5, r6, r14} 110 mov r5, r0 111 clz r4, r1 112 mov r0, r1, asl r4 113 rsb r6, r0, #0 114 bl mpn_invert_limb 115 str r0, [r5, #0] 116 str r4, [r5, #4] 117 cmp r4, #0 118 beq L(2) 119 rsb r1, r4, #32 120 mov r3, #1 121 mov r3, r3, asl r4 122 orr r3, r3, r0, lsr r1 123 mul r3, r6, r3 124 mov r4, r3, lsr r4 125 str r4, [r5, #8] 126L(2): mul r0, r6, r0 127 str r0, [r5, #12] 128 ldmfd sp!, {r4, r5, r6, pc} 129EPILOGUE() 130