return REGION_CONST;
return NO_CONSTANT;
-} /* get_const_class */
+}
/**
* returns the operands of a commutative bin-op, if one operand is
*c = op_b;
break;
}
-} /* get_comm_Binop_ops */
+}
/**
* reassociate a Sub: x - c = x + (-c)
return 1;
}
return 0;
-} /* reassoc_Sub */
+}
/** Retrieve a mode from the operands. We need this, because
* Add and Sub are allowed to operate on (P, Is)
assert(m1 == m2);
return m1;
-} /* get_mode_from_ops */
+}
/**
* reassociate a commutative Binop
}
}
return 0;
-} /* reassoc_commutative */
-
-#define reassoc_Add reassoc_commutative
-#define reassoc_And reassoc_commutative
-#define reassoc_Or reassoc_commutative
-#define reassoc_Eor reassoc_commutative
+}
/**
* Reassociate using commutative law for Mul and distributive law for Mul and Add/Sub:
}
}
return 0;
-} /* reassoc_Mul */
+}
/**
* Reassociate Shl. We transform Shl(x, const) into Mul's if possible.
return 1;
}
return 0;
-} /* reassoc_Shl */
+}
/**
* The walker for the reassociation.
waitq_put(wq, n);
set_irn_link(n, wq);
}
-} /* wq_walker */
+}
/**
* The walker for the reassociation.
}
}
}
-} /* do_reassociation */
+}
/**
* Returns the earliest were a,b are available.
if (res == get_irg_start_block(get_irn_irg(curr_blk)))
return curr_blk;
return res;
-} /* earliest_block */
+}
/**
* Checks whether a node is a Constant expression.
default:
return 0;
}
-} /* is_constant_expr */
+}
/**
* Apply distributive Law for Mul and Add/Sub
exchange(n, irn);
*node = irn;
return 1;
-} /* reverse_rule_distributive */
+}
/**
* Move Constants towards the root.
exchange(n, irn);
*node = irn;
return 1;
-} /* move_consts_up */
+}
/**
* Apply the rules in reverse order, removing code that was not collapsed
*/
void optimize_reassociation(ir_graph *irg)
{
- assert(get_irg_phase_state(irg) != phase_building);
assert(get_irg_pinned(irg) != op_pin_state_floats &&
"Reassociation needs pinned graph to work properly");
del_waitq(wq);
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_CONTROL_FLOW);
-} /* optimize_reassociation */
+}
/* create a pass for the reassociation */
ir_graph_pass_t *optimize_reassociation_pass(const char *name)
{
return def_graph_pass(name ? name : "reassoc", optimize_reassociation);
-} /* optimize_reassociation_pass */
+}
static void register_node_reassoc_func(ir_op *op, reassociate_func func)
{
void ir_register_reassoc_node_ops(void)
{
+ register_node_reassoc_func(op_Add, reassoc_commutative);
+ register_node_reassoc_func(op_And, reassoc_commutative);
+ register_node_reassoc_func(op_Eor, reassoc_commutative);
register_node_reassoc_func(op_Mul, reassoc_Mul);
- register_node_reassoc_func(op_Add, reassoc_Add);
+ register_node_reassoc_func(op_Or, reassoc_commutative);
register_node_reassoc_func(op_Sub, reassoc_Sub);
- register_node_reassoc_func(op_And, reassoc_And);
- register_node_reassoc_func(op_Or, reassoc_Or);
- register_node_reassoc_func(op_Eor, reassoc_Eor);
register_node_reassoc_func(op_Shl, reassoc_Shl);
}
void firm_init_reassociation(void)
{
FIRM_DBG_REGISTER(dbg, "firm.opt.reassoc");
-} /* firm_init_reassociation */
+}