xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/powerpc64/mode64/bdiv_dbm1c.asm (revision 8ecbf5f02b752fcb7debe1a8fab1dc82602bc760)
1dnl  PPC64 mpn_bdiv_dbm1c.
2
3dnl  Copyright 2008, 2010 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 POWER3/PPC630       6-18
35C POWER4/PPC970       8.25
36C POWER5              8.5  fluctuating as function of n % 3
37C POWER6             15
38C POWER7              4.75
39
40C TODO
41C  * Nothing to do...
42
43C INPUT PARAMETERS
44define(`rp', `r3')
45define(`up', `r4')
46define(`n',  `r5')
47define(`bd', `r6')
48define(`cy', `r7')
49
50ASM_START()
51PROLOGUE(mpn_bdiv_dbm1c)
52	ld	r0, 0(r4)
53
54	rldicl.	r12, r5, 0,62
55	cmpldi	cr6, r12, 2
56	cmpldi	cr7, r5, 4
57	addi	r5, r5, 1
58	srwi	r5, r5, 2
59	mtctr	r5
60	beq	cr0, L(b00)
61	blt	cr6, L(b01)
62	beq	cr6, L(b10)
63
64	ALIGN(16)
65L(b11):	mulld	r5, r0, r6
66	mulhdu	r12, r0, r6
67	ld	r0, 8(r4)
68	addi	r4, r4, -24
69	addi	r3, r3, -24
70	b	L(3)
71
72	ALIGN(16)
73L(b00):	mulld	r9, r0, r6
74	mulhdu	r8, r0, r6
75	addi	r4, r4, -16
76	addi	r3, r3, -16
77	b	L(0)
78
79	ALIGN(16)
80L(b01):	mulld	r5, r0, r6
81	mulhdu	r12, r0, r6
82	addi	r3, r3, -8
83	ble	cr7, L(e1)
84	ld	r0, 8(r4)
85	addi	r4, r4, -8
86	b	L(1)
87
88	ALIGN(16)
89L(b10):	mulld	r9, r0, r6
90	mulhdu	r8, r0, r6
91	ble	cr7, L(e2)
92
93	ALIGN(16)
94L(top):	subfc	r11, r9, r7
95	ld	r10, 8(r4)
96	ld	r0, 16(r4)
97	subfe	r7, r8, r11
98	std	r11, 0(r3)
99	mulld	r5, r10, r6
100	mulhdu	r12, r10, r6
101L(1):	mulld	r9, r0, r6
102	mulhdu	r8, r0, r6
103	subfc	r11, r5, r7
104	subfe	r7, r12, r11
105	std	r11, 8(r3)
106L(0):	subfc	r11, r9, r7
107	ld	r10, 24(r4)
108	ld	r0, 32(r4)
109	subfe	r7, r8, r11
110	std	r11, 16(r3)
111	mulld	r5, r10, r6
112	mulhdu	r12, r10, r6
113L(3):	mulld	r9, r0, r6
114	mulhdu	r8, r0, r6
115	subfc	r11, r5, r7
116	subfe	r7, r12, r11
117	std	r11, 24(r3)
118	addi	r4, r4, 32
119	addi	r3, r3, 32
120	bdnz	L(top)
121
122L(e2):	ld	r10, 8(r4)
123	mulld	r5, r10, r6
124	mulhdu	r12, r10, r6
125	subfc	r11, r9, r7
126	subfe	r7, r8, r11
127	std	r11, 0(r3)
128L(e1):	subfc	r11, r5, r7
129	std	r11, 8(r3)
130	subfe	r3, r12, r11
131	blr
132EPILOGUE()
133