xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/arm/bdiv_dbm1c.asm (revision 41f3ac3e09f0c1c4d8b911b4c8a1d6450bd14f46)
1dnl  ARM mpn_bdiv_dbm1c.
2
3dnl  Copyright 2008, 2011, 2012 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6dnl
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of either:
9dnl
10dnl    * the GNU Lesser General Public License as published by the Free
11dnl      Software Foundation; either version 3 of the License, or (at your
12dnl      option) any later version.
13dnl
14dnl  or
15dnl
16dnl    * the GNU General Public License as published by the Free Software
17dnl      Foundation; either version 2 of the License, or (at your option) any
18dnl      later version.
19dnl
20dnl  or both in parallel, as here.
21dnl
22dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25dnl  for more details.
26dnl
27dnl  You should have received copies of the GNU General Public License and the
28dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29dnl  see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33C	     cycles/limb
34C StrongARM	 ?
35C XScale	 ?
36C Cortex-A7	 ?
37C Cortex-A8	 ?
38C Cortex-A9	 4.25
39C Cortex-A15	 2.5
40
41C TODO
42C  * Try using umlal or umaal.
43C  * Try using ldm/stm.
44
45define(`qp',	  `r0')
46define(`up',	  `r1')
47define(`n',	  `r2')
48define(`bd',	  `r3')
49define(`cy',	  `sp,#0')
50
51ASM_START()
52	TEXT
53	ALIGN(16)
54PROLOGUE(mpn_bdiv_dbm1c)
55	push	{r4, r5, r6, r7, r8}
56	ldr	r4, [up], #4
57	ldr	r5, [sp, #20]
58	ands	r12, n, #3
59	beq	L(fi0)
60	cmp	r12, #2
61	bcc	L(fi1)
62	beq	L(fi2)
63
64L(fi3):	umull	r8, r12, r4, bd
65	ldr	r4, [up], #4
66	b	L(lo3)
67
68L(fi0):	umull	r6, r7, r4, bd
69	ldr	r4, [up], #4
70	b	L(lo0)
71
72L(fi1):	subs	n, n, #1
73	umull	r8, r12, r4, bd
74	bls	L(wd1)
75	ldr	r4, [up], #4
76	b	L(lo1)
77
78L(fi2):	umull	r6, r7, r4, bd
79	ldr	r4, [up], #4
80	b	L(lo2)
81
82L(top):	ldr	r4, [up], #4
83	subs	r5, r5, r6
84	str	r5, [qp], #4
85	sbc	r5, r5, r7
86L(lo1):	umull	r6, r7, r4, bd
87	ldr	r4, [up], #4
88	subs	r5, r5, r8
89	str	r5, [qp], #4
90	sbc	r5, r5, r12
91L(lo0):	umull	r8, r12, r4, bd
92	ldr	r4, [up], #4
93	subs	r5, r5, r6
94	str	r5, [qp], #4
95	sbc	r5, r5, r7
96L(lo3):	umull	r6, r7, r4, bd
97	ldr	r4, [up], #4
98	subs	r5, r5, r8
99	str	r5, [qp], #4
100	sbc	r5, r5, r12
101L(lo2):	subs	n, n, #4
102	umull	r8, r12, r4, bd
103	bhi	L(top)
104
105L(wd2):	subs	r5, r5, r6
106	str	r5, [qp], #4
107	sbc	r5, r5, r7
108L(wd1):	subs	r5, r5, r8
109	str	r5, [qp]
110	sbc	r0, r5, r12
111	pop	{r4, r5, r6, r7, r8}
112	return	lr
113EPILOGUE()
114