add isl_multi_aff_lift
[platform/upstream/isl.git] / isl_id.c
index 81ed8a0..ef03330 100644 (file)
--- a/isl_id.c
+++ b/isl_id.c
 #include <isl_ctx_private.h>
 #include <isl_id_private.h>
 
+/* A special, static isl_id to use as domains (and ranges)
+ * of sets and parameters domains.
+ * The user should never get a hold on this isl_id.
+ */
+isl_id isl_id_none = {
+       .ref = -1,
+       .ctx = NULL,
+       .name = "#none",
+       .user = NULL
+};
+
 isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id)
 {
        return id ? id->ctx : NULL;
@@ -85,11 +96,17 @@ __isl_give isl_id *isl_id_alloc(isl_ctx *ctx, const char *name, void *user)
        return entry->data;
 }
 
+/* If the id has a negative refcount, then it is a static isl_id
+ * which should not be changed.
+ */
 __isl_give isl_id *isl_id_copy(isl_id *id)
 {
        if (!id)
                return NULL;
 
+       if (id->ref < 0)
+               return id;
+
        id->ref++;
        return id;
 }
@@ -107,6 +124,9 @@ uint32_t isl_hash_id(uint32_t hash, __isl_keep isl_id *id)
        return hash;
 }
 
+/* If the id has a negative refcount, then it is a static isl_id
+ * and should not be freed.
+ */
 void *isl_id_free(__isl_take isl_id *id)
 {
        struct isl_hash_table_entry *entry;
@@ -114,6 +134,9 @@ void *isl_id_free(__isl_take isl_id *id)
        if (!id)
                return NULL;
 
+       if (id->ref < 0)
+               return NULL;
+
        if (--id->ref > 0)
                return NULL;
 
@@ -150,17 +173,3 @@ error:
        isl_printer_free(p);
        return NULL;
 }
-
-void isl_id_dump(__isl_keep isl_id *id)
-{
-       isl_printer *printer;
-
-       if (!id)
-               return;
-
-       printer = isl_printer_to_file(isl_id_get_ctx(id), stderr);
-       printer = isl_printer_print_id(printer, id);
-       printer = isl_printer_end_line(printer);
-
-       isl_printer_free(printer);
-}