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