From 4402ff71e8a876aa7ef50de56597b0eb7110583d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Fri, 23 Jun 2006 10:37:32 +0000 Subject: [PATCH 1/1] added function to retrieve number of reachable nodes in an irg --- ir/be/beutil.c | 16 ++++++++++++++++ ir/be/beutil.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/ir/be/beutil.c b/ir/be/beutil.c index 844fcf27f..7e0e7a3d2 100644 --- a/ir/be/beutil.c +++ b/ir/be/beutil.c @@ -1,3 +1,8 @@ +/** + * Contains some useful function for the backend. + * @author Sebastian Hack + * @cvsid $Id$ + */ #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -207,6 +212,17 @@ void be_collect_phis(ir_graph *irg) irg_walk_graph(irg, collect_phis, NULL, NULL); } +unsigned count_num_reachable_nodes(ir_node *irn, void *env) { + int *num = env; + (*num)++; +} + +unsigned get_num_reachable_nodes(ir_graph *irg) { + int num = 0; + irg_walk_graph(irg, count_num_reachable_nodes, NULL, &num); + return num; +} + /* FIXME: not used. can be deleted? */ ir_node *dom_up_search(pset *accept, ir_node *start_point_exclusive) { ir_node *irn, *idom; diff --git a/ir/be/beutil.h b/ir/be/beutil.h index ae193f5bb..cc6e60b62 100644 --- a/ir/be/beutil.h +++ b/ir/be/beutil.h @@ -117,6 +117,13 @@ void dump_ir_extblock_graph_sched(ir_graph *irg, const char *suffix); */ void be_dump(ir_graph *irg, const char *suffix, void (*dumper)(ir_graph *, const char *)); +/** + * Returns the number of reachable nodes in an irg. + * @param irg The irg. + * @return The number of reachable nodes. + */ +unsigned get_num_reachable_nodes(ir_graph *irg); + /** * Search for an irn in @p accept. * The search is started at @p start_point_exclusive and continues upwards the dom-tree -- 2.20.1