1# _lshrsi3.S for Lattice Mico32
2# Contributed by Jon Beniston <jon@beniston.com> and Richard Henderson.
3#
4# Copyright (C) 2009-2015 Free Software Foundation, Inc.
5#
6# This file is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by the
8# Free Software Foundation; either version 3, or (at your option) any
9# later version.
10#
11# This file is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# General Public License for more details.
15#
16# Under Section 7 of GPL version 3, you are granted additional
17# permissions described in the GCC Runtime Library Exception, version
18# 3.1, as published by the Free Software Foundation.
19#
20# You should have received a copy of the GNU General Public License and
21# a copy of the GCC Runtime Library Exception along with this program;
22# see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23# <http://www.gnu.org/licenses/>.
24#
25
26/* Logical right shift.  */
27
28        .global __lshrsi3
29        .type __lshrsi3,@function
30
31__lshrsi3:
32        /* Only use 5 LSBs, as that's all the h/w shifter uses.  */
33        andi    r2, r2, 0x1f
34        /* Get address of offset into unrolled shift loop to jump to.  */
35#ifdef __PIC__
36        lw      r3, (gp+got(__lshrsi3_0))
37#else
38        mvhi    r3, hi(__lshrsi3_0)
39        ori     r3, r3, lo(__lshrsi3_0)
40#endif
41        add     r2, r2, r2
42        add     r2, r2, r2
43        sub     r3, r3, r2
44        b       r3
45
46__lshrsi3_31:
47        srui    r1, r1, 1
48__lshrsi3_30:
49        srui    r1, r1, 1
50__lshrsi3_29:
51        srui    r1, r1, 1
52__lshrsi3_28:
53        srui    r1, r1, 1
54__lshrsi3_27:
55        srui    r1, r1, 1
56__lshrsi3_26:
57        srui    r1, r1, 1
58__lshrsi3_25:
59        srui    r1, r1, 1
60__lshrsi3_24:
61        srui    r1, r1, 1
62__lshrsi3_23:
63        srui    r1, r1, 1
64__lshrsi3_22:
65        srui    r1, r1, 1
66__lshrsi3_21:
67        srui    r1, r1, 1
68__lshrsi3_20:
69        srui    r1, r1, 1
70__lshrsi3_19:
71        srui    r1, r1, 1
72__lshrsi3_18:
73        srui    r1, r1, 1
74__lshrsi3_17:
75        srui    r1, r1, 1
76__lshrsi3_16:
77        srui    r1, r1, 1
78__lshrsi3_15:
79        srui    r1, r1, 1
80__lshrsi3_14:
81        srui    r1, r1, 1
82__lshrsi3_13:
83        srui    r1, r1, 1
84__lshrsi3_12:
85        srui    r1, r1, 1
86__lshrsi3_11:
87        srui    r1, r1, 1
88__lshrsi3_10:
89        srui    r1, r1, 1
90__lshrsi3_9:
91        srui    r1, r1, 1
92__lshrsi3_8:
93        srui    r1, r1, 1
94__lshrsi3_7:
95        srui    r1, r1, 1
96__lshrsi3_6:
97        srui    r1, r1, 1
98__lshrsi3_5:
99        srui    r1, r1, 1
100__lshrsi3_4:
101        srui    r1, r1, 1
102__lshrsi3_3:
103        srui    r1, r1, 1
104__lshrsi3_2:
105        srui    r1, r1, 1
106__lshrsi3_1:
107        srui    r1, r1, 1
108__lshrsi3_0:
109        ret
110