bestat.c 1.78 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
3
4
5
/**
 * This file calls the corresponding statistic functions for
 * some backend statistics.
 * $Id$
 */
6
7
8
9
10
11
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef FIRM_STATISTICS

12
13
14
15
16
#include "irnode_t.h"
#include "irprintf.h"
#include "irgwalk.h"
#include "irhooks.h"
#include "dbginfo_t.h"
17
#include "firmstat_t.h"
18
19
20
21
22

#include "bestat.h"
#include "belive_t.h"
#include "besched.h"

23
24
25
#undef MIN
#define MIN(a, b) (a < b ? a : b)

26
27
28
29
30
31
32
33
34
35
36
/**
 * Collect reg pressure statistics per block and per class.
 */
static void stat_reg_pressure_block(ir_node *block, void *env) {
	be_irg_t         *birg = env;
	const arch_env_t *aenv = birg->main_env->arch_env;
	int i, n = arch_isa_get_n_reg_class(aenv->isa);

	for (i = 0; i < n; i++) {
		const arch_register_class_t *cls = arch_isa_get_reg_class(aenv->isa, i);
		ir_node  *irn;
37
		pset     *live_nodes = pset_new_ptr(64);
38
39
40
41
42
43
44
45
46
47
48
49
50
51
		int       max_live;

		live_nodes = be_liveness_end_of_block(aenv, cls, block, live_nodes);
		max_live   = pset_count(live_nodes);

		sched_foreach_reverse(block, irn) {
			int cnt;

			live_nodes = be_liveness_transfer(aenv, cls, irn, live_nodes);
			cnt        = pset_count(live_nodes);

			max_live = cnt < max_live ? max_live : cnt;
		}

Christian Würdig's avatar
Christian Würdig committed
52
		stat_be_block_regpressure(birg->irg, block, max_live, cls->name);
53
54
55
56
57
58
59
	}
}

void be_do_stat_reg_pressure(be_irg_t *birg) {
	/* Collect register pressure information for each block */
	irg_block_walk_graph(birg->irg, stat_reg_pressure_block, NULL, birg);
}
60
61
62
63
64

/**
 * Notify statistic module about amount of ready nodes.
 */
void be_do_stat_sched_ready(ir_node *block, nodeset *ready_set) {
65
	stat_be_block_sched_ready(get_irn_irg(block), block, nodeset_count(ready_set));
66
}
67
68
69
70
71
72
73

#else

void (be_do_stat_reg_pressure)(be_irg_t *birg) {}
void (be_do_stat_sched_ready)(ir_node *block, nodeset *ready_set) {}

#endif /* FIRM_STATISTICS */