4 typedef unsigned char UChar
;
5 typedef unsigned int UInt
;
6 typedef signed int Int
;
13 typedef union _V128 V128
;
15 static inline UChar
randUChar ( void )
17 static UInt seed
= 80021;
18 seed
= 1103515245 * seed
+ 12345;
19 return (seed
>> 17) & 0xFF;
22 /* Generates a random V128. */
23 static void randV128 ( /*OUT*/V128
* v
)
25 static UInt nCalls
= 0;
28 for (i
= 0; i
< 16; i
++) {
29 v
->u8
[i
] = randUChar();
31 if (0 == (nCalls
& 0xFF))
32 printf("randV128: %u calls\n", nCalls
);
35 static void showV128 ( V128
* v
)
38 for (i
= 15; i
>= 0; i
--)
39 printf("%02x", (Int
)v
->u8
[i
]);
42 #define GEN_BINARY_TEST_BODY(INSN,SUFFIXD,SUFFIXN,SUFFIXM) \
44 for (i = 0; i < ITERS; i++) { \
46 randV128(&block[0]); \
47 randV128(&block[1]); \
48 randV128(&block[2]); \
49 __asm__ __volatile__( \
51 "ldr q8, [%0, #16];" \
52 "ldr q9, [%0, #32];" \
53 #INSN " v9." #SUFFIXD ", v7." #SUFFIXN ", v8." SUFFIXM " ; " \
54 "str q9, [%0, #32];" \
55 : : "r"(&block[0]) : "memory", "v7", "v8", "v9" \
57 printf(#INSN " v9." #SUFFIXD \
58 ", v7." #SUFFIXN ", v8." SUFFIXM " "); \
59 showV128(&block[0]); printf(" "); \
60 showV128(&block[1]); printf(" "); \
61 showV128(&block[2]); printf("\n"); \
64 #define GEN_BINARY_TEST_BY_ELEM(INSN,SUFFIXD,SUFFIXN,MELEM) \
65 __attribute__((noinline)) \
66 static void test_##INSN##_##SUFFIXD##_##SUFFIXN##_elem_##MELEM () { \
67 GEN_BINARY_TEST_BODY(INSN,SUFFIXD,SUFFIXN,"4b[" #MELEM "]") \
70 #define GEN_BINARY_TEST(INSN,SUFFIXD,SUFFIXN,SUFFIXM) \
71 __attribute__((noinline)) \
72 static void test_##INSN##_##SUFFIXD##_##SUFFIXN##_##SUFFIXM () { \
73 GEN_BINARY_TEST_BODY(INSN,SUFFIXD,SUFFIXN,#SUFFIXM) \
76 GEN_BINARY_TEST(sdot
, 2s
, 8b
, 8b
)
77 GEN_BINARY_TEST(udot
, 2s
, 8b
, 8b
)
78 GEN_BINARY_TEST(sdot
, 4s
, 16b
, 16b
)
79 GEN_BINARY_TEST(udot
, 4s
, 16b
, 16b
)
80 GEN_BINARY_TEST_BY_ELEM(sdot
, 2s
, 8b
, 0)
81 GEN_BINARY_TEST_BY_ELEM(udot
, 2s
, 8b
, 1)
82 GEN_BINARY_TEST_BY_ELEM(sdot
, 4s
, 16b
, 2)
83 GEN_BINARY_TEST_BY_ELEM(udot
, 4s
, 16b
, 3)
87 assert(sizeof(V128
) == 16);
89 // ======================== {S,U}DOT by element ====================
94 test_sdot_2s_8b_elem_0();
95 test_udot_2s_8b_elem_1();
96 test_sdot_4s_16b_elem_2();
97 test_udot_4s_16b_elem_3();
99 // ======================== {S,U}DOT vector ========================
104 test_sdot_2s_8b_8b();
105 test_udot_2s_8b_8b();
106 test_sdot_4s_16b_16b();
107 test_udot_4s_16b_16b();