#include "debug.h"
#include "error.h"
#include "irflag.h"
-#include "opt_manage.h"
/**
* Walker environment.
*/
static void handle_case(ir_node *block, ir_node *switchn, long pn, env_t *env)
{
- ir_node *c = NULL;
- ir_node *selector = get_Switch_selector(switchn);
- const ir_edge_t *edge;
- const ir_edge_t *next;
+ ir_node *c = NULL;
+ ir_node *selector = get_Switch_selector(switchn);
/* we can't do usefull things with the default label */
if (pn == pn_Switch_default)
return;
- foreach_out_edge_safe(selector, edge, next) {
+ foreach_out_edge_safe(selector, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *blk = get_effective_use_block(succ, pos);
{
ir_node *cond, *old, *other_blk = NULL, *con = NULL;
ir_node *c_b = NULL, *c_o = NULL;
- const ir_edge_t *edge, *next;
- for (edge = get_irn_out_edge_first(selector); edge; edge = next) {
+ foreach_out_edge_safe(selector, edge) {
ir_node *user = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *user_blk = get_effective_use_block(user, pos);
- next = get_irn_out_edge_next(selector, edge);
if (block_dominates(block, user_blk)) {
/*
* Ok, we found a usage of selector in a block
ir_node *left = get_Cmp_left(cmp);
ir_node *right = get_Cmp_right(cmp);
ir_node *cond_block;
- ir_op *op;
- const ir_edge_t *edge, *next;
/* Beware of Bads */
if (is_Bad(left) || is_Bad(right))
return;
- op = get_irn_op(left);
-
/* Do not create Confirm nodes for Cmp(Const, Const) constructs.
These are removed anyway */
- if (op == op_Const && is_Const(right))
+ if (is_Const(left) && is_Const(right))
return;
/* try to place the constant on the right side for a Confirm */
- if (op == op_Const || op == op_SymConst) {
+ if (is_Const(left) || is_SymConst(left)) {
ir_node *t = left;
left = right;
*/
if (rel == ir_relation_equal) {
cond_block = get_Block_cfgpred_block(block, 0);
- for (edge = get_irn_out_edge_first(left); edge; edge = next) {
+ foreach_out_edge_safe(left, edge) {
ir_node *user = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *blk = get_effective_use_block(user, pos);
- next = get_irn_out_edge_next(left, edge);
if (block_dominates(block, blk)) {
/*
* Ok, we found a usage of left in a block
* left == Const and we found a movable user of left in a
* dominator of the Cond block
*/
- const ir_edge_t *user_edge;
- const ir_edge_t *user_next;
- foreach_out_edge_safe(user, user_edge, user_next) {
+ foreach_out_edge_safe(user, user_edge) {
ir_node *usr_of_usr = get_edge_src_irn(user_edge);
int npos = get_edge_src_pos(user_edge);
ir_node *user_blk = get_effective_use_block(usr_of_usr, npos);
} else { /* not ir_relation_equal cases */
ir_node *c = NULL;
- foreach_out_edge_safe(left, edge, next) {
+ foreach_out_edge_safe(left, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *blk = get_effective_use_block(succ, pos);
ir_node *rc = NULL;
rel = get_inversed_relation(rel);
- foreach_out_edge_safe(right, edge, next) {
+ foreach_out_edge_safe(right, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos;
ir_node *blk;
*/
static void insert_non_null(ir_node *ptr, ir_node *block, env_t *env)
{
- const ir_edge_t *edge, *next;
- ir_node *c = NULL;
+ ir_node *c = NULL;
- foreach_out_edge_safe(ptr, edge, next) {
+ foreach_out_edge_safe(ptr, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos;
ir_node *blk;
}
}
-/*
- * Construct Confirm nodes
- */
-static ir_graph_properties_t do_construct_confirms(ir_graph *irg)
+void construct_confirms(ir_graph *irg)
{
env_t env;
FIRM_DBG_REGISTER(dbg, "firm.ana.confirm");
+ assure_irg_properties(irg,
+ IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
+ | IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
+ | IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES);
+
assert(get_irg_pinned(irg) == op_pin_state_pinned &&
"Nodes must be placed to insert Confirms");
DB((dbg, LEVEL_1, "# Const replacements: %u\n", env.num_consts));
DB((dbg, LEVEL_1, "# node equalities : %u\n", env.num_eq));
DB((dbg, LEVEL_1, "# non-null Confirms : %u\n", env.num_non_null));
- return 0;
-}
-
-static optdesc_t opt_confirms = {
- "confirms",
- IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
- | IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
- | IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES,
- do_construct_confirms
-};
-void construct_confirms(ir_graph *irg)
-{
- perform_irg_optimization(irg, &opt_confirms);
+ confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_CONTROL_FLOW);
}
ir_graph_pass_t *construct_confirms_pass(const char *name)
void remove_confirms(ir_graph *irg)
{
irg_walk_graph(irg, NULL, remove_confirm, NULL);
+ confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_CONTROL_FLOW);
}
ir_graph_pass_t *remove_confirms_pass(const char *name)