15 #include "besched_t.h"
18 static void dump_allocated_block(ir_node *block, void *env)
24 ir_fprintf(f, "node:{title:\"b%N\"\nlabel:\"%n\n", block, block);
25 sched_foreach(block, irn) {
26 const char *prefix = "";
29 if(is_color(get_irn_color(irn)))
30 ir_fprintf(f, "r%d = ", get_irn_color(irn));
31 ir_fprintf(f, "%n(", irn);
33 if(block != get_irg_start_block(get_irn_irg(block))) {
34 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
35 ir_node *op = get_irn_n(irn, i);
36 if(is_allocatable_irn(op)) {
37 ir_fprintf(f, "%sr%d", prefix, get_irn_color(op));
45 ir_fprintf(f, "\"}\n");
47 if(get_irg_start_block(get_irn_irg(block)) != block) {
48 for(i = 0, n = get_irn_arity(block); i < n; ++i) {
49 ir_node *pred_bl = get_nodes_block(get_irn_n(block, i));
50 ir_fprintf(f, "edge:{sourcename:\"b%N\" targetname:\"b%N\"}\n", pred_bl, block);
55 void dump_allocated_irg(ir_graph *irg, char *suffix)
60 snprintf(buf, sizeof(buf), "%s-alloc%s.vcg", get_entity_name(get_irg_entity(irg)), suffix);
62 if((f = fopen(buf, "wt")) != NULL) {
63 fprintf(f, "graph:{title:\"prg\"\n");
64 irg_block_walk_graph(irg, dump_allocated_block, NULL, f);
70 static void localize_const_walker(ir_node *irn, void *data)
75 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
76 ir_node *op = get_irn_n(irn, i);
77 if(get_irn_opcode(op) == iro_Const) {
78 ir_node *tgt_block, *cnst;
80 /* Special treatment for phi nodes, because phi-usage is different */
81 tgt_block = get_nodes_block(irn);
83 tgt_block = get_nodes_block(get_irn_n(tgt_block, i));
86 * We have to create the const node by ourselves, since the
87 * firmcons implementation always places it in the start block.
89 cnst = new_ir_node(NULL, get_irn_irg(irn),
90 tgt_block, op_Const, get_irn_mode(op), 0, NULL);
91 cnst->attr.con.tv = get_Const_tarval(op);
92 set_irn_n(irn, i, cnst);
98 void localize_consts(ir_graph *irg)
100 irg_walk_graph(irg, localize_const_walker, NULL, NULL);
101 dead_node_elimination(irg);