1dnl  PPC64 mpn_bdiv_dbm1c.
2
3dnl  Copyright 2008 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 POWER3/PPC630:    6-18
24C POWER4/PPC970:    8.5
25C POWER5:           ?
26
27C TODO
28C  * Nothing to do...
29
30C INPUT PARAMETERS
31define(`rp', `r3')
32define(`up', `r4')
33define(`n',  `r5')
34define(`bd', `r6')
35define(`cy', `r7')
36
37ASM_START()
38PROLOGUE(mpn_bdiv_dbm1c)
39	ld	r0, 0(r4)
40
41	rldicl.	r12, r5, 0,62
42	cmpldi	cr6, r12, 2
43	cmpldi	cr7, r5, 4
44	addi	r5, r5, 1
45	srwi	r5, r5, 2
46	mtctr	r5
47	beq	cr0, L(b00)
48	blt	cr6, L(b01)
49	beq	cr6, L(b10)
50
51L(b11):	mulld	r5, r0, r6
52	mulhdu	r12, r0, r6
53	ld	r0, 8(r4)
54	addi	r4, r4, -24
55	addi	r3, r3, -24
56	b	L(3)
57
58L(b00):	mulld	r9, r0, r6
59	mulhdu	r8, r0, r6
60	ld	r0, 8(r4)
61	addi	r4, r4, -16
62	addi	r3, r3, -16
63	b	L(0)
64
65L(b01):	mulld	r5, r0, r6
66	mulhdu	r12, r0, r6
67	addi	r3, r3, -8
68	ble	cr7, L(e1)
69	ld	r0, 8(r4)
70	addi	r4, r4, -8
71	b	L(1)
72
73L(b10):	mulld	r9, r0, r6
74	mulhdu	r8, r0, r6
75	ld	r0, 8(r4)
76	ble	cr7, L(e2)
77
78	ALIGN(16)
79L(top):	mulld	r5, r0, r6
80	mulhdu	r12, r0, r6
81	subfc	r11, r9, r7
82	ld	r0, 16(r4)
83	subfe	r7, r8, r11
84	std	r11, 0(r3)
85L(1):	mulld	r9, r0, r6
86	mulhdu	r8, r0, r6
87	subfc	r11, r5, r7
88	ld	r0, 24(r4)
89	subfe	r7, r12, r11
90	std	r11, 8(r3)
91L(0):	mulld	r5, r0, r6
92	mulhdu	r12, r0, r6
93	subfc	r11, r9, r7
94	ld	r0, 32(r4)
95	subfe	r7, r8, r11
96	std	r11, 16(r3)
97L(3):	mulld	r9, r0, r6
98	mulhdu	r8, r0, r6
99	subfc	r11, r5, r7
100	ld	r0, 40(r4)
101	subfe	r7, r12, r11
102	std	r11, 24(r3)
103	addi	r4, r4, 32
104	addi	r3, r3, 32
105	bdnz	L(top)
106
107L(e2):	mulld	r5, r0, r6
108	mulhdu	r12, r0, r6
109	subfc	r11, r9, r7
110	subfe	r7, r8, r11
111	std	r11, 0(r3)
112L(e1):	subfc	r11, r5, r7
113	std	r11, 8(r3)
114	subfe	r3, r12, r11
115	blr
116EPILOGUE()
117