xref: /openbmc/qemu/tests/tcg/s390x/vstl.c (revision f14eced5)
1 /*
2  * Test the VSTL instruction.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 #include <assert.h>
7 #include <stdlib.h>
8 #include "vx.h"
9 
10 static inline void vstl(S390Vector *v1, void *db2, size_t r3)
11 {
12     asm("vstl %[v1],%[r3],%[db2]"
13         : [db2] "=Q" (*(char *)db2)
14         : [v1] "v" (v1->v), [r3] "r" (r3)
15         : "memory");
16 }
17 
18 int main(void)
19 {
20     uint64_t buf[3] = {0x1122334455667788ULL, 0x99aabbccddeeffULL,
21                        0x5a5a5a5a5a5a5a5aULL};
22     S390Vector v = {.d[0] = 0x1234567887654321ULL,
23                     .d[1] = 0x9abcdef00fedcba9ULL};
24 
25     vstl(&v, buf, 0);
26     assert(buf[0] == 0x1222334455667788ULL);
27 
28     vstl(&v, buf, 1);
29     assert(buf[0] == 0x1234334455667788ULL);
30 
31     vstl(&v, buf, -1);
32     assert(buf[0] == 0x1234567887654321ULL);
33     assert(buf[1] == 0x9abcdef00fedcba9ULL);
34     assert(buf[2] == 0x5a5a5a5a5a5a5a5aULL);
35 
36     return EXIT_SUCCESS;
37 }
38