Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Paul Mundt | 180ae20 | 2008-12-12 16:53:14 +0900 | [diff] [blame] | 2 | .global __sdivsi3 |
Paul Mundt | 1031a3a | 2009-05-09 17:57:21 +0900 | [diff] [blame] | 3 | .global __sdivsi3_1 |
| 4 | .global __sdivsi3_2 |
Paul Mundt | 180ae20 | 2008-12-12 16:53:14 +0900 | [diff] [blame] | 5 | .section .text..SHmedia32,"ax" |
| 6 | .align 2 |
| 7 | |
| 8 | /* inputs: r4,r5 */ |
| 9 | /* clobbered: r1,r18,r19,r20,r21,r25,tr0 */ |
| 10 | /* result in r0 */ |
| 11 | __sdivsi3: |
Paul Mundt | 1031a3a | 2009-05-09 17:57:21 +0900 | [diff] [blame] | 12 | __sdivsi3_1: |
Paul Mundt | 180ae20 | 2008-12-12 16:53:14 +0900 | [diff] [blame] | 13 | ptb __div_table,tr0 |
Paul Mundt | 1031a3a | 2009-05-09 17:57:21 +0900 | [diff] [blame] | 14 | gettr tr0,r20 |
Paul Mundt | 180ae20 | 2008-12-12 16:53:14 +0900 | [diff] [blame] | 15 | |
Paul Mundt | 1031a3a | 2009-05-09 17:57:21 +0900 | [diff] [blame] | 16 | __sdivsi3_2: |
Paul Mundt | 180ae20 | 2008-12-12 16:53:14 +0900 | [diff] [blame] | 17 | nsb r5, r1 |
| 18 | shlld r5, r1, r25 /* normalize; [-2 ..1, 1..2) in s2.62 */ |
| 19 | shari r25, 58, r21 /* extract 5(6) bit index (s2.4 with hole -1..1) */ |
| 20 | /* bubble */ |
Paul Mundt | 180ae20 | 2008-12-12 16:53:14 +0900 | [diff] [blame] | 21 | ldx.ub r20, r21, r19 /* u0.8 */ |
| 22 | shari r25, 32, r25 /* normalize to s2.30 */ |
| 23 | shlli r21, 1, r21 |
| 24 | muls.l r25, r19, r19 /* s2.38 */ |
| 25 | ldx.w r20, r21, r21 /* s2.14 */ |
| 26 | ptabs r18, tr0 |
| 27 | shari r19, 24, r19 /* truncate to s2.14 */ |
| 28 | sub r21, r19, r19 /* some 11 bit inverse in s1.14 */ |
| 29 | muls.l r19, r19, r21 /* u0.28 */ |
| 30 | sub r63, r1, r1 |
| 31 | addi r1, 92, r1 |
| 32 | muls.l r25, r21, r18 /* s2.58 */ |
| 33 | shlli r19, 45, r19 /* multiply by two and convert to s2.58 */ |
| 34 | /* bubble */ |
| 35 | sub r19, r18, r18 |
| 36 | shari r18, 28, r18 /* some 22 bit inverse in s1.30 */ |
| 37 | muls.l r18, r25, r0 /* s2.60 */ |
| 38 | muls.l r18, r4, r25 /* s32.30 */ |
| 39 | /* bubble */ |
| 40 | shari r0, 16, r19 /* s-16.44 */ |
| 41 | muls.l r19, r18, r19 /* s-16.74 */ |
| 42 | shari r25, 63, r0 |
| 43 | shari r4, 14, r18 /* s19.-14 */ |
| 44 | shari r19, 30, r19 /* s-16.44 */ |
| 45 | muls.l r19, r18, r19 /* s15.30 */ |
| 46 | xor r21, r0, r21 /* You could also use the constant 1 << 27. */ |
| 47 | add r21, r25, r21 |
| 48 | sub r21, r19, r21 |
| 49 | shard r21, r1, r21 |
| 50 | sub r21, r0, r0 |
| 51 | blink tr0, r63 |
| 52 | |
| 53 | /* This table has been generated by divtab.c . |
| 54 | Defects for bias -330: |
| 55 | Max defect: 6.081536e-07 at -1.000000e+00 |
| 56 | Min defect: 2.849516e-08 at 1.030651e+00 |
| 57 | Max 2nd step defect: 9.606539e-12 at -1.000000e+00 |
| 58 | Min 2nd step defect: 0.000000e+00 at 0.000000e+00 |
| 59 | Defect at 1: 1.238659e-07 |
| 60 | Defect at -2: 1.061708e-07 */ |
| 61 | |
| 62 | .balign 2 |
| 63 | .type __div_table,@object |
| 64 | .size __div_table,128 |
| 65 | /* negative division constants */ |
| 66 | .word -16638 |
| 67 | .word -17135 |
| 68 | .word -17737 |
| 69 | .word -18433 |
| 70 | .word -19103 |
| 71 | .word -19751 |
| 72 | .word -20583 |
| 73 | .word -21383 |
| 74 | .word -22343 |
| 75 | .word -23353 |
| 76 | .word -24407 |
| 77 | .word -25582 |
| 78 | .word -26863 |
| 79 | .word -28382 |
| 80 | .word -29965 |
| 81 | .word -31800 |
| 82 | /* negative division factors */ |
| 83 | .byte 66 |
| 84 | .byte 70 |
| 85 | .byte 75 |
| 86 | .byte 81 |
| 87 | .byte 87 |
| 88 | .byte 93 |
| 89 | .byte 101 |
| 90 | .byte 109 |
| 91 | .byte 119 |
| 92 | .byte 130 |
| 93 | .byte 142 |
| 94 | .byte 156 |
| 95 | .byte 172 |
| 96 | .byte 192 |
| 97 | .byte 214 |
| 98 | .byte 241 |
| 99 | .skip 16 |
| 100 | .global __div_table |
| 101 | __div_table: |
| 102 | .skip 16 |
| 103 | /* positive division factors */ |
| 104 | .byte 241 |
| 105 | .byte 214 |
| 106 | .byte 192 |
| 107 | .byte 172 |
| 108 | .byte 156 |
| 109 | .byte 142 |
| 110 | .byte 130 |
| 111 | .byte 119 |
| 112 | .byte 109 |
| 113 | .byte 101 |
| 114 | .byte 93 |
| 115 | .byte 87 |
| 116 | .byte 81 |
| 117 | .byte 75 |
| 118 | .byte 70 |
| 119 | .byte 66 |
| 120 | /* positive division constants */ |
| 121 | .word 31801 |
| 122 | .word 29966 |
| 123 | .word 28383 |
| 124 | .word 26864 |
| 125 | .word 25583 |
| 126 | .word 24408 |
| 127 | .word 23354 |
| 128 | .word 22344 |
| 129 | .word 21384 |
| 130 | .word 20584 |
| 131 | .word 19752 |
| 132 | .word 19104 |
| 133 | .word 18434 |
| 134 | .word 17738 |
| 135 | .word 17136 |
| 136 | .word 16639 |