be: Change insert_Perm_after() to insert_Perm_before().
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 24 Nov 2012 14:16:30 +0000 (15:16 +0100)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 24 Nov 2012 14:23:20 +0000 (15:23 +0100)
The operation we want to perform is to insert a Perm before a node.

ir/be/bechordal_common.c
ir/be/beirgmod.c
ir/be/beirgmod.h

index aafebe6..90145a9 100644 (file)
@@ -230,9 +230,9 @@ ir_node *pre_process_constraints(be_chordal_env_t *env, be_insn_t **the_insn)
         * Make the Perm, recompute liveness and re-scan the insn since the
         * in operands are now the Projs of the Perm.
         */
-       perm = insert_Perm_after(env->irg, env->cls, sched_prev(insn->irn));
+       perm = insert_Perm_before(env->irg, env->cls, insn->irn);
 
-       /* Registers are propagated by insert_Perm_after(). Clean them here! */
+       /* Registers are propagated by insert_Perm_before(). Clean them here! */
        if (perm == NULL)
                return NULL;
 
index e7c7530..34b221b 100644 (file)
@@ -87,20 +87,19 @@ static int cmp_node_nr(const void *a, const void *b)
 
 */
 
-ir_node *insert_Perm_after(ir_graph *irg, const arch_register_class_t *cls,
+ir_node *insert_Perm_before(ir_graph *irg, const arch_register_class_t *cls,
                                                   ir_node *pos)
 {
        be_lv_t     *lv = be_get_irg_liveness(irg);
-       ir_node     *bl = is_Block(pos) ? pos : get_nodes_block(pos);
        ir_nodeset_t live;
 
        ir_node *perm, **nodes;
        size_t i, n;
 
-       DBG((dbg, LEVEL_1, "Insert Perm after: %+F\n", pos));
+       DBG((dbg, LEVEL_1, "Insert Perm before: %+F\n", pos));
 
        ir_nodeset_init(&live);
-       be_liveness_nodes_live_at(lv, cls, pos, &live);
+       be_liveness_nodes_live_at(lv, cls, sched_prev(pos), &live);
 
        n = ir_nodeset_size(&live);
        if (n == 0) {
@@ -121,8 +120,9 @@ ir_node *insert_Perm_after(ir_graph *irg, const arch_register_class_t *cls,
        /* make the input order deterministic */
        qsort(nodes, n, sizeof(nodes[0]), cmp_node_nr);
 
+       ir_node *const bl = get_nodes_block(pos);
        perm = be_new_Perm(cls, bl, n, nodes);
-       sched_add_after(pos, perm);
+       sched_add_before(pos, perm);
        free(nodes);
 
        for (i = 0; i < n; ++i) {
index 50ec874..ee8fc43 100644 (file)
  * Insert a Perm which permutes all (non-ignore) live values of a given register class
  * after a certain instruction.
  * @param lv        Liveness Information.
- * @param irn       The node to insert the Perm after.
- * @return          The Perm or NULL if nothing was live before @p irn.
+ * @param irn       The node to insert the Perm before.
+ * @return          The Perm or NULL if nothing was live after @p irn.
  */
-ir_node *insert_Perm_after(ir_graph *irg, const arch_register_class_t *cls,
+ir_node *insert_Perm_before(ir_graph *irg, const arch_register_class_t *cls,
                                                   ir_node *irn);
 
 /**