isl_output.c: print_nested_tuple: rename "local_dim" argument to "local_space"
[isl.git] / isl_union_eval.c
blobb26a74d52886142fe077d380997ee55f5345169e
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 /* Evaluate "u" in the void point "pnt".
14 * In particular, return the value NaN.
16 static __isl_give isl_val *FN(UNION,eval_void)(__isl_take UNION *u,
17 __isl_take isl_point *pnt)
19 isl_ctx *ctx;
21 ctx = isl_point_get_ctx(pnt);
22 FN(UNION,free)(u);
23 isl_point_free(pnt);
24 return isl_val_nan(ctx);
27 /* Is the domain space of "entry" equal to "space"?
29 static int FN(UNION,has_domain_space)(const void *entry, const void *val)
31 PART *part = (PART *)entry;
32 isl_space *space = (isl_space *) val;
34 if (isl_space_is_params(space))
35 return isl_space_is_set(part->dim);
37 return isl_space_tuple_is_equal(part->dim, isl_dim_in,
38 space, isl_dim_set);
41 __isl_give isl_val *FN(UNION,eval)(__isl_take UNION *u,
42 __isl_take isl_point *pnt)
44 uint32_t hash;
45 struct isl_hash_table_entry *entry;
46 isl_bool is_void;
47 isl_space *space;
48 isl_val *v;
50 if (!u || !pnt)
51 goto error;
52 is_void = isl_point_is_void(pnt);
53 if (is_void < 0)
54 goto error;
55 if (is_void)
56 return FN(UNION,eval_void)(u, pnt);
58 space = isl_space_copy(pnt->dim);
59 if (!space)
60 goto error;
61 hash = isl_space_get_hash(space);
62 entry = isl_hash_table_find(u->space->ctx, &u->table,
63 hash, &FN(UNION,has_domain_space),
64 space, 0);
65 isl_space_free(space);
66 if (!entry) {
67 v = isl_val_zero(isl_point_get_ctx(pnt));
68 isl_point_free(pnt);
69 } else {
70 v = FN(PART,eval)(FN(PART,copy)(entry->data), pnt);
72 FN(UNION,free)(u);
73 return v;
74 error:
75 FN(UNION,free)(u);
76 isl_point_free(pnt);
77 return NULL;