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