summaryrefslogtreecommitdiff
path: root/gcc/graphite-cloog-util.c
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-30 21:17:12 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-30 21:17:12 +0000
commit63b03ccf2817e57882dcee680da769eca1c14002 (patch)
treea0ccbcc73847fed9ec59209131f8140c27a2123a /gcc/graphite-cloog-util.c
parentf245969131cc40ce7db0870c1c610df3db9472fc (diff)
downloadgcc-63b03ccf2817e57882dcee680da769eca1c14002.tar.gz
Enable graphite to read an OpenScop file.
2010-08-12 Riyadh Baghdadi <baghdadi.mr@gmail.com> * graphite-cloog-util.c (openscop_read_cloog_matrix): New. (openscop_read_polyhedron_matrix): New. * graphite-cloog-util.h (openscop_read_polyhedron_matrix): Declared. (openscop_read_N_int): Same. * graphite-poly.c (openscop_read_N_int): New. (openscop_read_one_int): New. (openscop_read_N_string): New. (openscop_read_one_string): New. (openscop_read_powerset_matrix): New. (graphite_read_transforms): Remove. (graphite_read_scatt): New. (graphite_read_scop_file): New. (apply_poly_transforms): Updated to call graphite_read_scop_file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164778 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-cloog-util.c')
-rw-r--r--gcc/graphite-cloog-util.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 949e8d47031..40c6fbc004f 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -339,4 +339,69 @@ openscop_print_polyhedron_matrix (FILE *file, ppl_const_Polyhedron_t ph,
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