xref: /openbmc/qemu/tests/tcg/aarch64/sme-smopa-2.c (revision d572bcb2)
1 #include <stdio.h>
2 #include <string.h>
3 
main()4 int main()
5 {
6     static const long cmp[4][4] = {
7         {  110,  134,  158,  182 },
8         {  390,  478,  566,  654 },
9         {  670,  822,  974, 1126 },
10         {  950, 1166, 1382, 1598 }
11     };
12     long dst[4][4];
13     long *tmp = &dst[0][0];
14     long svl;
15 
16     /* Validate that we have a wide enough vector for 4 elements. */
17     asm(".arch armv8-r+sme-i64\n\trdsvl %0, #1" : "=r"(svl));
18     if (svl < 32) {
19         return 0;
20     }
21 
22     asm volatile(
23         "smstart\n\t"
24         "index z0.h, #0, #1\n\t"
25         "movprfx z1, z0\n\t"
26         "add z1.h, z1.h, #16\n\t"
27         "ptrue p0.b\n\t"
28         "smopa za0.d, p0/m, p0/m, z0.h, z1.h\n\t"
29         "ptrue p0.d, vl4\n\t"
30         "mov w12, #0\n\t"
31         "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t"
32         "add %0, %0, #32\n\t"
33         "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t"
34         "mov w12, #2\n\t"
35         "add %0, %0, #32\n\t"
36         "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t"
37         "add %0, %0, #32\n\t"
38         "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t"
39         "smstop"
40         : "+r"(tmp) : : "memory");
41 
42     if (memcmp(cmp, dst, sizeof(dst)) == 0) {
43         return 0;
44     }
45 
46     /* See above for correct results. */
47     for (int i = 0; i < 4; ++i) {
48         for (int j = 0; j < 4; ++j) {
49             printf("%6ld", dst[i][j]);
50         }
51         printf("\n");
52     }
53     return 1;
54 }
55