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

split graph state into properties and constraints

graph_properties are things that a transformation may destroy but which
can be easily recalculated.

graph_constraints are set after lowering phases have been running and
forbid certain constructs that no (later) transformation is allowed to construct
parent 81e19778
......@@ -413,71 +413,92 @@ FIRM_API ir_resources_t ir_resources_reserved(const ir_graph *irg);
#endif
/**
* graph state. This is used for 2 things:
* - stating properties about a graph
* - disallow certain transformations for the graph (typically highlevel
* constructs are disallowed after lowering them)
* graph constraints:
* These are typically used when lowering a graph for a target machine,
* typically you get stricter constraints the closer you get to a real
* machine.
*/
typedef enum {
typedef enum ir_graph_constraints_t {
/**
* Should not construct more nodes which irarch potentially breaks down
*/
IR_GRAPH_STATE_ARCH_DEP = 1U << 0,
IR_GRAPH_CONSTRAINT_ARCH_DEP = 1U << 0,
/**
* mode_b nodes have been lowered so you should not create any new nodes
* with mode_b (except for Cmp)
*/
IR_GRAPH_STATE_MODEB_LOWERED = 1U << 1,
IR_GRAPH_CONSTRAINT_MODEB_LOWERED = 1U << 1,
/**
* There are normalisations where there is no "best" representative.
* In this case we first normalise into 1 direction (!NORMALISATION2) and
* later in the other (NORMALISATION2).
*/
IR_GRAPH_STATE_NORMALISATION2 = 1U << 2,
IR_GRAPH_CONSTRAINT_NORMALISATION2 = 1U << 2,
/**
* Allows localopts to remove edges to unreachable code.
* Warning: It is only safe to enable this when you are sure that you
* apply all localopts to the fixpunkt. (=in optimize_graph_df)
*/
IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE = 1U << 3,
IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE = 1U << 4,
} ir_graph_constraints_t;
ENUM_BITSET(ir_graph_constraints_t)
/** sets @p constraints on the graph @p irg */
FIRM_API void add_irg_constraints(ir_graph *irg,
ir_graph_constraints_t constraints);
/** clears some graph constraints */
FIRM_API void clear_irg_constraints(ir_graph *irg,
ir_graph_constraints_t constraints);
/** queries whether @p irg is at least as constrained as @p constraints. */
FIRM_API int irg_is_constrained(const ir_graph *irg,
ir_graph_constraints_t constraints);
/**
* graph state. They properties about a graph.
* Graph transformations may destroy these properties and have to explicitely
* state when they did not affect some properties and want to keep them.
*/
typedef enum ir_graph_properties_t {
IR_GRAPH_PROPERTIES_NONE = 0,
/** graph contains no critical edges */
IR_GRAPH_STATE_NO_CRITICAL_EDGES = 1U << 4,
IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES = 1U << 0,
/** graph contains no Bad nodes */
IR_GRAPH_STATE_NO_BADS = 1U << 5,
IR_GRAPH_PROPERTY_NO_BADS = 1U << 1,
/**
* there exists no (obviously) unreachable code in the graph.
* Unreachable in this context is code that you can't reach by following
* execution flow from the start block.
*/
IR_GRAPH_STATE_NO_UNREACHABLE_CODE = 1U << 6,
IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE = 1U << 2,
/** graph contains at most one return */
IR_GRAPH_STATE_ONE_RETURN = 1U << 7,
IR_GRAPH_PROPERTY_ONE_RETURN = 1U << 3,
/** dominance information about the graph is valid */
IR_GRAPH_STATE_CONSISTENT_DOMINANCE = 1U << 8,
IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE = 1U << 4,
/** postdominance information about the graph is valid */
IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE = 1U << 9,
IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE = 1U << 5,
/**
* out edges (=iredges) are enable and there is no dead code that can be
* reached by following them
*/
IR_GRAPH_STATE_CONSISTENT_OUT_EDGES = 1U << 10,
IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES = 1U << 6,
/** outs (irouts) are computed and up to date */
IR_GRAPH_STATE_CONSISTENT_OUTS = 1U << 11,
IR_GRAPH_PROPERTY_CONSISTENT_OUTS = 1U << 7,
/** loopinfo is computed and up to date */
IR_GRAPH_STATE_CONSISTENT_LOOPINFO = 1U << 12,
IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO = 1U << 8,
/** entity usage information is computed and up to date */
IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE = 1U << 13,
IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE = 1U << 9,
/** graph contains as many returns as possible */
IR_GRAPH_STATE_MANY_RETURNS = 1U << 14,
} ir_graph_state_t;
ENUM_BITSET(ir_graph_state_t)
/** Sets some state flags on the graph (this does not clear the other flags) */
FIRM_API void set_irg_state(ir_graph *irg, ir_graph_state_t state);
/** Clears some state flags of the graph */
FIRM_API void clear_irg_state(ir_graph *irg, ir_graph_state_t state);
/** Queries whether a set of graph state flags are activated */
FIRM_API int is_irg_state(const ir_graph *irg, ir_graph_state_t state);
IR_GRAPH_PROPERTY_MANY_RETURNS = 1U << 10,
} ir_graph_properties_t;
ENUM_BITSET(ir_graph_properties_t)
/** sets some state properties on the graph */
FIRM_API void add_irg_properties(ir_graph *irg, ir_graph_properties_t props);
/** clears some graph properties */
FIRM_API void clear_irg_properties(ir_graph *irg, ir_graph_properties_t props);
/** queries whether @p irg has the @p props properties set */
FIRM_API int irg_has_properties(const ir_graph *irg,
ir_graph_properties_t props);
/** Sets a description for local value n. */
FIRM_API void set_irg_loc_description(ir_graph *irg, int n, void *description);
......
......@@ -651,7 +651,7 @@ int construct_cf_backedges(ir_graph *irg)
assert(head_rem == current_loop);
mature_loops(current_loop, irg->obst);
set_irg_loop(irg, current_loop);
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
current_ir_graph = rem;
return max_loop_depth;
......@@ -659,7 +659,7 @@ int construct_cf_backedges(ir_graph *irg)
void assure_loopinfo(ir_graph *irg)
{
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO))
return;
construct_cf_backedges(irg);
}
......@@ -566,7 +566,7 @@ static void insert_Confirm(ir_node *node, void *data)
/*
* Construct Confirm nodes
*/
static ir_graph_state_t do_construct_confirms(ir_graph *irg)
static ir_graph_properties_t do_construct_confirms(ir_graph *irg)
{
env_t env;
FIRM_DBG_REGISTER(dbg, "firm.ana.confirm");
......@@ -596,9 +596,9 @@ static ir_graph_state_t do_construct_confirms(ir_graph *irg)
static optdesc_t opt_confirms = {
"confirms",
IR_GRAPH_STATE_CONSISTENT_OUT_EDGES
| IR_GRAPH_STATE_CONSISTENT_DOMINANCE
| IR_GRAPH_STATE_NO_CRITICAL_EDGES,
IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
| IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
| IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES,
do_construct_confirms
};
......
......@@ -307,7 +307,7 @@ void dom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
/* The root of the dominator tree should be the Start block. */
ir_node *root = get_irg_start_block(irg);
assert(is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE)
assert(irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE)
&& "The dominators of the irg must be consistent");
assert(root && "The start block of the graph is NULL?");
assert(get_dom_info(root)->idom == NULL
......@@ -321,7 +321,7 @@ void postdom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
/* The root of the post dominator tree should be the End block. */
ir_node *root = get_irg_end_block(irg);
assert(is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE)
assert(irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE)
&& "The dominators of the irg must be consistent");
assert(root && "The end block of the graph is NULL?");
assert(get_pdom_info(root)->idom == NULL
......@@ -684,12 +684,12 @@ void compute_doms(ir_graph *irg)
assign_tree_dom_pre_order_max, &tree_pre_order);
}
current_ir_graph = rem;
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
}
void assure_doms(ir_graph *irg)
{
if (! is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE))
if (! irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE))
compute_doms(irg);
}
......@@ -697,7 +697,7 @@ void free_dom(ir_graph *irg)
{
/* Update graph state */
assert(get_irg_phase_state(irg) != phase_building);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
/* With the implementation right now there is nothing to free,
but better call it anyways... */
......@@ -796,12 +796,12 @@ void compute_postdoms(ir_graph *irg)
assign_tree_postdom_pre_order_max, &tree_pre_order);
}
current_ir_graph = rem;
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE);
}
void assure_postdoms(ir_graph *irg)
{
if (! is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE))
if (! irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE))
compute_postdoms(irg);
}
......@@ -809,7 +809,7 @@ void free_postdom(ir_graph *irg)
{
/* Update graph state */
assert(get_irg_phase_state(irg) != phase_building);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE);
/* With the implementation right now there is nothing to free,
but better call it anyways... */
......
......@@ -1023,12 +1023,12 @@ static void analyse_irg_entity_usage(ir_graph *irg)
/* now computed */
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE);
}
void assure_irg_entity_usage_computed(ir_graph *irg)
{
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE))
return;
analyse_irg_entity_usage(irg);
......
......@@ -219,7 +219,7 @@ void irg_out_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
{
assert(node);
ir_graph *irg = get_irn_irg(node);
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS)) {
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS)) {
inc_irg_visited (irg);
irg_out_walk_2(node, pre, post, env);
}
......@@ -454,13 +454,13 @@ void compute_irg_outs(ir_graph *irg)
/* Check how much memory we have used */
assert (end == (irg->outs + n_out_edges));
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
current_ir_graph = rem;
}
void assure_irg_outs(ir_graph *irg)
{
if (! is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS))
if (! irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS))
compute_irg_outs(irg);
}
......
......@@ -776,7 +776,7 @@ int construct_backedges(ir_graph *irg)
assert(head_rem == current_loop);
mature_loops(current_loop, irg->obst);
set_irg_loop(irg, current_loop);
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
assert(get_irg_loop(irg)->kind == k_ir_loop);
current_ir_graph = rem;
return max_loop_depth;
......@@ -818,7 +818,7 @@ void free_loop_information(ir_graph *irg)
*/
irg_walk_graph(irg, loop_reset_node, NULL, NULL);
set_irg_loop(irg, NULL);
clear_irg_state(current_ir_graph, IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
clear_irg_properties(current_ir_graph, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
/* We cannot free the loop nodes, they are on the obstack. */
}
......
......@@ -265,7 +265,7 @@ int be_remove_empty_blocks(ir_graph *irg)
if (blocks_removed) {
/* invalidate analysis info */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
}
return blocks_removed;
}
......
......@@ -418,7 +418,7 @@ void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
free_irg_outs(irg);
free_trouts();
free_loop_information(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
be_invalidate_live_chk(irg);
be_invalidate_dom_front(irg);
......
......@@ -583,7 +583,7 @@ ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn)
/* we should never do the reverse transformations again
(like x+x -> 2*x) */
irg = get_irn_irg(irn);
set_irg_state(irg, IR_GRAPH_STATE_ARCH_DEP);
add_irg_constraints(irg, IR_GRAPH_CONSTRAINT_ARCH_DEP);
left = get_binop_left(irn);
right = get_binop_right(irn);
......
......@@ -1406,7 +1406,7 @@ static void dump_block_graph(FILE *F, ir_graph *irg)
}
if ((flags & ir_dump_flag_loops)
&& is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO))
&& irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO))
dump_loop_nodes_into_graph(F, irg);
}
......@@ -1421,34 +1421,37 @@ static void dump_graph_info(FILE *F, ir_graph *irg)
fprintf(F, "\n");
/* dump graph state */
fprintf(F, "state:");
if (is_irg_state(irg, IR_GRAPH_STATE_ARCH_DEP))
fprintf(F, "constraints:");
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_ARCH_DEP))
fprintf(F, " arch_dep");
if (is_irg_state(irg, IR_GRAPH_STATE_MODEB_LOWERED))
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_MODEB_LOWERED))
fprintf(F, " modeb_lowered");
if (is_irg_state(irg, IR_GRAPH_STATE_NORMALISATION2))
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_NORMALISATION2))
fprintf(F, " normalisation2");
if (is_irg_state(irg, IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE))
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE))
fprintf(F, " optimize_unreachable_code");
if (is_irg_state(irg, IR_GRAPH_STATE_NO_CRITICAL_EDGES))
fprintf(F, "\n");
fprintf(F, "properties:");
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES))
fprintf(F, " no_critical_edges");
if (is_irg_state(irg, IR_GRAPH_STATE_NO_BADS))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_NO_BADS))
fprintf(F, " no_bads");
if (is_irg_state(irg, IR_GRAPH_STATE_NO_UNREACHABLE_CODE))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE))
fprintf(F, " no_unreachable_code");
if (is_irg_state(irg, IR_GRAPH_STATE_ONE_RETURN))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_ONE_RETURN))
fprintf(F, " one_return");
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE))
fprintf(F, " consistent_dominance");
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE))
fprintf(F, " consistent_postdominance");
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUT_EDGES))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES))
fprintf(F, " consistent_out_edges");
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS))
fprintf(F, " consistent_outs");
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO))
fprintf(F, " consistent_loopinfo");
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE))
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE))
fprintf(F, " consistent_entity_usage");
fprintf(F, "\"\n");
}
......@@ -1998,7 +2001,7 @@ void dump_ir_graph_file(FILE *out, ir_graph *irg)
/* dump the out edges in a separate walk */
if ((flags & ir_dump_flag_out_edges)
&& (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS))) {
&& (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS))) {
irg_out_walk(get_irg_start(irg), dump_out_edge, NULL, out);
}
......@@ -2054,7 +2057,7 @@ static void dump_block_to_cfg(ir_node *block, void *env)
/* Dump dominator/postdominator edge */
if (ir_get_dump_flags() & ir_dump_flag_dominance) {
if (is_irg_state(get_irn_irg(block), IR_GRAPH_STATE_CONSISTENT_DOMINANCE) && get_Block_idom(block)) {
if (irg_has_properties(get_irn_irg(block), IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE) && get_Block_idom(block)) {
ir_node *pred = get_Block_idom(block);
fprintf(F, "edge: { sourcename: ");
print_nodeid(F, block);
......@@ -2062,7 +2065,7 @@ static void dump_block_to_cfg(ir_node *block, void *env)
print_nodeid(F, pred);
fprintf(F, " " DOMINATOR_EDGE_ATTR "}\n");
}
if (is_irg_state(get_irn_irg(block), IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE) && get_Block_ipostdom(block)) {
if (irg_has_properties(get_irn_irg(block), IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE) && get_Block_ipostdom(block)) {
ir_node *pred = get_Block_ipostdom(block);
fprintf(F, "edge: { sourcename: ");
print_nodeid(F, block);
......
......@@ -140,7 +140,7 @@ void dump_irnode_to_file(FILE *F, const ir_node *n)
}
/* Loop node. Someone else please tell me what's wrong ... */
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO)) {
if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO)) {
ir_loop *loop = get_irn_loop(n);
if (loop != NULL) {
fprintf(F, " in loop %ld with depth %u\n",
......@@ -156,12 +156,12 @@ void dump_irnode_to_file(FILE *F, const ir_node *n)
fprintf(F, " Label: %lu\n", get_entity_label(entity));
fprintf(F, " block visited: %lu\n", get_Block_block_visited(n));
fprintf(F, " block marked: %u\n", get_Block_mark(n));
if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_DOMINANCE)) {
if (irg_has_properties(get_irn_irg(n), IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE)) {
fprintf(F, " dom depth %d\n", get_Block_dom_depth(n));
fprintf(F, " domtree pre num %u\n", get_Block_dom_tree_pre_num(n));
fprintf(F, " max subtree pre num %u\n", get_Block_dom_max_subtree_pre_num(n));
}
if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE)) {
if (irg_has_properties(get_irn_irg(n), IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE)) {
fprintf(F, " pdom depth %d\n", get_Block_postdom_depth(n));
fprintf(F, " pdomtree pre num %u\n", get_Block_pdom_tree_pre_num(n));
fprintf(F, " max pdomsubtree pre num %u\n", get_Block_pdom_max_subtree_pre_num(n));
......
......@@ -102,8 +102,8 @@ void exchange(ir_node *old, ir_node *nw)
}
/* update irg flags */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS
| IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS
| IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
}
/**
......
......@@ -74,7 +74,7 @@ static inline void do_local_optimize(ir_node *n)
if (get_opt_global_cse())
set_irg_pinned(irg, op_pin_state_floats);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
/* Clean the value_table in irg for the CSE. */
new_identities(irg);
......@@ -199,8 +199,8 @@ int optimize_graph_df(ir_graph *irg)
set_irg_pinned(irg, op_pin_state_floats);
/* enable unreachable code elimination */
assert(!is_irg_state(irg, IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE));
set_irg_state(irg, IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE);
assert(!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE));
add_irg_constraints(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE);
new_identities(irg);
edges_assure(irg);
......@@ -227,12 +227,12 @@ int optimize_graph_df(ir_graph *irg)
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
/* disable unreachable code elimination */
clear_irg_state(irg, IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE);
set_irg_state(irg, IR_GRAPH_STATE_NO_UNREACHABLE_CODE);
clear_irg_constraints(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE);
add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE);
/* invalidate infos */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
edges_deactivate(irg);
/* Finally kill BAD and doublets from the keep alives.
......
......@@ -768,17 +768,32 @@ size_t register_additional_graph_data(size_t size)
return additional_graph_data_size += size;
}
void (set_irg_state)(ir_graph *irg, ir_graph_state_t state)
void add_irg_constraints(ir_graph *irg, ir_graph_constraints_t constraints)
{
set_irg_state_(irg, state);
irg->constraints |= constraints;
}
void (clear_irg_state)(ir_graph *irg, ir_graph_state_t state)
void clear_irg_constraints(ir_graph *irg, ir_graph_constraints_t constraints)
{
clear_irg_state_(irg, state);
irg->constraints &= ~constraints;
}
int (is_irg_state)(const ir_graph *irg, ir_graph_state_t state)
int (irg_is_constrained)(const ir_graph *irg, ir_graph_constraints_t constraints)
{
return is_irg_state_(irg, state);
return irg_is_constrained_(irg, constraints);
}
void (add_irg_properties)(ir_graph *irg, ir_graph_properties_t props)
{
add_irg_properties_(irg, props);
}
void (clear_irg_properties)(ir_graph *irg, ir_graph_properties_t props)
{
clear_irg_properties_(irg, props);
}
int (irg_has_properties)(const ir_graph *irg, ir_graph_properties_t props)
{
return irg_has_properties_(irg, props);
}
......@@ -336,19 +336,28 @@ static inline unsigned get_irg_fp_model_(const ir_graph *irg)
return irg->fp_model;
}
static inline void set_irg_state_(ir_graph *irg, ir_graph_state_t state)
static inline int irg_is_constrained_(const ir_graph *irg,
ir_graph_constraints_t constraints)
{
irg->state = (ir_graph_state_t) (irg->state | state);
return (irg->constraints & constraints) == constraints;
}
static inline void clear_irg_state_(ir_graph *irg, ir_graph_state_t state)
static inline void add_irg_properties_(ir_graph *irg,
ir_graph_properties_t props)
{
irg->state = (ir_graph_state_t) (irg->state & ~state);
irg->properties |= props;
}
static inline int is_irg_state_(const ir_graph *irg, ir_graph_state_t state)
static inline void clear_irg_properties_(ir_graph *irg,
ir_graph_properties_t props)
{
return (irg->state & state) == state;
irg->properties &= ~props;
}
static inline int irg_has_properties_(const ir_graph *irg,
ir_graph_properties_t props)
{
return (irg->properties & props) == props;
}
/**
......@@ -465,8 +474,9 @@ static inline void set_irg_anchor(ir_graph *irg, int idx, ir_node *irn)
#define get_irg_estimated_node_cnt(irg) get_irg_estimated_node_cnt_(irg)
#define get_irg_fp_model(irg) get_irg_fp_model_(irg)
#define get_idx_irn(irg, idx) get_idx_irn_(irg, idx)
#define set_irg_state(irg, state) set_irg_state_(irg, state)
#define clear_irg_state(irg, state) clear_irg_state_(irg, state)
#define is_irg_state(irg, state) is_irg_state_(irg, state)
#define irg_is_constrained(irg, constraints) irg_is_constrained_(irg, constraints)
#define add_irg_properties(irg, props) add_irg_properties_(irg, props)
#define clear_irg_properties(irg, props) clear_irg_properties_(irg, props)
#define irg_has_properties(irg, props) irg_has_properties_(irg, props)
#endif
......@@ -240,7 +240,7 @@ void set_irn_in(ir_node *node, int arity, ir_node **in)
memcpy((*pOld_in) + 1, in, sizeof(ir_node *) * arity);
/* update irg flags */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS | IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
}
ir_node *(get_irn_n)(const ir_node *node, int n)
......@@ -265,7 +265,7 @@ void set_irn_n(ir_node *node, int n, ir_node *in)
node->in[n + 1] = in;
/* update irg flags */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS | IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
}
int add_irn_n(ir_node *node, ir_node *in)
......@@ -661,7 +661,7 @@ void set_End_keepalives(ir_node *end, int n, ir_node *in[])
}
/* update irg flags */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
}
void remove_End_keepalive(ir_node *end, ir_node *irn)
......@@ -698,7 +698,7 @@ found:
ARR_RESIZE(ir_node *, end->in, (n - 1) + 1 + END_KEEPALIVE_OFFSET);
/* update irg flags */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
}
void remove_End_Bads_and_doublets(ir_node *end)
......@@ -740,7 +740,7 @@ void remove_End_Bads_and_doublets(ir_node *end)
pset_new_destroy(&keeps);
if (changed) {
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
}
}
......
......@@ -634,7 +634,7 @@ static ir_tarval *compute_cmp_ext(const ir_node *cmp)
static ir_tarval *computed_value_Cmp(const ir_node *cmp)