xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/s390_32/esame/mul_basecase.asm (revision e89934bbf778a6d6d6894877c4da59d0c7835b0f)
1dnl  S/390-32/esame mpn_mul_basecase.
2
3dnl  Copyright 2011 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 z900		 ?
24C z990		 ?
25C z9		 ?
26C z10		 ?
27C z196		 ?
28
29C TODO
30C  * Perhaps add special case for un <= 2.
31C  * Replace loops by faster code.  The mul_1 and addmul_1 loops could be sped
32C    up by about 10%.
33
34C INPUT PARAMETERS
35define(`rp',	`%r2')
36define(`up',	`%r3')
37define(`un',	`%r4')
38define(`vp',	`%r5')
39define(`vn',	`%r6')
40
41define(`zero',	`%r8')
42
43ASM_START()
44PROLOGUE(mpn_mul_basecase)
45	chi	un, 2
46	jhe	L(ge2)
47
48C un = vn = 1
49	l	%r1, 0(vp)
50	ml	%r0, 0(up)
51	st	%r1, 0(rp)
52	st	%r0, 4(rp)
53	br	%r14
54
55L(ge2):	C jne	L(gen)
56
57
58L(gen):
59C mul_1 =======================================================================
60
61	stm	%r6, %r12, 24(%r15)
62	lhi	zero, 0
63	ahi	un, -1
64
65	l	%r7, 0(vp)
66	l	%r11, 0(up)
67	lhi	%r12, 4			C init index register
68	mlr	%r10, %r7
69	lr	%r9, un
70	st	%r11, 0(rp)
71	cr	%r15, %r15		C clear carry flag
72
73L(tm):	l	%r1, 0(%r12,up)
74	mlr	%r0, %r7
75	alcr	%r1, %r10
76	lr	%r10, %r0		C copy high part to carry limb
77	st	%r1, 0(%r12,rp)
78	la	%r12, 4(%r12)
79	brct	%r9, L(tm)
80
81	alcr	%r0, zero
82	st	%r0, 0(%r12,rp)
83
84C addmul_1 loop ===============================================================
85
86	ahi	vn, -1
87	je	L(outer_end)
88L(outer_loop):
89
90	la	rp, 4(rp)		C rp += 1
91	la	vp, 4(vp)		C up += 1
92	l	%r7, 0(vp)
93	l	%r11, 0(up)
94	lhi	%r12, 4			C init index register
95	mlr	%r10, %r7
96	lr	%r9, un
97	al	%r11, 0(rp)
98	st	%r11, 0(rp)
99
100L(tam):	l	%r1, 0(%r12,up)
101	l	%r11, 0(%r12,rp)
102	mlr	%r0, %r7
103	alcr	%r1, %r11
104	alcr	%r0, zero
105	alr	%r1, %r10
106	lr	%r10, %r0
107	st	%r1, 0(%r12,rp)
108	la	%r12, 4(%r12)
109	brct	%r9, L(tam)
110
111	alcr	%r0, zero
112	st	%r0, 0(%r12,rp)
113
114	brct	vn, L(outer_loop)
115L(outer_end):
116
117	lm	%r6, %r12, 24(%r15)
118	br	%r14
119EPILOGUE()
120