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