* stdlib/Makefile (mpn-stuff): New target.
[glibc.git] / sysdeps / alpha / alphaev5 / rshift.s
blobd20dde35b76917fc65ed1ec86cd85b0c1a719b6c
1 # Alpha EV5 __mpn_rshift --
3 # Copyright (C) 1994, 1995 Free Software Foundation, Inc.
5 # This file is part of the GNU MP Library.
7 # The GNU MP Library is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version.
12 # The GNU MP Library is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 # License for more details.
17 # You should have received a copy of the GNU Library General Public License
18 # along with the GNU MP Library; see the file COPYING.LIB. If not, write to
19 # the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 # INPUT PARAMETERS
23 # res_ptr r16
24 # s1_ptr r17
25 # size r18
26 # cnt r19
28 # This code runs at 3.25 cycles/limb on the EV5.
30 .set noreorder
31 .set noat
32 .text
33 .align 3
34 .globl __mpn_rshift
35 .ent __mpn_rshift
36 __mpn_rshift:
37 .frame $30,0,$26,0
39 ldq $4,0($17) # load first limb
40 subq $31,$19,$20
41 subq $18,1,$18
42 and $18,4-1,$28 # number of limbs in first loop
43 sll $4,$20,$0 # compute function result
45 beq $28,.L0
46 subq $18,$28,$18
48 .align 3
49 .Loop0: ldq $3,8($17)
50 addq $16,8,$16
51 srl $4,$19,$5
52 addq $17,8,$17
53 subq $28,1,$28
54 sll $3,$20,$6
55 or $3,$3,$4
56 or $5,$6,$8
57 stq $8,-8($16)
58 bne $28,.Loop0
60 .L0: srl $4,$19,$24
61 beq $18,.Lend
62 # warm up phase 1
63 ldq $1,8($17)
64 subq $18,4,$18
65 ldq $2,16($17)
66 ldq $3,24($17)
67 ldq $4,32($17)
68 beq $18,.Lend1
69 # warm up phase 2
70 sll $1,$20,$7
71 srl $1,$19,$21
72 sll $2,$20,$8
73 ldq $1,40($17)
74 srl $2,$19,$22
75 ldq $2,48($17)
76 sll $3,$20,$5
77 or $7,$24,$7
78 srl $3,$19,$23
79 or $8,$21,$8
80 sll $4,$20,$6
81 ldq $3,56($17)
82 srl $4,$19,$24
83 ldq $4,64($17)
84 subq $18,4,$18
85 beq $18,.Lend2
86 .align 4
87 # main loop
88 .Loop: stq $7,0($16)
89 or $5,$22,$5
90 stq $8,8($16)
91 or $6,$23,$6
93 sll $1,$20,$7
94 subq $18,4,$18
95 srl $1,$19,$21
96 unop # ldq $31,-96($17)
98 sll $2,$20,$8
99 ldq $1,72($17)
100 srl $2,$19,$22
101 ldq $2,80($17)
103 stq $5,16($16)
104 or $7,$24,$7
105 stq $6,24($16)
106 or $8,$21,$8
108 sll $3,$20,$5
109 unop # ldq $31,-96($17)
110 srl $3,$19,$23
111 addq $16,32,$16
113 sll $4,$20,$6
114 ldq $3,88($17)
115 srl $4,$19,$24
116 ldq $4,96($17)
118 addq $17,32,$17
119 bne $18,.Loop
120 # cool down phase 2/1
121 .Lend2: stq $7,0($16)
122 or $5,$22,$5
123 stq $8,8($16)
124 or $6,$23,$6
125 sll $1,$20,$7
126 srl $1,$19,$21
127 sll $2,$20,$8
128 srl $2,$19,$22
129 stq $5,16($16)
130 or $7,$24,$7
131 stq $6,24($16)
132 or $8,$21,$8
133 sll $3,$20,$5
134 srl $3,$19,$23
135 sll $4,$20,$6
136 srl $4,$19,$24
137 # cool down phase 2/2
138 stq $7,32($16)
139 or $5,$22,$5
140 stq $8,40($16)
141 or $6,$23,$6
142 stq $5,48($16)
143 stq $6,56($16)
144 # cool down phase 2/3
145 stq $24,64($16)
146 ret $31,($26),1
148 # cool down phase 1/1
149 .Lend1: sll $1,$20,$7
150 srl $1,$19,$21
151 sll $2,$20,$8
152 srl $2,$19,$22
153 sll $3,$20,$5
154 or $7,$24,$7
155 srl $3,$19,$23
156 or $8,$21,$8
157 sll $4,$20,$6
158 srl $4,$19,$24
159 # cool down phase 1/2
160 stq $7,0($16)
161 or $5,$22,$5
162 stq $8,8($16)
163 or $6,$23,$6
164 stq $5,16($16)
165 stq $6,24($16)
166 stq $24,32($16)
167 ret $31,($26),1
169 .Lend: stq $24,0($16)
170 ret $31,($26),1
171 .end __mpn_rshift