2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Compute statistics about firm library.
23 * @author Goetz Lindenmaier
28 #include "statistics.h"
29 #include "irgraph_t.h"
34 /***********************************************************************/
35 /* Statistics about allocated datastructures: counts. */
37 static void count_nodes(ir_node *n, void *env) {
38 int * counter_ptr = (int *)env;
44 /** Prints number of irgraphs, number of nodes in them and
46 void print_graph_counts(int verbosity) {
47 int i, counter, total = 0;
48 ir_graph *old = current_ir_graph;
50 #ifdef INTERPROCEDURAL_VIEW
51 int view = get_interprocedural_view();
52 set_interprocedural_view(0);
55 for (i = 0; i < get_irp_n_irgs(); i++) {
57 irg_walk_graph(get_irp_irg(i), count_nodes, NULL, &counter);
59 printf(" +%4d nodes in graph %s.\n", counter, get_entity_name(get_irg_entity(get_irp_irg(i))));
62 printf(" +++ There are %d graphs with total %d nodes.\n", get_irp_n_irgs(), total);
64 current_ir_graph = old;
65 #ifdef INTERPROCEDURAL_VIEW
66 set_interprocedural_view(view);
70 /** Prints number of types, number of entities and totals.
72 void print_type_counts(int verbosity) {
73 int i, counter, total = 0;
74 for (i = 0; i < get_irp_n_types(); i++) {
75 ir_type *tp = get_irp_type(i);
77 if (is_Class_type(tp)) counter = get_class_n_members(tp);
78 if (is_Struct_type(tp)) counter = get_struct_n_members(tp);
79 if (is_Union_type(tp)) counter = get_union_n_members(tp);
82 printf(" +%3d entities in %s type %s.\n", counter, get_type_tpop_name(tp), get_type_name(tp));
86 printf(" +++ There are %d types with total %d entities.\n", get_irp_n_types(), total);
87 printf(" +++ Global type has %d entities\n",
88 get_class_n_members(get_glob_type()));
92 /** Prints number of tarvals.
94 void print_tarval_counts(int verbosity) {
96 printf("tarval count not implemented.\n\n");
99 /** Prints number of idents.
101 void print_ident_counts(int verbosity) {
103 printf("ident count not implemented.\n\n");
107 void print_all_counts(int verbosity) {
108 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
109 print_graph_counts(verbosity);
110 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
111 print_type_counts(verbosity);
112 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
114 print_tarval_counts(verbosity);
115 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
116 print_ident_counts(verbosity);
117 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");