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