1dnl  PPC32 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 603e:            ?
24C 604e:            ?
25C 75x (G3):        ?
26C 7400,7410 (G4):  9.43
27C 744x,745x (G4+): 6.28
28C power4/ppc970:   ?
29C power5:          ?
30
31C TODO
32C  * Nothing to do...
33
34C INPUT PARAMETERS
35define(`rp', `r3')
36define(`up', `r4')
37define(`n',  `r5')
38define(`bd', `r6')
39define(`cy', `r7')
40
41ASM_START()
42PROLOGUE(mpn_bdiv_dbm1c)
43	lwz	r0, 0(r4)
44
45	rlwinm.	r12, r5, 0,30,31
46	cmplwi	cr6, r12, 2
47	cmplwi	cr7, r5, 4
48	addi	r5, r5, 1
49	srwi	r5, r5, 2
50	mtctr	r5
51	beq	cr0, L(b00)
52	blt	cr6, L(b01)
53	beq	cr6, L(b10)
54
55L(b11):	mullw	r5, r0, r6
56	mulhwu	r12, r0, r6
57	lwz	r0, 4(r4)
58	addi	r4, r4, -12
59	addi	r3, r3, -12
60	b	L(3)
61
62L(b00):	mullw	r9, r0, r6
63	mulhwu	r8, r0, r6
64	lwz	r0, 4(r4)
65	addi	r4, r4, -8
66	addi	r3, r3, -8
67	b	L(0)
68
69L(b01):	mullw	r5, r0, r6
70	mulhwu	r12, r0, r6
71	addi	r3, r3, -4
72	ble	cr7, L(e1)
73	lwz	r0, 4(r4)
74	addi	r4, r4, -4
75	b	L(1)
76
77L(b10):	mullw	r9, r0, r6
78	mulhwu	r8, r0, r6
79	lwz	r0, 4(r4)
80	ble	cr7, L(e2)
81
82	ALIGN(16)
83L(top):	mullw	r5, r0, r6
84	mulhwu	r12, r0, r6
85	subfc	r11, r9, r7
86	lwz	r0, 8(r4)
87	subfe	r7, r8, r11
88	stw	r11, 0(r3)
89L(1):	mullw	r9, r0, r6
90	mulhwu	r8, r0, r6
91	subfc	r11, r5, r7
92	lwz	r0, 12(r4)
93	subfe	r7, r12, r11
94	stw	r11, 4(r3)
95L(0):	mullw	r5, r0, r6
96	mulhwu	r12, r0, r6
97	subfc	r11, r9, r7
98	lwz	r0, 16(r4)
99	subfe	r7, r8, r11
100	stw	r11, 8(r3)
101L(3):	mullw	r9, r0, r6
102	mulhwu	r8, r0, r6
103	subfc	r11, r5, r7
104	lwz	r0, 20(r4)
105	subfe	r7, r12, r11
106	stw	r11, 12(r3)
107	addi	r4, r4, 16
108	addi	r3, r3, 16
109	bdnz	L(top)
110
111L(e2):	mullw	r5, r0, r6
112	mulhwu	r12, r0, r6
113	subfc	r11, r9, r7
114	subfe	r7, r8, r11
115	stw	r11, 0(r3)
116L(e1):	subfc	r11, r5, r7
117	stw	r11, 4(r3)
118	subfe	r3, r12, r11
119	blr
120EPILOGUE()
121