Update.
[glibc.git] / sysdeps / sparc / sparc64 / rshift.S
blobe1b3aca1121cf192a824895fed4bd6eea7f8748d
1 /* SPARC v9 __mpn_rshift --
3    Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston,
20    MA 02111-1307, USA.  */
22 #include <sysdep.h>
24 /* INPUT PARAMETERS
25    res_ptr      %i0
26    src_ptr      %i1
27    size         %i2
28    cnt          %i3  */
30 ENTRY(__mpn_rshift)
31         save    %sp, -128, %sp
33         ldx     [%i1],%g2       ! load first limb
34         sub     %g0,%i3,%i5     ! negate shift count
35         add     %i2,-1,%i2
36         and     %i2,4-1,%l4     ! number of limbs in first loop
37         sllx    %g2,%i5,%g1     ! compute function result
38         brz,pn  %l4,.L0         ! if multiple of 4 limbs, skip first loop
39         mov     %g1,%l1
41         sub     %i2,%l4,%i2     ! adjust count for main loop
43 .Loop0: ldx     [%i1+8],%g3
44         add     %i0,8,%i0
45         add     %i1,8,%i1
46         add     %l4,-1,%l4
47         srlx    %g2,%i3,%i4
48         sllx    %g3,%i5,%g1
49         mov     %g3,%g2
50         or      %i4,%g1,%i4
51         brnz,pt %l4,.Loop0
52          stx    %i4,[%i0-8]
54 .L0:    brz,pn  %i2,.Lend
55          nop
57 .Loop:  ldx     [%i1+8],%g3
58         add     %i0,32,%i0
59         add     %i2,-4,%i2
60         srlx    %g2,%i3,%i4
61         sllx    %g3,%i5,%g1
63         ldx     [%i1+16],%g2
64         srlx    %g3,%i3,%l4
65         or      %i4,%g1,%i4
66         stx     %i4,[%i0-32]
67         sllx    %g2,%i5,%g1
69         ldx     [%i1+24],%g3
70         srlx    %g2,%i3,%i4
71         or      %l4,%g1,%l4
72         stx     %l4,[%i0-24]
73         sllx    %g3,%i5,%g1
75         ldx     [%i1+32],%g2
76         srlx    %g3,%i3,%l4
77         or      %i4,%g1,%i4
78         stx     %i4,[%i0-16]
79         sllx    %g2,%i5,%g1
81         add     %i1,32,%i1
82         or      %l4,%g1,%l4
83         brnz    %i2,.Loop
84          stx    %l4,[%i0-8]
86 .Lend:  srlx    %g2,%i3,%g2
87         stx     %g2,[%i0-0]
89         mov     %l1,%i0
90         jmpl    %i7+8,%g0
91          restore
93 END(__mpn_rshift)