3 * File name: ir/ir/firmstat.c
4 * Purpose: Statistics for Firm.
8 * Copyright: (c) 2004 Universität Karlsruhe
9 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
16 #ifdef FIRM_STATISTICS
22 #include "firmstat_t.h"
27 * names of the optimizations
29 static const char *opt_names[] = {
30 "straightening optimization",
32 "algebraic simplification",
34 "Write-After-Write optimization",
35 "Write-After-Read optimization",
36 "Read-After-Write optimization",
37 "Read-After-Read optimization",
40 "Constant evaluation",
42 "Architecture dependant optimization",
47 * need this to be static:
48 * Special pseudo Opcodes that we need to count some interesting cases
52 * The Phi0, a node that is created during SSA construction
54 static ir_op _op_Phi0;
56 /** The PhiM, just to count memorty Phi's. */
57 static ir_op _op_PhiM;
59 /** The Mul by Const node. */
60 static ir_op _op_MulC;
62 /** The Div by Const node. */
63 static ir_op _op_DivC;
65 /** The Div by Const node. */
66 static ir_op _op_ModC;
68 /** The Div by Const node. */
69 static ir_op _op_DivModC;
71 /* ---------------------------------------------------------------------------------- */
73 #define STAT_ENTER ++status->recursive
74 #define STAT_LEAVE --status->recursive
75 #define STAT_ENTER_SINGLE do { if (status->recursive > 0) return; ++status->recursive; } while (0)
80 static stat_info_t _status, *status = &_status;
83 * compare two elements of the opcode hash
85 static int opcode_cmp(const void *elt, const void *key)
87 const node_entry_t *e1 = elt;
88 const node_entry_t *e2 = key;
90 return e1->op->code - e2->op->code;
94 * compare two elements of the graph hash
96 static int graph_cmp(const void *elt, const void *key)
98 const graph_entry_t *e1 = elt;
99 const graph_entry_t *e2 = key;
101 return e1->irg != e2->irg;
105 * compare two elements of the optimization hash
107 static int opt_cmp(const void *elt, const void *key)
109 const opt_entry_t *e1 = elt;
110 const opt_entry_t *e2 = key;
112 return e1->op->code != e2->op->code;
116 * compare two elements of the block hash
118 static int block_cmp(const void *elt, const void *key)
120 const block_entry_t *e1 = elt;
121 const block_entry_t *e2 = key;
123 return e1->block_nr != e2->block_nr;
127 * compare two elements of the ir_op hash
129 static int opcode_cmp_2(const void *elt, const void *key)
131 const ir_op *e1 = elt;
132 const ir_op *e2 = key;
134 return e1->code != e2->code;
138 * clears all counter in a node_entry_t
140 static void opcode_clear_entry(node_entry_t *elem)
142 cnt_clr(&elem->cnt_alive);
143 cnt_clr(&elem->new_node);
144 cnt_clr(&elem->into_Id);
148 * Returns the associates node_entry_t for an ir_op
150 static node_entry_t *opcode_get_entry(const ir_op *op, pset *set)
157 elem = pset_find(set, &key, op->code);
161 elem = obstack_alloc(&status->cnts, sizeof(*elem));
164 opcode_clear_entry(elem);
168 return pset_insert(set, elem, op->code);
172 * Returns the associates ir_op for an opcode
174 static ir_op *opcode_find_entry(opcode code, pset *set)
179 return pset_find(set, &key, code);
183 * calculates a hash value for an irg
184 * Addresses are typically aligned at 32bit, so we ignore the lowest bits
186 static INLINE unsigned irg_hash(const ir_graph *irg)
188 return (unsigned)irg >> 3;
192 * clears all counter in a graph_entry_t
194 static void graph_clear_entry(graph_entry_t *elem)
196 cnt_clr(&elem->cnt_walked);
197 cnt_clr(&elem->cnt_walked_blocks);
198 cnt_clr(&elem->cnt_was_inlined);
199 cnt_clr(&elem->cnt_got_inlined);
200 cnt_clr(&elem->cnt_strength_red);
201 cnt_clr(&elem->cnt_edges);
205 * Returns the acssociates graph_entry_t for an irg
207 static graph_entry_t *graph_get_entry(ir_graph *irg, pset *set)
215 elem = pset_find(set, &key, irg_hash(irg));
219 elem = obstack_alloc(&status->cnts, sizeof(*elem));
222 graph_clear_entry(elem);
224 /* new hash table for opcodes here */
225 elem->opcode_hash = new_pset(opcode_cmp, 5);
226 elem->block_hash = new_pset(block_cmp, 5);
229 for (i = 0; i < sizeof(elem->opt_hash)/sizeof(elem->opt_hash[0]); ++i)
230 elem->opt_hash[i] = new_pset(opt_cmp, 4);
232 return pset_insert(set, elem, irg_hash(irg));
236 * clears all counter in an opt_entry_t
238 static void opt_clear_entry(opt_entry_t *elem)
240 cnt_clr(&elem->count);
244 * Returns the associates opt_entry_t for an ir_op
246 static opt_entry_t *opt_get_entry(const ir_op *op, pset *set)
253 elem = pset_find(set, &key, op->code);
257 elem = obstack_alloc(&status->cnts, sizeof(*elem));
259 /* clear new counter */
260 opt_clear_entry(elem);
264 return pset_insert(set, elem, op->code);
268 * clears all counter in a block_entry_t
270 static void block_clear_entry(block_entry_t *elem)
272 cnt_clr(&elem->cnt_nodes);
273 cnt_clr(&elem->cnt_edges);
274 cnt_clr(&elem->cnt_in_edges);
275 cnt_clr(&elem->cnt_out_edges);
279 * Returns the associates block_entry_t for an block
281 static block_entry_t *block_get_entry(long block_nr, pset *set)
286 key.block_nr = block_nr;
288 elem = pset_find(set, &key, block_nr);
292 elem = obstack_alloc(&status->cnts, sizeof(*elem));
294 /* clear new counter */
295 block_clear_entry(elem);
297 elem->block_nr = block_nr;
299 return pset_insert(set, elem, block_nr);
304 * Returns the ir_op for an IR-node,
305 * handles special cases and return pseudo op codes
307 static ir_op *stat_get_irn_op(ir_node *node)
309 ir_op *op = get_irn_op(node);
311 if (op->code == iro_Phi && get_irn_arity(node) == 0) {
312 /* special case, a Phi0 node, count on extra counter */
313 op = status->op_Phi0;
315 else if (op->code == iro_Phi && get_irn_mode(node) == mode_M) {
316 /* special case, a Memory Phi node, count on extra counter */
317 op = status->op_PhiM;
319 else if (op->code == iro_Mul &&
320 (get_irn_op(get_Mul_left(node)) == op_Const || get_irn_op(get_Mul_right(node)) == op_Const)) {
321 /* special case, a Multiply by a const, count on extra counter */
322 op = status->op_MulC ? status->op_MulC : op_Mul;
324 else if (op->code == iro_Div && get_irn_op(get_Div_right(node)) == op_Const) {
325 /* special case, a division by a const, count on extra counter */
326 op = status->op_DivC ? status->op_DivC : op_Div;
328 else if (op->code == iro_Mod && get_irn_op(get_Mod_right(node)) == op_Const) {
329 /* special case, a module by a const, count on extra counter */
330 op = status->op_ModC ? status->op_ModC : op_Mod;
332 else if (op->code == iro_DivMod && get_irn_op(get_DivMod_right(node)) == op_Const) {
333 /* special case, a division/modulo by a const, count on extra counter */
334 op = status->op_DivModC ? status->op_DivModC : op_DivMod;
341 * update the block counter
343 static void count_block_info(ir_node *node, graph_entry_t *graph)
345 ir_op *op = get_irn_op(node);
347 block_entry_t *b_entry;
350 /* check for block */
351 if (op == op_Block) {
352 arity = get_irn_arity(node);
353 b_entry = block_get_entry(get_irn_node_nr(node), graph->block_hash);
355 /* count all incoming edges */
356 for (i = 0; i < arity; ++i) {
357 ir_node *pred = get_irn_n(node, i);
358 ir_node *other_block = get_nodes_block(pred);
359 block_entry_t *b_entry_other = block_get_entry(get_irn_node_nr(other_block), graph->block_hash);
361 cnt_inc(&b_entry->cnt_in_edges); /* an edge coming from another block */
362 cnt_inc(&b_entry_other->cnt_out_edges);
366 else if (op == op_Call) {
370 block = get_nodes_block(node);
371 b_entry = block_get_entry(get_irn_node_nr(block), graph->block_hash);
373 /* we have a new nodes */
374 cnt_inc(&b_entry->cnt_nodes);
376 arity = get_irn_arity(node);
378 for (i = 0; i < arity; ++i) {
379 ir_node *pred = get_irn_n(node, i);
380 ir_node *other_block;
382 if (get_irn_op(pred) == op_Block)
385 other_block = get_nodes_block(pred);
387 if (other_block == block)
388 cnt_inc(&b_entry->cnt_edges); /* a in block edge */
390 block_entry_t *b_entry_other = block_get_entry(get_irn_node_nr(other_block), graph->block_hash);
392 cnt_inc(&b_entry->cnt_in_edges); /* an edge coming from another block */
393 cnt_inc(&b_entry_other->cnt_out_edges);
399 * walker for reachable nodes count
401 static void count_nodes(ir_node *node, void *env)
403 graph_entry_t *graph = env;
406 ir_op *op = stat_get_irn_op(node);
407 int arity = get_irn_arity(node);
409 entry = opcode_get_entry(op, graph->opcode_hash);
411 cnt_inc(&entry->cnt_alive);
412 cnt_add_i(&graph->cnt_edges, arity);
414 /* count block edges */
415 count_block_info(node, graph);
419 * count all alive nodes and edges in a graph
421 static void count_nodes_in_graph(graph_entry_t *global, graph_entry_t *graph)
425 /* clear first the alive counter in the graph */
426 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
427 cnt_clr(&entry->cnt_alive);
430 /* count the nodes in the graph */
431 irg_walk_graph(graph->irg, count_nodes, NULL, graph);
433 /* assume we walk every graph only ONCE, we could sum here the global count */
434 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
435 node_entry_t *g_entry = opcode_get_entry(entry->op, global->opcode_hash);
437 /* update the node counter */
438 cnt_add(&g_entry->cnt_alive, &entry->cnt_alive);
441 /* update the edge counter */
442 cnt_add(&global->cnt_edges, &graph->cnt_edges);
448 static void stat_register_dumper(dumper_t *dumper)
450 dumper->next = status->dumper;
451 status->dumper = dumper;
457 static void dump_graph(graph_entry_t *entry)
461 for (dumper = status->dumper; dumper; dumper = dumper->next) {
462 if (dumper->dump_graph)
463 dumper->dump_graph(dumper, entry);
468 * initialise the dumper
470 static void dump_init(const char *name)
474 for (dumper = status->dumper; dumper; dumper = dumper->next) {
476 dumper->init(dumper, name);
483 static void dump_finish(void)
487 for (dumper = status->dumper; dumper; dumper = dumper->next) {
489 dumper->finish(dumper);
493 /* ---------------------------------------------------------------------- */
496 * dumps a opcode hash into human readable form
498 static void simple_dump_opcode_hash(dumper_t *dmp, pset *set)
502 counter_t f_new_node;
506 cnt_clr(&f_new_node);
509 fprintf(dmp->f, "%-16s %-8s %-8s %-8s\n", "Opcode", "alive", "created", "->Id");
510 for (entry = pset_first(set); entry; entry = pset_next(set)) {
511 fprintf(dmp->f, "%-16s %8d %8d %8d\n",
512 get_id_str(entry->op->name), entry->cnt_alive.cnt[0], entry->new_node.cnt[0], entry->into_Id.cnt[0]);
514 cnt_add(&f_alive, &entry->cnt_alive);
515 cnt_add(&f_new_node, &entry->new_node);
516 cnt_add(&f_Id, &entry->into_Id);
518 fprintf(dmp->f, "-------------------------------------------\n");
519 fprintf(dmp->f, "%-16s %8d %8d %8d\n", "Sum",
526 * dumps a optimization hash into human readable form
528 static void simple_dump_opt_hash(dumper_t *dmp, pset *set, int index)
530 opt_entry_t *entry = pset_first(set);
533 fprintf(dmp->f, "\n%s:\n", opt_names[index]);
534 fprintf(dmp->f, "%-16s %-8s\n", "Opcode", "deref");
536 for (; entry; entry = pset_next(set)) {
537 fprintf(dmp->f, "%-16s %8d\n",
538 get_id_str(entry->op->name), entry->count.cnt[0]);
544 * dumps the endges count
546 static void simple_dump_edges(dumper_t *dmp, counter_t *cnt)
548 fprintf(dmp->f, "%-16s %8d\n", "Edges", cnt->cnt[0]);
554 static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry)
557 block_entry_t *b_entry;
560 ir_graph *const_irg = get_const_code_irg();
562 if (entry->irg == const_irg) {
563 fprintf(dmp->f, "\nConst code Irg %p", (void *)entry->irg);
567 fprintf(dmp->f, "\nEntity %s, Irg %p", get_entity_name(entry->ent), (void *)entry->irg);
569 fprintf(dmp->f, "\nIrg %p", (void *)entry->irg);
572 fprintf(dmp->f, " %swalked %d over blocks %d was inlined %d got inlined %d strength red %d:\n",
573 entry->deleted ? "DELETED " : "",
574 entry->cnt_walked.cnt[0], entry->cnt_walked_blocks.cnt[0],
575 entry->cnt_was_inlined.cnt[0],
576 entry->cnt_got_inlined.cnt[0],
577 entry->cnt_strength_red.cnt[0]
581 fprintf(dmp->f, "\nGlobals counts:\n");
582 fprintf(dmp->f, "--------------\n");
586 simple_dump_opcode_hash(dmp, entry->opcode_hash);
587 simple_dump_edges(dmp, &entry->cnt_edges);
589 /* effects of optimizations */
593 for (i = 0; i < sizeof(entry->opt_hash)/sizeof(entry->opt_hash[0]); ++i) {
594 simple_dump_opt_hash(dmp, entry->opt_hash[i], i);
597 /* dump block info */
598 fprintf(dmp->f, "\n%12s %12s %12s %12s %12s %12s\n", "Block Nr", "Nodes", "intern E", "incoming E", "outgoing E", "quot");
599 for (b_entry = pset_first(entry->block_hash);
601 b_entry = pset_next(entry->block_hash)) {
602 fprintf(dmp->f, "BLK %12ld %12u %12u %12u %12u %4.8f\n",
604 b_entry->cnt_nodes.cnt[0],
605 b_entry->cnt_edges.cnt[0],
606 b_entry->cnt_in_edges.cnt[0],
607 b_entry->cnt_out_edges.cnt[0],
608 (double)b_entry->cnt_edges.cnt[0] / (double)b_entry->cnt_nodes.cnt[0]
615 * initialise the simple dumper
617 static void simple_init(dumper_t *dmp, const char *name)
621 snprintf(fname, sizeof(fname), "%s.txt", name);
622 dmp->f = fopen(fname, "w");
626 * finishes the simple dumper
628 static void simple_finish(dumper_t *dmp)
635 * the simple human readable dumper
637 static dumper_t simple_dumper = {
645 /* ---------------------------------------------------------------------- */
648 * count the nodes as needed:
650 * 1 normal (data) Phi's
655 static void csv_count_nodes(graph_entry_t *graph, counter_t cnt[])
660 for (i = 0; i < 4; ++i)
663 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
664 if (entry->op == op_Phi) {
666 cnt_add(&cnt[1], &entry->cnt_alive);
668 else if (entry->op == status->op_PhiM) {
670 cnt_add(&cnt[2], &entry->cnt_alive);
672 else if (entry->op == op_Proj) {
674 cnt_add(&cnt[3], &entry->cnt_alive);
677 /* all other nodes */
678 cnt_add(&cnt[0], &entry->cnt_alive);
686 static void csv_dump_graph(dumper_t *dmp, graph_entry_t *entry)
692 if (entry->irg && !entry->deleted) {
693 ir_graph *const_irg = get_const_code_irg();
695 if (entry->irg == const_irg) {
696 name = "<Const code Irg>";
701 name = get_entity_name(entry->ent);
703 name = "<UNKNOWN IRG>";
706 csv_count_nodes(entry, cnt);
708 fprintf(dmp->f, "%-40s, %p, %d, %d, %d, %d\n",
720 * initialise the simple dumper
722 static void csv_init(dumper_t *dmp, const char *name)
726 snprintf(fname, sizeof(fname), "%s.csv", name);
727 dmp->f = fopen(fname, "a");
731 * finishes the simple dumper
733 static void csv_finish(dumper_t *dmp)
740 * the simple human readable dumper
742 static dumper_t csv_dumper = {
751 /* ---------------------------------------------------------------------- */
754 * helper: get an ir_op from an opcode
756 ir_op *stat_get_op_from_opcode(opcode code)
758 return opcode_find_entry(code, status->ir_op_hash);
761 /* initialize the statistics module. */
762 void init_stat(unsigned enable_options)
764 #define X(a) a, sizeof(a)-1
768 /* enable statistics */
769 status->enable = enable_options & FIRMSTAT_ENABLED;
771 if (! status->enable)
774 obstack_init(&status->cnts);
776 /* build the pseudo-ops */
777 _op_Phi0.code = --pseudo_id;
778 _op_Phi0.name = new_id_from_chars(X("Phi0"));
780 _op_PhiM.code = --pseudo_id;
781 _op_PhiM.name = new_id_from_chars(X("PhiM"));
783 _op_MulC.code = --pseudo_id;
784 _op_MulC.name = new_id_from_chars(X("MulC"));
786 _op_DivC.code = --pseudo_id;
787 _op_DivC.name = new_id_from_chars(X("DivC"));
789 _op_ModC.code = --pseudo_id;
790 _op_ModC.name = new_id_from_chars(X("ModC"));
792 _op_DivModC.code = --pseudo_id;
793 _op_DivModC.name = new_id_from_chars(X("DivModC"));
795 /* create the hash-tables */
796 status->irg_hash = new_pset(graph_cmp, 8);
797 status->ir_op_hash = new_pset(opcode_cmp_2, 1);
799 status->op_Phi0 = &_op_Phi0;
800 status->op_PhiM = &_op_PhiM;
802 if (enable_options & FIRMSTAT_COUNT_STRONG_OP) {
803 status->op_MulC = &_op_MulC;
804 status->op_DivC = &_op_DivC;
805 status->op_ModC = &_op_ModC;
806 status->op_DivModC = &_op_DivModC;
809 status->op_MulC = NULL;
810 status->op_DivC = NULL;
811 status->op_ModC = NULL;
812 status->op_DivModC = NULL;
815 stat_register_dumper(&simple_dumper);
816 stat_register_dumper(&csv_dumper);
818 /* initialize the pattern hash */
819 stat_init_pattern_history(enable_options & FIRMSTAT_PATTERN_ENABLED);
823 /* A new IR op is registered. */
824 void stat_new_ir_op(const ir_op *op)
826 if (! status->enable)
831 graph_entry_t *graph = graph_get_entry(NULL, status->irg_hash);
833 /* execute for side effect :-) */
834 opcode_get_entry(op, graph->opcode_hash);
836 pset_insert(status->ir_op_hash, op, op->code);
841 /* An IR op is freed. */
842 void stat_free_ir_op(const ir_op *op)
844 if (! status->enable)
853 /* A new node is created. */
854 void stat_new_node(ir_node *node)
856 if (! status->enable)
859 /* do NOT count during dead node elimination */
860 if (status->in_dead_node_elim > 0)
866 graph_entry_t *graph;
867 ir_op *op = stat_get_irn_op(node);
869 /* increase global value */
870 graph = graph_get_entry(NULL, status->irg_hash);
871 entry = opcode_get_entry(op, graph->opcode_hash);
872 cnt_inc(&entry->new_node);
874 /* increase local value */
875 graph = graph_get_entry(current_ir_graph, status->irg_hash);
876 entry = opcode_get_entry(op, graph->opcode_hash);
877 cnt_inc(&entry->new_node);
882 /* A node is changed into a Id node */
883 void stat_turn_into_id(ir_node *node)
885 if (! status->enable)
891 graph_entry_t *graph;
892 ir_op *op = stat_get_irn_op(node);
894 /* increase global value */
895 graph = graph_get_entry(NULL, status->irg_hash);
896 entry = opcode_get_entry(op, graph->opcode_hash);
897 cnt_inc(&entry->into_Id);
899 /* increase local value */
900 graph = graph_get_entry(current_ir_graph, status->irg_hash);
901 entry = opcode_get_entry(op, graph->opcode_hash);
902 cnt_inc(&entry->into_Id);
907 /* A new graph was created */
908 void stat_new_graph(ir_graph *irg, entity *ent)
910 if (! status->enable)
915 /* execute for side effect :-) */
916 graph_entry_t * graph = graph_get_entry(irg, status->irg_hash);
925 * A graph was deleted
927 void stat_free_graph(ir_graph *irg)
929 if (! status->enable)
934 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
935 graph_entry_t *global = graph_get_entry(NULL, status->irg_hash);
939 /* count the nodes of the graph yet, it will be destroyed later */
940 count_nodes_in_graph(global, graph);
942 /* count the DAG's */
943 // count_dags_in_graph(global, graph);
945 /* calculate the pattern */
946 stat_calc_pattern_history(irg);
952 * A walk over a graph is initiated. Do not count walks from statistic code.
954 void stat_irg_walk(ir_graph *irg, void *pre, void *post)
956 if (! status->enable)
961 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
963 cnt_inc(&graph->cnt_walked);
969 * A walk over a graph in block-wise order is initiated. Do not count walks from statistic code.
971 void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post)
973 /* for now, do NOT differentiate between blockwise and normal */
974 stat_irg_walk(irg, pre, post);
978 * A walk over the graph's blocks is initiated. Do not count walks from statistic code.
980 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post)
982 if (! status->enable)
987 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
989 cnt_inc(&graph->cnt_walked_blocks);
995 * called for every node that is removed due to an optimization
997 static void removed_due_opt(ir_node *n, pset *set)
999 ir_op *op = stat_get_irn_op(n);
1000 opt_entry_t *entry = opt_get_entry(op, set);
1002 /* increase global value */
1003 cnt_inc(&entry->count);
1007 * Some nodes were optimized into some others due to an optimization
1009 void stat_merge_nodes(
1010 ir_node **new_node_array, int new_num_entries,
1011 ir_node **old_node_array, int old_num_entries,
1014 if (! status->enable)
1020 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1022 for (i = 0; i < old_num_entries; ++i) {
1023 for (j = 0; j < new_num_entries; ++j)
1024 if (old_node_array[i] == new_node_array[j])
1027 /* nodes might be in new and old, these are NOT removed */
1028 if (j >= new_num_entries) {
1029 removed_due_opt(old_node_array[i], graph->opt_hash[opt]);
1037 * A node was lowered into other nodes
1039 void stat_lower(ir_node *node)
1041 if (! status->enable)
1046 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1048 removed_due_opt(node, graph->opt_hash[STAT_LOWERED]);
1054 * A graph was inlined
1056 void stat_inline(ir_node *call, ir_graph *called_irg)
1058 if (! status->enable)
1063 ir_graph *irg = get_irn_irg(call);
1064 graph_entry_t *i_graph = graph_get_entry(called_irg, status->irg_hash);
1065 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
1067 cnt_inc(&graph->cnt_got_inlined);
1068 cnt_inc(&i_graph->cnt_was_inlined);
1074 * A graph with tail-recursions was optimized.
1076 void stat_tail_rec(ir_graph *irg)
1078 if (! status->enable)
1088 * Strength reduction was performed on an iteration variable.
1090 void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp)
1092 if (! status->enable)
1097 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
1098 cnt_inc(&graph->cnt_strength_red);
1100 removed_due_opt(strong, graph->opt_hash[STAT_OPT_STRENGTH_RED]);
1106 * Start the dead node elimination.
1108 void stat_dead_node_elim_start(ir_graph *irg)
1110 if (! status->enable)
1113 ++status->in_dead_node_elim;
1117 * Stops the dead node elimination.
1119 void stat_dead_node_elim_stop(ir_graph *irg)
1121 if (! status->enable)
1124 --status->in_dead_node_elim;
1128 * A multiply was replaced by a series of Shifts/Adds/Subs
1130 void stat_arch_dep_replace_mul_with_shifts(ir_node *mul)
1132 if (! status->enable)
1137 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1138 removed_due_opt(mul, graph->opt_hash[STAT_OPT_ARCH_DEP]);
1143 /* Finish the statistics */
1144 void stat_finish(const char *name)
1146 if (! status->enable)
1151 graph_entry_t *entry;
1152 graph_entry_t *global = graph_get_entry(NULL, status->irg_hash);
1156 /* dump per graph */
1157 for (entry = pset_first(status->irg_hash); entry; entry = pset_next(status->irg_hash)) {
1159 if (entry->irg == NULL) {
1160 /* special entry for the global count */
1164 if (! entry->deleted) {
1165 /* the graph is still alive, count the nodes on it */
1166 count_nodes_in_graph(global, entry);
1168 /* count the DAG's */
1169 // count_dags_in_graph(global, entry);
1171 /* calculate the pattern */
1172 stat_calc_pattern_history(entry->irg);
1177 /* clear the counter here:
1178 * we need only the edge counter to be cleared, all others are cumulative
1180 cnt_clr(&entry->cnt_edges);
1184 // dump_graph(global);
1187 stat_finish_pattern_history();
1189 /* clear the global counter here */
1191 node_entry_t *entry;
1193 for (entry = pset_first(global->opcode_hash); entry; entry = pset_next(global->opcode_hash)) {
1194 opcode_clear_entry(entry);
1196 graph_clear_entry(global);
1200 // status->enable = 0;
1207 /* need this for prototypes */
1208 #define FIRM_STATISTICS
1209 #include "firmstat.h"
1211 void init_stat(unsigned enable_options) {}
1213 void stat_finish(const char *name) {}
1215 void stat_new_ir_op(const ir_op *op) {}
1217 void stat_free_ir_op(const ir_op *op) {}
1219 void stat_new_node(ir_node *node) {}
1221 void stat_turn_into_id(ir_node *node) {}
1223 void stat_new_graph(ir_graph *irg, entity *ent) {}
1225 void stat_free_graph(ir_graph *irg) {}
1227 void stat_irg_walk(ir_graph *irg, void *pre, void *post) {}
1229 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post) {}
1231 void stat_merge_nodes(
1232 ir_node **new_node_array, int new_num_entries,
1233 ir_node **old_node_array, int old_num_entries,
1234 stat_opt_kind opt) {}
1236 void stat_lower(ir_node *node) {}
1238 void stat_inline(ir_node *call, ir_graph *irg) {}
1240 void stat_tail_rec(ir_graph *irg) {}
1242 void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp) {}
1244 void stat_dead_node_elim_start(ir_graph *irg) {}
1246 void stat_dead_node_elim_stop(ir_graph *irg) {}
1248 void stat_arch_dep_replace_mul_with_shifts(ir_node *mul) {}