Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / s390x / vxeh2_vlstr.c
blobcf971150cffe8121f64628102b9e0aa438532479
1 /*
2 * vxeh2_vlstr: vector-enhancements facility 2 vector load/store reversed *
3 */
4 #include <stdint.h>
5 #include "vx.h"
7 #define vtst(v1, v2) \
8 if (v1.d[0] != v2.d[0] || v1.d[1] != v2.d[1]) { \
9 return 1; \
12 static inline void vler(S390Vector *v1, const void *va, uint8_t m3)
14 asm volatile("vler %[v1], 0(%[va]), %[m3]\n"
15 : [v1] "+v" (v1->v)
16 : [va] "a" (va)
17 , [m3] "i" (m3)
18 : "memory");
21 static inline void vster(S390Vector *v1, const void *va, uint8_t m3)
23 asm volatile("vster %[v1], 0(%[va]), %[m3]\n"
24 : [va] "+a" (va)
25 : [v1] "v" (v1->v)
26 , [m3] "i" (m3)
27 : "memory");
30 static inline void vlbr(S390Vector *v1, void *va, const uint8_t m3)
32 asm volatile("vlbr %[v1], 0(%[va]), %[m3]\n"
33 : [v1] "+v" (v1->v)
34 : [va] "a" (va)
35 , [m3] "i" (m3)
36 : "memory");
39 static inline void vstbr(S390Vector *v1, void *va, const uint8_t m3)
41 asm volatile("vstbr %[v1], 0(%[va]), %[m3]\n"
42 : [va] "+a" (va)
43 : [v1] "v" (v1->v)
44 , [m3] "i" (m3)
45 : "memory");
49 static inline void vlebrh(S390Vector *v1, void *va, const uint8_t m3)
51 asm volatile("vlebrh %[v1], 0(%[va]), %[m3]\n"
52 : [v1] "+v" (v1->v)
53 : [va] "a" (va)
54 , [m3] "i" (m3)
55 : "memory");
58 static inline void vstebrh(S390Vector *v1, void *va, const uint8_t m3)
60 asm volatile("vstebrh %[v1], 0(%[va]), %[m3]\n"
61 : [va] "+a" (va)
62 : [v1] "v" (v1->v)
63 , [m3] "i" (m3)
64 : "memory");
67 static inline void vllebrz(S390Vector *v1, void *va, const uint8_t m3)
69 asm volatile("vllebrz %[v1], 0(%[va]), %[m3]\n"
70 : [v1] "+v" (v1->v)
71 : [va] "a" (va)
72 , [m3] "i" (m3)
73 : "memory");
76 static inline void vlbrrep(S390Vector *v1, void *va, const uint8_t m3)
78 asm volatile("vlbrrep %[v1], 0(%[va]), %[m3]\n"
79 : [v1] "+v" (v1->v)
80 : [va] "a" (va)
81 , [m3] "i" (m3)
82 : "memory");
85 int main(int argc, char *argv[])
87 S390Vector vd = { .d[0] = 0, .d[1] = 0 };
88 S390Vector vs = { .d[0] = 0x8FEEDDCCBBAA9988ull,
89 .d[1] = 0x7766554433221107ull };
91 const S390Vector vt_v_er16 = {
92 .h[0] = 0x1107, .h[1] = 0x3322, .h[2] = 0x5544, .h[3] = 0x7766,
93 .h[4] = 0x9988, .h[5] = 0xBBAA, .h[6] = 0xDDCC, .h[7] = 0x8FEE };
95 const S390Vector vt_v_br16 = {
96 .h[0] = 0xEE8F, .h[1] = 0xCCDD, .h[2] = 0xAABB, .h[3] = 0x8899,
97 .h[4] = 0x6677, .h[5] = 0x4455, .h[6] = 0x2233, .h[7] = 0x0711 };
99 int ix;
100 uint64_t ss64 = 0xFEEDFACE0BADBEEFull, sd64 = 0;
102 vler(&vd, &vs, ES16);
103 vtst(vd, vt_v_er16);
105 vster(&vs, &vd, ES16);
106 vtst(vd, vt_v_er16);
108 vlbr(&vd, &vs, ES16);
109 vtst(vd, vt_v_br16);
111 vstbr(&vs, &vd, ES16);
112 vtst(vd, vt_v_br16);
114 vlebrh(&vd, &ss64, 5);
115 if (0xEDFE != vd.h[5]) {
116 return 1;
119 vstebrh(&vs, (uint8_t *)&sd64 + 4, 7);
120 if (0x0000000007110000ull != sd64) {
121 return 1;
124 vllebrz(&vd, (uint8_t *)&ss64 + 3, 2);
125 for (ix = 0; ix < 4; ix++) {
126 if (vd.w[ix] != (ix != 1 ? 0 : 0xBEAD0BCE)) {
127 return 1;
131 vlbrrep(&vd, (uint8_t *)&ss64 + 4, 1);
132 for (ix = 0; ix < 8; ix++) {
133 if (0xAD0B != vd.h[ix]) {
134 return 1;
138 return 0;