Imported Upstream version 6.0.0
[platform/upstream/gmp.git] / mpn / s390_32 / esame / aorslsh1_n.asm
1 dnl  S/390-32 mpn_addlsh1_n
2
3 dnl  Copyright 2011 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6 dnl
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of either:
9 dnl
10 dnl    * the GNU Lesser General Public License as published by the Free
11 dnl      Software Foundation; either version 3 of the License, or (at your
12 dnl      option) any later version.
13 dnl
14 dnl  or
15 dnl
16 dnl    * the GNU General Public License as published by the Free Software
17 dnl      Foundation; either version 2 of the License, or (at your option) any
18 dnl      later version.
19 dnl
20 dnl  or both in parallel, as here.
21 dnl
22 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 dnl  for more details.
26 dnl
27 dnl  You should have received copies of the GNU General Public License and the
28 dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29 dnl  see https://www.gnu.org/licenses/.
30
31 include(`../config.m4')
32
33 C            cycles/limb
34 C z900           9.25
35 C z990           5
36 C z9             ?
37 C z10            ?
38 C z196           ?
39
40 C TODO
41 C  * Optimise for small n
42 C  * Compute RETVAL for sublsh1_n less stupidly
43
44 C INPUT PARAMETERS
45 define(`rp',    `%r2')
46 define(`up',    `%r3')
47 define(`vp',    `%r4')
48 define(`n',     `%r5')
49
50 ifdef(`OPERATION_addlsh1_n',`
51   define(ADDSUBC,       alr)
52   define(ADDSUBE,       alcr)
53   define(INITCY,        `lhi    %r13, -1')
54   define(RETVAL,        `alr    %r1, %r13
55                         lhi     %r2, 2
56                         alr     %r2, %r1')
57   define(func, mpn_addlsh1_n)
58 ')
59 ifdef(`OPERATION_sublsh1_n',`
60   define(ADDSUBC,       slr)
61   define(ADDSUBE,       slbr)
62   define(INITCY,        `lhi    %r13, 0')
63   define(RETVAL,        `slr    %r1, %r13
64                         lhi     %r2, 1
65                         alr     %r2, %r1')
66   define(func, mpn_sublsh1_n)
67 ')
68
69 MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_sublsh1_n)
70
71 ASM_START()
72 PROLOGUE(func)
73         stm     %r6, %r13, 24(%r15)
74
75         la      %r0, 3(n)
76         lhi     %r7, 3
77         srl     %r0, 2
78         nr      %r7, n                  C n mod 4
79         je      L(b0)
80         chi     %r7, 2
81         jl      L(b1)
82         je      L(b2)
83
84 L(b3):  lm      %r5, %r7, 0(up)
85         la      up, 12(up)
86         lm      %r9, %r11, 0(vp)
87         la      vp, 12(vp)
88
89         alr     %r9, %r9
90         alcr    %r10, %r10
91         alcr    %r11, %r11
92         slbr    %r1, %r1
93
94         ADDSUBC %r5, %r9
95         ADDSUBE %r6, %r10
96         ADDSUBE %r7, %r11
97         slbr    %r13, %r13
98
99         stm     %r5, %r7, 0(rp)
100         la      rp, 12(rp)
101         brct    %r0, L(top)
102         j       L(end)
103
104 L(b0):  lhi     %r1, -1
105         INITCY
106         j       L(top)
107
108 L(b1):  l       %r5, 0(up)
109         la      up, 4(up)
110         l       %r9, 0(vp)
111         la      vp, 4(vp)
112
113         alr     %r9, %r9
114         slbr    %r1, %r1
115         ADDSUBC %r5, %r9
116         slbr    %r13, %r13
117
118         st      %r5, 0(rp)
119         la      rp, 4(rp)
120         brct    %r0, L(top)
121         j       L(end)
122
123 L(b2):  lm      %r5, %r6, 0(up)
124         la      up, 8(up)
125         lm      %r9, %r10, 0(vp)
126         la      vp, 8(vp)
127
128         alr     %r9, %r9
129         alcr    %r10, %r10
130         slbr    %r1, %r1
131
132         ADDSUBC %r5, %r9
133         ADDSUBE %r6, %r10
134         slbr    %r13, %r13
135
136         stm     %r5, %r6, 0(rp)
137         la      rp, 8(rp)
138         brct    %r0, L(top)
139         j       L(end)
140
141 L(top): lm      %r9, %r12, 0(vp)
142         la      vp, 16(vp)
143
144         ahi     %r1, 1                  C restore carry
145
146         alcr    %r9, %r9
147         alcr    %r10, %r10
148         alcr    %r11, %r11
149         alcr    %r12, %r12
150
151         slbr    %r1, %r1                C save carry
152
153         lm      %r5, %r8, 0(up)
154         la      up, 16(up)
155
156         ahi     %r13, 1                 C restore carry
157
158         ADDSUBE %r5, %r9
159         ADDSUBE %r6, %r10
160         ADDSUBE %r7, %r11
161         ADDSUBE %r8, %r12
162
163         slbr    %r13, %r13
164
165         stm     %r5, %r8, 0(rp)
166         la      rp, 16(rp)
167         brct    %r0, L(top)
168
169 L(end):
170         RETVAL
171         lm      %r6, %r13, 24(%r15)
172         br      %r14
173 EPILOGUE()