fixing grgen dumper to autogenerate file names
authorAndreas Zwinkau <zwinkau@kit.edu>
Mon, 31 Mar 2008 12:10:21 +0000 (12:10 +0000)
committerAndreas Zwinkau <zwinkau@kit.edu>
Mon, 31 Mar 2008 12:10:21 +0000 (12:10 +0000)
[r18302]

include/libfirm/irdump_grgen.h
ir/ir/irdump_grgen.c

index bddf8ff..6937f16 100644 (file)
 * @file
 * @brief   Write ir graph as a grgen construction rule
 * @author  Andreas Schoesser
-* @version $Id:$
+* @version $Id$
 */
 
 
 /**
  * Dumps a complete irg in the grgen format
  * irg:                        irg to dump
- * filename:   text file to dump to
+ * filename:           text file to dump to
  * append:             1 if the new rule should be appended to the file,
  *                             otherwise the previous contents are deleted
  **/
-void dump_irg_grgen(ir_graph *irg, char *filename, int append);
+void dump_irg_grgen_file(ir_graph *irg, char *filename, int append);
+
+/**
+ * Like dump_irg_grgen_file dumps a complete irg in the grgen format
+ * irg:                        irg to dump
+ * suffix:             suffix for the output file
+ *                      (e.g. "main"+ suffix +".grg")
+ **/
+void dump_irg_grgen(ir_graph *irg, char *suffix);
index b301f6b..286fb80 100644 (file)
@@ -21,7 +21,7 @@
 * @file
 * @brief   Write ir graph as a grgen construction rule
 * @author  Andreas Schoesser
-* @version $Id:$
+* @version $Id$
 */
 
 /*
@@ -157,7 +157,7 @@ static void collect_nodes(ir_node *n, void * env)
  * Starts dumping
  ************************************************************************/
 
-void dump_irg_grgen(ir_graph *irg, char *filename, int append)
+void dump_irg_grgen_file(ir_graph *irg, char *filename, int append)
 {
        FILE *fp;
        grgen_dumpinfo_t dump_info;
@@ -212,6 +212,18 @@ void dump_irg_grgen(ir_graph *irg, char *filename, int append)
 }
 
 
+void dump_irg_grgen(ir_graph *irg, char *suffix)
+{
+  char filename[100] = "";
+
+  strncat(filename, get_entity_name(get_irg_entity(irg)), 100);
+  strncat(filename, suffix, 100);
+  strncat(filename, ".grg", 100);
+
+  dump_irg_grgen_file(irg, filename, 0);
+}
+
+
 /************************************************************************
  * Dumps the left hand side of the rule
  ************************************************************************/