3 /* -- Logical instructions -- */
5 #define TEST_GENERATE(opcode,insn) \
6 static void test_##insn(unsigned long a, unsigned long b) \
8 unsigned long out = 0xdecaffee42424242; \
12 "cr 0,0\n\t" /* Clear CC */ \
13 ".insn rrf,0x" #opcode "0000,%[out],%[a],%[b],0\n\t" \
22 printf("\t%016lx %016lx -> %016lx cc=%d\n", \
26 #define TEST_EXEC(opcode,insn) \
32 test_##insn(-1, -1); \
33 test_##insn(0x012345678abcdef, 0); \
34 test_##insn(0x012345678abcdef, -1); \
35 test_##insn(0x55555555aaaaaaaa, 0xaaaaaaaa55555555); \
50 #define XTEST TEST_GENERATE
54 static void test_all_logical_insns()
56 #define XTEST TEST_EXEC
65 /* -- Full population count -- */
67 static void test_popcnt(unsigned long op2
)
72 __asm__(".insn rrf,0xb9e10000,%[result],%[op2],8,0\n\t"
75 : [result
]"=d" (result
),
79 printf("\t%016lx -> %2lu cc=%d\n", op2
, result
, cc
);
82 static int test_all_popcnt()
87 test_popcnt(0x8000000000000000);
89 test_popcnt(0xff427e3800556bcd);
95 #define TEST_GENERATE(opcode,insn) \
96 static void test_##insn(unsigned long a, unsigned long b) \
98 unsigned long out0 = 0x0cafebad0badcafe; \
99 unsigned long out1 = 0x0badcafe0cafebad; \
102 "cr 0,0\n\t" /* Clear CC */ \
103 ".insn rrf,0x" #opcode "0000,%[out0],%[a],%[b],8\n\t" \
104 ".insn rrf,0x" #opcode "0000,%[out1],%[a],%[b],7\n\t" \
105 : [out0] "+d" (out0), \
111 printf("\t%016lx %016lx -> %016lx %016lx\n", \
115 #define TEST_EXEC(opcode,insn) \
118 test_##insn(-1, 0); \
119 test_##insn(0, -1); \
120 test_##insn(0x1234567890abcdef, 0xfedcba9876543210); \
128 #define XTEST TEST_GENERATE
132 static void test_all_select()
134 #define XTEST TEST_EXEC
143 /* -- Move right to left -- */
145 static void test_mvcrl(char *to
, char *from
, size_t len
)
148 __asm__("lgr 0,%[len]\n\t"
149 ".insn sse,0xe50a00000000,%[to],%[from]\n\t"
150 : [to
] "+Q" (*(char (*)[len
]) to
)
151 : [from
] "Q" (*(char (*)[len
]) from
),
156 static void test_all_mvcrl()
158 static const char pattern
[] =
159 "abcdefghijklmnopqrstuvwxyz-0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZ";
160 char buf
[4 * sizeof(pattern
) - 2];
162 test_mvcrl(buf
, (char *) pattern
, sizeof(pattern
));
163 test_mvcrl(buf
+ sizeof(pattern
) - 1, buf
, sizeof(pattern
));
164 test_mvcrl(buf
+ 2 * sizeof(pattern
) - 2, buf
, 2 * sizeof(pattern
) - 1);
165 test_mvcrl(buf
+ 32, buf
+ 10, 63);
166 test_mvcrl(buf
+ 2, buf
+ 1, 256);
167 test_mvcrl(buf
+ 254, buf
+ 256, 2);
169 for (int i
= 0; i
< 256; i
+= 64) {
170 printf("\t%.64s\n", buf
+ i
);
177 test_all_logical_insns();