#include "ppl_c.h"
#include "cloog/cloog.h"
#include "graphite-cloog-util.h"
+#include "graphite-cloog-compat.h"
/* Counts the number of constraints in PCS. */
ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
ppl_delete_Coefficient (coef);
- if (mpz_sgn (matrix->p[row][0]))
+ if (mpz_sgn (matrix->p[row][0]) == 0)
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
else
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
/* Creates a CloogDomain from polyhedron PH. */
CloogDomain *
-new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph)
+new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params,
+ CloogState *state ATTRIBUTE_UNUSED)
{
CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
- CloogDomain *res = cloog_domain_matrix2domain (mat);
+ CloogDomain *res = cloog_domain_from_cloog_matrix (state, mat, nb_params);
cloog_matrix_free (mat);
return res;
}
+/* Create a CloogScattering from polyhedron PH. */
+
+CloogScattering *
+new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
+ int nb_params ATTRIBUTE_UNUSED,
+ int nb_scatt ATTRIBUTE_UNUSED,
+ CloogState *state ATTRIBUTE_UNUSED)
+{
+#ifdef CLOOG_ORG
+ CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
+ CloogScattering *res = cloog_scattering_from_cloog_matrix (state, mat,
+ nb_scatt,
+ nb_params);
+
+ cloog_matrix_free (mat);
+ return res;
+#else
+ return new_Cloog_Domain_from_ppl_Polyhedron (ph, nb_params, state);
+#endif
+}
+
/* Creates a CloogDomain from a pointset powerset PS. */
CloogDomain *
-new_Cloog_Domain_from_ppl_Pointset_Powerset (
- ppl_Pointset_Powerset_C_Polyhedron_t ps)
+new_Cloog_Domain_from_ppl_Pointset_Powerset
+ (ppl_Pointset_Powerset_C_Polyhedron_t ps, int nb_params,
+ CloogState *state ATTRIBUTE_UNUSED)
{
CloogDomain *res = NULL;
ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
CloogDomain *tmp;
ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
- tmp = new_Cloog_Domain_from_ppl_Polyhedron (ph);
+ tmp = new_Cloog_Domain_from_ppl_Polyhedron (ph, nb_params, state);
if (res == NULL)
res = tmp;
return res;
}
+
+/* Print to FILE the matrix MAT in OpenScop format. OUTPUT is the number
+ of output dimensions, INPUT is the number of input dimensions, LOCALS
+ is the number of existentially quantified variables and PARAMS is the
+ number of parameters. */
+
+static void
+openscop_print_cloog_matrix (FILE *file, CloogMatrix *mat,
+ int output, int input, int locals,
+ int params)
+{
+ int i, j;
+
+ fprintf (file, "%d %d %d %d %d %d \n", cloog_matrix_nrows (mat),
+ cloog_matrix_ncolumns (mat), output, input, locals, params);
+
+ for (i = 0; i < cloog_matrix_nrows (mat); i++)
+ {
+ for (j = 0; j < cloog_matrix_ncolumns (mat); j++)
+ if (j == 0)
+ fprintf (file, "%ld ", mpz_get_si (mat->p[i][j]));
+ else
+ fprintf (file, "%6ld ", mpz_get_si (mat->p[i][j]));
+
+ fprintf (file, "\n");
+ }
+}
+
+/* Print to FILE the polyhedron PH in OpenScop format. OUTPUT is the number
+ of output dimensions, INPUT is the number of input dimensions, LOCALS is
+ the number of existentially quantified variables and PARAMS is the number
+ of parameters. */
+
+void
+openscop_print_polyhedron_matrix (FILE *file, ppl_const_Polyhedron_t ph,
+ int output, int input, int locals,
+ int params)
+{
+ CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
+ openscop_print_cloog_matrix (file, mat, output, input, locals, params);
+ cloog_matrix_free (mat);
+}
+
+/* Read from FILE a matrix in OpenScop format. OUTPUT is the number of
+ output dimensions, INPUT is the number of input dimensions, LOCALS
+ is the number of existentially quantified variables and PARAMS is the
+ number of parameters. */
+
+static CloogMatrix *
+openscop_read_cloog_matrix (FILE *file, int *output, int *input, int *locals,
+ int *params)
+{
+ int nb_rows, nb_cols, i, j;
+ CloogMatrix *mat;
+ int *openscop_matrix_header, *matrix_line;
+
+ openscop_matrix_header = openscop_read_N_int (file, 6);
+
+ nb_rows = openscop_matrix_header[0];
+ nb_cols = openscop_matrix_header[1];
+ *output = openscop_matrix_header[2];
+ *input = openscop_matrix_header[3];
+ *locals = openscop_matrix_header[4];
+ *params = openscop_matrix_header[5];
+
+ free (openscop_matrix_header);
+
+ if (nb_rows == 0 || nb_cols == 0)
+ return NULL;
+
+ mat = cloog_matrix_alloc (nb_rows, nb_cols);
+ mat->NbRows = nb_rows;
+ mat->NbColumns = nb_cols;
+
+ for (i = 0; i < nb_rows; i++)
+ {
+ matrix_line = openscop_read_N_int (file, nb_cols);
+
+ for (j = 0; j < nb_cols; j++)
+ mpz_set_si (mat->p[i][j], matrix_line[j]);
+ }
+
+ return mat;
+}
+
+/* Read from FILE the polyhedron PH in OpenScop format. OUTPUT is the number
+ of output dimensions, INPUT is the number of input dimensions, LOCALS is
+ the number of existentially quantified variables and PARAMS is the number
+ of parameters. */
+
+void
+openscop_read_polyhedron_matrix (FILE *file, ppl_Polyhedron_t *ph,
+ int *output, int *input, int *locals,
+ int *params)
+{
+ CloogMatrix *mat;
+
+ mat = openscop_read_cloog_matrix (file, output, input, locals, params);
+
+ if (!mat)
+ *ph = NULL;
+ else
+ {
+ new_C_Polyhedron_from_Cloog_Matrix (ph, mat);
+ cloog_matrix_free (mat);
+ }
+}
+
#endif