Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / tests / tcg / s390x / exrl-trt.c
blob451f777b9d9c6e002f6607be151aeb58e35a2cba
1 #include <stdint.h>
2 #include <unistd.h>
4 int main(void)
6 char op1[] = "hello";
7 char op2[256];
8 register uint64_t r1 asm("r1") = 0xffffffffffffffffull;
9 register uint64_t r2 asm("r2") = 0xffffffffffffffffull;
10 uint64_t cc;
11 int i;
13 for (i = 0; i < 256; i++) {
14 if (i == 0) {
15 op2[i] = 0xaa;
16 } else {
17 op2[i] = 0;
20 asm volatile(
21 " j 2f\n"
22 "1: trt 0(1,%[op1]),%[op2]\n"
23 "2: exrl %[op1_len],1b\n"
24 " ipm %[cc]\n"
25 : [r1] "+r" (r1),
26 [r2] "+r" (r2),
27 [cc] "=r" (cc)
28 : [op1] "a" (&op1),
29 [op1_len] "a" (5),
30 [op2] "Q" (op2)
31 : "cc");
32 cc = (cc >> 28) & 3;
33 if (cc != 2) {
34 write(1, "bad cc\n", 7);
35 return 1;
37 if ((char *)r1 != &op1[5]) {
38 write(1, "bad r1\n", 7);
39 return 1;
41 if (r2 != 0xffffffffffffffaaull) {
42 write(1, "bad r2\n", 7);
43 return 1;
45 return 0;