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