Commit fc2d3435 authored by Christian Würdig's avatar Christian Würdig
Browse files

added reg pressure statitics

parent 3fd73bc8
......@@ -55,6 +55,7 @@
#include "bessadestr.h"
#include "beabi.h"
#include "belower.h"
#include "bestat.h"
#define DUMP_INITIAL (1 << 0)
#define DUMP_ABI (1 << 1)
......@@ -338,6 +339,9 @@ static void be_main_loop(FILE *file_handle)
/* Verify the schedule */
sched_verify_irg(irg);
/* do some statistics */
be_do_stat_reg_pressure(&birg);
/* Do register allocation */
arch_code_generator_before_ra(birg.cg);
ra->allocate(&birg);
......
#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"
/**
* Compare two live entries.
*/
static int cmp_irn_live(const void *a, const void *b)
{
const irn_live_t *p = a;
const irn_live_t *q = b;
return !(p->block == q->block && p->irn == q->irn);
}
/**
* 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;
pset *live_nodes = new_pset(cmp_irn_live, 64);
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));
ir_printf("max regpressure %+F: %d\n", block, max_live);
}
}
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);
}
#ifndef _BESTAT_H_
#define _BESTAT_H_
#include "be_t.h"
/**
* Collects statistics information about register pressure.
* @param birg The be irg object containing the irg
*/
void be_do_stat_reg_pressure(be_irg_t *birg);
#endif /* _BESTAT_H_ */
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment