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
;
91 /******************************************************************************
92 * Memory leak hunt functions *
93 ******************************************************************************/
94 void cloog_value_leak_up() ;
95 void cloog_value_leak_down() ;
98 /******************************************************************************
100 ******************************************************************************/
101 CloogDomain
* cloog_domain_matrix2domain(Matrix
*) ;
102 Matrix
* cloog_domain_domain2matrix(CloogDomain
*) ;
103 void cloog_domain_print(FILE *, CloogDomain
*) ;
104 void cloog_polyhedron_print(FILE *, Polyhedron
*) ;
105 void cloog_domain_free(CloogDomain
*) ;
106 CloogDomain
* cloog_domain_copy(CloogDomain
*) ;
107 CloogDomain
* cloog_domain_image(CloogDomain
*, Matrix
*) ;
108 CloogDomain
* cloog_domain_preimage(CloogDomain
*, Matrix
*) ;
109 CloogDomain
* cloog_domain_convex(CloogDomain
* Pol
) ;
110 CloogDomain
* cloog_domain_simplify(CloogDomain
*, CloogDomain
*) ;
111 CloogDomain
* cloog_domain_union(CloogDomain
*, CloogDomain
*) ;
112 CloogDomain
* cloog_domain_disjoint(CloogDomain
*) ;
113 CloogDomain
* cloog_domain_intersection(CloogDomain
*, CloogDomain
*) ;
114 CloogDomain
* cloog_domain_difference(CloogDomain
*, CloogDomain
*) ;
115 int cloog_domain_includes(CloogDomain
*, CloogDomain
*) ;
116 CloogDomain
* cloog_domain_addconstraints(CloogDomain
*, CloogDomain
*) ;
117 void cloog_domain_sort(Polyhedron
**,unsigned,unsigned,unsigned,int *);
118 CloogDomain
* cloog_domain_empty(int) ;
121 /******************************************************************************
122 * Structure display function *
123 ******************************************************************************/
124 void cloog_domain_print_structure(FILE *, CloogDomain
*, int) ;
125 void cloog_domain_list_print(FILE *, CloogDomainList
*) ;
128 /******************************************************************************
129 * Memory deallocation function *
130 ******************************************************************************/
131 void cloog_domain_list_free(CloogDomainList
*) ;
134 /*+****************************************************************************
136 ******************************************************************************/
137 CloogDomain
* cloog_domain_read(FILE *) ;
138 CloogDomain
* cloog_domain_union_read(FILE *) ;
139 CloogDomainList
* cloog_domain_list_read(FILE *) ;
142 /******************************************************************************
143 * Processing functions *
144 ******************************************************************************/
145 CloogDomain
* cloog_domain_malloc() ;
146 CloogDomain
* cloog_domain_alloc(Polyhedron
*) ;
147 CloogDomain
* cloog_domain_compact(CloogDomain
*) ;
148 int cloog_domain_isempty(CloogDomain
*) ;
149 int cloog_domain_universe(CloogDomain
*) ;
150 CloogDomain
* cloog_domain_project(CloogDomain
*, int, int) ;
151 CloogDomain
* cloog_domain_extend(CloogDomain
*, int, int) ;
152 int cloog_domain_never_integral(CloogDomain
*) ;
153 void cloog_domain_stride(CloogDomain
*, int, int, Value
*, Value
*) ;
154 int cloog_domain_integral_lowerbound(CloogDomain
*, int, Value
*) ;
155 void cloog_domain_lowerbound_update(CloogDomain
*, int, Value
) ;
156 int cloog_domain_lazy_disjoint(CloogDomain
*, CloogDomain
*) ;
157 int cloog_domain_lazy_equal(CloogDomain
*, CloogDomain
*) ;
158 int cloog_domain_lazy_block(CloogDomain
*, CloogDomain
*,
159 CloogDomainList
*, int) ;
160 int cloog_domain_lazy_isscalar(CloogDomain
*, int) ;
161 int cloog_domain_list_lazy_same(CloogDomainList
*) ;
162 void cloog_domain_scalar(CloogDomain
*, int, Value
*) ;
163 CloogDomain
* cloog_domain_grow(CloogDomain
*, int, int) ;
164 CloogDomain
* cloog_domain_cut_first(CloogDomain
*) ;
165 CloogDomain
* cloog_domain_erase_dimension(CloogDomain
*, int) ;
166 void cloog_domain_reverse(CloogDomain
*) ;
167 void cloog_domain_line_update(Polyhedron
*, CloogMatrix
*, int, int) ;
169 #define cloog_domain_polyhedron(x) (x)->polyhedron
170 #define cloog_domain_dimension(x) (x)->polyhedron->Dimension
171 #define cloog_domain_nbconstraints(x) (x)->polyhedron->NbConstraints
172 #define cloog_domain_isconvex(x) ((x)->polyhedron->next == NULL)? 1 : 0
174 Polyhedron * cloog_domain_polyhedron(CloogDomain *) ;
175 int cloog_domain_dimension(CloogDomain *) ;
176 int cloog_domain_nbconstraints(CloogDomain *) ;
177 int cloog_domain_isconvex(CloogDomain *) ;
180 #if defined(__cplusplus)
183 #endif /* define _H */