xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/s390_64/mul_basecase.asm (revision f89f6560d453f5e37386cc7938c072d2f528b9fa)
1dnl  S/390-64 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		23
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	cghi	un, 2
46	jhe	L(ge2)
47
48C un = vn = 1
49	lg	%r1, 0(vp)
50	mlg	%r0, 0(up)
51	stg	%r1, 0(rp)
52	stg	%r0, 8(rp)
53	br	%r14
54
55L(ge2):	C jne	L(gen)
56
57
58L(gen):
59C mul_1 =======================================================================
60
61	stmg	%r6, %r12, 48(%r15)
62	lghi	zero, 0
63	aghi	un, -1
64
65	lg	%r7, 0(vp)
66	lg	%r11, 0(up)
67	lghi	%r12, 8			C init index register
68	mlgr	%r10, %r7
69	lgr	%r9, un
70	stg	%r11, 0(rp)
71	cr	%r15, %r15		C clear carry flag
72
73L(tm):	lg	%r1, 0(%r12,up)
74	mlgr	%r0, %r7
75	alcgr	%r1, %r10
76	lgr	%r10, %r0		C copy high part to carry limb
77	stg	%r1, 0(%r12,rp)
78	la	%r12, 8(%r12)
79	brctg	%r9, L(tm)
80
81	alcgr	%r0, zero
82	stg	%r0, 0(%r12,rp)
83
84C addmul_1 loop ===============================================================
85
86	aghi	vn, -1
87	je	L(outer_end)
88L(outer_loop):
89
90	la	rp, 8(rp)		C rp += 1
91	la	vp, 8(vp)		C up += 1
92	lg	%r7, 0(vp)
93	lg	%r11, 0(up)
94	lghi	%r12, 8			C init index register
95	mlgr	%r10, %r7
96	lgr	%r9, un
97	alg	%r11, 0(rp)
98	stg	%r11, 0(rp)
99
100L(tam):	lg	%r1, 0(%r12,up)
101	lg	%r11, 0(%r12,rp)
102	mlgr	%r0, %r7
103	alcgr	%r1, %r11
104	alcgr	%r0, zero
105	algr	%r1, %r10
106	lgr	%r10, %r0
107	stg	%r1, 0(%r12,rp)
108	la	%r12, 8(%r12)
109	brctg	%r9, L(tam)
110
111	alcgr	%r0, zero
112	stg	%r0, 0(%r12,rp)
113
114	brctg	vn, L(outer_loop)
115L(outer_end):
116
117	lmg	%r6, %r12, 48(%r15)
118	br	%r14
119EPILOGUE()
120