Just fixed a typo (HASHPTR -> HASH_PTR)
[libfirm] / ir / ir / irgraph.c
index ce8923a..22da0c0 100644 (file)
@@ -79,7 +79,7 @@ void free_Phi_in_stack(Phi_in_stack *s);
    and optimization.
 */
 ir_graph *
-new_ir_graph (entity *ent, int n_loc)
+new_r_ir_graph (entity *ent, int n_loc)
 {
   ir_graph *res;
   ir_node *first_block;
@@ -93,7 +93,6 @@ new_ir_graph (entity *ent, int n_loc)
   stat_new_graph(res, ent);
 
   current_ir_graph = res;
-  add_irp_irg(res);          /* remember this graph global. */
 
   /*-- initialized for each graph. --*/
   if (get_opt_precise_exc_context()) {
@@ -181,6 +180,14 @@ new_ir_graph (entity *ent, int n_loc)
 }
 
 
+ir_graph *
+new_ir_graph (entity *ent, int n_loc)
+{
+  ir_graph *res = new_r_ir_graph (ent, n_loc);
+  add_irp_irg(res);          /* remember this graph global. */
+  return res;
+}
+
 /* Make a rudimentary ir graph for the constant code.
    Must look like a correct irg, spare everything else. */
 ir_graph *new_const_code_irg(void) {
@@ -678,19 +685,26 @@ void
   __inc_irg_block_visited(irg);
 }
 
-/* is irg a pseudo graph for analysis? */
-int is_pseudo_ir_graph(ir_graph *irg)
-{
-  int res = false;
-  entity *ent;
 
-  assert(irg && "nothing here");
-  assert(is_ir_graph(irg) && "no ir_graph given");
+/**
+ * walker Start->End: places Proj nodes into the same block
+ * as it's predecessors
+ *
+ * @param n    the node
+ * @param env  ignored
+ */
+static void normalize_proj_walker(ir_node *n, void *env)
+{
+  if (is_Proj(n)) {
+    ir_node *pred  = get_Proj_pred(n);
+    ir_node *block = get_nodes_block(pred);
 
-  ent = get_irg_entity(irg);
-  if(visibility_external_allocated == get_entity_visibility(ent)
-     && peculiarity_existent == get_entity_peculiarity(ent)) {
-    res = true;
+    set_nodes_block(n, block);
   }
-  return(res);
+}
+
+/* put the proj's into the same block as its predecessors */
+void normalize_proj_nodes(ir_graph *irg)
+{
+  irg_walk_graph(irg, NULL, normalize_proj_walker, NULL);
 }