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