15 #include "besched_t.h"
23 static void dump_allocated_block(ir_node *block, void *data)
27 struct dump_env *dump_env = data;
28 FILE *f = dump_env->f;
29 arch_env_t *env = dump_env->env;
31 ir_fprintf(f, "node:{title:\"b%N\"\nlabel:\"%n\n", block, block);
32 sched_foreach(block, irn) {
33 const char *prefix = "";
34 const arch_register_t *reg = arch_get_irn_register(env, irn, 0);
38 ir_fprintf(f, "%s = ", arch_register_get_name(reg));
39 ir_fprintf(f, "%n(", irn);
41 if(block != get_irg_start_block(get_irn_irg(block))) {
42 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
43 ir_node *op = get_irn_n(irn, i);
44 if(arch_is_register_operand(dump_env->env, op, arch_pos_make_out(0))) {
45 ir_fprintf(f, "%s%s", prefix,
46 arch_register_get_name(arch_get_irn_register(env, op, 0)));
54 ir_fprintf(f, "\"}\n");
56 if(get_irg_start_block(get_irn_irg(block)) != block) {
57 for(i = 0, n = get_irn_arity(block); i < n; ++i) {
58 ir_node *pred_bl = get_nodes_block(get_irn_n(block, i));
59 ir_fprintf(f, "edge:{sourcename:\"b%N\" targetname:\"b%N\"}\n", pred_bl, block);
64 void dump_allocated_irg(arch_env_t *arch_env, ir_graph *irg, char *suffix)
71 ir_snprintf(buf, sizeof(buf), "%F-alloc%s.vcg", irg, suffix);
73 if((env.f = fopen(buf, "wt")) != NULL) {
74 fprintf(env.f, "graph:{title:\"prg\"\n");
75 irg_block_walk_graph(irg, dump_allocated_block, NULL, &env);
76 fprintf(env.f, "}\n");
81 static void localize_const_walker(ir_node *irn, void *data)
86 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
87 ir_node *op = get_irn_n(irn, i);
88 if(get_irn_opcode(op) == iro_Const) {
89 ir_node *tgt_block, *cnst;
91 /* Special treatment for phi nodes, because phi-usage is different */
92 tgt_block = get_nodes_block(irn);
94 tgt_block = get_nodes_block(get_irn_n(tgt_block, i));
97 * We have to create the const node by ourselves, since the
98 * firmcons implementation always places it in the start block.
100 cnst = new_ir_node(NULL, get_irn_irg(irn),
101 tgt_block, op_Const, get_irn_mode(op), 0, NULL);
102 cnst->attr.con.tv = get_Const_tarval(op);
103 set_irn_n(irn, i, cnst);
109 void localize_consts(ir_graph *irg)
111 irg_walk_graph(irg, localize_const_walker, NULL, NULL);
112 dead_node_elimination(irg);