Commit 3be74f06 authored by Andreas Zwinkau's avatar Andreas Zwinkau
Browse files

Remove dom_state and pdom_state attributes

parent dc3b229f
......@@ -326,24 +326,6 @@ typedef enum {
FIRM_API irg_extblk_info_state get_irg_extblk_state(const ir_graph *irg);
FIRM_API void set_irg_extblk_inconsistent(ir_graph *irg);
/** state: dom_state
* Signals the state of the dominator / post dominator information.
*/
typedef enum {
dom_none, /**< dominator are not computed, no memory is allocated */
dom_consistent, /**< dominator information is computed and correct */
dom_inconsistent /**< dominator information is computed but the graph has been changed since */
} irg_dom_state;
/** returns the dominator state of an IR graph. */
FIRM_API irg_dom_state get_irg_dom_state(const ir_graph *irg);
/** returns the post dominator state of an IR graph. */
FIRM_API irg_dom_state get_irg_postdom_state(const ir_graph *irg);
/** sets the dominator and post dominator state of an IR graph to inconsistent. */
FIRM_API void set_irg_doms_inconsistent(ir_graph *irg);
/** state: loopinfo_state
* Loop information describes the loops within the control and
* data flow of the procedure.
......
......@@ -384,7 +384,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(irg->dom_state == dom_consistent
assert(is_irg_state(irg, IR_GRAPH_STATE_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
......@@ -396,10 +396,10 @@ void dom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
void postdom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
irg_walk_func *post, void *env)
{
/* The root of the dominator tree should be the End block. */
/* The root of the post dominator tree should be the End block. */
ir_node *root = get_irg_end_block(irg);
assert(irg->pdom_state == dom_consistent
assert(is_irg_state(irg, IR_GRAPH_STATE_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
......@@ -640,9 +640,7 @@ static void count_and_init_blocks_dom(ir_node *bl, void *env)
set_Block_dom_depth(bl, -1);
}
/* Computes the dominator trees. Sets a flag in irg to "dom_consistent".
If the control flow of the graph is changed this flag must be set to
"dom_inconsistent". */
/* Computes the dominator trees. */
void compute_doms(ir_graph *irg)
{
ir_graph *rem = current_ir_graph;
......@@ -653,7 +651,6 @@ void compute_doms(ir_graph *irg)
/* Update graph state */
assert(get_irg_phase_state(irg) != phase_building);
irg->dom_state = dom_consistent;
/* Count the number of blocks in the graph. */
n_blocks = 0;
......@@ -766,15 +763,16 @@ void compute_doms(ir_graph *irg)
/* Do a walk over the tree and assign the tree pre orders. */
{
unsigned tree_pre_order = 0;
dom_tree_walk_irg(irg, assign_tree_dom_pre_order,
dom_tree_walk(get_irg_start_block(irg), assign_tree_dom_pre_order,
assign_tree_dom_pre_order_max, &tree_pre_order);
}
current_ir_graph = rem;
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
void assure_doms(ir_graph *irg)
{
if (get_irg_dom_state(irg) != dom_consistent)
if (! is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE))
compute_doms(irg);
}
......@@ -782,15 +780,13 @@ void free_dom(ir_graph *irg)
{
/* Update graph state */
assert(get_irg_phase_state(irg) != phase_building);
irg->dom_state = dom_none;
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
/* With the implementation right now there is nothing to free,
but better call it anyways... */
}
/* Computes the post dominator trees. Sets a flag in irg to "dom_consistent".
If the control flow of the graph is changed this flag must be set to
"dom_inconsistent". */
/* Computes the post dominator trees. */
void compute_postdoms(ir_graph *irg)
{
ir_graph *rem = current_ir_graph;
......@@ -801,7 +797,6 @@ void compute_postdoms(ir_graph *irg)
/* Update graph state */
assert(get_irg_phase_state(irg) != phase_building);
irg->pdom_state = dom_consistent;
/* Count the number of blocks in the graph. */
n_blocks = 0;
......@@ -881,15 +876,16 @@ void compute_postdoms(ir_graph *irg)
/* Do a walk over the tree and assign the tree pre orders. */
{
unsigned tree_pre_order = 0;
postdom_tree_walk_irg(irg, assign_tree_postdom_pre_order,
postdom_tree_walk(get_irg_end_block(irg), assign_tree_postdom_pre_order,
assign_tree_postdom_pre_order_max, &tree_pre_order);
}
current_ir_graph = rem;
set_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE);
}
void assure_postdoms(ir_graph *irg)
{
if (get_irg_postdom_state(irg) != dom_consistent)
if (! is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE))
compute_postdoms(irg);
}
......@@ -897,7 +893,7 @@ void free_postdom(ir_graph *irg)
{
/* Update graph state */
assert(get_irg_phase_state(irg) != phase_building);
irg->pdom_state = dom_none;
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE);
/* With the implementation right now there is nothing to free,
but better call it anyways... */
......
......@@ -263,7 +263,7 @@ int be_remove_empty_blocks(ir_graph *irg)
if (blocks_removed) {
/* invalidate analysis info */
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
set_irg_extblk_inconsistent(irg);
}
return blocks_removed;
......
......@@ -422,7 +422,7 @@ void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
free_irg_outs(irg);
free_trouts();
free_loop_information(irg);
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
be_liveness_invalidate(be_get_irg_liveness(irg));
/* Hack for now, something is buggy with invalidate liveness... */
......
......@@ -2374,7 +2374,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 (get_irg_dom_state(current_ir_graph) == dom_consistent && get_Block_idom(block)) {
if (is_irg_state(get_irn_irg(block), IR_GRAPH_STATE_CONSISTENT_DOMINANCE) && get_Block_idom(block)) {
ir_node *pred = get_Block_idom(block);
fprintf(F, "edge: { sourcename: \"");
PRINT_NODEID(block);
......@@ -2382,7 +2382,7 @@ static void dump_block_to_cfg(ir_node *block, void *env)
PRINT_NODEID(pred);
fprintf(F, "\" " DOMINATOR_EDGE_ATTR "}\n");
}
if (get_irg_postdom_state(current_ir_graph) == dom_consistent && get_Block_ipostdom(block)) {
if (is_irg_state(get_irn_irg(block), IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE) && get_Block_ipostdom(block)) {
ir_node *pred = get_Block_ipostdom(block);
fprintf(F, "edge: { sourcename: \"");
PRINT_NODEID(block);
......
......@@ -138,12 +138,12 @@ void dump_irnode_to_file(FILE *F, ir_node *n)
fprintf(F, " Label: %lu\n", get_entity_label(get_Block_entity(n)));
fprintf(F, " block visited: %lu\n", get_Block_block_visited(n));
fprintf(F, " block marked: %u\n", get_Block_mark(n));
if (get_irg_dom_state(get_irn_irg(n)) == dom_consistent) {
if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_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 (get_irg_postdom_state(get_irn_irg(n)) == dom_consistent) {
if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_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));
......
......@@ -78,7 +78,7 @@ static inline void do_local_optimize(ir_node *n)
if (get_opt_global_cse())
set_irg_pinned(irg, op_pin_state_floats);
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
/* Clean the value_table in irg for the CSE. */
new_identities(irg);
......@@ -206,7 +206,7 @@ int optimize_graph_df(ir_graph *irg)
clear_irg_state(irg, IR_GRAPH_STATE_NO_UNREACHABLE_BLOCKS);
/* invalidate info */
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
......@@ -230,7 +230,7 @@ int optimize_graph_df(ir_graph *irg)
compute_doms(irg);
irg_block_walk_graph(irg, NULL, find_unreachable_blocks, waitq);
}
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
del_pdeq(waitq);
......
......@@ -186,8 +186,6 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
res->additional_properties = mtp_property_inherited; /* inherited from type */
res->irg_pinned_state = op_pin_state_pinned;
res->dom_state = dom_none;
res->pdom_state = dom_none;
res->typeinfo_state = ir_typeinfo_none;
set_irp_typeinfo_inconsistent(); /* there is a new graph with typeinfo_none. */
res->callee_info_state = irg_callee_info_none;
......@@ -661,21 +659,6 @@ void (set_irg_extblk_inconsistent)(ir_graph *irg)
_set_irg_extblk_inconsistent(irg);
}
irg_dom_state (get_irg_dom_state)(const ir_graph *irg)
{
return _get_irg_dom_state(irg);
}
irg_dom_state (get_irg_postdom_state)(const ir_graph *irg)
{
return _get_irg_postdom_state(irg);
}
void (set_irg_doms_inconsistent)(ir_graph *irg)
{
_set_irg_doms_inconsistent(irg);
}
irg_loopinfo_state (get_irg_loopinfo_state)(const ir_graph *irg)
{
return _get_irg_loopinfo_state(irg);
......
......@@ -251,25 +251,6 @@ static inline void _set_irg_extblk_inconsistent(ir_graph *irg)
irg->extblk_state = ir_extblk_info_invalid;
}
static inline irg_dom_state _get_irg_dom_state(const ir_graph *irg)
{
return irg->dom_state;
}
static inline irg_dom_state _get_irg_postdom_state(const ir_graph *irg)
{
return irg->pdom_state;
}
static inline void _set_irg_doms_inconsistent(ir_graph *irg)
{
if (irg->dom_state != dom_none)
irg->dom_state = dom_inconsistent;
if (irg->pdom_state != dom_none)
irg->pdom_state = dom_inconsistent;
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
static inline irg_loopinfo_state _get_irg_loopinfo_state(const ir_graph *irg)
{
return irg->loopinfo_state;
......@@ -524,9 +505,6 @@ static inline ir_phase *irg_get_phase(const ir_graph *irg, ir_phase_id id)
#define get_irg_pinned(irg) _get_irg_pinned(irg)
#define get_irg_extblk_state(irg) _get_irg_extblk_state(irg)
#define set_irg_extblk_inconsistent(irg) _set_irg_extblk_inconsistent(irg)
#define get_irg_dom_state(irg) _get_irg_dom_state(irg)
#define get_irg_postdom_state(irg) _get_irg_postdom_state(irg)
#define set_irg_doms_inconsistent(irg) _set_irg_doms_inconsistent(irg)
#define get_irg_loopinfo_state(irg) _get_irg_loopinfo_state(irg)
#define set_irg_loopinfo_state(irg, s) _set_irg_loopinfo_state(irg, s)
#define set_irg_loopinfo_inconsistent(irg) _set_irg_loopinfo_inconsistent(irg)
......
......@@ -6732,7 +6732,7 @@ ir_node *optimize_in_place(ir_node *n)
/* FIXME: Maybe we could also test whether optimizing the node can
change the control graph. */
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
return optimize_in_place_2(n);
} /* optimize_in_place */
......
......@@ -479,8 +479,6 @@ struct ir_graph {
ir_graph_state_t state;
irg_phase_state phase_state; /**< Compiler phase. */
op_pin_state irg_pinned_state; /**< Flag for status of nodes. */
irg_dom_state dom_state; /**< Dominator state information. */
irg_dom_state pdom_state; /**< Post Dominator state information. */
ir_typeinfo_state typeinfo_state; /**< Validity of type information. */
irg_callee_info_state callee_info_state; /**< Validity of callee information. */
irg_loopinfo_state loopinfo_state; /**< State of loop information. */
......
......@@ -2010,7 +2010,7 @@ int irg_verify(ir_graph *irg, unsigned flags)
irg_walk_anchors(
irg,
pinned && get_irg_dom_state(irg) == dom_consistent
pinned && is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE)
? verify_wrap_ssa : verify_wrap,
NULL,
&res
......@@ -2075,7 +2075,7 @@ int irn_verify_irg_dump(const ir_node *n, ir_graph *irg,
firm_verify_failure_msg = NULL;
do_node_verification(FIRM_VERIFICATION_ERROR_ONLY);
res = irn_verify_irg(n, irg);
if (res && get_irg_dom_state(irg) == dom_consistent &&
if (res && is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE) &&
get_irg_pinned(irg) == op_pin_state_pinned)
res = check_dominance_for_node(n);
do_node_verification(old);
......
......@@ -139,6 +139,7 @@ int remove_bads(ir_graph *irg)
if (changed) {
edges_deactivate(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
return changed;
......
......@@ -2580,7 +2580,7 @@ static void lower_irg(ir_graph *irg)
if (env->flags & CF_CHANGED) {
/* control flow changed, dominance info is invalid */
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
set_irg_extblk_inconsistent(irg);
}
edges_deactivate(irg);
......
......@@ -142,7 +142,7 @@ size_t lower_intrinsics(i_record *list, size_t length, int part_block_used)
set_irg_callee_info_state(irg, irg_callee_info_inconsistent);
/* Exception control flow might have changed / new block might have added. */
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
set_irg_extblk_inconsistent(irg);
/* Calls might be removed/added. */
......
......@@ -459,7 +459,7 @@ void ir_lower_mode_b(ir_graph *irg, const lower_mode_b_config_t *nconfig)
if (changed) {
/* lowering might create new blocks, so be sure to handle this */
set_irg_extblk_inconsistent(irg);
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
edges_deactivate(irg);
}
}
......@@ -137,7 +137,7 @@ void lower_mux(ir_graph *irg, lower_mux_callback *cb_func)
/* Cleanup, verify the graph. */
ir_free_resources(irg, resources);
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
set_irg_extblk_inconsistent(irg);
}
DEL_ARR_F(env.muxes);
......
......@@ -422,7 +422,7 @@ void lower_switch(ir_graph *irg, unsigned small_switch, unsigned spare_size,
if (env.changed) {
/* control flow changed */
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
set_irg_extblk_inconsistent(irg);
}
}
......@@ -838,7 +838,7 @@ static void cfgopt_ignoring_phis(ir_graph *irg)
irg_block_walk_graph(irg, NULL, optimize_ifs, &env);
if (env.changed) {
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
/* clear block info, because it must be recomputed */
irg_block_walk_graph(irg, clear_block_info, NULL, block_info);
/* Removing blocks and Conds might enable more optimizations */
......@@ -905,7 +905,7 @@ static ir_graph_state_t do_cfopt(ir_graph *irg)
if (!changed)
break;
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
set_irg_extblk_inconsistent(irg);
set_irg_entity_usage_state(irg, ir_entity_usage_not_computed);
}
......
......@@ -106,7 +106,7 @@ void remove_critical_cf_edges_ex(ir_graph *irg, int ignore_exception_edges)
if (env.changed) {
/* control flow changed */
set_irg_extblk_inconsistent(irg);
set_irg_doms_inconsistent(irg);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
}
......
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