+static void dump_whole_node(ir_node *n, void* env);
+static INLINE void dump_loop_nodes_into_graph(ir_graph *irg);
+
+/*******************************************************************/
+/* Helper functions. */
+/*******************************************************************/
+
+/* Use private link attr to be able to call dumper anywhere without
+ destroying link fields. */
+
+static pmap *irdump_link_map = NULL;
+
+static void init_irdump(void) {
+ /* We need a new, empty map. */
+ if (irdump_link_map) pmap_destroy(irdump_link_map);
+ irdump_link_map = pmap_create();
+}
+
+
+void *ird_get_irn_link(ir_node *n) {
+ void *res = NULL;
+ if (!irdump_link_map) return NULL;
+
+ if (pmap_contains(irdump_link_map, (void *)n))
+ res = pmap_get(irdump_link_map, (void *)n);
+ return res;
+}
+
+void ird_set_irn_link(ir_node *n, void *x) {
+ if (!irdump_link_map) init_irdump();
+ pmap_insert(irdump_link_map, (void *)n, x);
+}
+
+void *ird_get_irg_link(ir_graph *irg) {
+ void *res = NULL;
+ if (!irdump_link_map) return NULL;
+
+ if (pmap_contains(irdump_link_map, (void *)irg))
+ res = pmap_get(irdump_link_map, (void *)irg);
+ return res;
+}
+
+void ird_set_irg_link(ir_graph *irg, void *x) {
+ if (!irdump_link_map) init_irdump();
+ pmap_insert(irdump_link_map, (void *)irg, x);
+}
+
+static void clear_link(ir_node * node, void * env) {
+ ird_set_irn_link(node, NULL);
+}
+
+
+static int node_floats(ir_node *n) {
+ return ((get_op_pinned(get_irn_op(n)) == floats) &&
+ (get_irg_pinned(current_ir_graph) == floats));
+}
+
+static const char *get_ent_dump_name(entity *ent) {
+ if (! ent)
+ return "<NULL entity>";
+ /* Don't use get_entity_ld_ident (ent) as it computes the mangled name! */
+ if (ent->ld_name) return get_id_str(ent->ld_name);
+ return get_id_str(ent->name);
+}
+
+static const char *get_irg_dump_name(ir_graph *irg) {
+ /* Don't use get_entity_ld_ident (ent) as it computes the mangled name! */
+ entity *ent = get_irg_ent(irg);
+ return get_ent_dump_name(ent);
+}
+
+static void collect_node(ir_node * node, void *env) {
+ if (is_Block(node)
+ || node_floats(node)
+ || get_irn_op(node) == op_Bad
+ || get_irn_op(node) == op_Unknown) {
+ ir_node ** arr = (ir_node **) ird_get_irg_link(get_irn_irg(node));
+ if (!arr) arr = NEW_ARR_F(ir_node *, 0);
+ ARR_APP1(ir_node *, arr, node);
+ ird_set_irg_link(get_irn_irg(node), arr); /* arr is an l-value, APP_ARR might change it! */
+ } else {
+ ir_node * block = get_nodes_block(node);
+ ird_set_irn_link(node, ird_get_irn_link(block));
+ ird_set_irn_link(block, node);
+ }
+}
+
+/** Construct lists to walk ir block-wise.
+ *
+ * Collects all blocks, nodes not pinned,
+ * Bad and Unknown into a flexible array in link field of
+ * irg they belong to. Sets the irg link field to NULL in all
+ * graphs not visited.
+ * Free the list with DEL_ARR_F. */
+static ir_node ** construct_block_lists(ir_graph *irg) {
+ int i;
+ ir_graph *rem = current_ir_graph;
+ current_ir_graph = irg;
+
+ for (i = 0; i < get_irp_n_irgs(); i++)
+ ird_set_irg_link(get_irp_irg(i), NULL);
+
+ irg_walk_graph(current_ir_graph, clear_link, collect_node, current_ir_graph);
+
+ current_ir_graph = rem;
+ return ird_get_irg_link(irg);
+}
+
+/*******************************************************************/
+/* flags to steer output */
+/*******************************************************************/
+