1#include <stdio.h>
2#include "opcodes.h"
3
4#define DO_RXSBG(insn, _r1, _r2, i3, i4, i5)		\
5({							\
6	register unsigned long r1 asm ("1") = _r1;	\
7	register unsigned long r2 asm ("2") = _r2;	\
8	int cc;						\
9	asm volatile(   "clgr 1,2\n"                    \
10                        insn(1,2, i3, i4, i5)           \
11			"ipm %1\n"			\
12			"srl %1,28\n"			\
13			: "+d" (r1), "=d" (cc)		\
14			: "d" (r1), "d" (r2)		\
15			: "cc");			\
16	printf(#insn " r1(==%16.16lX),r2(==%16.16lX),0x" #i3 ",0x" #i4 ",0x" #i5 " = %16.16lX (cc=%d)\n", _r1, _r2, r1, cc); \
17})
18
19#define r1sweep(i, r2, i3, i4, i5)				\
20({								\
21	DO_RXSBG(i, 000000000000000000ul, r2, i3, i4, i5);	\
22	DO_RXSBG(i, 0x0000ffffccccaaaaul, r2, i3, i4, i5);	\
23	DO_RXSBG(i, 0xfffffffffffffffful, r2, i3, i4, i5);	\
24})
25
26#define r2sweep(i, i3, i4, i5)				\
27({							\
28	r1sweep(i, 0x0000000000000000ul, i3, i4, i5);	\
29	r1sweep(i, 0x5555ccccffff0000ul, i3, i4, i5);	\
30	r1sweep(i, 0xfffffffffffffffful, i3, i4, i5);	\
31})
32
33
34/* min/max z=0/1 and some random number in the middle */
35#define i3sweep(i, i4, i5)		\
36({					\
37	r2sweep(i, 00, i4, i5);		\
38	r2sweep(i, 14, i4, i5);		\
39	r2sweep(i, 3f, i4, i5);		\
40	r2sweep(i, 80, i4, i5);		\
41	r2sweep(i, a1, i4, i5);		\
42	r2sweep(i, bf, i4, i5);		\
43})
44
45/* min/max t=0/1 and some random number in the middle */
46#define i4sweep(i, i5)			\
47({					\
48	i3sweep(i, 00, i5);		\
49	i3sweep(i, 2a, i5);		\
50	i3sweep(i, 3f, i5);		\
51	i3sweep(i, 80, i5);		\
52	i3sweep(i, 9e, i5);		\
53	i3sweep(i, bf, i5);		\
54})
55
56/* min/max and other shifts */
57#define i5sweep(i)		\
58({				\
59	i4sweep(i, 00);		\
60	i4sweep(i, 01);		\
61	i4sweep(i, 13);		\
62	i4sweep(i, 3e);		\
63	i4sweep(i, 3f);		\
64})
65
66
67
68
69
70
71int main()
72{
73	i5sweep(RISBG);
74	i5sweep(RNSBG);
75	i5sweep(ROSBG);
76	i5sweep(RXSBG);
77        i5sweep(RISBGN);
78
79	return 0;
80}
81