Currently bitwise types only support bitwise operations (&, |, ^ and ~) and the constant 0 (since this value is invariant for all bitwise operations and endianness conversion). But the incoming series will relax this a little bit. So, add a few testcases for it. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- validation/bitwise-cmp.c | 32 ++++++++++++++++++++++++++++++++ validation/bitwise-is-signed.c | 22 ++++++++++++++++++++++ validation/linear/bitwise-cmps.c | 18 ++++++++++++++++++ validation/linear/bitwise-cmpu.c | 18 ++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 validation/bitwise-cmp.c create mode 100644 validation/bitwise-is-signed.c create mode 100644 validation/linear/bitwise-cmps.c create mode 100644 validation/linear/bitwise-cmpu.c diff --git a/validation/bitwise-cmp.c b/validation/bitwise-cmp.c new file mode 100644 index 000000000000..ca12b5e51e8e --- /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 000000000000..dd9c147173cd --- /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 000000000000..6122944a42c6 --- /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 000000000000..8932436a7764 --- /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\\. + */ -- 2.36.1