Commit ea9c2195 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ircons: Add and use new_{r,rd}_Const_one().

parent f86e2456
......@@ -14,7 +14,7 @@
#include "irgwalk.h"
#include "irprog.h"
#include "iredges_t.h"
#include "ircons.h"
#include "ircons_t.h"
#include "irflag.h"
#include "irgmod.h"
#include "irgopt.h"
......@@ -1371,7 +1371,7 @@ static ir_node *ia32_create_trampoline_fkt(ir_node *block, ir_node *mem, ir_node
ir_graph *const irg = get_irn_irg(block);
ir_node * p = trampoline;
ir_mode *const mode = get_irn_mode(p);
ir_node *const one = new_r_Const(irg, get_mode_one(ia32_mode_gp));
ir_node *const one = new_r_Const_one(irg, ia32_mode_gp);
ir_node *const four = new_r_Const_long(irg, ia32_mode_gp, 4);
ir_node * st;
......
......@@ -658,3 +658,13 @@ ir_node *new_r_Const_null(ir_graph *const irg, ir_mode *const mode)
{
return new_r_Const(irg, get_mode_null(mode));
}
ir_node *new_rd_Const_one(dbg_info *const dbgi, ir_graph *const irg, ir_mode *const mode)
{
return new_rd_Const(dbgi, irg, get_mode_one(mode));
}
ir_node *new_r_Const_one(ir_graph *const irg, ir_mode *const mode)
{
return new_r_Const(irg, get_mode_one(mode));
}
......@@ -85,4 +85,8 @@ ir_node *new_rd_Const_null(dbg_info *dbgi, ir_graph *irg, ir_mode *mode);
ir_node *new_r_Const_null(ir_graph *irg, ir_mode *mode);
ir_node *new_rd_Const_one(dbg_info *dbgi, ir_graph *irg, ir_mode *mode);
ir_node *new_r_Const_one(ir_graph *irg, ir_mode *mode);
#endif
......@@ -2604,7 +2604,7 @@ static ir_node *transform_node_Add(ir_node *n)
return n;
} else if (get_mode_arithmetic(mode) == irma_twos_complement) {
/* a + a -> a << 1 */
ir_node *const one = new_r_Const(irg, get_mode_one(mode_Iu));
ir_node *const one = new_r_Const_one(irg, mode_Iu);
n = new_rd_Shl(dbgi, block, a, one, mode);
return n;
}
......@@ -2668,7 +2668,7 @@ static ir_node *transform_node_Add(ir_node *n)
if (y) {
/* x + (x * y) -> x * (y + 1) */
mul_y_plus_1:;
z = new_r_Const(irg, get_mode_one(mode));
z = new_r_Const_one(irg, mode);
mul_y_plus_z:;
dbg_info *const dbgi = get_irn_dbg_info(n);
ir_node *const block = get_nodes_block(n);
......@@ -2935,7 +2935,7 @@ restart:
dbg_info *const dbg = get_irn_dbg_info(n);
ir_node *const blk = get_nodes_block(n);
ir_graph *const irg = get_irn_irg(n);
ir_node *const one = new_r_Const(irg, get_mode_one(mode));
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);
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_MUL_A_X_A);
......@@ -3078,8 +3078,7 @@ static ir_node *can_negate_cheaply(ir_node *node)
if (is_Not(node)) {
assert(get_mode_arithmetic(mode) == irma_twos_complement);
ir_graph *irg = get_irn_irg(node);
ir_tarval *tv1 = get_mode_one(mode);
ir_node *c1 = new_r_Const(irg, tv1);
ir_node *c1 = new_r_Const_one(irg, mode);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = get_nodes_block(node);
ir_node *op = get_Not_op(node);
......@@ -5777,8 +5776,7 @@ static ir_node *transform_Mux_set(ir_node *n, ir_relation relation)
unsigned shift_amount = get_tarval_highest_bit(tv);
ir_node *shift_cnt = new_rd_Const_long(dbgi, irg, mode_Iu, shift_amount);
ir_node *shift = new_rd_Shr(dbgi, block, a, shift_cnt, calc_mode);
ir_tarval *one = get_mode_one(calc_mode);
ir_node *c = new_rd_Const(dbgi, irg, one);
ir_node *c = new_rd_Const_one(dbgi, irg, calc_mode);
ir_node *and = new_rd_And(dbgi, block, shift, c, calc_mode);
if (calc_mode != dest_mode) {
and = new_rd_Conv(dbgi, block, and, dest_mode);
......
......@@ -251,7 +251,7 @@ static void instrument_block(ir_node *bb, ir_node *address, unsigned int id)
load = new_r_Load(bb, unknown, offset, mode_Iu, cons_none);
projm = new_r_Proj(load, mode_M, pn_Load_M);
proji = new_r_Proj(load, mode_Iu, pn_Load_res);
cnst = new_r_Const(irg, get_mode_one(mode_Iu));
cnst = new_r_Const_one(irg, mode_Iu);
add = new_r_Add(bb, proji, cnst, mode_Iu);
store = new_r_Store(bb, projm, offset, add, cons_none);
projm = new_r_Proj(store, mode_M, pn_Store_M);
......
......@@ -120,11 +120,9 @@ static void replace_may_alias(ir_node *node)
ir_alias_relation alias = get_alias_relation(in0, type0, in1, type1);
ir_graph *irg = get_irn_irg(node);
ir_tarval *resval = alias == ir_no_alias
? get_mode_null(rmode) : get_mode_one(rmode);
ir_node *result = new_r_Const(irg, resval);
ir_node *const in[] = {
ir_graph *const irg = get_irn_irg(node);
ir_node *const result = (alias != ir_no_alias ? new_r_Const_one : new_r_Const_null)(irg, rmode);
ir_node *const in[] = {
[pn_Builtin_M] = get_Builtin_mem(node),
[pn_Builtin_max+1] = result,
};
......
......@@ -824,7 +824,7 @@ static void lower_shr_helper(ir_node *node, ir_mode *mode,
low_unsigned);
ir_node *tconv = create_conv(block_true, left_high,
low_unsigned);
ir_node *one = new_r_Const(irg, get_mode_one(low_unsigned));
ir_node *one = new_r_Const_one(irg, low_unsigned);
ir_node *carry0 = new_rd_Shl(dbgi, block_true, tconv, one,
low_unsigned);
ir_node *carry1 = new_rd_Shl(dbgi, block_true, carry0,
......@@ -933,7 +933,7 @@ static void lower_Shl(ir_node *node, ir_mode *mode)
ir_node *not_shiftval = new_rd_Not(dbgi, block_true, right,
low_unsigned);
ir_node *conv = create_conv(block_true, left_low, mode);
ir_node *one = new_r_Const(irg, get_mode_one(low_unsigned));
ir_node *one = new_r_Const_one(irg, low_unsigned);
ir_node *carry0 = new_rd_Shr(dbgi, block_true, conv, one, mode);
ir_node *carry1 = new_rd_Shr(dbgi, block_true, carry0,
not_shiftval, mode);
......
......@@ -295,7 +295,7 @@ int i_mapper_pow(ir_node *call)
if (tarval_is_null(tv)) {
/* pow(x, 0.0) = 1.0 */
ir_mode *mode = get_tarval_mode(tv);
irn = new_r_Const(irg, get_mode_one(mode));
irn = new_r_Const_one(irg, mode);
} else if (tarval_is_one(tv)) {
/* pow(x, 1.0) = x */
irn = left;
......@@ -322,7 +322,7 @@ int i_mapper_pow(ir_node *call)
mode = float_arithmetic;
}
irn = new_r_Const(irg, get_mode_one(mode));
irn = new_r_Const_one(irg, mode);
div = new_rd_Div(dbg, block, mem, irn, left, mode, op_pin_state_pinned);
mem = new_r_Proj(div, mode_M, pn_Div_M);
irn = new_r_Proj(div, mode, pn_Div_res);
......@@ -348,7 +348,7 @@ int i_mapper_exp(ir_node *call)
/* exp(0.0) = 1.0 */
ir_graph *irg = get_irn_irg(val);
ir_mode *mode = get_irn_mode(val);
ir_node *irn = new_r_Const(irg, get_mode_one(mode));
ir_node *irn = new_r_Const_one(irg, mode);
ir_node *mem = get_Call_mem(call);
DBG_OPT_ALGSIM0(call, irn, FS_OPT_RTS_EXP);
replace_call(irn, call, mem, NULL, NULL);
......@@ -440,7 +440,7 @@ static int i_mapper_symmetric_zero_to_one(ir_node *call, int reason)
/* f(0.0) = 1.0 */
ir_graph *irg = get_irn_irg(val);
ir_mode *mode = get_irn_mode(val);
ir_node *irn = new_r_Const(irg, get_mode_one(mode));
ir_node *irn = new_r_Const_one(irg, mode);
ir_node *mem = get_Call_mem(call);
DBG_OPT_ALGSIM0(call, irn, reason);
replace_call(irn, call, mem, NULL, NULL);
......
......@@ -38,11 +38,10 @@ static needs_lowering_t *needs_lowering;
static ir_node *create_not(dbg_info *dbgi, ir_node *node)
{
ir_node *block = get_nodes_block(node);
ir_mode *mode = lowered_mode;
ir_tarval *tv_one = get_mode_one(mode);
ir_graph *irg = get_irn_irg(node);
ir_node *one = new_rd_Const(dbgi, irg, tv_one);
ir_node *block = get_nodes_block(node);
ir_mode *mode = lowered_mode;
ir_graph *irg = get_irn_irg(node);
ir_node *one = new_rd_Const_one(dbgi, irg, mode);
return new_rd_Eor(dbgi, block, node, one, mode);
}
......@@ -75,7 +74,7 @@ static ir_node *create_cond_set(ir_node *cond_value, ir_mode *dest_mode)
ir_node *true_jmp = new_r_Jmp(true_block);
ir_node *false_jmp = new_r_Jmp(false_block);
ir_node *lower_in[2] = { true_jmp, false_jmp };
ir_node *one = new_r_Const(irg, get_mode_one(dest_mode));
ir_node *one = new_r_Const_one(irg, dest_mode);
ir_node *zero = new_r_Const_null(irg, dest_mode);
ir_node *phi_in[2] = { one, zero };
ir_node *phi;
......@@ -175,8 +174,7 @@ static ir_node *lower_node(ir_node *node)
case iro_Const: {
ir_tarval *tv = get_Const_tarval(node);
if (tv == get_tarval_b_true()) {
ir_tarval *tv_one = get_mode_one(mode);
res = new_rd_Const(dbgi, irg, tv_one);
res = new_rd_Const_one(dbgi, irg, mode);
} else if (tv == get_tarval_b_false()) {
res = new_rd_Const_null(dbgi, irg, mode);
} else {
......
......@@ -247,7 +247,7 @@ static void do_opt_tail_rec(ir_graph *irg, tr_env *env)
if (env->variants[i] == TR_ADD) {
set_r_value(irg, i, new_r_Const_null(irg, mode));
} else if (env->variants[i] == TR_MUL) {
set_r_value(irg, i, new_r_Const(irg, get_mode_one(mode)));
set_r_value(irg, i, new_r_Const_one(irg, mode));
}
}
mature_immBlock(start_block);
......
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