beloopana: Remove duplicate comments.
[libfirm] / ir / opt / escape_ana.c
index 977c1e0..53151c5 100644 (file)
@@ -1,37 +1,13 @@
 /*
- * Copyright (C) 1995-2011 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.
- */
-
-/*
- * Project:     libFIRM
- * File name:   ir/opt/escape_ana.c
- * Purpose:     escape analysis and optimization
- * Author:      Michael Beck
- * Modified by:
- * Created:     03.11.2005
- * CVS-ID:      $Id$
- * Copyright:   (c) 1999-2005 Universität Karlsruhe
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
- * @file escape_ana.c
- *
- * A fast and simple Escape analysis.
+ * @file
+ * @author Michael Beck
+ * @date   03.11.2005
+ * @brief  A fast and simple Escape analysis.
  */
 #include "config.h"
 
@@ -48,6 +24,7 @@
 #include "irprintf.h"
 #include "debug.h"
 #include "error.h"
+#include "util.h"
 
 /**
  * walker environment
@@ -202,7 +179,7 @@ static int can_escape(ir_node *n)
                                        size_t j;
                                        ent = get_Call_callee(succ, --k);
 
-                                       if (ent == unknown_entity) {
+                                       if (is_unknown_entity(ent)) {
                                                /* we don't know what will be called, a possible escape */
                                                return 1;
                                        }
@@ -393,10 +370,12 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env)
 
                mem = get_Alloc_mem(alloc);
                blk = get_nodes_block(alloc);
-               turn_into_tuple(alloc, pn_Alloc_max+1);
-               set_Tuple_pred(alloc, pn_Alloc_M, mem);
-               set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk));
-               set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg, mode_X));
+               ir_node *const in[] = {
+                       [pn_Alloc_M]         = mem,
+                       [pn_Alloc_X_regular] = new_r_Jmp(blk),
+                       [pn_Alloc_X_except]  = new_r_Bad(irg, mode_X),
+               };
+               turn_into_tuple(alloc, ARRAY_SIZE(in), in);
 
                ++env->nr_deads;
        }
@@ -424,7 +403,7 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env)
                        }
                }
 
-               if (tp && tp != firm_unknown_type) {
+               if (tp && !is_unknown_type(tp)) {
                        /* we could determine the type, so we could place it on the frame */
                        dbg  = get_irn_dbg_info(alloc);
                        blk  = get_nodes_block(alloc);
@@ -438,11 +417,13 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env)
                        sel = new_rd_simpleSel(dbg, get_nodes_block(alloc), get_irg_no_mem(irg), get_irg_frame(irg), ent);
                        mem = get_Alloc_mem(alloc);
 
-                       turn_into_tuple(alloc, pn_Alloc_max+1);
-                       set_Tuple_pred(alloc, pn_Alloc_M, mem);
-                       set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk));
-                       set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg, mode_X));
-                       set_Tuple_pred(alloc, pn_Alloc_res, sel);
+                       ir_node *const in[] = {
+                               [pn_Alloc_M]         = mem,
+                               [pn_Alloc_res]       = sel,
+                               [pn_Alloc_X_regular] = new_r_Jmp(blk),
+                               [pn_Alloc_X_except]  = new_r_Bad(irg, mode_X),
+                       };
+                       turn_into_tuple(alloc, ARRAY_SIZE(in), in);
 
                        ++env->nr_removed;
                }
@@ -460,8 +441,7 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env)
 
        /* if allocs were removed somehow */
        if (env->nr_removed && env->nr_deads) {
-               /* exception control flow might have been changed */
-               set_irg_doms_inconsistent(irg);
+               confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
        }
 }
 
@@ -481,11 +461,13 @@ static void transform_alloc_calls(ir_graph *irg, walk_env_t *env)
 
                mem = get_Call_mem(call);
                blk = get_nodes_block(call);
-               turn_into_tuple(call, pn_Call_max+1);
-               set_Tuple_pred(call, pn_Call_M,         mem);
-               set_Tuple_pred(call, pn_Call_X_regular, new_r_Jmp(blk));
-               set_Tuple_pred(call, pn_Call_X_except,  new_r_Bad(irg, mode_X));
-               set_Tuple_pred(call, pn_Call_T_result,  new_r_Bad(irg, mode_T));
+               ir_node *const in[] = {
+                       [pn_Call_M]         = mem,
+                       [pn_Call_T_result]  = new_r_Bad(irg, mode_T),
+                       [pn_Call_X_regular] = new_r_Jmp(blk),
+                       [pn_Call_X_except]  = new_r_Bad(irg, mode_X),
+               };
+               turn_into_tuple(call, ARRAY_SIZE(in), in);
 
                ++env->nr_deads;
        }
@@ -494,6 +476,8 @@ static void transform_alloc_calls(ir_graph *irg, walk_env_t *env)
        for (call = env->found_allocs; call; call = next) {
                next = (ir_node*)get_irn_link(call);
        }
+
+       confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
 }
 
 
@@ -508,7 +492,7 @@ void escape_enalysis_irg(ir_graph *irg, check_alloc_entity_func callback)
                return;
        }
 
-       if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS))
+       if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS))
                compute_irg_outs(irg);
 
        env.found_allocs = NULL;
@@ -561,7 +545,7 @@ void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback)
        for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
                ir_graph *irg = get_irp_irg(i);
 
-               assure_irg_outs(irg);
+               assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
 
                if (callback) {
                        /* search for Calls */