#include "bedump.h"
#include "irdump_t.h"
+#include "irgwalk.h"
#include "beifg.h"
#include "becopyopt_t.h"
+#include "belive_t.h"
static void dump_ifg_nodes(FILE *F, const be_ifg_t *ifg)
{
if (get_irn_node_nr(node) >= get_irn_node_nr(neighbour))
continue;
- fprintf(F, "edge: {sourcename: \"");
- PRINT_NODEID(node);
- fprintf(F, "\" targetname: \"");
- PRINT_NODEID(neighbour);
- fprintf(F, "\" arrowstyle:none class:1}\n");
+ fprintf(F, "edge: {sourcename: ");
+ print_nodeid(F, node);
+ fprintf(F, " targetname: ");
+ print_nodeid(F, neighbour);
+ fprintf(F, " arrowstyle:none class:1}\n");
}
}
}
if (get_irn_node_nr(a->irn) >= get_irn_node_nr(n->irn))
continue;
- fprintf(F, "edge: {sourcename: \"");
- PRINT_NODEID(a->irn);
- fprintf(F, "\" targetname: \"");
- PRINT_NODEID(n->irn);
- fprintf(F, "\" arrowstyle:none");
+ fprintf(F, "edge: {sourcename: ");
+ print_nodeid(F, a->irn);
+ fprintf(F, " targetname: ");
+ print_nodeid(F, n->irn);
+ fprintf(F, " arrowstyle:none");
if (dump_costs)
fprintf(F, " label:\"%d\"", n->costs);
fprintf(F, "}\n");
}
+
+static const char *lv_flags_to_str(unsigned flags)
+{
+ static const char *states[] = {
+ "---",
+ "i--",
+ "-e-",
+ "ie-",
+ "--o",
+ "i-o",
+ "-eo",
+ "ieo"
+ };
+
+ return states[flags & 7];
+}
+
+void be_dump_liveness_block(void *context, FILE *F, const ir_node *bl)
+{
+ if (is_Block(bl)) {
+ be_lv_t *lv = (be_lv_t*)context;
+ be_lv_info_t *info = (be_lv_info_t*)ir_nodehashmap_get(&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), get_idx_irn(lv->irg, n->idx));
+ }
+ }
+ }
+}
+
+typedef struct lv_walker_t {
+ be_lv_t *lv;
+ void *data;
+} 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);
+}
+
+void be_liveness_dump(FILE *F, const be_lv_t *lv)
+{
+ lv_walker_t w;
+
+ w.lv = (be_lv_t *) lv;
+ w.data = F;
+ irg_block_walk_graph(lv->irg, lv_dump_block_walker, NULL, &w);
+}