summaryrefslogtreecommitdiffhomepage
path: root/ir/be/bedump.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2011-12-02 21:41:26 +0100
committerMatthias Braun <matze@braunis.de>2011-12-05 12:52:03 +0100
commitee7d02f0224c71ad158f07c193d731ad7762c884 (patch)
tree30b01eabee13674d2337a7aaaad63ba5162688d2 /ir/be/bedump.c
parent979e11a67115604f5ca3050ad2fab08d190a13e8 (diff)
belive: move dumper to bedump, checker to beverify
Diffstat (limited to 'ir/be/bedump.c')
-rw-r--r--ir/be/bedump.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/ir/be/bedump.c b/ir/be/bedump.c
index 5e478c5..74dc9fe 100644
--- a/ir/be/bedump.c
+++ b/ir/be/bedump.c
@@ -27,8 +27,10 @@
#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)
{
@@ -132,3 +134,60 @@ void be_dump_ifg_co(FILE *F, const copy_opt_t *co, bool dump_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);
+}