return !(p->block == q->block && p->irn == q->irn);
}
+static int (*old_dump_block_func)(ir_node *self, FILE *F, dump_reason_t reason) = NULL;
+
+static int dump_block_func(ir_node *self, FILE *F, dump_reason_t reason)
+{
+ switch(reason) {
+ case dump_node_opcode_txt:
+ fprintf(F, get_irn_opname(self));
+ break;
+ case dump_node_mode_txt:
+ fprintf(F, get_irn_modename(self));
+ break;
+ case dump_node_nodeattr_txt:
+ break;
+ case dump_node_info_txt:
+ if(!get_irg_live_info(get_irn_irg(self))->live)
+ return 0;
+
+ fprintf(F, "liveness information:\n");
+ {
+ irn_live_t *li;
+ live_foreach(self, li) {
+ ir_fprintf(F, "%+F", li->irn);
+ if(live_is_in(li))
+ fprintf(F, " in");
+ if(live_is_end(li))
+ fprintf(F, " end");
+ if(live_is_out(li))
+ fprintf(F, " out");
+
+ fprintf(F, "\n");
+ }
+ }
+ }
+
+ return 0;
+}
+
void be_liveness(ir_graph *irg)
{
irg_live_info_t *live_info = get_irg_live_info(irg);
if(live_info->live)
del_set(live_info->live);
- ir_fprintf(stderr, "%F\n", irg);
-
live_info->live = new_set(cmp_irn_live, 8192);
irg_walk_graph(irg, liveness_for_node, NULL, NULL);
+
+ old_dump_block_func = op_Block->ops.dump_node;
+ op_Block->ops.dump_node = dump_block_func;
}
static void dump_liveness_walker(ir_node *bl, void *data)
{
irg_block_walk_graph(irg, dump_liveness_walker, NULL, f);
}
+
+void be_liveness_dumpto(ir_graph *irg, const char *cls_name)
+{
+ FILE *f;
+ char buf[128];
+ ir_snprintf(buf, sizeof(buf), "%F_%s-live.txt", irg, cls_name);
+ if((f = fopen(buf, "wt")) != NULL) {
+ be_liveness_dump(irg, f);
+ fclose(f);
+ }
+}
+
+static void dom_check(ir_node *irn, void *data)
+{
+ if(!is_Block(irn) && irn != get_irg_end(get_irn_irg(irn))) {
+ int i, n;
+ ir_node *bl = get_nodes_block(irn);
+
+ for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
+ ir_node *op = get_irn_n(irn, i);
+ ir_node *def_bl = get_nodes_block(op);
+ ir_node *use_bl = bl;
+
+ if(is_Phi(irn))
+ use_bl = get_Block_cfgpred_block(bl, i);
+
+ if(!block_dominates(def_bl, use_bl)) {
+ ir_fprintf(stderr, "%+F in %+F must dominate %+F for user %+F\n", op, def_bl, use_bl, irn);
+ assert(0);
+ }
+ }
+ }
+}
+
+void be_check_dominance(ir_graph *irg)
+{
+ irg_walk_graph(irg, dom_check, NULL, NULL);
+}