qed: Consistency check support
[qemu.git] / tests / alpha / test-cond.c
blob74adffaa695871530ad0ee59d7af261c6c0b93fc
2 #ifdef TEST_CMOV
4 #define TEST_COND(N) \
5 int test_##N (long a) \
6 { \
7 int res = 1; \
9 asm ("cmov"#N" %1,$31,%0" \
10 : "+r" (res) : "r" (a)); \
11 return !res; \
14 #else
16 #define TEST_COND(N) \
17 int test_##N (long a) \
18 { \
19 int res = 1; \
21 asm ("b"#N" %1,1f\n\t" \
22 "addq $31,$31,%0\n\t" \
23 "1: unop\n" \
24 : "+r" (res) : "r" (a)); \
25 return res; \
28 #endif
30 TEST_COND(eq)
31 TEST_COND(ne)
32 TEST_COND(ge)
33 TEST_COND(gt)
34 TEST_COND(lbc)
35 TEST_COND(lbs)
36 TEST_COND(le)
37 TEST_COND(lt)
39 static struct {
40 int (*func)(long);
41 long v;
42 int r;
43 } vectors[] =
45 {test_eq, 0, 1},
46 {test_eq, 1, 0},
48 {test_ne, 0, 0},
49 {test_ne, 1, 1},
51 {test_ge, 0, 1},
52 {test_ge, 1, 1},
53 {test_ge, -1, 0},
55 {test_gt, 0, 0},
56 {test_gt, 1, 1},
57 {test_gt, -1, 0},
59 {test_lbc, 0, 1},
60 {test_lbc, 1, 0},
61 {test_lbc, -1, 0},
63 {test_lbs, 0, 0},
64 {test_lbs, 1, 1},
65 {test_lbs, -1, 1},
67 {test_le, 0, 1},
68 {test_le, 1, 0},
69 {test_le, -1, 1},
71 {test_lt, 0, 0},
72 {test_lt, 1, 0},
73 {test_lt, -1, 1},
76 int main (void)
78 int i;
80 for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
81 if ((*vectors[i].func)(vectors[i].v) != vectors[i].r) {
82 write(1, "Failed\n", 7);
83 return 1;
85 write(1, "OK\n", 3);
86 return 0;