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
30 #include "firmstat_t.h"
36 * need this to be static:
37 * Special pseudo Opcodes that we need to count some interesting cases
41 * The Phi0, a node that is created during SSA construction
43 static ir_op _op_Phi0;
45 /** The PhiM, just to count memorty Phi's. */
46 static ir_op _op_PhiM;
48 /** The Mul by Const node. */
49 static ir_op _op_MulC;
51 /** The Div by Const node. */
52 static ir_op _op_DivC;
54 /** The Div by Const node. */
55 static ir_op _op_ModC;
57 /** The Div by Const node. */
58 static ir_op _op_DivModC;
60 /* ---------------------------------------------------------------------------------- */
62 #define STAT_ENTER ++status->recursive
63 #define STAT_LEAVE --status->recursive
64 #define STAT_ENTER_SINGLE do { if (status->recursive > 0) return; ++status->recursive; } while (0)
69 static stat_info_t _status, *status = &_status;
72 * compare two elements of the opcode hash
74 static int opcode_cmp(const void *elt, const void *key)
76 const node_entry_t *e1 = elt;
77 const node_entry_t *e2 = key;
79 return e1->op->code - e2->op->code;
83 * compare two elements of the graph hash
85 static int graph_cmp(const void *elt, const void *key)
87 const graph_entry_t *e1 = elt;
88 const graph_entry_t *e2 = key;
90 return e1->irg != e2->irg;
94 * compare two elements of the optimization hash
96 static int opt_cmp(const void *elt, const void *key)
98 const opt_entry_t *e1 = elt;
99 const opt_entry_t *e2 = key;
101 return e1->op->code != e2->op->code;
105 * compare two elements of the block hash
107 static int block_cmp(const void *elt, const void *key)
109 const block_entry_t *e1 = elt;
110 const block_entry_t *e2 = key;
112 return e1->block_nr != e2->block_nr;
116 * compare two elements of the ir_op hash
118 static int opcode_cmp_2(const void *elt, const void *key)
120 const ir_op *e1 = elt;
121 const ir_op *e2 = key;
123 return e1->code != e2->code;
127 * compare two elements of the address_mark set
129 static int address_mark_cmp(const void *elt, const void *key, size_t size)
131 const address_mark_entry_t *e1 = elt;
132 const address_mark_entry_t *e2 = key;
134 /* compare only the nodes, the rest is used as data container */
135 return e1->node != e2->node;
139 * clears all counter in a node_entry_t
141 static void opcode_clear_entry(node_entry_t *elem)
143 cnt_clr(&elem->cnt_alive);
144 cnt_clr(&elem->new_node);
145 cnt_clr(&elem->into_Id);
149 * Returns the associates node_entry_t for an ir_op
151 static node_entry_t *opcode_get_entry(const ir_op *op, pset *set)
158 elem = pset_find(set, &key, op->code);
162 elem = obstack_alloc(&status->cnts, sizeof(*elem));
165 opcode_clear_entry(elem);
169 return pset_insert(set, elem, op->code);
173 * Returns the associates ir_op for an opcode
175 static ir_op *opcode_find_entry(opcode code, pset *set)
180 return pset_find(set, &key, code);
184 * clears all counter in a graph_entry_t
186 static void graph_clear_entry(graph_entry_t *elem, int all)
189 cnt_clr(&elem->cnt_walked);
190 cnt_clr(&elem->cnt_walked_blocks);
191 cnt_clr(&elem->cnt_was_inlined);
192 cnt_clr(&elem->cnt_got_inlined);
193 cnt_clr(&elem->cnt_strength_red);
195 cnt_clr(&elem->cnt_edges);
196 cnt_clr(&elem->cnt_all_calls);
197 cnt_clr(&elem->cnt_indirect_calls);
201 * Returns the acssociates graph_entry_t for an irg
203 static graph_entry_t *graph_get_entry(ir_graph *irg, pset *set)
211 elem = pset_find(set, &key, HASH_PTR(irg));
215 /* allocate a new one */
216 elem = obstack_alloc(&status->cnts, sizeof(*elem));
219 graph_clear_entry(elem, 1);
221 /* new hash table for opcodes here */
222 elem->opcode_hash = new_pset(opcode_cmp, 5);
223 elem->block_hash = new_pset(block_cmp, 5);
224 elem->address_mark = new_set(address_mark_cmp, 5);
227 for (i = 0; i < sizeof(elem->opt_hash)/sizeof(elem->opt_hash[0]); ++i)
228 elem->opt_hash[i] = new_pset(opt_cmp, 4);
230 return pset_insert(set, elem, HASH_PTR(irg));
234 * clears all counter in an opt_entry_t
236 static void opt_clear_entry(opt_entry_t *elem)
238 cnt_clr(&elem->count);
242 * Returns the associates opt_entry_t for an ir_op
244 static opt_entry_t *opt_get_entry(const ir_op *op, pset *set)
251 elem = pset_find(set, &key, op->code);
255 elem = obstack_alloc(&status->cnts, sizeof(*elem));
257 /* clear new counter */
258 opt_clear_entry(elem);
262 return pset_insert(set, elem, op->code);
266 * clears all counter in a block_entry_t
268 static void block_clear_entry(block_entry_t *elem)
270 cnt_clr(&elem->cnt_nodes);
271 cnt_clr(&elem->cnt_edges);
272 cnt_clr(&elem->cnt_in_edges);
273 cnt_clr(&elem->cnt_out_edges);
277 * Returns the associates block_entry_t for an block
279 static block_entry_t *block_get_entry(long block_nr, pset *set)
284 key.block_nr = block_nr;
286 elem = pset_find(set, &key, block_nr);
290 elem = obstack_alloc(&status->cnts, sizeof(*elem));
292 /* clear new counter */
293 block_clear_entry(elem);
295 elem->block_nr = block_nr;
297 return pset_insert(set, elem, block_nr);
302 * Returns the ir_op for an IR-node,
303 * handles special cases and return pseudo op codes
305 static ir_op *stat_get_irn_op(ir_node *node)
307 ir_op *op = get_irn_op(node);
309 if (op->code == iro_Phi && get_irn_arity(node) == 0) {
310 /* special case, a Phi0 node, count on extra counter */
311 op = status->op_Phi0;
313 else if (op->code == iro_Phi && get_irn_mode(node) == mode_M) {
314 /* special case, a Memory Phi node, count on extra counter */
315 op = status->op_PhiM;
317 else if (op->code == iro_Mul &&
318 (get_irn_op(get_Mul_left(node)) == op_Const || get_irn_op(get_Mul_right(node)) == op_Const)) {
319 /* special case, a Multiply by a const, count on extra counter */
320 op = status->op_MulC ? status->op_MulC : op_Mul;
322 else if (op->code == iro_Div && get_irn_op(get_Div_right(node)) == op_Const) {
323 /* special case, a division by a const, count on extra counter */
324 op = status->op_DivC ? status->op_DivC : op_Div;
326 else if (op->code == iro_Mod && get_irn_op(get_Mod_right(node)) == op_Const) {
327 /* special case, a module by a const, count on extra counter */
328 op = status->op_ModC ? status->op_ModC : op_Mod;
330 else if (op->code == iro_DivMod && get_irn_op(get_DivMod_right(node)) == op_Const) {
331 /* special case, a division/modulo by a const, count on extra counter */
332 op = status->op_DivModC ? status->op_DivModC : op_DivMod;
339 * update the block counter
341 static void count_block_info(ir_node *node, graph_entry_t *graph)
343 ir_op *op = get_irn_op(node);
345 block_entry_t *b_entry;
348 /* check for block */
349 if (op == op_Block) {
350 arity = get_irn_arity(node);
351 b_entry = block_get_entry(get_irn_node_nr(node), graph->block_hash);
353 /* count all incoming edges */
354 for (i = 0; i < arity; ++i) {
355 ir_node *pred = get_irn_n(node, i);
356 ir_node *other_block = get_nodes_block(pred);
357 block_entry_t *b_entry_other = block_get_entry(get_irn_node_nr(other_block), graph->block_hash);
359 cnt_inc(&b_entry->cnt_in_edges); /* an edge coming from another block */
360 cnt_inc(&b_entry_other->cnt_out_edges);
365 block = get_nodes_block(node);
366 b_entry = block_get_entry(get_irn_node_nr(block), graph->block_hash);
368 /* we have a new nodes */
369 cnt_inc(&b_entry->cnt_nodes);
371 arity = get_irn_arity(node);
373 for (i = 0; i < arity; ++i) {
374 ir_node *pred = get_irn_n(node, i);
375 ir_node *other_block;
377 if (get_irn_op(pred) == op_Block)
380 other_block = get_nodes_block(pred);
382 if (other_block == block)
383 cnt_inc(&b_entry->cnt_edges); /* a in block edge */
385 block_entry_t *b_entry_other = block_get_entry(get_irn_node_nr(other_block), graph->block_hash);
387 cnt_inc(&b_entry->cnt_in_edges); /* an edge coming from another block */
388 cnt_inc(&b_entry_other->cnt_out_edges);
394 * update info on calls
396 static void update_call_stat(ir_node *call, graph_entry_t *graph)
398 ir_node *block = get_nodes_block(call);
399 ir_node *ptr = get_Call_ptr(call);
403 * If the block is bad, the whole subgraph will colabse later
404 * so do not count this call.
405 * This happens in dead code
410 cnt_inc(&graph->cnt_all_calls);
412 /* found a call, is not a leaf function */
415 if (get_irn_op(ptr) == op_SymConst) {
416 if (get_SymConst_kind(ptr) == symconst_addr_ent) {
417 /* ok, we seems to know the entity */
418 ent = get_SymConst_entity(ptr);
420 if (get_entity_irg(ent) == graph->irg)
421 graph->is_recursive = 1;
426 cnt_inc(&graph->cnt_indirect_calls);
429 /* check, if it's a chain-call: Then, the call-block
430 * must dominate the end block. */
432 ir_node *curr = get_irg_end_block(graph->irg);
433 int depth = get_Block_dom_depth(block);
435 for (; curr != block && get_Block_dom_depth(curr) > depth;) {
436 curr = get_Block_idom(curr);
438 if (! curr || is_no_Block(curr))
443 graph->is_chain_call = 0;
448 * walker for reachable nodes count
450 static void update_node_stat(ir_node *node, void *env)
452 graph_entry_t *graph = env;
455 ir_op *op = stat_get_irn_op(node);
456 int arity = get_irn_arity(node);
458 entry = opcode_get_entry(op, graph->opcode_hash);
460 cnt_inc(&entry->cnt_alive);
461 cnt_add_i(&graph->cnt_edges, arity);
463 /* count block edges */
464 count_block_info(node, graph);
466 /* check for properties that depends on calls like recursion/leaf/indirect call */
467 if (get_irn_op(node) == op_Call)
468 update_call_stat(node, graph);
472 * get the current address mark
474 static unsigned get_adr_mark(graph_entry_t *graph, ir_node *node)
476 address_mark_entry_t *value = set_find(graph->address_mark, &node, sizeof(*value), HASH_PTR(node));
478 return value ? value->mark : 0;
482 * set the current address mark
484 static void set_adr_mark(graph_entry_t *graph, ir_node *node, unsigned val)
486 address_mark_entry_t *value = set_insert(graph->address_mark, &node, sizeof(*value), HASH_PTR(node));
492 * a vcg attribute hook
494 static int stat_adr_mark_hook(FILE *F, ir_node *n)
496 ir_graph *irg = get_irn_irg(n);
497 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
498 unsigned mark = get_adr_mark(graph, n);
500 if (mark & MARK_ADDRESS_CALC)
501 fprintf(F, "color: purple");
502 else if ((mark & (MARK_REF_ADR | MARK_REF_NON_ADR)) == MARK_REF_ADR)
503 fprintf(F, "color: lightpurple");
504 else if ((mark & (MARK_REF_ADR | MARK_REF_NON_ADR)) == (MARK_REF_ADR|MARK_REF_NON_ADR))
505 fprintf(F, "color: lightblue");
509 /* I know the color! */
514 * walker that marks every node that is an address calculation
516 * predecessor nodes must be visited first. We ensure this by
517 * calling in in the post of an outs walk. This should work even in cycles,
518 * while the pre in a normal walk will not.
520 static void mark_address_calc(ir_node *node, void *env)
522 graph_entry_t *graph = env;
523 ir_mode *mode = get_irn_mode(node);
525 unsigned mark_preds = MARK_REF_NON_ADR;
527 if (! mode_is_numP(mode))
530 if (mode_is_reference(mode)) {
531 /* a reference is calculated here, we are sure */
532 set_adr_mark(graph, node, MARK_ADDRESS_CALC);
534 mark_preds = MARK_REF_ADR;
537 unsigned mark = get_adr_mark(graph, node);
539 if ((mark & (MARK_REF_ADR | MARK_REF_NON_ADR)) == MARK_REF_ADR) {
541 * this node has not an reference mode, but is only
542 * referenced by address calculations
544 mark_preds = MARK_REF_ADR;
548 /* makr all predecessors */
549 for (i = 0, n = get_irn_arity(node); i < n; ++i) {
550 ir_node *pred = get_irn_n(node, i);
552 set_adr_mark(graph, pred, get_adr_mark(graph, pred) | mark_preds);
557 * called for every graph when the graph is either deleted or stat_finish()
558 * is called, must recalculate all statistic info
560 static void update_graph_stat(graph_entry_t *global, graph_entry_t *graph)
564 /* clear first the alive counter in the graph */
565 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
566 cnt_clr(&entry->cnt_alive);
569 /* set pessimistic values */
571 graph->is_recursive = 0;
572 graph->is_chain_call = 1;
574 /* we need dominator info */
575 if (graph->irg != get_const_code_irg())
576 if (get_irg_dom_state(graph->irg) != dom_consistent)
577 compute_doms(graph->irg);
579 /* count the nodes in the graph */
580 irg_walk_graph(graph->irg, update_node_stat, NULL, graph);
583 entry = opcode_get_entry(op_Call, graph->opcode_hash);
585 /* check if we have more than 1 call */
586 if (cnt_gt(entry->cnt_alive, 1))
587 graph->is_chain_call = 0;
590 /* recursive functions are never chain calls, leafs don't have calls */
591 if (graph->is_recursive || graph->is_leaf)
592 graph->is_chain_call = 0;
594 /* assume we walk every graph only ONCE, we could sum here the global count */
595 for (entry = pset_first(graph->opcode_hash); entry; entry = pset_next(graph->opcode_hash)) {
596 node_entry_t *g_entry = opcode_get_entry(entry->op, global->opcode_hash);
598 /* update the node counter */
599 cnt_add(&g_entry->cnt_alive, &entry->cnt_alive);
602 /* update the edge counter */
603 cnt_add(&global->cnt_edges, &graph->cnt_edges);
605 /* count the number of address calculation */
606 if (graph->irg != get_const_code_irg()) {
607 ir_graph *rem = current_ir_graph;
609 if (get_irg_outs_state(graph->irg) != outs_consistent)
610 compute_outs(graph->irg);
612 /* Must be done an the outs graph */
613 current_ir_graph = graph->irg;
614 irg_out_walk(get_irg_start(graph->irg), NULL, mark_address_calc, graph);
615 current_ir_graph = rem;
618 set_dump_node_vcgattr_hook(stat_adr_mark_hook);
619 dump_ir_block_graph(graph->irg, "-adr");
620 set_dump_node_vcgattr_hook(NULL);
628 static void stat_register_dumper(const dumper_t *dumper)
630 dumper_t *p = malloc(sizeof(*p));
635 p->next = status->dumper;
640 /* FIXME: memory leak */
646 static void stat_dump_graph(graph_entry_t *entry)
650 for (dumper = status->dumper; dumper; dumper = dumper->next) {
651 if (dumper->dump_graph)
652 dumper->dump_graph(dumper, entry);
657 * initialise the dumper
659 static void stat_dump_init(const char *name)
663 for (dumper = status->dumper; dumper; dumper = dumper->next) {
665 dumper->init(dumper, name);
672 static void stat_dump_finish(void)
676 for (dumper = status->dumper; dumper; dumper = dumper->next) {
678 dumper->finish(dumper);
682 /* ---------------------------------------------------------------------- */
685 * helper: get an ir_op from an opcode
687 ir_op *stat_get_op_from_opcode(opcode code)
689 return opcode_find_entry(code, status->ir_op_hash);
692 /* initialize the statistics module. */
693 void init_stat(unsigned enable_options)
695 #define X(a) a, sizeof(a)-1
697 /* enable statistics */
698 status->enable = enable_options & FIRMSTAT_ENABLED;
700 if (! status->enable)
703 obstack_init(&status->cnts);
705 /* create the hash-tables */
706 status->irg_hash = new_pset(graph_cmp, 8);
707 status->ir_op_hash = new_pset(opcode_cmp_2, 1);
709 status->op_Phi0 = &_op_Phi0;
710 status->op_PhiM = &_op_PhiM;
712 if (enable_options & FIRMSTAT_COUNT_STRONG_OP) {
713 /* build the pseudo-ops */
714 _op_Phi0.code = get_next_ir_opcode();
715 _op_Phi0.name = new_id_from_chars(X("Phi0"));
717 _op_PhiM.code = get_next_ir_opcode();
718 _op_PhiM.name = new_id_from_chars(X("PhiM"));
720 _op_MulC.code = get_next_ir_opcode();
721 _op_MulC.name = new_id_from_chars(X("MulC"));
723 _op_DivC.code = get_next_ir_opcode();
724 _op_DivC.name = new_id_from_chars(X("DivC"));
726 _op_ModC.code = get_next_ir_opcode();
727 _op_ModC.name = new_id_from_chars(X("ModC"));
729 _op_DivModC.code = get_next_ir_opcode();
730 _op_DivModC.name = new_id_from_chars(X("DivModC"));
732 status->op_MulC = &_op_MulC;
733 status->op_DivC = &_op_DivC;
734 status->op_ModC = &_op_ModC;
735 status->op_DivModC = &_op_DivModC;
738 status->op_MulC = NULL;
739 status->op_DivC = NULL;
740 status->op_ModC = NULL;
741 status->op_DivModC = NULL;
744 /* register the dumper */
745 stat_register_dumper(&simple_dumper);
747 if (enable_options & FIRMSTAT_CSV_OUTPUT)
748 stat_register_dumper(&csv_dumper);
750 /* initialize the pattern hash */
751 stat_init_pattern_history(enable_options & FIRMSTAT_PATTERN_ENABLED);
755 /* A new IR op is registered. */
756 void stat_new_ir_op(const ir_op *op)
758 if (! status->enable)
763 graph_entry_t *graph = graph_get_entry(NULL, status->irg_hash);
765 /* execute for side effect :-) */
766 opcode_get_entry(op, graph->opcode_hash);
768 pset_insert(status->ir_op_hash, op, op->code);
773 /* An IR op is freed. */
774 void stat_free_ir_op(const ir_op *op)
776 if (! status->enable)
785 /* A new node is created. */
786 void stat_new_node(ir_node *node)
788 if (! status->enable)
791 /* do NOT count during dead node elimination */
792 if (status->in_dead_node_elim > 0)
798 graph_entry_t *graph;
799 ir_op *op = stat_get_irn_op(node);
801 /* increase global value */
802 graph = graph_get_entry(NULL, status->irg_hash);
803 entry = opcode_get_entry(op, graph->opcode_hash);
804 cnt_inc(&entry->new_node);
806 /* increase local value */
807 graph = graph_get_entry(current_ir_graph, status->irg_hash);
808 entry = opcode_get_entry(op, graph->opcode_hash);
809 cnt_inc(&entry->new_node);
814 /* A node is changed into a Id node */
815 void stat_turn_into_id(ir_node *node)
817 if (! status->enable)
823 graph_entry_t *graph;
824 ir_op *op = stat_get_irn_op(node);
826 /* increase global value */
827 graph = graph_get_entry(NULL, status->irg_hash);
828 entry = opcode_get_entry(op, graph->opcode_hash);
829 cnt_inc(&entry->into_Id);
831 /* increase local value */
832 graph = graph_get_entry(current_ir_graph, status->irg_hash);
833 entry = opcode_get_entry(op, graph->opcode_hash);
834 cnt_inc(&entry->into_Id);
839 /* A new graph was created */
840 void stat_new_graph(ir_graph *irg, entity *ent)
842 if (! status->enable)
847 /* execute for side effect :-) */
848 graph_entry_t * graph = graph_get_entry(irg, status->irg_hash);
851 graph->is_deleted = 0;
853 graph->is_recursive = 0;
854 graph->is_chain_call = 0;
860 * A graph will be deleted
862 void stat_free_graph(ir_graph *irg)
864 if (! status->enable)
869 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
870 graph_entry_t *global = graph_get_entry(NULL, status->irg_hash);
872 graph->is_deleted = 1;
874 /* count the nodes of the graph yet, it will be destroyed later */
875 update_graph_stat(global, graph);
877 /* count the DAG's */
878 //count_dags_in_graph(global, graph);
880 /* calculate the pattern */
881 stat_calc_pattern_history(irg);
887 * A walk over a graph is initiated. Do not count walks from statistic code.
889 void stat_irg_walk(ir_graph *irg, void *pre, void *post)
891 if (! status->enable)
896 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
898 cnt_inc(&graph->cnt_walked);
904 * A walk over a graph in block-wise order is initiated. Do not count walks from statistic code.
906 void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post)
908 /* for now, do NOT differentiate between blockwise and normal */
909 stat_irg_walk(irg, pre, post);
913 * A walk over the graph's blocks is initiated. Do not count walks from statistic code.
915 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post)
917 if (! status->enable)
922 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
924 cnt_inc(&graph->cnt_walked_blocks);
930 * called for every node that is removed due to an optimization
932 static void removed_due_opt(ir_node *n, pset *set)
934 ir_op *op = stat_get_irn_op(n);
935 opt_entry_t *entry = opt_get_entry(op, set);
937 /* increase global value */
938 cnt_inc(&entry->count);
942 * Some nodes were optimized into some others due to an optimization
944 void stat_merge_nodes(
945 ir_node **new_node_array, int new_num_entries,
946 ir_node **old_node_array, int old_num_entries,
949 if (! status->enable)
955 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
957 if (status->reassoc_run)
958 opt = STAT_OPT_REASSOC;
960 for (i = 0; i < old_num_entries; ++i) {
961 for (j = 0; j < new_num_entries; ++j)
962 if (old_node_array[i] == new_node_array[j])
965 /* nodes might be in new and old, these are NOT removed */
966 if (j >= new_num_entries) {
967 removed_due_opt(old_node_array[i], graph->opt_hash[opt]);
975 * reassociation started/stopped.
977 void stat_reassociate(int flag)
979 if (! status->enable)
984 status->reassoc_run = flag;
990 * A node was lowered into other nodes
992 void stat_lower(ir_node *node)
994 if (! status->enable)
999 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1001 removed_due_opt(node, graph->opt_hash[STAT_LOWERED]);
1007 * A graph was inlined
1009 void stat_inline(ir_node *call, ir_graph *called_irg)
1011 if (! status->enable)
1016 ir_graph *irg = get_irn_irg(call);
1017 graph_entry_t *i_graph = graph_get_entry(called_irg, status->irg_hash);
1018 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
1020 cnt_inc(&graph->cnt_got_inlined);
1021 cnt_inc(&i_graph->cnt_was_inlined);
1027 * A graph with tail-recursions was optimized.
1029 void stat_tail_rec(ir_graph *irg)
1031 if (! status->enable)
1041 * Strength reduction was performed on an iteration variable.
1043 void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp)
1045 if (! status->enable)
1050 graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
1051 cnt_inc(&graph->cnt_strength_red);
1053 removed_due_opt(strong, graph->opt_hash[STAT_OPT_STRENGTH_RED]);
1059 * Start the dead node elimination.
1061 void stat_dead_node_elim_start(ir_graph *irg)
1063 if (! status->enable)
1066 ++status->in_dead_node_elim;
1070 * Stops the dead node elimination.
1072 void stat_dead_node_elim_stop(ir_graph *irg)
1074 if (! status->enable)
1077 --status->in_dead_node_elim;
1081 * A multiply was replaced by a series of Shifts/Adds/Subs
1083 void stat_arch_dep_replace_mul_with_shifts(ir_node *mul)
1085 if (! status->enable)
1090 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1091 removed_due_opt(mul, graph->opt_hash[STAT_OPT_ARCH_DEP]);
1097 * A division was replaced by a series of Shifts/Muls
1099 void stat_arch_dep_replace_div_by_const(ir_node *div)
1101 if (! status->enable)
1106 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1107 removed_due_opt(div, graph->opt_hash[STAT_OPT_ARCH_DEP]);
1113 * A modulo was replaced by a series of Shifts/Muls
1115 void stat_arch_dep_replace_mod_by_const(ir_node *mod)
1117 if (! status->enable)
1122 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1123 removed_due_opt(mod, graph->opt_hash[STAT_OPT_ARCH_DEP]);
1129 * A DivMod was replaced by a series of Shifts/Muls
1131 void stat_arch_dep_replace_DivMod_by_const(ir_node *divmod)
1133 if (! status->enable)
1138 graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
1139 removed_due_opt(divmod, graph->opt_hash[STAT_OPT_ARCH_DEP]);
1144 /* Finish the statistics */
1145 void stat_finish(const char *name)
1147 if (! status->enable)
1152 graph_entry_t *entry;
1153 graph_entry_t *global = graph_get_entry(NULL, status->irg_hash);
1155 stat_dump_init(name);
1157 /* dump per graph */
1158 for (entry = pset_first(status->irg_hash); entry; entry = pset_next(status->irg_hash)) {
1160 if (entry->irg == NULL) {
1161 /* special entry for the global count */
1165 if (! entry->is_deleted) {
1166 /* the graph is still alive, count the nodes on it */
1167 update_graph_stat(global, entry);
1169 /* count the DAG's */
1170 //count_dags_in_graph(global, entry);
1172 /* calculate the pattern */
1173 stat_calc_pattern_history(entry->irg);
1176 stat_dump_graph(entry);
1178 /* clear the counter that are not accumulated */
1179 graph_clear_entry(entry, 0);
1183 stat_dump_graph(global);
1186 stat_finish_pattern_history();
1188 /* clear the global counter here */
1190 node_entry_t *entry;
1192 for (entry = pset_first(global->opcode_hash); entry; entry = pset_next(global->opcode_hash)) {
1193 opcode_clear_entry(entry);
1195 /* clear all global counter */
1196 graph_clear_entry(global, 1);
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_reassociate(int start) {}
1238 void stat_lower(ir_node *node) {}
1240 void stat_inline(ir_node *call, ir_graph *irg) {}
1242 void stat_tail_rec(ir_graph *irg) {}
1244 void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp) {}
1246 void stat_dead_node_elim_start(ir_graph *irg) {}
1248 void stat_dead_node_elim_stop(ir_graph *irg) {}
1250 void stat_arch_dep_replace_mul_with_shifts(ir_node *mul) {}
1252 void stat_arch_dep_replace_div_by_const(ir_node *div) {}
1254 void stat_arch_dep_replace_mod_by_const(ir_node *mod) {}
1256 void stat_arch_dep_replace_DivMod_by_const(ir_node *divmod) {}