1dnl  S/390-32 mpn_rshift.
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               6
35C z990             3
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_rshift)
51          stm       %r6, %r12, 24(%r15)
52          lhi       %r8, 32
53          sr        %r8, cnt
54          l         %r12, 0(up)
55          sll       %r12, 0(%r8)                  C return value
56          lhi       %r7, 3
57          nr        %r7, n
58          srl       n, 2
59          je        L(b0)
60          chi       %r7, 2
61          jl        L(b1)
62          je        L(b2)
63
64L(b3):    l         %r11, 0(up)
65          l         %r10, 4(up)
66          l         %r8,  8(up)
67          ahi       up, 8
68          lr        %r9, %r10
69          srdl      %r10, 0(cnt)
70          srdl      %r8,  0(cnt)
71          st        %r11, 0(rp)
72          st        %r9,  4(rp)
73          ahi       rp, 8
74          ltr       n, n
75          je        L(end)
76          j         L(top)
77
78L(b2):    l         %r11, 0(up)
79          l         %r10, 4(up)
80          ahi       up, 4
81          srdl      %r10, 0(cnt)
82          st        %r11, 0(rp)
83          ahi       rp, 4
84          ltr       n, n
85          je        L(end)
86          j         L(top)
87
88L(b1):    ltr       n, n
89          je        L(end)
90          j         L(top)
91
92L(b0):    l         %r11, 0(up)
93          l         %r9,  4(up)
94          l         %r7,  8(up)
95          l         %r1, 12(up)
96          ahi       up, 12
97          lr        %r10, %r9
98          lr        %r8,  %r7
99          lr        %r6,  %r1
100          srdl      %r10, 0(cnt)
101          srdl      %r8,  0(cnt)
102          srdl      %r6,  0(cnt)
103          st        %r11, 0(rp)
104          st        %r9,  4(rp)
105          st        %r7,  8(rp)
106          ahi       rp, 12
107          ahi       n, -1
108          je        L(end)
109
110          ALIGN(8)
111L(top):   l         %r11, 0(up)
112          l         %r9,  4(up)
113          l         %r7,  8(up)
114          l         %r1, 12(up)
115          l         %r0, 16(up)
116          lr        %r10, %r9
117          lr        %r8,  %r7
118          lr        %r6,  %r1
119          ahi       up, 16
120          srdl      %r10, 0(cnt)
121          srdl      %r8,  0(cnt)
122          srdl      %r6,  0(cnt)
123          srdl      %r0,  0(cnt)
124          st        %r11, 0(rp)
125          st        %r9,  4(rp)
126          st        %r7,  8(rp)
127          st        %r1, 12(rp)
128          ahi       rp, 16
129          brct      n, L(top)
130
131L(end):   l         %r11, 0(up)
132          srl       %r11, 0(cnt)
133          st        %r11, 0(rp)
134
135          lr        %r2, %r12
136          lm        %r6, %r12, 24(%r15)
137          br        %r14
138EPILOGUE()
139