return states[flags & 7];
}
-void be_dump_liveness_block(void *context, FILE *F, const ir_node *bl)
+void be_dump_liveness_block(be_lv_t *lv, FILE *F, const ir_node *bl)
{
- if (is_Block(bl)) {
- be_lv_t *lv = (be_lv_t*)context;
- be_lv_info_t *info = ir_nodehashmap_get(be_lv_info_t, &lv->map, bl);
-
- fprintf(F, "liveness:\n");
- if (info != NULL) {
- unsigned n = info[0].head.n_members;
- unsigned i;
-
- for (i = 0; i < n; ++i) {
- be_lv_info_node_t *n = &info[i+1].node;
- ir_fprintf(F, "%s %+F\n", lv_flags_to_str(n->flags), n->node);
- }
+ be_lv_info_t *info = ir_nodehashmap_get(be_lv_info_t, &lv->map, bl);
+
+ fprintf(F, "liveness:\n");
+ if (info != NULL) {
+ unsigned n = info[0].head.n_members;
+ unsigned i;
+
+ for (i = 0; i < n; ++i) {
+ be_lv_info_node_t *n = &info[i+1].node;
+ ir_fprintf(F, "%s %+F\n", lv_flags_to_str(n->flags), n->node);
}
}
}
typedef struct lv_walker_t {
be_lv_t *lv;
- void *data;
+ FILE *out;
} lv_walker_t;
static void lv_dump_block_walker(ir_node *irn, void *data)
lv_walker_t *w = (lv_walker_t*)data;
if (!is_Block(irn))
return;
- be_dump_liveness_block(w->lv, (FILE*)w->data, irn);
+ be_dump_liveness_block(w->lv, w->out, irn);
}
void be_liveness_dump(FILE *F, const be_lv_t *lv)
{
lv_walker_t w;
- w.lv = (be_lv_t *) lv;
- w.data = F;
+ w.lv = (be_lv_t *) lv;
+ w.out = F;
irg_block_walk_graph(lv->irg, lv_dump_block_walker, NULL, &w);
}
/**
* node_info hook that dumps liveness for blocks
*/
-void be_dump_liveness_block(void *context, FILE *F, const ir_node *block);
+void be_dump_liveness_block(be_lv_t *lv, FILE *F, const ir_node *block);
#endif
#include "bearch.h"
#include "benode.h"
#include "besched.h"
+#include "bedump.h"
+#include "belive_t.h"
#include "irgwalk.h"
#include "irnode_t.h"
#include "irdump_t.h"
+#include "irhooks.h"
#include "error.h"
static copy_attr_func old_phi_copy_attr;
be_info_new_node(irg, node);
}
-static bool initialized = false;
+static bool initialized = false;
+static hook_entry_t hook_liveness_info;
+
+static void dump_liveness_info_hook(void *context, FILE *F, const ir_node *node)
+{
+ (void)context;
+ if (!is_Block(node))
+ return;
+ ir_graph *irg = get_irn_irg(node);
+ if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_BACKEND))
+ return;
+
+ be_lv_t *lv = be_get_irg_liveness(irg);
+ if (lv == NULL)
+ return;
+ if (!lv->sets_valid)
+ return;
+
+ be_dump_liveness_block(lv, F, node);
+}
void be_info_init(void)
{
/* phis have register and register requirements now which we want to dump */
assert(op_Phi->ops.dump_node == NULL);
op_Phi->ops.dump_node = be_dump_phi_reg_reqs;
+
+ hook_liveness_info.hook._hook_node_info = dump_liveness_info_hook;
+ register_hook(hook_node_info, &hook_liveness_info);
}
/**
assert(op_Phi->ops.dump_node == be_dump_phi_reg_reqs);
op_Phi->ops.dump_node = NULL;
+
+ unregister_hook(hook_node_info, &hook_liveness_info);
}
#include "belive_t.h"
#include "besched.h"
#include "bemodule.h"
-#include "bedump.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
DEL_ARR_F(nodes);
free(re.visited);
- register_hook(hook_node_info, &lv->hook_info);
be_timer_pop(T_LIVE);
{
if (!lv->sets_valid)
return;
- unregister_hook(hook_node_info, &lv->hook_info);
obstack_free(&lv->obst, NULL);
ir_nodehashmap_destroy(&lv->map);
lv->sets_valid = false;
be_lv_t *lv = XMALLOCZ(be_lv_t);
lv->irg = irg;
- lv->hook_info.context = lv;
- lv->hook_info.hook._hook_node_info = be_dump_liveness_block;
return lv;
}
struct obstack obst;
bool sets_valid;
ir_graph *irg;
- hook_entry_t hook_info;
lv_chk_t *lvc;
};