Move cloog-related functions from graphite-ppl.{c,h} to new graphite-cloog-util.{c,h}.

2010-07-05  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>

	* Makefile.in
	(OBJS-common): Added graphite-cloog-util.o.
	(graphite-clast-to-gimple.o): Added graphite-cloog-util.h.
	(graphite-cloog-util.o): New.
	(graphite-ppl.o): Added graphite-cloog-util.h.
	* graphite-clast-to-gimple.c:
	Added graphite-cloog-util.h to include statements.
	* graphite-cloog-util.c: New.
	(new_Cloog_Matrix_from_ppl_Polyhedron): Moved from graphite-ppl.c.
	(new_Cloog_Domain_from_ppl_Polyhedron): Same.
	(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
	(new_C_Polyhedron_from_Cloog_Matrix): Same.
	(insert_constraint_into_matrix): Same.
	(ppl_Constrain_System_number_of_constraints): Same.
	(new_Cloog_Matrix_from_ppl_Constraint_System): Same.
	(oppose_constraint): Same.
	(cloog_matrix_to_ppl_constraint): Same.
	(new_Constraint_System_from_Cloog_Matrix): Same.
	* graphite-cloog-util.h: New.
	(new_Cloog_Matrix_from_ppl_Polyhedron): Moved from graphite-ppl.h.
	(new_Cloog_Domain_from_ppl_Polyhedron): Same.
	(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
	(new_C_Polyhedron_from_Cloog_Matrix): Same.
	(insert_constraint_into_matrix): Same.
	* graphite-ppl.c:
	Added graphite-cloog-util.h to include statements.
	(new_Cloog_Matrix_from_ppl_Polyhedron): Moved to graphite-cloog-util.c.
	(new_Cloog_Domain_from_ppl_Polyhedron): Same.
	(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
	(new_C_Polyhedron_from_Cloog_Matrix): Same.
	(insert_constraint_into_matrix): Same.
	(ppl_Constrain_System_number_of_constraints): Same.
	(new_Cloog_Matrix_from_ppl_Constraint_System): Same.
	(oppose_constraint): Same.
	(cloog_matrix_to_ppl_constraint): Same.
	(new_Constraint_System_from_Cloog_Matrix): Same.
	* graphite-ppl.h:
	(new_Cloog_Matrix_from_ppl_Polyhedron): Moved to
	graphite-cloog-util.h.
	(new_Cloog_Domain_from_ppl_Polyhedron): Same.
	(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
	(new_C_Polyhedron_from_Cloog_Matrix): Same.
	(insert_constraint_into_matrix): Same.

From-SVN: r163134
This commit is contained in:
Andreas Simbuerger 2010-08-11 20:26:38 +00:00 committed by Sebastian Pop
parent 589ac63c0e
commit 0647324a1c
8 changed files with 403 additions and 250 deletions

View file

@ -1,3 +1,48 @@
2010-08-02 Andreas Simbuerger <simbuerg@fim.uni-passau.de>
* Makefile.in (OBJS-common): Added graphite-cloog-util.o.
(graphite-clast-to-gimple.o): Added graphite-cloog-util.h.
(graphite-cloog-util.o): New.
(graphite-ppl.o): Added graphite-cloog-util.h.
* graphite-clast-to-gimple.c:
Added graphite-cloog-util.h to include statements.
* graphite-cloog-util.c: New.
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved from graphite-ppl.c.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Same.
(ppl_Constrain_System_number_of_constraints): Same.
(new_Cloog_Matrix_from_ppl_Constraint_System): Same.
(oppose_constraint): Same.
(cloog_matrix_to_ppl_constraint): Same.
(new_Constraint_System_from_Cloog_Matrix): Same.
* graphite-cloog-util.h: New.
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved from graphite-ppl.h.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Same.
* graphite-ppl.c:
Added graphite-cloog-util.h to include statements.
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved to graphite-cloog-util.c.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Same.
(ppl_Constrain_System_number_of_constraints): Same.
(new_Cloog_Matrix_from_ppl_Constraint_System): Same.
(oppose_constraint): Same.
(cloog_matrix_to_ppl_constraint): Same.
(new_Constraint_System_from_Cloog_Matrix): Same.
* graphite-ppl.h:
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved to
graphite-cloog-util.h.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Same.
2010-08-02 Andreas Simbuerger <simbuerg@fim.uni-passau.de>
* graphite-clast-to-gimple.c

View file

@ -1,3 +1,49 @@
2010-07-05 Andreas Simbuerger <simbuerg@fim.uni-passau.de>
* Makefile.in
(OBJS-common): Added graphite-cloog-util.o.
(graphite-clast-to-gimple.o): Added graphite-cloog-util.h.
(graphite-cloog-util.o): New.
(graphite-ppl.o): Added graphite-cloog-util.h.
* graphite-clast-to-gimple.c:
Added graphite-cloog-util.h to include statements.
* graphite-cloog-util.c: New.
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved from graphite-ppl.c.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(ppl_Constrain_System_number_of_constraints): Same.
(new_Cloog_Matrix_from_ppl_Constraint_System): Same.
(oppose_constraint): Same.
(cloog_matrix_to_ppl_constraint): Same.
(new_Constraint_System_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Same. Declared static.
* graphite-cloog-util.h: New.
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved from graphite-ppl.h.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Same.
* graphite-ppl.c:
Added graphite-cloog-util.h to include statements.
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved to graphite-cloog-util.c.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Same.
(ppl_Constrain_System_number_of_constraints): Same.
(new_Cloog_Matrix_from_ppl_Constraint_System): Same.
(oppose_constraint): Same.
(cloog_matrix_to_ppl_constraint): Same.
(new_Constraint_System_from_Cloog_Matrix): Same.
* graphite-ppl.h:
(new_Cloog_Matrix_from_ppl_Polyhedron): Moved to
graphite-cloog-util.h.
(new_Cloog_Domain_from_ppl_Polyhedron): Same.
(new_Cloog_Domain_from_ppl_Pointset_Powerset): Same.
(new_C_Polyhedron_from_Cloog_Matrix): Same.
(insert_constraint_into_matrix): Removed.
2010-07-04 Andreas Simbuerger <simbuerg@fim.uni-passau.de>
* graphite-clast-to-gimple.c

View file

@ -1239,6 +1239,7 @@ OBJS-common = \
graphite.o \
graphite-blocking.o \
graphite-clast-to-gimple.o \
graphite-cloog-util.o \
graphite-dependences.o \
graphite-interchange.o \
graphite-poly.o \
@ -2679,9 +2680,11 @@ graphite-clast-to-gimple.o: graphite-clast-to-gimple.c $(CONFIG_H) \
$(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) $(TOPLEV_H) $(DIAGNOSTIC_CORE_H) \
$(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) $(CFGLOOP_H) $(GIMPLE_H) \
$(TREE_DATA_REF_H) tree-pass.h domwalk.h graphite.h \
pointer-set.h value-prof.h graphite-ppl.h sese.h \
pointer-set.h value-prof.h graphite-cloog-util.h graphite-ppl.h sese.h \
graphite-scop-detection.h graphite-clast-to-gimple.h graphite-poly.h \
graphite-dependences.h
graphite-cloog-util.o: graphite-cloog-util.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TMP_H) $(GGC_H)
graphite-dependences.o: graphite-dependences.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h \
$(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) \
@ -2701,7 +2704,7 @@ graphite-poly.o: graphite-poly.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
pointer-set.h value-prof.h graphite-ppl.h sese.h output.h graphite-poly.h \
tree-pretty-print.h gimple-pretty-print.h
graphite-ppl.o: graphite-ppl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(GGC_H) graphite-ppl.h
$(GGC_H) graphite-ppl.h graphite-cloog-util.h
graphite-scop-detection.o: graphite-scop-detection.c $(CONFIG_H) $(SYSTEM_H) \
$(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) $(TOPLEV_H) $(DIAGNOSTIC_CORE_H) \
$(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) $(CFGLOOP_H) $(GIMPLE_H) \

View file

@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see
#ifdef HAVE_cloog
#include "cloog/cloog.h"
#include "ppl_c.h"
#include "graphite-cloog-util.h"
#include "graphite-ppl.h"
#include "graphite.h"
#include "graphite-poly.h"

275
gcc/graphite-cloog-util.c Normal file
View file

@ -0,0 +1,275 @@
/* Gimple Represented as Polyhedra.
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@inria.fr>
and Tobias Grosser <grosser@fim.uni-passau.de>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "ggc.h"
#ifdef HAVE_cloog
#include "ppl_c.h"
#include "cloog/cloog.h"
#include "graphite-cloog-util.h"
/* Counts the number of constraints in PCS. */
static int
ppl_Constrain_System_number_of_constraints (ppl_const_Constraint_System_t pcs)
{
ppl_Constraint_System_const_iterator_t cit, end;
int num = 0;
ppl_new_Constraint_System_const_iterator (&cit);
ppl_new_Constraint_System_const_iterator (&end);
for (ppl_Constraint_System_begin (pcs, cit),
ppl_Constraint_System_end (pcs, end);
!ppl_Constraint_System_const_iterator_equal_test (cit, end);
ppl_Constraint_System_const_iterator_increment (cit))
num++;
ppl_delete_Constraint_System_const_iterator (cit);
ppl_delete_Constraint_System_const_iterator (end);
return num;
}
static void
oppose_constraint (CloogMatrix *m, int row)
{
int k;
/* Do not oppose the first column: it is the eq/ineq one. */
for (k = 1; k < m->NbColumns; k++)
mpz_neg (m->p[row][k], m->p[row][k]);
}
/* Inserts constraint CSTR at row ROW of matrix M. */
static void
insert_constraint_into_matrix (CloogMatrix *m, int row,
ppl_const_Constraint_t cstr)
{
ppl_Coefficient_t c;
ppl_dimension_type i, dim, nb_cols = m->NbColumns;
ppl_Constraint_space_dimension (cstr, &dim);
ppl_new_Coefficient (&c);
for (i = 0; i < dim; i++)
{
ppl_Constraint_coefficient (cstr, i, c);
ppl_Coefficient_to_mpz_t (c, m->p[row][i + 1]);
}
for (i = dim; i < nb_cols - 1; i++)
mpz_set_si (m->p[row][i + 1], 0);
ppl_Constraint_inhomogeneous_term (cstr, c);
ppl_Coefficient_to_mpz_t (c, m->p[row][nb_cols - 1]);
mpz_set_si (m->p[row][0], 1);
switch (ppl_Constraint_type (cstr))
{
case PPL_CONSTRAINT_TYPE_LESS_THAN:
oppose_constraint (m, row);
case PPL_CONSTRAINT_TYPE_GREATER_THAN:
mpz_sub_ui (m->p[row][nb_cols - 1],
m->p[row][nb_cols - 1], 1);
break;
case PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL:
oppose_constraint (m, row);
case PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL:
break;
case PPL_CONSTRAINT_TYPE_EQUAL:
mpz_set_si (m->p[row][0], 0);
break;
default:
/* Not yet implemented. */
gcc_unreachable();
}
ppl_delete_Coefficient (c);
}
/* Creates a CloogMatrix from constraint system PCS. */
static CloogMatrix *
new_Cloog_Matrix_from_ppl_Constraint_System (ppl_const_Constraint_System_t pcs)
{
CloogMatrix *matrix;
ppl_Constraint_System_const_iterator_t cit, end;
ppl_dimension_type dim;
int rows;
int row = 0;
rows = ppl_Constrain_System_number_of_constraints (pcs);
ppl_Constraint_System_space_dimension (pcs, &dim);
matrix = cloog_matrix_alloc (rows, dim + 2);
ppl_new_Constraint_System_const_iterator (&cit);
ppl_new_Constraint_System_const_iterator (&end);
for (ppl_Constraint_System_begin (pcs, cit),
ppl_Constraint_System_end (pcs, end);
!ppl_Constraint_System_const_iterator_equal_test (cit, end);
ppl_Constraint_System_const_iterator_increment (cit))
{
ppl_const_Constraint_t c;
ppl_Constraint_System_const_iterator_dereference (cit, &c);
insert_constraint_into_matrix (matrix, row, c);
row++;
}
ppl_delete_Constraint_System_const_iterator (cit);
ppl_delete_Constraint_System_const_iterator (end);
return matrix;
}
/* Creates a CloogMatrix from polyhedron PH. */
CloogMatrix *
new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph)
{
ppl_const_Constraint_System_t pcs;
CloogMatrix *res;
ppl_Polyhedron_get_constraints (ph, &pcs);
res = new_Cloog_Matrix_from_ppl_Constraint_System (pcs);
return res;
}
/* Translates row ROW of the CloogMatrix MATRIX to a PPL Constraint. */
static ppl_Constraint_t
cloog_matrix_to_ppl_constraint (CloogMatrix *matrix, int row)
{
int j;
ppl_Constraint_t cstr;
ppl_Coefficient_t coef;
ppl_Linear_Expression_t expr;
ppl_dimension_type dim = matrix->NbColumns - 2;
ppl_new_Coefficient (&coef);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
for (j = 1; j < matrix->NbColumns - 1; j++)
{
ppl_assign_Coefficient_from_mpz_t (coef, matrix->p[row][j]);
ppl_Linear_Expression_add_to_coefficient (expr, j - 1, coef);
}
ppl_assign_Coefficient_from_mpz_t (coef,
matrix->p[row][matrix->NbColumns - 1]);
ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
ppl_delete_Coefficient (coef);
if (mpz_sgn (matrix->p[row][0]))
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
else
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
ppl_delete_Linear_Expression (expr);
return cstr;
}
/* Creates a PPL constraint system from MATRIX. */
static void
new_Constraint_System_from_Cloog_Matrix (ppl_Constraint_System_t *pcs,
CloogMatrix *matrix)
{
int i;
ppl_new_Constraint_System (pcs);
for (i = 0; i < matrix->NbRows; i++)
{
ppl_Constraint_t c = cloog_matrix_to_ppl_constraint (matrix, i);
ppl_Constraint_System_insert_Constraint (*pcs, c);
ppl_delete_Constraint (c);
}
}
/* Creates a PPL Polyhedron from MATRIX. */
void
new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *ph,
CloogMatrix *matrix)
{
ppl_Constraint_System_t cs;
new_Constraint_System_from_Cloog_Matrix (&cs, matrix);
ppl_new_C_Polyhedron_recycle_Constraint_System (ph, cs);
}
/* Creates a CloogDomain from polyhedron PH. */
CloogDomain *
new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph)
{
CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
CloogDomain *res = cloog_domain_matrix2domain (mat);
cloog_matrix_free (mat);
return res;
}
/* Creates a CloogDomain from a pointset powerset PS. */
CloogDomain *
new_Cloog_Domain_from_ppl_Pointset_Powerset (
ppl_Pointset_Powerset_C_Polyhedron_t ps)
{
CloogDomain *res = NULL;
ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it);
ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end);
for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it),
ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end);
!ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end);
ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it))
{
ppl_const_Polyhedron_t ph;
CloogDomain *tmp;
ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
tmp = new_Cloog_Domain_from_ppl_Polyhedron (ph);
if (res == NULL)
res = tmp;
else
res = cloog_domain_union (res, tmp);
}
ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it);
ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end);
gcc_assert (res != NULL);
return res;
}
#endif

30
gcc/graphite-cloog-util.h Normal file
View file

@ -0,0 +1,30 @@
/* Gimple Represented as Polyhedra.
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@inria.fr>
and Tobias Grosser <grosser@fim.uni-passau.de>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GRAPHITE_CLOOG_UTIL_H
#define GRAPHITE_CLOOG_UTIL_H
CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
CloogDomain * new_Cloog_Domain_from_ppl_Pointset_Powerset (
ppl_Pointset_Powerset_C_Polyhedron_t);
void new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *, CloogMatrix *);
#endif /* GRAPHITE_CLOOG_UTIL_H */

View file

@ -29,250 +29,9 @@ along with GCC; see the file COPYING3. If not see
#include "ppl_c.h"
#include "cloog/cloog.h"
#include "graphite-cloog-util.h"
#include "graphite-ppl.h"
/* Translates row ROW of the CloogMatrix MATRIX to a PPL Constraint. */
static ppl_Constraint_t
cloog_matrix_to_ppl_constraint (CloogMatrix *matrix, int row)
{
int j;
ppl_Constraint_t cstr;
ppl_Coefficient_t coef;
ppl_Linear_Expression_t expr;
ppl_dimension_type dim = matrix->NbColumns - 2;
ppl_new_Coefficient (&coef);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
for (j = 1; j < matrix->NbColumns - 1; j++)
{
ppl_assign_Coefficient_from_mpz_t (coef, matrix->p[row][j]);
ppl_Linear_Expression_add_to_coefficient (expr, j - 1, coef);
}
ppl_assign_Coefficient_from_mpz_t (coef,
matrix->p[row][matrix->NbColumns - 1]);
ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
ppl_delete_Coefficient (coef);
if (mpz_sgn (matrix->p[row][0]))
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
else
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
ppl_delete_Linear_Expression (expr);
return cstr;
}
/* Creates a PPL constraint system from MATRIX. */
static void
new_Constraint_System_from_Cloog_Matrix (ppl_Constraint_System_t *pcs,
CloogMatrix *matrix)
{
int i;
ppl_new_Constraint_System (pcs);
for (i = 0; i < matrix->NbRows; i++)
{
ppl_Constraint_t c = cloog_matrix_to_ppl_constraint (matrix, i);
ppl_Constraint_System_insert_Constraint (*pcs, c);
ppl_delete_Constraint (c);
}
}
/* Creates a PPL Polyhedron from MATRIX. */
void
new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *ph,
CloogMatrix *matrix)
{
ppl_Constraint_System_t cs;
new_Constraint_System_from_Cloog_Matrix (&cs, matrix);
ppl_new_C_Polyhedron_recycle_Constraint_System (ph, cs);
}
/* Counts the number of constraints in PCS. */
static int
ppl_Constrain_System_number_of_constraints (ppl_const_Constraint_System_t pcs)
{
ppl_Constraint_System_const_iterator_t cit, end;
int num = 0;
ppl_new_Constraint_System_const_iterator (&cit);
ppl_new_Constraint_System_const_iterator (&end);
for (ppl_Constraint_System_begin (pcs, cit),
ppl_Constraint_System_end (pcs, end);
!ppl_Constraint_System_const_iterator_equal_test (cit, end);
ppl_Constraint_System_const_iterator_increment (cit))
num++;
ppl_delete_Constraint_System_const_iterator (cit);
ppl_delete_Constraint_System_const_iterator (end);
return num;
}
static void
oppose_constraint (CloogMatrix *m, int row)
{
int k;
/* Do not oppose the first column: it is the eq/ineq one. */
for (k = 1; k < m->NbColumns; k++)
mpz_neg (m->p[row][k], m->p[row][k]);
}
/* Inserts constraint CSTR at row ROW of matrix M. */
void
insert_constraint_into_matrix (CloogMatrix *m, int row,
ppl_const_Constraint_t cstr)
{
ppl_Coefficient_t c;
ppl_dimension_type i, dim, nb_cols = m->NbColumns;
ppl_Constraint_space_dimension (cstr, &dim);
ppl_new_Coefficient (&c);
for (i = 0; i < dim; i++)
{
ppl_Constraint_coefficient (cstr, i, c);
ppl_Coefficient_to_mpz_t (c, m->p[row][i + 1]);
}
for (i = dim; i < nb_cols - 1; i++)
mpz_set_si (m->p[row][i + 1], 0);
ppl_Constraint_inhomogeneous_term (cstr, c);
ppl_Coefficient_to_mpz_t (c, m->p[row][nb_cols - 1]);
mpz_set_si (m->p[row][0], 1);
switch (ppl_Constraint_type (cstr))
{
case PPL_CONSTRAINT_TYPE_LESS_THAN:
oppose_constraint (m, row);
case PPL_CONSTRAINT_TYPE_GREATER_THAN:
mpz_sub_ui (m->p[row][nb_cols - 1],
m->p[row][nb_cols - 1], 1);
break;
case PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL:
oppose_constraint (m, row);
case PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL:
break;
case PPL_CONSTRAINT_TYPE_EQUAL:
mpz_set_si (m->p[row][0], 0);
break;
default:
/* Not yet implemented. */
gcc_unreachable();
}
ppl_delete_Coefficient (c);
}
/* Creates a CloogMatrix from constraint system PCS. */
static CloogMatrix *
new_Cloog_Matrix_from_ppl_Constraint_System (ppl_const_Constraint_System_t pcs)
{
CloogMatrix *matrix;
ppl_Constraint_System_const_iterator_t cit, end;
ppl_dimension_type dim;
int rows;
int row = 0;
rows = ppl_Constrain_System_number_of_constraints (pcs);
ppl_Constraint_System_space_dimension (pcs, &dim);
matrix = cloog_matrix_alloc (rows, dim + 2);
ppl_new_Constraint_System_const_iterator (&cit);
ppl_new_Constraint_System_const_iterator (&end);
for (ppl_Constraint_System_begin (pcs, cit),
ppl_Constraint_System_end (pcs, end);
!ppl_Constraint_System_const_iterator_equal_test (cit, end);
ppl_Constraint_System_const_iterator_increment (cit))
{
ppl_const_Constraint_t c;
ppl_Constraint_System_const_iterator_dereference (cit, &c);
insert_constraint_into_matrix (matrix, row, c);
row++;
}
ppl_delete_Constraint_System_const_iterator (cit);
ppl_delete_Constraint_System_const_iterator (end);
return matrix;
}
/* Creates a CloogMatrix from polyhedron PH. */
CloogMatrix *
new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph)
{
ppl_const_Constraint_System_t pcs;
CloogMatrix *res;
ppl_Polyhedron_get_constraints (ph, &pcs);
res = new_Cloog_Matrix_from_ppl_Constraint_System (pcs);
return res;
}
/* Creates a CloogDomain from polyhedron PH. */
CloogDomain *
new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph)
{
CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
CloogDomain *res = cloog_domain_matrix2domain (mat);
cloog_matrix_free (mat);
return res;
}
/* Creates a CloogDomain from a pointset powerset PS. */
CloogDomain *
new_Cloog_Domain_from_ppl_Pointset_Powerset (
ppl_Pointset_Powerset_C_Polyhedron_t ps)
{
CloogDomain *res = NULL;
ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it);
ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end);
for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it),
ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end);
!ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end);
ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it))
{
ppl_const_Polyhedron_t ph;
CloogDomain *tmp;
ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
tmp = new_Cloog_Domain_from_ppl_Polyhedron (ph);
if (res == NULL)
res = tmp;
else
res = cloog_domain_union (res, tmp);
}
ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it);
ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end);
gcc_assert (res != NULL);
return res;
}
/* Set the inhomogeneous term of E to X. */
void

View file

@ -24,12 +24,6 @@ along with GCC; see the file COPYING3. If not see
#include "double-int.h"
#include "tree.h"
CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
CloogDomain * new_Cloog_Domain_from_ppl_Pointset_Powerset (
ppl_Pointset_Powerset_C_Polyhedron_t);
void new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *, CloogMatrix *);
void insert_constraint_into_matrix (CloogMatrix *, int, ppl_const_Constraint_t);
ppl_Polyhedron_t ppl_strip_loop (ppl_Polyhedron_t, ppl_dimension_type, int);
int ppl_lexico_compare_linear_expressions (ppl_Linear_Expression_t,
ppl_Linear_Expression_t);