summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beutil.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2009-09-04 15:19:44 +0200
committerMatthias Braun <matze@braunis.de>2009-09-04 15:19:44 +0200
commit3910c38cb1f9dc1ec8792cd2b9234c802ab5ff9c (patch)
treee713213243ba6db761547cfe3af80ab93edfdd9f /ir/be/beutil.c
parent37a5b71805c64d63532e1dc10e37bfe516dbdc42 (diff)
new heursitic for good coloring order; add utility function to generate a postorder
[r26488]
Diffstat (limited to 'ir/be/beutil.c')
-rw-r--r--ir/be/beutil.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ir/be/beutil.c b/ir/be/beutil.c
index 07fd04a..2e884d0 100644
--- a/ir/be/beutil.c
+++ b/ir/be/beutil.c
@@ -163,3 +163,25 @@ FILE *be_ffopen(const char *base, const char *ext, const char *mode) {
}
return out;
}
+
+static void add_to_postorder(ir_node *block, void *data)
+{
+ ir_node ***list = (ir_node***) data;
+ ARR_APP1(ir_node*, *list, block);
+}
+
+ir_node **be_get_cfgpostorder(ir_graph *irg)
+{
+ ir_node **list = NEW_ARR_F(ir_node*, 0);
+ ir_node *end_block = get_irg_end_block(irg);
+
+ /* end block may be unreachable in case of endless loops */
+ if (get_Block_n_cfgpreds(end_block) == 0)
+ ARR_APP1(ir_node*, list, end_block);
+
+ /* walk blocks */
+ irg_block_edges_walk(get_irg_start_block(irg), NULL, add_to_postorder,
+ &list);
+
+ return list;
+}