12 #include "besched_t.h"
15 static void dump_allocated_block(ir_node *block, void *env)
21 ir_fprintf(f, "node:{title:\"b%N\"\nlabel:\"%n\n", block, block);
22 sched_foreach(block, irn) {
23 const char *prefix = "";
26 if(is_color(get_irn_color(irn)))
27 ir_fprintf(f, "r%d = ", get_irn_color(irn));
28 ir_fprintf(f, "%n(", irn);
30 if(block != get_irg_start_block(get_irn_irg(block))) {
31 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
32 ir_node *op = get_irn_n(irn, i);
33 if(is_allocatable_irn(op)) {
34 ir_fprintf(f, "%sr%d", prefix, get_irn_color(op));
42 ir_fprintf(f, "\"}\n");
44 if(get_irg_start_block(get_irn_irg(block)) != block) {
45 for(i = 0, n = get_irn_arity(block); i < n; ++i) {
46 ir_node *pred_bl = get_nodes_block(get_irn_n(block, i));
47 ir_fprintf(f, "edge:{sourcename:\"b%N\" targetname:\"b%N\"}\n", pred_bl, block);
52 void dump_allocated_irg(ir_graph *irg, char *suffix)
57 snprintf(buf, sizeof(buf), "%s-alloc%s.vcg", get_entity_name(get_irg_entity(irg)), suffix);
59 if((f = fopen(buf, "wt")) != NULL) {
60 fprintf(f, "graph:{title:\"prg\"\n");
61 irg_block_walk_graph(irg, dump_allocated_block, NULL, f);
67 static void localize_const_walker(ir_node *irn, void *data)
72 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
73 ir_node *op = get_irn_n(irn, i);
74 if(get_irn_opcode(op) == iro_Const) {
75 ir_node *tgt_block, *cnst;
77 /* Special treatment for phi nodes, because phi-usage is different */
78 tgt_block = get_nodes_block(irn);
80 tgt_block = get_nodes_block(get_irn_n(tgt_block, i));
83 * We have to create the const node by ourselves, since the
84 * firmcons implementation always places it in the start block.
86 cnst = new_ir_node(NULL, get_irn_irg(irn),
87 tgt_block, op_Const, get_irn_mode(op), 0, NULL);
88 cnst->attr.con.tv = get_Const_tarval(op);
89 set_irn_n(irn, i, cnst);
95 void localize_consts(ir_graph *irg)
97 irg_walk_graph(irg, localize_const_walker, NULL, NULL);
98 dead_node_elimination(irg);