2 /*+-----------------------------------------------------------------**
4 **-----------------------------------------------------------------**
6 **-----------------------------------------------------------------**
7 ** First version: 30/04/2008 **
8 **-----------------------------------------------------------------**
11 *****************************************************************************
12 * OpenScop: Structures and formats for polyhedral tools to talk together *
13 *****************************************************************************
14 * ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__, *
15 * / / / // // // // / / / // // / / // / /|,_, *
16 * / / / // // // // / / / // // / / // / / / /\ *
17 * |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/ \ *
18 * | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\ \ /\ *
19 * | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\ *
20 * | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \ \ *
21 * | P |n| l | = | s | t |=| = |d| = | = | = | | |=| o | | \# \ \ *
22 * | H | | y | | e | o | | = |l| | | = | | | | G | | \ \ \ *
23 * | I | | | | e | | | | | | | | | | | | | \ \ \ *
24 * | T | | | | | | | | | | | | | | | | | \ \ \ *
25 * | E | | | | | | | | | | | | | | | | | \ \ \ *
26 * | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | / \* \ \ *
27 * | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/ \ \ / *
28 * '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---' '--' *
30 * Copyright (C) 2008 University Paris-Sud 11 and INRIA *
32 * (3-clause BSD license) *
33 * Redistribution and use in source and binary forms, with or without *
34 * modification, are permitted provided that the following conditions *
37 * 1. Redistributions of source code must retain the above copyright notice, *
38 * this list of conditions and the following disclaimer. *
39 * 2. Redistributions in binary form must reproduce the above copyright *
40 * notice, this list of conditions and the following disclaimer in the *
41 * documentation and/or other materials provided with the distribution. *
42 * 3. The name of the author may not be used to endorse or promote products *
43 * derived from this software without specific prior written permission. *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
56 * OpenScop Library, a library to manipulate OpenScop formats and data *
57 * structures. Written by: *
58 * Cedric Bastoul <Cedric.Bastoul@u-psud.fr> and *
59 * Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr> *
61 *****************************************************************************/
64 #ifndef OSL_RELATION_H
65 # define OSL_RELATION_H
69 # include <osl/names.h>
70 # include <osl/vector.h>
72 # if defined(__cplusplus)
77 # define OSL_URI_RELATION "relation"
80 * The osl_relation_t structure stores a union of relations. It is a
81 * NULL-terminated linked list of relations. Each relation is described
82 * using a matrix where each row represents a linear constraint. The entries
83 * of each row are organised in the following order:
84 * - An equality/inequality tag: 0 means the row corresponds to an
85 * equality constraint == 0, 1 means it is an inequality >= 0.
86 * - The coefficients of the output dimensions.
87 * - The coefficients of the input dimensions (0 for a set).
88 * - The coefficients of the local (existentially quantified) dimensions.
89 * - The coefficients of the parameters.
90 * - The coefficient of the constant.
91 * Thus we have the following invariant: nb_columns =
92 * 1 + nb_output_dims + nb_input_dims + dims + nb_parameters + 1.
93 * Moreover we use the following conventions:
94 * - Sets (e.g., iteration domains) are the images of relations with a
95 * zero-dimensional domain, hence the number of input dimensions is 0.
96 * - The first output dimension of any access relations corresponds to
97 * the name of the array.
98 * The type field may provide some semantics about the relation, it may be:
99 * - Undefined : OSL_UNDEFINED,
100 * - An iteration domain : OSL_TYPE_DOMAIN,
101 * - A scattering relation : OSL_TYPE_SCATTERING,
102 * - An access relation : OSL_TYPE_ACCESS.
104 struct osl_relation
{
105 int type
; /**< Semantics about the relation */
106 int precision
; /**< Precision of relation matrix elements*/
107 int nb_rows
; /**< Number of rows */
108 int nb_columns
; /**< Number of columns */
109 int nb_output_dims
; /**< Number of output dimensions */
110 int nb_input_dims
; /**< Number of input dimensions */
111 int nb_local_dims
; /**< Number of local (existentially
112 quantified) dimensions */
113 int nb_parameters
; /**< Number of parameters */
114 osl_int_t
** m
; /**< An array of pointers to the beginning
115 of each row of the relation matrix */
116 void* usr
; /**< User-managed field, untouched by osl */
117 struct osl_relation
* next
; /**< Pointer to the next relation in the
118 union of relations (NULL if none) */
120 typedef struct osl_relation osl_relation_t
;
121 typedef struct osl_relation
* osl_relation_p
;
124 /*+***************************************************************************
125 * Structure display function *
126 *****************************************************************************/
127 void osl_relation_idump(FILE *, osl_relation_p
, int);
128 void osl_relation_dump(FILE *, osl_relation_p
);
129 char * osl_relation_expression(osl_relation_p relation
,
130 int row
, char ** names
);
131 char * osl_relation_spprint_polylib(osl_relation_p
, osl_names_p
);
132 char * osl_relation_spprint(osl_relation_p
, osl_names_p
);
133 void osl_relation_pprint(FILE *, osl_relation_p
, osl_names_p
);
134 char * osl_relation_sprint(osl_relation_p
);
135 void osl_relation_print(FILE *, osl_relation_p
);
137 // SCoPLib Compatibility
138 char * osl_relation_spprint_polylib_scoplib(osl_relation_p
,
139 osl_names_p
, int, int);
140 char * osl_relation_spprint_scoplib(osl_relation_p
, osl_names_p
,
142 void osl_relation_pprint_scoplib(FILE *, osl_relation_p
,
143 osl_names_p
, int, int);
145 /*****************************************************************************
147 *****************************************************************************/
148 osl_relation_p
osl_relation_pread(FILE *, int);
149 osl_relation_p
osl_relation_read(FILE *);
150 osl_relation_p
osl_relation_psread(char **, int);
151 osl_relation_p
osl_relation_sread(char **);
154 /*+***************************************************************************
155 * Memory allocation/deallocation function *
156 *****************************************************************************/
157 osl_relation_p
osl_relation_pmalloc(int, int, int);
158 osl_relation_p
osl_relation_malloc(int, int);
159 void osl_relation_free_inside(osl_relation_p
);
160 void osl_relation_free(osl_relation_p
);
163 /*+***************************************************************************
164 * Processing functions *
165 *****************************************************************************/
166 int osl_relation_nb_components(osl_relation_p relation
);
167 osl_relation_p
osl_relation_nclone(osl_relation_p
, int);
168 osl_relation_p
osl_relation_clone_nconstraints(osl_relation_p
, int);
169 osl_relation_p
osl_relation_clone(osl_relation_p
);
170 void osl_relation_add(osl_relation_p
*, osl_relation_p
);
171 osl_relation_p
osl_relation_union(osl_relation_p
, osl_relation_p
);
172 void osl_relation_replace_vector(osl_relation_p
, osl_vector_p
, int);
173 void osl_relation_insert_vector(osl_relation_p
, osl_vector_p
, int);
174 osl_relation_p
osl_relation_concat_vector(osl_relation_p
, osl_vector_p
);
175 void osl_relation_insert_blank_row(osl_relation_p
, int);
176 void osl_relation_insert_blank_column(osl_relation_p
, int);
177 void osl_relation_add_vector(osl_relation_p
, osl_vector_p
, int);
178 void osl_relation_sub_vector(osl_relation_p
, osl_vector_p
, int);
179 osl_relation_p
osl_relation_from_vector(osl_vector_p
);
180 void osl_relation_replace_constraints(osl_relation_p
,
181 osl_relation_p
, int);
182 void osl_relation_insert_constraints(osl_relation_p
,
183 osl_relation_p
, int);
184 void osl_relation_swap_constraints(osl_relation_p
, int, int);
185 void osl_relation_remove_row(osl_relation_p
, int);
186 void osl_relation_remove_column(osl_relation_p
, int);
187 void osl_relation_insert_columns(osl_relation_p
, osl_relation_p
,int);
188 osl_relation_p
osl_relation_concat_constraints(osl_relation_p
, osl_relation_p
);
189 int osl_relation_part_equal(osl_relation_p
, osl_relation_p
);
190 int osl_relation_equal(osl_relation_p
, osl_relation_p
);
191 int osl_relation_integrity_check(osl_relation_p
, int, int, int,int);
192 void osl_relation_set_attributes_one(osl_relation_p
,
194 void osl_relation_set_attributes(osl_relation_p
, int, int, int, int);
195 void osl_relation_set_type(osl_relation_p
, int);
196 int osl_relation_get_array_id(osl_relation_p
);
197 int osl_relation_is_access(osl_relation_p
);
198 void osl_relation_get_attributes(osl_relation_p
,
199 int *, int *, int *, int *, int *);
200 osl_relation_p
osl_relation_extend_output(osl_relation_p
, int);
201 osl_interface_p
osl_relation_interface();
202 void osl_relation_set_precision(int const, osl_relation_p
);
203 void osl_relation_set_same_precision(osl_relation_p
, osl_relation_p
);
205 # if defined(__cplusplus)
208 #endif /* define OSL_RELATION_H */