1dnl  ARM v6 mpn_modexact_1c_odd
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          9
41C Cortex-A15         7
42
43C Architecture requirements:
44C v5      -
45C v5t     -
46C v5te    smulbb
47C v6      umaal
48C v6t2    -
49C v7a     -
50
51define(`up', `r0')
52define(`n',  `r1')
53define(`d',  `r2')
54define(`cy', `r3')
55
56          .protected          binvert_limb_table
57ASM_START()
58PROLOGUE(mpn_modexact_1c_odd)
59          stmfd     sp!, {r4, r5, r6, r7}
60
61          LEA(      r4, binvert_limb_table)
62
63          ldr       r6, [up], #4                  C up[0]
64
65          and       r12, d, #254
66          ldrb      r4, [r4, r12, lsr #1]
67          smulbb    r12, r4, r4
68          mul       r12, d, r12
69          rsb       r12, r12, r4, asl #1
70          mul       r4, r12, r12
71          mul       r4, d, r4
72          rsb       r4, r4, r12, asl #1 C r4 = inverse
73
74          subs      n, n, #1
75          sub       r6, r6, cy
76          mul       r6, r6, r4
77          beq       L(end)
78
79          rsb       r5, r4, #0                    C r5 = -inverse
80
81L(top):   ldr       r7, [up], #4
82          mov       r12, #0
83          umaal     r12, cy, r6, d
84          mul       r6, r7, r4
85          mla       r6, cy, r5, r6
86          subs      n, n, #1
87          bne       L(top)
88
89L(end):   mov       r12, #0
90          umaal     r12, cy, r6, d
91          mov       r0, cy
92
93          ldmfd     sp!, {r4, r5, r6, r7}
94          bx        r14
95EPILOGUE()
96