Home | History | Annotate | Line # | Download | only in lm32
      1 # _lshrsi3.S for Lattice Mico32
      2 # Contributed by Jon Beniston <jon@beniston.com> and Richard Henderson.
      3 #
      4 # Copyright (C) 2009-2022 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