xref: /openbmc/qemu/tests/tcg/aarch64/sme-fmopa-2.c (revision e69b2c67)
1 /*
2  * SME outer product, FZ vs FZ16
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  */
5 
6 #include <stdint.h>
7 #include <stdio.h>
8 
9 static void test_fmopa(uint32_t *result)
10 {
11     asm(".arch_extension sme\n\t"
12         "smstart\n\t"               /* Z*, P* and ZArray cleared */
13         "ptrue p2.b, vl16\n\t"      /* Limit vector length to 16 */
14         "ptrue p5.b, vl16\n\t"
15         "movi d0, #0x00ff\n\t"      /* fp16 denormal */
16         "movi d16, #0x00ff\n\t"
17         "mov w15, #0x0001000000\n\t" /* FZ=1, FZ16=0 */
18         "msr fpcr, x15\n\t"
19         "fmopa za3.s, p2/m, p5/m, z16.h, z0.h\n\t"
20         "mov w15, #0\n\t"
21         "st1w {za3h.s[w15, 0]}, p2, [%0]\n\t"
22         "add %0, %0, #16\n\t"
23         "st1w {za3h.s[w15, 1]}, p2, [%0]\n\t"
24         "mov w15, #2\n\t"
25         "add %0, %0, #16\n\t"
26         "st1w {za3h.s[w15, 0]}, p2, [%0]\n\t"
27         "add %0, %0, #16\n\t"
28         "st1w {za3h.s[w15, 1]}, p2, [%0]\n\t"
29         "smstop"
30         : "+r"(result) :
31         : "x15", "x16", "p2", "p5", "d0", "d16", "memory");
32 }
33 
34 int main(void)
35 {
36     uint32_t result[4 * 4] = { };
37 
38     test_fmopa(result);
39 
40     if (result[0] != 0x2f7e0100) {
41         printf("Test failed: Incorrect output in first 4 bytes\n"
42                "Expected: %08x\n"
43                "Got:      %08x\n",
44                0x2f7e0100, result[0]);
45         return 1;
46     }
47 
48     for (int i = 1; i < 16; ++i) {
49         if (result[i] != 0) {
50             printf("Test failed: Non-zero word at position %d\n", i);
51             return 1;
52         }
53     }
54 
55     return 0;
56 }
57