Patchwork [39/44] New flag: -fgraphite-dump-cloog.

login
register
mail settings
Submitter Sebastian Pop
Date Sept. 30, 2010, 6:01 p.m.
Message ID <1285869696-10915-40-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/66231/
State New
Headers show

Comments

Sebastian Pop - Sept. 30, 2010, 6:01 p.m.
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>

Introduce a new flag: -fgraphite-dump-cloog. If enabled, graphite
dumps each SCoP into a CLooG input file for further debugging.
The naming follows the naming scheme of -fgraphite-write:
 <basename>.<scopnumber>.cloog

The file is dumped into the current working directory.

2010-09-16  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>

	* common.opt (fgraphite-dump-cloog): New flag.
	* doc/invoke.texi (-fgraphite-dump-cloog): Documented.
	* graphite-clast-to-gimple.c (init_cloog_input_file): New.
	(build_cloog_prog): Dump CLooG input file when
	flag_graphite_dump_cloog is set.
	* graphite-cloog-compat.h (cloog_program_dump_cloog): New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@164464 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                  |    7 +++++++
 gcc/ChangeLog.graphite         |   21 +++++++++++++++++++++
 gcc/graphite-clast-to-gimple.c |   36 ++++++++++++++++++++++++++++++++++++
 gcc/graphite-cloog-compat.h    |    2 ++
 4 files changed, 66 insertions(+), 0 deletions(-)

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4d9cd28..a742e33 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@ 
+2010-09-30  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
+
+	* graphite-clast-to-gimple.c (init_cloog_input_file): New.
+	(build_cloog_prog): Dump CLooG input file when
+	flag_graphite_dump_cloog is set.  This is disabled on trunk.
+	* graphite-cloog-compat.h (cloog_program_dump_cloog): New.
+
 2010-09-30  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* graphite-clast-to-gimple.c (graphite_verify): Remove call to
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 997df9b..ba7d99e 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,24 @@ 
+2010-09-21  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
+
+	* common.opt (fgraphite-dump-cloog): New flag.
+	* doc/invoke.texi (-fgraphite-dump-cloog): Documented.
+	* graphite-clast-to-gimple.c (init_cloog_input_file): New.
+	(build_cloog_prog): Dump CLooG input file when
+	flag_graphite_dump_cloog is set.
+	* graphite-cloog-compat.h (cloog_program_dump_cloog): New.
+
+2010-09-20  Sebastian Pop  <sebastian.pop@amd.com>
+
+	Revert previous patch "New flag: -fgraphite-dump-cloog."
+
+2010-09-20  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
+
+	* common.opt (fgraphite-dump-cloog): New flag.
+	* doc/invoke.texi (-fgraphite-dump-cloog): Documented.
+	* graphite-clast-to-gimple.c (init_cloog_input_file): New.
+	(build_cloog_prog): Dump CLooG input file when
+	flag_graphite_dump_cloog is set.
+
 2010-09-20  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* graphite-clast-to-gimple.c (graphite_verify): Remove call to
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 0e2ec80..faefbb6 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -1216,6 +1216,31 @@  initialize_cloog_names (scop_p scop, CloogProgram *prog)
 			      scattering);
 }
 
+/* Initialize a CLooG input file.  */
+
+static FILE *
+init_cloog_input_file (int scop_number)
+{
+  FILE *graphite_out_file;
+  int len = strlen (dump_base_name);
+  char *dumpname = XNEWVEC (char, len + 25);
+  char *s_scop_number = XNEWVEC (char, 15);
+
+  memcpy (dumpname, dump_base_name, len + 1);
+  strip_off_ending (dumpname, len);
+  sprintf (s_scop_number, ".%d", scop_number);
+  strcat (dumpname, s_scop_number);
+  strcat (dumpname, ".cloog");
+  graphite_out_file = fopen (dumpname, "w+b");
+
+  if (graphite_out_file == 0)
+    fatal_error ("can%'t open %s for writing: %m", dumpname);
+
+  free (dumpname);
+
+  return graphite_out_file;
+}
+
 /* Build cloog program for SCoP.  */
 
 static void
@@ -1306,6 +1331,17 @@  build_cloog_prog (scop_p scop, CloogProgram *prog,
   /* Extract scalar dimensions to simplify the code generation problem.  */
   cloog_program_extract_scalars (prog, scattering, options);
 
+  /* Dump a .cloog input file, if requested.  This feature is only
+     enabled in the Graphite branch.  */
+  if (0)
+    {
+      static size_t file_scop_number = 0;
+      FILE *cloog_file = init_cloog_input_file (file_scop_number);
+
+      cloog_program_dump_cloog (cloog_file, prog, scattering);
+      ++file_scop_number;
+    }
+
   /* Apply scattering.  */
   cloog_program_scatter (prog, scattering, options);
   free_scattering (scattering);
diff --git a/gcc/graphite-cloog-compat.h b/gcc/graphite-cloog-compat.h
index 061aa47..b7a3b23 100644
--- a/gcc/graphite-cloog-compat.h
+++ b/gcc/graphite-cloog-compat.h
@@ -72,6 +72,8 @@  typedef const char *clast_name_p;
 #define cloog_scattering cloog_domain
 #define cloog_next_scattering cloog_next_domain
 #define cloog_scattering_free cloog_domain_free
+#define cloog_program_dump_cloog(DUMPFILE, PROGRAM, SCATTERINGLIST)\
+  cloog_program_dump_cloog (DUMPFILE, PROGRAM)
 
 #endif