@samitouri / QOSamiQemu / commits / 2458f0cab5

tests/tcg/loongarch64: Tidy test_bit.c

Use one macro for all test templates. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Richard Henderson committed Aug 10, 2026 at 12:26 UTC 2458f0cab5aaa21117f2a151e2f4f1e7d4f9d0ce
1 file changed +14 -53
tests/tcg/loongarch64/test_bit.c
+14 -53
@@ -2,62 +2,23 @@
2 #include <inttypes.h>
3
4 #define ARRAY_SIZE(X) (sizeof(X) / sizeof(*(X)))
5 -#define TEST_CLO(N) \
6 -static uint64_t test_clo_##N(uint64_t rj) \
7 -{ \
8 - uint64_t rd = 0; \
9 - \
10 - asm volatile("clo."#N" %0, %1\n\t" \
11 - : "=r"(rd) \
12 - : "r"(rj) \
13 - : ); \
14 - return rd; \
15 -}
16 -
17 -#define TEST_CLZ(N) \
18 -static uint64_t test_clz_##N(uint64_t rj) \
19 -{ \
20 - uint64_t rd = 0; \
21 - \
22 - asm volatile("clz."#N" %0, %1\n\t" \
23 - : "=r"(rd) \
24 - : "r"(rj) \
25 - : ); \
26 - return rd; \
27 -}
28 -
29 -#define TEST_CTO(N) \
30 -static uint64_t test_cto_##N(uint64_t rj) \
31 -{ \
32 - uint64_t rd = 0; \
33 - \
34 - asm volatile("cto."#N" %0, %1\n\t" \
35 - : "=r"(rd) \
36 - : "r"(rj) \
37 - : ); \
38 - return rd; \
39 -}
5
41 -#define TEST_CTZ(N) \
42 -static uint64_t test_ctz_##N(uint64_t rj) \
43 -{ \
44 - uint64_t rd = 0; \
45 - \
46 - asm volatile("ctz."#N" %0, %1\n\t" \
47 - : "=r"(rd) \
48 - : "r"(rj) \
49 - : ); \
50 - return rd; \
6 +#define TEST(C, I) \
7 +static uint64_t test_##C(uint64_t rj) \
8 +{ \
9 + uint64_t rd; \
10 + asm volatile(I " %0, %1\n\t" : "=r"(rd) : "r"(rj)); \
11 + return rd; \
12 }
13
53 -TEST_CLO(w)
54 -TEST_CLO(d)
55 -TEST_CLZ(w)
56 -TEST_CLZ(d)
57 -TEST_CTO(w)
58 -TEST_CTO(d)
59 -TEST_CTZ(w)
60 -TEST_CTZ(d)
14 +TEST(clo_w, "clo.w")
15 +TEST(clo_d, "clo.d")
16 +TEST(clz_w, "clz.w")
17 +TEST(clz_d, "clz.d")
18 +TEST(cto_w, "cto.w")
19 +TEST(cto_d, "cto.d")
20 +TEST(ctz_w, "ctz.w")
21 +TEST(ctz_d, "ctz.d")
22
23 struct vector {
24 uint64_t (*func)(uint64_t);