Paul Mundt | 180ae20 | 2008-12-12 16:53:14 +0900 | [diff] [blame] | 1 | .global __udivsi3 |
| 2 | .section .text..SHmedia32,"ax" |
| 3 | .align 2 |
| 4 | |
| 5 | /* |
| 6 | inputs: r4,r5 |
| 7 | clobbered: r18,r19,r20,r21,r22,r25,tr0 |
| 8 | result in r0. |
| 9 | */ |
| 10 | __udivsi3: |
| 11 | addz.l r5,r63,r22 |
| 12 | nsb r22,r0 |
| 13 | shlld r22,r0,r25 |
| 14 | shlri r25,48,r25 |
| 15 | movi 0xffffffffffffbb0c,r20 /* shift count eqiv 76 */ |
| 16 | sub r20,r25,r21 |
| 17 | mmulfx.w r21,r21,r19 |
| 18 | mshflo.w r21,r63,r21 |
| 19 | ptabs r18,tr0 |
| 20 | mmulfx.w r25,r19,r19 |
| 21 | sub r20,r0,r0 |
| 22 | /* bubble */ |
| 23 | msub.w r21,r19,r19 |
| 24 | |
| 25 | /* |
| 26 | * It would be nice for scheduling to do this add to r21 before |
| 27 | * the msub.w, but we need a different value for r19 to keep |
| 28 | * errors under control. |
| 29 | */ |
| 30 | addi r19,-2,r21 |
| 31 | mulu.l r4,r21,r18 |
| 32 | mmulfx.w r19,r19,r19 |
| 33 | shlli r21,15,r21 |
| 34 | shlrd r18,r0,r18 |
| 35 | mulu.l r18,r22,r20 |
| 36 | mmacnfx.wl r25,r19,r21 |
| 37 | /* bubble */ |
| 38 | sub r4,r20,r25 |
| 39 | |
| 40 | mulu.l r25,r21,r19 |
| 41 | addi r0,14,r0 |
| 42 | /* bubble */ |
| 43 | shlrd r19,r0,r19 |
| 44 | mulu.l r19,r22,r20 |
| 45 | add r18,r19,r18 |
| 46 | /* bubble */ |
| 47 | sub.l r25,r20,r25 |
| 48 | |
| 49 | mulu.l r25,r21,r19 |
| 50 | addz.l r25,r63,r25 |
| 51 | sub r25,r22,r25 |
| 52 | shlrd r19,r0,r19 |
| 53 | mulu.l r19,r22,r20 |
| 54 | addi r25,1,r25 |
| 55 | add r18,r19,r18 |
| 56 | |
| 57 | cmpgt r25,r20,r25 |
| 58 | add.l r18,r25,r0 |
| 59 | blink tr0,r63 |