Coverage Report

Created: 2017-08-18 19:41

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/include/isl/hmap_templ.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2011      INRIA Saclay
3
 * Copyright 2013      Ecole Normale Superieure
4
 *
5
 * Use of this software is governed by the MIT license
6
 *
7
 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
8
 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
9
 * 91893 Orsay, France
10
 * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
11
 */
12
13
#include <isl/ctx.h>
14
#include <isl/hash.h>
15
16
#define ISL_xCAT(A,B) A ## B
17
#define ISL_CAT(A,B) ISL_xCAT(A,B)
18
7.46k
#define ISL_xFN(TYPE,NAME) TYPE ## _ ## NAME
19
7.46k
#define ISL_FN(TYPE,NAME) ISL_xFN(TYPE,NAME)
20
3.35k
#define ISL_xS(TYPE1,TYPE2,NAME) struct isl_ ## TYPE1 ## _ ## TYPE2 ## _ ## NAME
21
3.35k
#define ISL_yS(TYPE1,TYPE2,NAME) ISL_xS(TYPE1,TYPE2,NAME)
22
3.35k
#define ISL_S(NAME) ISL_yS(ISL_KEY,ISL_VAL,NAME)
23
24
struct ISL_HMAP {
25
  int ref;
26
  isl_ctx *ctx;
27
  struct isl_hash_table table;
28
};
29
30
ISL_S(pair) {
31
  ISL_KEY *key;
32
  ISL_VAL *val;
33
};
34
35
__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,alloc)(isl_ctx *ctx, int min_size)
36
1.21k
{
37
1.21k
  ISL_HMAP *hmap;
38
1.21k
39
1.21k
  hmap = isl_calloc_type(ctx, ISL_HMAP);
40
1.21k
  if (!hmap)
41
0
    return NULL;
42
1.21k
43
1.21k
  hmap->ctx = ctx;
44
1.21k
  isl_ctx_ref(ctx);
45
1.21k
  hmap->ref = 1;
46
1.21k
47
1.21k
  if (isl_hash_table_init(ctx, &hmap->table, min_size) < 0)
48
0
    
return 0
ISL_FN0
(ISL_HMAP,free)(hmap);
49
1.21k
50
1.21k
  return hmap;
51
1.21k
}
isl_map_to_basic_set_alloc
Line
Count
Source
36
786
{
37
786
  ISL_HMAP *hmap;
38
786
39
786
  hmap = isl_calloc_type(ctx, ISL_HMAP);
40
786
  if (!hmap)
41
0
    return NULL;
42
786
43
786
  hmap->ctx = ctx;
44
786
  isl_ctx_ref(ctx);
45
786
  hmap->ref = 1;
46
786
47
786
  if (isl_hash_table_init(ctx, &hmap->table, min_size) < 0)
48
0
    
return 0
ISL_FN0
(ISL_HMAP,free)(hmap);
49
786
50
786
  return hmap;
51
786
}
Unexecuted instantiation: isl_id_to_id_alloc
isl_id_to_ast_expr_alloc
Line
Count
Source
36
428
{
37
428
  ISL_HMAP *hmap;
38
428
39
428
  hmap = isl_calloc_type(ctx, ISL_HMAP);
40
428
  if (!hmap)
41
0
    return NULL;
42
428
43
428
  hmap->ctx = ctx;
44
428
  isl_ctx_ref(ctx);
45
428
  hmap->ref = 1;
46
428
47
428
  if (isl_hash_table_init(ctx, &hmap->table, min_size) < 0)
48
0
    
return 0
ISL_FN0
(ISL_HMAP,free)(hmap);
49
428
50
428
  return hmap;
51
428
}
52
53
static isl_stat free_pair(void **entry, void *user)
54
486
{
55
486
  ISL_S(pair) *pair = *entry;
56
486
  ISL_FN(ISL_KEY,free)(pair->key);
57
486
  ISL_FN(ISL_VAL,free)(pair->val);
58
486
  free(pair);
59
486
  *entry = NULL;
60
486
  return isl_stat_ok;
61
486
}
isl_map_to_basic_set.c:free_pair
Line
Count
Source
54
277
{
55
277
  ISL_S(pair) *pair = *entry;
56
277
  ISL_FN(ISL_KEY,free)(pair->key);
57
277
  ISL_FN(ISL_VAL,free)(pair->val);
58
277
  free(pair);
59
277
  *entry = NULL;
60
277
  return isl_stat_ok;
61
277
}
isl_id_to_ast_expr.c:free_pair
Line
Count
Source
54
209
{
55
209
  ISL_S(pair) *pair = *entry;
56
209
  ISL_FN(ISL_KEY,free)(pair->key);
57
209
  ISL_FN(ISL_VAL,free)(pair->val);
58
209
  free(pair);
59
209
  *entry = NULL;
60
209
  return isl_stat_ok;
61
209
}
Unexecuted instantiation: isl_id_to_id.c:free_pair
62
63
__isl_null ISL_HMAP *ISL_FN(ISL_HMAP,free)(__isl_take ISL_HMAP *hmap)
64
8.47k
{
65
8.47k
  if (!hmap)
66
7.26k
    return NULL;
67
1.21k
  
if (1.21k
--hmap->ref > 01.21k
)
68
0
    return NULL;
69
1.21k
  isl_hash_table_foreach(hmap->ctx, &hmap->table, &free_pair, NULL);
70
1.21k
  isl_hash_table_clear(&hmap->table);
71
1.21k
  isl_ctx_deref(hmap->ctx);
72
1.21k
  free(hmap);
73
1.21k
  return NULL;
74
8.47k
}
isl_id_to_ast_expr_free
Line
Count
Source
64
428
{
65
428
  if (!hmap)
66
0
    return NULL;
67
428
  
if (428
--hmap->ref > 0428
)
68
0
    return NULL;
69
428
  isl_hash_table_foreach(hmap->ctx, &hmap->table, &free_pair, NULL);
70
428
  isl_hash_table_clear(&hmap->table);
71
428
  isl_ctx_deref(hmap->ctx);
72
428
  free(hmap);
73
428
  return NULL;
74
428
}
isl_map_to_basic_set_free
Line
Count
Source
64
840
{
65
840
  if (!hmap)
66
54
    return NULL;
67
786
  
if (786
--hmap->ref > 0786
)
68
0
    return NULL;
69
786
  isl_hash_table_foreach(hmap->ctx, &hmap->table, &free_pair, NULL);
70
786
  isl_hash_table_clear(&hmap->table);
71
786
  isl_ctx_deref(hmap->ctx);
72
786
  free(hmap);
73
786
  return NULL;
74
840
}
isl_id_to_id_free
Line
Count
Source
64
7.21k
{
65
7.21k
  if (!hmap)
66
7.21k
    return NULL;
67
0
  
if (0
--hmap->ref > 00
)
68
0
    return NULL;
69
0
  isl_hash_table_foreach(hmap->ctx, &hmap->table, &free_pair, NULL);
70
0
  isl_hash_table_clear(&hmap->table);
71
0
  isl_ctx_deref(hmap->ctx);
72
0
  free(hmap);
73
0
  return NULL;
74
7.21k
}
75
76
isl_ctx *ISL_FN(ISL_HMAP,get_ctx)(__isl_keep ISL_HMAP *hmap)
77
0
{
78
0
  return hmap ? hmap->ctx : NULL;
79
0
}
Unexecuted instantiation: isl_id_to_ast_expr_get_ctx
Unexecuted instantiation: isl_id_to_id_get_ctx
Unexecuted instantiation: isl_map_to_basic_set_get_ctx
80
81
/* Add a mapping from "key" to "val" to the associative array
82
 * pointed to by user.
83
 */
84
static isl_stat add_key_val(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val,
85
  void *user)
86
0
{
87
0
  ISL_HMAP **hmap = (ISL_HMAP **) user;
88
0
89
0
  *hmap = ISL_FN(ISL_HMAP,set)(*hmap, key, val);
90
0
91
0
  if (!*hmap)
92
0
    return isl_stat_error;
93
0
94
0
  return isl_stat_ok;
95
0
}
Unexecuted instantiation: isl_id_to_id.c:add_key_val
Unexecuted instantiation: isl_id_to_ast_expr.c:add_key_val
Unexecuted instantiation: isl_map_to_basic_set.c:add_key_val
96
97
__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,dup)(__isl_keep ISL_HMAP *hmap)
98
0
{
99
0
  ISL_HMAP *dup;
100
0
101
0
  if (!hmap)
102
0
    return NULL;
103
0
104
0
  
dup = 0
ISL_FN0
(ISL_HMAP,alloc)(hmap->ctx, hmap->table.n);
105
0
  if (
ISL_FN0
(ISL_HMAP,foreach)(hmap, &add_key_val, &dup) < 00
)
106
0
    
return 0
ISL_FN0
(ISL_HMAP,free)(dup);
107
0
108
0
  return dup;
109
0
}
Unexecuted instantiation: isl_map_to_basic_set_dup
Unexecuted instantiation: isl_id_to_id_dup
Unexecuted instantiation: isl_id_to_ast_expr_dup
110
111
__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,cow)(__isl_take ISL_HMAP *hmap)
112
486
{
113
486
  if (!hmap)
114
0
    return NULL;
115
486
116
486
  
if (486
hmap->ref == 1486
)
117
486
    return hmap;
118
486
  hmap->ref--;
119
0
  return ISL_FN(ISL_HMAP,dup)(hmap);
120
486
}
isl_id_to_ast_expr_cow
Line
Count
Source
112
209
{
113
209
  if (!hmap)
114
0
    return NULL;
115
209
116
209
  
if (209
hmap->ref == 1209
)
117
209
    return hmap;
118
209
  hmap->ref--;
119
0
  return ISL_FN(ISL_HMAP,dup)(hmap);
120
209
}
Unexecuted instantiation: isl_id_to_id_cow
isl_map_to_basic_set_cow
Line
Count
Source
112
277
{
113
277
  if (!hmap)
114
0
    return NULL;
115
277
116
277
  
if (277
hmap->ref == 1277
)
117
277
    return hmap;
118
277
  hmap->ref--;
119
0
  return ISL_FN(ISL_HMAP,dup)(hmap);
120
277
}
121
122
__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,copy)(__isl_keep ISL_HMAP *hmap)
123
0
{
124
0
  if (!hmap)
125
0
    return NULL;
126
0
127
0
  hmap->ref++;
128
0
  return hmap;
129
0
}
Unexecuted instantiation: isl_id_to_ast_expr_copy
Unexecuted instantiation: isl_id_to_id_copy
Unexecuted instantiation: isl_map_to_basic_set_copy
130
131
static int has_key(const void *entry, const void *c_key)
132
1.57k
{
133
1.57k
  const ISL_S(pair) *pair = entry;
134
1.57k
  ISL_KEY *key = (ISL_KEY *) c_key;
135
1.57k
136
1.57k
  return ISL_KEY_IS_EQUAL(pair->key, key);
137
1.57k
}
Unexecuted instantiation: isl_id_to_id.c:has_key
isl_map_to_basic_set.c:has_key
Line
Count
Source
132
1.33k
{
133
1.33k
  const ISL_S(pair) *pair = entry;
134
1.33k
  ISL_KEY *key = (ISL_KEY *) c_key;
135
1.33k
136
1.33k
  return ISL_KEY_IS_EQUAL(pair->key, key);
137
1.33k
}
isl_id_to_ast_expr.c:has_key
Line
Count
Source
132
234
{
133
234
  const ISL_S(pair) *pair = entry;
134
234
  ISL_KEY *key = (ISL_KEY *) c_key;
135
234
136
234
  return ISL_KEY_IS_EQUAL(pair->key, key);
137
234
}
138
139
/* If "hmap" contains a value associated to "key", then return
140
 * (isl_bool_true, copy of value).
141
 * Otherwise, return
142
 * (isl_bool_false, NULL).
143
 * If an error occurs, then return
144
 * (isl_bool_error, NULL).
145
 */
146
__isl_give ISL_MAYBE(ISL_VAL) ISL_FN(ISL_HMAP,try_get)(
147
  __isl_keep ISL_HMAP *hmap, __isl_keep ISL_KEY *key)
148
2.38k
{
149
2.38k
  struct isl_hash_table_entry *entry;
150
2.38k
  ISL_S(pair) *pair;
151
2.38k
  uint32_t hash;
152
2.38k
  ISL_MAYBE(ISL_VAL) res = { isl_bool_false, NULL };
153
2.38k
154
2.38k
  if (
!hmap || 2.38k
!key2.38k
)
155
0
    goto error;
156
2.38k
157
2.38k
  
hash = 2.38k
ISL_FN2.38k
(ISL_KEY,get_hash)(key);
158
2.38k
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
159
2.38k
          &has_key, key, 0);
160
2.38k
161
2.38k
  if (!entry)
162
838
    return res;
163
2.38k
164
2.38k
  pair = entry->data;
165
1.54k
166
1.54k
  res.valid = isl_bool_true;
167
1.54k
  res.value = ISL_FN(ISL_VAL,copy)(pair->val);
168
1.54k
  if (!res.value)
169
0
    res.valid = isl_bool_error;
170
2.38k
  return res;
171
2.38k
error:
172
0
  res.valid = isl_bool_error;
173
0
  res.value = NULL;
174
2.38k
  return res;
175
2.38k
}
Unexecuted instantiation: isl_id_to_id_try_get
isl_id_to_ast_expr_try_get
Line
Count
Source
148
795
{
149
795
  struct isl_hash_table_entry *entry;
150
795
  ISL_S(pair) *pair;
151
795
  uint32_t hash;
152
795
  ISL_MAYBE(ISL_VAL) res = { isl_bool_false, NULL };
153
795
154
795
  if (
!hmap || 795
!key795
)
155
0
    goto error;
156
795
157
795
  
hash = 795
ISL_FN795
(ISL_KEY,get_hash)(key);
158
795
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
159
795
          &has_key, key, 0);
160
795
161
795
  if (!entry)
162
561
    return res;
163
795
164
795
  pair = entry->data;
165
234
166
234
  res.valid = isl_bool_true;
167
234
  res.value = ISL_FN(ISL_VAL,copy)(pair->val);
168
234
  if (!res.value)
169
0
    res.valid = isl_bool_error;
170
795
  return res;
171
795
error:
172
0
  res.valid = isl_bool_error;
173
0
  res.value = NULL;
174
795
  return res;
175
795
}
isl_map_to_basic_set_try_get
Line
Count
Source
148
1.59k
{
149
1.59k
  struct isl_hash_table_entry *entry;
150
1.59k
  ISL_S(pair) *pair;
151
1.59k
  uint32_t hash;
152
1.59k
  ISL_MAYBE(ISL_VAL) res = { isl_bool_false, NULL };
153
1.59k
154
1.59k
  if (
!hmap || 1.59k
!key1.59k
)
155
0
    goto error;
156
1.59k
157
1.59k
  
hash = 1.59k
ISL_FN1.59k
(ISL_KEY,get_hash)(key);
158
1.59k
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
159
1.59k
          &has_key, key, 0);
160
1.59k
161
1.59k
  if (!entry)
162
277
    return res;
163
1.59k
164
1.59k
  pair = entry->data;
165
1.31k
166
1.31k
  res.valid = isl_bool_true;
167
1.31k
  res.value = ISL_FN(ISL_VAL,copy)(pair->val);
168
1.31k
  if (!res.value)
169
0
    res.valid = isl_bool_error;
170
1.59k
  return res;
171
1.59k
error:
172
0
  res.valid = isl_bool_error;
173
0
  res.value = NULL;
174
1.59k
  return res;
175
1.59k
}
176
177
/* If "hmap" contains a value associated to "key", then return
178
 * isl_bool_true.  Otherwise, return isl_bool_false.
179
 * Return isl_bool_error on error.
180
 */
181
isl_bool ISL_FN(ISL_HMAP,has)(__isl_keep ISL_HMAP *hmap,
182
  __isl_keep ISL_KEY *key)
183
0
{
184
0
  ISL_MAYBE(ISL_VAL) res;
185
0
186
0
  res = ISL_FN(ISL_HMAP,try_get)(hmap, key);
187
0
  ISL_FN(ISL_VAL,free)(res.value);
188
0
189
0
  return res.valid;
190
0
}
Unexecuted instantiation: isl_id_to_ast_expr_has
Unexecuted instantiation: isl_id_to_id_has
Unexecuted instantiation: isl_map_to_basic_set_has
191
192
/* If "hmap" contains a value associated to "key", then return
193
 * a copy of that value.  Otherwise, return NULL.
194
 * Return NULL on error.
195
 */
196
__isl_give ISL_VAL *ISL_FN(ISL_HMAP,get)(__isl_keep ISL_HMAP *hmap,
197
  __isl_take ISL_KEY *key)
198
795
{
199
795
  ISL_VAL *res;
200
795
201
795
  res = ISL_FN(ISL_HMAP,try_get)(hmap, key).value;
202
795
  ISL_FN(ISL_KEY,free)(key);
203
795
  return res;
204
795
}
isl_id_to_ast_expr_get
Line
Count
Source
198
795
{
199
795
  ISL_VAL *res;
200
795
201
795
  res = ISL_FN(ISL_HMAP,try_get)(hmap, key).value;
202
795
  ISL_FN(ISL_KEY,free)(key);
203
795
  return res;
204
795
}
Unexecuted instantiation: isl_map_to_basic_set_get
Unexecuted instantiation: isl_id_to_id_get
205
206
/* Remove the mapping between "key" and its associated value (if any)
207
 * from "hmap".
208
 *
209
 * If "key" is not mapped to anything, then we leave "hmap" untouched"
210
 */
211
__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,drop)(__isl_take ISL_HMAP *hmap,
212
  __isl_take ISL_KEY *key)
213
0
{
214
0
  struct isl_hash_table_entry *entry;
215
0
  ISL_S(pair) *pair;
216
0
  uint32_t hash;
217
0
218
0
  if (
!hmap || 0
!key0
)
219
0
    goto error;
220
0
221
0
  
hash = 0
ISL_FN0
(ISL_KEY,get_hash)(key);
222
0
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
223
0
          &has_key, key, 0);
224
0
  if (
!entry0
)
{0
225
0
    ISL_FN(ISL_KEY,free)(key);
226
0
    return hmap;
227
0
  }
228
0
229
0
  
hmap = 0
ISL_FN0
(ISL_HMAP,cow)(hmap);
230
0
  if (!hmap)
231
0
    goto error;
232
0
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
233
0
          &has_key, key, 0);
234
0
  ISL_FN(ISL_KEY,free)(key);
235
0
236
0
  if (!entry)
237
0
    isl_die(hmap->ctx, isl_error_internal,
238
0
      "missing entry" , goto error);
239
0
240
0
  pair = entry->data;
241
0
  isl_hash_table_remove(hmap->ctx, &hmap->table, entry);
242
0
  ISL_FN(ISL_KEY,free)(pair->key);
243
0
  ISL_FN(ISL_VAL,free)(pair->val);
244
0
  free(pair);
245
0
246
0
  return hmap;
247
0
error:
248
0
  ISL_FN(ISL_KEY,free)(key);
249
0
  ISL_FN(ISL_HMAP,free)(hmap);
250
0
  return NULL;
251
0
}
Unexecuted instantiation: isl_map_to_basic_set_drop
Unexecuted instantiation: isl_id_to_id_drop
Unexecuted instantiation: isl_id_to_ast_expr_drop
252
253
/* Add a mapping from "key" to "val" to "hmap".
254
 * If "key" was already mapped to something else, then that mapping
255
 * is replaced.
256
 * If key happened to be mapped to "val" already, then we leave
257
 * "hmap" untouched.
258
 */
259
__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,set)(__isl_take ISL_HMAP *hmap,
260
  __isl_take ISL_KEY *key, __isl_take ISL_VAL *val)
261
486
{
262
486
  struct isl_hash_table_entry *entry;
263
486
  ISL_S(pair) *pair;
264
486
  uint32_t hash;
265
486
266
486
  if (
!hmap || 486
!key486
||
!val486
)
267
0
    goto error;
268
486
269
486
  
hash = 486
ISL_FN486
(ISL_KEY,get_hash)(key);
270
486
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
271
486
          &has_key, key, 0);
272
486
  if (
entry486
)
{0
273
0
    int equal;
274
0
    pair = entry->data;
275
0
    equal = ISL_VAL_IS_EQUAL(pair->val, val);
276
0
    if (equal < 0)
277
0
      goto error;
278
0
    
if (0
equal0
)
{0
279
0
      ISL_FN(ISL_KEY,free)(key);
280
0
      ISL_FN(ISL_VAL,free)(val);
281
0
      return hmap;
282
0
    }
283
486
  }
284
486
285
486
  
hmap = 486
ISL_FN486
(ISL_HMAP,cow)(hmap);
286
486
  if (!hmap)
287
0
    goto error;
288
486
289
486
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
290
486
          &has_key, key, 1);
291
486
292
486
  if (!entry)
293
0
    goto error;
294
486
295
486
  
if (486
entry->data486
)
{0
296
0
    pair = entry->data;
297
0
    ISL_FN(ISL_VAL,free)(pair->val);
298
0
    pair->val = val;
299
0
    ISL_FN(ISL_KEY,free)(key);
300
0
    return hmap;
301
486
  }
302
486
303
486
  
pair = 486
isl_alloc_type486
(hmap->ctx, ISL_S(pair));
304
486
  if (!pair)
305
0
    goto error;
306
486
307
486
  entry->data = pair;
308
486
  pair->key = key;
309
486
  pair->val = val;
310
486
  return hmap;
311
486
error:
312
0
  ISL_FN(ISL_KEY,free)(key);
313
0
  ISL_FN(ISL_VAL,free)(val);
314
0
  return ISL_FN(ISL_HMAP,free)(hmap);
315
486
}
isl_map_to_basic_set_set
Line
Count
Source
261
277
{
262
277
  struct isl_hash_table_entry *entry;
263
277
  ISL_S(pair) *pair;
264
277
  uint32_t hash;
265
277
266
277
  if (
!hmap || 277
!key277
||
!val277
)
267
0
    goto error;
268
277
269
277
  
hash = 277
ISL_FN277
(ISL_KEY,get_hash)(key);
270
277
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
271
277
          &has_key, key, 0);
272
277
  if (
entry277
)
{0
273
0
    int equal;
274
0
    pair = entry->data;
275
0
    equal = ISL_VAL_IS_EQUAL(pair->val, val);
276
0
    if (equal < 0)
277
0
      goto error;
278
0
    
if (0
equal0
)
{0
279
0
      ISL_FN(ISL_KEY,free)(key);
280
0
      ISL_FN(ISL_VAL,free)(val);
281
0
      return hmap;
282
0
    }
283
277
  }
284
277
285
277
  
hmap = 277
ISL_FN277
(ISL_HMAP,cow)(hmap);
286
277
  if (!hmap)
287
0
    goto error;
288
277
289
277
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
290
277
          &has_key, key, 1);
291
277
292
277
  if (!entry)
293
0
    goto error;
294
277
295
277
  
if (277
entry->data277
)
{0
296
0
    pair = entry->data;
297
0
    ISL_FN(ISL_VAL,free)(pair->val);
298
0
    pair->val = val;
299
0
    ISL_FN(ISL_KEY,free)(key);
300
0
    return hmap;
301
277
  }
302
277
303
277
  
pair = 277
isl_alloc_type277
(hmap->ctx, ISL_S(pair));
304
277
  if (!pair)
305
0
    goto error;
306
277
307
277
  entry->data = pair;
308
277
  pair->key = key;
309
277
  pair->val = val;
310
277
  return hmap;
311
277
error:
312
0
  ISL_FN(ISL_KEY,free)(key);
313
0
  ISL_FN(ISL_VAL,free)(val);
314
0
  return ISL_FN(ISL_HMAP,free)(hmap);
315
277
}
isl_id_to_ast_expr_set
Line
Count
Source
261
209
{
262
209
  struct isl_hash_table_entry *entry;
263
209
  ISL_S(pair) *pair;
264
209
  uint32_t hash;
265
209
266
209
  if (
!hmap || 209
!key209
||
!val209
)
267
0
    goto error;
268
209
269
209
  
hash = 209
ISL_FN209
(ISL_KEY,get_hash)(key);
270
209
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
271
209
          &has_key, key, 0);
272
209
  if (
entry209
)
{0
273
0
    int equal;
274
0
    pair = entry->data;
275
0
    equal = ISL_VAL_IS_EQUAL(pair->val, val);
276
0
    if (equal < 0)
277
0
      goto error;
278
0
    
if (0
equal0
)
{0
279
0
      ISL_FN(ISL_KEY,free)(key);
280
0
      ISL_FN(ISL_VAL,free)(val);
281
0
      return hmap;
282
0
    }
283
209
  }
284
209
285
209
  
hmap = 209
ISL_FN209
(ISL_HMAP,cow)(hmap);
286
209
  if (!hmap)
287
0
    goto error;
288
209
289
209
  entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
290
209
          &has_key, key, 1);
291
209
292
209
  if (!entry)
293
0
    goto error;
294
209
295
209
  
if (209
entry->data209
)
{0
296
0
    pair = entry->data;
297
0
    ISL_FN(ISL_VAL,free)(pair->val);
298
0
    pair->val = val;
299
0
    ISL_FN(ISL_KEY,free)(key);
300
0
    return hmap;
301
209
  }
302
209
303
209
  
pair = 209
isl_alloc_type209
(hmap->ctx, ISL_S(pair));
304
209
  if (!pair)
305
0
    goto error;
306
209
307
209
  entry->data = pair;
308
209
  pair->key = key;
309
209
  pair->val = val;
310
209
  return hmap;
311
209
error:
312
0
  ISL_FN(ISL_KEY,free)(key);
313
0
  ISL_FN(ISL_VAL,free)(val);
314
0
  return ISL_FN(ISL_HMAP,free)(hmap);
315
209
}
Unexecuted instantiation: isl_id_to_id_set
316
317
/* Internal data structure for isl_map_to_basic_set_foreach.
318
 *
319
 * fn is the function that should be called on each entry.
320
 * user is the user-specified final argument to fn.
321
 */
322
ISL_S(foreach_data) {
323
  isl_stat (*fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val,
324
    void *user);
325
  void *user;
326
};
327
328
/* Call data->fn on a copy of the key and value in *entry.
329
 */
330
static isl_stat call_on_copy(void **entry, void *user)
331
0
{
332
0
  ISL_S(pair) *pair = *entry;
333
0
  ISL_S(foreach_data) *data = (ISL_S(foreach_data) *) user;
334
0
335
0
  return data->fn(ISL_FN(ISL_KEY,copy)(pair->key),
336
0
      ISL_FN(ISL_VAL,copy)(pair->val), data->user);
337
0
}
Unexecuted instantiation: isl_id_to_ast_expr.c:call_on_copy
Unexecuted instantiation: isl_id_to_id.c:call_on_copy
Unexecuted instantiation: isl_map_to_basic_set.c:call_on_copy
338
339
/* Call "fn" on each pair of key and value in "hmap".
340
 */
341
isl_stat ISL_FN(ISL_HMAP,foreach)(__isl_keep ISL_HMAP *hmap,
342
  isl_stat (*fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val,
343
    void *user),
344
  void *user)
345
0
{
346
0
  ISL_S(foreach_data) data = { fn, user };
347
0
348
0
  if (!hmap)
349
0
    return isl_stat_error;
350
0
351
0
  return isl_hash_table_foreach(hmap->ctx, &hmap->table,
352
0
              &call_on_copy, &data);
353
0
}
Unexecuted instantiation: isl_id_to_ast_expr_foreach
Unexecuted instantiation: isl_id_to_id_foreach
Unexecuted instantiation: isl_map_to_basic_set_foreach
354
355
/* Internal data structure for print_pair.
356
 *
357
 * p is the printer on which the associative array is being printed.
358
 * first is set if the current key-value pair is the first to be printed.
359
 */
360
ISL_S(print_data) {
361
  isl_printer *p;
362
  int first;
363
};
364
365
/* Print the given key-value pair to data->p.
366
 */
367
static isl_stat print_pair(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val,
368
  void *user)
369
0
{
370
0
  ISL_S(print_data) *data = user;
371
0
372
0
  if (!data->first)
373
0
    data->p = isl_printer_print_str(data->p, ", ");
374
0
  data->p = ISL_KEY_PRINT(data->p, key);
375
0
  data->p = isl_printer_print_str(data->p, ": ");
376
0
  data->p = ISL_VAL_PRINT(data->p, val);
377
0
  data->first = 0;
378
0
379
0
  ISL_FN(ISL_KEY,free)(key);
380
0
  ISL_FN(ISL_VAL,free)(val);
381
0
  return isl_stat_ok;
382
0
}
Unexecuted instantiation: isl_id_to_id.c:print_pair
Unexecuted instantiation: isl_id_to_ast_expr.c:print_pair
Unexecuted instantiation: isl_map_to_basic_set.c:print_pair
383
384
/* Print the associative array to "p".
385
 */
386
__isl_give isl_printer *ISL_FN(isl_printer_print,ISL_HMAP_SUFFIX)(
387
  __isl_take isl_printer *p, __isl_keep ISL_HMAP *hmap)
388
0
{
389
0
  ISL_S(print_data) data;
390
0
391
0
  if (
!p || 0
!hmap0
)
392
0
    return isl_printer_free(p);
393
0
394
0
  p = isl_printer_print_str(p, "{");
395
0
  data.p = p;
396
0
  data.first = 1;
397
0
  if (
ISL_FN0
(ISL_HMAP,foreach)(hmap, &print_pair, &data) < 00
)
398
0
    data.p = isl_printer_free(data.p);
399
0
  p = data.p;
400
0
  p = isl_printer_print_str(p, "}");
401
0
402
0
  return p;
403
0
}
Unexecuted instantiation: isl_printer_print_id_to_id
Unexecuted instantiation: isl_printer_print_map_to_basic_set
Unexecuted instantiation: isl_printer_print_id_to_ast_expr
404
405
void ISL_FN(ISL_HMAP,dump)(__isl_keep ISL_HMAP *hmap)
406
0
{
407
0
  isl_printer *printer;
408
0
409
0
  if (!hmap)
410
0
    return;
411
0
412
0
  
printer = isl_printer_to_file(0
ISL_FN0
(ISL_HMAP,get_ctx)(hmap), stderr);
413
0
  printer = ISL_FN(isl_printer_print,ISL_HMAP_SUFFIX)(printer, hmap);
414
0
  printer = isl_printer_end_line(printer);
415
0
416
0
  isl_printer_free(printer);
417
0
}
Unexecuted instantiation: isl_id_to_id_dump
Unexecuted instantiation: isl_map_to_basic_set_dump
Unexecuted instantiation: isl_id_to_ast_expr_dump