* with as domain the given space and as range the range of "model".
*/
__isl_give isl_space *isl_space_extend_domain_with_range(
- __isl_take isl_space *domain, __isl_take isl_space *model)
+ __isl_take isl_space *space, __isl_take isl_space *model)
{
- isl_space *space;
+ if (!model)
+ goto error;
- space = isl_space_from_domain(domain);
+ space = isl_space_from_domain(space);
space = isl_space_add_dims(space, isl_dim_out,
isl_space_dim(model, isl_dim_out));
if (isl_space_has_tuple_id(model, isl_dim_out))
space = isl_space_set_tuple_id(space, isl_dim_out,
isl_space_get_tuple_id(model, isl_dim_out));
+ if (!space)
+ goto error;
+ if (model->nested[1]) {
+ isl_space *nested = isl_space_copy(model->nested[1]);
+ int n_nested, n_space;
+ nested = isl_space_align_params(nested, isl_space_copy(space));
+ n_nested = isl_space_dim(nested, isl_dim_param);
+ n_space = isl_space_dim(space, isl_dim_param);
+ if (n_nested > n_space)
+ nested = isl_space_drop_dims(nested, isl_dim_param,
+ n_space, n_nested - n_space);
+ if (!nested)
+ goto error;
+ space->nested[1] = nested;
+ }
isl_space_free(model);
return space;
+error:
+ isl_space_free(model);
+ isl_space_free(space);
+ return NULL;
}
#include <limits.h>
#include <isl_ctx_private.h>
#include <isl_map_private.h>
-#include <isl/aff.h>
+#include <isl_aff_private.h>
#include <isl/set.h>
#include <isl/flow.h>
#include <isl/constraint.h>
return 0;
}
+int test_align_parameters(isl_ctx *ctx)
+{
+ const char *str;
+ isl_space *space;
+ isl_multi_aff *ma1, *ma2;
+ int equal;
+
+ str = "{ A[B[] -> C[]] -> D[E[] -> F[]] }";
+ ma1 = isl_multi_aff_read_from_str(ctx, str);
+
+ space = isl_space_params_alloc(ctx, 1);
+ space = isl_space_set_dim_name(space, isl_dim_param, 0, "N");
+ ma1 = isl_multi_aff_align_params(ma1, space);
+
+ str = "[N] -> { A[B[] -> C[]] -> D[E[] -> F[]] }";
+ ma2 = isl_multi_aff_read_from_str(ctx, str);
+
+ equal = isl_multi_aff_plain_is_equal(ma1, ma2);
+
+ isl_multi_aff_free(ma1);
+ isl_multi_aff_free(ma2);
+
+ if (equal < 0)
+ return -1;
+ if (!equal)
+ isl_die(ctx, isl_error_unknown,
+ "result not as expected", return -1);
+
+ return 0;
+}
+
struct {
const char *name;
int (*fn)(isl_ctx *ctx);
} tests [] = {
+ { "align parameters", &test_align_parameters },
{ "eliminate", &test_eliminate },
{ "div", &test_div },
{ "slice", &test_slice },