move get_irn_edge_kind to internal API
[libfirm] / ir / ir / irarch.c
index 7b30379..db787cb 100644 (file)
@@ -22,7 +22,6 @@
  * @brief   Machine dependent Firm optimizations.
  * @date    28.9.2004
  * @author  Sebastian Hack, Michael Beck
- * @version $Id$
  *
  * Implements "Strength Reduction of Multiplications by Integer Constants"
  * by Youfeng Wu.
@@ -282,14 +281,10 @@ static unsigned char *complement_condensed(mul_env *env, unsigned char *R, int r
  */
 static ir_tarval *condensed_to_value(mul_env *env, unsigned char *R, int r)
 {
-       ir_tarval *res, *tv;
-       int i, j;
-
-       j = 0;
-       tv = get_mode_one(env->mode);
-       res = NULL;
-       for (i = 0; i < r; ++i) {
-               j = R[i];
+       ir_tarval *tv  = get_mode_one(env->mode);
+       ir_tarval *res = NULL;
+       for (int i = 0; i < r; ++i) {
+               int j = R[i];
                if (j) {
                        ir_tarval *t = new_tarval_from_long(j, mode_Iu);
                        tv = tarval_shl(tv, t);
@@ -572,19 +567,19 @@ ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn)
        ir_tarval *tv;
        const ir_settings_arch_dep_t *params = be_get_backend_param()->dep_param;
 
-
        /* If the architecture dependent optimizations were not initialized
           or this optimization was not enabled. */
        if (params == NULL || (opts & arch_dep_mul_to_shift) == 0)
-               return irn;
+               return res;
 
-       if (!is_Mul(irn) || !mode_is_int(mode))
+       assert(is_Mul(irn));
+       if (!mode_is_int(mode))
                return res;
 
        /* we should never do the reverse transformations again
           (like x+x -> 2*x) */
        irg = get_irn_irg(irn);
-       set_irg_state(irg, IR_GRAPH_STATE_ARCH_DEP);
+       add_irg_constraints(irg, IR_GRAPH_CONSTRAINT_ARCH_DEP);
 
        left    = get_binop_left(irn);
        right   = get_binop_right(irn);
@@ -600,6 +595,11 @@ ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn)
                operand = left;
        }
 
+       /* multiplications with 0 are a special case which we leave for
+        * equivalent_node_Mul because the code here can't handle them */
+       if (tv == get_mode_null(mode))
+               return res;
+
        if (tv != NULL) {
                res = do_decomposition(irn, operand, tv);
 
@@ -826,7 +826,7 @@ static ir_node *replace_div_by_mulh(ir_node *div, ir_tarval *tv)
 {
        dbg_info *dbg  = get_irn_dbg_info(div);
        ir_node *n     = get_binop_left(div);
-       ir_node *block = get_irn_n(div, -1);
+       ir_node *block = get_nodes_block(div);
        ir_mode *mode  = get_irn_mode(n);
        int bits       = get_mode_size_bits(mode);
        ir_node *q;
@@ -932,7 +932,7 @@ ir_node *arch_dep_replace_div_by_const(ir_node *irn)
        if (!mode_is_int(mode))
                return irn;
 
-       block = get_irn_n(irn, -1);
+       block = get_nodes_block(irn);
        dbg   = get_irn_dbg_info(irn);
 
        bits = get_mode_size_bits(mode);
@@ -1035,7 +1035,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn)
 
                left  = get_Mod_left(irn);
                mode  = get_irn_mode(left);
-               block = get_irn_n(irn, -1);
+               block = get_nodes_block(irn);
                dbg   = get_irn_dbg_info(irn);
                bits = get_mode_size_bits(mode);
                n    = (bits + 7) / 8;