beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / arm / mode1o.asm
blob5e0f78fc8f58a2332e47d23af93ef208e931cfc4
1 dnl ARM mpn_modexact_1c_odd
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright 2012 Free Software Foundation, Inc.
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/.
33 include(`../config.m4')
35 C cycles/limb
36 C StrongARM ?
37 C XScale ?
38 C Cortex-A7 ?
39 C Cortex-A8 ?
40 C Cortex-A9 10
41 C Cortex-A15 9
43 C Architecture requirements:
44 C v5 -
45 C v5t -
46 C v5te -
47 C v6 -
48 C v6t2 -
49 C v7a -
51 define(`up', `r0')
52 define(`n', `r1')
53 define(`d', `r2')
54 define(`cy', `r3')
56 .protected binvert_limb_table
57 ASM_START()
58 PROLOGUE(mpn_modexact_1c_odd)
59 stmfd sp!, {r4, r5}
61 LEA( r4, binvert_limb_table)
63 ldr r5, [up], #4 C up[0]
65 and r12, d, #254
66 ldrb r4, [r4, r12, lsr #1]
67 mul 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
74 subs n, n, #1 C set carry as side-effect
75 beq L(end)
77 L(top): sbcs cy, r5, cy
78 ldr r5, [up], #4
79 sub n, n, #1
80 mul r12, r4, cy
81 tst n, n
82 umull r12, cy, d, r12
83 bne L(top)
85 L(end): sbcs cy, r5, cy
86 mul r12, r4, cy
87 umull r12, r0, d, r12
88 addcc r0, r0, #1
90 ldmfd sp!, {r4, r5}
91 bx r14
92 EPILOGUE()