| 1 |
/* Executable testcase for 'output flags.' */ |
| 2 |
/* { dg-do run } */ |
| 3 |
|
| 4 |
#ifdef __LP64__ |
| 5 |
#define W "" |
| 6 |
#else |
| 7 |
#define W "w" |
| 8 |
#endif |
| 9 |
|
| 10 |
int test_bits (long nzcv) |
| 11 |
{ |
| 12 |
long n, z, c, v; |
| 13 |
|
| 14 |
__asm__ ("msr nzcv, %[in]" |
| 15 |
: "=@ccmi"(n), "=@cceq"(z), "=@cccs"(c), "=@ccvs"(v) |
| 16 |
: [in] "r"(nzcv << 28)); |
| 17 |
|
| 18 |
return n * 8 + z * 4 + c * 2 + v == nzcv; |
| 19 |
} |
| 20 |
|
| 21 |
int test_cmps (long x, long y) |
| 22 |
{ |
| 23 |
long gt, lt, ge, le; |
| 24 |
|
| 25 |
__asm__ ("cmp %"W"[x], %"W"[y]" |
| 26 |
: "=@ccgt"(gt), "=@cclt"(lt), "=@ccge"(ge), "=@ccle"(le) |
| 27 |
: [x] "r"(x), [y] "r"(y)); |
| 28 |
|
| 29 |
return (gt == (x > y) |
| 30 |
&& lt == (x < y) |
| 31 |
&& ge == (x >= y) |
| 32 |
&& le == (x <= y)); |
| 33 |
} |
| 34 |
|
| 35 |
int test_cmpu (unsigned long x, unsigned long y) |
| 36 |
{ |
| 37 |
long gt, lt, ge, le; |
| 38 |
|
| 39 |
__asm__ ("cmp %"W"[x], %"W"[y]" |
| 40 |
: "=@cchi"(gt), "=@cclo"(lt), "=@cchs"(ge), "=@ccls"(le) |
| 41 |
: [x] "r"(x), [y] "r"(y)); |
| 42 |
|
| 43 |
return (gt == (x > y) |
| 44 |
&& lt == (x < y) |
| 45 |
&& ge == (x >= y) |
| 46 |
&& le == (x <= y)); |
| 47 |
} |
| 48 |
|
| 49 |
int main () |
| 50 |
{ |
| 51 |
long i, j; |
| 52 |
|
| 53 |
for (i = 0; i < 16; ++i) |
| 54 |
if (!test_bits (i)) |
| 55 |
__builtin_abort (); |
| 56 |
|
| 57 |
for (i = -1; i <= 1; ++i) |
| 58 |
for (j = -1; j <= 1; ++j) |
| 59 |
if (!test_cmps (i, j)) |
| 60 |
__builtin_abort (); |
| 61 |
|
| 62 |
for (i = 0; i <= 2; ++i) |
| 63 |
for (j = 0; j <= 2; ++j) |
| 64 |
if (!test_cmpu (i, j)) |
| 65 |
__builtin_abort (); |
| 66 |
|
| 67 |
return 0; |
| 68 |
} |