Line data Source code
1 : /*
2 : * Copyright 2010 INRIA Saclay
3 : *
4 : * Use of this software is governed by the MIT license
5 : *
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 : */
10 :
11 : #include <isl_union_macro.h>
12 :
13 : /* Evaluate "u" in the void point "pnt".
14 : * In particular, return the value NaN.
15 : */
16 0 : static __isl_give isl_val *FN(UNION,eval_void)(__isl_take UNION *u,
17 : __isl_take isl_point *pnt)
18 : {
19 : isl_ctx *ctx;
20 :
21 0 : ctx = isl_point_get_ctx(pnt);
22 0 : FN(UNION,free)(u);
23 0 : isl_point_free(pnt);
24 0 : return isl_val_nan(ctx);
25 : }
26 :
27 : /* Is the domain space of "entry" equal to "space"?
28 : */
29 0 : static int FN(UNION,has_domain_space)(const void *entry, const void *val)
30 : {
31 0 : PART *part = (PART *)entry;
32 0 : isl_space *space = (isl_space *) val;
33 :
34 0 : if (isl_space_is_params(space))
35 0 : return isl_space_is_set(part->dim);
36 :
37 0 : return isl_space_tuple_is_equal(part->dim, isl_dim_in,
38 : space, isl_dim_set);
39 : }
40 :
41 0 : __isl_give isl_val *FN(UNION,eval)(__isl_take UNION *u,
42 : __isl_take isl_point *pnt)
43 : {
44 : uint32_t hash;
45 : struct isl_hash_table_entry *entry;
46 : isl_bool is_void;
47 : isl_space *space;
48 : isl_val *v;
49 :
50 0 : if (!u || !pnt)
51 : goto error;
52 0 : is_void = isl_point_is_void(pnt);
53 0 : if (is_void < 0)
54 0 : goto error;
55 0 : if (is_void)
56 0 : return FN(UNION,eval_void)(u, pnt);
57 :
58 0 : space = isl_space_copy(pnt->dim);
59 0 : if (!space)
60 0 : goto error;
61 0 : hash = isl_space_get_hash(space);
62 0 : entry = isl_hash_table_find(u->space->ctx, &u->table,
63 : hash, &FN(UNION,has_domain_space),
64 : space, 0);
65 0 : isl_space_free(space);
66 0 : if (!entry) {
67 0 : v = isl_val_zero(isl_point_get_ctx(pnt));
68 0 : isl_point_free(pnt);
69 : } else {
70 0 : v = FN(PART,eval)(FN(PART,copy)(entry->data), pnt);
71 : }
72 0 : FN(UNION,free)(u);
73 0 : return v;
74 : error:
75 0 : FN(UNION,free)(u);
76 0 : isl_point_free(pnt);
77 0 : return NULL;
78 : }
|