Rename functions working on constraints
[openscop.git] / include / openscop / relation.h
blobca54139a88472dd8799db21582c49bb05c59fce3
2 /*+-----------------------------------------------------------------**
3 ** OpenScop Library **
4 **-----------------------------------------------------------------**
5 ** relation.h **
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 * '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---' '--' *
29 * *
30 * Copyright (C) 2008 University Paris-Sud 11 and INRIA *
31 * *
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 *
35 * are met: *
36 * *
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. *
44 * *
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. *
55 * *
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> *
60 * *
61 *****************************************************************************/
64 #ifndef OPENSCOP_RELATION_H
65 # define OPENSCOP_RELATION_H
67 # include <stdio.h>
68 # include <openscop/macros.h>
69 # include <openscop/util.h>
70 # include <openscop/names.h>
71 # include <openscop/vector.h>
74 # if defined(__cplusplus)
75 extern "C"
77 # endif
80 /**
81 * The openscop_relation_t structure stores a union of relations. It is a
82 * NULL-terminated linked list of relations. Each relation is described
83 * using a matrix where each row represents a linear constraint. The entries
84 * of each row are organised in the following order:
85 * - An equality/inequality tag: 0 means the row corresponds to an
86 * equality constraint == 0, 1 means it is an inequality >= 0.
87 * - The coefficients of the output dimensions.
88 * - The coefficients of the input dimensions (0 for a set).
89 * - The coefficients of the local (existentially quantified) dimensions.
90 * - The coefficients of the parameters.
91 * - The coefficient of the constant.
92 * Thus we have the following invariant: nb_columns =
93 * 1 + nb_output_dims + nb_input_dims + dims + nb_parameters + 1.
94 * Moreover we use the following conventions:
95 * - Sets (e.g., iteration domains) are the images of relations with a
96 * zero-dimensional domain, hence the number of input dimensions is 0.
97 * - The first output dimension of any access relations corresponds to
98 * the name of the array.
99 * The type field may provide some semantics about the relation, it may be:
100 * - Undefined : OPENSCOP_UNDEFINED,
101 * - An iteration domain : OPENSCOP_TYPE_DOMAIN,
102 * - A scattering relation : OPENSCOP_TYPE_SCATTERING,
103 * - An access relation : OPENSCOP_TYPE_ACCESS.
105 struct openscop_relation {
106 int type; /**< Semantics about the relation */
107 int nb_rows; /**< The number of rows */
108 int nb_columns; /**< The number of columns */
109 int nb_output_dims; /**< The number of output dimensions */
110 int nb_input_dims; /**< The number of input dimensions */
111 int nb_local_dims; /**< The number of local (existentially
112 quantified) dimensions */
113 int nb_parameters; /**< The number of parameters */
114 openscop_int_t ** m; /**< An array of pointers to the beginning
115 of each row of the relation matrix */
116 struct openscop_relation * next; /**< Pointer to the next relation in the
117 union of relations (NULL if none) */
119 typedef struct openscop_relation openscop_relation_t;
120 typedef struct openscop_relation * openscop_relation_p;
123 /*+***************************************************************************
124 * Structure display function *
125 *****************************************************************************/
126 void openscop_relation_idump(FILE *,
127 openscop_relation_p, int);
128 void openscop_relation_dump(FILE *, openscop_relation_p);
129 char * openscop_relation_expression(
130 openscop_relation_p relation,
131 int row, openscop_names_p names);
132 void openscop_relation_print(FILE *,
133 openscop_relation_p,
134 openscop_names_p);
137 /*****************************************************************************
138 * Reading function *
139 *****************************************************************************/
140 openscop_relation_p openscop_relation_read(FILE *);
141 openscop_relation_p openscop_relation_read_arrays(FILE *, char ***, int *);
144 /*+***************************************************************************
145 * Memory allocation/deallocation function *
146 *****************************************************************************/
147 openscop_relation_p openscop_relation_malloc(int, int);
148 void openscop_relation_free_inside(openscop_relation_p);
149 void openscop_relation_free(openscop_relation_p);
152 /*+***************************************************************************
153 * Processing functions *
154 *****************************************************************************/
155 openscop_relation_p openscop_relation_ncopy(openscop_relation_p, int);
156 openscop_relation_p openscop_relation_copy(openscop_relation_p);
157 void openscop_relation_replace_vector(openscop_relation_p,
158 openscop_vector_p, int);
159 void openscop_relation_insert_vector(openscop_relation_p,
160 openscop_vector_p, int);
161 void openscop_relation_add_vector(openscop_relation_p,
162 openscop_vector_p, int);
163 void openscop_relation_sub_vector(openscop_relation_p,
164 openscop_vector_p, int);
165 openscop_relation_p openscop_relation_from_vector(openscop_vector_p);
166 void openscop_relation_replace_constraints(openscop_relation_p,
167 openscop_relation_p, int);
168 void openscop_relation_insert_constraints(openscop_relation_p,
169 openscop_relation_p, int);
170 openscop_relation_p openscop_relation_concat_constraints(openscop_relation_p,
171 openscop_relation_p);
172 int openscop_relation_equal(openscop_relation_p,
173 openscop_relation_p);
174 int openscop_relation_integrity_check(openscop_relation_p,
175 int, int, int, int);
176 openscop_relation_p openscop_relation_union(openscop_relation_p,
177 openscop_relation_p);
178 void openscop_relation_set_type(openscop_relation_p, int);
179 int openscop_relation_get_array_id(openscop_relation_p);
180 int openscop_relation_is_access(openscop_relation_p);
183 # if defined(__cplusplus)
185 # endif
186 #endif /* define OPENSCOP_RELATION_H */