Converted documentation to doxygen.
[libfirm] / ir / ir / irgmod.c
index bdd782a..5ec25d3 100644 (file)
@@ -1,10 +1,10 @@
 
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Martin Trapp, Christian Schaefer
-**
-** irgmod: ir graph modification
+* All rights reserved.
+*
+* Authors: Martin Trapp, Christian Schaefer
+*
+* irgmod: ir graph modification
 */
 
 /* $Id$ */
@@ -13,6 +13,9 @@
 # include <config.h>
 #endif
 
+# include "irvrfy.h"
+# include "irflag.h"
+# include "irgwalk.h"
 # include "irnode_t.h"
 # include "irgraph_t.h"
 # include "irgmod.h"
@@ -41,28 +44,27 @@ turn_into_tuple (ir_node *node, int arity)
 /* Insert irnode `new' in place of irnode `old'
    Since `new' may be bigger than `old' replace `old'
    by an op_Id which is smaller than everything */
-inline void
-exchange (ir_node *old, ir_node *new)
+INLINE void
+exchange (ir_node *old, ir_node *nw)
 {
   ir_node *block = old->in[0];
 
   old->op = op_Id;
   old->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 2);
   old->in[0] = block;
-  old->in[1] = new;
+  old->in[1] = nw;
 }
 
-
 /**********************************************************************/
-/*  Funcionality for collect_phis                                     */
+/*  Functionality for collect_phis                                     */
 /**********************************************************************/
 
-void
+static void
 clear_link (ir_node *n, void *env) {
   set_irn_link(n, NULL);
 }
 
-void
+static void
 collect (ir_node *n, void *env) {
   ir_node *pred;
   if (get_irn_op(n) == op_Phi) {
@@ -98,7 +100,7 @@ void collect_phiprojs(ir_graph *irg) {
 /* Moves node and all predecessors of node from from_bl to to_bl.
    Does not move predecessors of Phi nodes (or block nodes). */
 
-void move (ir_node *node, ir_node *from_bl, ir_node *to_bl) {
+static void move (ir_node *node, ir_node *from_bl, ir_node *to_bl) {
   int i;
   ir_node *proj, *pred;
 
@@ -130,6 +132,10 @@ void part_block(ir_node *node) {
   ir_node *old_block;
   ir_node *phi;
 
+  /* Turn off optimizations so that blocks are not merged again. */
+  int rem_opt = get_optimize();
+  set_optimize(0);
+
   /* Transform the control flow */
   old_block = get_nodes_Block(node);
   new_block = new_Block(get_Block_n_cfgpreds(old_block),
@@ -139,7 +145,7 @@ void part_block(ir_node *node) {
     ir_node *in[1];
     in[0] = new_Jmp();
     set_irn_in(old_block, 1, in);
-    irn_vrfy(old_block);
+    irn_vrfy_irg(old_block, current_ir_graph);
   }
 
   /* move node and its predecessors to new_block */
@@ -150,7 +156,12 @@ void part_block(ir_node *node) {
   set_irn_link(new_block, phi);
   set_irn_link(old_block, NULL);
   while (phi) {
-    set_nodes_Block(phi, new_block);
+    if(get_nodes_Block(phi) == old_block);   /* @@@ inlinening chokes on phis that don't
+                                              obey this condition.  How do they get into
+                                              the list??? Example: InterfaceIII */
+      set_nodes_Block(phi, new_block);
     phi = get_irn_link(phi);
   }
+
+  set_optimize(rem_opt);
 }