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