1 #include <stdint.h>
2 #include <stdio.h>
3
4 typedef struct {
5 uint64_t high;
6 uint64_t low;
7 } __attribute__((aligned(16))) quad_word;
8
9
10 /* CDSG needs quad-word alignment */
11 quad_word _op1, _op2, _op3;
12
13 void
test(quad_word op1_init,quad_word op2_init,quad_word op3_init)14 test(quad_word op1_init, quad_word op2_init, quad_word op3_init)
15 {
16 int cc; // unused
17 _op1 = op1_init;
18 _op2 = op2_init;
19 _op3 = op3_init;
20
21 __asm__ volatile (
22 "lmg %%r0,%%r1,%1\n\t"
23 "lmg %%r2,%%r3,%3\n\t"
24 "cdsg %%r0,%%r2,%2\n\t" // cdsg 1st,3rd,2nd
25 "stmg %%r0,%%r1,%1\n" // store r0,r1 to op1
26 "stmg %%r2,%%r3,%3\n" // store r2,r3 to op3
27 : "=d"(cc), "+QS" (_op1), "+QS" (_op2), "+QS" (_op3)
28 :
29 : "r0", "r1", "r2", "r3", "cc");
30 }
31
op1_undefined(void)32 void op1_undefined(void)
33 {
34 quad_word op1, op2, op3;
35
36 // op1 undefined
37 op2.high = op2.low = 42;
38 op3.high = op3.low = 0xdeadbeefdeadbabeull;
39 test(op1, op2, op3); // complaint
40 }
41
op2_undefined(void)42 void op2_undefined(void)
43 {
44 quad_word op1, op2, op3;
45
46 op1.high = op1.low = 42;
47 // op2 undefined
48 op3.high = op3.low = 0xdeadbeefdeadbabeull;
49 test(op1, op2, op3); // complaint
50 }
51
op3_undefined(void)52 void op3_undefined(void)
53 {
54 quad_word op1, op2, op3;
55
56 op1.high = op1.low = 42;
57 op2 = op1;
58 // op3 undefined
59 test(op1, op2, op3); // no complaint; op3 is just copied around
60 }
61
main()62 int main ()
63 {
64 op1_undefined();
65 op2_undefined();
66 op3_undefined();
67
68 return 0;
69 }
70