void be_set_transformed_node(ir_node *old_node, ir_node *new_node)
{
+ ir_graph *irg = get_irn_irg(old_node);
+
set_irn_link(old_node, new_node);
mark_irn_visited(old_node);
+ hook_dead_node_elim_subst(irg, old_node, new_node);
}
int be_is_transformed(const ir_node *node)
*/
static ir_node *transform_block(ir_node *node)
{
- ir_graph *irg = current_ir_graph;
- dbg_info *dbgi = get_irn_dbg_info(node);
+ ir_graph *irg = get_irn_irg(node);
+ dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block;
block = new_ir_node(dbgi, irg, NULL, get_irn_op(node), get_irn_mode(node),
static ir_node *transform_end(ir_node *node)
{
/* end has to be duplicated manually because we need a dynamic in array */
- ir_graph *irg = current_ir_graph;
+ ir_graph *irg = get_irn_irg(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = be_transform_node(get_nodes_block(node));
int i, arity;
assert(new_node != NULL);
be_set_transformed_node(node, new_node);
- hook_dead_node_elim_subst(current_ir_graph, node, new_node);
return new_node;
}
return be_transform_node(place);
}
-static void pre_transform_anchor(int anchor)
+static void pre_transform_anchor(ir_graph *irg, int anchor)
{
ir_node *old_anchor_node = get_irn_n(env.old_anchor, anchor);
ir_node *transformed = be_transform_node(old_anchor_node);
- set_irg_anchor(current_ir_graph, anchor, transformed);
-}
-
-static void kill_unused_anchor(int anchor)
-{
- ir_node *old_anchor_node = get_irn_n(env.old_anchor, anchor);
- ir_node *old_bad = get_irn_n(env.old_anchor, anchor_bad);
- if (old_anchor_node != NULL && get_irn_n_edges(old_anchor_node) <= 1) {
- set_irn_n(env.old_anchor, anchor, old_bad);
- }
+ set_irg_anchor(irg, anchor, transformed);
}
/**
/* pre transform some anchors (so they are available in the other transform
* functions) */
- pre_transform_anchor(anchor_bad);
- pre_transform_anchor(anchor_no_mem);
- pre_transform_anchor(anchor_end_block);
- pre_transform_anchor(anchor_end);
- pre_transform_anchor(anchor_start_block);
- pre_transform_anchor(anchor_start);
- pre_transform_anchor(anchor_frame);
- kill_unused_anchor(anchor_tls);
+ pre_transform_anchor(irg, anchor_no_mem);
+ pre_transform_anchor(irg, anchor_end_block);
+ pre_transform_anchor(irg, anchor_end);
+ pre_transform_anchor(irg, anchor_start_block);
+ pre_transform_anchor(irg, anchor_start);
+ pre_transform_anchor(irg, anchor_frame);
if (pre_transform)
pre_transform();
be_transform_node(node);
}
- /* let beabi grab new nodes */
- be_abi_transform_fixup(irg);
- assert(waitq_empty(env.worklist)); // let's hope this didn't trigger new transforms
-
/* fix loops and set new anchors*/
inc_irg_visited(irg);
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
edges_deactivate(irg);
edges_activate(irg);
}
-
-int be_mux_is_abs(ir_node *sel, ir_node *mux_true, ir_node *mux_false)
-{
- ir_node *cmp_left;
- ir_node *cmp_right;
- ir_mode *mode;
- ir_relation relation;
-
- if (!is_Cmp(sel))
- return 0;
-
- /**
- * Note further that these optimization work even for floating point
- * with NaN's because -NaN == NaN.
- * However, if +0 and -0 is handled differently, we cannot use the Abs/-Abs
- * transformations.
- */
- mode = get_irn_mode(mux_true);
- if (mode_honor_signed_zeros(mode))
- return 0;
-
- /* must be <, <=, >=, > */
- relation = get_Cmp_relation(sel);
- if ((relation & ir_relation_less_greater) == 0)
- return 0;
-
- if (!ir_is_negated_value(mux_true, mux_false))
- return 0;
-
- /* must be x cmp 0 */
- cmp_right = get_Cmp_right(sel);
- if (!is_Const(cmp_right) || !is_Const_null(cmp_right))
- return 0;
-
- cmp_left = get_Cmp_left(sel);
- if (cmp_left == mux_false) {
- if (relation & ir_relation_less) {
- return 1;
- } else {
- assert(relation & ir_relation_greater);
- return -1;
- }
- } else if (cmp_left == mux_true) {
- if (relation & ir_relation_less) {
- return -1;
- } else {
- assert(relation & ir_relation_greater);
- return 1;
- }
- }
-
- return 0;
-}
-
-ir_node *be_get_abs_op(ir_node *sel)
-{
- ir_node *cmp_left = get_Cmp_left(sel);
- return cmp_left;
-}