xref: /qemu/tests/tcg/s390x/rxsbg.c (revision 86d063fa)
1 /*
2  * Test the RXSBG instruction.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 #include <assert.h>
7 #include <stdlib.h>
8 
9 static inline __attribute__((__always_inline__)) void
10 rxsbg(unsigned long *r1, unsigned long r2, int i3, int i4, int i5, int *cc)
11 {
12     asm("rxsbg %[r1],%[r2],%[i3],%[i4],%[i5]\n"
13         "ipm %[cc]"
14         : [r1] "+r" (*r1), [cc] "=r" (*cc)
15         : [r2] "r" (r2) , [i3] "i" (i3) , [i4] "i" (i4) , [i5] "i" (i5)
16         : "cc");
17     *cc = (*cc >> 28) & 3;
18 }
19 
20 void test_cc0(void)
21 {
22     unsigned long r1 = 6;
23     int cc;
24 
25     rxsbg(&r1, 3, 61 | 0x80, 62, 1, &cc);
26     assert(r1 == 6);
27     assert(cc == 0);
28 }
29 
30 void test_cc1(void)
31 {
32     unsigned long r1 = 2;
33     int cc;
34 
35     rxsbg(&r1, 3, 61 | 0x80, 62, 1, &cc);
36     assert(r1 == 2);
37     assert(cc == 1);
38 }
39 
40 int main(void)
41 {
42     test_cc0();
43     test_cc1();
44 
45     return EXIT_SUCCESS;
46 }
47