From 2e329cd97a36f1a1b4f02c52fabb36e98cb67ee0 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 14 Nov 2005 10:13:23 +0000 Subject: [PATCH] estimated node count added [r6912] --- ir/ir/irgraph.c | 6 ++++++ ir/ir/irgraph.h | 5 +++++ ir/ir/irgraph_t.h | 14 +++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index 51fbe4150..e71066c2f 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -235,6 +235,7 @@ new_r_ir_graph (entity *ent, int n_loc) add_immBlock_pred (first_block, projX); res->method_execution_frequency = -1; + res->estimated_node_count = 0; return res; } @@ -809,6 +810,11 @@ void *get_irg_loc_description(ir_graph *irg, int n) return irg->loc_descriptions ? irg->loc_descriptions[n] : NULL; } +/* Returns a estimated node count of the irg. */ +unsigned (get_irg_estimated_node_cnt)(const ir_graph *irg) { + return _get_irg_estimated_node_cnt(irg); +} + /* register additional space in an IR graph */ size_t register_additional_graph_data(size_t size) { diff --git a/ir/ir/irgraph.h b/ir/ir/irgraph.h index 60f58b725..742ed6c04 100644 --- a/ir/ir/irgraph.h +++ b/ir/ir/irgraph.h @@ -459,6 +459,11 @@ void set_irg_loc_description(ir_graph *irg, int n, void *description); /** get the description for local value n */ void *get_irg_loc_description(ir_graph *irg, int n); +/** Returns a estimated node count of the irg. This count is updated + * after every irg_walk_graph(). + */ +unsigned get_irg_estimated_node_cnt(const ir_graph *irg); + /** * Access custom graph data. * The data must have been registered with diff --git a/ir/ir/irgraph_t.h b/ir/ir/irgraph_t.h index 965f05caf..3f7aa493a 100644 --- a/ir/ir/irgraph_t.h +++ b/ir/ir/irgraph_t.h @@ -135,14 +135,16 @@ struct ir_graph { every time someone walks through the graph */ unsigned long block_visited; /**< same as visited, for a complete block */ + unsigned estimated_node_count; /**< estimated number of nodes in this graph, + updated after every walk */ +#if FIRM_EDGES_INPLACE + irg_edge_info_t edge_info; /**< edge info for automatic outs */ +#endif #ifdef DEBUG_libfirm int graph_nr; /**< a unique graph number for each graph to make output readable. */ #endif -#if FIRM_EDGES_INPLACE - irg_edge_info_t edge_info; /**< edge info for automatic outs */ -#endif }; /** @@ -498,6 +500,11 @@ _inc_irg_block_visited(ir_graph *irg) { ++irg->block_visited; } +static INLINE unsigned +_get_irg_estimated_node_cnt(const ir_graph *irg) { + return irg->estimated_node_count; +} + #define get_interprocedural_view() _get_interprocedural_view() #define is_ir_graph(thing) _is_ir_graph(thing) #define get_irg_start_block(irg) _get_irg_start_block(irg) @@ -555,5 +562,6 @@ _inc_irg_block_visited(ir_graph *irg) { #define get_irg_block_visited(irg) _get_irg_block_visited(irg) #define set_irg_block_visited(irg, v) _set_irg_block_visited(irg, v) #define inc_irg_block_visited(irg) _inc_irg_block_visited(irg) +#define get_irg_estimated_node_cnt(irg) _get_irg_estimated_node_cnt(irg) # endif /* _IRGRAPH_T_H_ */ -- 2.20.1