xref: /openbmc/qemu/tests/tcg/s390x/mie3-compl.c (revision 90f9e35b)
1 #include <stdint.h>
2 
3 #define FbinOp(S, ASM) uint64_t S(uint64_t a, uint64_t b) \
4 { \
5     uint64_t res = 0; \
6     asm ("llihf %[res],801\n" ASM \
7          : [res]"=&r"(res) : [a]"r"(a), [b]"r"(b) : "cc"); \
8     return res; \
9 }
10 
11 /* AND WITH COMPLEMENT */
12 FbinOp(_ncrk,  ".insn rrf, 0xB9F50000, %[res], %[b], %[a], 0\n")
13 FbinOp(_ncgrk, ".insn rrf, 0xB9E50000, %[res], %[b], %[a], 0\n")
14 
15 /* NAND */
16 FbinOp(_nnrk,  ".insn rrf, 0xB9740000, %[res], %[b], %[a], 0\n")
17 FbinOp(_nngrk, ".insn rrf, 0xB9640000, %[res], %[b], %[a], 0\n")
18 
19 /* NOT XOR */
20 FbinOp(_nxrk,  ".insn rrf, 0xB9770000, %[res], %[b], %[a], 0\n")
21 FbinOp(_nxgrk, ".insn rrf, 0xB9670000, %[res], %[b], %[a], 0\n")
22 
23 /* NOR */
24 FbinOp(_nork,  ".insn rrf, 0xB9760000, %[res], %[b], %[a], 0\n")
25 FbinOp(_nogrk, ".insn rrf, 0xB9660000, %[res], %[b], %[a], 0\n")
26 
27 /* OR WITH COMPLEMENT */
28 FbinOp(_ocrk,  ".insn rrf, 0xB9750000, %[res], %[b], %[a], 0\n")
29 FbinOp(_ocgrk, ".insn rrf, 0xB9650000, %[res], %[b], %[a], 0\n")
30 
31 int main(int argc, char *argv[])
32 {
33     if (_ncrk(0xFF88, 0xAA11)  != 0x0000032100000011ull ||
34         _nnrk(0xFF88, 0xAA11)  != 0x00000321FFFF55FFull ||
35         _nork(0xFF88, 0xAA11)  != 0x00000321FFFF0066ull ||
36         _nxrk(0xFF88, 0xAA11)  != 0x00000321FFFFAA66ull ||
37         _ocrk(0xFF88, 0xAA11)  != 0x00000321FFFFAA77ull ||
38         _ncgrk(0xFF88, 0xAA11) != 0x0000000000000011ull ||
39         _nngrk(0xFF88, 0xAA11) != 0xFFFFFFFFFFFF55FFull ||
40         _nogrk(0xFF88, 0xAA11) != 0xFFFFFFFFFFFF0066ull ||
41         _nxgrk(0xFF88, 0xAA11) != 0xFFFFFFFFFFFFAA66ull ||
42         _ocgrk(0xFF88, 0xAA11) != 0xFFFFFFFFFFFFAA77ull)
43     {
44         return 1;
45     }
46 
47     return 0;
48 }
49