Commit e6203174 authored by Matthias Braun's avatar Matthias Braun
Browse files

change a bunch of pointless usages of get_unop_op

parent 997a9d51
......@@ -122,12 +122,12 @@ static ir_node *gen_Mul(ir_node *node)
typedef ir_node* (*new_unop_func)(dbg_info *dbgi, ir_node *block, ir_node *op);
static ir_node *transform_unop(ir_node *node, new_unop_func new_func)
static ir_node *transform_unop(ir_node *node, int op_index, new_unop_func new_func)
{
ir_node *block = get_nodes_block(node);
ir_node *new_block = be_transform_node(block);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *op = get_unop_op(node);
ir_node *op = get_irn_n(node, op_index);
ir_node *new_op = be_transform_node(op);
return new_func(dbgi, new_block, new_op);
......@@ -138,14 +138,14 @@ static ir_node *gen_Minus(ir_node *node)
ir_mode *mode = get_irn_mode(node);
if (mode_is_float(mode)) {
return transform_unop(node, new_bd_TEMPLATE_fMinus);
return transform_unop(node, n_Minus_op, new_bd_TEMPLATE_fMinus);
}
return transform_unop(node, new_bd_TEMPLATE_Minus);
return transform_unop(node, n_Minus_op, new_bd_TEMPLATE_Minus);
}
static ir_node *gen_Not(ir_node *node)
{
return transform_unop(node, new_bd_TEMPLATE_Not);
return transform_unop(node, n_Not_op, new_bd_TEMPLATE_Not);
}
static ir_node *gen_Const(ir_node *node)
......
......@@ -116,18 +116,24 @@ static ir_node *gen_Shr (ir_node *const node) { return gen_binop(node, &new_bd_a
static ir_node *gen_Shrs(ir_node *const node) { return gen_binop(node, &new_bd_amd64_Sar); }
static ir_node *gen_Sub (ir_node *const node) { return gen_binop(node, &new_bd_amd64_Sub); }
static ir_node *gen_unop(ir_node *const node, ir_node *(*const new_node)(dbg_info*, ir_node*, ir_node*))
static ir_node *gen_unop(ir_node *const node, int op_pos, ir_node *(*const new_node)(dbg_info*, ir_node*, ir_node*))
{
dbg_info *const dbgi = get_irn_dbg_info(node);
ir_node *const block = be_transform_node(get_nodes_block(node));
ir_node *const op = get_unop_op(node);
ir_node *const op = get_irn_n(node, op_pos);
ir_node *const new_op = be_transform_node(op);
return new_node(dbgi, block, new_op);
}
static ir_node *gen_Minus(ir_node *const node) { return gen_unop(node, &new_bd_amd64_Neg); }
static ir_node *gen_Not (ir_node *const node) { return gen_unop(node, &new_bd_amd64_Not); }
static ir_node *gen_Minus(ir_node *const node)
{
return gen_unop(node, n_Minus_op, &new_bd_amd64_Neg);
}
static ir_node *gen_Not (ir_node *const node)
{
return gen_unop(node, n_Not_op, &new_bd_amd64_Not);
}
static ir_node *gen_Jmp(ir_node *node)
{
......
......@@ -316,30 +316,6 @@ static ir_node *gen_helper_binfpop(ir_node *node, ir_mode *mode,
panic("unsupported mode %+F for float op", mode);
}
static ir_node *gen_helper_unfpop(ir_node *node, ir_mode *mode,
new_unop_fp_func new_func_single,
new_unop_fp_func new_func_double,
new_unop_fp_func new_func_quad)
{
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *op = get_unop_op(node);
ir_node *new_op = be_transform_node(op);
dbg_info *dbgi = get_irn_dbg_info(node);
unsigned bits = get_mode_size_bits(mode);
switch (bits) {
case 32:
return new_func_single(dbgi, block, new_op, mode);
case 64:
return new_func_double(dbgi, block, new_op, mode);
case 128:
return new_func_quad(dbgi, block, new_op, mode);
default:
break;
}
panic("unsupported mode %+F for float op", mode);
}
typedef ir_node* (*new_binopx_imm_func)(dbg_info *dbgi, ir_node *block,
ir_node *op1, ir_node *flags,
ir_entity *imm_entity, int32_t imm);
......@@ -972,27 +948,42 @@ static ir_node *gen_Shrs(ir_node *node)
return gen_helper_binop(node, MATCH_NONE, new_bd_sparc_Sra_reg, new_bd_sparc_Sra_imm);
}
static ir_node *gen_fneg(ir_node *node, ir_mode *mode)
{
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *op = get_Minus_op(node);
ir_node *new_op = be_transform_node(op);
dbg_info *dbgi = get_irn_dbg_info(node);
unsigned bits = get_mode_size_bits(mode);
switch (bits) {
case 32:
return new_bd_sparc_fneg_s(dbgi, block, new_op, mode);
case 64:
return new_bd_sparc_fneg_d(dbgi, block, new_op, mode);
case 128:
return new_bd_sparc_fneg_q(dbgi, block, new_op, mode);
default:
break;
}
panic("unsupported mode %+F for float op", mode);
}
/**
* Transforms a Minus node.
*/
static ir_node *gen_Minus(ir_node *node)
{
ir_mode *mode = get_irn_mode(node);
ir_node *op;
ir_node *block;
ir_node *new_op;
ir_node *zero;
dbg_info *dbgi;
if (mode_is_float(mode)) {
return gen_helper_unfpop(node, mode, new_bd_sparc_fneg_s,
new_bd_sparc_fneg_d, new_bd_sparc_fneg_q);
}
block = be_transform_node(get_nodes_block(node));
dbgi = get_irn_dbg_info(node);
op = get_Minus_op(node);
new_op = be_transform_node(op);
zero = get_g0(get_irn_irg(node));
return gen_fneg(node, mode);
}
ir_node *block = be_transform_node(get_nodes_block(node));
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *op = get_Minus_op(node);
ir_node *new_op = be_transform_node(op);
ir_node *zero = get_g0(get_irn_irg(node));
return new_bd_sparc_Sub_reg(dbgi, block, zero, new_op);
}
......
......@@ -892,17 +892,27 @@ static ir_node *equivalent_node_Sub(ir_node *n)
* We handle it anyway here but the better way would be a
* flag. This would be needed for Pascal for instance.
*/
static ir_node *equivalent_node_involution(ir_node *n)
static ir_node *equivalent_node_involution(ir_node *n, int input)
{
ir_node *oldn = n;
ir_node *pred = get_unop_op(n);
ir_node *pred = get_irn_n(n, input);
if (get_irn_op(pred) == get_irn_op(n)) {
n = get_unop_op(pred);
n = get_irn_n(pred, input);
DBG_OPT_ALGSIM2(oldn, pred, n, FS_OPT_INVOLUTION);
}
return n;
}
static ir_node *equivalent_node_Minus(ir_node *n)
{
return equivalent_node_involution(n, n_Minus_op);
}
static ir_node *equivalent_node_Not(ir_node *n)
{
return equivalent_node_involution(n, n_Not_op);
}
/**
* Optimize a * 1 = 1 * a = a.
*/
......@@ -4037,8 +4047,9 @@ static ir_node *transform_node_Cmp(ir_node *n)
case iro_Not:
case iro_Minus:
/* ~a CMP ~b => a CMP b, -a CMP -b ==> a CMP b */
left = get_unop_op(left);
right = get_unop_op(right);
assert((int)n_Minus_op == (int)n_Not_op);
left = get_irn_n(left, n_Minus_op);
right = get_irn_n(right, n_Not_op);
changed = true;
DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_OP_OP);
break;
......@@ -6149,10 +6160,10 @@ void ir_register_opt_node_ops(void)
register_equivalent_node_func(op_Conv, equivalent_node_Conv);
register_equivalent_node_func(op_Eor, equivalent_node_Eor);
register_equivalent_node_func(op_Id, equivalent_node_Id);
register_equivalent_node_func(op_Minus, equivalent_node_involution);
register_equivalent_node_func(op_Minus, equivalent_node_Minus);
register_equivalent_node_func(op_Mul, equivalent_node_Mul);
register_equivalent_node_func(op_Mux, equivalent_node_Mux);
register_equivalent_node_func(op_Not, equivalent_node_involution);
register_equivalent_node_func(op_Not, equivalent_node_Not);
register_equivalent_node_func(op_Or, equivalent_node_Or);
register_equivalent_node_func(op_Phi, equivalent_node_Phi);
register_equivalent_node_func(op_Proj, equivalent_node_Proj);
......
......@@ -1085,16 +1085,16 @@ static void prepare_links_and_handle_rotl(ir_node *node, void *data)
*
* Create an intrinsic Call.
*/
static void lower_unop(ir_node *node, ir_mode *mode)
{
ir_node *op = get_unop_op(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = get_nodes_block(node);
ir_graph *irg = get_irn_irg(block);
ir_type *mtp = mode_is_signed(mode) ? unop_tp_s : unop_tp_u;
ir_op *irop = get_irn_op(node);
ir_node *addr = get_intrinsic_address(mtp, irop, mode, mode);
ir_node *nomem = get_irg_no_mem(irg);
static void lower_Minus(ir_node *node, ir_mode *mode)
{
ir_node *op = get_Minus_op(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = get_nodes_block(node);
ir_graph *irg = get_irn_irg(block);
ir_type *mtp = mode_is_signed(mode) ? unop_tp_s : unop_tp_u;
ir_op *irop = get_irn_op(node);
ir_node *addr = get_intrinsic_address(mtp, irop, mode, mode);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *in[2];
ir_node *call;
ir_node *resproj;
......@@ -3032,7 +3032,7 @@ void ir_prepare_dw_lowering(const lwrdw_param_t *new_param)
ir_register_dw_lower_function(op_Div, lower_Div);
ir_register_dw_lower_function(op_Eor, lower_Eor);
ir_register_dw_lower_function(op_Load, lower_Load);
ir_register_dw_lower_function(op_Minus, lower_unop);
ir_register_dw_lower_function(op_Minus, lower_Minus);
ir_register_dw_lower_function(op_Mod, lower_Mod);
ir_register_dw_lower_function(op_Mul, lower_binop);
ir_register_dw_lower_function(op_Mux, lower_Mux);
......
......@@ -94,7 +94,7 @@ int value_not_zero(const ir_node *n, const ir_node **confirm)
for (;;) {
if (is_Minus(n)) {
/* we can safely skip Minus when checking for != 0 */
n = get_unop_op(n);
n = get_Minus_op(n);
continue;
}
if (! is_Confirm(n))
......
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