end block can not be optimized away any more.
[libfirm] / ir / ir / ircons.c
index 1843209..5015199 100644 (file)
@@ -9,8 +9,13 @@
 **   by Goetz Lindenmaier
 */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 # include "irgraph_t.h"
 # include "irnode_t.h"
+# include "irmode_t.h"
 # include "ircons.h"
 # include "common.h"
 # include "irvrfy.h"
@@ -31,7 +36,7 @@ struct Phi_in_stack {
 typedef struct Phi_in_stack Phi_in_stack;
 #endif
 
-/*********************************************** */
+/*** ******************************************** */
 /** privat interfaces, for professional use only */
 
 /* Constructs a Block with a fixed number of predecessors.
@@ -574,10 +579,24 @@ new_r_Bad ()
   return current_ir_graph->bad;
 }
 
-/***********************/
+/** ********************/
 /** public interfaces  */
 /** construction tools */
 
+/****f* ircons/new_Start
+ *
+ * NAME
+ *   new_Start -- create a new Start node in the current block
+ *
+ * SYNOPSIS
+ *   s = new_Start(void);
+ *   ir_node* new_Start(void);
+ *
+ * RESULT
+ *   s - pointer to the created Start node
+ *
+ ****
+ */
 ir_node *
 new_Start (void)
 {
@@ -605,7 +624,6 @@ new_End (void)
   return res;
 }
 
-#if 0
 /* Constructs a Block with a fixed number of predecessors.
    Does set current_block.  Can be used with automatic Phi
    node construction. */
@@ -614,28 +632,21 @@ new_Block (int arity, ir_node **in)
 {
   ir_node *res;
 
-  res = new_r_Block (arity, in);
+  res = new_r_Block (current_ir_graph, arity, in);
   current_ir_graph->current_block = res;
 
   /* Create and initialize array for Phi-node construction. */
   res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
-                                         current_ir_graph->params);
-  memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params);
+                                         current_ir_graph->n_loc);
+  memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
 
   res = optimize (res);
   irn_vrfy (res);
 
   return res;
 }
-#else
-ir_node *
-new_Block (void)
-{
-  return new_immBlock();
-}
-#endif
 
-/*************************************************************************/
+/* ***********************************************************************/
 /* Methods necessary for automatic Phi node creation                     */
 /*
   ir_node *phi_merge            (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins)
@@ -659,7 +670,7 @@ new_Block (void)
               \|/                \|/
            new_r_Phi0          new_r_Phi_in
 
-*****************************************************************************/
+* *************************************************************************** */
 
 /* Creates a Phi node with 0 predecessors */
 inline ir_node *
@@ -1197,7 +1208,7 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode)
 
 #endif /* USE_FAST_PHI_CONSTRUCTION */
 
-/****************************************************************************/
+/* ************************************************************************** */
 
 /** Finalize a Block node, when all control flows are known.  */
 /** Acceptable parameters are only Block nodes.               */
@@ -1216,6 +1227,7 @@ mature_block (ir_node *block)
     /* turn the dynamic in-array into a static one. */
     ins = ARR_LEN (block->in)-1;
     NEW_ARR_A (ir_node *, nin, ins);
+    /*  @@@ something is strange here... why isn't the array copied? */
 
     /* Traverse a chain of Phi nodes attached to this block and mature
        these, too. **/
@@ -1507,10 +1519,10 @@ new_Bad (void)
   return current_ir_graph->bad;
 }
 
-/*************************************************************************/
+/* ********************************************************************* */
 /* Comfortable interface with automatic Phi node construction.           */
 /* (Uses also constructors of ?? interface, except new_Block.            */
-/*************************************************************************/
+/* ********************************************************************* */
 
 /** Block construction **/
 /* immature Block without predecessors */
@@ -1525,8 +1537,8 @@ ir_node *new_immBlock (void) {
 
   /* Create and initialize array for Phi-node construction. */
   res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
-                                         current_ir_graph->params);
-  memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params);
+                                         current_ir_graph->n_loc);
+  memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
 
   /* Immature block may not be optimized! */
   irn_vrfy (res);
@@ -1554,7 +1566,7 @@ switch_block (ir_node *target)
   current_ir_graph->current_block = target;
 }
 
-/****************************/
+/* ************************ */
 /* parameter administration */
 
 /* get a value from the parameter array from the current block by its index */
@@ -1589,7 +1601,7 @@ set_store (ir_node *store)
   current_ir_graph->current_block->attr.block.graph_arr[0] = store;
 }
 
-/*************************************************************************/
+/* ********************************************************************* */
 /* initialize */
 
 /* call once for each run of the library */