#include "irprog.h"
#include "irmode_t.h"
-#include "bechordal.h"
+#include "bera.h"
#include "phistat.h"
#define MAX_ARITY 10
#define MAX_CLS_SIZE 10
+/**
+ * For an explanation of these values see phi_stat_dump_pretty
+ */
enum vals_t {
I_ARG = 0,
I_CONST,
static int curr_vals[ASIZE];
-/**
- * Resets the array holding the data
- */
void phi_stat_reset(void) {
int i;
curr_vals[I_CLS_SIZE_S + size]++;
/* get an array of all members for double iterating */
- members = (ir_node **) malloc(size * sizeof(ir_node*));
- for (i=0, p = (ir_node *)pset_first(pc); p; p = (ir_node *)pset_next(pc))
+ members = malloc(size * sizeof(*members));
+ for (i = 0, p = pset_first(pc); p; p = pset_next(pc))
members[i++] = p;
assert(i == size);
doit = 1;
for (o = i+1; o < size; ++o) {
curr_vals[I_PAIRS]++;
- if (phi_ops_interfere(members[i], members[o])) {
+ if (values_interfere(members[i], members[o])) {
sth_interfered = 1;
curr_vals[I_PAIRSI]++;
if (doit) {
}
-/**
- * Collect all stat data
- */
void phi_stat_collect(ir_graph *irg, pset *all_phi_nodes, pset *all_phi_classes) {
ir_node *n;
pset *pc;
irg_walk_graph(irg, stat_walker, NULL, NULL);
curr_vals[I_BLOCKS] -= 2;
- for (n = (ir_node *)pset_first(all_phi_nodes); n; n = (ir_node *)pset_next(all_phi_nodes))
+ for (n = pset_first(all_phi_nodes); n; n = pset_next(all_phi_nodes))
phi_node_stat(n);
- for (pc = (pset *)pset_first(all_phi_classes); pc; pc = (pset *)pset_next(all_phi_classes))
+ for (pc = pset_first(all_phi_classes); pc; pc = pset_next(all_phi_classes))
phi_class_stat(pc);
}
int i;
if (! (file = fopen(filename, "wt"))) {
- fprintf(stderr, "Cannot open file for writing\n");
+ fprintf(stderr, "Cannot open file for writing: %s\n", filename);
return;
}
for (i = 0; i < ASIZE; i++) {
if (i >= I_ARITY_S && i <= I_ARITY_E)
- fprintf(file, "%i %i\n", stat[i], stat[I_ALL_NODES]);
+ fprintf(file, "%i %i\n", stat[i], stat[I_PHIS]);
+ else if (i >= I_CLS_SIZE_S && i <= I_CLS_SIZE_E)
+ fprintf(file, "%i %i\n", stat[i], stat[I_PHICLS]);
else
fprintf(file, "%i\n", stat[i]);
}
}
-/**
- * Updates a cumulative file with the current values.
- */
-static void update_file(char *filename) {
+void phi_stat_update(char *filename) {
int i;
FILE *all;
int vals[ASIZE];
+ if (!filename)
+ return;
+
/* read in */
all = fopen(filename, "rt");
if (all) {
for (i = 0; i < ASIZE; i++) {
if (i >= I_ARITY_S && i <= I_ARITY_E)
- fscanf(all, "%i %i\n", &vals[i], &vals[I_ALL_NODES]);
+ fscanf(all, "%i %i\n", &vals[i], &vals[I_PHIS]);
+ else if (i >= I_CLS_SIZE_S && i <= I_CLS_SIZE_E)
+ fscanf(all, "%i %i\n", &vals[i], &vals[I_PHICLS]);
else
fscanf(all, "%i\n", &vals[i]);
}
}
-/**
- * Dumps the current contents of the values array to a file.
- * Updates a cumulative file.
- */
-void phi_stat_dump(char *filename, char *cum_filename) {
+void phi_stat_dump(char *filename) {
if (filename)
dump_file(filename, curr_vals);
- if (cum_filename)
- update_file(cum_filename);
}
-/**
- * Dumps the current contents of the values array
- * and annotations to a file.
- */
void phi_stat_dump_pretty(char *filename) {
int i;
FILE *out;
if (! (out = fopen(filename, "wt"))) {
- fprintf(stderr, "Cannot open file for writing\n");
+ fprintf(stderr, "Cannot open file for writing: %s\n", filename);
return;
}