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