1 2#ifdef TEST_CMOV 3 4#define TEST_COND(N) \ 5int test_##N (long a) \ 6{ \ 7 int res = 1; \ 8 \ 9 asm ("cmov"#N" %1,$31,%0" \ 10 : "+r" (res) : "r" (a)); \ 11 return !res; \ 12} 13 14#else 15 16#define TEST_COND(N) \ 17int test_##N (long a) \ 18{ \ 19 int res = 1; \ 20 \ 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; \ 26} 27 28#endif 29 30TEST_COND(eq) 31TEST_COND(ne) 32TEST_COND(ge) 33TEST_COND(gt) 34TEST_COND(lbc) 35TEST_COND(lbs) 36TEST_COND(le) 37TEST_COND(lt) 38 39static struct { 40 int (*func)(long); 41 long v; 42 int r; 43} vectors[] = 44 { 45 {test_eq, 0, 1}, 46 {test_eq, 1, 0}, 47 48 {test_ne, 0, 0}, 49 {test_ne, 1, 1}, 50 51 {test_ge, 0, 1}, 52 {test_ge, 1, 1}, 53 {test_ge, -1, 0}, 54 55 {test_gt, 0, 0}, 56 {test_gt, 1, 1}, 57 {test_gt, -1, 0}, 58 59 {test_lbc, 0, 1}, 60 {test_lbc, 1, 0}, 61 {test_lbc, -1, 0}, 62 63 {test_lbs, 0, 0}, 64 {test_lbs, 1, 1}, 65 {test_lbs, -1, 1}, 66 67 {test_le, 0, 1}, 68 {test_le, 1, 0}, 69 {test_le, -1, 1}, 70 71 {test_lt, 0, 0}, 72 {test_lt, 1, 0}, 73 {test_lt, -1, 1}, 74 }; 75 76int main (void) 77{ 78 int i; 79 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; 84 } 85 write(1, "OK\n", 3); 86 return 0; 87} 88