Use new scope instead of empty statement.
[libfirm] / ir / ir / irpass.c
index 95186cb..88c3454 100644 (file)
@@ -1,27 +1,12 @@
 /*
- * Copyright (C) 1995-2010 University of Karlsruhe.  All right reserved.
- *
  * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
  * @file
  * @brief     Manager for optimization passes.
  * @author    Michael Beck
- * @version   $Id$
  */
 #include "config.h"
 
 #include "irprog_t.h"
 #include "irdump.h"
 #include "irverify.h"
+#include "ircons.h"
 #include "xmalloc.h"
 
 typedef void (*void_pass_func_irg)(ir_graph *irg);
 typedef int (*int_pass_func_irg)(ir_graph *irg);
 typedef void (*void_pass_func)(void);
 
-/*Add a graph pass to a graph pass manager. */
 void ir_graph_pass_mgr_add(ir_graph_pass_manager_t *mgr, ir_graph_pass_t *pass)
 {
        list_add_tail(&pass->list, &mgr->passes);
@@ -47,7 +32,6 @@ void ir_graph_pass_mgr_add(ir_graph_pass_manager_t *mgr, ir_graph_pass_t *pass)
                pass->add_to_mgr(pass->context);
 }
 
-/* Add an irprog pass to an irprog pass manager. */
 void ir_prog_pass_mgr_add(ir_prog_pass_manager_t *mgr, ir_prog_pass_t *pass)
 {
        list_add_tail(&pass->list, &mgr->passes);
@@ -68,7 +52,6 @@ static int run_wrapper(ir_prog *prog, void *ctx)
        return ir_graph_pass_mgr_run(mgr);
 }
 
-/* Ensure that no verifier is run an ir_prog pass. */
 int ir_prog_no_verify(ir_prog *prog, void *ctx)
 {
        (void)prog;
@@ -76,7 +59,6 @@ int ir_prog_no_verify(ir_prog *prog, void *ctx)
        return 0;
 }
 
-/* Ensure that no dumper is run from an ir_prog pass. */
 void ir_prog_no_dump(ir_prog *prog, void *ctx, unsigned idx)
 {
        (void)prog;
@@ -117,7 +99,6 @@ static ir_prog_pass_t *create_wrapper_pass(ir_graph_pass_manager_t *graph_mgr)
        return pass;
 }
 
-/* Add an ir_graph_pass as a pass to an ir_prog pass manager. */
 void ir_prog_pass_mgr_add_graph_pass(
        ir_prog_pass_manager_t *mgr, ir_graph_pass_t *pass)
 {
@@ -147,7 +128,6 @@ void ir_prog_pass_mgr_add_graph_pass(
        ir_prog_pass_mgr_add(mgr, wrapper);
 }
 
-/* Add an ir_graph_pass_manager as a pass to an ir_prog pass manager. */
 void ir_prog_pass_mgr_add_graph_mgr(
        ir_prog_pass_manager_t *mgr, ir_graph_pass_manager_t *graph_mgr)
 {
@@ -162,18 +142,11 @@ void ir_prog_pass_mgr_add_graph_mgr(
        ir_prog_pass_mgr_add(mgr, pass);
 }
 
-static void create_suffix(char *suffix, size_t n, const char *pass_name)
-{
-       snprintf(suffix, n, "%s.svg", pass_name);
-}
-
-/* Run all passes of an ir_graph pass manager. */
 int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
 {
-       ir_graph_pass_t *pass;
-       size_t           i;
-       int              res = 0;
-       ir_graph        *rem = current_ir_graph;
+       size_t    i;
+       int       res = 0;
+       ir_graph *rem = current_ir_graph;
 
        /* on all graphs: beware: number of irgs might be changed */
        for (i = 0; i < get_irp_n_irgs(); ++i) {
@@ -197,9 +170,7 @@ int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
                                if (pass->dump_irg) {
                                        pass->dump_irg(irg, pass->context, idx);
                                } else {
-                                       char buf[1024];
-                                       create_suffix(buf, sizeof(buf), pass->name);
-                                       dump_ir_graph(irg, buf);
+                                       dump_ir_graph(irg, pass->name);
                                }
                        }
                        ++idx;
@@ -223,11 +194,9 @@ static int irp_verify_irgs(void)
        return res;
 }
 
-/* Run all passes of an ir_prog pass manager. */
 int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr)
 {
-       ir_prog_pass_t *pass;
-       int            res = 0;
+       int res = 0;
 
        /* run every pass on every graph */
        unsigned idx = mgr->run_idx;
@@ -248,9 +217,7 @@ int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr)
                        if (pass->dump_irprog) {
                                pass->dump_irprog(irp, pass->context, idx);
                        } else {
-                               char buf[1024];
-                               create_suffix(buf, sizeof(buf), pass->name);
-                               dump_all_ir_graphs(buf);
+                               dump_all_ir_graphs(pass->name);
                        }
                }
                if (pass->is_wrapper) {
@@ -262,7 +229,6 @@ int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr)
        return res;
 }
 
-/* Creates a new ir_graph pass manager. */
 ir_graph_pass_manager_t *new_graph_pass_mgr(
        const char *name, int verify_all, int dump_all)
 {
@@ -278,7 +244,6 @@ ir_graph_pass_manager_t *new_graph_pass_mgr(
        return res;
 }
 
-/* Creates a new ir_prog pass manager. */
 ir_prog_pass_manager_t *new_prog_pass_mgr(
        const char *name, int verify_all, int dump_all)
 {
@@ -294,11 +259,8 @@ ir_prog_pass_manager_t *new_prog_pass_mgr(
        return res;
 }
 
-/* Terminate an ir_graph pass manager and all owned passes. */
 void term_graph_pass_mgr(ir_graph_pass_manager_t *mgr)
 {
-       ir_graph_pass_t *pass, *next;
-
        list_for_each_entry_safe(ir_graph_pass_t, pass, next, &mgr->passes, list) {
                if (pass->rem_from_mgr)
                        pass->rem_from_mgr(pass->context);
@@ -309,11 +271,8 @@ void term_graph_pass_mgr(ir_graph_pass_manager_t *mgr)
        xfree(mgr);
 }
 
-/* Terminate an ir_prog pass manager and all owned passes. */
 void term_prog_pass_mgr(ir_prog_pass_manager_t *mgr)
 {
-       ir_prog_pass_t *pass, *next;
-
        list_for_each_entry_safe(ir_prog_pass_t, pass, next, &mgr->passes, list) {
                if (pass->rem_from_mgr)
                        pass->rem_from_mgr(pass->context);
@@ -324,24 +283,12 @@ void term_prog_pass_mgr(ir_prog_pass_manager_t *mgr)
        xfree(mgr);
 }
 
-/**
- * Set the run index for an irgraph pass manager.
- *
- * @param mgr      the manager
- * @param run_idx  the index for the first pass of this manager
- */
 void ir_graph_pass_mgr_set_run_idx(
        ir_graph_pass_manager_t *mgr, unsigned run_idx)
 {
        mgr->run_idx = run_idx;
 }
 
-/**
- * Set the run index for an irprog pass manager.
- *
- * @param mgr      the manager
- * @param run_idx  the index for the first pass of this manager
- */
 void ir_prog_pass_mgr_set_run_idx(
        ir_prog_pass_manager_t *mgr, unsigned run_idx)
 {
@@ -358,7 +305,6 @@ static int void_graph_wrapper(ir_graph *irg, void *context)
        return 0;
 }
 
-/* Creates an ir_graph pass for running void function(ir_graph *irg). */
 ir_graph_pass_t *def_graph_pass(
        const char *name, void (*function)(ir_graph *irg))
 {
@@ -383,7 +329,6 @@ static int int_graph_wrapper(ir_graph *irg, void *context)
        return function(irg);
 }
 
-/* Creates an ir_graph pass for running void function(ir_graph *irg). */
 ir_graph_pass_t *def_graph_pass_ret(
                const char *name, int (*function)(ir_graph *irg))
 {
@@ -399,7 +344,6 @@ ir_graph_pass_t *def_graph_pass_ret(
        return pass;
 }
 
-/* constructor for a default graph pass */
 ir_graph_pass_t *def_graph_pass_constructor(
        ir_graph_pass_t *pass,
        const char *name, int (*function)(ir_graph *irg, void *context)) {
@@ -417,7 +361,6 @@ ir_graph_pass_t *def_graph_pass_constructor(
        return pass;
 }
 
-/* set the run parallel property */
 void ir_graph_pass_set_parallel(ir_graph_pass_t *pass, int flag)
 {
        pass->run_parallel = flag != 0;
@@ -435,7 +378,6 @@ static int void_prog_wrapper(ir_prog *irp, void *context)
        return 0;
 }
 
-/* Creates an ir_prog pass for running void function(void). */
 ir_prog_pass_t *def_prog_pass(
        const char *name,
        void (*function)(void))
@@ -452,7 +394,6 @@ ir_prog_pass_t *def_prog_pass(
        return pass;
 }
 
-/* Creates an ir_prog pass for running void function(void). */
 ir_prog_pass_t *def_prog_pass_constructor(
        ir_prog_pass_t *pass,
        const char *name,