| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0 */
|
| 2 | |
| 3 | |
| 4 | |
| 5 |
|
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 |
|
| 12 | ENTRY(__umulsidi3)
|
| 13 |
|
| 14 | |
| 15 | abi_entry(32)
|
| 16 | s32i a12, sp, 16
|
| 17 | s32i a13, sp, 20
|
| 18 | s32i a14, sp, 24
|
| 19 | s32i a15, sp, 28
|
| 20 | |
| 21 | /* This is not really a leaf function; allocate enough stack space
|
| 22 | to allow CALL12s to a helper function. */
|
| 23 | abi_entry(32)
|
| 24 | |
| 25 | abi_entry_default
|
| 26 | |
| 27 |
|
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 |
|
| 36 | /* This code is taken from the mulsf3 routine in ieee754-sf.S.
|
| 37 | See more comments there. */
|
| 38 |
|
| 39 | |
| 40 | mull a6, a2, a3
|
| 41 | muluh wh, a2, a3
|
| 42 | mov wl, a6
|
| 43 |
|
| 44 | |
| 45 |
|
| 46 | |
| 47 | /* a0 and a8 will be clobbered by calling the multiply function
|
| 48 | but a8 is not used here and need not be saved. */
|
| 49 | s32i a0, sp, 0
|
| 50 | |
| 51 |
|
| 52 | |
| 53 |
|
| 54 | |
| 55 | |
| 56 |
|
| 57 | /* Get the high halves of the inputs into registers. */
|
| 58 | srli a2h, a2, 16
|
| 59 | srli a3h, a3, 16
|
| 60 |
|
| 61 | |
| 62 | |
| 63 |
|
| 64 | |
| 65 | /* Clear the high halves of the inputs. This does not matter
|
| 66 | for MUL16 because the high bits are ignored. */
|
| 67 | extui a2, a2, 0, 16
|
| 68 | extui a3, a3, 0, 16
|
| 69 | |
| 70 | |
| 71 |
|
| 72 |
|
| 73 | |
| 74 |
|
| 75 | |
| 76 | mul16u dst, xreg |
| 77 |
|
| 78 | |
| 79 |
|
| 80 | |
| 81 | mull dst, xreg |
| 82 |
|
| 83 | |
| 84 |
|
| 85 | /* The preprocessor insists on inserting a space when concatenating after
|
| 86 | a period in the definition of do_mul below. These macros are a workaround
|
| 87 | using underscores instead of periods when doing the concatenation. */
|
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 |
|
| 93 | |
| 94 | umul_aa_ |
| 95 | rsr dst, ACCLO
|
| 96 |
|
| 97 | |
| 98 |
|
| 99 | |
| 100 | extui dst, src, 0, 16
|
| 101 | |
| 102 | srli dst, src, 16
|
| 103 |
|
| 104 | |
| 105 | |
| 106 | set_arg_ |
| 107 | set_arg_ |
| 108 | call0 .Lmul_mulsi3; \
|
| 109 | mov dst, a12
|
| 110 | |
| 111 | |
| 112 | set_arg_ |
| 113 | set_arg_ |
| 114 | call12 .Lmul_mulsi3; \
|
| 115 | mov dst, a14
|
| 116 | |
| 117 |
|
| 118 | |
| 119 |
|
| 120 | /* Add pp1 and pp2 into a6 with carry-out in a9. */
|
| 121 | do_mul(a6, a2, l, a3, h) /* pp 1 */
|
| 122 | do_mul(a11, a2, h, a3, l) /* pp 2 */
|
| 123 | movi a9, 0
|
| 124 | add a6, a6, a11
|
| 125 | bgeu a6, a11, 1f
|
| 126 | addi a9, a9, 1
|
| 127 | 1:
|
| 128 | /* Shift the high half of a9/a6 into position in a9. Note that
|
| 129 | this value can be safely incremented without any carry-outs. */
|
| 130 | ssai 16
|
| 131 | src a9, a9, a6
|
| 132 |
|
| 133 | /* Compute the low word into a6. */
|
| 134 | do_mul(a11, a2, l, a3, l) /* pp 0 */
|
| 135 | sll a6, a6
|
| 136 | add a6, a6, a11
|
| 137 | bgeu a6, a11, 1f
|
| 138 | addi a9, a9, 1
|
| 139 | 1:
|
| 140 | /* Compute the high word into wh. */
|
| 141 | do_mul(wh, a2, h, a3, h) /* pp 3 */
|
| 142 | add wh, wh, a9
|
| 143 | mov wl, a6
|
| 144 |
|
| 145 | |
| 146 |
|
| 147 | |
| 148 | /* Restore the original return address. */
|
| 149 | l32i a0, sp, 0
|
| 150 | |
| 151 | |
| 152 | l32i a12, sp, 16
|
| 153 | l32i a13, sp, 20
|
| 154 | l32i a14, sp, 24
|
| 155 | l32i a15, sp, 28
|
| 156 | abi_ret(32)
|
| 157 | |
| 158 | abi_ret_default
|
| 159 | |
| 160 |
|
| 161 | |
| 162 |
|
| 163 | .macro do_addx2 dst, as, at, tmp
|
| 164 | |
| 165 | addx2 \dst, \as, \at
|
| 166 | |
| 167 | slli \tmp, \as, 1
|
| 168 | add \dst, \tmp, \at
|
| 169 | |
| 170 | .endm
|
| 171 |
|
| 172 | .macro do_addx4 dst, as, at, tmp
|
| 173 | |
| 174 | addx4 \dst, \as, \at
|
| 175 | |
| 176 | slli \tmp, \as, 2
|
| 177 | add \dst, \tmp, \at
|
| 178 | |
| 179 | .endm
|
| 180 |
|
| 181 | .macro do_addx8 dst, as, at, tmp
|
| 182 | |
| 183 | addx8 \dst, \as, \at
|
| 184 | |
| 185 | slli \tmp, \as, 3
|
| 186 | add \dst, \tmp, \at
|
| 187 | |
| 188 | .endm
|
| 189 |
|
| 190 | /* For Xtensa processors with no multiply hardware, this simplified
|
| 191 | version of _mulsi3 is used for multiplying 16-bit chunks of
|
| 192 | the floating-point mantissas. When using CALL0, this function
|
| 193 | uses a custom ABI: the inputs are passed in a13 and a14, the
|
| 194 | result is returned in a12, and a8 and a15 are clobbered. */
|
| 195 | .align 4
|
| 196 | .Lmul_mulsi3:
|
| 197 | abi_entry_default
|
| 198 |
|
| 199 | .macro mul_mulsi3_body dst, src1, src2, tmp1, tmp2
|
| 200 | movi \dst, 0
|
| 201 | 1: add \tmp1, \src2, \dst
|
| 202 | extui \tmp2, \src1, 0, 1
|
| 203 | movnez \dst, \tmp1, \tmp2
|
| 204 |
|
| 205 | do_addx2 \tmp1, \src2, \dst, \tmp1
|
| 206 | extui \tmp2, \src1, 1, 1
|
| 207 | movnez \dst, \tmp1, \tmp2
|
| 208 |
|
| 209 | do_addx4 \tmp1, \src2, \dst, \tmp1
|
| 210 | extui \tmp2, \src1, 2, 1
|
| 211 | movnez \dst, \tmp1, \tmp2
|
| 212 |
|
| 213 | do_addx8 \tmp1, \src2, \dst, \tmp1
|
| 214 | extui \tmp2, \src1, 3, 1
|
| 215 | movnez \dst, \tmp1, \tmp2
|
| 216 |
|
| 217 | srli \src1, \src1, 4
|
| 218 | slli \src2, \src2, 4
|
| 219 | bnez \src1, 1b
|
| 220 | .endm
|
| 221 |
|
| 222 | |
| 223 | mul_mulsi3_body a12, a13, a14, a15, a8
|
| 224 | |
| 225 | /* The result will be written into a2, so save that argument in a4. */
|
| 226 | mov a4, a2
|
| 227 | mul_mulsi3_body a2, a4, a3, a5, a6
|
| 228 | |
| 229 | abi_ret_default
|
| 230 | |
| 231 |
|
| 232 | ENDPROC(__umulsidi3)
|
| 233 | EXPORT_SYMBOL(__umulsidi3)
|