diff options
-rw-r--r-- | validation/bitwise-cmp.c | 32 | ||||
-rw-r--r-- | validation/bitwise-is-signed.c | 22 | ||||
-rw-r--r-- | validation/linear/bitwise-cmps.c | 18 | ||||
-rw-r--r-- | validation/linear/bitwise-cmpu.c | 18 |
4 files changed, 90 insertions, 0 deletions
diff --git a/validation/bitwise-cmp.c b/validation/bitwise-cmp.c new file mode 100644 index 00000000..ca12b5e5 --- /dev/null +++ b/validation/bitwise-cmp.c @@ -0,0 +1,32 @@ +#define M 0xffffffff + +typedef int __attribute__((bitwise)) b32; + +static int eq0(b32 x, b32 y) { return (x == 0); } +static int eqm(b32 x, b32 y) { return (x == M); } +static int eqx(b32 x, b32 y) { return (x == y); } + +static int ne0(b32 x, b32 y) { return (x != 0); } +static int nem(b32 x, b32 y) { return (x != M); } +static int nex(b32 x, b32 y) { return (x != y); } + +static int lt0(b32 x, b32 y) { return (x < 0); } +static int ltm(b32 x, b32 y) { return (x < M); } +static int ltx(b32 x, b32 y) { return (x < y); } + +static int lte0(b32 x, b32 y) { return (x <= 0); } +static int ltem(b32 x, b32 y) { return (x <= M); } +static int ltex(b32 x, b32 y) { return (x <= y); } + +static int gte0(b32 x, b32 y) { return (x >= 0); } +static int gtem(b32 x, b32 y) { return (x >= M); } +static int gtex(b32 x, b32 y) { return (x >= y); } + +static int gt0(b32 x, b32 y) { return (x > 0); } +static int gtm(b32 x, b32 y) { return (x > M); } +static int gtx(b32 x, b32 y) { return (x > y); } + +/* + * check-name: bitwise-cmp + * check-known-to-fail + */ diff --git a/validation/bitwise-is-signed.c b/validation/bitwise-is-signed.c new file mode 100644 index 00000000..dd9c1471 --- /dev/null +++ b/validation/bitwise-is-signed.c @@ -0,0 +1,22 @@ +#define __bitwise __attribute__((bitwise)) + +#define is_signed_type(type) (((type)-1) <= 0) + +typedef signed int __bitwise s; +typedef unsigned int __bitwise u; + +int fos(void); +int fou(void); + + +int fos(void) { return is_signed_type(s); } +int fou(void) { return !is_signed_type(u); } + +/* + * check-name: bitwise-is-signed + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/linear/bitwise-cmps.c b/validation/linear/bitwise-cmps.c new file mode 100644 index 00000000..6122944a --- /dev/null +++ b/validation/linear/bitwise-cmps.c @@ -0,0 +1,18 @@ +typedef signed int __attribute__((bitwise)) bs32; + +static int ltu(bs32 x, bs32 y) { return (x < y); } +static int lteu(bs32 x, bs32 y) { return (x <= y); } +static int gteu(bs32 x, bs32 y) { return (x >= y); } +static int gtu(bs32 x, bs32 y) { return (x > y); } + +/* + * check-name: bitwise-cmps + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: setb\\. + * check-output-excludes: setbe\\. + * check-output-excludes: setae\\. + * check-output-excludes: seta\\. + */ diff --git a/validation/linear/bitwise-cmpu.c b/validation/linear/bitwise-cmpu.c new file mode 100644 index 00000000..8932436a --- /dev/null +++ b/validation/linear/bitwise-cmpu.c @@ -0,0 +1,18 @@ +typedef unsigned int __attribute__((bitwise)) bu32; + +static int ltu(bu32 x, bu32 y) { return (x < y); } +static int lteu(bu32 x, bu32 y) { return (x <= y); } +static int gteu(bu32 x, bu32 y) { return (x >= y); } +static int gtu(bu32 x, bu32 y) { return (x > y); } + +/* + * check-name: bitwise-cmpu + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: setlt\\. + * check-output-excludes: setlte\\. + * check-output-excludes: setgte\\. + * check-output-excludes: setgt\\. + */ |