github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/arm/v6/dive_1.asm (about) 1 dnl ARM v6 mpn_divexact_1 2 3 dnl Contributed to the GNU project by Torbjörn Granlund. 4 5 dnl Copyright 2012, 2013 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 cycles/limb 36 C norm unorm modexact_1c_odd 37 C StrongARM - - 38 C XScale - - 39 C Cortex-A7 ? ? 40 C Cortex-A8 ? ? 41 C Cortex-A9 9 10 9 42 C Cortex-A15 7 7 7 43 44 C Architecture requirements: 45 C v5 - 46 C v5t clz 47 C v5te - 48 C v6 umaal 49 C v6t2 - 50 C v7a - 51 52 define(`rp', `r0') 53 define(`up', `r1') 54 define(`n', `r2') 55 define(`d', `r3') 56 57 define(`cy', `r7') 58 define(`cnt', `r6') 59 define(`tnc', `r10') 60 61 ASM_START() 62 PROLOGUE(mpn_divexact_1) 63 push {r4,r5,r6,r7,r8,r9} 64 65 tst d, #1 66 67 rsb r4, d, #0 68 and r4, r4, d 69 clz r4, r4 70 rsb cnt, r4, #31 C count_trailing_zeros 71 mov d, d, lsr cnt 72 73 C binvert limb 74 LEA( r4, binvert_limb_table) 75 and r12, d, #254 76 ldrb r4, [r4, r12, lsr #1] 77 mul r12, r4, r4 78 mul r12, d, r12 79 rsb r12, r12, r4, lsl #1 80 mul r4, r12, r12 81 mul r4, d, r4 82 rsb r4, r4, r12, lsl #1 C r4 = inverse 83 84 ldr r5, [up], #4 C up[0] 85 mov cy, #0 86 rsb r8, r4, #0 C r8 = -inverse 87 beq L(unnorm) 88 89 L(norm): 90 subs n, n, #1 91 mul r5, r5, r4 92 beq L(end) 93 94 ALIGN(16) 95 L(top): ldr r9, [up], #4 96 mov r12, #0 97 str r5, [rp], #4 98 umaal r12, cy, r5, d 99 mul r5, r9, r4 100 mla r5, cy, r8, r5 101 subs n, n, #1 102 bne L(top) 103 104 L(end): str r5, [rp] 105 pop {r4,r5,r6,r7,r8,r9} 106 bx r14 107 108 L(unnorm): 109 push {r10,r11} 110 rsb tnc, cnt, #32 111 mov r11, r5, lsr cnt 112 subs n, n, #1 113 beq L(edx) 114 115 ldr r12, [up], #4 116 orr r9, r11, r12, lsl tnc 117 mov r11, r12, lsr cnt 118 mul r5, r9, r4 119 subs n, n, #1 120 beq L(edu) 121 122 ALIGN(16) 123 L(tpu): ldr r12, [up], #4 124 orr r9, r11, r12, lsl tnc 125 mov r11, r12, lsr cnt 126 mov r12, #0 127 str r5, [rp], #4 128 umaal r12, cy, r5, d 129 mul r5, r9, r4 130 mla r5, cy, r8, r5 131 subs n, n, #1 132 bne L(tpu) 133 134 L(edu): str r5, [rp], #4 135 mov r12, #0 136 umaal r12, cy, r5, d 137 mul r5, r11, r4 138 mla r5, cy, r8, r5 139 str r5, [rp] 140 pop {r10,r11} 141 pop {r4,r5,r6,r7,r8,r9} 142 bx r14 143 144 L(edx): mul r5, r11, r4 145 str r5, [rp] 146 pop {r10,r11} 147 pop {r4,r5,r6,r7,r8,r9} 148 bx r14 149 EPILOGUE()