1 /* SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0 */
2 #include <linux/linkage.h>
3 #include <asm/asmmacro.h>
6 .macro do_addx2 dst, as, at, tmp
15 .macro do_addx4 dst, as, at, tmp
24 .macro do_addx8 dst, as, at, tmp
40 #elif XCHAL_HAVE_MUL16
56 #elif XCHAL_HAVE_MAC16
65 #else /* !MUL32 && !MUL16 && !MAC16 */
67 /* Multiply one bit at a time, but unroll the loop 4x to better
68 exploit the addx instructions and avoid overhead.
69 Peel the first iteration to save a cycle on init. */
71 /* Avoid negative numbers. */
72 xor a5, a2, a3 /* Top bit is 1 if one input is negative. */
76 /* Swap so the second argument is smaller. */
79 movgez a4, a2, a7 /* a4 = max (a2, a3) */
80 movltz a3, a2, a7 /* a3 = min (a2, a3) */
86 do_addx2 a7, a4, a2, a7
90 do_addx4 a7, a4, a2, a7
94 do_addx8 a7, a4, a2, a7
98 bgeui a3, 16, .Lmult_main_loop
112 do_addx2 a7, a4, a2, a7
116 do_addx4 a7, a4, a2, a7
120 do_addx8 a7, a4, a2, a7
124 bgeui a3, 16, .Lmult_main_loop
129 #endif /* !MUL32 && !MUL16 && !MAC16 */