beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / arm / v6 / dive_1.asm
blob92de81473f91bbf1215576e7b37ebaf61a4f54f3
1 dnl ARM v6 mpn_divexact_1
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright 2012, 2013 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 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
44 C Architecture requirements:
45 C v5 -
46 C v5t clz
47 C v5te -
48 C v6 umaal
49 C v6t2 -
50 C v7a -
52 define(`rp', `r0')
53 define(`up', `r1')
54 define(`n', `r2')
55 define(`d', `r3')
57 define(`cy', `r7')
58 define(`cnt', `r6')
59 define(`tnc', `r10')
61 ASM_START()
62 PROLOGUE(mpn_divexact_1)
63 push {r4,r5,r6,r7,r8,r9}
65 tst d, #1
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
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
84 ldr r5, [up], #4 C up[0]
85 mov cy, #0
86 rsb r8, r4, #0 C r8 = -inverse
87 beq L(unnorm)
89 L(norm):
90 subs n, n, #1
91 mul r5, r5, r4
92 beq L(end)
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)
104 L(end): str r5, [rp]
105 pop {r4,r5,r6,r7,r8,r9}
106 bx r14
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)
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)
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)
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
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()