bepeephole: Inline be_peephole_new_node() into its only caller.
[libfirm] / ir / be / bepeephole.c
index cc26a63..6ff06f5 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
@@ -93,14 +79,9 @@ static void set_reg_value(ir_node *node)
 static void clear_defs(ir_node *node)
 {
        /* clear values defined */
-       if (get_irn_mode(node) == mode_T) {
-               foreach_out_edge(node, edge) {
-                       ir_node *proj = get_edge_src_irn(edge);
-                       clear_reg_value(proj);
-               }
-       } else {
-               clear_reg_value(node);
-       }
+       be_foreach_value(node, value,
+               clear_reg_value(value);
+       );
 }
 
 static void set_uses(ir_node *node)
@@ -115,11 +96,6 @@ static void set_uses(ir_node *node)
        }
 }
 
-void be_peephole_new_node(ir_node * nw)
-{
-       be_liveness_introduce(lv, nw);
-}
-
 /**
  * must be called from peephole optimisations before a node will be killed
  * and its users will be redirected to new_node.
@@ -176,7 +152,7 @@ void be_peephole_exchange(ir_node *old, ir_node *nw)
        be_peephole_before_exchange(old, nw);
        sched_remove(old);
        exchange(old, nw);
-       be_peephole_new_node(nw);
+       be_liveness_introduce(lv, nw);
 }
 
 /**
@@ -269,7 +245,6 @@ bool be_can_move_down(ir_heights_t *heights, const ir_node *node,
                        return false;
 
                /* schedpoint must not overwrite registers of our inputs */
-               unsigned n_outs = arch_get_irn_n_outs(schedpoint);
                for (int i = 0; i < node_arity; ++i) {
                        ir_node                   *in  = get_irn_n(node, i);
                        const arch_register_t     *reg = arch_get_irn_register(in);
@@ -277,7 +252,7 @@ bool be_can_move_down(ir_heights_t *heights, const ir_node *node,
                                continue;
                        const arch_register_req_t *in_req
                                = arch_get_irn_register_req_in(node, i);
-                       for (unsigned o = 0; o < n_outs; ++o) {
+                       be_foreach_out(schedpoint, o) {
                                const arch_register_t *outreg
                                        = arch_get_irn_register_out(schedpoint, o);
                                const arch_register_req_t *outreq
@@ -295,7 +270,6 @@ bool be_can_move_down(ir_heights_t *heights, const ir_node *node,
 bool be_can_move_up(ir_heights_t *heights, const ir_node *node,
                     const ir_node *after)
 {
-       unsigned       n_outs      = arch_get_irn_n_outs(node);
        const ir_node *node_block  = get_nodes_block(node);
        const ir_node *after_block = get_block_const(after);
        const ir_node *schedpoint;
@@ -326,7 +300,7 @@ bool be_can_move_up(ir_heights_t *heights, const ir_node *node,
                        be_lv_foreach(lv, succ, be_lv_state_in, live_node) {
                                const arch_register_t     *reg = arch_get_irn_register(live_node);
                                const arch_register_req_t *req = arch_get_irn_register_req(live_node);
-                               for (unsigned o = 0; o < n_outs; ++o) {
+                               be_foreach_out(node, o) {
                                        const arch_register_t *outreg
                                                = arch_get_irn_register_out(node, o);
                                        const arch_register_req_t *outreq
@@ -340,7 +314,7 @@ bool be_can_move_up(ir_heights_t *heights, const ir_node *node,
                                        break;
                                const arch_register_t     *reg = arch_get_irn_register(phi);
                                const arch_register_req_t *req = arch_get_irn_register_req(phi);
-                               for (unsigned o = 0; o < n_outs; ++o) {
+                               be_foreach_out(node, o) {
                                        const arch_register_t *outreg
                                                = arch_get_irn_register_out(node, o);
                                        const arch_register_req_t *outreq
@@ -374,7 +348,7 @@ bool be_can_move_up(ir_heights_t *heights, const ir_node *node,
                                continue;
                        const arch_register_req_t *in_req
                                = arch_get_irn_register_req_in(schedpoint, i);
-                       for (unsigned o = 0; o < n_outs; ++o) {
+                       be_foreach_out(node, o) {
                                const arch_register_t *outreg
                                        = arch_get_irn_register_out(node, o);
                                const arch_register_req_t *outreq
@@ -419,11 +393,6 @@ ir_node *be_peephole_IncSP_IncSP(ir_node *node)
 
 void be_peephole_opt(ir_graph *irg)
 {
-#if 0
-       /* we sometimes find BadE nodes in float apps like optest_float.c or
-        * kahansum.c for example... */
-       be_invalidate_live_sets(irg);
-#endif
        be_assure_live_sets(irg);
 
        arch_env = be_get_irg_arch_env(irg);