1dnl  ARM64 mpn_bdiv_dbm1c.
2
3dnl  Copyright 2008, 2011, 2012, 2014 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 Cortex-A53	 8
35C Cortex-A57	 7
36C X-Gene	 4.25
37
38define(`qp',	  `x0')
39define(`up',	  `x1')
40define(`n',	  `x2')
41define(`bd',	  `x3')
42define(`cy',	  `x4')
43
44ASM_START()
45	TEXT
46	ALIGN(16)
47PROLOGUE(mpn_bdiv_dbm1c)
48	ldr	x5, [up], #8
49	ands	x6, n, #3
50	b.eq	L(fi0)
51	cmp	x6, #2
52	b.cc	L(fi1)
53	b.eq	L(fi2)
54
55L(fi3):	mul	x12, x5, bd
56	umulh	x13, x5, bd
57	ldr	x5, [up], #8
58	b	L(lo3)
59
60L(fi0):	mul	x10, x5, bd
61	umulh	x11, x5, bd
62	ldr	x5, [up], #8
63	b	L(lo0)
64
65L(fi1):	subs	n, n, #1
66	mul	x12, x5, bd
67	umulh	x13, x5, bd
68	b.ls	L(wd1)
69	ldr	x5, [up], #8
70	b	L(lo1)
71
72L(fi2):	mul	x10, x5, bd
73	umulh	x11, x5, bd
74	ldr	x5, [up], #8
75	b	L(lo2)
76
77L(top):	ldr	x5, [up], #8
78	subs	x4, x4, x10
79	str	x4, [qp], #8
80	sbc	x4, x4, x11
81L(lo1):	mul	x10, x5, bd
82	umulh	x11, x5, bd
83	ldr	x5, [up], #8
84	subs	x4, x4, x12
85	str	x4, [qp], #8
86	sbc	x4, x4, x13
87L(lo0):	mul	x12, x5, bd
88	umulh	x13, x5, bd
89	ldr	x5, [up], #8
90	subs	x4, x4, x10
91	str	x4, [qp], #8
92	sbc	x4, x4, x11
93L(lo3):	mul	x10, x5, bd
94	umulh	x11, x5, bd
95	ldr	x5, [up], #8
96	subs	x4, x4, x12
97	str	x4, [qp], #8
98	sbc	x4, x4, x13
99L(lo2):	subs	n, n, #4
100	mul	x12, x5, bd
101	umulh	x13, x5, bd
102	b.hi	L(top)
103
104L(wd2):	subs	x4, x4, x10
105	str	x4, [qp], #8
106	sbc	x4, x4, x11
107L(wd1):	subs	x4, x4, x12
108	str	x4, [qp]
109	sbc	x0, x4, x13
110	ret
111EPILOGUE()
112