Enqueue Phi nodes to reach fixpoint.
[libfirm] / ir / ir / irop.c
index 5f98506..31adf0c 100644 (file)
@@ -33,7 +33,7 @@
 #include "irbackedge_t.h"
 
 #include "iropt_t.h"
-#include "irvrfy_t.h"
+#include "irverify_t.h"
 #include "reassoc_t.h"
 
 #include "xmalloc.h"
@@ -86,10 +86,11 @@ static void block_copy_attr(ir_graph *irg, const ir_node *old_node,
        new_node->attr.block.block_visited = 0;
        memset(&new_node->attr.block.dom, 0, sizeof(new_node->attr.block.dom));
        memset(&new_node->attr.block.pdom, 0, sizeof(new_node->attr.block.pdom));
-       /* TODO: we should probably create a new entity. But we somehow have to
-        * patch the stuff at the same time */
-       new_node->attr.block.entity            = NULL;
-       new_node->attr.block.phis              = NULL;
+       /* It should be safe to copy the entity here, as it has no back-link to the old block.
+        * It serves just as a label number, so copying a labeled block results in an exact copy.
+        * This is at least what we need for DCE to work. */
+       new_node->attr.block.entity         = old_node->attr.block.entity;
+       new_node->attr.block.phis           = NULL;
        INIT_LIST_HEAD(&new_node->attr.block.succ_head);
 }
 
@@ -104,16 +105,6 @@ static void phi_copy_attr(ir_graph *irg, const ir_node *old_node,
        new_node->attr.phi.u.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node));
 }
 
-/**
- * Copies all filter attributes stored in old node to the new node
- */
-static void filter_copy_attr(ir_graph *irg, const ir_node *old_node,
-                             ir_node *new_node)
-{
-       default_copy_attr(irg, old_node, new_node);
-       new_node->attr.filter.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node));
-}
-
 /**
  * Copies all ASM attributes stored in old node to the new node
  */
@@ -123,7 +114,7 @@ static void ASM_copy_attr(ir_graph *irg, const ir_node *old_node,
        default_copy_attr(irg, old_node, new_node);
        new_node->attr.assem.input_constraints  = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.input_constraints);
        new_node->attr.assem.output_constraints = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.output_constraints);
-       new_node->attr.assem.clobbers = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.clobbers);
+       new_node->attr.assem.clobbers = DUP_ARR_D(ident*, irg->obst, old_node->attr.assem.clobbers);
 }
 
 /**
@@ -135,7 +126,7 @@ static void ASM_copy_attr(ir_graph *irg, const ir_node *old_node,
  * @return
  *    The operations.
  */
-static ir_op_ops *firm_set_default_copy_attr(ir_opcode code, ir_op_ops *ops)
+static ir_op_ops *firm_set_default_copy_attr(unsigned code, ir_op_ops *ops)
 {
        switch (code) {
        case iro_Call:
@@ -147,9 +138,6 @@ static ir_op_ops *firm_set_default_copy_attr(ir_opcode code, ir_op_ops *ops)
        case iro_Phi:
                ops->copy_attr = phi_copy_attr;
                break;
-       case iro_Filter:
-               ops->copy_attr = filter_copy_attr;
-               break;
        case iro_ASM:
                ops->copy_attr = ASM_copy_attr;
                break;
@@ -178,13 +166,13 @@ ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
        res->tag       = 0;
 
        if (ops)
-               memcpy(&res->ops, ops, sizeof(res->ops));
+               res->ops = *ops;
        else /* no given ops, set all operations to NULL */
                memset(&res->ops, 0, sizeof(res->ops));
 
        firm_set_default_operations(code, &res->ops);
        firm_set_default_copy_attr(code, &res->ops);
-       firm_set_default_verifyer(code, &res->ops);
+       firm_set_default_verifier(code, &res->ops);
        firm_set_default_reassoc(code, &res->ops);
 
        add_irp_opcode(res);
@@ -201,6 +189,14 @@ void free_ir_op(ir_op *code)
        free(code);
 }  /* free_ir_op */
 
+void ir_op_set_fragile_indices(ir_op *op, int fragile_mem_index,
+                               int pn_x_regular, int pn_x_except)
+{
+       op->fragile_mem_index = fragile_mem_index;
+       op->pn_x_regular = pn_x_regular;
+       op->pn_x_except = pn_x_except;
+}
+
 /* Returns the string for the opcode. */
 const char *get_op_name (const ir_op *op)
 {
@@ -277,7 +273,7 @@ const ir_op_ops *(get_op_ops)(const ir_op *op)
 
 irop_flags get_op_flags(const ir_op *op)
 {
-       return op->flags;
+       return (irop_flags)op->flags;
 }
 
 #include "gen_irop.c.inl"