1dnl  S/390-32 mpn_lshiftc.
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               7
35C z990             3.375
36C z9                 ?
37C z10                ?
38C z196               ?
39
40C TODO
41C  *
42
43C INPUT PARAMETERS
44define(`rp',        `%r2')
45define(`up',        `%r3')
46define(`n',         `%r4')
47define(`cnt',       `%r5')
48
49ASM_START()
50PROLOGUE(mpn_lshiftc)
51          lr        %r1, n
52          sll       %r1, 2
53          stm       %r6, %r13, 24(%r15)
54          la        up, 0(%r1,up)                 C put up near end of U
55          la        rp, 0(%r1,rp)                 C put rp near end of R
56          ahi       up, -20
57          ahi       rp, -16
58          lhi       %r8, 32
59          sr        %r8, cnt
60          l         %r12, 16(up)
61          srl       %r12, 0(%r8)                  C return value
62          lhi       %r13, -1
63          lhi       %r7, 3
64          nr        %r7, n
65          srl       n, 2
66          je        L(b0)
67          chi       %r7, 2
68          jl        L(b1)
69          je        L(b2)
70
71L(b3):    l         %r10, 16(up)
72          l         %r11, 12(up)
73          l         %r9,   8(up)
74          ahi       up, -8
75          lr        %r8, %r11
76          sldl      %r10, 0(cnt)
77          sldl      %r8,  0(cnt)
78          xr        %r10, %r13
79          xr        %r8, %r13
80          st        %r10, 12(rp)
81          st        %r8,   8(rp)
82          ahi       rp, -8
83          ltr       n, n
84          je        L(end)
85          j         L(top)
86
87L(b2):    l         %r10, 16(up)
88          l         %r11, 12(up)
89          ahi       up, -4
90          sldl      %r10, 0(cnt)
91          xr        %r10, %r13
92          st        %r10, 12(rp)
93          ahi       rp, -4
94          ltr       n, n
95          je        L(end)
96          j         L(top)
97
98L(b1):    ltr       n, n
99          je        L(end)
100          j         L(top)
101
102L(b0):    l         %r10,16(up)
103          l         %r8, 12(up)
104          l         %r6,  8(up)
105          l         %r0,  4(up)
106          ahi       up, -12
107          lr        %r11, %r8
108          lr        %r9,  %r6
109          lr        %r7,  %r0
110          sldl      %r10,0(cnt)
111          sldl      %r8, 0(cnt)
112          sldl      %r6, 0(cnt)
113          xr        %r10, %r13
114          xr        %r8, %r13
115          xr        %r6, %r13
116          st        %r10, 12(rp)
117          st        %r8,   8(rp)
118          st        %r6,   4(rp)
119          ahi       rp, -12
120          ahi       n, -1
121          je        L(end)
122
123          ALIGN(8)
124L(top):   l         %r10, 16(up)
125          l         %r8,  12(up)
126          l         %r6,   8(up)
127          l         %r0,   4(up)
128          l         %r1,   0(up)
129          lr        %r11, %r8
130          lr        %r9,  %r6
131          lr        %r7,  %r0
132          ahi       up, -16
133          sldl      %r10, 0(cnt)
134          sldl      %r8,  0(cnt)
135          sldl      %r6,  0(cnt)
136          sldl      %r0,  0(cnt)
137          xr        %r10, %r13
138          xr        %r8, %r13
139          xr        %r6, %r13
140          xr        %r0, %r13
141          st        %r10, 12(rp)
142          st        %r8,   8(rp)
143          st        %r6,   4(rp)
144          st        %r0,   0(rp)
145          ahi       rp, -16
146          brct      n, L(top)
147
148L(end):   l         %r10, 16(up)
149          sll       %r10, 0(cnt)
150          xr        %r10, %r13
151          st        %r10, 12(rp)
152
153          lr        %r2, %r12
154          lm        %r6, %r13, 24(%r15)
155          br        %r14
156EPILOGUE()
157