Commit 550c63db authored by Christoph Mallon's avatar Christoph Mallon
Browse files

When making a 'Mul', automatically infer its mode from its left operand.

parent 47929205
......@@ -89,14 +89,13 @@ static void lower64_mul(ir_node *node, ir_mode *mode)
ir_node *right_low = get_lowered_low(right);
ir_node *right_high = get_lowered_high(right);
ir_node *conv_l_low = new_rd_Conv(dbgi, block, left_low, mode);
ir_node *mul1 = new_rd_Mul(dbgi, block, conv_l_low, right_high,
mode);
ir_node *mul1 = new_rd_Mul(dbgi, block, conv_l_low, right_high);
ir_node *umull = new_bd_arm_UMulL_t(dbgi, block, left_low, right_low);
ir_mode *umode = get_irn_mode(right_low);
ir_node *umull_low = new_r_Proj(umull, umode, pn_arm_UMulL_t_low);
ir_node *umull_high = new_r_Proj(umull, mode, pn_arm_UMulL_t_high);
ir_node *conv_r_low = new_rd_Conv(dbgi, block, right_low, mode);
ir_node *mul2 = new_rd_Mul(dbgi, block, conv_r_low, left_high, mode);
ir_node *mul2 = new_rd_Mul(dbgi, block, conv_r_low, left_high);
ir_node *add1 = new_rd_Add(dbgi, block, mul2, mul1, mode);
ir_node *add2 = new_rd_Add(dbgi, block, add1, umull_high, mode);
ir_set_dw_lowered(node, umull_low, add2);
......
......@@ -313,10 +313,10 @@ static void ia32_lower_mul64(ir_node *node, ir_mode *mode)
l_res = new_rd_Proj(dbg, mul, ia32_mode_gp, pn_ia32_l_Mul_res_low);
ir_node *right_lowc = new_rd_Conv(dbg, block, right_low, mode);
ir_node *mul1 = new_rd_Mul(dbg, block, left_high, right_lowc, mode);
ir_node *mul1 = new_rd_Mul(dbg, block, left_high, right_lowc);
ir_node *add = new_rd_Add(dbg, block, mul1, pEDX, mode);
ir_node *left_lowc = new_rd_Conv(dbg, block, left_low, mode);
ir_node *mul2 = new_rd_Mul(dbg, block, left_lowc, right_high, mode);
ir_node *mul2 = new_rd_Mul(dbg, block, left_lowc, right_high);
h_res = new_rd_Add(dbg, block, add, mul2, mode);
}
ir_set_dw_lowered(node, l_res, h_res);
......
......@@ -1048,7 +1048,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn)
/* other constant */
} else if (allow_Mulh(params, mode)) {
res = replace_div_by_mulh(irn, tv);
res = new_rd_Mul(dbg, block, res, c, mode);
res = new_rd_Mul(dbg, block, res, c);
res = new_rd_Sub(dbg, block, left, res, mode);
}
......
......@@ -340,8 +340,7 @@ ir_node *duplicate_subgraph(dbg_info *dbg, ir_node *n, ir_node *block)
case iro_Mul:
return new_rd_Mul(dbg, block,
duplicate_subgraph(dbg, get_Mul_left(n), block),
duplicate_subgraph(dbg, get_Mul_right(n), block),
mode);
duplicate_subgraph(dbg, get_Mul_right(n), block));
case iro_And:
return new_rd_And(dbg, block,
duplicate_subgraph(dbg, get_And_left(n), block),
......
......@@ -47,7 +47,7 @@ static void lower_sel(ir_node *sel)
ir_graph *const irg = get_irn_irg(sel);
ir_node *const el_size = new_rd_Const_long(dbg, irg, offset_mode,
element_size);
scaled_index = new_rd_Mul(dbg, bl, idx_conv, el_size, offset_mode);
scaled_index = new_rd_Mul(dbg, bl, idx_conv, el_size);
}
newn = new_rd_Add(dbg, bl, ptr, scaled_index, mode);
}
......
......@@ -3072,7 +3072,7 @@ static ir_node *transform_node_Add(ir_node *n)
ir_tarval *const tv_one = get_mode_one(mode);
ir_tarval *const tv_two = tarval_add(tv_one, tv_one);
ir_node *const two = new_r_Const(irg, tv_two);
n = new_rd_Mul(dbgi, block, a, two, mode);
n = new_rd_Mul(dbgi, block, a, two);
DBG_OPT_ALGSIM0(oldn, n);
return n;
} else if (get_mode_arithmetic(mode) == irma_twos_complement) {
......@@ -3171,7 +3171,7 @@ mul_y_plus_z:;
dbg_info *const dbgi = get_irn_dbg_info(n);
ir_node *const block = get_nodes_block(n);
ir_node *const sum = new_rd_Add(dbgi, block, y, z, mode);
return new_rd_Mul(dbgi, block, x, sum, mode);
return new_rd_Mul(dbgi, block, x, sum);
}
}
}
......@@ -3466,7 +3466,7 @@ static ir_node *transform_node_Sub(ir_node *n)
ir_graph *const irg = get_irn_irg(n);
ir_node *const one = new_r_Const_one(irg, mode);
ir_node *const sub = new_rd_Sub(dbg, blk, y, one, mode);
n = new_rd_Mul(dbg, blk, x, sub, mode);
n = new_rd_Mul(dbg, blk, x, sub);
DBG_OPT_ALGSIM0(oldn, n);
return n;
}
......@@ -3627,7 +3627,7 @@ static ir_node *can_negate_cheaply(dbg_info *const dbgi, ir_node *const node)
ir_graph *irg = get_irn_irg(node);
ir_node *newc = new_r_Const(irg, negtv);
ir_node *block = get_nodes_block(node);
return new_rd_Mul(dbgi, block, left, newc, mode);
return new_rd_Mul(dbgi, block, left, newc);
}
}
/* -(a + C) => -C - a */
......@@ -3715,7 +3715,7 @@ static ir_node *transform_node_Mul(ir_node *n)
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_node *mul = new_rd_Mul(dbgi, block, add_left, b, mode);
ir_node *mul = new_rd_Mul(dbgi, block, add_left, b);
ir_tarval *c1_c2 = tarval_mul(c1, c2);
ir_graph *irg = get_irn_irg(n);
ir_node *cnst = new_r_Const(irg, c1_c2);
......@@ -3769,7 +3769,7 @@ static ir_node *transform_node_Mul(ir_node *n)
if (neg_b != NULL) {
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
return new_rd_Mul(dbgi, block, get_Minus_op(a), neg_b, mode);
return new_rd_Mul(dbgi, block, get_Minus_op(a), neg_b);
}
}
/* distribute minus: x * -y => -x * y */
......@@ -3778,7 +3778,7 @@ static ir_node *transform_node_Mul(ir_node *n)
if (neg_a != NULL) {
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
return new_rd_Mul(dbgi, block, neg_a, get_Minus_op(b), mode);
return new_rd_Mul(dbgi, block, neg_a, get_Minus_op(b));
}
}
if (is_Shl(a)) {
......@@ -3948,7 +3948,7 @@ static ir_node *transform_node_Div(ir_node *n)
ir_graph *irg = get_irn_irg(block);
ir_node *c = new_r_Const(irg, tv);
dbg_info *dbgi = get_irn_dbg_info(n);
value = new_rd_Mul(dbgi, block, a, c, mode);
value = new_rd_Mul(dbgi, block, a, c);
goto make_tuple;
}
......@@ -4717,15 +4717,13 @@ static ir_node *transform_node_Minus(ir_node *n)
if (negated_l != NULL) {
/* -((a - b) * c) -> (b - a) * c */
ir_node *block = get_nodes_block(n);
ir_mode *mode = get_irn_mode(n);
return new_rd_Mul(dbgi, block, negated_l, r, mode);
return new_rd_Mul(dbgi, block, negated_l, r);
}
ir_node *negated_r = can_negate_cheaply(NULL, r);
if (negated_r != NULL) {
/* -(a * (b - c)) -> a * (c - b) */
ir_node *block = get_nodes_block(n);
ir_mode *mode = get_irn_mode(n);
return new_rd_Mul(dbgi, block, l, negated_r, mode);
return new_rd_Mul(dbgi, block, l, negated_r);
}
}
......@@ -6260,7 +6258,7 @@ static ir_node *transform_node_Shl(ir_node *n)
ir_tarval *const one = get_mode_one(mode);
ir_tarval *const val = tarval_shl(one, get_Const_tarval(b));
ir_node *const cnst = new_r_Const(irg, val);
return new_rd_Mul(dbgi, block, a, cnst, mode);
return new_rd_Mul(dbgi, block, a, cnst);
}
}
......
......@@ -289,7 +289,7 @@ static ir_node *do_apply(unsigned code, dbg_info *db, ir_node *op1,
ir_node *block = find_location(get_nodes_block(op1), get_nodes_block(op2));
switch (code) {
case iro_Mul:
return new_rd_Mul(db, block, op1, op2, mode);
return new_rd_Mul(db, block, op1, op2);
case iro_Add:
return new_rd_Add(db, block, op1, op2, mode);
case iro_Sub:
......
......@@ -439,7 +439,7 @@ transform:;
blk = earliest_block(irn, x, curr_blk);
if (op == op_Mul)
irn = new_rd_Mul(dbg, blk, irn, x, mode);
irn = new_rd_Mul(dbg, blk, irn, x);
else
irn = new_rd_Shl(dbg, blk, irn, x, mode);
......@@ -1815,9 +1815,8 @@ static void rebuild(multi_op_env *multi_env)
}
if (!is_one) {
ir_mode *node_mode = get_irn_mode(inner);
ir_node *c = new_rd_Const(dbgi, get_irn_irg(inner), positiv_val);
inner = new_rd_Mul(dbgi, block, c, inner, node_mode);
inner = new_rd_Mul(dbgi, block, c, inner);
}
if (!curr || is_one) {
......@@ -1856,7 +1855,7 @@ static void rebuild(multi_op_env *multi_env)
if (!tarval_is_one(positiv_val)) {
ir_mode *node_mode = get_irn_mode(inner);
ir_node *c = new_rd_Const(dbgi, get_irn_irg(inner), tarval_convert_to(positiv_val, node_mode));
inner = new_rd_Mul(dbgi, block, c, inner, node_mode);
inner = new_rd_Mul(dbgi, block, c, inner);
}
if (!curr) {
......
......@@ -278,7 +278,7 @@ static void do_opt_tail_rec(ir_graph *irg, tr_env *env)
case TR_MUL: {
ir_node *v = get_r_value(irg, r, modes[r]);
ir_node *n = new_r_Mul(pred_block, v, pred, modes[r]);
ir_node *n = new_r_Mul(pred_block, v, pred);
set_Return_res(ret, r, n);
continue;
}
......
......@@ -590,6 +590,7 @@ class Mod(Node):
class Mul(Binop):
"""returns the product of its operands"""
mode = "get_irn_mode(irn_left)"
flags = [ "commutative" ]
class Mulh(Binop):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment