root / tests / alpha / test-cond.c @ 9c9efb6b
History | View | Annotate | Download (1.3 kB)
1 | df0fc998 | aurel32 | |
---|---|---|---|
2 | df0fc998 | aurel32 | #ifdef TEST_CMOV
|
3 | df0fc998 | aurel32 | |
4 | df0fc998 | aurel32 | #define TEST_COND(N) \
|
5 | df0fc998 | aurel32 | int test_##N (long a) \ |
6 | df0fc998 | aurel32 | { \ |
7 | df0fc998 | aurel32 | int res = 1; \ |
8 | df0fc998 | aurel32 | \ |
9 | df0fc998 | aurel32 | asm ("cmov"#N" %1,$31,%0" \ |
10 | df0fc998 | aurel32 | : "+r" (res) : "r" (a)); \ |
11 | df0fc998 | aurel32 | return !res; \
|
12 | df0fc998 | aurel32 | } |
13 | df0fc998 | aurel32 | |
14 | df0fc998 | aurel32 | #else
|
15 | df0fc998 | aurel32 | |
16 | df0fc998 | aurel32 | #define TEST_COND(N) \
|
17 | df0fc998 | aurel32 | int test_##N (long a) \ |
18 | df0fc998 | aurel32 | { \ |
19 | df0fc998 | aurel32 | int res = 1; \ |
20 | df0fc998 | aurel32 | \ |
21 | df0fc998 | aurel32 | asm ("b"#N" %1,1f\n\t" \ |
22 | df0fc998 | aurel32 | "addq $31,$31,%0\n\t" \
|
23 | df0fc998 | aurel32 | "1: unop\n" \
|
24 | df0fc998 | aurel32 | : "+r" (res) : "r" (a)); \ |
25 | df0fc998 | aurel32 | return res; \
|
26 | df0fc998 | aurel32 | } |
27 | df0fc998 | aurel32 | |
28 | df0fc998 | aurel32 | #endif
|
29 | df0fc998 | aurel32 | |
30 | df0fc998 | aurel32 | TEST_COND(eq) |
31 | df0fc998 | aurel32 | TEST_COND(ne) |
32 | df0fc998 | aurel32 | TEST_COND(ge) |
33 | df0fc998 | aurel32 | TEST_COND(gt) |
34 | df0fc998 | aurel32 | TEST_COND(lbc) |
35 | df0fc998 | aurel32 | TEST_COND(lbs) |
36 | df0fc998 | aurel32 | TEST_COND(le) |
37 | df0fc998 | aurel32 | TEST_COND(lt) |
38 | df0fc998 | aurel32 | |
39 | df0fc998 | aurel32 | static struct { |
40 | df0fc998 | aurel32 | int (*func)(long); |
41 | df0fc998 | aurel32 | long v;
|
42 | df0fc998 | aurel32 | int r;
|
43 | df0fc998 | aurel32 | } vectors[] = |
44 | df0fc998 | aurel32 | { |
45 | df0fc998 | aurel32 | {test_eq, 0, 1}, |
46 | df0fc998 | aurel32 | {test_eq, 1, 0}, |
47 | df0fc998 | aurel32 | |
48 | df0fc998 | aurel32 | {test_ne, 0, 0}, |
49 | df0fc998 | aurel32 | {test_ne, 1, 1}, |
50 | df0fc998 | aurel32 | |
51 | df0fc998 | aurel32 | {test_ge, 0, 1}, |
52 | df0fc998 | aurel32 | {test_ge, 1, 1}, |
53 | df0fc998 | aurel32 | {test_ge, -1, 0}, |
54 | df0fc998 | aurel32 | |
55 | df0fc998 | aurel32 | {test_gt, 0, 0}, |
56 | df0fc998 | aurel32 | {test_gt, 1, 1}, |
57 | df0fc998 | aurel32 | {test_gt, -1, 0}, |
58 | df0fc998 | aurel32 | |
59 | df0fc998 | aurel32 | {test_lbc, 0, 1}, |
60 | df0fc998 | aurel32 | {test_lbc, 1, 0}, |
61 | df0fc998 | aurel32 | {test_lbc, -1, 0}, |
62 | df0fc998 | aurel32 | |
63 | df0fc998 | aurel32 | {test_lbs, 0, 0}, |
64 | df0fc998 | aurel32 | {test_lbs, 1, 1}, |
65 | df0fc998 | aurel32 | {test_lbs, -1, 1}, |
66 | df0fc998 | aurel32 | |
67 | df0fc998 | aurel32 | {test_le, 0, 1}, |
68 | df0fc998 | aurel32 | {test_le, 1, 0}, |
69 | df0fc998 | aurel32 | {test_le, -1, 1}, |
70 | df0fc998 | aurel32 | |
71 | df0fc998 | aurel32 | {test_lt, 0, 0}, |
72 | df0fc998 | aurel32 | {test_lt, 1, 0}, |
73 | df0fc998 | aurel32 | {test_lt, -1, 1}, |
74 | df0fc998 | aurel32 | }; |
75 | df0fc998 | aurel32 | |
76 | df0fc998 | aurel32 | int main (void) |
77 | df0fc998 | aurel32 | { |
78 | df0fc998 | aurel32 | int i;
|
79 | df0fc998 | aurel32 | |
80 | df0fc998 | aurel32 | for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++) |
81 | df0fc998 | aurel32 | if ((*vectors[i].func)(vectors[i].v) != vectors[i].r) {
|
82 | df0fc998 | aurel32 | write(1, "Failed\n", 7); |
83 | df0fc998 | aurel32 | return 1; |
84 | df0fc998 | aurel32 | } |
85 | df0fc998 | aurel32 | write(1, "OK\n", 3); |
86 | df0fc998 | aurel32 | return 0; |
87 | df0fc998 | aurel32 | } |