besched: Change sched_foreach_from(sched_next(x), y) to sched_foreach_after(x, y).
[libfirm] / ir / be / sparc / sparc_finish.c
index 962c832..e30e550 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * 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.
  */
 
 /**
@@ -427,13 +413,6 @@ static void peephole_sparc_FrameAddr(ir_node *node)
 {
        /* the peephole code currently doesn't allow this since it changes
         * the register. Find out why and how to workaround this... */
-#if 0
-       const sparc_attr_t *attr = get_sparc_attr_const(node);
-       if (attr->immediate_value == 0) {
-               ir_node *base = get_irn_n(node, n_sparc_FrameAddr_base);
-               be_peephole_exchange(node, base);
-       }
-#endif
        (void) node;
 }
 
@@ -577,25 +556,13 @@ static void peephole_sparc_RestoreZero(ir_node *node)
 
 static void finish_sparc_Return(ir_node *node)
 {
-       ir_node *schedpoint = node;
-       ir_node *restore;
-       /* see that there is no code between Return and restore, if there is move
-        * it in front of the restore */
-       while (true) {
-               schedpoint = sched_prev(schedpoint);
-               if (sched_is_begin(schedpoint))
-                       return;
-               if (is_sparc_Restore(schedpoint) || is_sparc_RestoreZero(schedpoint))
+       /* Ensure that the restore is directly before the return. */
+       sched_foreach_reverse_from(sched_prev(node), restore) {
+               if (is_sparc_Restore(restore) || is_sparc_RestoreZero(restore)) {
+                       sched_remove(restore);
+                       sched_add_before(node, restore);
                        break;
-       }
-       restore = schedpoint;
-       schedpoint = sched_prev(node);
-       /* move all code between return and restore up */
-       while (schedpoint != restore) {
-               ir_node *next_schedpoint = sched_prev(schedpoint);
-               sched_remove(schedpoint);
-               sched_add_before(restore, schedpoint);
-               schedpoint = next_schedpoint;
+               }
        }
 }