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.
11 #include "firmstat_t.h"
14 static stat_info_t *status;
17 * calculated the dual logarithmus of |value|
19 static unsigned log2(long value) {
49 * update info on Consts
51 * @param node The Const node
52 * @param graph The graph entry containing the call
54 void stat_update_const(stat_info_t *status, ir_node *node, graph_entry_t *graph)
56 ir_mode *mode = get_irn_mode(node);
60 /* we handle integer modes only here */
61 if (! mode_is_int(mode)) {
62 cnt_inc(&status->const_info.others);
66 tv = get_Const_tarval(node);
67 bits = log2(get_tarval_long(tv));
69 if (bits > ARR_SIZE(status->const_info.bits_count))
70 bits = ARR_SIZE(status->const_info.bits_count);
72 cnt_inc(&status->const_info.bits_count[bits]);
75 /* clears the const statistics for a new snapshot */
76 void stat_const_clear(stat_info_t *status)
80 for (i = 0; i < ARR_SIZE(status->const_info.bits_count); ++i)
81 cnt_clr(&status->const_info.bits_count[i]);
82 cnt_clr(&status->const_info.others);
85 /* initialize the Const statistic. */
86 void stat_init_const_cnt(stat_info_t *status)