modulo-sched: print sccs and check it
authorRevital Eres <eres@il.ibm.com>
Tue, 3 Jul 2007 10:27:19 +0000 (10:27 +0000)
committerRevital Eres <revitale@gcc.gnu.org>
Tue, 3 Jul 2007 10:27:19 +0000 (10:27 +0000)
From-SVN: r126249

gcc/ChangeLog
gcc/ddg.c
gcc/ddg.h
gcc/modulo-sched.c

index 35f68c1d945c6b91f54fd936c07d860e0ac30e2d..2b9b2452df57842ecd3e9922b81dd8435f74a9a0 100644 (file)
@@ -1,3 +1,11 @@
+2007-07-03  Revital Eres  <eres@il.ibm.com>
+
+       * ddg.c (print_sccs): New function.
+       (check_sccs): New function.
+       (create_ddg_all_sccs): Use it.
+       * ddg.h (print_sccs): Declare.
+       * modulo-sched.c (sms_order_nodes): Call print_sccs.
+
 2007-07-03  Uros Bizjak  <ubizjak@gmail.com>
 
        * targhooks.h (default_mode_for_suffix): New function declaration.
index 882cc818a322f54405f6d0433cfa6653b6e0ed1d..9822806546077e7493d93c1969806f8263c7eea1 100644 (file)
--- a/gcc/ddg.c
+++ b/gcc/ddg.c
@@ -630,6 +630,30 @@ vcg_print_ddg (FILE *file, ddg_ptr g)
   fprintf (file, "}\n");
 }
 
+/* Dump the sccs in SCCS.  */
+void
+print_sccs (FILE *file, ddg_all_sccs_ptr sccs, ddg_ptr g)
+{
+  unsigned int u = 0;
+  sbitmap_iterator sbi;
+  int i;
+
+  if (!file)
+    return;
+
+  fprintf (file, "\n;; Number of SCC nodes - %d\n", sccs->num_sccs);
+  for (i = 0; i < sccs->num_sccs; i++)
+    {
+      fprintf (file, "SCC number: %d\n", i);
+      EXECUTE_IF_SET_IN_SBITMAP (sccs->sccs[i]->nodes, 0, u, sbi)
+      {
+        fprintf (file, "insn num %d\n", u);
+        print_rtl_single (file, g->nodes[u].insn);
+      }
+    }
+  fprintf (file, "\n");
+}
+
 /* Create an edge and initialize it with given values.  */
 static ddg_edge_ptr
 create_ddg_edge (ddg_node_ptr src, ddg_node_ptr dest,
@@ -846,6 +870,27 @@ order_sccs (ddg_all_sccs_ptr g)
         (int (*) (const void *, const void *)) compare_sccs);
 }
 
+/* Check that every node in SCCS belongs to exactly one strongly connected
+   component and that no element of SCCS is empty.  */
+static void
+check_sccs (ddg_all_sccs_ptr sccs, int num_nodes)
+{
+  int i = 0;
+  sbitmap tmp = sbitmap_alloc (num_nodes);
+
+  sbitmap_zero (tmp);
+  for (i = 0; i < sccs->num_sccs; i++)
+    {
+      gcc_assert (!sbitmap_empty_p (sccs->sccs[i]->nodes));
+      /* Verify that every node in sccs is in exactly one strongly
+         connected component.  */
+      gcc_assert (!sbitmap_any_common_bits (tmp, sccs->sccs[i]->nodes));
+      sbitmap_a_or_b (tmp, tmp, sccs->sccs[i]->nodes);
+    }
+  sbitmap_free (tmp);
+}
+
+
 /* Perform the Strongly Connected Components decomposing algorithm on the
    DDG and return DDG_ALL_SCCS structure that contains them.  */
 ddg_all_sccs_ptr
@@ -890,6 +935,9 @@ create_ddg_all_sccs (ddg_ptr g)
   sbitmap_free (from);
   sbitmap_free (to);
   sbitmap_free (scc_nodes);
+#ifdef ENABLE_CHECKING
+  check_sccs (sccs, num_nodes);
+#endif
   return sccs;
 }
 
index ef293b0c04759b23abffb3b3ba6e025287ee0feb..f82599e1e3da8a5a2c3ff0865f4cc3f944057765 100644 (file)
--- a/gcc/ddg.h
+++ b/gcc/ddg.h
@@ -171,6 +171,7 @@ void free_ddg (ddg_ptr);
 void print_ddg (FILE *, ddg_ptr);
 void vcg_print_ddg (FILE *, ddg_ptr);
 void print_ddg_edge (FILE *, ddg_edge_ptr);
+void print_sccs (FILE *, ddg_all_sccs_ptr, ddg_ptr);
 
 ddg_node_ptr get_node_of_insn (ddg_ptr, rtx);
 
index 6664e32183854c2478aad19b9285bd4cc0361937..bf9bc9b7dcd5fed833e6ea98b3378dcfc97e4212 100644 (file)
@@ -1648,6 +1648,9 @@ sms_order_nodes (ddg_ptr g, int mii, int * node_order)
 
   nopa nops = calculate_order_params (g, mii);
 
+  if (dump_file)
+    print_sccs (dump_file, sccs, g);
+
   order_nodes_of_sccs (sccs, node_order);
 
   if (sccs->num_sccs > 0)