add isl_dim_replace
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 24 Aug 2010 18:59:04 +0000 (20:59 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 26 Aug 2010 14:23:58 +0000 (16:23 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_dim.c
isl_dim_private.h

index 656839b..66df687 100644 (file)
--- a/isl_dim.c
+++ b/isl_dim.c
@@ -1080,3 +1080,21 @@ __isl_give isl_dim *isl_dim_flatten(__isl_take isl_dim *dim)
 
        return dim;
 }
+
+/* Replace the dimensions of the given type of dst by those of src.
+ */
+__isl_give isl_dim *isl_dim_replace(__isl_take isl_dim *dst,
+       enum isl_dim_type type, __isl_keep isl_dim *src)
+{
+       if (!dst || !src)
+               goto error;
+
+       dst = isl_dim_drop(dst, type, 0, isl_dim_size(dst, type));
+       dst = isl_dim_add(dst, type, isl_dim_size(src, type));
+       dst = copy_names(dst, type, 0, src, type);
+
+       return dst;
+error:
+       isl_dim_free(dst);
+       return NULL;
+}
index 6bc8e1d..04b1958 100644 (file)
@@ -28,3 +28,6 @@ int isl_dim_is_named_or_nested(__isl_keep isl_dim *dim, enum isl_dim_type type);
 __isl_give isl_dim *isl_dim_reset(__isl_take isl_dim *dim,
        enum isl_dim_type type);
 __isl_give isl_dim *isl_dim_flatten(__isl_take isl_dim *dim);
+
+__isl_give isl_dim *isl_dim_replace(__isl_take isl_dim *dst,
+       enum isl_dim_type type, __isl_keep isl_dim *src);