add isl_multi_aff_plain_cmp
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 2 Mar 2016 16:48:12 +0000 (2 17:48 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 10 Mar 2016 13:21:15 +0000 (10 14:21 +0100)
This function will be used to compare the fields of an isl_pw_multi_aff
in isl_pw_multi_aff_normalize.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
Makefile.am
isl_aff.c
isl_multi_cmp.c [new file with mode: 0644]

index 6aa8108..739bd66 100644 (file)
@@ -341,6 +341,7 @@ EXTRA_DIST = \
        isl_multi_apply_templ.c \
        isl_multi_apply_set.c \
        isl_multi_apply_union_set.c \
+       isl_multi_cmp.c \
        isl_multi_coalesce.c \
        isl_multi_floor.c \
        isl_multi_gist.c \
index afe53c8..0682a8b 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -3798,6 +3798,7 @@ error:
 
 #include <isl_multi_templ.c>
 #include <isl_multi_apply_set.c>
+#include <isl_multi_cmp.c>
 #include <isl_multi_floor.c>
 #include <isl_multi_gist.c>
 
diff --git a/isl_multi_cmp.c b/isl_multi_cmp.c
new file mode 100644 (file)
index 0000000..a99d370
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016      Sven Verdoolaege
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege
+ */
+
+#include <isl_multi_macro.h>
+
+/* Compare two multi expressions.
+ *
+ * Return -1 if "multi1" is "smaller" than "multi2", 1 if "multi1" is "greater"
+ * than "multi2" and 0 if they are equal.
+ */
+int FN(MULTI(BASE),plain_cmp)(__isl_keep MULTI(BASE) *multi1,
+       __isl_keep MULTI(BASE) *multi2)
+{
+       int i;
+       int cmp;
+
+       if (multi1 == multi2)
+               return 0;
+       if (!multi1)
+               return -1;
+       if (!multi2)
+               return 1;
+
+       cmp = isl_space_cmp(multi1->space, multi2->space);
+       if (cmp != 0)
+               return cmp;
+
+       for (i = 0; i < multi1->n; ++i) {
+               cmp = FN(EL,plain_cmp)(multi1->p[i], multi2->p[i]);
+               if (cmp != 0)
+                       return cmp;
+       }
+
+       return 0;
+}