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",
46 * need this to be static:
47 * Special pseudo Opcodes that we need to count some interesting cases
51 * The Phi0, a node that is created during SSA construction
53 static ir_op _op_Phi0;
55 /** The PhiM, just to count memorty Phi's. */
56 static ir_op _op_PhiM;
58 /** The Mul by Const node. */
59 static ir_op _op_MulC;
61 /** The Div by Const node. */
62 static ir_op _op_DivC;
64 /** The Div by Const node. */
65 static ir_op _op_ModC;
67 /** The Div by Const node. */
68 static ir_op _op_DivModC;
70 /* ---------------------------------------------------------------------------------- */
72 #define STAT_ENTER ++status->recursive
73 #define STAT_LEAVE --status->recursive
74 #define STAT_ENTER_SINGLE do { if (status->recursive > 0) return; ++status->recursive; } while (0)
79 static stat_info_t _status, *status = &_status;
82 * compare two elements of the opcode hash
84 static int opcode_cmp(const void *elt, const void *key)
86 const node_entry_t *e1 = elt;
87 const node_entry_t *e2 = key;
89 return e1->op->code - e2->op->code;
93 * compare two elements of the graph hash
95 static int graph_cmp(const void *elt, const void *key)
97 const graph_entry_t *e1 = elt;
98 const graph_entry_t *e2 = key;
100 return e1->irg != e2->irg;
104 * compare two elements of the optimization hash
106 static int opt_cmp(const void *elt, const void *key)
108 const opt_entry_t *e1 = elt;
109 const opt_entry_t *e2 = key;
111 return e1->op->code != e2->op->code;
115 * compare two elements of the block hash
117 static int block_cmp(const void *elt, const void *key)
119 const block_entry_t *e1 = elt;
120 const block_entry_t *e2 = key;
122 return e1->block_nr != e2->block_nr;
126 * compare two elements of the ir_op hash
128 static int opcode_cmp_2(const void *elt, const void *key)
130 const ir_op *e1 = elt;
131 const ir_op *e2 = key;
133 return e1->code != e2->code;
137 * clears all counter in a node_entry_t
139 static void opcode_clear_entry(node_entry_t *elem)
141 cnt_clr(&elem->cnt_alive);
142 cnt_clr(&elem->new_node);
143 cnt_clr(&elem->into_Id);
147 * Returns the associates node_entry_t for an ir_op
149 static node_entry_t *opcode_get_entry(const ir_op *op, pset *set)
156 elem = pset_find(set, &key, op->code);
160 elem = obstack_alloc(&status->cnts, sizeof(*elem));
163 opcode_clear_entry(elem);
167 return pset_insert(set, elem, op->code);
171 * Returns the associates ir_op for an opcode
173 static ir_op *opcode_find_entry(opcode code, pset *set)
178 return pset_find(set, &key, code);
182 * calculates a hash value for an irg
183 * Addresses are typically aligned at 32bit, so we ignore the lowest bits
185 static INLINE unsigned irg_hash(const ir_graph *irg)
187 return (unsigned)irg >> 3;
191 * clears all counter in a graph_entry_t
193 static void graph_clear_entry(graph_entry_t *elem)
195 cnt_clr(&elem->cnt_walked);
196 cnt_clr(&elem->cnt_walked_blocks);
197 cnt_clr(&elem->cnt_was_inlined);
198 cnt_clr(&elem->cnt_got_inlined);
199 cnt_clr(&elem->cnt_strength_red);
200 cnt_clr(&elem->cnt_edges);
204 * Returns the acssociates graph_entry_t for an irg
206 static graph_entry_t *graph_get_entry(ir_graph *irg, pset *set)
214 elem = pset_find(set, &key, irg_hash(irg));
218 elem = obstack_alloc(&status->cnts, sizeof(*elem));
221 graph_clear_entry(elem);
223 /* new hash table for opcodes here */
224 elem->opcode_hash = new_pset(opcode_cmp, 5);
225 elem->block_hash = new_pset(block_cmp, 5);
228 for (i = 0; i < sizeof(elem->opt_hash)/sizeof(elem->opt_hash[0]); ++i)
229 elem->opt_hash[i] = new_pset(opt_cmp, 4);
231 return pset_insert(set, elem, irg_hash(irg));
235 * clears all counter in an opt_entry_t
237 static void opt_clear_entry(opt_entry_t *elem)
239 cnt_clr(&elem->count);
243 * Returns the associates opt_entry_t for an ir_op
245 static opt_entry_t *opt_get_entry(const ir_op *op, pset *set)
252 elem = pset_find(set, &key, op->code);
256 elem = obstack_alloc(&status->cnts, sizeof(*elem));
258 /* clear new counter */
259 opt_clear_entry(elem);
263 return pset_insert(set, elem, op->code);
267 * clears all counter in a block_entry_t
269 static void block_clear_entry(block_entry_t *elem)
271 cnt_clr(&elem->cnt_nodes);
272 cnt_clr(&elem->cnt_edges);
273 cnt_clr(&elem->cnt_in_edges);
274 cnt_clr(&elem->cnt_out_edges);
278 * Returns the associates block_entry_t for an block
280 static block_entry_t *block_get_entry(long block_nr, pset *set)
285 key.block_nr = block_nr;
287 elem = pset_find(set, &key, block_nr);
291 elem = obstack_alloc(&status->cnts, sizeof(*elem));
293 /* clear new counter */
294 block_clear_entry(elem);
296 elem->block_nr = block_nr;
298 return pset_insert(set, elem, block_nr);
303 * Returns the ir_op for an IR-node,
304 * handles special cases and return pseudo op codes
306 static ir_op *stat_get_irn_op(ir_node *node)
308 ir_op *op = get_irn_op(node);
310 if (op->code == iro_Phi && get_irn_arity(node) == 0) {
311 /* special case, a Phi0 node, count on extra counter */
312 op = status->op_Phi0;
314 else if (op->code == iro_Phi && get_irn_mode(node) == mode_M) {
315 /* special case, a Memory Phi node, count on extra counter */
316 op = status->op_PhiM;
318 else if (op->code == iro_Mul &&
319 (get_irn_op(get_Mul_left(node)) == op_Const || get_irn_op(get_Mul_right(node)) == op_Const)) {
320 /* special case, a Multiply by a const, count on extra counter */
321 op = status->op_MulC ? status->op_MulC : op_Mul;
323 else if (op->code == iro_Div && get_irn_op(get_Div_right(node)) == op_Const) {
324 /* special case, a division by a const, count on extra counter */
325 op = status->op_DivC ? status->op_DivC : op_Div;
327 else if (op->code == iro_Mod && get_irn_op(get_Mod_right(node)) == op_Const) {
328 /* special case, a module by a const, count on extra counter */
329 op = status->op_ModC ? status->op_ModC : op_Mod;
331 else if (op->code == iro_DivMod && get_irn_op(get_DivMod_right(node)) == op_Const) {
332 /* special case, a division/modulo by a const, count on extra counter */
333 op = status->op_DivModC ? status->op_DivModC : op_DivMod;
340 * update the block counter
342 static void count_block_info(ir_node *node, graph_entry_t *graph)
344 ir_op *op = get_irn_op(node);
346 block_entry_t *b_entry;
349 /* check for block */
350 if (op == op_Block) {
351 arity = get_irn_arity(node);
352 b_entry = block_get_entry(get_irn_node_nr(node), graph->block_hash);
354 /* count all incoming edges */
355 for (i = 0; i < arity; ++i) {
356 ir_node *pred = get_irn_n(node, i);
357 ir_node *other_block = get_nodes_block(pred);
358 block_entry_t *b_entry_other = block_get_entry(get_irn_node_nr(other_block), graph->block_hash);
360 cnt_inc(&b_entry->cnt_in_edges); /* an edge coming from another block */
361 cnt_inc(&b_entry_other->cnt_out_edges);
365 else if (op == op_Call) {
369 block = get_nodes_block(node);
370 b_entry = block_get_entry(get_irn_node_nr(block), graph->block_hash);
372 /* we have a new nodes */
373 cnt_inc(&b_entry->cnt_nodes);
375 arity = get_irn_arity(node);
377 for (i = 0; i < arity; ++i) {
378 ir_node *pred = get_irn_n(node, i);
379 ir_node *other_block;
381 if (get_irn_op(pred) == op_Block)
384 other_block = get_nodes_block(pred);
386 if (other_block == block)
387 cnt_inc(&b_entry->cnt_edges); /* a in block edge */
389 block_entry_t *b_entry_other = block_get_entry(get_irn_node_nr(other_block), graph->block_hash);
391 cnt_inc(&b_entry->cnt_in_edges); /* an edge coming from another block */
392 cnt_inc(&b_entry_other->cnt_out_edges);
398 * walker for reachable nodes count
400 static void count_nodes(ir_node *node, void *env)
402 graph_entry_t *graph = env;
405 ir_op *op = stat_get_irn_op(node);
406 int arity = get_irn_arity(node);
408 entry = opcode_get_entry(op, graph->opcode_hash);
410 cnt_inc(&entry->cnt_alive);
411 cnt_add_i(&graph->cnt_edges, arity);
413 /* count block edges */
414 count_block_info(node, graph);
418 * count all alive nodes and edges in a graph
420 static void count_nodes_in_graph(graph_entry_t *global, graph_entry_t *graph)
424 /* clear first the alive counter in the graph */
425 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
426 cnt_clr(&entry->cnt_alive);
429 /* count the nodes in the graph */
430 irg_walk_graph(graph->irg, count_nodes, NULL, graph);
432 /* assume we walk every graph only ONCE, we could sum here the global count */
433 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
434 node_entry_t *g_entry = opcode_get_entry(entry->op, global->opcode_hash);
436 /* update the node counter */
437 cnt_add(&g_entry->cnt_alive, &entry->cnt_alive);
440 /* update the edge counter */
441 cnt_add(&global->cnt_edges, &graph->cnt_edges);
447 static void stat_register_dumper(dumper_t *dumper)
449 dumper->next = status->dumper;
450 status->dumper = dumper;
456 static void dump_graph(graph_entry_t *entry)
460 for (dumper = status->dumper; dumper; dumper = dumper->next) {
461 if (dumper->dump_graph)
462 dumper->dump_graph(dumper, entry);
467 * initialise the dumper
469 static void dump_init(const char *name)
473 for (dumper = status->dumper; dumper; dumper = dumper->next) {
475 dumper->init(dumper, name);
482 static void dump_finish(void)
486 for (dumper = status->dumper; dumper; dumper = dumper->next) {
488 dumper->finish(dumper);
492 /* ---------------------------------------------------------------------- */
495 * dumps a opcode hash into human readable form
497 static void simple_dump_opcode_hash(dumper_t *dmp, pset *set)
501 counter_t f_new_node;
505 cnt_clr(&f_new_node);
508 fprintf(dmp->f, "%-16s %-8s %-8s %-8s\n", "Opcode", "alive", "created", "->Id");
509 for (entry = pset_first(set); entry; entry = pset_next(set)) {
510 fprintf(dmp->f, "%-16s %8d %8d %8d\n",
511 get_id_str(entry->op->name), entry->cnt_alive.cnt[0], entry->new_node.cnt[0], entry->into_Id.cnt[0]);
513 cnt_add(&f_alive, &entry->cnt_alive);
514 cnt_add(&f_new_node, &entry->new_node);
515 cnt_add(&f_Id, &entry->into_Id);
517 fprintf(dmp->f, "-------------------------------------------\n");
518 fprintf(dmp->f, "%-16s %8d %8d %8d\n", "Sum",
525 * dumps a optimization hash into human readable form
527 static void simple_dump_opt_hash(dumper_t *dmp, pset *set, int index)
529 opt_entry_t *entry = pset_first(set);
532 fprintf(dmp->f, "\n%s:\n", opt_names[index]);
533 fprintf(dmp->f, "%-16s %-8s\n", "Opcode", "deref");
535 for (; entry; entry = pset_next(set)) {
536 fprintf(dmp->f, "%-16s %8d\n",
537 get_id_str(entry->op->name), entry->count.cnt[0]);
543 * dumps the endges count
545 static void simple_dump_edges(dumper_t *dmp, counter_t *cnt)
547 fprintf(dmp->f, "%-16s %8d\n", "Edges", cnt->cnt[0]);
553 static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry)
556 block_entry_t *b_entry;
559 ir_graph *const_irg = get_const_code_irg();
561 if (entry->irg == const_irg) {
562 fprintf(dmp->f, "\nConst code Irg %p", (void *)entry->irg);
566 fprintf(dmp->f, "\nEntity %s, Irg %p", get_entity_name(entry->ent), (void *)entry->irg);
568 fprintf(dmp->f, "\nIrg %p", (void *)entry->irg);
571 fprintf(dmp->f, " %swalked %d over blocks %d was inlined %d got inlined %d strength red %d:\n",
572 entry->deleted ? "DELETED " : "",
573 entry->cnt_walked.cnt[0], entry->cnt_walked_blocks.cnt[0],
574 entry->cnt_was_inlined.cnt[0],
575 entry->cnt_got_inlined.cnt[0],
576 entry->cnt_strength_red.cnt[0]
580 fprintf(dmp->f, "\nGlobals counts:\n");
581 fprintf(dmp->f, "--------------\n");
585 simple_dump_opcode_hash(dmp, entry->opcode_hash);
586 simple_dump_edges(dmp, &entry->cnt_edges);
588 /* effects of optimizations */
592 for (i = 0; i < sizeof(entry->opt_hash)/sizeof(entry->opt_hash[0]); ++i) {
593 simple_dump_opt_hash(dmp, entry->opt_hash[i], i);
596 /* dump block info */
597 fprintf(dmp->f, "\n%12s %12s %12s %12s %12s %12s\n", "Block Nr", "Nodes", "intern E", "incoming E", "outgoing E", "quot");
598 for (b_entry = pset_first(entry->block_hash);
600 b_entry = pset_next(entry->block_hash)) {
601 fprintf(dmp->f, "BLK %12ld %12u %12u %12u %12u %4.8f\n",
603 b_entry->cnt_nodes.cnt[0],
604 b_entry->cnt_edges.cnt[0],
605 b_entry->cnt_in_edges.cnt[0],
606 b_entry->cnt_out_edges.cnt[0],
607 (double)b_entry->cnt_edges.cnt[0] / (double)b_entry->cnt_nodes.cnt[0]
614 * initialise the simple dumper
616 static void simple_init(dumper_t *dmp, const char *name)
620 snprintf(fname, sizeof(fname), "%s.txt", name);
621 dmp->f = fopen(fname, "w");
625 * finishes the simple dumper
627 static void simple_finish(dumper_t *dmp)
634 * the simple human readable dumper
636 static dumper_t simple_dumper = {
644 /* ---------------------------------------------------------------------- */
647 * count the nodes as needed:
649 * 1 normal (data) Phi's
654 static void csv_count_nodes(graph_entry_t *graph, counter_t cnt[])
659 for (i = 0; i < 4; ++i)
662 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
663 if (entry->op == op_Phi) {
665 cnt_add(&cnt[1], &entry->cnt_alive);
667 else if (entry->op == status->op_PhiM) {
669 cnt_add(&cnt[2], &entry->cnt_alive);
671 else if (entry->op == op_Proj) {
673 cnt_add(&cnt[3], &entry->cnt_alive);
676 /* all other nodes */
677 cnt_add(&cnt[0], &entry->cnt_alive);
685 static void csv_dump_graph(dumper_t *dmp, graph_entry_t *entry)
691 if (entry->irg && !entry->deleted) {
692 ir_graph *const_irg = get_const_code_irg();
694 if (entry->irg == const_irg) {
695 name = "<Const code Irg>";
700 name = get_entity_name(entry->ent);
702 name = "<UNKNOWN IRG>";
705 csv_count_nodes(entry, cnt);
707 fprintf(dmp->f, "%-40s, %p, %d, %d, %d, %d\n",
719 * initialise the simple dumper
721 static void csv_init(dumper_t *dmp, const char *name)
725 snprintf(fname, sizeof(fname), "%s.csv", name);
726 dmp->f = fopen(fname, "a");
730 * finishes the simple dumper
732 static void csv_finish(dumper_t *dmp)
739 * the simple human readable dumper
741 static dumper_t csv_dumper = {
750 /* ---------------------------------------------------------------------- */
753 * helper: get an ir_op from an opcode
755 ir_op *stat_get_op_from_opcode(opcode code)
757 return opcode_find_entry(code, status->ir_op_hash);
760 /* initialize the statistics module. */
761 void init_stat(unsigned enable_options)
763 #define X(a) a, sizeof(a)-1
767 /* enable statistics */
768 status->enable = enable_options & FIRMSTAT_ENABLED;
770 if (! status->enable)
773 obstack_init(&status->cnts);
775 /* build the pseudo-ops */
776 _op_Phi0.code = --pseudo_id;
777 _op_Phi0.name = new_id_from_chars(X("Phi0"));
779 _op_PhiM.code = --pseudo_id;
780 _op_PhiM.name = new_id_from_chars(X("PhiM"));
782 _op_MulC.code = --pseudo_id;
783 _op_MulC.name = new_id_from_chars(X("MulC"));
785 _op_DivC.code = --pseudo_id;
786 _op_DivC.name = new_id_from_chars(X("DivC"));
788 _op_ModC.code = --pseudo_id;
789 _op_ModC.name = new_id_from_chars(X("ModC"));
791 _op_DivModC.code = --pseudo_id;
792 _op_DivModC.name = new_id_from_chars(X("DivModC"));
794 /* create the hash-tables */
795 status->irg_hash = new_pset(graph_cmp, 8);
796 status->ir_op_hash = new_pset(opcode_cmp_2, 1);
798 status->op_Phi0 = &_op_Phi0;
799 status->op_PhiM = &_op_PhiM;
801 if (enable_options & FIRMSTAT_COUNT_STRONG_OP) {
802 status->op_MulC = &_op_MulC;
803 status->op_DivC = &_op_DivC;
804 status->op_ModC = &_op_ModC;
805 status->op_DivModC = &_op_DivModC;
808 status->op_MulC = NULL;
809 status->op_DivC = NULL;
810 status->op_ModC = NULL;
811 status->op_DivModC = NULL;
814 stat_register_dumper(&simple_dumper);
815 stat_register_dumper(&csv_dumper);
817 /* initialize the pattern hash */
818 stat_init_pattern_history(enable_options & FIRMSTAT_PATTERN_ENABLED);
822 /* A new IR op is registered. */
823 void stat_new_ir_op(const ir_op *op)
825 if (! status->enable)
830 graph_entry_t *graph = graph_get_entry(NULL, status->irg_hash);
832 /* execute for side effect :-) */
833 opcode_get_entry(op, graph->opcode_hash);
835 pset_insert(status->ir_op_hash, op, op->code);
840 /* An IR op is freed. */
841 void stat_free_ir_op(const ir_op *op)
843 if (! status->enable)
852 /* A new node is created. */
853 void stat_new_node(ir_node *node)
855 if (! status->enable)
858 /* do NOT count during dead node elimination */
859 if (status->in_dead_node_elim > 0)
865 graph_entry_t *graph;
866 ir_op *op = stat_get_irn_op(node);
868 /* increase global value */
869 graph = graph_get_entry(NULL, status->irg_hash);
870 entry = opcode_get_entry(op, graph->opcode_hash);
871 cnt_inc(&entry->new_node);
873 /* increase local value */
874 graph = graph_get_entry(current_ir_graph, status->irg_hash);
875 entry = opcode_get_entry(op, graph->opcode_hash);
876 cnt_inc(&entry->new_node);
881 /* A node is changed into a Id node */
882 void stat_turn_into_id(ir_node *node)
884 if (! status->enable)
890 graph_entry_t *graph;
891 ir_op *op = stat_get_irn_op(node);
893 /* increase global value */
894 graph = graph_get_entry(NULL, status->irg_hash);
895 entry = opcode_get_entry(op, graph->opcode_hash);
896 cnt_inc(&entry->into_Id);
898 /* increase local value */
899 graph = graph_get_entry(current_ir_graph, status->irg_hash);
900 entry = opcode_get_entry(op, graph->opcode_hash);
901 cnt_inc(&entry->into_Id);
906 /* A new graph was created */
907 void stat_new_graph(ir_graph *irg, entity *ent)
909 if (! status->enable)
914 /* execute for side effect :-) */
915 graph_entry_t * graph = graph_get_entry(irg, status->irg_hash);
924 * A graph was deleted
926 void stat_free_graph(ir_graph *irg)
928 if (! status->enable)
933 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
934 graph_entry_t *global = graph_get_entry(NULL, status->irg_hash);
938 /* count the nodes of the graph yet, it will be destroyed later */
939 count_nodes_in_graph(global, graph);
941 /* count the DAG's */
942 // count_dags_in_graph(global, graph);
944 /* calculate the pattern */
945 stat_calc_pattern_history(irg);
951 * A walk over a graph is initiated. Do not count walks from statistic code.
953 void stat_irg_walk(ir_graph *irg, void *pre, void *post)
955 if (! status->enable)
960 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
962 cnt_inc(&graph->cnt_walked);
968 * A walk over a graph in block-wise order is initiated. Do not count walks from statistic code.
970 void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post)
972 /* for now, do NOT differentiate between blockwise and normal */
973 stat_irg_walk(irg, pre, post);
977 * A walk over the graph's blocks is initiated. Do not count walks from statistic code.
979 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post)
981 if (! status->enable)
986 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
988 cnt_inc(&graph->cnt_walked_blocks);
994 * called for every node that is removed due to an optimization
996 static void removed_due_opt(ir_node *n, pset *set)
998 ir_op *op = stat_get_irn_op(n);
999 opt_entry_t *entry = opt_get_entry(op, set);
1001 /* increase global value */
1002 cnt_inc(&entry->count);
1006 * Some nodes were optimized into some others due to an optimization
1008 void stat_merge_nodes(
1009 ir_node **new_node_array, int new_num_entries,
1010 ir_node **old_node_array, int old_num_entries,
1013 if (! status->enable)
1019 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1021 for (i = 0; i < old_num_entries; ++i) {
1022 for (j = 0; j < new_num_entries; ++j)
1023 if (old_node_array[i] == new_node_array[j])
1026 /* nodes might be in new and old, these are NOT removed */
1027 if (j >= new_num_entries) {
1028 removed_due_opt(old_node_array[i], graph->opt_hash[opt]);
1036 * A node was lowered into other nodes
1038 void stat_lower(ir_node *node)
1040 if (! status->enable)
1045 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1047 removed_due_opt(node, graph->opt_hash[STAT_LOWERED]);
1053 * A graph was inlined
1055 void stat_inline(ir_node *call, ir_graph *called_irg)
1057 if (! status->enable)
1062 ir_graph *irg = get_irn_irg(call);
1063 graph_entry_t *i_graph = graph_get_entry(called_irg, status->irg_hash);
1064 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
1066 cnt_inc(&graph->cnt_got_inlined);
1067 cnt_inc(&i_graph->cnt_was_inlined);
1073 * A graph with tail-recursions was optimized.
1075 void stat_tail_rec(ir_graph *irg)
1077 if (! status->enable)
1087 * Strength reduction was performed on an iteration variable.
1089 void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp)
1091 if (! status->enable)
1096 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
1097 cnt_inc(&graph->cnt_strength_red);
1099 removed_due_opt(strong, graph->opt_hash[STAT_OPT_STRENGTH_RED]);
1105 * Start the dead node elimination.
1107 void stat_dead_node_elim_start(ir_graph *irg)
1109 if (! status->enable)
1112 ++status->in_dead_node_elim;
1116 * Stops the dead node elimination.
1118 void stat_dead_node_elim_stop(ir_graph *irg)
1120 if (! status->enable)
1123 --status->in_dead_node_elim;
1126 /* Finish the statistics */
1127 void stat_finish(const char *name)
1129 if (! status->enable)
1134 graph_entry_t *entry;
1135 graph_entry_t *global = graph_get_entry(NULL, status->irg_hash);
1139 /* dump per graph */
1140 for (entry = pset_first(status->irg_hash); entry; entry = pset_next(status->irg_hash)) {
1142 if (entry->irg == NULL) {
1143 /* special entry for the global count */
1147 if (! entry->deleted) {
1148 /* the graph is still alive, count the nodes on it */
1149 count_nodes_in_graph(global, entry);
1151 /* count the DAG's */
1152 // count_dags_in_graph(global, entry);
1154 /* calculate the pattern */
1155 stat_calc_pattern_history(entry->irg);
1160 /* clear the counter here:
1161 * we need only the edge counter to be cleared, all others are cumulative
1163 cnt_clr(&entry->cnt_edges);
1167 // dump_graph(global);
1170 stat_finish_pattern_history();
1172 /* clear the global counter here */
1174 node_entry_t *entry;
1176 for (entry = pset_first(global->opcode_hash); entry; entry = pset_next(global->opcode_hash)) {
1177 opcode_clear_entry(entry);
1179 graph_clear_entry(global);
1183 // status->enable = 0;
1190 /* need this for prototypes */
1191 #define FIRM_STATISTICS
1192 #include "firmstat.h"
1194 void init_stat(unsigned enable_options) {}
1196 void stat_finish(const char *name) {}
1198 void stat_new_ir_op(const ir_op *op) {}
1200 void stat_free_ir_op(const ir_op *op) {}
1202 void stat_new_node(ir_node *node) {}
1204 void stat_turn_into_id(ir_node *node) {}
1206 void stat_new_graph(ir_graph *irg, entity *ent) {}
1208 void stat_free_graph(ir_graph *irg) {}
1210 void stat_irg_walk(ir_graph *irg, void *pre, void *post) {}
1212 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post) {}
1214 void stat_merge_nodes(
1215 ir_node **new_node_array, int new_num_entries,
1216 ir_node **old_node_array, int old_num_entries,
1217 stat_opt_kind opt) {}
1219 void stat_lower(ir_node *node) {}
1221 void stat_inline(ir_node *call, ir_graph *irg) {}
1223 void stat_tail_rec(ir_graph *irg) {}
1225 void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp) {}
1227 void stat_dead_node_elim_start(ir_graph *irg) {}
1229 void stat_dead_node_elim_stop(ir_graph *irg) {}