#endif
#include <string.h>
-#include "phiclass_t.h"
+#include "irgraph.h"
#include "irprog.h"
+#include "phiclass_t.h"
#include "becopyopt.h"
#include "becopystat.h"
#include "xmalloc.h"
#ifdef DO_STAT
+#define DEBUG_LVL 0 //SET_LEVEL_1
+static firm_dbg_module_t *dbg = NULL;
+
static pset *all_phi_nodes;
static pset *all_phi_classes;
static pset *all_copy_nodes;
void copystat_init(void) {
+ dbg = firm_dbg_register("ir.be.copystat");
+ firm_dbg_set_mask(dbg, DEBUG_LVL);
+
all_phi_nodes = pset_new_ptr_default();
all_phi_classes = pset_new_ptr_default();
all_copy_nodes = pset_new_ptr_default();
phi_class_init();
-
}
void copystat_reset(void) {
int i;
for (i = 0; i < ASIZE; ++i)
curr_vals[i] = 0;
+ del_pset(all_phi_nodes);
+ del_pset(all_phi_classes);
+ del_pset(all_copy_nodes);
+ all_phi_nodes = pset_new_ptr_default();
+ all_phi_classes = pset_new_ptr_default();
+ all_copy_nodes = pset_new_ptr_default();
}
/**
* Collect general data
*/
-static void stat_walker(ir_node *node, void *env) {
+static void irg_stat_walker(ir_node *node, void *env) {
+ arch_env_t *arch_env = env;
curr_vals[I_ALL_NODES]++; /* count all nodes */
if (is_Block(node)) /* count all blocks */
if (is_Phi(node)) /* collect phis */
pset_insert_ptr(all_phi_nodes, node);
- if (is_Copy(node))
+ if (is_Copy(arch_env, node))
pset_insert_ptr(all_copy_nodes, node);
}
+void copystat_collect_irg(ir_graph *irg, arch_env_t *arch_env) {
+ irg_walk_graph(irg, irg_stat_walker, NULL, arch_env);
+ curr_vals[I_BLOCKS] -= 2; /* substract 2 for start and end block */
+ all_phi_classes = phi_class_compute_by_phis(all_phi_nodes);
+}
+
/**
* Collect phi node data
*/
if (phi != arg) {
curr_vals[I_COPIES_MAX]++; /* if arg!=phi this is a possible copy */
- if (nodes_interfere(chordal_env, phi, arg))
+ if (nodes_interfere(chordal_env, phi, arg)) {
+ DBG((dbg, LEVEL_1, "%e -- In Block %N: %n %N %n %N\n", get_irg_entity(chordal_env->irg), get_nodes_block(phi), phi, phi, arg, arg));
curr_vals[I_COPIES_IF]++;
+ }
}
if (arg == phi) {
continue;
}
- block_of_arg = get_nodes_block(arg);
+ block_of_arg = get_Block_cfgpred_block(get_nodes_block(phi), i);
block_ith_pred = get_nodes_block(get_irn_n(get_nodes_block(phi), i));
if (block_of_arg == block_ith_pred) {
curr_vals[I_PHI_ARG_PRED]++;
* Collect phi class data
*/
static void stat_phi_class(be_chordal_env_t *chordal_env, pset *pc) {
- int i, o, size, if_free;
+ int i, o, size, if_free, phis;
ir_node **members, *p;
/* phi class count */
members[i++] = p;
assert(i == size);
+ /* determine number of phis on this class */
+ phis = 0;
+ for (i = 0; i < size-1; ++i)
+ if (is_Phi(members[i]))
+ phis++;
+ if (phis > MAX_CLS_PHIS)
+ curr_vals[I_CLS_PHIS_E]++;
+ else
+ curr_vals[I_CLS_PHIS_S + phis]++;
+
/* determine interference of phi class members */
curr_vals[I_CLS_IF_MAX] += size*(size-1)/2;
if_free = 1;
xfree(members);
}
-void copystat_collect_irg(ir_graph *irg) {
- irg_walk_graph(irg, stat_walker, NULL, NULL);
- curr_vals[I_BLOCKS] -= 2; /* substract 2 for start and end block */
- all_phi_classes = phi_class_compute_by_phis(all_phi_nodes);
-}
-
#define is_curr_reg_class(irn) (arch_get_irn_reg_class(chordal_env->arch_env, irn, arch_pos_make_out(0)) == chordal_env->cls)
void copystat_collect_cls(be_chordal_env_t *chordal_env) {
void copystat_dump(ir_graph *irg) {
int i;
char buf[1024];
+ FILE *out;
snprintf(buf, sizeof(buf), "%s__%s", get_irp_prog_name(), get_entity_name(get_irg_entity(irg)));
- FILE *out = ffopen(buf, "stat", "wt");
+ out = ffopen(buf, "stat", "wt");
fprintf(out, "%s\n", get_irp_prog_name());
for (i = 0; i < ASIZE; i++) {
void copystat_dump_pretty(ir_graph *irg) {
int i;
char buf[1024];
+ FILE *out;
snprintf(buf, sizeof(buf), "%s__%s", get_irp_prog_name(), get_entity_name(get_irg_entity(irg)));
- FILE *out = ffopen(buf, "pstat", "wt");
+ out = ffopen(buf, "pstat", "wt");
fprintf(out, "Nodes %4d\n", curr_vals[I_ALL_NODES]);
fprintf(out, "Blocks %4d\n", curr_vals[I_BLOCKS]);
fprintf(out, "... sizes\n");
for (i = I_CLS_SIZE_S; i<=I_CLS_SIZE_E; i++)
fprintf(out, " %2i %4d\n", i-I_CLS_SIZE_S, curr_vals[i]);
+ fprintf(out, "... contained phis\n");
+ for (i = I_CLS_PHIS_S; i<=I_CLS_PHIS_E; i++)
+ fprintf(out, " %2i %4d\n", i-I_CLS_PHIS_S, curr_vals[i]);
fprintf(out, "\nILP stat\n");
fprintf(out, " Time %8d\n", curr_vals[I_ILP_TIME]);