new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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\\.
+ */
new file mode 100644
@@ -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\\.
+ */
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@gmail.com> --- 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