+/* When ORIG is true, pretty print to FILE all the original data
+ dependences of SCoP in DOT format, otherwise print the transformed
+ data deps. */
+
+static void
+dot_deps_stmt_2 (FILE *file, scop_p scop, bool orig)
+{
+ int i, j, k, l;
+ poly_bb_p pbb1, pbb2;
+ poly_dr_p pdr1, pdr2;
+
+ FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb1)
+ FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), j, pbb2)
+ {
+ FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb1), k, pdr1)
+ FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb2), l, pdr2)
+ {
+ poly_ddr_p pddr = new_poly_ddr (pdr1, pdr2, 1, orig);
+
+ if (!pddr_is_empty (pddr))
+ {
+ fprintf (file, orig ? "OS%d -> OS%d\n" : "TS%d -> TS%d\n",
+ pbb_index (pbb1), pbb_index (pbb2));
+
+ free_poly_ddr (pddr);
+ goto done;
+ }
+
+ free_poly_ddr (pddr);
+ }
+ done:;
+ }
+}
+
+/* Pretty print to FILE all the data dependences of SCoP in DOT
+ format. */
+
+static void
+dot_deps_stmt_1 (FILE *file, scop_p scop)
+{
+ fputs ("digraph all {\n", file);
+
+ dot_deps_stmt_2 (file, scop, true);
+ dot_deps_stmt_2 (file, scop, false);
+
+ fputs ("}\n\n", file);
+}
+
+/* When ORIG is true, pretty print to FILE all the original data
+ dependences of SCoP in DOT format, otherwise print the transformed
+ data deps. */
+
+static void
+dot_deps_2 (FILE *file, scop_p scop, bool orig)
+{
+ int i, j, k, l;
+ poly_bb_p pbb1, pbb2;
+ poly_dr_p pdr1, pdr2;
+
+ FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb1)
+ FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), j, pbb2)
+ FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb1), k, pdr1)
+ FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb2), l, pdr2)
+ {
+ poly_ddr_p pddr = new_poly_ddr (pdr1, pdr2, 1, orig);
+
+ if (!pddr_is_empty (pddr))
+ fprintf (file, orig
+ ? "OS%d_D%d -> OS%d_D%d\n" : "TS%d_D%d -> TS%d_D%d\n",
+ pbb_index (pbb1), PDR_ID (pdr1),
+ pbb_index (pbb2), PDR_ID (pdr2));
+
+ free_poly_ddr (pddr);
+ }
+}
+
+/* Pretty print to FILE all the data dependences of SCoP in DOT
+ format. */
+
+static void
+dot_deps_1 (FILE *file, scop_p scop)
+{
+ fputs ("digraph all {\n", file);
+
+ dot_deps_2 (file, scop, true);
+ dot_deps_2 (file, scop, false);
+
+ fputs ("}\n\n", file);
+}
+
+/* Display all the data dependences in SCoP using dotty. */
+
+DEBUG_FUNCTION void
+dot_deps (scop_p scop)
+{
+ /* When debugging, enable the following code. This cannot be used
+ in production compilers because it calls "system". */
+#if 0
+ FILE *stream = fopen ("/tmp/scopdeps.dot", "w");
+ gcc_assert (stream);
+
+ dot_deps_1 (stream, scop);
+ fclose (stream);
+
+ system ("dotty /tmp/scopdeps.dot &");
+#else
+ dot_deps_1 (stderr, scop);
+#endif
+}
+
+/* Display all the statement dependences in SCoP using dotty. */
+
+DEBUG_FUNCTION void
+dot_deps_stmt (scop_p scop)
+{
+ /* When debugging, enable the following code. This cannot be used
+ in production compilers because it calls "system". */
+#if 0
+ FILE *stream = fopen ("/tmp/scopdeps.dot", "w");
+ gcc_assert (stream);
+
+ dot_deps_stmt_1 (stream, scop);
+ fclose (stream);
+
+ system ("dotty /tmp/scopdeps.dot &");
+#else
+ dot_deps_stmt_1 (stderr, scop);
+#endif
+}
+