1 /* SPDX-License-Identifier: GPL-2.0-or-later */
7 int64_t mac_w(int64_t mac
, const int16_t *a
, const int16_t *b
)
9 register uint32_t macl
__asm__("macl") = mac
;
10 register uint32_t mach
__asm__("mach") = mac
>> 32;
12 asm volatile("mac.w @%0+,@%1+"
13 : "+r"(a
), "+r"(b
), "+x"(macl
), "+x"(mach
));
15 return ((uint64_t)mach
<< 32) | macl
;
24 __attribute__((noinline
))
25 void test(const Test
*t
, int sat
)
34 res
= mac_w(t
->mac
, &t
->a
, &t
->b
);
36 if (res
!= t
->res
[sat
]) {
37 fprintf(stderr
, "%#llx + (%#x * %#x) = %#llx -- got %#llx\n",
38 t
->mac
, t
->a
, t
->b
, t
->res
[sat
], res
);
45 static const Test tests
[] = {
46 { 0, 2, 3, { 6, 6 } },
47 { 0x123456787ffffffell
, 2, -3,
48 { 0x123456787ffffff8ll
, 0x123456787ffffff8ll
} },
49 { 0xabcdef127ffffffall
, 2, 3,
50 { 0xabcdef1280000000ll
, 0x000000017fffffffll
} },
51 { 0xfffffffffll
, INT16_MAX
, INT16_MAX
,
52 { 0x103fff0000ll
, 0xf3fff0000ll
} },
55 for (int i
= 0; i
< sizeof(tests
) / sizeof(tests
[0]); ++i
) {
56 for (int j
= 0; j
< 2; ++j
) {