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