1*5971e316Smrg /*
2*5971e316Smrg * Copyright 2013 Ecole Normale Superieure
3*5971e316Smrg *
4*5971e316Smrg * Use of this software is governed by the MIT license
5*5971e316Smrg *
6*5971e316Smrg * Written by Sven Verdoolaege,
7*5971e316Smrg * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8*5971e316Smrg */
9*5971e316Smrg
10*5971e316Smrg #include <isl/space.h>
11*5971e316Smrg #include <isl/local_space.h>
12*5971e316Smrg #include <isl_reordering.h>
13*5971e316Smrg
14*5971e316Smrg #include <isl_multi_macro.h>
15*5971e316Smrg
16*5971e316Smrg /* The functions in this file are meant for base object types
17*5971e316Smrg * that do not have any associated space. They are only meant to be used
18*5971e316Smrg * in the generic isl_multi_* functions which have to deal with base objects
19*5971e316Smrg * that do have an associated space.
20*5971e316Smrg */
21*5971e316Smrg
22*5971e316Smrg
23*5971e316Smrg /* Drop the "n" first dimensions of type "type" at position "first".
24*5971e316Smrg *
25*5971e316Smrg * For a base expression without an associated space, this function
26*5971e316Smrg * does not do anything.
27*5971e316Smrg */
FN(EL,drop_dims)28*5971e316Smrg static __isl_give EL *FN(EL,drop_dims)(__isl_take EL *el,
29*5971e316Smrg enum isl_dim_type type, unsigned first, unsigned n)
30*5971e316Smrg {
31*5971e316Smrg return el;
32*5971e316Smrg }
33*5971e316Smrg
34*5971e316Smrg /* Return the space of "el".
35*5971e316Smrg *
36*5971e316Smrg * For a base expression without an associated space,
37*5971e316Smrg * the conditions surrounding the call to this function make sure
38*5971e316Smrg * that this function will never actually get called. We return a valid
39*5971e316Smrg * space anyway, just in case.
40*5971e316Smrg */
FN(EL,get_space)41*5971e316Smrg static __isl_give isl_space *FN(EL,get_space)(__isl_keep EL *el)
42*5971e316Smrg {
43*5971e316Smrg if (!el)
44*5971e316Smrg return NULL;
45*5971e316Smrg
46*5971e316Smrg return isl_space_params_alloc(FN(EL,get_ctx)(el), 0);
47*5971e316Smrg }
48*5971e316Smrg
49*5971e316Smrg /* Reset the domain space of "el" to "space".
50*5971e316Smrg *
51*5971e316Smrg * For a base expression without an associated space, this function
52*5971e316Smrg * does not do anything, apart from error handling and cleaning up memory.
53*5971e316Smrg */
FN(EL,reset_domain_space)54*5971e316Smrg static __isl_give EL *FN(EL,reset_domain_space)(__isl_take EL *el,
55*5971e316Smrg __isl_take isl_space *space)
56*5971e316Smrg {
57*5971e316Smrg if (!space)
58*5971e316Smrg return FN(EL,free)(el);
59*5971e316Smrg isl_space_free(space);
60*5971e316Smrg return el;
61*5971e316Smrg }
62*5971e316Smrg
63*5971e316Smrg /* Align the parameters of "el" to those of "space".
64*5971e316Smrg *
65*5971e316Smrg * For a base expression without an associated space, this function
66*5971e316Smrg * does not do anything, apart from error handling and cleaning up memory.
67*5971e316Smrg * Note that the conditions surrounding the call to this function make sure
68*5971e316Smrg * that this function will never actually get called.
69*5971e316Smrg */
FN(EL,align_params)70*5971e316Smrg static __isl_give EL *FN(EL,align_params)(__isl_take EL *el,
71*5971e316Smrg __isl_take isl_space *space)
72*5971e316Smrg {
73*5971e316Smrg if (!space)
74*5971e316Smrg return FN(EL,free)(el);
75*5971e316Smrg isl_space_free(space);
76*5971e316Smrg return el;
77*5971e316Smrg }
78*5971e316Smrg
79*5971e316Smrg /* Reorder the dimensions of the domain of "el" according
80*5971e316Smrg * to the given reordering.
81*5971e316Smrg *
82*5971e316Smrg * For a base expression without an associated space, this function
83*5971e316Smrg * does not do anything, apart from error handling and cleaning up memory.
84*5971e316Smrg */
FN(EL,realign_domain)85*5971e316Smrg static __isl_give EL *FN(EL,realign_domain)(__isl_take EL *el,
86*5971e316Smrg __isl_take isl_reordering *r)
87*5971e316Smrg {
88*5971e316Smrg if (!r)
89*5971e316Smrg return FN(EL,free)(el);
90*5971e316Smrg isl_reordering_free(r);
91*5971e316Smrg return el;
92*5971e316Smrg }
93*5971e316Smrg
94*5971e316Smrg /* Do the parameters of "el" match those of "space"?
95*5971e316Smrg *
96*5971e316Smrg * For a base expression without an associated space, this function
97*5971e316Smrg * simply returns true, except if "el" or "space" are NULL.
98*5971e316Smrg */
FN(EL,matching_params)99*5971e316Smrg static isl_bool FN(EL,matching_params)(__isl_keep EL *el,
100*5971e316Smrg __isl_keep isl_space *space)
101*5971e316Smrg {
102*5971e316Smrg if (!el || !space)
103*5971e316Smrg return isl_bool_error;
104*5971e316Smrg return isl_bool_true;
105*5971e316Smrg }
106*5971e316Smrg
107*5971e316Smrg /* Check that the domain space of "el" matches "space".
108*5971e316Smrg *
109*5971e316Smrg * For a base expression without an associated space, this function
110*5971e316Smrg * simply returns isl_stat_ok, except if "el" or "space" are NULL.
111*5971e316Smrg */
FN(EL,check_match_domain_space)112*5971e316Smrg static isl_stat FN(EL,check_match_domain_space)(__isl_keep EL *el,
113*5971e316Smrg __isl_keep isl_space *space)
114*5971e316Smrg {
115*5971e316Smrg if (!el || !space)
116*5971e316Smrg return isl_stat_error;
117*5971e316Smrg return isl_stat_ok;
118*5971e316Smrg }
119