Polly 19.0.0git
isl_multi_apply_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
4 *
5 * Use of this software is governed by the MIT license
6 *
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
9 */
10
11#include <isl_multi_macro.h>
12
13/* Transform the elements of "multi" by applying "fn" to them
14 * with extra argument "set".
15 *
16 * The parameters of "multi" and "set" are assumed to have been aligned.
17 */
20 __isl_give EL *(*fn)(EL *el, __isl_take APPLY_DOM *set))
21{
22 isl_size n;
23 int i;
24
25 n = FN(MULTI(BASE),size)(multi);
26 if (n < 0 || !set)
27 goto error;
28
29 for (i = 0; i < n; ++i) {
30 EL *el;
31
32 el = FN(MULTI(BASE),take_at)(multi, i);
33 el = fn(el, FN(APPLY_DOM,copy)(set));
34 multi = FN(MULTI(BASE),restore_at)(multi, i, el);
35 }
36
37 FN(APPLY_DOM,free)(set);
38 return multi;
39error:
40 FN(APPLY_DOM,free)(set);
41 FN(MULTI(BASE),free)(multi);
42 return NULL;
43}
44
45/* Transform the elements of "multi" by applying "fn" to them
46 * with extra argument "set".
47 *
48 * Align the parameters if needed and call apply_set_aligned.
49 */
52 __isl_give EL *(*fn)(EL *el, __isl_take APPLY_DOM *set))
53{
54 isl_bool aligned;
55 isl_ctx *ctx;
56
57 if (!multi || !set)
58 goto error;
59
60 aligned = FN(APPLY_DOM,space_has_equal_params)(set, multi->space);
61 if (aligned < 0)
62 goto error;
63 if (aligned)
64 return FN(FN(MULTI(BASE),apply_aligned),APPLY_DOMBASE)(multi,
65 set, fn);
66 ctx = FN(MULTI(BASE),get_ctx)(multi);
67 if (!isl_space_has_named_params(multi->space) ||
70 "unaligned unnamed parameters", goto error);
71 multi = FN(MULTI(BASE),align_params)(multi,
72 FN(APPLY_DOM,get_space)(set));
73 set = FN(APPLY_DOM,align_params)(set, FN(MULTI(BASE),get_space)(multi));
74 return FN(FN(MULTI(BASE),apply_aligned),APPLY_DOMBASE)(multi, set, fn);
75error:
76 FN(MULTI(BASE),free)(multi);
77 FN(APPLY_DOM,free)(set);
78 return NULL;
79}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
#define isl_die(ctx, errno, msg, code)
Definition: ctx.h:137
@ isl_error_invalid
Definition: ctx.h:80
int isl_size
Definition: ctx.h:96
isl_bool
Definition: ctx.h:89
#define BASE
Definition: flow_cmp.c:49
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
Definition: hmap.h:37
#define EL
#define APPLY_DOMBASE
#define APPLY_DOM
#define MULTI(BASE)
static __isl_give isl_schedule_node * align_params(__isl_take isl_schedule_node *node, void *user)
Definition: isl_schedule.c:311
isl_bool isl_space_has_named_params(__isl_keep isl_space *space)
Definition: isl_space.c:3225
const char * set
Definition: isl_test.c:1356
const char * size
Definition: isl_test.c:1570
static TupleKindPtr apply(const TupleKindPtr tuple, const Substitution &subs)
Definition: template_cpp.cc:82
n
Definition: youcefn.c:8