bestat.c 1.71 KB
Newer Older
1
2
3
4
5
6
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef FIRM_STATISTICS

7
8
9
10
11
12
13
14
15
16
17
18
#include "irnode_t.h"
#include "irprintf.h"
#include "irgwalk.h"
#include "irhooks.h"
#include "dbginfo_t.h"
#include "firmstat.h"
#include "ident.h"

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

19
20
21
#undef MIN
#define MIN(a, b) (a < b ? a : b)

22
23
24
25
26
27
28
29
30
31
32
/**
 * 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;
33
		pset     *live_nodes = pset_new_ptr(64);
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
		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;
		}

		hook_be_block_regpressure(block, birg->irg, max_live, new_id_from_str(cls->name));
	}
}

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);
}
56
57
58
59
60

/**
 * Notify statistic module about amount of ready nodes.
 */
void be_do_stat_sched_ready(ir_node *block, nodeset *ready_set) {
61
	hook_be_block_sched_ready(block, get_irn_irg(block), MIN(nodeset_count(ready_set), 5));
62
}
63
64
65
66
67
68
69

#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 */