]>
Commit | Line | Data |
---|---|---|
d19f5793 | 1 | /* Unsigned 32 bit division optimized for Epiphany. |
f1717362 | 2 | Copyright (C) 2009-2016 Free Software Foundation, Inc. |
d19f5793 | 3 | Contributed by Embecosm on behalf of Adapteva, Inc. |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | This file is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU General Public License as published by the | |
9 | Free Software Foundation; either version 3, or (at your option) any | |
10 | later version. | |
11 | ||
12 | This file is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | General Public License for more details. | |
16 | ||
17 | Under Section 7 of GPL version 3, you are granted additional | |
18 | permissions described in the GCC Runtime Library Exception, version | |
19 | 3.1, as published by the Free Software Foundation. | |
20 | ||
21 | You should have received a copy of the GNU General Public License and | |
22 | a copy of the GCC Runtime Library Exception along with this program; | |
23 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 | <http://www.gnu.org/licenses/>. */ | |
25 | ||
26 | #include "epiphany-asm.h" | |
27 | ||
28 | /* Because we handle a divident with bit 31 set with truncating integer | |
29 | arithmetic, there is no rounding-related overflow. */ | |
30 | FSTAB (__umodsi3,T_UINT) | |
31 | .global SYM(__umodsi3) | |
32 | .balign 4 | |
33 | HIDDEN_FUNC(__umodsi3) | |
34 | SYM(__umodsi3): | |
35 | float r2,r0 | |
36 | mov TMP1,%low(0xb0800000) ; ??? this would be faster with small data | |
37 | float TMP2,r1 | |
38 | movt TMP1,%high(0xb0800000) | |
39 | asr TMP0,r0,8 | |
40 | sub TMP0,TMP0,TMP1 | |
41 | mov TMP1,%low(.L0step) | |
42 | movgteu r2,TMP0 | |
43 | sub r2,r2,TMP2 | |
44 | blteu .L0step | |
45 | asr r2,r2,23 | |
46 | movt TMP1,%high(.L0step) | |
47 | lsl TMP2,r2,3 | |
48 | lsl r2,r1,r2` sub r2,r0,r2` movgteu r0,r2 ; STEP(r2) | |
49 | sub r2,TMP1,TMP2 | |
50 | jr r2 | |
51 | #define STEP(n) lsl.l r2,r1,n` sub r2,r0,r2` movgteu r0,r2 | |
52 | .balign 8,,2 | |
53 | STEP(31)` STEP(30)` STEP(29)` STEP(28)` | |
54 | STEP(27)` STEP(26)` STEP(25)` STEP(24)` | |
55 | STEP(23)` STEP(22)` STEP(21)` STEP(20)` | |
56 | STEP(19)` STEP(18)` STEP(17)` STEP(16)` | |
57 | STEP(15)` STEP(14)` STEP(13)` STEP(12)` | |
58 | STEP(11)` STEP(10)` STEP(9)` STEP(8)` | |
59 | STEP(7)` STEP(6)` STEP(5)` STEP(4)` STEP(3)` STEP(2)` STEP(1) | |
60 | .L0step:STEP(0) | |
61 | .Lret_r0: | |
62 | rts | |
63 | ENDFUNC(__umodsi3) |