2 /**-------------------------------------------------------------------**
4 **-------------------------------------------------------------------**
6 **-------------------------------------------------------------------**
7 ** First version: october 28th 2001 **
8 **-------------------------------------------------------------------**/
11 /******************************************************************************
12 * CLooG : the Chunky Loop Generator (experimental) *
13 ******************************************************************************
15 * Copyright (C) 2001-2005 Cedric Bastoul *
17 * This is free software; you can redistribute it and/or modify it under the *
18 * terms of the GNU General Public License as published by the Free Software *
19 * Foundation; either version 2 of the License, or (at your option) any later *
22 * This software is distributed in the hope that it will be useful, but *
23 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
24 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
27 * You should have received a copy of the GNU General Public License along *
28 * with software; if not, write to the Free Software Foundation, Inc., *
29 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
31 * CLooG, the Chunky Loop Generator *
32 * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr *
34 ******************************************************************************/
37 #ifndef CLOOG_DOMAIN_H
38 #define CLOOG_DOMAIN_H
39 #if defined(__cplusplus)
45 /* The Polyhedron structure comes directly from PolyLib (defined in
46 * polylib/types.h) here is how it looks like (at least in PolyLib 5.20.0
49 * typedef struct polyhedron {
50 * unsigned Dimension, // Dimension number (NbColumns-2 in Matrix).
51 * NbConstraints, // Number of constraints (NbRows in Matrix).
52 * NbRays, // Number of rays in dual representation.
53 * NbEq, // Number of vertices (?).
54 * NbBid; // Number of extremal rays (?).
55 * Value **Constraint; // The pointers to rows in matrix representation.
56 * Value **Ray; // The pointers to rays in dual representation.
57 * Value *p_Init; // The whole data, consecutive in memory.
58 * int p_Init_size; // To clear values in GMP mode.
59 * struct polyhedron *next; // Pointer to next component of the union.
65 * CloogDomain structure:
66 * this structure contains a polyhedron in the PolyLib shape and the number of
67 * active references to this structure. Because CLooG uses many copies of
68 * domains there is no need to actually copy these domains but just to return
69 * a pointer to them and to increment the number of active references. Each time
70 * a CloogDomain will be freed, we will decrement the active reference counter
71 * and actually free it if its value is zero.
74 { Polyhedron
* polyhedron
; /**< The polyhedral domain. */
75 int references
; /**< Number of references to this structure. */
77 typedef struct cloogdomain CloogDomain
;
81 * CloogDomainList structure:
82 * this structure reprensents a node of a linked list of CloogDomain structures.
84 struct cloogdomainlist
85 { CloogDomain
* domain
; /**< An element of the list. */
86 struct cloogdomainlist
* next
;/**< Pointer to the next element of the list.*/
88 typedef struct cloogdomainlist CloogDomainList
;
90 static inline Polyhedron
* cloog_domain_polyhedron(CloogDomain
* domain
)
91 { return domain
->polyhedron
;
94 static inline Polyhedron
* cloog_domain_polyhedron_set(CloogDomain
*d
,
96 { return d
->polyhedron
= p
;
99 static inline Polyhedron
* cloog_domain_polyhedron_next(CloogDomain
* domain
)
100 { return domain
->polyhedron
->next
;
103 static inline Polyhedron
* cloog_domain_polyhedron_set_next(CloogDomain
*d
,
105 { return d
->polyhedron
->next
= p
;
108 static inline int cloog_domain_nbconstraints(CloogDomain
* domain
)
109 { return domain
->polyhedron
->NbConstraints
;
112 static inline int cloog_domain_isconvex(CloogDomain
* domain
)
113 { return !cloog_domain_polyhedron_next (domain
);
116 static inline unsigned cloog_polyhedron_nbeq (Polyhedron
*p
)
121 static inline unsigned cloog_domain_nbeq (CloogDomain
*d
)
123 return cloog_polyhedron_nbeq (cloog_domain_polyhedron (d
));
126 static inline unsigned cloog_polyhedron_dim (Polyhedron
*p
)
131 static inline unsigned cloog_domain_dim (CloogDomain
*d
)
133 return cloog_polyhedron_dim (cloog_domain_polyhedron (d
));
136 /******************************************************************************
137 * PolyLib interface *
138 ******************************************************************************/
139 CloogMatrix
* cloog_simplify_domain_matrix_with_equalities (CloogDomain
*, int,
141 void cloog_domain_print(FILE *, CloogDomain
*) ;
142 void cloog_polyhedron_print(FILE *, Polyhedron
*) ;
143 void cloog_domain_free(CloogDomain
*) ;
144 CloogDomain
* cloog_domain_copy(CloogDomain
*) ;
145 CloogDomain
* cloog_domain_convex(CloogDomain
* Pol
) ;
146 CloogDomain
* cloog_domain_simple_convex(CloogDomain
* domain
, int nb_par
);
147 CloogDomain
* cloog_domain_simplify(CloogDomain
*, CloogDomain
*) ;
148 CloogDomain
* cloog_domain_union(CloogDomain
*, CloogDomain
*) ;
149 CloogDomain
* cloog_domain_intersection(CloogDomain
*, CloogDomain
*) ;
150 CloogDomain
* cloog_domain_difference(CloogDomain
*, CloogDomain
*) ;
151 CloogDomain
* cloog_domain_addconstraints(CloogDomain
*, CloogDomain
*) ;
152 void cloog_domain_sort(Polyhedron
**,unsigned,unsigned,unsigned,int *);
153 CloogDomain
* cloog_domain_empty(int) ;
156 /******************************************************************************
157 * Structure display function *
158 ******************************************************************************/
159 void cloog_domain_print_structure(FILE *, CloogDomain
*, int) ;
160 void cloog_domain_list_print(FILE *, CloogDomainList
*) ;
163 /******************************************************************************
164 * Memory deallocation function *
165 ******************************************************************************/
166 void cloog_domain_list_free(CloogDomainList
*) ;
169 /*+****************************************************************************
171 ******************************************************************************/
172 CloogDomain
* cloog_domain_read(FILE *) ;
173 CloogDomain
* cloog_domain_union_read(FILE *) ;
174 CloogDomainList
* cloog_domain_list_read(FILE *) ;
177 /******************************************************************************
178 * Processing functions *
179 ******************************************************************************/
180 CloogDomain
* cloog_domain_alloc(Polyhedron
*) ;
181 int cloog_domain_isempty(CloogDomain
*) ;
182 CloogDomain
* cloog_domain_project(CloogDomain
*, int, int) ;
183 CloogDomain
* cloog_domain_extend(CloogDomain
*, int, int) ;
184 int cloog_domain_never_integral(CloogDomain
*) ;
185 void cloog_domain_stride(CloogDomain
*, int, int, Value
*, Value
*) ;
186 int cloog_domain_integral_lowerbound(CloogDomain
*, int, Value
*) ;
187 void cloog_domain_lowerbound_update(CloogDomain
*, int, Value
) ;
188 int cloog_domain_lazy_disjoint(CloogDomain
*, CloogDomain
*) ;
189 int cloog_domain_lazy_equal(CloogDomain
*, CloogDomain
*) ;
190 int cloog_domain_lazy_block(CloogDomain
*, CloogDomain
*,
191 CloogDomainList
*, int) ;
192 int cloog_domain_lazy_isscalar(CloogDomain
*, int) ;
193 int cloog_domain_list_lazy_same(CloogDomainList
*) ;
194 void cloog_domain_scalar(CloogDomain
*, int, Value
*) ;
195 CloogDomain
* cloog_domain_cut_first(CloogDomain
*) ;
196 CloogDomain
* cloog_domain_erase_dimension(CloogDomain
*, int) ;
198 #if defined(__cplusplus)
201 #endif /* define _H */