isl_scheduler.c: compute_max_coefficient: round up half of minimal size
[isl.git] / isl_union_eval.c
blob3daab3fc99d7424cf5a1f192155fbe1c14e759b5
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 #include <isl_union_macro.h>
13 /* Is the domain space of "entry" equal to "space"?
15 static int FN(UNION,has_domain_space)(const void *entry, const void *val)
17 PART *part = (PART *)entry;
18 isl_space *space = (isl_space *) val;
20 if (isl_space_is_params(space))
21 return isl_space_is_set(part->dim);
23 return isl_space_tuple_is_equal(part->dim, isl_dim_in,
24 space, isl_dim_set);
27 __isl_give isl_val *FN(UNION,eval)(__isl_take UNION *u,
28 __isl_take isl_point *pnt)
30 uint32_t hash;
31 struct isl_hash_table_entry *entry;
32 isl_space *space;
33 isl_val *v;
35 if (!u || !pnt)
36 goto error;
38 space = isl_space_copy(pnt->dim);
39 if (!space)
40 goto error;
41 hash = isl_space_get_hash(space);
42 entry = isl_hash_table_find(u->space->ctx, &u->table,
43 hash, &FN(UNION,has_domain_space),
44 space, 0);
45 isl_space_free(space);
46 if (!entry) {
47 v = isl_val_zero(isl_point_get_ctx(pnt));
48 isl_point_free(pnt);
49 } else {
50 v = FN(PART,eval)(FN(PART,copy)(entry->data), pnt);
52 FN(UNION,free)(u);
53 return v;
54 error:
55 FN(UNION,free)(u);
56 isl_point_free(pnt);
57 return NULL;