xref: /openbmc/qemu/tests/tcg/s390x/mie3-sel.c (revision d0bf492f)
1 #include <stdint.h>
2 
3 
4 #define Fi3(S, ASM) uint64_t S(uint64_t a, uint64_t b, uint64_t c) \
5 {                       \
6 asm volatile (          \
7     "ltgr %[c], %[c]\n" \
8     ASM                 \
9     : [c] "+r" (c)      \
10     : [a]  "r" (a)      \
11     , [b]  "r" (b)      \
12 );                      \
13     return c;           \
14 }
15 
16 Fi3 (_selre,     ".insn rrf, 0xB9F00000, %[c], %[b], %[a], 8\n")
17 Fi3 (_selgrz,    ".insn rrf, 0xB9E30000, %[c], %[b], %[a], 8\n")
18 Fi3 (_selfhrnz,  ".insn rrf, 0xB9C00000, %[c], %[b], %[a], 7\n")
19 
20 
21 int main(int argc, char *argv[])
22 {
23     uint64_t a = ~0, b = ~0, c = ~0;
24 
25     a =    _selre(0x066600000066ull, 0x066600000006ull, a);
26     b =   _selgrz(0xF00D00000005ull, 0xF00D00000055ull, b);
27     c = _selfhrnz(0x043200000044ull, 0x065400000004ull, c);
28 
29     return (int) (
30         (0xFFFFFFFF00000066ull != a) ||
31         (0x0000F00D00000005ull != b) ||
32         (0x00000654FFFFFFFFull != c));
33 }
34