Home | History | Annotate | Line # | Download | only in epiphany
      1       1.1  mrg /* Unsigned 32 bit modulo optimized for Epiphany.
      2  1.1.1.11  mrg    Copyright (C) 2009-2024 Free Software Foundation, Inc.
      3       1.1  mrg    Contributed by Embecosm on behalf of Adapteva, Inc.
      4       1.1  mrg 
      5       1.1  mrg This file is part of GCC.
      6       1.1  mrg 
      7       1.1  mrg This file is free software; you can redistribute it and/or modify it
      8       1.1  mrg under the terms of the GNU General Public License as published by the
      9       1.1  mrg Free Software Foundation; either version 3, or (at your option) any
     10       1.1  mrg later version.
     11       1.1  mrg 
     12       1.1  mrg This file is distributed in the hope that it will be useful, but
     13       1.1  mrg WITHOUT ANY WARRANTY; without even the implied warranty of
     14       1.1  mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15       1.1  mrg General Public License for more details.
     16       1.1  mrg 
     17       1.1  mrg Under Section 7 of GPL version 3, you are granted additional
     18       1.1  mrg permissions described in the GCC Runtime Library Exception, version
     19       1.1  mrg 3.1, as published by the Free Software Foundation.
     20       1.1  mrg 
     21       1.1  mrg You should have received a copy of the GNU General Public License and
     22       1.1  mrg a copy of the GCC Runtime Library Exception along with this program;
     23       1.1  mrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     24       1.1  mrg <http://www.gnu.org/licenses/>.  */
     25       1.1  mrg 
     26       1.1  mrg #include "epiphany-asm.h"
     27       1.1  mrg 
     28       1.1  mrg 	FSTAB (__umodsi3,T_UINT)
     29       1.1  mrg 	.global SYM(__umodsi3)
     30       1.1  mrg 	.balign 4
     31       1.1  mrg 	HIDDEN_FUNC(__umodsi3)
     32       1.1  mrg SYM(__umodsi3):
     33       1.1  mrg 	mov r2,5
     34       1.1  mrg 	lsl r2,r2,29 ; 0xa0000000
     35       1.1  mrg 	orr r3,r2,r0
     36       1.1  mrg 	lsr r15,r0,16
     37       1.1  mrg 	movt r15,0xa800
     38       1.1  mrg 	movne r3,r15
     39       1.1  mrg 	lsr r16,r2,2 ; 0x28000000
     40       1.1  mrg 	and r15,r3,r16
     41       1.1  mrg 	fadd r12,r3,r15
     42       1.1  mrg 	 orr r3,r2,r1
     43       1.1  mrg 	lsr r2,r1,16
     44       1.1  mrg 	movt r2,0xa800
     45       1.1  mrg 	movne r3,r2
     46       1.1  mrg 	and r2,r16,r3
     47       1.1  mrg 	fadd r3,r3,r2
     48       1.1  mrg 	 sub r2,r0,r1
     49       1.1  mrg 	bltu .Lret_a
     50       1.1  mrg 	lsr r12,r12,23
     51       1.1  mrg 	mov r2,%low(.L0step)
     52       1.1  mrg 	movt r2,%high(.L0step)
     53       1.1  mrg 	lsr r3,r3,23
     54       1.1  mrg 	sub r3,r12,r3 ; calculate bit number difference.
     55       1.1  mrg 	lsl r3,r3,3
     56       1.1  mrg 	sub r2,r2,r3
     57       1.1  mrg 	jr r2
     58       1.1  mrg /*              lsl_l r2,r1,n`               sub r2,r0,r2` movgteu r0,r2  */
     59       1.1  mrg #define STEP(n) .long 0x0006441f | (n) << 5` sub r2,r0,r2` movgteu r0,r2
     60       1.1  mrg 	.balign 8,,2
     61       1.1  mrg 	STEP(31)` STEP(30)` STEP(29)` STEP(28)`
     62       1.1  mrg 	STEP(27)` STEP(26)` STEP(25)` STEP(24)`
     63       1.1  mrg 	STEP(23)` STEP(22)` STEP(21)` STEP(20)`
     64       1.1  mrg 	STEP(19)` STEP(18)` STEP(17)` STEP(16)`
     65       1.1  mrg 	STEP(15)` STEP(14)` STEP(13)` STEP(12)`
     66       1.1  mrg 	STEP(11)` STEP(10)` STEP(9)`  STEP(8)`
     67       1.1  mrg 	STEP(7)` STEP(6)` STEP(5)` STEP(4)` STEP(3)` STEP(2)` STEP(1)
     68       1.1  mrg .L0step:STEP(0)
     69       1.1  mrg .Lret_a:rts
     70       1.1  mrg 	ENDFUNC(__umodsi3)
     71